diff options
author | Haru <haru@dotalux.com> | 2020-04-05 21:05:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-05 21:05:27 +0200 |
commit | 024c9c48d4a1d064ac9d37d997d3983fb1bff40f (patch) | |
tree | 0eae933a4a69c220f98dacfe17b9df2cc5b877ec /src/map/script.c | |
parent | 02a84aa9870422bddb7b631dd09bb45c1e5e6856 (diff) | |
parent | 876cfa678d5e9a43d1ce419bd9d8300d9c8c6b36 (diff) | |
download | hercules-024c9c48d4a1d064ac9d37d997d3983fb1bff40f.tar.gz hercules-024c9c48d4a1d064ac9d37d997d3983fb1bff40f.tar.bz2 hercules-024c9c48d4a1d064ac9d37d997d3983fb1bff40f.tar.xz hercules-024c9c48d4a1d064ac9d37d997d3983fb1bff40f.zip |
Merge pull request #2657 from Kenpachi2k13/autocast_clean_up
Clean up auto-cast related code
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/map/script.c b/src/map/script.c index c644e9b75..d575c5925 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11001,33 +11001,29 @@ static BUILDIN(itemskill) if (sd == NULL || sd->ud.skilltimer != INVALID_TIMER) return true; - pc->itemskill_clear(sd); - sd->skillitem = script_isstringtype(st, 2) ? skill->name2id(script_getstr(st, 2)) : script_getnum(st, 2); - sd->skillitemlv = script_getnum(st, 3); - sd->state.itemskill_conditions_checked = 0; // Skill casting items will check the conditions prior to the target selection in AEGIS. Thus we need a flag to prevent checking them twice. + 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); 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 - || skill->check_condition_castend(sd, sd->skillitem, sd->skillitemlv) == 0) { - pc->itemskill_clear(sd); + 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; } - 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; - sd->itemskill_lv = sd->skillitemlv; - - clif->item_skill(sd, sd->skillitem, sd->skillitemlv); + clif->item_skill(sd, sd->autocast.skill_id, sd->autocast.skill_lv); return true; } @@ -21429,7 +21425,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); } @@ -21465,7 +21464,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); } |