From 3e847676d726c0e38782ce3708be430289972405 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Wed, 11 Mar 2020 20:46:44 +0100 Subject: Add map_session_data->autocast.type assignments --- src/map/pc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/map/pc.c') diff --git a/src/map/pc.c b/src/map/pc.c index c604e16dc..73bae2b5b 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5346,6 +5346,7 @@ static int pc_itemskill_clear(struct map_session_data *sd) { nullpo_ret(sd); + sd->autocast.type = AUTOCAST_NONE; sd->itemskill_id = 0; sd->itemskill_lv = 0; sd->state.itemskill_conditions_checked = 0; -- cgit v1.2.3-60-g2f50 From 80e505df06aab94b74210cc2f0e0651d6b6feb5f Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Wed, 11 Mar 2020 20:53:34 +0100 Subject: Add map_session_data->autocast.skill_id/_lv assignments --- src/map/pc.c | 2 ++ src/map/script.c | 2 ++ src/map/skill.c | 4 ++++ 3 files changed, 8 insertions(+) (limited to 'src/map/pc.c') diff --git a/src/map/pc.c b/src/map/pc.c index 73bae2b5b..0981cdee9 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5347,6 +5347,8 @@ static int pc_itemskill_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->itemskill_id = 0; sd->itemskill_lv = 0; sd->state.itemskill_conditions_checked = 0; diff --git a/src/map/script.c b/src/map/script.c index 18855e3b0..44cab8429 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11003,6 +11003,8 @@ static BUILDIN(itemskill) pc->itemskill_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); 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. diff --git a/src/map/skill.c b/src/map/skill.c index a83f3bfe5..5ceff376f 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -6322,6 +6322,8 @@ 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->state.abra_flag = 1; sd->skillitem = abra_skill_id; sd->skillitemlv = abra_skill_lv; @@ -10065,6 +10067,8 @@ static int skill_castend_nodamage_id(struct block_list *src, struct block_list * if (sd != NULL) { sd->autocast.type = AUTOCAST_IMPROVISE; + sd->autocast.skill_id = improv_skill_id; + sd->autocast.skill_lv = improv_skill_lv; sd->state.abra_flag = 2; sd->skillitem = improv_skill_id; sd->skillitemlv = improv_skill_lv; -- cgit v1.2.3-60-g2f50 From 735b763ed55c8cf9aca3ddeb6b469ce43896bf7d Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Wed, 11 Mar 2020 21:04:42 +0100 Subject: Add map_session_data->autocast.itemskill_* assignments --- src/map/pc.c | 4 ++++ src/map/script.c | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'src/map/pc.c') diff --git a/src/map/pc.c b/src/map/pc.c index 0981cdee9..ebba015a2 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5349,6 +5349,10 @@ static int pc_itemskill_clear(struct map_session_data *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->itemskill_id = 0; sd->itemskill_lv = 0; sd->state.itemskill_conditions_checked = 0; diff --git a/src/map/script.c b/src/map/script.c index 44cab8429..83c221e78 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11012,6 +11012,7 @@ static BUILDIN(itemskill) 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_itemskill_clear(). + sd->autocast.itemskill_check_conditions = ((flag & ISF_CHECKCONDITIONS) == ISF_CHECKCONDITIONS); if (sd->state.itemskill_check_conditions == 1) { if (skill->check_condition_castbegin(sd, sd->skillitem, sd->skillitemlv) == 0 @@ -11021,10 +11022,13 @@ static BUILDIN(itemskill) } sd->state.itemskill_conditions_checked = 1; // Unset in pc_itemskill_clear(). + sd->autocast.itemskill_conditions_checked = true; } sd->state.itemskill_no_casttime = ((flag & ISF_INSTANTCAST) == ISF_INSTANTCAST) ? 1 : 0; // Unset in pc_itemskill_clear(). sd->state.itemskill_castonself = ((flag & ISF_CASTONSELF) == ISF_CASTONSELF) ? 1 : 0; // Unset in pc_itemskill_clear(). + sd->autocast.itemskill_instant_cast = ((flag & ISF_INSTANTCAST) == ISF_INSTANTCAST); + sd->autocast.itemskill_cast_on_self = ((flag & ISF_CASTONSELF) == ISF_CASTONSELF); // itemskill_conditions_checked/itemskill_no_conditions/itemskill_no_casttime/itemskill_castonself abuse prevention. Unset in pc_itemskill_clear(). sd->itemskill_id = sd->skillitem; -- cgit v1.2.3-60-g2f50 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/clif.c | 2 +- src/map/pc.c | 6 +++--- src/map/pc.h | 2 +- src/map/script.c | 14 +++++++------- src/map/skill.c | 2 +- src/map/unit.c | 4 ++-- src/plugins/HPMHooking/HPMHooking.Defs.inc | 4 ++-- src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc | 8 ++++---- src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc | 2 +- src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 16 ++++++++-------- 10 files changed, 30 insertions(+), 30 deletions(-) (limited to 'src/map/pc.c') diff --git a/src/map/clif.c b/src/map/clif.c index c9e018f73..d7dffb293 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -12987,7 +12987,7 @@ static void clif_parse_UseSkillMap(int fd, struct map_session_data *sd) pc->delinvincibletimer(sd); skill->castend_map(sd,skill_id,map_name); - pc->itemskill_clear(sd); + pc->autocast_clear(sd); } static void clif_parse_RequestMemo(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); diff --git a/src/map/pc.c b/src/map/pc.c index ebba015a2..073c16029 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5337,12 +5337,12 @@ static int pc_useitem(struct map_session_data *sd, int n) } /** - * Sets state flags and helper variables, used by itemskill() script command, to 0. + * 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_itemskill_clear(struct map_session_data *sd) +static int pc_autocast_clear(struct map_session_data *sd) { nullpo_ret(sd); @@ -12733,7 +12733,7 @@ void pc_defaults(void) pc->unequipitem_pos = pc_unequipitem_pos; pc->checkitem = pc_checkitem; pc->useitem = pc_useitem; - pc->itemskill_clear = pc_itemskill_clear; + pc->autocast_clear = pc_autocast_clear; 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 f069c0d66..92444aa2a 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -1046,7 +1046,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); - int (*itemskill_clear) (struct map_session_data *sd); + int (*autocast_clear) (struct map_session_data *sd); int (*skillatk_bonus) (struct map_session_data *sd, uint16 skill_id); int (*skillheal_bonus) (struct map_session_data *sd, uint16 skill_id); diff --git a/src/map/script.c b/src/map/script.c index 83c221e78..b08613ec3 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11001,7 +11001,7 @@ static BUILDIN(itemskill) if (sd == NULL || sd->ud.skilltimer != INVALID_TIMER) return true; - pc->itemskill_clear(sd); + 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); @@ -11011,26 +11011,26 @@ static BUILDIN(itemskill) 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_itemskill_clear(). + 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 (skill->check_condition_castbegin(sd, sd->skillitem, sd->skillitemlv) == 0 || skill->check_condition_castend(sd, sd->skillitem, sd->skillitemlv) == 0) { - pc->itemskill_clear(sd); + pc->autocast_clear(sd); return true; } - sd->state.itemskill_conditions_checked = 1; // Unset in pc_itemskill_clear(). + 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_itemskill_clear(). - sd->state.itemskill_castonself = ((flag & ISF_CASTONSELF) == ISF_CASTONSELF) ? 1 : 0; // Unset in pc_itemskill_clear(). + 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); - // itemskill_conditions_checked/itemskill_no_conditions/itemskill_no_casttime/itemskill_castonself abuse prevention. Unset in pc_itemskill_clear(). + // itemskill_conditions_checked/itemskill_no_conditions/itemskill_no_casttime/itemskill_castonself abuse prevention. Unset in pc_autocast_clear(). sd->itemskill_id = sd->skillitem; sd->itemskill_lv = sd->skillitemlv; diff --git a/src/map/skill.c b/src/map/skill.c index 5ceff376f..f28d50c6e 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -4223,7 +4223,7 @@ static void skill_castend_type(int type, struct block_list *src, struct block_li struct map_session_data *sd = BL_CAST(BL_PC, src); if (sd != NULL) - pc->itemskill_clear(sd); + pc->autocast_clear(sd); } /*========================================== 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; } diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc index 28f81b97f..edfd60fbc 100644 --- a/src/plugins/HPMHooking/HPMHooking.Defs.inc +++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc @@ -6184,8 +6184,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_itemskill_clear) (struct map_session_data **sd); -typedef int (*HPMHOOK_post_pc_itemskill_clear) (int retVal___, struct map_session_data *sd); +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 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.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index f94606bab..fed7e7a5e 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -4764,8 +4764,8 @@ struct { struct HPMHookPoint *HP_pc_checkitem_post; struct HPMHookPoint *HP_pc_useitem_pre; struct HPMHookPoint *HP_pc_useitem_post; - struct HPMHookPoint *HP_pc_itemskill_clear_pre; - struct HPMHookPoint *HP_pc_itemskill_clear_post; + struct HPMHookPoint *HP_pc_autocast_clear_pre; + struct HPMHookPoint *HP_pc_autocast_clear_post; struct HPMHookPoint *HP_pc_skillatk_bonus_pre; struct HPMHookPoint *HP_pc_skillatk_bonus_post; struct HPMHookPoint *HP_pc_skillheal_bonus_pre; @@ -11639,8 +11639,8 @@ struct { int HP_pc_checkitem_post; int HP_pc_useitem_pre; int HP_pc_useitem_post; - int HP_pc_itemskill_clear_pre; - int HP_pc_itemskill_clear_post; + int HP_pc_autocast_clear_pre; + int HP_pc_autocast_clear_post; int HP_pc_skillatk_bonus_pre; int HP_pc_skillatk_bonus_post; int HP_pc_skillheal_bonus_pre; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index a360b3f53..8b38177ae 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -2440,7 +2440,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(pc->unequipitem_pos, HP_pc_unequipitem_pos) }, { HP_POP(pc->checkitem, HP_pc_checkitem) }, { HP_POP(pc->useitem, HP_pc_useitem) }, - { HP_POP(pc->itemskill_clear, HP_pc_itemskill_clear) }, + { HP_POP(pc->autocast_clear, HP_pc_autocast_clear) }, { HP_POP(pc->skillatk_bonus, HP_pc_skillatk_bonus) }, { HP_POP(pc->skillheal_bonus, HP_pc_skillheal_bonus) }, { HP_POP(pc->skillheal2_bonus, HP_pc_skillheal2_bonus) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index 592279cc4..4b139b322 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -63359,14 +63359,14 @@ int HP_pc_useitem(struct map_session_data *sd, int n) { } return retVal___; } -int HP_pc_itemskill_clear(struct map_session_data *sd) { +int HP_pc_autocast_clear(struct map_session_data *sd) { int hIndex = 0; int retVal___ = 0; - if (HPMHooks.count.HP_pc_itemskill_clear_pre > 0) { + if (HPMHooks.count.HP_pc_autocast_clear_pre > 0) { int (*preHookFunc) (struct map_session_data **sd); *HPMforce_return = false; - for (hIndex = 0; hIndex < HPMHooks.count.HP_pc_itemskill_clear_pre; hIndex++) { - preHookFunc = HPMHooks.list.HP_pc_itemskill_clear_pre[hIndex].func; + 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); } if (*HPMforce_return) { @@ -63375,12 +63375,12 @@ int HP_pc_itemskill_clear(struct map_session_data *sd) { } } { - retVal___ = HPMHooks.source.pc.itemskill_clear(sd); + retVal___ = HPMHooks.source.pc.autocast_clear(sd); } - if (HPMHooks.count.HP_pc_itemskill_clear_post > 0) { + if (HPMHooks.count.HP_pc_autocast_clear_post > 0) { int (*postHookFunc) (int retVal___, struct map_session_data *sd); - for (hIndex = 0; hIndex < HPMHooks.count.HP_pc_itemskill_clear_post; hIndex++) { - postHookFunc = HPMHooks.list.HP_pc_itemskill_clear_post[hIndex].func; + 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); } } -- cgit v1.2.3-60-g2f50 From b6ecc4bf45b87261f4269e7d61683126c40780f1 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Wed, 11 Mar 2020 21:35:47 +0100 Subject: Add pc_autocast_clear() function calls --- src/map/atcommand.c | 2 ++ src/map/clif.c | 4 ++-- src/map/pc.c | 6 +++--- src/map/script.c | 6 ++++++ src/map/skill.c | 10 +++++----- 5 files changed, 18 insertions(+), 10 deletions(-) (limited to 'src/map/pc.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 410cd7af7..d3368c3b0 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -5671,6 +5671,8 @@ ACMD(useskill) return false; } + pc->autocast_clear(sd); + if (skill_id >= HM_SKILLBASE && skill_id < HM_SKILLBASE+MAX_HOMUNSKILL && sd->hd && homun_alive(sd->hd)) // (If used with @useskill, put the homunc as dest) bl = &sd->hd->bl; diff --git a/src/map/clif.c b/src/map/clif.c index d7dffb293..6c693297d 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -12786,7 +12786,7 @@ static void clif_useSkillToIdReal(int fd, struct map_session_data *sd, int skill return; } - sd->skillitem = sd->skillitemlv = 0; + pc->autocast_clear(sd); if (skill_id >= GD_SKILLBASE && skill_id < GD_MAX) { if (sd->state.gmaster_flag) @@ -12914,7 +12914,7 @@ static void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uin unit->skilluse_pos(&sd->bl, x, y, skill_id, skill_lv); } else { int lv; - sd->skillitem = sd->skillitemlv = 0; + pc->autocast_clear(sd); if( (lv = pc->checkskill(sd, skill_id)) > 0 ) { if( skill_lv > lv ) skill_lv = lv; diff --git a/src/map/pc.c b/src/map/pc.c index 073c16029..b37afab86 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -8129,9 +8129,9 @@ static int pc_dead(struct map_session_data *sd, struct block_list *src) clif->party_dead_notification(sd); - //Reset menu skills/item skills - if (sd->skillitem) - sd->skillitem = sd->skillitemlv = 0; + pc->autocast_clear(sd); // Unset auto-cast data. + + // Reset menu skills. if (sd->menuskill_id) sd->menuskill_id = sd->menuskill_val = 0; //Reset ticks. diff --git a/src/map/script.c b/src/map/script.c index b08613ec3..5e285020f 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -21436,7 +21436,10 @@ static BUILDIN(unitskilluseid) } else { status_calc_npc(nd, SCO_NONE); } + } else if (bl->type == BL_PC) { + pc->autocast_clear(BL_UCAST(BL_PC, bl)); } + unit->skilluse_id(bl, target_id, skill_id, skill_lv); } @@ -21472,7 +21475,10 @@ static BUILDIN(unitskillusepos) } else { status_calc_npc(nd, SCO_NONE); } + } else if (bl->type == BL_PC) { + pc->autocast_clear(BL_UCAST(BL_PC, bl)); } + unit->skilluse_pos(bl, skill_x, skill_y, skill_id, skill_lv); } diff --git a/src/map/skill.c b/src/map/skill.c index f28d50c6e..f679c3f6a 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -5883,7 +5883,7 @@ 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] - sd->skillitem = sd->skillitemlv = 0; + pc->autocast_clear(sd); if (ud->skilltimer == INVALID_TIMER) { if(md) md->skill_idx = -1; @@ -5939,7 +5939,7 @@ 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) - sd->skillitem = sd->skillitemlv = 0; + pc->autocast_clear(sd); else if(md) md->skill_idx = -1; return 0; @@ -10870,7 +10870,7 @@ 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 && sd->skillitem != AL_WARP ) // Warp-Portal thru items will clear data in skill_castend_map. [Inkfish] - sd->skillitem = sd->skillitemlv = 0; + pc->autocast_clear(sd); unit->set_dir(src, map->calc_dir(src, ud->skillx, ud->skilly)); @@ -10888,7 +10888,7 @@ 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) - sd->skillitem = sd->skillitemlv = 0; + pc->autocast_clear(sd); else if(md) md->skill_idx = -1; return 0; @@ -11041,7 +11041,7 @@ static int skill_castend_map(struct map_session_data *sd, uint16 skill_id, const } skill->consume_requirement(sd,sd->menuskill_id,lv,2); - sd->skillitem = sd->skillitemlv = 0; // Clear data that's skipped in 'skill_castend_pos' [Inkfish] + pc->autocast_clear(sd); // Clear data which was skipped in skill_castend_pos(). if((group=skill->unitsetting(&sd->bl,skill_id,lv,wx,wy,0))==NULL) { skill_failed(sd); -- cgit v1.2.3-60-g2f50 From 492c7bc03c5a40957677f2d98c7d61961dfa6113 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Wed, 11 Mar 2020 22:53:36 +0100 Subject: Remove map_session_data->state.abra_flag and use map_session_data->autocast.type instead --- src/map/pc.c | 7 ++++--- src/map/pc.h | 1 - src/map/skill.c | 8 +++----- 3 files changed, 7 insertions(+), 9 deletions(-) (limited to 'src/map/pc.c') diff --git a/src/map/pc.c b/src/map/pc.c index b37afab86..3cfe28a11 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5295,9 +5295,10 @@ static int pc_useitem(struct map_session_data *sd, int n) if(sd->catch_target_class != -1) //Abort pet catching. sd->catch_target_class = -1; - // Removes abracadabra/randomize spell flag for delayed consume items or item doesn't get consumed - if (sd->inventory_data[n]->flag.delay_consume) - sd->state.abra_flag = 0; + // Unset auto-cast related data for items of type IT_DELAYCONSUME or the item won't be consumed. + // TODO: Check if this is still required. [Kenpachi] + if (sd->inventory_data[n]->flag.delay_consume != 0) + sd->autocast.type = AUTOCAST_NONE; amount = sd->status.inventory[n].amount; //Check if the item is to be consumed immediately [Skotlex] diff --git a/src/map/pc.h b/src/map/pc.h index 7e69169f0..a0566fadc 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -206,7 +206,6 @@ struct map_session_data { unsigned int rest : 1; unsigned int storage_flag : 2; // @see enum storage_flag unsigned int snovice_dead_flag : 1; //Explosion spirits on death: 0 off, 1 used. - unsigned int abra_flag : 2; // Abracadabra bugfix by Aru unsigned int autotrade : 2; //By Fantik unsigned int showdelay :1; unsigned int showexp :1; diff --git a/src/map/skill.c b/src/map/skill.c index dfc939c6f..d21a19742 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -6334,7 +6334,6 @@ 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; - sd->state.abra_flag = 1; sd->skillitem = abra_skill_id; sd->skillitemlv = abra_skill_lv; clif->item_skill(sd, abra_skill_id, abra_skill_lv); @@ -10079,7 +10078,6 @@ 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; - sd->state.abra_flag = 2; sd->skillitem = improv_skill_id; sd->skillitemlv = improv_skill_lv; clif->item_skill(sd, improv_skill_id, improv_skill_lv); @@ -14118,9 +14116,9 @@ static int skill_check_condition_castbegin(struct map_session_data *sd, uint16 s sc = NULL; if( sd->skillitem == skill_id ) { - if( sd->state.abra_flag ) // Hocus-Pocus was used. [Inkfish] - sd->state.abra_flag = 0; - else { + if (sd->autocast.type == AUTOCAST_ABRA || sd->autocast.type == AUTOCAST_IMPROVISE) { // Abracadabra or Improvised Song was used. + sd->autocast.type = AUTOCAST_NONE; + } else { int i; // When a target was selected, consume items that were skipped in pc_use_item [Skotlex] if( (i = sd->itemindex) == -1 || -- cgit v1.2.3-60-g2f50 From d92d1772e8dd2fc65fd009247b7009f26ae73b66 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Wed, 11 Mar 2020 23:05:28 +0100 Subject: Remove itemskill_id and itemskill_lv helper variables, since they are not used anymore --- src/map/pc.c | 2 -- src/map/pc.h | 9 --------- src/map/script.c | 4 ---- 3 files changed, 15 deletions(-) (limited to 'src/map/pc.c') diff --git a/src/map/pc.c b/src/map/pc.c index 3cfe28a11..8586270b8 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5354,8 +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->itemskill_id = 0; - sd->itemskill_lv = 0; sd->state.itemskill_conditions_checked = 0; sd->state.itemskill_check_conditions = 0; sd->state.itemskill_no_casttime = 0; diff --git a/src/map/pc.h b/src/map/pc.h index a0566fadc..83b86b68b 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -657,15 +657,6 @@ END_ZEROED_BLOCK; bool achievements_received; // Title VECTOR_DECL(int) title_ids; - - /* - * itemskill_conditions_checked/itemskill_no_conditions/itemskill_no_casttime/itemskill_castonself abuse prevention. - * If a skill, casted by itemskill() script command, is aborted while target selection, - * the map server gets no notification where these states could be unset. - * Thus we need this helper variables to prevent abusing these states for next skill cast. - */ - int itemskill_id; - int itemskill_lv; }; #define EQP_WEAPON EQP_HAND_R diff --git a/src/map/script.c b/src/map/script.c index 5e285020f..b8f8d7638 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11030,10 +11030,6 @@ static BUILDIN(itemskill) sd->autocast.itemskill_instant_cast = ((flag & ISF_INSTANTCAST) == ISF_INSTANTCAST); sd->autocast.itemskill_cast_on_self = ((flag & ISF_CASTONSELF) == ISF_CASTONSELF); - // itemskill_conditions_checked/itemskill_no_conditions/itemskill_no_casttime/itemskill_castonself abuse prevention. Unset in pc_autocast_clear(). - sd->itemskill_id = sd->skillitem; - sd->itemskill_lv = sd->skillitemlv; - clif->item_skill(sd, sd->skillitem, sd->skillitemlv); return true; -- cgit v1.2.3-60-g2f50 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/pc.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-60-g2f50 From 7c6e21a9057b07929b55de23ae67299434edb6db Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 12 Mar 2020 17:22:36 +0100 Subject: Remove IT_DELAYCONSUME related auto-cast code First of all: In official servers, skill casting item are consumed immediately and thus IT_DELAYCONSUME should not be used for those items And additionally these code blocks are obsolete, because of the way how skill casting items work. * If the item won't check the skill's requirements, the code block to delete the item of type IT_DELAYCONSUME isn't even executed. * If the item does check the skill's requirements, the check is done prior to the skill casting which would be the same as using IT_USABLE. --- src/map/pc.c | 5 ----- src/map/skill.c | 19 ------------------- 2 files changed, 24 deletions(-) (limited to 'src/map/pc.c') diff --git a/src/map/pc.c b/src/map/pc.c index e181b5f89..5d87d017d 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5295,11 +5295,6 @@ static int pc_useitem(struct map_session_data *sd, int n) if(sd->catch_target_class != -1) //Abort pet catching. sd->catch_target_class = -1; - // Unset auto-cast related data for items of type IT_DELAYCONSUME or the item won't be consumed. - // TODO: Check if this is still required. [Kenpachi] - if (sd->inventory_data[n]->flag.delay_consume != 0) - sd->autocast.type = AUTOCAST_NONE; - amount = sd->status.inventory[n].amount; //Check if the item is to be consumed immediately [Skotlex] if (sd->inventory_data[n]->flag.delay_consume || sd->inventory_data[n]->flag.keepafteruse) diff --git a/src/map/skill.c b/src/map/skill.c index 6fc1b80a2..e779e9859 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -14095,25 +14095,6 @@ static int skill_check_condition_castbegin(struct map_session_data *sd, uint16 s if( !sc->count ) sc = NULL; - // TODO: Check if the validation of delayed consume is still required. (See the delayed consume related TODO in pc_useitem().) - if (sd->autocast.type == AUTOCAST_ITEM) { - int i = sd->itemindex; - - if (i == INDEX_NOT_FOUND || sd->status.inventory[i].nameid != sd->itemid || sd->inventory_data[i] == NULL - || sd->status.inventory[i].amount < 1) { // Something went wrong. Item exploit? - sd->itemid = INDEX_NOT_FOUND; - sd->itemindex = INDEX_NOT_FOUND; - return 0; - } - - // Consume the item. Rental usable items are not consumed until expiration. - if (sd->status.inventory[i].expire_time == 0 && sd->inventory_data[i]->flag.delay_consume == 1) - pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_CONSUME); - - sd->itemid = INDEX_NOT_FOUND; - sd->itemindex = INDEX_NOT_FOUND; - } - 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; -- cgit v1.2.3-60-g2f50