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/battle.c | 12 ++++++++++++ src/map/pc.c | 1 + src/map/script.c | 1 + src/map/skill.c | 24 ++++++++++++++++++++++++ 4 files changed, 38 insertions(+) diff --git a/src/map/battle.c b/src/map/battle.c index 985d2bca4..e73c93bab 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -5939,8 +5939,18 @@ static void battle_reflect_damage(struct block_list *target, struct block_list * sd->state.autocast = 1; } + enum autocast_type ac_type; + + if (sd != NULL) { + ac_type = sd->autocast.type; + sd->autocast.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; + if( change ) sd->state.autocast = 0; @@ -6457,8 +6467,10 @@ static enum damage_lv battle_weapon_attack(struct block_list *src, struct block_ } sd->state.autocast = 1; + sd->autocast.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->state.autocast = 0; 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/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; diff --git a/src/map/script.c b/src/map/script.c index b8a7979a7..18855e3b0 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11002,6 +11002,7 @@ static BUILDIN(itemskill) return true; pc->itemskill_clear(sd); + sd->autocast.type = AUTOCAST_ITEM; 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 a1a22f74f..a83f3bfe5 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -2066,7 +2066,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->state.autocast = 1; + sd->autocast.type = AUTOCAST_TEMP; notok = skill->not_ok(temp, sd); + sd->autocast.type = AUTOCAST_NONE; sd->state.autocast = 0; if ( notok ) @@ -2119,9 +2121,11 @@ static int skill_additional_effect(struct block_list *src, struct block_list *bl type = CAST_GROUND; sd->state.autocast = 1; + sd->autocast.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->state.autocast = 0; //Set canact delay. [Skotlex] ud = unit->bl2ud(src); @@ -2191,6 +2195,9 @@ static int skill_onskillusage(struct map_session_data *sd, struct block_list *bl if( sd == NULL || !skill_id ) 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; + for( i = 0; i < ARRAYLENGTH(sd->autospell3) && sd->autospell3[i].flag; i++ ) { if( sd->autospell3[i].flag != skill_id ) continue; @@ -2201,7 +2208,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->state.autocast = 1; + sd->autocast.type = AUTOCAST_TEMP; notok = skill->not_ok(temp, sd); + sd->autocast.type = AUTOCAST_NONE; sd->state.autocast = 0; if ( notok ) @@ -2250,12 +2259,16 @@ static int skill_onskillusage(struct map_session_data *sd, struct block_list *bl sd->state.autocast = 1; sd->autospell3[i].lock = true; + sd->autocast.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->autospell3[i].lock = false; sd->state.autocast = 0; } + sd->autocast.type = ac_type; + if (sd->autobonus3[0].rate) { for( i = 0; i < ARRAYLENGTH(sd->autobonus3); i++ ) { if( rnd()%1000 >= sd->autobonus3[i].rate ) @@ -2402,6 +2415,9 @@ static int skill_counter_additional_effect(struct block_list *src, struct block_ struct unit_data *ud; 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; + for (i = 0; i < ARRAYLENGTH(dstsd->autospell2) && dstsd->autospell2[i].id; i++) { if(!(dstsd->autospell2[i].flag&attack_type&BF_WEAPONMASK && @@ -2418,7 +2434,9 @@ static int skill_counter_additional_effect(struct block_list *src, struct block_ rate>>=1; dstsd->state.autocast = 1; + dstsd->autocast.type = AUTOCAST_TEMP; notok = skill->not_ok(auto_skill_id, dstsd); + dstsd->autocast.type = AUTOCAST_NONE; dstsd->state.autocast = 0; if ( notok ) @@ -2461,8 +2479,10 @@ static int skill_counter_additional_effect(struct block_list *src, struct block_ continue; dstsd->state.autocast = 1; + dstsd->autocast.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->state.autocast = 0; // Set canact delay. [Skotlex] ud = unit->bl2ud(bl); @@ -2475,6 +2495,8 @@ static int skill_counter_additional_effect(struct block_list *src, struct block_ } } } + + dstsd->autocast.type = ac_type; } //Autobonus when attacked @@ -6299,6 +6321,7 @@ static int skill_castend_nodamage_id(struct block_list *src, struct block_list * if (sd) { // player-casted + sd->autocast.type = AUTOCAST_ABRA; sd->state.abra_flag = 1; sd->skillitem = abra_skill_id; sd->skillitemlv = abra_skill_lv; @@ -10041,6 +10064,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) { + sd->autocast.type = AUTOCAST_IMPROVISE; sd->state.abra_flag = 2; sd->skillitem = improv_skill_id; sd->skillitemlv = improv_skill_lv; -- cgit v1.2.3-60-g2f50