From 30ec16f3473772c3792e12912649a4c73c0025cd Mon Sep 17 00:00:00 2001 From: Ibrahim Zidan Date: Sat, 11 May 2019 16:23:51 +0200 Subject: [PATCH 1/6] Move enum achievement_types entries from constants.conf to script.c Signed-off-by: Ibrahim Zidan --- db/constants.conf | 48 ----------------------------------------------- src/map/script.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/db/constants.conf b/db/constants.conf index b3dd902a413..6af31d89a9b 100644 --- a/db/constants.conf +++ b/db/constants.conf @@ -3949,54 +3949,6 @@ constants_db: { HAT_DIGITAL_SPACE: 87 HAT_EF_SLEIPNIR: 88 - comment__: "Achievement Types" - ACH_QUEST: 0 - ACH_KILL_PC_TOTAL: 1 - ACH_KILL_PC_JOB: 2 - ACH_KILL_PC_JOBTYPE: 3 - ACH_KILL_MOB_CLASS: 4 - ACH_DAMAGE_PC_MAX: 5 - ACH_DAMAGE_PC_TOTAL: 6 - ACH_DAMAGE_PC_REC_MAX: 7 - ACH_DAMAGE_PC_REC_TOTAL: 8 - ACH_DAMAGE_MOB_MAX: 9 - ACH_DAMAGE_MOB_TOTAL: 10 - ACH_DAMAGE_MOB_REC_MAX: 11 - ACH_DAMAGE_MOB_REC_TOTAL: 12 - ACH_JOB_CHANGE: 13 - ACH_STATUS: 14 - ACH_STATUS_BY_JOB: 15 - ACH_STATUS_BY_JOBTYPE: 16 - ACH_CHATROOM_CREATE_DEAD: 17 - ACH_CHATROOM_CREATE: 18 - ACH_CHATROOM_MEMBERS: 19 - ACH_FRIEND_ADD: 20 - ACH_PARTY_CREATE: 21 - ACH_PARTY_JOIN: 22 - ACH_MARRY: 23 - ACH_ADOPT_BABY: 24 - ACH_ADOPT_PARENT: 25 - ACH_ZENY_HOLD: 26 - ACH_ZENY_GET_ONCE: 27 - ACH_ZENY_GET_TOTAL: 28 - ACH_ZENY_SPEND_ONCE: 29 - ACH_ZENY_SPEND_TOTAL: 30 - ACH_EQUIP_REFINE_SUCCESS: 31 - ACH_EQUIP_REFINE_FAILURE: 32 - ACH_EQUIP_REFINE_SUCCESS_TOTAL: 33 - ACH_EQUIP_REFINE_FAILURE_TOTAL: 34 - ACH_EQUIP_REFINE_SUCCESS_WLV: 35 - ACH_EQUIP_REFINE_FAILURE_WLV: 36 - ACH_EQUIP_REFINE_SUCCESS_ID: 37 - ACH_EQUIP_REFINE_FAILURE_ID: 38 - ACH_ITEM_GET_COUNT: 39 - ACH_ITEM_GET_COUNT_ITEMTYPE: 40 - ACH_ITEM_GET_WORTH: 41 - ACH_ITEM_SELL_WORTH: 42 - ACH_PET_CREATE: 43 - ACH_ACHIEVE: 44 - ACH_ACHIEVEMENT_RANK: 45 - comment__: "inventory expansion" INVENTORY_INCREASE_STEP: 10 } diff --git a/src/map/script.c b/src/map/script.c index 5843ac29299..9fc56e735de 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -26600,6 +26600,54 @@ static void script_hardcoded_constants(void) script->set_constant("UDT_BODY2", UDT_BODY2, false, false); script->set_constant("UDT_GROUP", UDT_GROUP, false, false); + script->constdb_comment("Achievement Types"); + script->set_constant("ACH_QUEST", ACH_QUEST, false, false); + script->set_constant("ACH_KILL_PC_TOTAL", ACH_KILL_PC_TOTAL, false, false); + script->set_constant("ACH_KILL_PC_JOB", ACH_KILL_PC_JOB, false, false); + script->set_constant("ACH_KILL_PC_JOBTYPE", ACH_KILL_PC_JOBTYPE, false, false); + script->set_constant("ACH_KILL_MOB_CLASS", ACH_KILL_MOB_CLASS, false, false); + script->set_constant("ACH_DAMAGE_PC_MAX", ACH_DAMAGE_PC_MAX, false, false); + script->set_constant("ACH_DAMAGE_PC_TOTAL", ACH_DAMAGE_PC_TOTAL, false, false); + script->set_constant("ACH_DAMAGE_PC_REC_MAX", ACH_DAMAGE_PC_REC_MAX, false, false); + script->set_constant("ACH_DAMAGE_PC_REC_TOTAL", ACH_DAMAGE_PC_REC_TOTAL, false, false); + script->set_constant("ACH_DAMAGE_MOB_MAX", ACH_DAMAGE_MOB_MAX, false, false); + script->set_constant("ACH_DAMAGE_MOB_TOTAL", ACH_DAMAGE_MOB_TOTAL, false, false); + script->set_constant("ACH_DAMAGE_MOB_REC_MAX", ACH_DAMAGE_MOB_REC_MAX, false, false); + script->set_constant("ACH_DAMAGE_MOB_REC_TOTAL", ACH_DAMAGE_MOB_REC_TOTAL, false, false); + script->set_constant("ACH_JOB_CHANGE", ACH_JOB_CHANGE, false, false); + script->set_constant("ACH_STATUS", ACH_STATUS, false, false); + script->set_constant("ACH_STATUS_BY_JOB", ACH_STATUS_BY_JOB, false, false); + script->set_constant("ACH_STATUS_BY_JOBTYPE", ACH_STATUS_BY_JOBTYPE, false, false); + script->set_constant("ACH_CHATROOM_CREATE_DEAD", ACH_CHATROOM_CREATE_DEAD, false, false); + script->set_constant("ACH_CHATROOM_CREATE", ACH_CHATROOM_CREATE, false, false); + script->set_constant("ACH_CHATROOM_MEMBERS", ACH_CHATROOM_MEMBERS, false, false); + script->set_constant("ACH_FRIEND_ADD", ACH_FRIEND_ADD, false, false); + script->set_constant("ACH_PARTY_CREATE", ACH_PARTY_CREATE, false, false); + script->set_constant("ACH_PARTY_JOIN", ACH_PARTY_JOIN, false, false); + script->set_constant("ACH_MARRY", ACH_MARRY, false, false); + script->set_constant("ACH_ADOPT_BABY", ACH_ADOPT_BABY, false, false); + script->set_constant("ACH_ADOPT_PARENT", ACH_ADOPT_PARENT, false, false); + script->set_constant("ACH_ZENY_HOLD", ACH_ZENY_HOLD, false, false); + script->set_constant("ACH_ZENY_GET_ONCE", ACH_ZENY_GET_ONCE, false, false); + script->set_constant("ACH_ZENY_GET_TOTAL", ACH_ZENY_GET_TOTAL, false, false); + script->set_constant("ACH_ZENY_SPEND_ONCE", ACH_ZENY_SPEND_ONCE, false, false); + script->set_constant("ACH_ZENY_SPEND_TOTAL", ACH_ZENY_SPEND_TOTAL, false, false); + script->set_constant("ACH_EQUIP_REFINE_SUCCESS", ACH_EQUIP_REFINE_SUCCESS, false, false); + script->set_constant("ACH_EQUIP_REFINE_FAILURE", ACH_EQUIP_REFINE_FAILURE, false, false); + script->set_constant("ACH_EQUIP_REFINE_SUCCESS_TOTAL", ACH_EQUIP_REFINE_SUCCESS_TOTAL, false, false); + script->set_constant("ACH_EQUIP_REFINE_FAILURE_TOTAL", ACH_EQUIP_REFINE_FAILURE_TOTAL, false, false); + script->set_constant("ACH_EQUIP_REFINE_SUCCESS_WLV", ACH_EQUIP_REFINE_SUCCESS_WLV, false, false); + script->set_constant("ACH_EQUIP_REFINE_FAILURE_WLV", ACH_EQUIP_REFINE_FAILURE_WLV, false, false); + script->set_constant("ACH_EQUIP_REFINE_SUCCESS_ID", ACH_EQUIP_REFINE_SUCCESS_ID, false, false); + script->set_constant("ACH_EQUIP_REFINE_FAILURE_ID", ACH_EQUIP_REFINE_FAILURE_ID, false, false); + script->set_constant("ACH_ITEM_GET_COUNT", ACH_ITEM_GET_COUNT, false, false); + script->set_constant("ACH_ITEM_GET_COUNT_ITEMTYPE", ACH_ITEM_GET_COUNT_ITEMTYPE, false, false); + script->set_constant("ACH_ITEM_GET_WORTH", ACH_ITEM_GET_WORTH, false, false); + script->set_constant("ACH_ITEM_SELL_WORTH", ACH_ITEM_SELL_WORTH, false, false); + script->set_constant("ACH_PET_CREATE", ACH_PET_CREATE, false, false); + script->set_constant("ACH_ACHIEVE", ACH_ACHIEVE, false, false); + script->set_constant("ACH_ACHIEVEMENT_RANK", ACH_ACHIEVEMENT_RANK, false, false); + script->constdb_comment("Renewal"); #ifdef RENEWAL script->set_constant("RENEWAL", 1, false, false); From 9bcd4f47c67378db2c9f78e80a98ef49a3efcabd Mon Sep 17 00:00:00 2001 From: Ibrahim Zidan Date: Sat, 11 May 2019 18:30:02 +0200 Subject: [PATCH 2/6] Implement ACH_ZENY_SPEND_VENDING and ACH_ZENY_SPEND_VENDING_TOTAL A new achievement type that triggers on spending zeny on vendors Signed-off-by: Ibrahim Zidan --- db/pre-re/achievement_db.conf | 2 ++ db/re/achievement_db.conf | 2 ++ src/map/achievement.c | 24 ++++++++++++++++++++++++ src/map/achievement.h | 3 +++ src/map/script.c | 2 ++ src/map/vending.c | 3 +++ 6 files changed, 36 insertions(+) diff --git a/db/pre-re/achievement_db.conf b/db/pre-re/achievement_db.conf index db63ed4a885..79ef3128029 100644 --- a/db/pre-re/achievement_db.conf +++ b/db/pre-re/achievement_db.conf @@ -67,6 +67,8 @@ achievement_db: ( ACH_ZENY_GET_TOTAL: (Accumulative) Gain a specific amount of zeny in total. (Gain Zeny) ACH_ZENY_SPEND_ONCE: Spend a specific amount of zeny in one transaction. (Pay Zeny) ACH_ZENY_SPEND_TOTAL: (Accumulative) Spend a specific amount of zeny in total. (Pay Zeny) + ACH_ZENY_SPEND_VENDING: Spend a specific amount of zeny in one transaction to a vending player + ACH_ZENY_SPEND_VENDING_TOTAL: (Accumulative) Spend a specific amount of zeny in one transaction to a vending player ACH_EQUIP_REFINE_SUCCESS: Refine an item to +N. (Successful Refine) ACH_EQUIP_REFINE_FAILURE: Fail to refine an item of +N refine. (Failed Refine) ACH_EQUIP_REFINE_SUCCESS_TOTAL: (Accumulative) Refine an item successfully N times. (Success Refine) diff --git a/db/re/achievement_db.conf b/db/re/achievement_db.conf index e54a1d92425..76a12707fae 100644 --- a/db/re/achievement_db.conf +++ b/db/re/achievement_db.conf @@ -67,6 +67,8 @@ achievement_db: ( ACH_ZENY_GET_TOTAL: (Accumulative) Gain a specific amount of zeny in total. (Gain Zeny) ACH_ZENY_SPEND_ONCE: Spend a specific amount of zeny in one transaction. (Pay Zeny) ACH_ZENY_SPEND_TOTAL: (Accumulative) Spend a specific amount of zeny in total. (Pay Zeny) + ACH_ZENY_SPEND_VENDING: Spend a specific amount of zeny in one transaction to a vending player + ACH_ZENY_SPEND_VENDING_TOTAL: (Accumulative) Spend a specific amount of zeny in total to a vending player ACH_EQUIP_REFINE_SUCCESS: Refine an item to +N. (Successful Refine) ACH_EQUIP_REFINE_FAILURE: Fail to refine an item of +N refine. (Failed Refine) ACH_EQUIP_REFINE_SUCCESS_TOTAL: (Accumulative) Refine an item successfully N times. (Success Refine) diff --git a/src/map/achievement.c b/src/map/achievement.c index 7ab80e183b6..d807bf34aa6 100644 --- a/src/map/achievement.c +++ b/src/map/achievement.c @@ -745,6 +745,29 @@ static void achievement_validate_zeny(struct map_session_data *sd, int amount) } } +/** + * Validates zeny type objectives. + * @types ACH_ZENY_SPEND_VENDING + * ACH_ZENY_SPEND_VENDING_TOTAL + * @param[in] sd pointer to session data. + * @param[in] amount (goal) amount of zeny spent. + * @see achievement_validate_type() + */ +static void achievement_validate_zeny_vending(struct map_session_data *sd, int amount) +{ + nullpo_retv(sd); + Assert_retv(amount > 0); + + if (!sd->achievements_received) + return; + + struct achievement_objective criteria = {0}; + criteria.goal = amount; + + achievement->validate_type(sd, ACH_ZENY_SPEND_VENDING, &criteria, false); + achievement->validate_type(sd, ACH_ZENY_SPEND_VENDING_TOTAL, &criteria, true); +} + /** * Validates equipment refinement type objectives. * @types ACH_EQUIP_REFINE_SUCCESS @@ -1991,6 +2014,7 @@ void achievement_defaults(void) achievement->validate_marry = achievement_validate_marry; achievement->validate_adopt = achievement_validate_adopt; achievement->validate_zeny = achievement_validate_zeny; + achievement->validate_zeny_vending = achievement_validate_zeny_vending; achievement->validate_refine = achievement_validate_refine; achievement->validate_item_get = achievement_validate_item_get; achievement->validate_item_sell = achievement_validate_item_sell; diff --git a/src/map/achievement.h b/src/map/achievement.h index de5eaa0607b..2e034183320 100644 --- a/src/map/achievement.h +++ b/src/map/achievement.h @@ -99,6 +99,8 @@ enum achievement_types { // Achievement ACH_ACHIEVE, ACH_ACHIEVEMENT_RANK, + ACH_ZENY_SPEND_VENDING, + ACH_ZENY_SPEND_VENDING_TOTAL, ACH_TYPE_MAX }; @@ -266,6 +268,7 @@ struct achievement_interface { void (*validate_marry) (struct map_session_data *sd); void (*validate_adopt) (struct map_session_data *sd, bool parent); void (*validate_zeny) (struct map_session_data *sd, int amount); + void (*validate_zeny_vending) (struct map_session_data *sd, int amount); void (*validate_refine) (struct map_session_data *sd, unsigned int idx, bool success); void (*validate_item_get) (struct map_session_data *sd, int nameid, int amount); void (*validate_item_sell) (struct map_session_data *sd, int nameid, int amount); diff --git a/src/map/script.c b/src/map/script.c index 9fc56e735de..30a6919cdad 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -26647,6 +26647,8 @@ static void script_hardcoded_constants(void) script->set_constant("ACH_PET_CREATE", ACH_PET_CREATE, false, false); script->set_constant("ACH_ACHIEVE", ACH_ACHIEVE, false, false); script->set_constant("ACH_ACHIEVEMENT_RANK", ACH_ACHIEVEMENT_RANK, false, false); + script->set_constant("ACH_ZENY_SPEND_VENDING", ACH_ZENY_SPEND_VENDING, false, false); + script->set_constant("ACH_ZENY_SPEND_VENDING_TOTAL", ACH_ZENY_SPEND_VENDING_TOTAL, false, false); script->constdb_comment("Renewal"); #ifdef RENEWAL diff --git a/src/map/vending.c b/src/map/vending.c index 692f5f378ae..5937ef15429 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -22,6 +22,7 @@ #include "vending.h" +#include "map/achievement.h" #include "map/atcommand.h" #include "map/battle.h" #include "map/chrif.h" @@ -184,6 +185,8 @@ static void vending_purchasereq(struct map_session_data *sd, int aid, unsigned i } pc->payzeny(sd, (int)z, LOG_TYPE_VENDING, vsd); + achievement->validate_zeny_vending(sd, (int)z); + if( battle_config.vending_tax ) z -= apply_percentrate64(z, battle_config.vending_tax, 10000); pc->getzeny(vsd, (int)z, LOG_TYPE_VENDING, sd); From 23eb25b49132b53076af87fb089e7974cb434a36 Mon Sep 17 00:00:00 2001 From: Ibrahim Zidan Date: Sat, 11 May 2019 18:34:11 +0200 Subject: [PATCH 3/6] Update MonsterId criteria to accept 0 as Monster ID for a wildcard achievements This also corrects the documentation of ACH_KILL_MOB_CLASS achievement type as it was missing the mention of being accumulative Signed-off-by: Ibrahim Zidan --- db/pre-re/achievement_db.conf | 5 +++-- db/re/achievement_db.conf | 5 +++-- src/map/achievement.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/db/pre-re/achievement_db.conf b/db/pre-re/achievement_db.conf index 79ef3128029..3f3a24109ff 100644 --- a/db/pre-re/achievement_db.conf +++ b/db/pre-re/achievement_db.conf @@ -40,7 +40,7 @@ achievement_db: ( ACH_KILL_PC_TOTAL: (Accumulative) Total kill count. (Player kill) ACH_KILL_PC_JOB: Kill a player of the specified job. (Player Kill) ACH_KILL_PC_JOBTYPE: Kill a player of the specified job type. (Player Kill) - ACH_KILL_MOB_CLASS: Kill a particular mob class. (Mob Kill) + ACH_KILL_MOB_CLASS: (Accumulative) Kill a particular mob class. (Mob Kill) ACH_DAMAGE_PC_MAX: Maximum damage caused on a player. (Player Damage) ACH_DAMAGE_PC_TOTAL: (Accumulative) Damage on players. (Player Damage) ACH_DAMAGE_PC_REC_MAX: Maximum damage received by a player. (Receive Player Damage) @@ -91,7 +91,8 @@ achievement_db: ( Criteria: { This is a field for achievements whose objectives must meet certain criteria before evaluating the player's progress for it. MobId: (mixed) MonsterId required for an objective. - For types such as ACH_KILL_MOB_CLASS and ACH_PET_CREATE. Can be either int or string constant. + For types such as ACH_KILL_MOB_CLASS and ACH_PET_CREATE. + Can be either int or string constant. If set to 0 would apply to any monster. JobId: (mixed) Array or Single entry of JobIds. For types - ACH_KILL_PC_JOBTYPE, ACH_JOB_CHANGE or ACH_STATUS_BY_JOBTYPE. Can be either a numeric or string constant. diff --git a/db/re/achievement_db.conf b/db/re/achievement_db.conf index 76a12707fae..9103dae6385 100644 --- a/db/re/achievement_db.conf +++ b/db/re/achievement_db.conf @@ -40,7 +40,7 @@ achievement_db: ( ACH_KILL_PC_TOTAL: (Accumulative) Total kill count. (Player kill) ACH_KILL_PC_JOB: Kill a player of the specified job. (Player Kill) ACH_KILL_PC_JOBTYPE: Kill a player of the specified job type. (Player Kill) - ACH_KILL_MOB_CLASS: Kill a particular mob class. (Mob Kill) + ACH_KILL_MOB_CLASS: (Accumulative) Kill a particular mob class. (Mob Kill) ACH_DAMAGE_PC_MAX: Maximum damage caused on a player. (Player Damage) ACH_DAMAGE_PC_TOTAL: (Accumulative) Damage on players. (Player Damage) ACH_DAMAGE_PC_REC_MAX: Maximum damage received by a player. (Receive Player Damage) @@ -91,7 +91,8 @@ achievement_db: ( Criteria: { This is a field for achievements whose objectives must meet certain criteria before evaluating the player's progress for it. MobId: (mixed) MonsterId required for an objective. - For types such as ACH_KILL_MOB_CLASS and ACH_PET_CREATE. Can be either int or string constant. + For types such as ACH_KILL_MOB_CLASS and ACH_PET_CREATE. + Can be either int or string constant. If set to 0 would apply to any monster. JobId: (mixed) Array or Single entry of JobIds. For types - ACH_KILL_PC_JOBTYPE, ACH_JOB_CHANGE or ACH_STATUS_BY_JOBTYPE. Can be either a numeric or string constant. diff --git a/src/map/achievement.c b/src/map/achievement.c index d807bf34aa6..5ec9cbe3d85 100644 --- a/src/map/achievement.c +++ b/src/map/achievement.c @@ -1195,7 +1195,7 @@ static bool achievement_readdb_validate_criteria_mobid(const struct config_setti nullpo_retr(false, obj); if (libconfig->setting_lookup_int(t, "MobId", &val)) { - if (mob->db_checkid(val) == 0) { + if (val != 0 && mob->db_checkid(val) == 0) { ShowError("achievement_readdb_validate_criteria_mobid: Non-existant monster with ID %id provided (Achievement: %d, Objective: %d). Skipping...\n", val, entry_id, obj_idx); return false; } From f3cae0b9713ca0948725978ec23e6b5e21177e55 Mon Sep 17 00:00:00 2001 From: Ibrahim Zidan Date: Sun, 12 May 2019 10:13:38 +0200 Subject: [PATCH 4/6] Implemented ACH_PET_INTIMACY and ACH_PET_RUNAWAY, corrected ACH_PET_CREATE documentation. - ACH_PET_INTIMACY allows an achievement to be triggered when pet intimacy reaches a specific intimacy or higher - ACH_PET_RUNAWAY allows an achievement to be triggered when pet runsaway - ACH_PET_CREATE corrected the documentation to include it being accumulative Signed-off-by: Ibrahim Zidan --- db/pre-re/achievement_db.conf | 9 ++- db/re/achievement_db.conf | 9 ++- src/map/achievement.c | 100 +++++++++++++++++++++++++++++++--- src/map/achievement.h | 14 ++++- src/map/pet.c | 4 ++ src/map/script.c | 2 + 6 files changed, 126 insertions(+), 12 deletions(-) diff --git a/db/pre-re/achievement_db.conf b/db/pre-re/achievement_db.conf index 3f3a24109ff..e478c92d4b6 100644 --- a/db/pre-re/achievement_db.conf +++ b/db/pre-re/achievement_db.conf @@ -81,7 +81,9 @@ achievement_db: ( ACH_ITEM_GET_COUNT_ITEMTYPE: Acquire N amount of items of a particular type mask. (Acquire Item) ACH_ITEM_GET_WORTH: Acquire an item of buy value N. (Acquire Item) ACH_ITEM_SELL_WORTH: Sell an item of sell value N. (NPC Sell Item) - ACH_PET_CREATE: Successfully tame a pet of a particular mob class. (Successful Pet Tame) + ACH_PET_CREATE: (Accumulative) Successfully tame a pet of a particular mob class. (Successful Pet Tame) + ACH_PET_INTIMACY: (Accumulative) Successfully reach a specific pet intimacy + ACH_PET_RUNAWAY: (Accumulative) Successfully make a pet runaway ACH_ACHIEVE: Achieve an Achievement. (Achievement Completion) ACH_ACHIEVEMENT_RANK: Achieve an Achievement Rank. (Achievement Rank Increase) Objectives: { [Mandatory Field] Objectives of an achievement. Up to 10 objectives per achievement. @@ -91,7 +93,7 @@ achievement_db: ( Criteria: { This is a field for achievements whose objectives must meet certain criteria before evaluating the player's progress for it. MobId: (mixed) MonsterId required for an objective. - For types such as ACH_KILL_MOB_CLASS and ACH_PET_CREATE. + For types such as ACH_KILL_MOB_CLASS, ACH_PET_CREATE, ACH_PET_INTIMACY, ACH_PET_RUNAWAY. Can be either int or string constant. If set to 0 would apply to any monster. JobId: (mixed) Array or Single entry of JobIds. For types - ACH_KILL_PC_JOBTYPE, ACH_JOB_CHANGE or ACH_STATUS_BY_JOBTYPE. @@ -118,6 +120,9 @@ achievement_db: ( For Types such as ACH_EQUIP_REFINE_SUCCESS_WLV and ACH_EQUIP_REFINE_FAILURE_WLV. Achieve: (int) AchievementID to be achieved. For Type - ACH_ACHIEVE. + Intimacy: (int) For types such as ACH_PET_INTIMACY, The desired pet intimacy for this achievement, + unlike other criteria this one checked for equal or bigger than, since Intimacy is not increased + or decreased by a predictable amount } Goal: (int) Target amount to be met for the completion of the objective. Default is 1. } diff --git a/db/re/achievement_db.conf b/db/re/achievement_db.conf index 9103dae6385..175c6a3ed82 100644 --- a/db/re/achievement_db.conf +++ b/db/re/achievement_db.conf @@ -81,7 +81,9 @@ achievement_db: ( ACH_ITEM_GET_COUNT_ITEMTYPE: Acquire N amount of items of a particular type mask. (Acquire Item) ACH_ITEM_GET_WORTH: Acquire an item of buy value N. (Acquire Item) ACH_ITEM_SELL_WORTH: Sell an item of sell value N. (NPC Sell Item) - ACH_PET_CREATE: Successfully tame a pet of a particular mob class. (Successful Pet Tame) + ACH_PET_CREATE: (Accumulative) Successfully tame a pet of a particular mob class. (Successful Pet Tame) + ACH_PET_INTIMACY: (Accumulative) Successfully reach a specific pet intimacy + ACH_PET_RUNAWAY: (Accumulative) Successfully make a pet runaway ACH_ACHIEVE: Achieve an Achievement. (Achievement Completion) ACH_ACHIEVEMENT_RANK: Achieve an Achievement Rank. (Achievement Rank Increase) Objectives: { [Mandatory Field] Objectives of an achievement. Up to 10 objectives per achievement. @@ -91,7 +93,7 @@ achievement_db: ( Criteria: { This is a field for achievements whose objectives must meet certain criteria before evaluating the player's progress for it. MobId: (mixed) MonsterId required for an objective. - For types such as ACH_KILL_MOB_CLASS and ACH_PET_CREATE. + For types such as ACH_KILL_MOB_CLASS, ACH_PET_CREATE, ACH_PET_INTIMACY, ACH_PET_RUNAWAY. Can be either int or string constant. If set to 0 would apply to any monster. JobId: (mixed) Array or Single entry of JobIds. For types - ACH_KILL_PC_JOBTYPE, ACH_JOB_CHANGE or ACH_STATUS_BY_JOBTYPE. @@ -118,6 +120,9 @@ achievement_db: ( For Types such as ACH_EQUIP_REFINE_SUCCESS_WLV and ACH_EQUIP_REFINE_FAILURE_WLV. Achieve: (int) AchievementID to be achieved. For Type - ACH_ACHIEVE. + Intimacy: (int) For types such as ACH_PET_INTIMACY, The desired pet intimacy for this achievement, + unlike other criteria this one checked for equal or bigger than, since Intimacy is not increased + or decreased by a predictable amount } Goal: (int) Target amount to be met for the completion of the objective. Default is 1. } diff --git a/src/map/achievement.c b/src/map/achievement.c index 5ec9cbe3d85..39356646658 100644 --- a/src/map/achievement.c +++ b/src/map/achievement.c @@ -26,12 +26,14 @@ #include "map/itemdb.h" #include "map/mob.h" #include "map/party.h" +#include "map/pet.h" #include "map/pc.h" #include "map/script.h" #include "common/conf.h" #include "common/db.h" #include "common/memmgr.h" +#include "common/mmo.h" #include "common/nullpo.h" #include "common/showmsg.h" #include "common/strlib.h" @@ -280,6 +282,10 @@ static bool achievement_check_criteria(const struct achievement_objective *objec return false; } + /* Pet intimacy */ + if (objective->intimacy > 0 && objective->intimacy > criteria->intimacy) + return false; + return true; } @@ -928,14 +934,14 @@ static void achievement_validate_achieve(struct map_session_data *sd, int achid) } /** - * Validates taming type objectives. - * @type ACH_PET_CREATE - * @param[in] sd pointer to session data. - * @param[in] class (criteria) class of the monster tamed. - */ +* Validates taming type objectives. +* @type ACH_PET_CREATE +* @param[in] sd pointer to session data. +* @param[in] class (criteria) class of the monster tamed. +*/ static void achievement_validate_taming(struct map_session_data *sd, int class) { - struct achievement_objective criteria = { 0 }; + struct achievement_objective criteria = {0}; nullpo_retv(sd); @@ -951,6 +957,47 @@ static void achievement_validate_taming(struct map_session_data *sd, int class) achievement->validate_type(sd, ACH_PET_CREATE, &criteria, true); } +/** + * Validates pet intimacy type objectives. + * @type ACH_PET_INTIMACY + * @param[in] sd pointer to session data. + */ +static void achievement_validate_pet_intimacy(struct map_session_data *sd) +{ + nullpo_retv(sd); + nullpo_retv(sd->pd); + + if (sd->achievements_received == false) + return; + + struct achievement_objective criteria = {0}; + criteria.mobid = sd->pd->pet.class_; + criteria.intimacy = sd->pd->pet.intimate; + criteria.goal = 1; + + achievement->validate_type(sd, ACH_PET_INTIMACY, &criteria, true); +} + +/** +* Validates pet runaway type objectives. +* @type ACH_PET_RUNAWAY +* @param[in] sd pointer to session data. +* @param[in] class (criteria) class of the monster tamed. +*/ +static void achievement_validate_pet_runaway(struct map_session_data *sd, int class) +{ + nullpo_retv(sd); + + if (sd->achievements_received == false) + return; + + struct achievement_objective criteria = {0}; + criteria.mobid = class; + criteria.goal = 1; + + achievement->validate_type(sd, ACH_PET_RUNAWAY, &criteria, true); +} + /** * Validated achievement rank type objectives. * @type ACH_ACHIEVEMENT_RANK @@ -959,7 +1006,7 @@ static void achievement_validate_taming(struct map_session_data *sd, int class) */ static void achievement_validate_achievement_rank(struct map_session_data *sd, int rank) { - struct achievement_objective criteria = { 0 }; + struct achievement_objective criteria = {0}; nullpo_retv(sd); @@ -993,6 +1040,8 @@ static bool achievement_type_requires_criteria(enum achievement_types type) || type == ACH_EQUIP_REFINE_FAILURE_ID || type == ACH_ITEM_GET_COUNT || type == ACH_PET_CREATE + || type == ACH_PET_INTIMACY + || type == ACH_PET_RUNAWAY || type == ACH_ACHIEVE) return true; @@ -1531,6 +1580,36 @@ static bool achievement_readdb_validate_criteria_achievement(const struct config return true; } +/** + * Validates achievement Id criteria of an objective while parsing an achievement entry. + * @param[in] t pointer to the config setting. + * @param[out] obj pointer to the achievement objective entry being parsed. + * @param[in] type Type of the achievement being parsed. + * @param[in] entry_id Id of the entry being parsed. + * @param[in] obj_idx Index of the objective entry being parsed. + * @return false on failure, true on success. + */ +static bool achievement_readdb_validate_criteria_intimacy(const struct config_setting_t *t, struct achievement_objective *obj, enum achievement_types type, int entry_id, int obj_idx) +{ + nullpo_retr(false, t); + nullpo_retr(false, obj); + + int val = 0; + if (libconfig->setting_lookup_int(t, "Intimacy", &val)) { + if (val < 1 || val > 1000) { + ShowError("achievement_readdb_validate_criteria_intimacy: Invalid intimacy range given %d (Max: %d Low: %d). Skipping...\n", val, 1, 1000); + return false; + } + + obj->intimacy = val; + } else if (achievement_criteria_intimacy(type)) { + ShowError("achievement_readdb_validate_criteria_intimacy: Achievement type of ID %d requires an Intimacy field in the objective criteria, setting not provided. Skipping...\n", entry_id); + return false; + } + + return true; +} + /** * Read a single objective entry of an achievement. * @param[in] conf config pointer. @@ -1583,6 +1662,10 @@ static bool achievement_readdb_objective_sub(const struct config_setting_t *conf if (achievement->readdb_validate_criteria_achievement(c, &obj, entry->type, entry->id, index) == false) return false; + /* Intimacy */ + if (achievement->readdb_validate_criteria_intimacy(c, &obj, entry->type, entry->id, index) == false) + return false; + /** * Vectors are read last to avoid memory leaks if either of the above break, in cases where they are stacked with other criteria. * Note to future editors - be sure to cleanup previous vectors before breaks. @@ -1978,6 +2061,7 @@ void achievement_defaults(void) achievement->readdb_validate_criteria_itemtype = achievement_readdb_validate_criteria_itemtype; achievement->readdb_validate_criteria_weaponlv = achievement_readdb_validate_criteria_weaponlv; achievement->readdb_validate_criteria_achievement = achievement_readdb_validate_criteria_achievement; + achievement->readdb_validate_criteria_intimacy = achievement_readdb_validate_criteria_intimacy; /* */ achievement->readdb_rewards = achievement_readdb_rewards; achievement->readdb_validate_reward_items = achievement_readdb_validate_reward_items; @@ -2020,6 +2104,8 @@ void achievement_defaults(void) achievement->validate_item_sell = achievement_validate_item_sell; achievement->validate_achieve = achievement_validate_achieve; achievement->validate_taming = achievement_validate_taming; + achievement->validate_pet_intimacy = achievement_validate_pet_intimacy; + achievement->validate_pet_runaway = achievement_validate_pet_runaway; achievement->validate_achievement_rank = achievement_validate_achievement_rank; /* */ achievement->type_requires_criteria = achievement_type_requires_criteria; diff --git a/src/map/achievement.h b/src/map/achievement.h index 2e034183320..1322b1ad7e3 100644 --- a/src/map/achievement.h +++ b/src/map/achievement.h @@ -101,6 +101,8 @@ enum achievement_types { ACH_ACHIEVEMENT_RANK, ACH_ZENY_SPEND_VENDING, ACH_ZENY_SPEND_VENDING_TOTAL, + ACH_PET_INTIMACY, + ACH_PET_RUNAWAY, ACH_TYPE_MAX }; @@ -140,6 +142,7 @@ struct achievement_objective { /* */ uint32 item_type; int mobid; + int intimacy; VECTOR_DECL(int) jobid; }; @@ -168,7 +171,9 @@ struct achievement_data { // Achievements types that use Mob ID as criteria. #define achievement_criteria_mobid(t) ( \ (t) == ACH_KILL_MOB_CLASS \ - || (t) == ACH_PET_CREATE ) + || (t) == ACH_PET_CREATE \ + || (t) == ACH_PET_INTIMACY \ + || (t) == ACH_PET_RUNAWAY ) // Achievements types that use JobID vector as criteria. #define achievement_criteria_jobid(t) ( \ @@ -199,6 +204,10 @@ struct achievement_data { (t) == ACH_EQUIP_REFINE_SUCCESS_WLV \ || (t) == ACH_EQUIP_REFINE_FAILURE_WLV ) +// Achievement types that uses intimacy as criteria +#define achievement_criteria_intimacy(t) ( \ + (t) == ACH_PET_INTIMACY ) + // Valid status types for objective criteria. #define achievement_valid_status_types(s) ( \ (s) == SP_STR \ @@ -232,6 +241,7 @@ struct achievement_interface { bool (*readdb_validate_criteria_itemtype) (const struct config_setting_t *t, struct achievement_objective *obj, enum achievement_types type, int entry_id, int obj_idx); bool (*readdb_validate_criteria_weaponlv) (const struct config_setting_t *t, struct achievement_objective *obj, enum achievement_types type, int entry_id, int obj_idx); bool (*readdb_validate_criteria_achievement) (const struct config_setting_t *t, struct achievement_objective *obj, enum achievement_types type, int entry_id, int obj_idx); + bool (*readdb_validate_criteria_intimacy) (const struct config_setting_t *t, struct achievement_objective *obj, enum achievement_types type, int entry_id, int obj_idx); /* */ bool (*readdb_rewards) (const struct config_setting_t *conf, struct achievement_data *entry, const char *source); void (*readdb_validate_reward_items) (const struct config_setting_t *t, struct achievement_data *entry); @@ -274,6 +284,8 @@ struct achievement_interface { void (*validate_item_sell) (struct map_session_data *sd, int nameid, int amount); void (*validate_achieve) (struct map_session_data *sd, int achid); void (*validate_taming) (struct map_session_data *sd, int class); + void (*validate_pet_intimacy) (struct map_session_data *sd); + void (*validate_pet_runaway) (struct map_session_data *sd, int class); void (*validate_achievement_rank) (struct map_session_data *sd, int rank); /* */ bool (*type_requires_criteria) (enum achievement_types type); diff --git a/src/map/pet.c b/src/map/pet.c index ce26b6cb1f1..548b05dc3ec 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -90,6 +90,10 @@ static void pet_set_intimate(struct pet_data *pd, int value) if( (intimate >= battle_config.pet_equip_min_friendly && pd->pet.intimate < battle_config.pet_equip_min_friendly) || (intimate < battle_config.pet_equip_min_friendly && pd->pet.intimate >= battle_config.pet_equip_min_friendly) ) status_calc_pc(sd,SCO_NONE); + if (value > 0) + achievement->validate_pet_intimacy(sd); + achievement->validate_pet_runaway(sd, pd->pet.class_); + /* Pet is lost, delete the egg */ if (value <= 0) { int i; diff --git a/src/map/script.c b/src/map/script.c index 30a6919cdad..b2884789a04 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -26649,6 +26649,8 @@ static void script_hardcoded_constants(void) script->set_constant("ACH_ACHIEVEMENT_RANK", ACH_ACHIEVEMENT_RANK, false, false); script->set_constant("ACH_ZENY_SPEND_VENDING", ACH_ZENY_SPEND_VENDING, false, false); script->set_constant("ACH_ZENY_SPEND_VENDING_TOTAL", ACH_ZENY_SPEND_VENDING_TOTAL, false, false); + script->set_constant("ACH_PET_INTIMACY", ACH_PET_INTIMACY, false, false); + script->set_constant("ACH_PET_RUNAWAY", ACH_PET_RUNAWAY, false, false); script->constdb_comment("Renewal"); #ifdef RENEWAL From 1379351325e1c814873437d6576b58417666e335 Mon Sep 17 00:00:00 2001 From: Ibrahim Zidan Date: Sun, 12 May 2019 10:34:39 +0200 Subject: [PATCH 5/6] Fix vending achievements 220009, 220010, 220011, 220012, 220013 previously they would be triggered on any zeny paying actions and not on vending merchants only Signed-off-by: Ibrahim Zidan --- db/pre-re/achievement_db.conf | 10 +++++----- db/re/achievement_db.conf | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/db/pre-re/achievement_db.conf b/db/pre-re/achievement_db.conf index e478c92d4b6..f54fa5dc38a 100644 --- a/db/pre-re/achievement_db.conf +++ b/db/pre-re/achievement_db.conf @@ -4652,7 +4652,7 @@ achievement_db: ( { Id: 220009 Name: "Activating the market economy (1)" - Type: "ACH_ZENY_SPEND_TOTAL" + Type: "ACH_ZENY_SPEND_VENDING_TOTAL" Objectives: { *1: { Description: "Spend 10000 zeny on vending merchant" @@ -4664,7 +4664,7 @@ achievement_db: ( { Id: 220010 Name: "Activating the market economy (2)" - Type: "ACH_ZENY_SPEND_TOTAL" + Type: "ACH_ZENY_SPEND_VENDING_TOTAL" Objectives: { *1: { Description: "Spend 100000 zeny on vending merchant" @@ -4676,7 +4676,7 @@ achievement_db: ( { Id: 220011 Name: "Activating the market economy (3)" - Type: "ACH_ZENY_SPEND_TOTAL" + Type: "ACH_ZENY_SPEND_VENDING_TOTAL" Objectives: { *1: { Description: "Spend 500000 zeny on vending merchant" @@ -4688,7 +4688,7 @@ achievement_db: ( { Id: 220012 Name: "Activating the market economy (4)" - Type: "ACH_ZENY_SPEND_TOTAL" + Type: "ACH_ZENY_SPEND_VENDING_TOTAL" Objectives: { *1: { Description: "Spend 1.000000 zeny on vending merchant" @@ -4700,7 +4700,7 @@ achievement_db: ( { Id: 220013 Name: "Activating the market economy (5)" - Type: "ACH_ZENY_SPEND_TOTAL" + Type: "ACH_ZENY_SPEND_VENDING_TOTAL" Objectives: { *1: { Description: "Spend 5.000000 zeny on vending merchant" diff --git a/db/re/achievement_db.conf b/db/re/achievement_db.conf index 175c6a3ed82..bdf693fcbf0 100644 --- a/db/re/achievement_db.conf +++ b/db/re/achievement_db.conf @@ -5353,7 +5353,7 @@ achievement_db: ( { Id: 220009 Name: "Activating the market economy (1)" - Type: "ACH_ZENY_SPEND_TOTAL" + Type: "ACH_ZENY_SPEND_VENDING_TOTAL" Objectives: { *1: { Description: "Spend 10000 zeny on vending merchant" @@ -5365,7 +5365,7 @@ achievement_db: ( { Id: 220010 Name: "Activating the market economy (2)" - Type: "ACH_ZENY_SPEND_TOTAL" + Type: "ACH_ZENY_SPEND_VENDING_TOTAL" Objectives: { *1: { Description: "Spend 100000 zeny on vending merchant" @@ -5377,7 +5377,7 @@ achievement_db: ( { Id: 220011 Name: "Activating the market economy (3)" - Type: "ACH_ZENY_SPEND_TOTAL" + Type: "ACH_ZENY_SPEND_VENDING_TOTAL" Objectives: { *1: { Description: "Spend 500000 zeny on vending merchant" @@ -5389,7 +5389,7 @@ achievement_db: ( { Id: 220012 Name: "Activating the market economy (4)" - Type: "ACH_ZENY_SPEND_TOTAL" + Type: "ACH_ZENY_SPEND_VENDING_TOTAL" Objectives: { *1: { Description: "Spend 1.000000 zeny on vending merchant" @@ -5401,7 +5401,7 @@ achievement_db: ( { Id: 220013 Name: "Activating the market economy (5)" - Type: "ACH_ZENY_SPEND_TOTAL" + Type: "ACH_ZENY_SPEND_VENDING_TOTAL" Objectives: { *1: { Description: "Spend 5.000000 zeny on vending merchant" From 4474971a8da8f05ffa16bdd583c51d8d8b171234 Mon Sep 17 00:00:00 2001 From: Ibrahim Zidan Date: Sun, 12 May 2019 10:43:17 +0200 Subject: [PATCH 6/6] HPM Hooks update Signed-off-by: Ibrahim Zidan --- src/plugins/HPMHooking/HPMHooking.Defs.inc | 8 ++ .../HPMHooking_map.HPMHooksCore.inc | 16 +++ .../HPMHooking_map.HookingPoints.inc | 4 + .../HPMHooking/HPMHooking_map.Hooks.inc | 105 ++++++++++++++++++ 4 files changed, 133 insertions(+) diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc index 920f81ca558..42e6071e06d 100644 --- a/src/plugins/HPMHooking/HPMHooking.Defs.inc +++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc @@ -100,6 +100,8 @@ typedef bool (*HPMHOOK_pre_achievement_readdb_validate_criteria_weaponlv) (const typedef bool (*HPMHOOK_post_achievement_readdb_validate_criteria_weaponlv) (bool retVal___, const struct config_setting_t *t, struct achievement_objective *obj, enum achievement_types type, int entry_id, int obj_idx); typedef bool (*HPMHOOK_pre_achievement_readdb_validate_criteria_achievement) (const struct config_setting_t **t, struct achievement_objective **obj, enum achievement_types *type, int *entry_id, int *obj_idx); typedef bool (*HPMHOOK_post_achievement_readdb_validate_criteria_achievement) (bool retVal___, const struct config_setting_t *t, struct achievement_objective *obj, enum achievement_types type, int entry_id, int obj_idx); +typedef bool (*HPMHOOK_pre_achievement_readdb_validate_criteria_intimacy) (const struct config_setting_t **t, struct achievement_objective **obj, enum achievement_types *type, int *entry_id, int *obj_idx); +typedef bool (*HPMHOOK_post_achievement_readdb_validate_criteria_intimacy) (bool retVal___, const struct config_setting_t *t, struct achievement_objective *obj, enum achievement_types type, int entry_id, int obj_idx); typedef bool (*HPMHOOK_pre_achievement_readdb_rewards) (const struct config_setting_t **conf, struct achievement_data **entry, const char **source); typedef bool (*HPMHOOK_post_achievement_readdb_rewards) (bool retVal___, const struct config_setting_t *conf, struct achievement_data *entry, const char *source); typedef void (*HPMHOOK_pre_achievement_readdb_validate_reward_items) (const struct config_setting_t **t, struct achievement_data **entry); @@ -158,6 +160,8 @@ typedef void (*HPMHOOK_pre_achievement_validate_adopt) (struct map_session_data typedef void (*HPMHOOK_post_achievement_validate_adopt) (struct map_session_data *sd, bool parent); typedef void (*HPMHOOK_pre_achievement_validate_zeny) (struct map_session_data **sd, int *amount); typedef void (*HPMHOOK_post_achievement_validate_zeny) (struct map_session_data *sd, int amount); +typedef void (*HPMHOOK_pre_achievement_validate_zeny_vending) (struct map_session_data **sd, int *amount); +typedef void (*HPMHOOK_post_achievement_validate_zeny_vending) (struct map_session_data *sd, int amount); typedef void (*HPMHOOK_pre_achievement_validate_refine) (struct map_session_data **sd, unsigned int *idx, bool *success); typedef void (*HPMHOOK_post_achievement_validate_refine) (struct map_session_data *sd, unsigned int idx, bool success); typedef void (*HPMHOOK_pre_achievement_validate_item_get) (struct map_session_data **sd, int *nameid, int *amount); @@ -168,6 +172,10 @@ typedef void (*HPMHOOK_pre_achievement_validate_achieve) (struct map_session_dat typedef void (*HPMHOOK_post_achievement_validate_achieve) (struct map_session_data *sd, int achid); typedef void (*HPMHOOK_pre_achievement_validate_taming) (struct map_session_data **sd, int *class); typedef void (*HPMHOOK_post_achievement_validate_taming) (struct map_session_data *sd, int class); +typedef void (*HPMHOOK_pre_achievement_validate_pet_intimacy) (struct map_session_data **sd); +typedef void (*HPMHOOK_post_achievement_validate_pet_intimacy) (struct map_session_data *sd); +typedef void (*HPMHOOK_pre_achievement_validate_pet_runaway) (struct map_session_data **sd, int *class); +typedef void (*HPMHOOK_post_achievement_validate_pet_runaway) (struct map_session_data *sd, int class); typedef void (*HPMHOOK_pre_achievement_validate_achievement_rank) (struct map_session_data **sd, int *rank); typedef void (*HPMHOOK_post_achievement_validate_achievement_rank) (struct map_session_data *sd, int rank); typedef bool (*HPMHOOK_pre_achievement_type_requires_criteria) (enum achievement_types *type); diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index 9c0b1905e92..771e802a476 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -58,6 +58,8 @@ struct { struct HPMHookPoint *HP_achievement_readdb_validate_criteria_weaponlv_post; struct HPMHookPoint *HP_achievement_readdb_validate_criteria_achievement_pre; struct HPMHookPoint *HP_achievement_readdb_validate_criteria_achievement_post; + struct HPMHookPoint *HP_achievement_readdb_validate_criteria_intimacy_pre; + struct HPMHookPoint *HP_achievement_readdb_validate_criteria_intimacy_post; struct HPMHookPoint *HP_achievement_readdb_rewards_pre; struct HPMHookPoint *HP_achievement_readdb_rewards_post; struct HPMHookPoint *HP_achievement_readdb_validate_reward_items_pre; @@ -116,6 +118,8 @@ struct { struct HPMHookPoint *HP_achievement_validate_adopt_post; struct HPMHookPoint *HP_achievement_validate_zeny_pre; struct HPMHookPoint *HP_achievement_validate_zeny_post; + struct HPMHookPoint *HP_achievement_validate_zeny_vending_pre; + struct HPMHookPoint *HP_achievement_validate_zeny_vending_post; struct HPMHookPoint *HP_achievement_validate_refine_pre; struct HPMHookPoint *HP_achievement_validate_refine_post; struct HPMHookPoint *HP_achievement_validate_item_get_pre; @@ -126,6 +130,10 @@ struct { struct HPMHookPoint *HP_achievement_validate_achieve_post; struct HPMHookPoint *HP_achievement_validate_taming_pre; struct HPMHookPoint *HP_achievement_validate_taming_post; + struct HPMHookPoint *HP_achievement_validate_pet_intimacy_pre; + struct HPMHookPoint *HP_achievement_validate_pet_intimacy_post; + struct HPMHookPoint *HP_achievement_validate_pet_runaway_pre; + struct HPMHookPoint *HP_achievement_validate_pet_runaway_post; struct HPMHookPoint *HP_achievement_validate_achievement_rank_pre; struct HPMHookPoint *HP_achievement_validate_achievement_rank_post; struct HPMHookPoint *HP_achievement_type_requires_criteria_pre; @@ -6839,6 +6847,8 @@ struct { int HP_achievement_readdb_validate_criteria_weaponlv_post; int HP_achievement_readdb_validate_criteria_achievement_pre; int HP_achievement_readdb_validate_criteria_achievement_post; + int HP_achievement_readdb_validate_criteria_intimacy_pre; + int HP_achievement_readdb_validate_criteria_intimacy_post; int HP_achievement_readdb_rewards_pre; int HP_achievement_readdb_rewards_post; int HP_achievement_readdb_validate_reward_items_pre; @@ -6897,6 +6907,8 @@ struct { int HP_achievement_validate_adopt_post; int HP_achievement_validate_zeny_pre; int HP_achievement_validate_zeny_post; + int HP_achievement_validate_zeny_vending_pre; + int HP_achievement_validate_zeny_vending_post; int HP_achievement_validate_refine_pre; int HP_achievement_validate_refine_post; int HP_achievement_validate_item_get_pre; @@ -6907,6 +6919,10 @@ struct { int HP_achievement_validate_achieve_post; int HP_achievement_validate_taming_pre; int HP_achievement_validate_taming_post; + int HP_achievement_validate_pet_intimacy_pre; + int HP_achievement_validate_pet_intimacy_post; + int HP_achievement_validate_pet_runaway_pre; + int HP_achievement_validate_pet_runaway_post; int HP_achievement_validate_achievement_rank_pre; int HP_achievement_validate_achievement_rank_post; int HP_achievement_type_requires_criteria_pre; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index 6c0b6db3614..407bf750e45 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -44,6 +44,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(achievement->readdb_validate_criteria_itemtype, HP_achievement_readdb_validate_criteria_itemtype) }, { HP_POP(achievement->readdb_validate_criteria_weaponlv, HP_achievement_readdb_validate_criteria_weaponlv) }, { HP_POP(achievement->readdb_validate_criteria_achievement, HP_achievement_readdb_validate_criteria_achievement) }, + { HP_POP(achievement->readdb_validate_criteria_intimacy, HP_achievement_readdb_validate_criteria_intimacy) }, { HP_POP(achievement->readdb_rewards, HP_achievement_readdb_rewards) }, { HP_POP(achievement->readdb_validate_reward_items, HP_achievement_readdb_validate_reward_items) }, { HP_POP(achievement->readdb_validate_reward_item_sub, HP_achievement_readdb_validate_reward_item_sub) }, @@ -73,11 +74,14 @@ struct HookingPointData HookingPoints[] = { { HP_POP(achievement->validate_marry, HP_achievement_validate_marry) }, { HP_POP(achievement->validate_adopt, HP_achievement_validate_adopt) }, { HP_POP(achievement->validate_zeny, HP_achievement_validate_zeny) }, + { HP_POP(achievement->validate_zeny_vending, HP_achievement_validate_zeny_vending) }, { HP_POP(achievement->validate_refine, HP_achievement_validate_refine) }, { HP_POP(achievement->validate_item_get, HP_achievement_validate_item_get) }, { HP_POP(achievement->validate_item_sell, HP_achievement_validate_item_sell) }, { HP_POP(achievement->validate_achieve, HP_achievement_validate_achieve) }, { HP_POP(achievement->validate_taming, HP_achievement_validate_taming) }, + { HP_POP(achievement->validate_pet_intimacy, HP_achievement_validate_pet_intimacy) }, + { HP_POP(achievement->validate_pet_runaway, HP_achievement_validate_pet_runaway) }, { HP_POP(achievement->validate_achievement_rank, HP_achievement_validate_achievement_rank) }, { HP_POP(achievement->type_requires_criteria, HP_achievement_type_requires_criteria) }, { HP_POP(achievement->init_titles, HP_achievement_init_titles) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index 9cc98692218..68166203237 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -461,6 +461,33 @@ bool HP_achievement_readdb_validate_criteria_achievement(const struct config_set } return retVal___; } +bool HP_achievement_readdb_validate_criteria_intimacy(const struct config_setting_t *t, struct achievement_objective *obj, enum achievement_types type, int entry_id, int obj_idx) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_achievement_readdb_validate_criteria_intimacy_pre > 0) { + bool (*preHookFunc) (const struct config_setting_t **t, struct achievement_objective **obj, enum achievement_types *type, int *entry_id, int *obj_idx); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_achievement_readdb_validate_criteria_intimacy_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_achievement_readdb_validate_criteria_intimacy_pre[hIndex].func; + retVal___ = preHookFunc(&t, &obj, &type, &entry_id, &obj_idx); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.achievement.readdb_validate_criteria_intimacy(t, obj, type, entry_id, obj_idx); + } + if (HPMHooks.count.HP_achievement_readdb_validate_criteria_intimacy_post > 0) { + bool (*postHookFunc) (bool retVal___, const struct config_setting_t *t, struct achievement_objective *obj, enum achievement_types type, int entry_id, int obj_idx); + for (hIndex = 0; hIndex < HPMHooks.count.HP_achievement_readdb_validate_criteria_intimacy_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_achievement_readdb_validate_criteria_intimacy_post[hIndex].func; + retVal___ = postHookFunc(retVal___, t, obj, type, entry_id, obj_idx); + } + } + return retVal___; +} bool HP_achievement_readdb_rewards(const struct config_setting_t *conf, struct achievement_data *entry, const char *source) { int hIndex = 0; bool retVal___ = false; @@ -1223,6 +1250,32 @@ void HP_achievement_validate_zeny(struct map_session_data *sd, int amount) { } return; } +void HP_achievement_validate_zeny_vending(struct map_session_data *sd, int amount) { + int hIndex = 0; + if (HPMHooks.count.HP_achievement_validate_zeny_vending_pre > 0) { + void (*preHookFunc) (struct map_session_data **sd, int *amount); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_achievement_validate_zeny_vending_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_achievement_validate_zeny_vending_pre[hIndex].func; + preHookFunc(&sd, &amount); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.achievement.validate_zeny_vending(sd, amount); + } + if (HPMHooks.count.HP_achievement_validate_zeny_vending_post > 0) { + void (*postHookFunc) (struct map_session_data *sd, int amount); + for (hIndex = 0; hIndex < HPMHooks.count.HP_achievement_validate_zeny_vending_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_achievement_validate_zeny_vending_post[hIndex].func; + postHookFunc(sd, amount); + } + } + return; +} void HP_achievement_validate_refine(struct map_session_data *sd, unsigned int idx, bool success) { int hIndex = 0; if (HPMHooks.count.HP_achievement_validate_refine_pre > 0) { @@ -1353,6 +1406,58 @@ void HP_achievement_validate_taming(struct map_session_data *sd, int class) { } return; } +void HP_achievement_validate_pet_intimacy(struct map_session_data *sd) { + int hIndex = 0; + if (HPMHooks.count.HP_achievement_validate_pet_intimacy_pre > 0) { + void (*preHookFunc) (struct map_session_data **sd); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_achievement_validate_pet_intimacy_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_achievement_validate_pet_intimacy_pre[hIndex].func; + preHookFunc(&sd); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.achievement.validate_pet_intimacy(sd); + } + if (HPMHooks.count.HP_achievement_validate_pet_intimacy_post > 0) { + void (*postHookFunc) (struct map_session_data *sd); + for (hIndex = 0; hIndex < HPMHooks.count.HP_achievement_validate_pet_intimacy_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_achievement_validate_pet_intimacy_post[hIndex].func; + postHookFunc(sd); + } + } + return; +} +void HP_achievement_validate_pet_runaway(struct map_session_data *sd, int class) { + int hIndex = 0; + if (HPMHooks.count.HP_achievement_validate_pet_runaway_pre > 0) { + void (*preHookFunc) (struct map_session_data **sd, int *class); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_achievement_validate_pet_runaway_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_achievement_validate_pet_runaway_pre[hIndex].func; + preHookFunc(&sd, &class); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.achievement.validate_pet_runaway(sd, class); + } + if (HPMHooks.count.HP_achievement_validate_pet_runaway_post > 0) { + void (*postHookFunc) (struct map_session_data *sd, int class); + for (hIndex = 0; hIndex < HPMHooks.count.HP_achievement_validate_pet_runaway_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_achievement_validate_pet_runaway_post[hIndex].func; + postHookFunc(sd, class); + } + } + return; +} void HP_achievement_validate_achievement_rank(struct map_session_data *sd, int rank) { int hIndex = 0; if (HPMHooks.count.HP_achievement_validate_achievement_rank_pre > 0) {