From 848e73703eeb15c650aee38eef46714d3863474f Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Tue, 21 Apr 2020 02:30:39 +0200 Subject: Introduce auto-cast vector --- src/map/pc.c | 3 +++ src/map/pc.h | 1 + src/map/unit.c | 2 ++ 3 files changed, 6 insertions(+) (limited to 'src/map') diff --git a/src/map/pc.c b/src/map/pc.c index 5faadf76a..411727c51 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1279,6 +1279,7 @@ static bool pc_authok(struct map_session_data *sd, int login_id2, time_t expirat sd->bg_queue.client_has_bg_data = 0; sd->bg_queue.type = 0; + VECTOR_INIT(sd->auto_cast); // Initialize auto-cast vector. VECTOR_INIT(sd->channels); VECTOR_INIT(sd->script_queues); VECTOR_INIT(sd->achievement); // Achievements [Smokexyz/Hercules] @@ -5350,6 +5351,8 @@ static int pc_autocast_clear(struct map_session_data *sd) sd->autocast.itemskill_instant_cast = false; sd->autocast.itemskill_cast_on_self = false; + VECTOR_TRUNCATE(sd->auto_cast); // Truncate auto-cast vector. + return 1; } diff --git a/src/map/pc.h b/src/map/pc.h index e560df549..32b7197a8 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -193,6 +193,7 @@ struct map_session_data { struct regen_data regen; struct regen_data_sub sregen, ssregen; struct autocast_data autocast; + VECTOR_DECL(struct autocast_data) auto_cast; // Auto-cast vector. //NOTE: When deciding to add a flag to state or special_state, take into consideration that state is preserved in //status_calc_pc, while special_state is recalculated in each call. [Skotlex] struct { diff --git a/src/map/unit.c b/src/map/unit.c index 19f09f83c..8bf0f2ce4 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2889,6 +2889,8 @@ static int unit_free(struct block_list *bl, enum clr_type clrtype) aFree(sd->instance); sd->instance = NULL; } + + VECTOR_CLEAR(sd->auto_cast); // Clear auto-cast vector. VECTOR_CLEAR(sd->channels); VECTOR_CLEAR(sd->script_queues); VECTOR_CLEAR(sd->achievement); // Achievement [Smokexyz/Hercules] -- cgit v1.2.3-60-g2f50 From c7f34b53e5bd0da415daf7d08d9abc7fe5a68116 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Tue, 21 Apr 2020 05:09:27 +0200 Subject: Add struct autocast_data auto_cast_current to struct map_session_data --- src/map/pc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/map') diff --git a/src/map/pc.h b/src/map/pc.h index 32b7197a8..d548339b2 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -193,6 +193,7 @@ struct map_session_data { struct regen_data regen; struct regen_data_sub sregen, ssregen; struct autocast_data autocast; + struct autocast_data auto_cast_current; // Currently processed auto-cast skill. VECTOR_DECL(struct autocast_data) auto_cast; // Auto-cast vector. //NOTE: When deciding to add a flag to state or special_state, take into consideration that state is preserved in //status_calc_pc, while special_state is recalculated in each call. [Skotlex] -- cgit v1.2.3-60-g2f50 From a31fa955dbc4f938f953555a50f2994f02aa14e6 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Tue, 21 Apr 2020 05:23:53 +0200 Subject: Add pc_autocast_set_current() function --- src/map/pc.c | 28 ++++++++++++++++++++++++++++ src/map/pc.h | 1 + 2 files changed, 29 insertions(+) (limited to 'src/map') diff --git a/src/map/pc.c b/src/map/pc.c index 411727c51..632b5693b 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5356,6 +5356,33 @@ static int pc_autocast_clear(struct map_session_data *sd) return 1; } +/** + * Sets a character's currently processed auto-cast skill data by comparing the skill ID. + * + * @param sd The character. + * @param skill_id The skill ID to compare. + * + **/ +static void pc_autocast_set_current(struct map_session_data *sd, int skill_id) +{ + nullpo_retv(sd); + + sd->auto_cast_current.type = AUTOCAST_NONE; + sd->auto_cast_current.skill_id = 0; + sd->auto_cast_current.skill_lv = 0; + sd->auto_cast_current.itemskill_conditions_checked = false; + sd->auto_cast_current.itemskill_check_conditions = true; + sd->auto_cast_current.itemskill_instant_cast = false; + sd->auto_cast_current.itemskill_cast_on_self = false; + + for (int i = 0; i < VECTOR_LENGTH(sd->auto_cast); i++) { + if (VECTOR_INDEX(sd->auto_cast, i).skill_id == skill_id) { + sd->auto_cast_current = VECTOR_INDEX(sd->auto_cast, i); + break; + } + } +} + /*========================================== * Add item on cart for given index. * Return: @@ -12887,6 +12914,7 @@ void pc_defaults(void) pc->checkitem = pc_checkitem; pc->useitem = pc_useitem; pc->autocast_clear = pc_autocast_clear; + pc->autocast_set_current = pc_autocast_set_current; pc->skillatk_bonus = pc_skillatk_bonus; pc->skillheal_bonus = pc_skillheal_bonus; diff --git a/src/map/pc.h b/src/map/pc.h index d548339b2..40c32f594 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -1035,6 +1035,7 @@ END_ZEROED_BLOCK; /* End */ int (*checkitem) (struct map_session_data *sd); int (*useitem) (struct map_session_data *sd,int n); int (*autocast_clear) (struct map_session_data *sd); + void (*autocast_set_current) (struct map_session_data *sd, int skill_id); int (*skillatk_bonus) (struct map_session_data *sd, uint16 skill_id); int (*skillheal_bonus) (struct map_session_data *sd, uint16 skill_id); -- cgit v1.2.3-60-g2f50 From aa84cb9979e686e11de89a235b97f9bb30456837 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Tue, 21 Apr 2020 05:29:42 +0200 Subject: Add pc_autocast_set_current() calls --- src/map/clif.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/map') diff --git a/src/map/clif.c b/src/map/clif.c index ab13ffe1f..6595e6f57 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -12804,6 +12804,8 @@ static void clif_useSkillToIdReal(int fd, struct map_session_data *sd, int skill { int64 tick = timer->gettick(); + pc->autocast_set_current(sd, skill_id); + /** * 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 @@ -12953,6 +12955,8 @@ static void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uin int64 tick = timer->gettick(); nullpo_retv(sd); + + pc->autocast_set_current(sd, skill_id); /** * When using clif_item_skill() to initiate the execution of ground skills, @@ -13100,6 +13104,8 @@ static void clif_parse_UseSkillMap(int fd, struct map_session_data *sd) clif_menuskill_clear(sd); return; } + + pc->autocast_set_current(sd, skill_id); /** * Since no skill level was passed use 0 to notify skill_validate_autocast_data() of this special case. -- cgit v1.2.3-60-g2f50 From 0009d8ed95dba17c4f559c11de58ee08f508e4f8 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Tue, 21 Apr 2020 05:34:42 +0200 Subject: Remove misplaced pc_autocast_clear() calls from BUILDIN(itemskill) --- src/map/script.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/map') diff --git a/src/map/script.c b/src/map/script.c index 347ef3d2a..7ffaced7b 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11039,7 +11039,6 @@ static BUILDIN(itemskill) if (sd == NULL || sd->ud.skilltimer != INVALID_TIMER) return true; - pc->autocast_clear(sd); sd->autocast.type = AUTOCAST_ITEM; sd->autocast.skill_id = script_isstringtype(st, 2) ? skill->name2id(script_getstr(st, 2)) : script_getnum(st, 2); sd->autocast.skill_lv = script_getnum(st, 3); @@ -11051,7 +11050,6 @@ static BUILDIN(itemskill) if (sd->autocast.itemskill_check_conditions) { if (skill->check_condition_castbegin(sd, sd->autocast.skill_id, sd->autocast.skill_lv) == 0 || skill->check_condition_castend(sd, sd->autocast.skill_id, sd->autocast.skill_lv) == 0) { - pc->autocast_clear(sd); return true; } -- cgit v1.2.3-60-g2f50 From f52be55dc66ff5adcf6e00f55abc5d91bd89e798 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Tue, 21 Apr 2020 05:39:22 +0200 Subject: Add data to auto-cast vector --- src/map/script.c | 3 +++ src/map/skill.c | 4 ++++ 2 files changed, 7 insertions(+) (limited to 'src/map') diff --git a/src/map/script.c b/src/map/script.c index 7ffaced7b..bc42cb49e 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11059,6 +11059,9 @@ static BUILDIN(itemskill) sd->autocast.itemskill_instant_cast = ((flag & ISF_INSTANTCAST) == ISF_INSTANTCAST); sd->autocast.itemskill_cast_on_self = ((flag & ISF_CASTONSELF) == ISF_CASTONSELF); + VECTOR_ENSURE(sd->auto_cast, 1, 1); + VECTOR_PUSH(sd->auto_cast, sd->autocast); + clif->item_skill(sd, sd->autocast.skill_id, sd->autocast.skill_lv); return true; diff --git a/src/map/skill.c b/src/map/skill.c index caa1a0f29..ed88ff04d 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -6353,6 +6353,8 @@ static int skill_castend_nodamage_id(struct block_list *src, struct block_list * sd->autocast.type = AUTOCAST_ABRA; sd->autocast.skill_id = abra_skill_id; sd->autocast.skill_lv = abra_skill_lv; + VECTOR_ENSURE(sd->auto_cast, 1, 1); + VECTOR_PUSH(sd->auto_cast, sd->autocast); clif->item_skill(sd, abra_skill_id, abra_skill_lv); } else { // mob-casted @@ -10095,6 +10097,8 @@ static int skill_castend_nodamage_id(struct block_list *src, struct block_list * sd->autocast.type = AUTOCAST_IMPROVISE; sd->autocast.skill_id = improv_skill_id; sd->autocast.skill_lv = improv_skill_lv; + VECTOR_ENSURE(sd->auto_cast, 1, 1); + VECTOR_PUSH(sd->auto_cast, sd->autocast); clif->item_skill(sd, improv_skill_id, improv_skill_lv); } else { struct unit_data *ud = unit->bl2ud(src); -- cgit v1.2.3-60-g2f50 From 94e9efa489b74ebed374dc7346a6605e43dedd85 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Tue, 21 Apr 2020 06:33:17 +0200 Subject: Use auto_cast_current instead of autocast --- src/map/battle.c | 12 +++---- src/map/clif.c | 22 ++++++------ src/map/pc.c | 14 ++++---- src/map/script.c | 24 ++++++------- src/map/skill.c | 102 +++++++++++++++++++++++++++---------------------------- src/map/status.c | 6 ++-- src/map/unit.c | 8 ++--- 7 files changed, 94 insertions(+), 94 deletions(-) (limited to 'src/map') diff --git a/src/map/battle.c b/src/map/battle.c index c8cd71b94..7fe9bbbb5 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -5934,14 +5934,14 @@ static void battle_reflect_damage(struct block_list *target, struct block_list * enum autocast_type ac_type; if (sd != NULL) { - ac_type = sd->autocast.type; - sd->autocast.type = AUTOCAST_TEMP; + ac_type = sd->auto_cast_current.type; + sd->auto_cast_current.type = AUTOCAST_TEMP; } map->foreachinshootrange(battle->damage_area,target,skill->get_splash(LG_REFLECTDAMAGE,1),BL_CHAR,tick,target,delay,wd->dmotion,rdamage,status_get_race(target)); if (sd != NULL) - sd->autocast.type = ac_type; + sd->auto_cast_current.type = ac_type; delay += 150;/* gradual increase so the numbers don't clip in the client */ @@ -6131,7 +6131,7 @@ static int battle_damage_area(struct block_list *bl, va_list ap) else status_fix_damage(src,bl,damage,0); clif->damage(bl,bl,amotion,dmotion,damage,1,BDT_ENDURE,0); - if (src->type != BL_PC || BL_UCCAST(BL_PC, src)->autocast.type != AUTOCAST_TEMP) + if (src->type != BL_PC || BL_UCCAST(BL_PC, src)->auto_cast_current.type != AUTOCAST_TEMP) skill->additional_effect(src, bl, CR_REFLECTSHIELD, 1, BF_WEAPON|BF_SHORT|BF_NORMAL,ATK_DEF,tick); map->freeblock_unlock(); } @@ -6455,10 +6455,10 @@ static enum damage_lv battle_weapon_attack(struct block_list *src, struct block_ } } - sd->autocast.type = AUTOCAST_TEMP; + sd->auto_cast_current.type = AUTOCAST_TEMP; skill->consume_requirement(sd,r_skill,r_lv,3); skill->castend_type(type, src, target, r_skill, r_lv, tick, flag); - sd->autocast.type = AUTOCAST_NONE; + sd->auto_cast_current.type = AUTOCAST_NONE; sd->ud.canact_tick = tick + skill->delay_fix(src, r_skill, r_lv); clif->status_change(src, status->get_sc_icon(SC_POSTDELAY), status->get_sc_relevant_bl_types(SC_POSTDELAY), 1, skill->delay_fix(src, r_skill, r_lv), 0, 0, 1); } diff --git a/src/map/clif.c b/src/map/clif.c index 6595e6f57..d9b2816bd 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->autocast.itemskill_cast_on_self && sd->autocast.type == AUTOCAST_ITEM) + if (sd->auto_cast_current.itemskill_cast_on_self && sd->auto_cast_current.type == AUTOCAST_ITEM) type = INF_SELF_SKILL; p->packetType = HEADER_ZC_AUTORUN_SKILL; @@ -12812,7 +12812,7 @@ static void clif_useSkillToIdReal(int fd, struct map_session_data *sd, int skill * 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); + skill->validate_autocast_data(sd, skill_id, (skill_lv == 0) ? sd->auto_cast_current.skill_lv : skill_lv); if (skill_lv < 1) skill_lv = 1; //No clue, I have seen the client do this with guild skills :/ [Skotlex] @@ -12867,7 +12867,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->autocast.type == AUTOCAST_NONE) { + if (sd->auto_cast_current.type == AUTOCAST_NONE) { clif->skill_fail(sd, skill_id, USESKILL_FAIL_SKILLINTERVAL, 0, 0); return; } @@ -12885,9 +12885,9 @@ 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->autocast.type != AUTOCAST_NONE) { - if (skill_lv != sd->autocast.skill_lv) - skill_lv = sd->autocast.skill_lv; + if (sd->auto_cast_current.type != AUTOCAST_NONE) { + if (skill_lv != sd->auto_cast_current.skill_lv) + skill_lv = sd->auto_cast_current.skill_lv; if (!(tmp&INF_SELF_SKILL)) pc->delinvincibletimer(sd); // Target skills through items cancel invincibility. [Inkfish] unit->skilluse_id(&sd->bl, target_id, skill_id, skill_lv); @@ -12965,7 +12965,7 @@ static void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uin * 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); + skill->validate_autocast_data(sd, skill_id, (skill_lv == 0) ? sd->auto_cast_current.skill_lv : skill_lv); if( !(skill->get_inf(skill_id)&INF_GROUND_SKILL) ) return; //Using a target skill on the ground? WRONG. @@ -13007,7 +13007,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->autocast.type == AUTOCAST_NONE) { + if (sd->auto_cast_current.type == AUTOCAST_NONE) { clif->skill_fail(sd, skill_id, USESKILL_FAIL_SKILLINTERVAL, 0, 0); return; } @@ -13028,9 +13028,9 @@ static void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uin pc->delinvincibletimer(sd); - if (sd->autocast.type != AUTOCAST_NONE) { - if (skill_lv != sd->autocast.skill_lv) - skill_lv = sd->autocast.skill_lv; + if (sd->auto_cast_current.type != AUTOCAST_NONE) { + if (skill_lv != sd->auto_cast_current.skill_lv) + skill_lv = sd->auto_cast_current.skill_lv; unit->skilluse_pos(&sd->bl, x, y, skill_id, skill_lv); } else { int lv; diff --git a/src/map/pc.c b/src/map/pc.c index 632b5693b..6985ecff8 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5343,13 +5343,13 @@ static int pc_autocast_clear(struct map_session_data *sd) { nullpo_ret(sd); - sd->autocast.type = AUTOCAST_NONE; - sd->autocast.skill_id = 0; - sd->autocast.skill_lv = 0; - sd->autocast.itemskill_conditions_checked = false; - sd->autocast.itemskill_check_conditions = false; - sd->autocast.itemskill_instant_cast = false; - sd->autocast.itemskill_cast_on_self = false; + sd->auto_cast_current.type = AUTOCAST_NONE; + sd->auto_cast_current.skill_id = 0; + sd->auto_cast_current.skill_lv = 0; + sd->auto_cast_current.itemskill_conditions_checked = false; + sd->auto_cast_current.itemskill_check_conditions = false; + sd->auto_cast_current.itemskill_instant_cast = false; + sd->auto_cast_current.itemskill_cast_on_self = false; VECTOR_TRUNCATE(sd->auto_cast); // Truncate auto-cast vector. diff --git a/src/map/script.c b/src/map/script.c index bc42cb49e..d5d81fbe5 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11039,30 +11039,30 @@ static BUILDIN(itemskill) if (sd == NULL || sd->ud.skilltimer != INVALID_TIMER) return true; - sd->autocast.type = AUTOCAST_ITEM; - sd->autocast.skill_id = script_isstringtype(st, 2) ? skill->name2id(script_getstr(st, 2)) : script_getnum(st, 2); - sd->autocast.skill_lv = script_getnum(st, 3); + sd->auto_cast_current.type = AUTOCAST_ITEM; + sd->auto_cast_current.skill_id = script_isstringtype(st, 2) ? skill->name2id(script_getstr(st, 2)) : script_getnum(st, 2); + sd->auto_cast_current.skill_lv = script_getnum(st, 3); int flag = script_hasdata(st, 4) ? script_getnum(st, 4) : ISF_NONE; - sd->autocast.itemskill_check_conditions = ((flag & ISF_CHECKCONDITIONS) == ISF_CHECKCONDITIONS); + sd->auto_cast_current.itemskill_check_conditions = ((flag & ISF_CHECKCONDITIONS) == ISF_CHECKCONDITIONS); - if (sd->autocast.itemskill_check_conditions) { - if (skill->check_condition_castbegin(sd, sd->autocast.skill_id, sd->autocast.skill_lv) == 0 - || skill->check_condition_castend(sd, sd->autocast.skill_id, sd->autocast.skill_lv) == 0) { + if (sd->auto_cast_current.itemskill_check_conditions) { + if (skill->check_condition_castbegin(sd, sd->auto_cast_current.skill_id, sd->auto_cast_current.skill_lv) == 0 + || skill->check_condition_castend(sd, sd->auto_cast_current.skill_id, sd->auto_cast_current.skill_lv) == 0) { return true; } - sd->autocast.itemskill_conditions_checked = true; + sd->auto_cast_current.itemskill_conditions_checked = true; } - sd->autocast.itemskill_instant_cast = ((flag & ISF_INSTANTCAST) == ISF_INSTANTCAST); - sd->autocast.itemskill_cast_on_self = ((flag & ISF_CASTONSELF) == ISF_CASTONSELF); + sd->auto_cast_current.itemskill_instant_cast = ((flag & ISF_INSTANTCAST) == ISF_INSTANTCAST); + sd->auto_cast_current.itemskill_cast_on_self = ((flag & ISF_CASTONSELF) == ISF_CASTONSELF); VECTOR_ENSURE(sd->auto_cast, 1, 1); - VECTOR_PUSH(sd->auto_cast, sd->autocast); + VECTOR_PUSH(sd->auto_cast, sd->auto_cast_current); - clif->item_skill(sd, sd->autocast.skill_id, sd->autocast.skill_lv); + clif->item_skill(sd, sd->auto_cast_current.skill_id, sd->auto_cast_current.skill_lv); return true; } diff --git a/src/map/skill.c b/src/map/skill.c index ed88ff04d..b7fcb2beb 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -1029,14 +1029,14 @@ static int skillnotok(uint16 skill_id, struct map_session_data *sd) if (map->getcell(sd->bl.m, &sd->bl, sd->bl.x, sd->bl.y, CELL_CHKNOSKILL)) return 1; // block usage on 'noskill' cells [Wolfie] - if (skill_id == AL_TELEPORT && sd->autocast.type == AUTOCAST_ITEM && sd->autocast.skill_lv > 2) + if (skill_id == AL_TELEPORT && sd->auto_cast_current.type == AUTOCAST_ITEM && sd->auto_cast_current.skill_lv > 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 // allowing a skill to be cast. This is to prevent no-delay ACT files from spamming skills such as // AC_DOUBLE which do not have a skill delay and are not regarded in terms of attack motion. - if (sd->autocast.type == AUTOCAST_NONE && sd->canskill_tick != 0 && + if (sd->auto_cast_current.type == AUTOCAST_NONE && sd->canskill_tick != 0 && DIFF_TICK(timer->gettick(), sd->canskill_tick) < (sd->battle_status.amotion * (battle_config.skill_amotion_leniency) / 100) ) {// attempted to cast a skill before the attack motion has finished return 1; @@ -1051,7 +1051,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->autocast.type == AUTOCAST_ITEM) + if (sd->auto_cast_current.type == AUTOCAST_ITEM) return 0; if( sd->sc.data[SC_ALL_RIDING] ) @@ -1211,13 +1211,13 @@ static void skill_validate_autocast_data(struct map_session_data *sd, int skill_ // Determine if called by clif_parse_UseSkillMap(). bool use_skill_map = (skill_lv == 0 && (skill_id == AL_WARP || skill_id == AL_TELEPORT)); - if (sd->autocast.type == AUTOCAST_NONE) + if (sd->auto_cast_current.type == AUTOCAST_NONE) pc->autocast_clear(sd); // No auto-cast type set. Preventively unset all auto-cast related data. - else if (sd->autocast.type == AUTOCAST_TEMP) + else if (sd->auto_cast_current.type == AUTOCAST_TEMP) pc->autocast_clear(sd); // AUTOCAST_TEMP should have been unset straight after usage. - else if (sd->autocast.skill_id == 0 || skill_id == 0 || sd->autocast.skill_id != skill_id) + else if (sd->auto_cast_current.skill_id == 0 || skill_id == 0 || sd->auto_cast_current.skill_id != skill_id) pc->autocast_clear(sd); // Implausible skill ID. - else if (sd->autocast.skill_lv == 0 || (!use_skill_map && (skill_lv == 0 || sd->autocast.skill_lv != skill_lv))) + else if (sd->auto_cast_current.skill_lv == 0 || (!use_skill_map && (skill_lv == 0 || sd->auto_cast_current.skill_lv != skill_lv))) pc->autocast_clear(sd); // Implausible skill level. } @@ -2109,9 +2109,9 @@ static int skill_additional_effect(struct block_list *src, struct block_list *bl temp = (sd->autospell[i].id > 0) ? sd->autospell[i].id : -sd->autospell[i].id; - sd->autocast.type = AUTOCAST_TEMP; + sd->auto_cast_current.type = AUTOCAST_TEMP; notok = skill->not_ok(temp, sd); - sd->autocast.type = AUTOCAST_NONE; + sd->auto_cast_current.type = AUTOCAST_NONE; if ( notok ) continue; @@ -2162,11 +2162,11 @@ static int skill_additional_effect(struct block_list *src, struct block_list *bl else if (temp == PF_SPIDERWEB) //Special case, due to its nature of coding. type = CAST_GROUND; - sd->autocast.type = AUTOCAST_TEMP; + sd->auto_cast_current.type = AUTOCAST_TEMP; skill->consume_requirement(sd,temp,auto_skill_lv,1); skill->toggle_magicpower(src, temp); skill->castend_type(type, src, tbl, temp, auto_skill_lv, tick, 0); - sd->autocast.type = AUTOCAST_NONE; + sd->auto_cast_current.type = AUTOCAST_NONE; //Set canact delay. [Skotlex] ud = unit->bl2ud(src); @@ -2237,7 +2237,7 @@ static int skill_onskillusage(struct map_session_data *sd, struct block_list *bl return 0; // Preserve auto-cast type if bAutoSpellOnSkill was triggered by a skill which was cast by Abracadabra, Improvised Song or an item. - enum autocast_type ac_type = sd->autocast.type; + enum autocast_type ac_type = sd->auto_cast_current.type; for( i = 0; i < ARRAYLENGTH(sd->autospell3) && sd->autospell3[i].flag; i++ ) { if( sd->autospell3[i].flag != skill_id ) @@ -2248,9 +2248,9 @@ static int skill_onskillusage(struct map_session_data *sd, struct block_list *bl temp = (sd->autospell3[i].id > 0) ? sd->autospell3[i].id : -sd->autospell3[i].id; - sd->autocast.type = AUTOCAST_TEMP; + sd->auto_cast_current.type = AUTOCAST_TEMP; notok = skill->not_ok(temp, sd); - sd->autocast.type = AUTOCAST_NONE; + sd->auto_cast_current.type = AUTOCAST_NONE; if ( notok ) continue; @@ -2297,14 +2297,14 @@ static int skill_onskillusage(struct map_session_data *sd, struct block_list *bl continue; sd->autospell3[i].lock = true; - sd->autocast.type = AUTOCAST_TEMP; + sd->auto_cast_current.type = AUTOCAST_TEMP; skill->consume_requirement(sd,temp,skill_lv,1); skill->castend_type(type, &sd->bl, tbl, temp, skill_lv, tick, 0); - sd->autocast.type = AUTOCAST_NONE; + sd->auto_cast_current.type = AUTOCAST_NONE; sd->autospell3[i].lock = false; } - sd->autocast.type = ac_type; + sd->auto_cast_current.type = ac_type; if (sd->autobonus3[0].rate) { for( i = 0; i < ARRAYLENGTH(sd->autobonus3); i++ ) { @@ -2453,7 +2453,7 @@ static int skill_counter_additional_effect(struct block_list *src, struct block_ int i, auto_skill_id, auto_skill_lv, type, notok; // Preserve auto-cast type if bAutoSpellWhenHit was triggered during cast of a skill which was cast by Abracadabra, Improvised Song or an item. - enum autocast_type ac_type = dstsd->autocast.type; + enum autocast_type ac_type = dstsd->auto_cast_current.type; for (i = 0; i < ARRAYLENGTH(dstsd->autospell2) && dstsd->autospell2[i].id; i++) { @@ -2470,9 +2470,9 @@ static int skill_counter_additional_effect(struct block_list *src, struct block_ if (attack_type&BF_LONG) rate>>=1; - dstsd->autocast.type = AUTOCAST_TEMP; + dstsd->auto_cast_current.type = AUTOCAST_TEMP; notok = skill->not_ok(auto_skill_id, dstsd); - dstsd->autocast.type = AUTOCAST_NONE; + dstsd->auto_cast_current.type = AUTOCAST_NONE; if ( notok ) continue; @@ -2513,10 +2513,10 @@ static int skill_counter_additional_effect(struct block_list *src, struct block_ if( !battle->check_range(src, tbl, skill->get_range2(src, auto_skill_id,auto_skill_lv) + (auto_skill_id == RG_CLOSECONFINE?0:1)) && battle_config.autospell_check_range ) continue; - dstsd->autocast.type = AUTOCAST_TEMP; + dstsd->auto_cast_current.type = AUTOCAST_TEMP; skill->consume_requirement(dstsd,auto_skill_id,auto_skill_lv,1); skill->castend_type(type, bl, tbl, auto_skill_id, auto_skill_lv, tick, 0); - dstsd->autocast.type = AUTOCAST_NONE; + dstsd->auto_cast_current.type = AUTOCAST_NONE; // Set canact delay. [Skotlex] ud = unit->bl2ud(bl); @@ -2530,7 +2530,7 @@ static int skill_counter_additional_effect(struct block_list *src, struct block_ } } - dstsd->autocast.type = ac_type; + dstsd->auto_cast_current.type = ac_type; } //Autobonus when attacked @@ -5843,7 +5843,7 @@ static int skill_castend_id(int tid, int64 tick, int id, intptr_t data) if (ud->walktimer != INVALID_TIMER && ud->skill_id != TK_RUN && ud->skill_id != RA_WUGDASH) unit->stop_walking(src, STOPWALKING_FLAG_FIXPOS); - if (sd == NULL || sd->autocast.skill_id != ud->skill_id || skill->get_delay(ud->skill_id,ud->skill_lv) != 0) + if (sd == NULL || sd->auto_cast_current.skill_id != ud->skill_id || skill->get_delay(ud->skill_id, ud->skill_lv) != 0) ud->canact_tick = tick + skill->delay_fix(src, ud->skill_id, ud->skill_lv); // Tests show wings don't overwrite the delay but skill scrolls do. [Inkfish] if (sd) { // Cooldown application int i, cooldown = skill->get_cooldown(ud->skill_id, ud->skill_lv); @@ -5961,7 +5961,7 @@ static int skill_castend_id(int tid, int64 tick, int id, intptr_t data) } } - if (sd == NULL || sd->autocast.skill_id != ud->skill_id || skill->get_delay(ud->skill_id,ud->skill_lv) != 0) + if (sd == NULL || sd->auto_cast_current.skill_id != ud->skill_id || skill->get_delay(ud->skill_id, ud->skill_lv) != 0) ud->canact_tick = tick; ud->skill_id = ud->skill_lv = ud->skilltarget = 0; //You can't place a skill failed packet here because it would be @@ -6350,11 +6350,11 @@ static int skill_castend_nodamage_id(struct block_list *src, struct block_list * if (sd) { // player-casted - sd->autocast.type = AUTOCAST_ABRA; - sd->autocast.skill_id = abra_skill_id; - sd->autocast.skill_lv = abra_skill_lv; + sd->auto_cast_current.type = AUTOCAST_ABRA; + sd->auto_cast_current.skill_id = abra_skill_id; + sd->auto_cast_current.skill_lv = abra_skill_lv; VECTOR_ENSURE(sd->auto_cast, 1, 1); - VECTOR_PUSH(sd->auto_cast, sd->autocast); + VECTOR_PUSH(sd->auto_cast, sd->auto_cast_current); clif->item_skill(sd, abra_skill_id, abra_skill_lv); } else { // mob-casted @@ -7483,7 +7483,7 @@ static int skill_castend_nodamage_id(struct block_list *src, struct block_list * map->freeblock_unlock(); return 1; } - if (sd->autocast.type == AUTOCAST_NONE) + if (sd->auto_cast_current.type == AUTOCAST_NONE) status_zap(src, 0, skill->get_sp(skill_id, skill_lv)); // consume sp only if succeeded } break; @@ -7520,7 +7520,7 @@ static int skill_castend_nodamage_id(struct block_list *src, struct block_list * break; } - if (sd->autocast.type == AUTOCAST_TEMP || ((sd->autocast.skill_id == AL_TELEPORT || battle_config.skip_teleport_lv1_menu) && skill_lv == 1) || skill_lv == 3) + if (sd->auto_cast_current.type == AUTOCAST_TEMP || ((sd->auto_cast_current.skill_id == AL_TELEPORT || battle_config.skip_teleport_lv1_menu) && skill_lv == 1) || skill_lv == 3) { if( skill_lv == 1 ) pc->randomwarp(sd,CLR_TELEPORT); @@ -10094,11 +10094,11 @@ static int skill_castend_nodamage_id(struct block_list *src, struct block_list * clif->skill_nodamage (src, bl, skill_id, skill_lv, 1); if (sd != NULL) { - sd->autocast.type = AUTOCAST_IMPROVISE; - sd->autocast.skill_id = improv_skill_id; - sd->autocast.skill_lv = improv_skill_lv; + sd->auto_cast_current.type = AUTOCAST_IMPROVISE; + sd->auto_cast_current.skill_id = improv_skill_id; + sd->auto_cast_current.skill_lv = improv_skill_lv; VECTOR_ENSURE(sd->auto_cast, 1, 1); - VECTOR_PUSH(sd->auto_cast, sd->autocast); + VECTOR_PUSH(sd->auto_cast, sd->auto_cast_current); clif->item_skill(sd, improv_skill_id, improv_skill_lv); } else { struct unit_data *ud = unit->bl2ud(src); @@ -10867,7 +10867,7 @@ static int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) if (ud->walktimer != INVALID_TIMER) unit->stop_walking(src, STOPWALKING_FLAG_FIXPOS); - if (sd == NULL || sd->autocast.skill_id != ud->skill_id || skill->get_delay(ud->skill_id,ud->skill_lv) != 0) + if (sd == NULL || sd->auto_cast_current.skill_id != ud->skill_id || skill->get_delay(ud->skill_id, ud->skill_lv) != 0) ud->canact_tick = tick + skill->delay_fix(src, ud->skill_id, ud->skill_lv); if (sd) { //Cooldown application int i, cooldown = skill->get_cooldown(ud->skill_id, ud->skill_lv); @@ -10896,7 +10896,7 @@ static int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) map->freeblock_lock(); skill->castend_pos2(src,ud->skillx,ud->skilly,ud->skill_id,ud->skill_lv,tick,0); - if (sd != NULL && sd->autocast.skill_id != AL_WARP) // Warp-Portal thru items will clear data in skill_castend_map. [Inkfish] + if (sd != NULL && sd->auto_cast_current.skill_id != AL_WARP) // Warp-Portal thru items will clear data in skill_castend_map. [Inkfish] pc->autocast_clear(sd); unit->set_dir(src, map->calc_dir(src, ud->skillx, ud->skilly)); @@ -10911,7 +10911,7 @@ static int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) return 1; } while(0); - if (sd == NULL || sd->autocast.skill_id != ud->skill_id || skill->get_delay(ud->skill_id,ud->skill_lv) != 0) + if (sd == NULL || sd->auto_cast_current.skill_id != ud->skill_id || skill->get_delay(ud->skill_id, ud->skill_lv) != 0) ud->canact_tick = tick; ud->skill_id = ud->skill_lv = 0; if(sd) @@ -11076,7 +11076,7 @@ static int skill_castend_map(struct map_session_data *sd, uint16 skill_id, const } } - lv = (sd->autocast.type > AUTOCAST_TEMP) ? sd->autocast.skill_lv : pc->checkskill(sd, skill_id); + lv = (sd->auto_cast_current.type > AUTOCAST_TEMP) ? sd->auto_cast_current.skill_lv : pc->checkskill(sd, skill_id); wx = sd->menuskill_val>>16; wy = sd->menuskill_val&0xffff; @@ -14112,12 +14112,12 @@ static int skill_check_condition_castbegin(struct map_session_data *sd, uint16 s if (sd->chat_id != 0) return 0; - if (((sd->autocast.itemskill_conditions_checked || !sd->autocast.itemskill_check_conditions) - && sd->autocast.type == AUTOCAST_ITEM) || sd->autocast.type == AUTOCAST_IMPROVISE) { + if (((sd->auto_cast_current.itemskill_conditions_checked || !sd->auto_cast_current.itemskill_check_conditions) + && sd->auto_cast_current.type == AUTOCAST_ITEM) || sd->auto_cast_current.type == AUTOCAST_IMPROVISE) { return 1; } - if (pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL) && sd->autocast.type != AUTOCAST_ITEM) { + if (pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL) && sd->auto_cast_current.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. @@ -14149,7 +14149,7 @@ static int skill_check_condition_castbegin(struct map_session_data *sd, uint16 s if( !sc->count ) sc = NULL; - if (pc_is90overweight(sd) && sd->autocast.type != AUTOCAST_ITEM) { // Skill casting items ignore the overweight restriction. + if (pc_is90overweight(sd) && sd->auto_cast_current.type != AUTOCAST_ITEM) { // Skill casting items ignore the overweight restriction. clif->skill_fail(sd, skill_id, USESKILL_FAIL_WEIGHTOVER, 0, 0); return 0; } @@ -15020,7 +15020,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->autocast.type == AUTOCAST_NONE) { // Auto-cast skills don't consume SP. + if (require.sp > 0 && st->sp < (unsigned int)require.sp && sd->auto_cast_current.type == AUTOCAST_NONE) { // Auto-cast skills don't consume SP. clif->skill_fail(sd, skill_id, USESKILL_FAIL_SP_INSUFFICIENT, 0, 0); return 0; } @@ -15078,12 +15078,12 @@ static int skill_check_condition_castend(struct map_session_data *sd, uint16 ski if (sd->chat_id != 0) return 0; - if (((sd->autocast.itemskill_conditions_checked || !sd->autocast.itemskill_check_conditions) - && sd->autocast.type == AUTOCAST_ITEM) || sd->autocast.type == AUTOCAST_IMPROVISE) { + if (((sd->auto_cast_current.itemskill_conditions_checked || !sd->auto_cast_current.itemskill_check_conditions) + && sd->auto_cast_current.type == AUTOCAST_ITEM) || sd->auto_cast_current.type == AUTOCAST_IMPROVISE) { return 1; } - if (pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL) && sd->autocast.type != AUTOCAST_ITEM) { + if (pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL) && sd->auto_cast_current.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. @@ -15111,7 +15111,7 @@ static int skill_check_condition_castend(struct map_session_data *sd, uint16 ski break; } - if (pc_is90overweight(sd) && sd->autocast.type != AUTOCAST_ITEM) { // Skill casting items ignore the overweight restriction. + if (pc_is90overweight(sd) && sd->auto_cast_current.type != AUTOCAST_ITEM) { // Skill casting items ignore the overweight restriction. clif->skill_fail(sd, skill_id, USESKILL_FAIL_WEIGHTOVER, 0, 0); return 0; } @@ -15282,8 +15282,8 @@ static int skill_consume_requirement(struct map_session_data *sd, uint16 skill_i nullpo_ret(sd); - if ((!sd->autocast.itemskill_check_conditions && sd->autocast.type == AUTOCAST_ITEM) - || sd->autocast.type == AUTOCAST_IMPROVISE) { + if ((!sd->auto_cast_current.itemskill_check_conditions && sd->auto_cast_current.type == AUTOCAST_ITEM) + || sd->auto_cast_current.type == AUTOCAST_IMPROVISE) { return 1; } @@ -15301,7 +15301,7 @@ static int skill_consume_requirement(struct map_session_data *sd, uint16 skill_i break; default: - if (sd->autocast.type != AUTOCAST_NONE) // Auto-cast skills don't consume SP. + if (sd->auto_cast_current.type != AUTOCAST_NONE) // Auto-cast skills don't consume SP. req.sp = 0; break; diff --git a/src/map/status.c b/src/map/status.c index dc49f7e4e..f7feda7d8 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1596,7 +1596,7 @@ static int status_check_skilluse(struct block_list *src, struct block_list *targ } if( skill_id ) { - if (src != NULL && (sd == NULL || sd->autocast.type != AUTOCAST_ITEM)) { + if (src != NULL && (sd == NULL || sd->auto_cast_current.type != AUTOCAST_ITEM)) { // Items that cast skills using 'itemskill' will not be handled by map_zone_db. int i; @@ -1640,7 +1640,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->autocast.type != AUTOCAST_ITEM)) + && (src->type != BL_PC || sd->auto_cast_current.type != AUTOCAST_ITEM)) return 0; break; default: @@ -1719,7 +1719,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->autocast.type != AUTOCAST_ITEM)) { + if (skill_id != 0 /* Do not block item-casted skills.*/ && (src->type != BL_PC || sd->auto_cast_current.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 8bf0f2ce4..530fa5f1a 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1718,7 +1718,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->autocast.itemskill_instant_cast && sd->autocast.type == AUTOCAST_ITEM) + if (sd != NULL && sd->auto_cast_current.itemskill_instant_cast && sd->auto_cast_current.type == AUTOCAST_ITEM) casttime = 0; // in official this is triggered even if no cast time. @@ -1756,7 +1756,7 @@ static int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill if( casttime <= 0 ) ud->state.skillcastcancel = 0; - if (sd == NULL || sd->autocast.type < AUTOCAST_ABRA || skill->get_cast(skill_id, skill_lv) != 0) + if (sd == NULL || sd->auto_cast_current.type < AUTOCAST_ABRA || skill->get_cast(skill_id, skill_lv) != 0) ud->canact_tick = tick + casttime + 100; if( sd ) { @@ -1895,7 +1895,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 == NULL || sd->autocast.type < AUTOCAST_ABRA || skill->get_cast(skill_id, skill_lv) != 0) + if (sd == NULL || sd->auto_cast_current.type < AUTOCAST_ABRA || skill->get_cast(skill_id, skill_lv) != 0) ud->canact_tick = tick + casttime + 100; #if 0 if (sd) { @@ -1926,7 +1926,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->autocast.itemskill_instant_cast && sd->autocast.type == AUTOCAST_ITEM) + if (sd != NULL && sd->auto_cast_current.itemskill_instant_cast && sd->auto_cast_current.type == AUTOCAST_ITEM) casttime = 0; // in official this is triggered even if no cast time. -- cgit v1.2.3-60-g2f50 From c5edda900937eb3156391dc8c2f726f34a34dba2 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Tue, 21 Apr 2020 06:33:30 +0200 Subject: Remove struct autocast_data autocast from struct map_session_data --- src/map/pc.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/map') diff --git a/src/map/pc.h b/src/map/pc.h index 40c32f594..010de1e9d 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -192,7 +192,6 @@ struct map_session_data { struct status_change sc; struct regen_data regen; struct regen_data_sub sregen, ssregen; - struct autocast_data autocast; struct autocast_data auto_cast_current; // Currently processed auto-cast skill. VECTOR_DECL(struct autocast_data) auto_cast; // Auto-cast vector. //NOTE: When deciding to add a flag to state or special_state, take into consideration that state is preserved in -- cgit v1.2.3-60-g2f50 From 77d59bad5d27a528fb503e19807bfc07cf2077b1 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Tue, 21 Apr 2020 07:06:12 +0200 Subject: Add pc_autocast_remove() function --- src/map/pc.c | 23 +++++++++++++++++++++++ src/map/pc.h | 1 + 2 files changed, 24 insertions(+) (limited to 'src/map') diff --git a/src/map/pc.c b/src/map/pc.c index 6985ecff8..9c1342836 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5383,6 +5383,28 @@ static void pc_autocast_set_current(struct map_session_data *sd, int skill_id) } } +/** + * Removes a specific entry from a character's auto-cast vector. + * + * @param sd The character. + * @param type The entry's auto-cast type. + * @param skill_id The entry's skill ID. + * @param skill_lv The entry's skill level. + * + **/ +static void pc_autocast_remove(struct map_session_data *sd, enum autocast_type type, int skill_id, int skill_lv) +{ + nullpo_retv(sd); + + for (int i = 0; i < VECTOR_LENGTH(sd->auto_cast); i++) { + if (VECTOR_INDEX(sd->auto_cast, i).type == type && VECTOR_INDEX(sd->auto_cast, i).skill_id == skill_id + && VECTOR_INDEX(sd->auto_cast, i).skill_lv == skill_lv) { + VECTOR_ERASE(sd->auto_cast, i); + break; + } + } +} + /*========================================== * Add item on cart for given index. * Return: @@ -12915,6 +12937,7 @@ void pc_defaults(void) pc->useitem = pc_useitem; pc->autocast_clear = pc_autocast_clear; pc->autocast_set_current = pc_autocast_set_current; + pc->autocast_remove = pc_autocast_remove; pc->skillatk_bonus = pc_skillatk_bonus; pc->skillheal_bonus = pc_skillheal_bonus; diff --git a/src/map/pc.h b/src/map/pc.h index 010de1e9d..9012a67cb 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -1035,6 +1035,7 @@ END_ZEROED_BLOCK; /* End */ int (*useitem) (struct map_session_data *sd,int n); int (*autocast_clear) (struct map_session_data *sd); void (*autocast_set_current) (struct map_session_data *sd, int skill_id); + void (*autocast_remove) (struct map_session_data *sd, enum autocast_type type, int skill_id, int skill_lv); int (*skillatk_bonus) (struct map_session_data *sd, uint16 skill_id); int (*skillheal_bonus) (struct map_session_data *sd, uint16 skill_id); -- cgit v1.2.3-60-g2f50 From 505122c96f725384d7687c55f2cb92d3b0ae0a8b Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Tue, 21 Apr 2020 06:55:10 +0200 Subject: Add pc_autocast_remove() calls --- src/map/skill.c | 31 ++++++++++++++++++++----------- src/map/unit.c | 14 ++++++-------- 2 files changed, 26 insertions(+), 19 deletions(-) (limited to 'src/map') diff --git a/src/map/skill.c b/src/map/skill.c index b7fcb2beb..f30142af7 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -1211,14 +1211,16 @@ static void skill_validate_autocast_data(struct map_session_data *sd, int skill_ // Determine if called by clif_parse_UseSkillMap(). bool use_skill_map = (skill_lv == 0 && (skill_id == AL_WARP || skill_id == AL_TELEPORT)); - if (sd->auto_cast_current.type == AUTOCAST_NONE) + struct autocast_data *auto_cast = &sd->auto_cast_current; + + if (auto_cast->type == AUTOCAST_NONE) pc->autocast_clear(sd); // No auto-cast type set. Preventively unset all auto-cast related data. - else if (sd->auto_cast_current.type == AUTOCAST_TEMP) + else if (auto_cast->type == AUTOCAST_TEMP) pc->autocast_clear(sd); // AUTOCAST_TEMP should have been unset straight after usage. - else if (sd->auto_cast_current.skill_id == 0 || skill_id == 0 || sd->auto_cast_current.skill_id != skill_id) - pc->autocast_clear(sd); // Implausible skill ID. - else if (sd->auto_cast_current.skill_lv == 0 || (!use_skill_map && (skill_lv == 0 || sd->auto_cast_current.skill_lv != skill_lv))) - pc->autocast_clear(sd); // Implausible skill level. + else if (auto_cast->skill_id == 0 || skill_id == 0 || auto_cast->skill_id != skill_id) + pc->autocast_remove(sd, auto_cast->type, auto_cast->skill_id, auto_cast->skill_lv); // Implausible skill ID. + else if (auto_cast->skill_lv == 0 || (!use_skill_map && (skill_lv == 0 || auto_cast->skill_lv != skill_lv))) + pc->autocast_remove(sd, auto_cast->type, auto_cast->skill_id, auto_cast->skill_lv); // Implausible skill level. } static struct s_skill_unit_layout *skill_get_unit_layout(uint16 skill_id, uint16 skill_lv, struct block_list *src, int x, int y) @@ -5912,7 +5914,8 @@ static int skill_castend_id(int tid, int64 tick, int id, intptr_t data) } if( sd && ud->skill_id != SA_ABRACADABRA && ud->skill_id != WM_RANDOMIZESPELL ) // they just set the data so leave it as it is.[Inkfish] - pc->autocast_clear(sd); + pc->autocast_remove(sd, sd->auto_cast_current.type, sd->auto_cast_current.skill_id, + sd->auto_cast_current.skill_lv); if (ud->skilltimer == INVALID_TIMER) { if(md) md->skill_idx = -1; @@ -5968,7 +5971,8 @@ static int skill_castend_id(int tid, int64 tick, int id, intptr_t data) //sent in ALL cases, even cases where skill_check_condition fails //which would lead to double 'skill failed' messages u.u [Skotlex] if(sd) - pc->autocast_clear(sd); + pc->autocast_remove(sd, sd->auto_cast_current.type, sd->auto_cast_current.skill_id, + sd->auto_cast_current.skill_lv); else if(md) md->skill_idx = -1; return 0; @@ -10897,7 +10901,8 @@ static int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) skill->castend_pos2(src,ud->skillx,ud->skilly,ud->skill_id,ud->skill_lv,tick,0); if (sd != NULL && sd->auto_cast_current.skill_id != AL_WARP) // Warp-Portal thru items will clear data in skill_castend_map. [Inkfish] - pc->autocast_clear(sd); + pc->autocast_remove(sd, sd->auto_cast_current.type, sd->auto_cast_current.skill_id, + sd->auto_cast_current.skill_lv); unit->set_dir(src, map->calc_dir(src, ud->skillx, ud->skilly)); @@ -10915,7 +10920,8 @@ static int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) ud->canact_tick = tick; ud->skill_id = ud->skill_lv = 0; if(sd) - pc->autocast_clear(sd); + pc->autocast_remove(sd, sd->auto_cast_current.type, sd->auto_cast_current.skill_id, + sd->auto_cast_current.skill_lv); else if(md) md->skill_idx = -1; return 0; @@ -11099,7 +11105,10 @@ static int skill_castend_map(struct map_session_data *sd, uint16 skill_id, const } skill->consume_requirement(sd,sd->menuskill_id,lv,2); - pc->autocast_clear(sd); // Clear data which was skipped in skill_castend_pos(). + + // Clear data which was skipped in skill_castend_pos(). + pc->autocast_remove(sd, sd->auto_cast_current.type, sd->auto_cast_current.skill_id, + sd->auto_cast_current.skill_lv); if((group=skill->unitsetting(&sd->bl,skill_id,lv,wx,wy,0))==NULL) { skill_failed(sd); diff --git a/src/map/unit.c b/src/map/unit.c index 530fa5f1a..53e517045 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1156,10 +1156,9 @@ 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) - 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); + if (sd != NULL) + pc->autocast_remove(sd, sd->auto_cast_current.type, sd->auto_cast_current.skill_id, + sd->auto_cast_current.skill_lv); return ret; } @@ -1795,10 +1794,9 @@ 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) - 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); + if (sd != NULL) + pc->autocast_remove(sd, sd->auto_cast_current.type, sd->auto_cast_current.skill_id, + sd->auto_cast_current.skill_lv); return ret; } -- cgit v1.2.3-60-g2f50 From 982dbd0ede4da728c9e10351f3a6e6acb14199ec Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Tue, 21 Apr 2020 07:37:22 +0200 Subject: Add pc_autocast_clear() calls --- src/map/skill.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/map') diff --git a/src/map/skill.c b/src/map/skill.c index f30142af7..136188238 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -6354,6 +6354,7 @@ static int skill_castend_nodamage_id(struct block_list *src, struct block_list * if (sd) { // player-casted + pc->autocast_clear(sd); sd->auto_cast_current.type = AUTOCAST_ABRA; sd->auto_cast_current.skill_id = abra_skill_id; sd->auto_cast_current.skill_lv = abra_skill_lv; @@ -10098,6 +10099,7 @@ static int skill_castend_nodamage_id(struct block_list *src, struct block_list * clif->skill_nodamage (src, bl, skill_id, skill_lv, 1); if (sd != NULL) { + pc->autocast_clear(sd); sd->auto_cast_current.type = AUTOCAST_IMPROVISE; sd->auto_cast_current.skill_id = improv_skill_id; sd->auto_cast_current.skill_lv = improv_skill_lv; -- cgit v1.2.3-60-g2f50 From 134fc00a1906793184ede7ec4351afbf2d204569 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Tue, 21 Apr 2020 07:42:04 +0200 Subject: Add pc_autocast_clear_current() function --- src/map/pc.c | 20 ++++++++++++++++++++ src/map/pc.h | 1 + 2 files changed, 21 insertions(+) (limited to 'src/map') diff --git a/src/map/pc.c b/src/map/pc.c index 9c1342836..56a4b938d 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5333,6 +5333,25 @@ static int pc_useitem(struct map_session_data *sd, int n) return 1; } +/** + * Unsets a character's currently processed auto-cast skill data. + * + * @param sd The character. + * + **/ +static void pc_autocast_clear_current(struct map_session_data *sd) +{ + nullpo_retv(sd); + + sd->auto_cast_current.type = AUTOCAST_NONE; + sd->auto_cast_current.skill_id = 0; + sd->auto_cast_current.skill_lv = 0; + sd->auto_cast_current.itemskill_conditions_checked = false; + sd->auto_cast_current.itemskill_check_conditions = true; + sd->auto_cast_current.itemskill_instant_cast = false; + sd->auto_cast_current.itemskill_cast_on_self = false; +} + /** * Unsets a character's auto-cast related data. * @@ -12935,6 +12954,7 @@ void pc_defaults(void) pc->unequipitem_pos = pc_unequipitem_pos; pc->checkitem = pc_checkitem; pc->useitem = pc_useitem; + pc->autocast_clear_current = pc_autocast_clear_current; pc->autocast_clear = pc_autocast_clear; pc->autocast_set_current = pc_autocast_set_current; pc->autocast_remove = pc_autocast_remove; diff --git a/src/map/pc.h b/src/map/pc.h index 9012a67cb..eff317847 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -1033,6 +1033,7 @@ END_ZEROED_BLOCK; /* End */ void (*unequipitem_pos) (struct map_session_data *sd, int n, int pos); int (*checkitem) (struct map_session_data *sd); int (*useitem) (struct map_session_data *sd,int n); + void (*autocast_clear_current) (struct map_session_data *sd); int (*autocast_clear) (struct map_session_data *sd); void (*autocast_set_current) (struct map_session_data *sd, int skill_id); void (*autocast_remove) (struct map_session_data *sd, enum autocast_type type, int skill_id, int skill_lv); -- cgit v1.2.3-60-g2f50 From 1f1bc12648dd2dc4a88c5e49164f1142d36c69ea Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Tue, 21 Apr 2020 07:43:37 +0200 Subject: Add pc_autocast_clear_current() calls --- src/map/pc.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'src/map') diff --git a/src/map/pc.c b/src/map/pc.c index 56a4b938d..d1d224aa7 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5362,14 +5362,7 @@ static int pc_autocast_clear(struct map_session_data *sd) { nullpo_ret(sd); - sd->auto_cast_current.type = AUTOCAST_NONE; - sd->auto_cast_current.skill_id = 0; - sd->auto_cast_current.skill_lv = 0; - sd->auto_cast_current.itemskill_conditions_checked = false; - sd->auto_cast_current.itemskill_check_conditions = false; - sd->auto_cast_current.itemskill_instant_cast = false; - sd->auto_cast_current.itemskill_cast_on_self = false; - + pc->autocast_clear_current(sd); VECTOR_TRUNCATE(sd->auto_cast); // Truncate auto-cast vector. return 1; @@ -5386,13 +5379,7 @@ static void pc_autocast_set_current(struct map_session_data *sd, int skill_id) { nullpo_retv(sd); - sd->auto_cast_current.type = AUTOCAST_NONE; - sd->auto_cast_current.skill_id = 0; - sd->auto_cast_current.skill_lv = 0; - sd->auto_cast_current.itemskill_conditions_checked = false; - sd->auto_cast_current.itemskill_check_conditions = true; - sd->auto_cast_current.itemskill_instant_cast = false; - sd->auto_cast_current.itemskill_cast_on_self = false; + pc->autocast_clear_current(sd); for (int i = 0; i < VECTOR_LENGTH(sd->auto_cast); i++) { if (VECTOR_INDEX(sd->auto_cast, i).skill_id == skill_id) { -- cgit v1.2.3-60-g2f50 From 9bc5fadd7e57e71d861259c828c39cac5d0545a3 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Tue, 21 Apr 2020 07:53:57 +0200 Subject: Change pc_autocast_clear() function to void --- src/map/pc.c | 12 +++++------- src/map/pc.h | 2 +- src/plugins/HPMHooking/HPMHooking.Defs.inc | 4 ++-- src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 17 ++++++++--------- 4 files changed, 16 insertions(+), 19 deletions(-) (limited to 'src/map') diff --git a/src/map/pc.c b/src/map/pc.c index d1d224aa7..4497ef54f 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5355,17 +5355,15 @@ static void pc_autocast_clear_current(struct map_session_data *sd) /** * Unsets a character's auto-cast related data. * - * @param sd The character's session data. - * @return 0 if parameter sd is NULL, otherwise 1. - */ -static int pc_autocast_clear(struct map_session_data *sd) + * @param sd The character. + * + **/ +static void pc_autocast_clear(struct map_session_data *sd) { - nullpo_ret(sd); + nullpo_retv(sd); pc->autocast_clear_current(sd); VECTOR_TRUNCATE(sd->auto_cast); // Truncate auto-cast vector. - - return 1; } /** diff --git a/src/map/pc.h b/src/map/pc.h index eff317847..f2eca0b89 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -1034,7 +1034,7 @@ END_ZEROED_BLOCK; /* End */ int (*checkitem) (struct map_session_data *sd); int (*useitem) (struct map_session_data *sd,int n); void (*autocast_clear_current) (struct map_session_data *sd); - int (*autocast_clear) (struct map_session_data *sd); + void (*autocast_clear) (struct map_session_data *sd); void (*autocast_set_current) (struct map_session_data *sd, int skill_id); void (*autocast_remove) (struct map_session_data *sd, enum autocast_type type, int skill_id, int skill_lv); diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc index ef71f1967..54e5c2da3 100644 --- a/src/plugins/HPMHooking/HPMHooking.Defs.inc +++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc @@ -6200,8 +6200,8 @@ typedef int (*HPMHOOK_pre_pc_checkitem) (struct map_session_data **sd); typedef int (*HPMHOOK_post_pc_checkitem) (int retVal___, struct map_session_data *sd); typedef int (*HPMHOOK_pre_pc_useitem) (struct map_session_data **sd, int *n); typedef int (*HPMHOOK_post_pc_useitem) (int retVal___, struct map_session_data *sd, int n); -typedef int (*HPMHOOK_pre_pc_autocast_clear) (struct map_session_data **sd); -typedef int (*HPMHOOK_post_pc_autocast_clear) (int retVal___, struct map_session_data *sd); +typedef void (*HPMHOOK_pre_pc_autocast_clear) (struct map_session_data **sd); +typedef void (*HPMHOOK_post_pc_autocast_clear) (struct map_session_data *sd); typedef int (*HPMHOOK_pre_pc_skillatk_bonus) (struct map_session_data **sd, uint16 *skill_id); typedef int (*HPMHOOK_post_pc_skillatk_bonus) (int retVal___, struct map_session_data *sd, uint16 skill_id); typedef int (*HPMHOOK_pre_pc_skillheal_bonus) (struct map_session_data **sd, uint16 *skill_id); diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index 02d55228e..c5be1529e 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -63569,32 +63569,31 @@ int HP_pc_useitem(struct map_session_data *sd, int n) { } return retVal___; } -int HP_pc_autocast_clear(struct map_session_data *sd) { +void HP_pc_autocast_clear(struct map_session_data *sd) { int hIndex = 0; - int retVal___ = 0; if (HPMHooks.count.HP_pc_autocast_clear_pre > 0) { - int (*preHookFunc) (struct map_session_data **sd); + void (*preHookFunc) (struct map_session_data **sd); *HPMforce_return = false; for (hIndex = 0; hIndex < HPMHooks.count.HP_pc_autocast_clear_pre; hIndex++) { preHookFunc = HPMHooks.list.HP_pc_autocast_clear_pre[hIndex].func; - retVal___ = preHookFunc(&sd); + preHookFunc(&sd); } if (*HPMforce_return) { *HPMforce_return = false; - return retVal___; + return; } } { - retVal___ = HPMHooks.source.pc.autocast_clear(sd); + HPMHooks.source.pc.autocast_clear(sd); } if (HPMHooks.count.HP_pc_autocast_clear_post > 0) { - int (*postHookFunc) (int retVal___, struct map_session_data *sd); + void (*postHookFunc) (struct map_session_data *sd); for (hIndex = 0; hIndex < HPMHooks.count.HP_pc_autocast_clear_post; hIndex++) { postHookFunc = HPMHooks.list.HP_pc_autocast_clear_post[hIndex].func; - retVal___ = postHookFunc(retVal___, sd); + postHookFunc(sd); } } - return retVal___; + return; } int HP_pc_skillatk_bonus(struct map_session_data *sd, uint16 skill_id) { int hIndex = 0; -- cgit v1.2.3-60-g2f50 From 292f740b40842fbf474ffd00e49aa358ee99bac1 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Tue, 21 Apr 2020 09:34:51 +0200 Subject: Adjust conditions to call pc_autocast_remove() --- src/map/skill.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'src/map') diff --git a/src/map/skill.c b/src/map/skill.c index 136188238..ceb979c1f 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -5913,9 +5913,10 @@ static int skill_castend_id(int tid, int64 tick, int id, intptr_t data) skill->blockpc_start(sd,BD_ADAPTATION,3000); } - if( sd && ud->skill_id != SA_ABRACADABRA && ud->skill_id != WM_RANDOMIZESPELL ) // they just set the data so leave it as it is.[Inkfish] - pc->autocast_remove(sd, sd->auto_cast_current.type, sd->auto_cast_current.skill_id, - sd->auto_cast_current.skill_lv); + if (sd != NULL && ud->skill_id != SA_ABRACADABRA && ud->skill_id != WM_RANDOMIZESPELL + && ud->skill_id == sd->auto_cast_current.skill_id) { // they just set the data so leave it as it is.[Inkfish] + pc->autocast_remove(sd, sd->auto_cast_current.type, ud->skill_id, ud->skill_lv); + } if (ud->skilltimer == INVALID_TIMER) { if(md) md->skill_idx = -1; @@ -5966,15 +5967,18 @@ static int skill_castend_id(int tid, int64 tick, int id, intptr_t data) if (sd == NULL || sd->auto_cast_current.skill_id != ud->skill_id || skill->get_delay(ud->skill_id, ud->skill_lv) != 0) ud->canact_tick = tick; - ud->skill_id = ud->skill_lv = ud->skilltarget = 0; //You can't place a skill failed packet here because it would be //sent in ALL cases, even cases where skill_check_condition fails //which would lead to double 'skill failed' messages u.u [Skotlex] - if(sd) - pc->autocast_remove(sd, sd->auto_cast_current.type, sd->auto_cast_current.skill_id, - sd->auto_cast_current.skill_lv); + if (sd != NULL && ud->skill_id == sd->auto_cast_current.skill_id) + pc->autocast_remove(sd, sd->auto_cast_current.type, ud->skill_id, ud->skill_lv); else if(md) md->skill_idx = -1; + + ud->skill_id = 0; + ud->skill_lv = 0; + ud->skilltarget = 0; + return 0; } @@ -10902,9 +10906,8 @@ static int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) map->freeblock_lock(); skill->castend_pos2(src,ud->skillx,ud->skilly,ud->skill_id,ud->skill_lv,tick,0); - if (sd != NULL && sd->auto_cast_current.skill_id != AL_WARP) // Warp-Portal thru items will clear data in skill_castend_map. [Inkfish] - pc->autocast_remove(sd, sd->auto_cast_current.type, sd->auto_cast_current.skill_id, - sd->auto_cast_current.skill_lv); + if (sd != NULL && ud->skill_id != AL_WARP && ud->skill_id == sd->auto_cast_current.skill_id) // Warp-Portal thru items will clear data in skill_castend_map. [Inkfish] + pc->autocast_remove(sd, sd->auto_cast_current.type, ud->skill_id, ud->skill_lv); unit->set_dir(src, map->calc_dir(src, ud->skillx, ud->skilly)); @@ -10920,12 +10923,15 @@ static int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) if (sd == NULL || sd->auto_cast_current.skill_id != ud->skill_id || skill->get_delay(ud->skill_id, ud->skill_lv) != 0) ud->canact_tick = tick; - ud->skill_id = ud->skill_lv = 0; - if(sd) - pc->autocast_remove(sd, sd->auto_cast_current.type, sd->auto_cast_current.skill_id, - sd->auto_cast_current.skill_lv); + + if (sd != NULL && ud->skill_id == sd->auto_cast_current.skill_id) + pc->autocast_remove(sd, sd->auto_cast_current.type, ud->skill_id, ud->skill_lv); else if(md) md->skill_idx = -1; + + ud->skill_id = 0; + ud->skill_lv = 0; + return 0; } -- cgit v1.2.3-60-g2f50 From 8ef065eada5f135a8837963b878f381e3c597d8a Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Tue, 21 Apr 2020 09:36:23 +0200 Subject: Don't abort auto-cast skills if sd->ud.skilltimer is not INVALID_TIMER --- src/map/clif.c | 4 ++-- src/map/script.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/map') diff --git a/src/map/clif.c b/src/map/clif.c index d9b2816bd..2778c0f03 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -12864,7 +12864,7 @@ static void clif_useSkillToIdReal(int fd, struct map_session_data *sd, int skill target_id = sd->bl.id; if (sd->ud.skilltimer != INVALID_TIMER) { - if (skill_id != SA_CASTCANCEL && skill_id != SO_SPELLFIST) + if (skill_id != SA_CASTCANCEL && skill_id != SO_SPELLFIST && sd->auto_cast_current.type == AUTOCAST_NONE) return; } else if (DIFF_TICK(tick, sd->ud.canact_tick) < 0) { if (sd->auto_cast_current.type == AUTOCAST_NONE) { @@ -13003,7 +13003,7 @@ static void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uin safestrncpy(sd->message, RFIFOP(fd, skillmoreinfo), TALKBOX_MESSAGE_SIZE); } - if( sd->ud.skilltimer != INVALID_TIMER ) + if (sd->ud.skilltimer != INVALID_TIMER && sd->auto_cast_current.type == AUTOCAST_NONE) return; if( DIFF_TICK(tick, sd->ud.canact_tick) < 0 ) { diff --git a/src/map/script.c b/src/map/script.c index d5d81fbe5..14db20549 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11036,7 +11036,7 @@ static BUILDIN(itemskill) { struct map_session_data *sd = script->rid2sd(st); - if (sd == NULL || sd->ud.skilltimer != INVALID_TIMER) + if (sd == NULL) return true; sd->auto_cast_current.type = AUTOCAST_ITEM; -- cgit v1.2.3-60-g2f50 From 468c81a5367c444e2e678148d556df94eaa623af Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Sat, 30 May 2020 01:50:18 +0200 Subject: Move misplaced SC_ALL_RIDING check in status_check_skilluse() --- src/map/status.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/map') diff --git a/src/map/status.c b/src/map/status.c index f7feda7d8..1e92bbd6a 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1737,6 +1737,7 @@ static int status_check_skilluse(struct block_list *src, struct block_list *targ (sc->data[SC_MARIONETTE] && skill_id == CG_MARIONETTE) || //Cannot use marionette if you are being buffed by another (sc->data[SC_STASIS] && skill->block_check(src, SC_STASIS, skill_id)) || (sc->data[SC_KG_KAGEHUMI] && skill->block_check(src, SC_KG_KAGEHUMI, skill_id)) + || sc->data[SC_ALL_RIDING] != NULL // New mounts can't attack nor use skills in the client; this check makes it cheat-safe. [Ind] )) return 0; @@ -1785,8 +1786,6 @@ static int status_check_skilluse(struct block_list *src, struct block_list *targ } else if ( skill_id != ST_CHASEWALK ) return 0; } - if( sc->data[SC_ALL_RIDING] ) - return 0;//New mounts can't attack nor use skills in the client; this check makes it cheat-safe [Ind] } if (target == NULL || target == src) //No further checking needed. -- cgit v1.2.3-60-g2f50