diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-08-09 22:05:22 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-08-09 22:05:22 +0300 |
commit | c95ac0d7e312aade368f7213eafa6476ef2cd3fe (patch) | |
tree | 6391aad9062c784f989d126938a4d9710865e3a4 /src/emap/script.c | |
parent | b5c56b1147e6ec93d948c9e5eedcd5d68618b308 (diff) | |
download | plugin-c95ac0d7e312aade368f7213eafa6476ef2cd3fe.tar.gz plugin-c95ac0d7e312aade368f7213eafa6476ef2cd3fe.tar.bz2 plugin-c95ac0d7e312aade368f7213eafa6476ef2cd3fe.tar.xz plugin-c95ac0d7e312aade368f7213eafa6476ef2cd3fe.zip |
Add support for different use actions for items.s20170810
Diffstat (limited to 'src/emap/script.c')
-rw-r--r-- | src/emap/script.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/emap/script.c b/src/emap/script.c index 73854ce..5b39e8a 100644 --- a/src/emap/script.c +++ b/src/emap/script.c @@ -9,6 +9,7 @@ #include "common/HPMi.h" #include "common/memmgr.h" +#include "common/nullpo.h" #include "map/npc.h" #include "map/pc.h" #include "map/script.h" @@ -17,7 +18,9 @@ #include "emap/script.h" #include "emap/map.h" +#include "emap/data/itemd.h" #include "emap/data/npcd.h" +#include "emap/struct/itemdext.h" #include "emap/struct/npcdext.h" #include "emap/skill_const.h" @@ -397,6 +400,41 @@ char *eget_val_npcscope_str_pre(struct script_state **stPtr, return NULL; } +void escript_run_use_script_pre(struct map_session_data **sdPtr, + struct item_data **itemDataPtr, + int *oidPtr) +{ + nullpo_retv(*itemDataPtr); + struct map_session_data *sd = *sdPtr; + struct item_data *itemData = *itemDataPtr; + const int oid = *oidPtr; + if (oid == 0) + { + pc->setreg(sd, script->add_str("@useType"), 0); + script->current_item_id = itemData->nameid; + script->run(itemData->script, 0, sd->bl.id, oid); + script->current_item_id = 0; + } + else + { + struct ItemdExt *data = itemd_get(itemData); + if (!data) + { + data->tmpUseType = 0; + hookStop(); + return; + } + + pc->setreg(sd, script->add_str("@useType"), data->tmpUseType); + script->current_item_id = itemData->nameid; + script->run(itemData->script, 0, sd->bl.id, oid); + script->current_item_id = 0; + pc->setreg(sd, script->add_str("@useType"), 0); + data->tmpUseType = 0; + } + hookStop(); +} + void script_run_item_amount_script(TBL_PC *sd, struct script_code *itemScript, int itemId, |