diff options
author | Jesusaves <cpntb1@ymail.com> | 2019-10-17 14:09:33 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2019-10-17 14:09:33 -0300 |
commit | 50ee9e848cb9b87ea42580783051e6c883ed8f73 (patch) | |
tree | 58cd4f4607704e5c81c3a5d6e53b08c7e4c3c8e4 /src | |
parent | b972376c3cd817d915e4a15cab84e46992a8d5a2 (diff) | |
download | evol-hercules-50ee9e848cb9b87ea42580783051e6c883ed8f73.tar.gz evol-hercules-50ee9e848cb9b87ea42580783051e6c883ed8f73.tar.bz2 evol-hercules-50ee9e848cb9b87ea42580783051e6c883ed8f73.tar.xz evol-hercules-50ee9e848cb9b87ea42580783051e6c883ed8f73.zip |
And now remove the cheat mentioned on previous commit; When resetting stats
equipment requeriments will be unequipped. FINALLY.
The bug was data being set to NULL...
Diffstat (limited to 'src')
-rw-r--r-- | src/emap/init.c | 1 | ||||
-rw-r--r-- | src/emap/pc.c | 51 | ||||
-rw-r--r-- | src/emap/pc.h | 3 |
3 files changed, 54 insertions, 1 deletions
diff --git a/src/emap/init.c b/src/emap/init.c index 35eb76a..0fc168b 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -408,6 +408,7 @@ HPExport void plugin_init (void) addHookPost(pc, takeitem, epc_takeitem_post); addHookPost(pc, can_insert_card_into, epc_can_insert_card_into_post); addHookPost(pc, insert_card, epc_insert_card_post); + addHookPost(pc, resetstate, epc_resetstate_post); skill->castend_nodamage_id_unknown = eskill_castend_nodamage_id_unknown; skill->additional_effect_unknown = eskill_additional_effect_unknown; diff --git a/src/emap/pc.c b/src/emap/pc.c index 0a3d1ce..5e8b3b0 100644 --- a/src/emap/pc.c +++ b/src/emap/pc.c @@ -22,6 +22,7 @@ #include "map/itemdb.h" #include "map/npc.h" #include "map/pc.h" +#include "map/status.h" #include "map/quest.h" #include "plugins/HPMHooking.h" @@ -1074,7 +1075,7 @@ int epc_equipitem_pre(struct map_session_data **sdPtr, (data->requiredSkill && !pc->checkskill(sd, data->requiredSkill)) ) { - clif->equipitemack(sd,n,0,EIA_FAIL); // fail + clif->equipitemack(sd,n,0,EIA_FAIL); // fail hookStop(); return 0; } @@ -1083,6 +1084,54 @@ int epc_equipitem_pre(struct map_session_data **sdPtr, return 0; } +int epc_resetstate_post(int retVal, + struct map_session_data *sd) { + + // Do nothing if it failed + if (!retVal) + return retVal; + + int i; + struct item_data *id; + struct ItemdExt *data; + + // Check all your equipped items + for (i = 0; i < EQI_MAX; i++) { + int index = sd->equip_index[i]; + + id = sd->inventory_data[index]; + + // Skip possibly empty slots + if (id == NULL) + continue; + + data = itemd_get(id); + + // Skip broken pointers + if (data == NULL) + continue; + + // Check for requeriments + if (sd->status.str < data->requiredStr || + sd->status.agi < data->requiredAgi || + sd->status.vit < data->requiredVit || + sd->status.int_ < data->requiredInt || + sd->status.dex < data->requiredDex || + sd->status.luk < data->requiredLuk || + sd->status.max_hp < data->requiredMaxHp || + sd->status.max_sp < data->requiredMaxSp || + (data->requiredSkill && !pc->checkskill(sd, data->requiredSkill)) + ) + { + // Unequip the item + pc->unequipitem(sd, index, PCUNEQUIPITEM_FORCE); + } + } + // Now recalculate, and return whatever it had to return + status_calc_pc(sd,SCO_NONE); + return retVal; +} + // disable job based bonuses void epc_calc_skilltree_bonus_pre(struct map_session_data **sdPtr __attribute__ ((unused)), int *classidxPtr __attribute__ ((unused))) diff --git a/src/emap/pc.h b/src/emap/pc.h index faefd82..a204917 100644 --- a/src/emap/pc.h +++ b/src/emap/pc.h @@ -148,4 +148,7 @@ int epc_equipitem_pre(struct map_session_data **sdPtr, int *nPtr, int *req_pos __attribute__ ((unused))); +int epc_resetstate_post(int retVal, + struct map_session_data *sd); + #endif // EVOL_MAP_PC |