diff options
-rw-r--r-- | src/emap/init.c | 1 | ||||
-rw-r--r-- | src/emap/pc.c | 65 | ||||
-rw-r--r-- | src/emap/pc.h | 4 |
3 files changed, 47 insertions, 23 deletions
diff --git a/src/emap/init.c b/src/emap/init.c index aa928c3..35eb76a 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -298,6 +298,7 @@ HPExport void plugin_init (void) addHookPre(pc, resetskill_job, epc_resetskill_job_pre); addHookPre(pc, isDeathPenaltyJob, epc_isDeathPenaltyJob_pre); addHookPre(pc, read_skill_job_skip, epc_read_skill_job_skip_pre); + addHookPre(pc, equipitem, epc_equipitem_pre); addHookPre(mob, deleteslave_sub, emob_deleteslave_sub_pre); addHookPre(mob, read_db_additional_fields, emob_read_db_additional_fields_pre); addHookPre(mob, dead, emob_dead_pre); diff --git a/src/emap/pc.c b/src/emap/pc.c index 011743e..0a3d1ce 100644 --- a/src/emap/pc.c +++ b/src/emap/pc.c @@ -15,6 +15,7 @@ #include "common/strlib.h" #include "common/timer.h" #include "map/achievement.h" +#include "map/clif.h" #include "map/chrif.h" #include "map/homunculus.h" #include "map/elemental.h" @@ -293,29 +294,6 @@ int epc_isequip_post(int retVal, if (!data) return retVal; - // test for missing basic stats calculation - if (sd->regen.sregen == NULL) - { - return retVal; - } - if (sd->battle_status.str < data->requiredStr || - sd->battle_status.agi < data->requiredAgi || - sd->battle_status.vit < data->requiredVit || - sd->battle_status.int_ < data->requiredInt || - sd->battle_status.dex < data->requiredDex || - sd->battle_status.luk < data->requiredLuk || - sd->battle_status.max_hp < data->requiredMaxHp || - sd->battle_status.max_sp < data->requiredMaxSp || - sd->battle_status.batk < data->requiredAtk || - sd->battle_status.matk_min < data->requiredMAtkMin || - sd->battle_status.matk_max < data->requiredMAtkMax || - sd->battle_status.def < data->requiredDef || - sd->battle_status.mdef < data->requiredMDef || - (data->requiredSkill && !pc->checkskill(sd, data->requiredSkill)) - ) - { - return 0; - } } return retVal; } @@ -1064,6 +1042,47 @@ void epc_calc_skilltree_clear_pre(struct map_session_data **sdPtr) hookStop(); } +// Required Stats +int epc_equipitem_pre(struct map_session_data **sdPtr, + int *nPtr, + int *req_pos __attribute__ ((unused))) +{ + struct map_session_data *sd = *sdPtr; + if (!sd) + return 1; + + const int n = *nPtr; + + if (n < 0 || n >= sd->status.inventorySize) + return 1; + + struct item_data *id; + id = sd->inventory_data[n]; + struct ItemdExt *data = itemd_get(id); + + if (!data) + return 1; + + 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)) + ) + { + clif->equipitemack(sd,n,0,EIA_FAIL); // fail + hookStop(); + return 0; + } + + // Okay, continue... + return 0; +} + // 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 d5c59bf..faefd82 100644 --- a/src/emap/pc.h +++ b/src/emap/pc.h @@ -144,4 +144,8 @@ bool epc_isDeathPenaltyJob_pre(uint16 *jobPtr); bool epc_read_skill_job_skip_pre(short *skill_idPtr, int *job_idPtr); +int epc_equipitem_pre(struct map_session_data **sdPtr, + int *nPtr, + int *req_pos __attribute__ ((unused))); + #endif // EVOL_MAP_PC |