diff options
author | Jesusaves <cpntb1@ymail.com> | 2019-10-21 14:32:05 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2019-10-21 14:32:05 -0300 |
commit | 517290161699e4092989c6c892710cc63fd3e1aa (patch) | |
tree | f42925d83c69491d494d207774b9951cfea92033 | |
parent | f8d8b072fcba2678f40e13947b1e621b0ffde262 (diff) | |
download | evol-hercules-517290161699e4092989c6c892710cc63fd3e1aa.tar.gz evol-hercules-517290161699e4092989c6c892710cc63fd3e1aa.tar.bz2 evol-hercules-517290161699e4092989c6c892710cc63fd3e1aa.tar.xz evol-hercules-517290161699e4092989c6c892710cc63fd3e1aa.zip |
Patch the plugin so it delete items and works out-of-box
-rw-r--r-- | src/emap/init.c | 1 | ||||
-rw-r--r-- | src/emap/skill.c | 29 | ||||
-rw-r--r-- | src/emap/skill.h | 4 |
3 files changed, 34 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c index c04b764..a784eec 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -398,6 +398,7 @@ HPExport void plugin_init (void) addHookPost(skill, check_condition_castend, eskill_check_condition_castend_post); addHookPost(skill, get_index, eskill_get_index_post); addHookPost(skill, calc_heal, eskill_calc_heal_post); + addHookPost(skill, consume_requirement, eskill_consume_requirement_post); addHookPost(pc, additem, epc_additem_post); addHookPost(pc, isequip, epc_isequip_post); addHookPost(pc, isUseitem, epc_isequip_post); diff --git a/src/emap/skill.c b/src/emap/skill.c index 30614b7..2cf45cc 100644 --- a/src/emap/skill.c +++ b/src/emap/skill.c @@ -19,6 +19,7 @@ #include "map/pc.h" #include "map/npc.h" #include "map/script.h" +#include "map/skill.h" #include "emap/skill.h" #include "emap/skill_const.h" @@ -305,5 +306,33 @@ int eskill_calc_heal_post(int retVal, return retVal; } +int eskill_consume_requirement_post(int retVal, + struct map_session_data *sd, + uint16 skill_id, uint16 skill_lv, short type) +{ + int i, n; + struct skill_condition req; + + if (!sd) + return retVal; + + //ShowInfo("crpost, Skill %d Level %d and type %d\n", skill_id, skill_lv, type); + + req = skill->get_requirement(sd,skill_id,skill_lv); + + // TODO We need more checks than only this + if (type == 1 && skill_id > EVOL_FIRST_SKILL) { + // Delete the items + for( i = 0; i < MAX_SKILL_ITEM_REQUIRE; ++i ) + { + if( !req.itemid[i] ) + continue; + + if ((n = pc->search_inventory(sd,req.itemid[i])) != INDEX_NOT_FOUND) + pc->delitem(sd, n, req.amount[i], 0, DELITEM_SKILLUSE, LOG_TYPE_CONSUME); + } + } + return retVal; +} diff --git a/src/emap/skill.h b/src/emap/skill.h index 4ae9b27..aa400d8 100644 --- a/src/emap/skill.h +++ b/src/emap/skill.h @@ -105,4 +105,8 @@ int eskill_calc_heal_post(int retVal, uint16 skill_lv __attribute__ ((unused)), bool heal __attribute__ ((unused))); +int eskill_consume_requirement_post(int retVal, + struct map_session_data *sd, + uint16 skill_id, uint16 skill_lv, short type); + #endif // EVOL_MAP_SKILL |