summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/emap/init.c1
-rw-r--r--src/emap/pc.c51
-rw-r--r--src/emap/pc.h3
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