From 0a1982baa30e29431622c1a4f52668756d563214 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Wed, 11 Mar 2020 21:24:28 +0100 Subject: Rename function pc_itemskill_clear() to pc_autocast_clear() --- src/map/unit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/map/unit.c') diff --git a/src/map/unit.c b/src/map/unit.c index d2cfcb03d..984cc6802 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1146,7 +1146,7 @@ static int unit_skilluse_id(struct block_list *src, int target_id, uint16 skill_ struct map_session_data *sd = BL_CAST(BL_PC, src); if (sd != NULL && (ret == 0 || !skill->is_item_skill(sd, skill_id, skill_lv))) - pc->itemskill_clear(sd); + pc->autocast_clear(sd); return ret; } @@ -1783,7 +1783,7 @@ static int unit_skilluse_pos(struct block_list *src, short skill_x, short skill_ struct map_session_data *sd = BL_CAST(BL_PC, src); if (sd != NULL && (ret == 0 || !skill->is_item_skill(sd, skill_id, skill_lv))) - pc->itemskill_clear(sd); + pc->autocast_clear(sd); return ret; } -- cgit v1.2.3-70-g09d2 From b151b29cf072ed336214c2d0ca43e6db34a773ad Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Wed, 11 Mar 2020 22:07:36 +0100 Subject: Add skill_validate_autocast_data() function calls --- src/map/clif.c | 24 ++++++++++++++++++++++++ src/map/unit.c | 12 ++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) (limited to 'src/map/unit.c') diff --git a/src/map/clif.c b/src/map/clif.c index 6c693297d..66533a6fc 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -12706,6 +12706,14 @@ static void clif_useSkillToIdReal(int fd, struct map_session_data *sd, int skill { int64 tick = timer->gettick(); + /** + * According to Skotlex' comment below, the client sometimes passes 0 for the skill level. + * Even though this seems to only affect guild skills, sd->autocast.skill_lv is used + * for the auto-cast data validation if skill_lv is 0. + * + **/ + skill->validate_autocast_data(sd, skill_id, (skill_lv == 0) ? sd->autocast.skill_lv : skill_lv); + if (skill_lv < 1) skill_lv = 1; //No clue, I have seen the client do this with guild skills :/ [Skotlex] @@ -12847,6 +12855,16 @@ static void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uin int64 tick = timer->gettick(); nullpo_retv(sd); + + /** + * When using clif_item_skill() to initiate the execution of ground skills, + * the client sometimes passes 0 for the skill level in packet 0x0af4. + * In that case sd->autocast.skill_lv is used for the auto-cast data validation, + * since clif_item_skill() is only used for auto-cast skills. + * + **/ + skill->validate_autocast_data(sd, skill_id, (skill_lv == 0) ? sd->autocast.skill_lv : skill_lv); + if( !(skill->get_inf(skill_id)&INF_GROUND_SKILL) ) return; //Using a target skill on the ground? WRONG. @@ -12985,6 +13003,12 @@ static void clif_parse_UseSkillMap(int fd, struct map_session_data *sd) return; } + /** + * Since no skill level was passed use 0 to notify skill_validate_autocast_data() of this special case. + * + **/ + skill->validate_autocast_data(sd, skill_id, 0); + pc->delinvincibletimer(sd); skill->castend_map(sd,skill_id,map_name); pc->autocast_clear(sd); diff --git a/src/map/unit.c b/src/map/unit.c index 984cc6802..c1da2c72b 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1145,8 +1145,10 @@ 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 && (ret == 0 || !skill->is_item_skill(sd, skill_id, skill_lv))) - pc->autocast_clear(sd); + if (sd != NULL && ret == 0) + pc->autocast_clear(sd); // Error in unit_skilluse_id2(). + else if (sd != NULL && ret != 0 && skill_id != SA_ABRACADABRA && skill_id != WM_RANDOMIZESPELL) + skill->validate_autocast_data(sd, skill_id, skill_lv); return ret; } @@ -1782,8 +1784,10 @@ 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 && (ret == 0 || !skill->is_item_skill(sd, skill_id, skill_lv))) - pc->autocast_clear(sd); + if (sd != NULL && ret == 0) + pc->autocast_clear(sd); // Error in unit_skilluse_pos2(). + else if (sd != NULL && ret != 0 && skill_id != SA_ABRACADABRA && skill_id != WM_RANDOMIZESPELL) + skill->validate_autocast_data(sd, skill_id, skill_lv); return ret; } -- cgit v1.2.3-70-g09d2 From 49d0ce1c60455e4971c7bf9c80f4b92ce49f377f Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Wed, 11 Mar 2020 23:02:24 +0100 Subject: Remove skill_is_item_skill() function and use map_session_data->autocast.type instead --- src/map/clif.c | 2 +- src/map/skill.c | 23 +++--------------- src/map/skill.h | 1 - src/map/unit.c | 4 ++-- src/plugins/HPMHooking/HPMHooking.Defs.inc | 2 -- .../HPMHooking/HPMHooking_map.HPMHooksCore.inc | 4 ---- .../HPMHooking/HPMHooking_map.HookingPoints.inc | 1 - src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 27 ---------------------- 8 files changed, 6 insertions(+), 58 deletions(-) (limited to 'src/map/unit.c') diff --git a/src/map/clif.c b/src/map/clif.c index 66533a6fc..1a99a07f3 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -6766,7 +6766,7 @@ static void clif_item_skill(struct map_session_data *sd, uint16 skill_id, uint16 struct PACKET_ZC_AUTORUN_SKILL *p = WFIFOP(fd, 0); int type = skill->get_inf(skill_id); - if (sd->state.itemskill_castonself == 1 && skill->is_item_skill(sd, skill_id, skill_lv)) + if (sd->state.itemskill_castonself == 1 && sd->autocast.type == AUTOCAST_ITEM) type = INF_SELF_SKILL; p->packetType = HEADER_ZC_AUTORUN_SKILL; diff --git a/src/map/skill.c b/src/map/skill.c index d21a19742..14bc9460e 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -14048,22 +14048,6 @@ static bool skill_is_combo(int skill_id) return false; } -/** - * Checks if a skill is casted by an item (itemskill() script command). - * - * @param sd The charcater's session data. - * @param skill_id The skill's ID. - * @param skill_lv The skill's level. - * @return true if skill is casted by an item, otherwise false. - */ -static bool skill_is_item_skill(struct map_session_data *sd, int skill_id, int skill_lv) -{ - nullpo_retr(false, sd); - - return (sd->skillitem == skill_id && sd->skillitemlv == skill_lv - && sd->itemskill_id == skill_id && sd->itemskill_lv == skill_lv); -} - static int skill_check_condition_castbegin(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv) { struct status_data *st; @@ -14079,7 +14063,7 @@ static int skill_check_condition_castbegin(struct map_session_data *sd, uint16 s return 0; if ((sd->state.itemskill_conditions_checked == 1 || sd->state.itemskill_check_conditions == 0) - && skill->is_item_skill(sd, skill_id, skill_lv)) { + && sd->autocast.type == AUTOCAST_ITEM) { return 1; } @@ -15068,7 +15052,7 @@ static int skill_check_condition_castend(struct map_session_data *sd, uint16 ski return 0; if ((sd->state.itemskill_conditions_checked == 1 || sd->state.itemskill_check_conditions == 0) - && skill->is_item_skill(sd, skill_id, skill_lv)) { + && sd->autocast.type == AUTOCAST_ITEM) { return 1; } @@ -15273,7 +15257,7 @@ static int skill_consume_requirement(struct map_session_data *sd, uint16 skill_i nullpo_ret(sd); - if (sd->state.itemskill_check_conditions == 0 && skill->is_item_skill(sd, skill_id, skill_lv)) + if (sd->state.itemskill_check_conditions == 0 && sd->autocast.type == AUTOCAST_ITEM) return 1; req = skill->get_requirement(sd,skill_id,skill_lv); @@ -21672,7 +21656,6 @@ void skill_defaults(void) skill->cast_fix_sc = skill_castfix_sc; skill->vf_cast_fix = skill_vfcastfix; skill->delay_fix = skill_delay_fix; - skill->is_item_skill = skill_is_item_skill; skill->check_condition_castbegin = skill_check_condition_castbegin; skill->check_condition_castend = skill_check_condition_castend; skill->consume_requirement = skill_consume_requirement; diff --git a/src/map/skill.h b/src/map/skill.h index 731044876..65195dc75 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -2029,7 +2029,6 @@ struct skill_interface { int (*cast_fix_sc) ( struct block_list *bl, int time); int (*vf_cast_fix) ( struct block_list *bl, double time, uint16 skill_id, uint16 skill_lv); int (*delay_fix) ( struct block_list *bl, uint16 skill_id, uint16 skill_lv); - bool (*is_item_skill) (struct map_session_data *sd, int skill_id, int skill_lv); int (*check_condition_castbegin) (struct map_session_data *sd, uint16 skill_id, uint16 skill_lv); int (*check_condition_castend) (struct map_session_data *sd, uint16 skill_id, uint16 skill_lv); int (*consume_requirement) (struct map_session_data *sd, uint16 skill_id, uint16 skill_lv, short type); diff --git a/src/map/unit.c b/src/map/unit.c index c1da2c72b..ab6f345ed 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1707,7 +1707,7 @@ static int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill if (!ud->state.running) //need TK_RUN or WUGDASH handler to be done before that, see bugreport:6026 unit->stop_walking(src, STOPWALKING_FLAG_FIXPOS);// even though this is not how official works but this will do the trick. bugreport:6829 - if (sd != NULL && sd->state.itemskill_no_casttime == 1 && skill->is_item_skill(sd, skill_id, skill_lv)) + if (sd != NULL && sd->state.itemskill_no_casttime == 1 && sd->autocast.type == AUTOCAST_ITEM) casttime = 0; // in official this is triggered even if no cast time. @@ -1915,7 +1915,7 @@ static int unit_skilluse_pos2(struct block_list *src, short skill_x, short skill unit->stop_walking(src, STOPWALKING_FLAG_FIXPOS); - if (sd != NULL && sd->state.itemskill_no_casttime == 1 && skill->is_item_skill(sd, skill_id, skill_lv)) + if (sd != NULL && sd->state.itemskill_no_casttime == 1 && sd->autocast.type == AUTOCAST_ITEM) casttime = 0; // in official this is triggered even if no cast time. diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc index edfd60fbc..018170812 100644 --- a/src/plugins/HPMHooking/HPMHooking.Defs.inc +++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc @@ -7332,8 +7332,6 @@ typedef int (*HPMHOOK_pre_skill_vf_cast_fix) (struct block_list **bl, double *ti typedef int (*HPMHOOK_post_skill_vf_cast_fix) (int retVal___, struct block_list *bl, double time, uint16 skill_id, uint16 skill_lv); typedef int (*HPMHOOK_pre_skill_delay_fix) (struct block_list **bl, uint16 *skill_id, uint16 *skill_lv); typedef int (*HPMHOOK_post_skill_delay_fix) (int retVal___, struct block_list *bl, uint16 skill_id, uint16 skill_lv); -typedef bool (*HPMHOOK_pre_skill_is_item_skill) (struct map_session_data **sd, int *skill_id, int *skill_lv); -typedef bool (*HPMHOOK_post_skill_is_item_skill) (bool retVal___, struct map_session_data *sd, int skill_id, int skill_lv); typedef int (*HPMHOOK_pre_skill_check_condition_castbegin) (struct map_session_data **sd, uint16 *skill_id, uint16 *skill_lv); typedef int (*HPMHOOK_post_skill_check_condition_castbegin) (int retVal___, struct map_session_data *sd, uint16 skill_id, uint16 skill_lv); typedef int (*HPMHOOK_pre_skill_check_condition_castend) (struct map_session_data **sd, uint16 *skill_id, uint16 *skill_lv); diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index fed7e7a5e..8912ad8ef 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -5856,8 +5856,6 @@ struct { struct HPMHookPoint *HP_skill_vf_cast_fix_post; struct HPMHookPoint *HP_skill_delay_fix_pre; struct HPMHookPoint *HP_skill_delay_fix_post; - struct HPMHookPoint *HP_skill_is_item_skill_pre; - struct HPMHookPoint *HP_skill_is_item_skill_post; struct HPMHookPoint *HP_skill_check_condition_castbegin_pre; struct HPMHookPoint *HP_skill_check_condition_castbegin_post; struct HPMHookPoint *HP_skill_check_condition_castend_pre; @@ -12731,8 +12729,6 @@ struct { int HP_skill_vf_cast_fix_post; int HP_skill_delay_fix_pre; int HP_skill_delay_fix_post; - int HP_skill_is_item_skill_pre; - int HP_skill_is_item_skill_post; int HP_skill_check_condition_castbegin_pre; int HP_skill_check_condition_castbegin_post; int HP_skill_check_condition_castend_pre; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index 8b38177ae..9458fc2f6 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -2997,7 +2997,6 @@ struct HookingPointData HookingPoints[] = { { HP_POP(skill->cast_fix_sc, HP_skill_cast_fix_sc) }, { HP_POP(skill->vf_cast_fix, HP_skill_vf_cast_fix) }, { HP_POP(skill->delay_fix, HP_skill_delay_fix) }, - { HP_POP(skill->is_item_skill, HP_skill_is_item_skill) }, { HP_POP(skill->check_condition_castbegin, HP_skill_check_condition_castbegin) }, { HP_POP(skill->check_condition_castend, HP_skill_check_condition_castend) }, { HP_POP(skill->consume_requirement, HP_skill_consume_requirement) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index 4b139b322..04706b751 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -78163,33 +78163,6 @@ int HP_skill_delay_fix(struct block_list *bl, uint16 skill_id, uint16 skill_lv) } return retVal___; } -bool HP_skill_is_item_skill(struct map_session_data *sd, int skill_id, int skill_lv) { - int hIndex = 0; - bool retVal___ = false; - if (HPMHooks.count.HP_skill_is_item_skill_pre > 0) { - bool (*preHookFunc) (struct map_session_data **sd, int *skill_id, int *skill_lv); - *HPMforce_return = false; - for (hIndex = 0; hIndex < HPMHooks.count.HP_skill_is_item_skill_pre; hIndex++) { - preHookFunc = HPMHooks.list.HP_skill_is_item_skill_pre[hIndex].func; - retVal___ = preHookFunc(&sd, &skill_id, &skill_lv); - } - if (*HPMforce_return) { - *HPMforce_return = false; - return retVal___; - } - } - { - retVal___ = HPMHooks.source.skill.is_item_skill(sd, skill_id, skill_lv); - } - if (HPMHooks.count.HP_skill_is_item_skill_post > 0) { - bool (*postHookFunc) (bool retVal___, struct map_session_data *sd, int skill_id, int skill_lv); - for (hIndex = 0; hIndex < HPMHooks.count.HP_skill_is_item_skill_post; hIndex++) { - postHookFunc = HPMHooks.list.HP_skill_is_item_skill_post[hIndex].func; - retVal___ = postHookFunc(retVal___, sd, skill_id, skill_lv); - } - } - return retVal___; -} int HP_skill_check_condition_castbegin(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv) { int hIndex = 0; int retVal___ = 0; -- cgit v1.2.3-70-g09d2 From 12de22e7008081c94631c8730d05d487e7b0cfcc Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Wed, 11 Mar 2020 23:16:29 +0100 Subject: Remove map_session_data->state.itemskill_* and use map_session_data->autocast.itemskill_* instead --- src/map/clif.c | 2 +- src/map/pc.c | 4 ---- src/map/pc.h | 4 ---- src/map/script.c | 7 +------ src/map/skill.c | 6 +++--- src/map/unit.c | 4 ++-- 6 files changed, 7 insertions(+), 20 deletions(-) (limited to 'src/map/unit.c') diff --git a/src/map/clif.c b/src/map/clif.c index 1a99a07f3..6b5c57d46 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -6766,7 +6766,7 @@ static void clif_item_skill(struct map_session_data *sd, uint16 skill_id, uint16 struct PACKET_ZC_AUTORUN_SKILL *p = WFIFOP(fd, 0); int type = skill->get_inf(skill_id); - if (sd->state.itemskill_castonself == 1 && sd->autocast.type == AUTOCAST_ITEM) + if (sd->autocast.itemskill_cast_on_self && sd->autocast.type == AUTOCAST_ITEM) type = INF_SELF_SKILL; p->packetType = HEADER_ZC_AUTORUN_SKILL; diff --git a/src/map/pc.c b/src/map/pc.c index 8586270b8..e181b5f89 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5354,10 +5354,6 @@ static int pc_autocast_clear(struct map_session_data *sd) sd->autocast.itemskill_check_conditions = false; sd->autocast.itemskill_instant_cast = false; sd->autocast.itemskill_cast_on_self = false; - sd->state.itemskill_conditions_checked = 0; - sd->state.itemskill_check_conditions = 0; - sd->state.itemskill_no_casttime = 0; - sd->state.itemskill_castonself = 0; return 1; } diff --git a/src/map/pc.h b/src/map/pc.h index 83b86b68b..2991bfc68 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -250,10 +250,6 @@ struct map_session_data { unsigned int refine_ui : 1; 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_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; struct { unsigned char no_weapon_damage, no_magic_damage, no_misc_damage; diff --git a/src/map/script.c b/src/map/script.c index b8f8d7638..6ed94bc92 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11007,26 +11007,21 @@ static BUILDIN(itemskill) sd->autocast.skill_lv = script_getnum(st, 3); 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_check_conditions = ((flag & ISF_CHECKCONDITIONS) == ISF_CHECKCONDITIONS) ? 1 : 0; // Unset in pc_autocast_clear(). sd->autocast.itemskill_check_conditions = ((flag & ISF_CHECKCONDITIONS) == ISF_CHECKCONDITIONS); - if (sd->state.itemskill_check_conditions == 1) { + if (sd->autocast.itemskill_check_conditions) { if (skill->check_condition_castbegin(sd, sd->skillitem, sd->skillitemlv) == 0 || skill->check_condition_castend(sd, sd->skillitem, sd->skillitemlv) == 0) { pc->autocast_clear(sd); return true; } - sd->state.itemskill_conditions_checked = 1; // Unset in pc_autocast_clear(). sd->autocast.itemskill_conditions_checked = true; } - sd->state.itemskill_no_casttime = ((flag & ISF_INSTANTCAST) == ISF_INSTANTCAST) ? 1 : 0; // Unset in pc_autocast_clear(). - sd->state.itemskill_castonself = ((flag & ISF_CASTONSELF) == ISF_CASTONSELF) ? 1 : 0; // Unset in pc_autocast_clear(). sd->autocast.itemskill_instant_cast = ((flag & ISF_INSTANTCAST) == ISF_INSTANTCAST); sd->autocast.itemskill_cast_on_self = ((flag & ISF_CASTONSELF) == ISF_CASTONSELF); diff --git a/src/map/skill.c b/src/map/skill.c index 14bc9460e..001c11c36 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -14062,7 +14062,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_check_conditions == 0) + if ((sd->autocast.itemskill_conditions_checked || !sd->autocast.itemskill_check_conditions) && sd->autocast.type == AUTOCAST_ITEM) { return 1; } @@ -15051,7 +15051,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_check_conditions == 0) + if ((sd->autocast.itemskill_conditions_checked || !sd->autocast.itemskill_check_conditions) && sd->autocast.type == AUTOCAST_ITEM) { return 1; } @@ -15257,7 +15257,7 @@ static int skill_consume_requirement(struct map_session_data *sd, uint16 skill_i nullpo_ret(sd); - if (sd->state.itemskill_check_conditions == 0 && sd->autocast.type == AUTOCAST_ITEM) + if (!sd->autocast.itemskill_check_conditions && sd->autocast.type == AUTOCAST_ITEM) return 1; req = skill->get_requirement(sd,skill_id,skill_lv); diff --git a/src/map/unit.c b/src/map/unit.c index ab6f345ed..ad4dc88b5 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1707,7 +1707,7 @@ static int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill if (!ud->state.running) //need TK_RUN or WUGDASH handler to be done before that, see bugreport:6026 unit->stop_walking(src, STOPWALKING_FLAG_FIXPOS);// even though this is not how official works but this will do the trick. bugreport:6829 - if (sd != NULL && sd->state.itemskill_no_casttime == 1 && sd->autocast.type == AUTOCAST_ITEM) + if (sd != NULL && sd->autocast.itemskill_instant_cast && sd->autocast.type == AUTOCAST_ITEM) casttime = 0; // in official this is triggered even if no cast time. @@ -1915,7 +1915,7 @@ static int unit_skilluse_pos2(struct block_list *src, short skill_x, short skill unit->stop_walking(src, STOPWALKING_FLAG_FIXPOS); - if (sd != NULL && sd->state.itemskill_no_casttime == 1 && sd->autocast.type == AUTOCAST_ITEM) + if (sd != NULL && sd->autocast.itemskill_instant_cast && sd->autocast.type == AUTOCAST_ITEM) casttime = 0; // in official this is triggered even if no cast time. -- cgit v1.2.3-70-g09d2 From 6f49858747acc7ee3767dd431bec32b919b81536 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 12 Mar 2020 00:03:54 +0100 Subject: Use map_session_data->autocast.type instead of skillitem variable to check for auto-cast skills --- src/map/clif.c | 8 ++++---- src/map/skill.c | 26 +++++++++++++------------- src/map/status.c | 6 +++--- src/map/unit.c | 4 ++-- 4 files changed, 22 insertions(+), 22 deletions(-) (limited to 'src/map/unit.c') diff --git a/src/map/clif.c b/src/map/clif.c index 6b5c57d46..074ca570b 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -12767,7 +12767,7 @@ static void clif_useSkillToIdReal(int fd, struct map_session_data *sd, int skill if (skill_id != SA_CASTCANCEL && skill_id != SO_SPELLFIST) return; } else if (DIFF_TICK(tick, sd->ud.canact_tick) < 0) { - if (sd->skillitem != skill_id) { + if (sd->autocast.type == AUTOCAST_NONE) { clif->skill_fail(sd, skill_id, USESKILL_FAIL_SKILLINTERVAL, 0, 0); return; } @@ -12785,7 +12785,7 @@ static void clif_useSkillToIdReal(int fd, struct map_session_data *sd, int skill } else if (sd->menuskill_id != SA_AUTOSPELL) return; //Can't use skills while a menu is open. } - if (sd->skillitem == skill_id) { + if (sd->autocast.type != AUTOCAST_NONE) { if (skill_lv != sd->skillitemlv) skill_lv = sd->skillitemlv; if (!(tmp&INF_SELF_SKILL)) @@ -12905,7 +12905,7 @@ static void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uin return; if( DIFF_TICK(tick, sd->ud.canact_tick) < 0 ) { - if( sd->skillitem != skill_id ) { + if (sd->autocast.type == AUTOCAST_NONE) { clif->skill_fail(sd, skill_id, USESKILL_FAIL_SKILLINTERVAL, 0, 0); return; } @@ -12926,7 +12926,7 @@ static void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uin pc->delinvincibletimer(sd); - if( sd->skillitem == skill_id ) { + if (sd->autocast.type != AUTOCAST_NONE) { if( skill_lv != sd->skillitemlv ) skill_lv = sd->skillitemlv; unit->skilluse_pos(&sd->bl, x, y, skill_id, skill_lv); diff --git a/src/map/skill.c b/src/map/skill.c index 001c11c36..8515cc3c9 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -1010,8 +1010,8 @@ static int skillnotok(uint16 skill_id, struct map_session_data *sd) if (pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL)) return 0; // can do any damn thing they want - if( skill_id == AL_TELEPORT && sd->skillitem == skill_id && sd->skillitemlv > 2 ) - return 0; // Teleport lv 3 bypasses this check.[Inkfish] + if (skill_id == AL_TELEPORT && sd->autocast.type == AUTOCAST_ITEM && sd->skillitemlv > 2) + return 0; // Teleport level 3 and higher bypasses this check if cast by itemskill() script commands. // Epoque: // This code will compare the player's attack motion value which is influenced by ASPD before @@ -1032,7 +1032,7 @@ static int skillnotok(uint16 skill_id, struct map_session_data *sd) * It has been confirmed on a official server (thanks to Yommy) that item-cast skills bypass all the restrictions below * Also, without this check, an exploit where an item casting + healing (or any other kind buff) isn't deleted after used on a restricted map **/ - if( sd->skillitem == skill_id ) + if (sd->autocast.type == AUTOCAST_ITEM) return 0; if( sd->sc.data[SC_ALL_RIDING] ) @@ -7464,7 +7464,7 @@ static int skill_castend_nodamage_id(struct block_list *src, struct block_list * map->freeblock_unlock(); return 1; } - if( sd->skillitem != skill_id ) + if (sd->autocast.type == AUTOCAST_NONE) status_zap(src, 0, skill->get_sp(skill_id, skill_lv)); // consume sp only if succeeded } break; @@ -11026,7 +11026,7 @@ static int skill_castend_map(struct map_session_data *sd, uint16 skill_id, const } } - lv = sd->skillitem==skill_id?sd->skillitemlv:pc->checkskill(sd,skill_id); + lv = (sd->autocast.type > AUTOCAST_TEMP) ? sd->skillitemlv : pc->checkskill(sd, skill_id); wx = sd->menuskill_val>>16; wy = sd->menuskill_val&0xffff; @@ -14067,8 +14067,8 @@ static int skill_check_condition_castbegin(struct map_session_data *sd, uint16 s return 1; } - if (pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL) && sd->skillitem != skill_id) { - //GMs don't override the skillItem check, otherwise they can use items without them being consumed! [Skotlex] + if (pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL) && sd->autocast.type != AUTOCAST_ITEM) { + // GMs don't override the AUTOCAST_ITEM check, otherwise they can use items without them being consumed! sd->state.arrow_atk = skill->get_ammotype(skill_id)?1:0; //Need to do arrow state check. sd->spiritball_old = sd->spiritball; //Need to do Spiritball check. return 1; @@ -14099,7 +14099,7 @@ static int skill_check_condition_castbegin(struct map_session_data *sd, uint16 s if( !sc->count ) sc = NULL; - if( sd->skillitem == skill_id ) { + if (sd->autocast.type == AUTOCAST_ITEM) { if (sd->autocast.type == AUTOCAST_ABRA || sd->autocast.type == AUTOCAST_IMPROVISE) { // Abracadabra or Improvised Song was used. sd->autocast.type = AUTOCAST_NONE; } else { @@ -14122,7 +14122,7 @@ static int skill_check_condition_castbegin(struct map_session_data *sd, uint16 s } } - if (pc_is90overweight(sd) && sd->skillitem != skill_id) { /// Skill casting items ignore the overweight restriction. [Kenpachi] + if (pc_is90overweight(sd) && sd->autocast.type != AUTOCAST_ITEM) { // Skill casting items ignore the overweight restriction. clif->skill_fail(sd, skill_id, USESKILL_FAIL_WEIGHTOVER, 0, 0); return 0; } @@ -14993,7 +14993,7 @@ static int skill_check_condition_castbegin(struct map_session_data *sd, uint16 s return 0; } - if (require.sp > 0 && st->sp < (unsigned int)require.sp && sd->skillitem != skill_id) { /// Skill casting items and Hocus-Pocus skills don't consume SP. [Kenpachi] + if (require.sp > 0 && st->sp < (unsigned int)require.sp && sd->autocast.type == AUTOCAST_NONE) { // Auto-cast skills don't consume SP. clif->skill_fail(sd, skill_id, USESKILL_FAIL_SP_INSUFFICIENT, 0, 0); return 0; } @@ -15056,8 +15056,8 @@ static int skill_check_condition_castend(struct map_session_data *sd, uint16 ski return 1; } - if( pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL) && sd->skillitem != skill_id ) { - //GMs don't override the skillItem check, otherwise they can use items without them being consumed! [Skotlex] + if (pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL) && sd->autocast.type != AUTOCAST_ITEM) { + // GMs don't override the AUTOCAST_ITEM check, otherwise they can use items without them being consumed! sd->state.arrow_atk = skill->get_ammotype(skill_id)?1:0; //Need to do arrow state check. sd->spiritball_old = sd->spiritball; //Need to do Spiritball check. return 1; @@ -15084,7 +15084,7 @@ static int skill_check_condition_castend(struct map_session_data *sd, uint16 ski break; } - if (pc_is90overweight(sd) && sd->skillitem != skill_id) { /// Skill casting items ignore the overweight restriction. [Kenpachi] + if (pc_is90overweight(sd) && sd->autocast.type != AUTOCAST_ITEM) { // Skill casting items ignore the overweight restriction. clif->skill_fail(sd, skill_id, USESKILL_FAIL_WEIGHTOVER, 0, 0); return 0; } diff --git a/src/map/status.c b/src/map/status.c index 4d798b606..a1aac8649 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1584,7 +1584,7 @@ static int status_check_skilluse(struct block_list *src, struct block_list *targ } if( skill_id ) { - if (src != NULL && (sd == NULL || sd->skillitem == 0)) { + if (src != NULL && (sd == NULL || sd->autocast.type != AUTOCAST_ITEM)) { // Items that cast skills using 'itemskill' will not be handled by map_zone_db. int i; @@ -1628,7 +1628,7 @@ static int status_check_skilluse(struct block_list *src, struct block_list *targ if (src != NULL && map->getcell(src->m, src, src->x, src->y, CELL_CHKLANDPROTECTOR) && !(st->mode&MD_BOSS) - && (src->type != BL_PC || sd->skillitem != skill_id)) + && (src->type != BL_PC || sd->autocast.type != AUTOCAST_ITEM)) return 0; break; default: @@ -1707,7 +1707,7 @@ static int status_check_skilluse(struct block_list *src, struct block_list *targ return 0; //Can't amp out of Wand of Hermode :/ [Skotlex] } - if (skill_id != 0 /* Do not block item-casted skills.*/ && (src->type != BL_PC || sd->skillitem != skill_id)) { + if (skill_id != 0 /* Do not block item-casted skills.*/ && (src->type != BL_PC || sd->autocast.type != AUTOCAST_ITEM)) { //Skills blocked through status changes... if (!flag && ( //Blocked only from using the skill (stuff like autospell may still go through sc->data[SC_SILENCE] || diff --git a/src/map/unit.c b/src/map/unit.c index ad4dc88b5..f9ea9adb6 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1745,7 +1745,7 @@ static int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill if( casttime <= 0 ) ud->state.skillcastcancel = 0; - if( !sd || sd->skillitem != skill_id || skill->get_cast(skill_id,skill_lv) ) + if (sd == NULL || sd->autocast.type < AUTOCAST_ABRA || skill->get_cast(skill_id, skill_lv) != 0) ud->canact_tick = tick + casttime + 100; if( sd ) { @@ -1884,7 +1884,7 @@ static int unit_skilluse_pos2(struct block_list *src, short skill_x, short skill } ud->state.skillcastcancel = castcancel&&casttime>0?1:0; - if( !sd || sd->skillitem != skill_id || skill->get_cast(skill_id,skill_lv) ) + if (sd == NULL || sd->autocast.type < AUTOCAST_ABRA || skill->get_cast(skill_id, skill_lv) != 0) ud->canact_tick = tick + casttime + 100; #if 0 if (sd) { -- cgit v1.2.3-70-g09d2