diff options
author | Haru <haru@dotalux.com> | 2020-03-09 00:38:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-09 00:38:45 +0100 |
commit | 2ec28927c81008a0e17d7e95e70d207de0954d83 (patch) | |
tree | e4b9042e09e60861726d8b3faae9f6bb400bf97b /src/map | |
parent | f80d9a72ae9e266d123d5f12ea751645691887ce (diff) | |
parent | 5baef19736fbe26f8b0ac23e61059c14afb6211c (diff) | |
download | hercules-2ec28927c81008a0e17d7e95e70d207de0954d83.tar.gz hercules-2ec28927c81008a0e17d7e95e70d207de0954d83.tar.bz2 hercules-2ec28927c81008a0e17d7e95e70d207de0954d83.tar.xz hercules-2ec28927c81008a0e17d7e95e70d207de0954d83.zip |
Merge pull request #2648 from Kenpachi2k13/itemskill_fix
Fix itemskill() script command
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/pc.c | 2 | ||||
-rw-r--r-- | src/map/pc.h | 2 | ||||
-rw-r--r-- | src/map/script.c | 8 | ||||
-rw-r--r-- | src/map/script.h | 2 | ||||
-rw-r--r-- | src/map/skill.c | 6 | ||||
-rw-r--r-- | src/map/unit.c | 4 |
6 files changed, 13 insertions, 11 deletions
diff --git a/src/map/pc.c b/src/map/pc.c index b1e8ae4d1..c604e16dc 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5349,7 +5349,7 @@ static int pc_itemskill_clear(struct map_session_data *sd) sd->itemskill_id = 0; sd->itemskill_lv = 0; sd->state.itemskill_conditions_checked = 0; - sd->state.itemskill_no_conditions = 0; + sd->state.itemskill_check_conditions = 0; sd->state.itemskill_no_casttime = 0; sd->state.itemskill_castonself = 0; diff --git a/src/map/pc.h b/src/map/pc.h index e940c3310..8d1ae3607 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -241,7 +241,7 @@ struct map_session_data { unsigned int npc_unloaded : 1; ///< The player is talking with an unloaded NPCs (respawned tombstones) unsigned int lapine_ui : 1; unsigned int itemskill_conditions_checked : 1; // Used by itemskill() script command, to prevent second check of conditions after target was selected. - unsigned int itemskill_no_conditions : 1; // Used by itemskill() script command, to ignore skill conditions and don't consume them. + unsigned int itemskill_check_conditions : 1; // Used by itemskill() script command, to check skill conditions and consume them. unsigned int itemskill_no_casttime : 1; // Used by itemskill() script command, to cast skill instantaneously. unsigned int itemskill_castonself : 1; // Used by itemskill() script command, to forcefully cast skill on invoking character. } state; diff --git a/src/map/script.c b/src/map/script.c index 73bfca5b9..b8a7979a7 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11001,17 +11001,19 @@ static BUILDIN(itemskill) if (sd == NULL || sd->ud.skilltimer != INVALID_TIMER) return true; + pc->itemskill_clear(sd); sd->skillitem = script_isstringtype(st, 2) ? skill->name2id(script_getstr(st, 2)) : script_getnum(st, 2); sd->skillitemlv = script_getnum(st, 3); sd->state.itemskill_conditions_checked = 0; // Skill casting items will check the conditions prior to the target selection in AEGIS. Thus we need a flag to prevent checking them twice. int flag = script_hasdata(st, 4) ? script_getnum(st, 4) : ISF_NONE; - sd->state.itemskill_no_conditions = ((flag & ISF_IGNORECONDITIONS) == ISF_IGNORECONDITIONS) ? 1 : 0; // Unset in pc_itemskill_clear(). + sd->state.itemskill_check_conditions = ((flag & ISF_CHECKCONDITIONS) == ISF_CHECKCONDITIONS) ? 1 : 0; // Unset in pc_itemskill_clear(). - if (sd->state.itemskill_no_conditions == 0) { + if (sd->state.itemskill_check_conditions == 1) { if (skill->check_condition_castbegin(sd, sd->skillitem, sd->skillitemlv) == 0 || skill->check_condition_castend(sd, sd->skillitem, sd->skillitemlv) == 0) { + pc->itemskill_clear(sd); return true; } @@ -27925,7 +27927,7 @@ static void script_hardcoded_constants(void) script->constdb_comment("itemskill option flags"); script->set_constant("ISF_NONE", ISF_NONE, false, false); - script->set_constant("ISF_IGNORECONDITIONS", ISF_IGNORECONDITIONS, false, false); + script->set_constant("ISF_CHECKCONDITIONS", ISF_CHECKCONDITIONS, false, false); script->set_constant("ISF_INSTANTCAST", ISF_INSTANTCAST, false, false); script->set_constant("ISF_CASTONSELF", ISF_CASTONSELF, false, false); diff --git a/src/map/script.h b/src/map/script.h index ed860368c..511497a66 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -572,7 +572,7 @@ enum mado_type { **/ enum itemskill_flag { ISF_NONE = 0x00, - ISF_IGNORECONDITIONS = 0x01, // Ignore skill conditions and don't consume them. + ISF_CHECKCONDITIONS = 0x01, // Check skill conditions and consume them. ISF_INSTANTCAST = 0x02, // Cast skill instantaneously. ISF_CASTONSELF = 0x04, // Forcefully cast skill on invoking character without showing the target selection cursor. }; diff --git a/src/map/skill.c b/src/map/skill.c index b3ed46fbd..a1a22f74f 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -14042,7 +14042,7 @@ static int skill_check_condition_castbegin(struct map_session_data *sd, uint16 s if (sd->chat_id != 0) return 0; - if ((sd->state.itemskill_conditions_checked == 1 || sd->state.itemskill_no_conditions == 1) + if ((sd->state.itemskill_conditions_checked == 1 || sd->state.itemskill_check_conditions == 0) && skill->is_item_skill(sd, skill_id, skill_lv)) { return 1; } @@ -15031,7 +15031,7 @@ static int skill_check_condition_castend(struct map_session_data *sd, uint16 ski if (sd->chat_id != 0) return 0; - if ((sd->state.itemskill_conditions_checked == 1 || sd->state.itemskill_no_conditions == 1) + if ((sd->state.itemskill_conditions_checked == 1 || sd->state.itemskill_check_conditions == 0) && skill->is_item_skill(sd, skill_id, skill_lv)) { return 1; } @@ -15237,7 +15237,7 @@ static int skill_consume_requirement(struct map_session_data *sd, uint16 skill_i nullpo_ret(sd); - if (sd->state.itemskill_no_conditions == 1 && skill->is_item_skill(sd, skill_id, skill_lv)) + if (sd->state.itemskill_check_conditions == 0 && skill->is_item_skill(sd, skill_id, skill_lv)) return 1; req = skill->get_requirement(sd,skill_id,skill_lv); diff --git a/src/map/unit.c b/src/map/unit.c index 99682e2d3..d2cfcb03d 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1145,7 +1145,7 @@ static int unit_skilluse_id(struct block_list *src, int target_id, uint16 skill_ int ret = unit->skilluse_id2(src, target_id, skill_id, skill_lv, casttime, castcancel); struct map_session_data *sd = BL_CAST(BL_PC, src); - if (sd != NULL) + if (sd != NULL && (ret == 0 || !skill->is_item_skill(sd, skill_id, skill_lv))) pc->itemskill_clear(sd); return ret; @@ -1782,7 +1782,7 @@ static int unit_skilluse_pos(struct block_list *src, short skill_x, short skill_ int ret = unit->skilluse_pos2(src, skill_x, skill_y, skill_id, skill_lv, casttime, castcancel); struct map_session_data *sd = BL_CAST(BL_PC, src); - if (sd != NULL) + if (sd != NULL && (ret == 0 || !skill->is_item_skill(sd, skill_id, skill_lv))) pc->itemskill_clear(sd); return ret; |