diff options
author | Kenpachi Developer <Kenpachi.Developer@gmx.de> | 2020-01-20 09:49:23 +0100 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2020-02-09 23:46:56 +0100 |
commit | 1098b588625774ca2cf4e05527b00fd4d0187919 (patch) | |
tree | 8acbfabdcbbf2cd7188ea02ff5ef084a6c022052 /src/map/unit.c | |
parent | e164b55dbb908c0006f0ca4e2e74e9995f318d57 (diff) | |
download | hercules-1098b588625774ca2cf4e05527b00fd4d0187919.tar.gz hercules-1098b588625774ca2cf4e05527b00fd4d0187919.tar.bz2 hercules-1098b588625774ca2cf4e05527b00fd4d0187919.tar.xz hercules-1098b588625774ca2cf4e05527b00fd4d0187919.zip |
Fixed skill conditions check and <flag> parameter in itemskill() script command.
* itemskill() script command should check for the skill's conditions and also consumes them. SP are not consumed.
* The same applies to Hocus-pocus skill. Conditions should be checked and consumed, SP are not consumed.
* This was bugged for more than 6 years now. See linked bug report and commits.
Related bug:
* https://herc.ws/oldboard/tracker/issue-7210-itemskill-command-does-not-check-for-required-items/
Related commits:
* https://github.com/HerculesWS/Hercules/commit/b864056b8d088660fca9129bddad477732ed8df9
* https://github.com/HerculesWS/Hercules/commit/07272f7a16db87970583286db03167ca79604a69
Diffstat (limited to 'src/map/unit.c')
-rw-r--r-- | src/map/unit.c | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/src/map/unit.c b/src/map/unit.c index 482440978..923438d78 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1041,11 +1041,19 @@ static int unit_stop_walking(struct block_list *bl, int flag) static int unit_skilluse_id(struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv) { - return unit->skilluse_id2( - src, target_id, skill_id, skill_lv, - skill->cast_fix(src, skill_id, skill_lv), - skill->get_castcancel(skill_id) - ); + int casttime = skill->cast_fix(src, skill_id, skill_lv); + int castcancel = skill->get_castcancel(skill_id); + 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) { + sd->itemskill_id = 0; + sd->itemskill_lv = 0; + sd->state.itemskill_conditions_checked = 0; + sd->state.itemskill_no_conditions = 0; + } + + return ret; } static int unit_is_walking(struct block_list *bl) @@ -1418,15 +1426,8 @@ static int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill } } - if (sd) { - /* temporarily disabled, awaiting for kenpachi to detail this so we can make it work properly */ -#if 0 - if (sd->skillitem != skill_id && !skill->check_condition_castbegin(sd, skill_id, skill_lv)) -#else - if (!skill->check_condition_castbegin(sd, skill_id, skill_lv)) -#endif - return 0; - } + if (sd != NULL && skill->check_condition_castbegin(sd, skill_id, skill_lv) == 0) + return 0; if (src->type == BL_MOB) { const struct mob_data *src_md = BL_UCCAST(BL_MOB, src); @@ -1678,11 +1679,19 @@ static int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill static int unit_skilluse_pos(struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv) { - return unit->skilluse_pos2( - src, skill_x, skill_y, skill_id, skill_lv, - skill->cast_fix(src, skill_id, skill_lv), - skill->get_castcancel(skill_id) - ); + int casttime = skill->cast_fix(src, skill_id, skill_lv); + int castcancel = skill->get_castcancel(skill_id); + 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) { + sd->itemskill_id = 0; + sd->itemskill_lv = 0; + sd->state.itemskill_conditions_checked = 0; + sd->state.itemskill_no_conditions = 0; + } + + return ret; } static int unit_skilluse_pos2(struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel) |