From 7d70f7ec35b0b4476686b73fc221527a6d1ed0fa Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Wed, 11 Mar 2020 22:22:59 +0100 Subject: Remove map_session_data->state.autocast and use map_session_data->autocast.type instead --- src/map/battle.c | 14 +------------- src/map/pc.h | 1 - src/map/skill.c | 20 +++++--------------- 3 files changed, 6 insertions(+), 29 deletions(-) (limited to 'src/map') diff --git a/src/map/battle.c b/src/map/battle.c index e73c93bab..6519b1f37 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -5928,17 +5928,10 @@ static void battle_reflect_damage(struct block_list *target, struct block_list * delay += 100;/* gradual increase so the numbers don't clip in the client */ } if( sc->data[SC_LG_REFLECTDAMAGE] && rnd()%100 < (30 + 10*sc->data[SC_LG_REFLECTDAMAGE]->val1) ) { - bool change = false; - NORMALIZE_RDAMAGE(damage * sc->data[SC_LG_REFLECTDAMAGE]->val2 / 100); trdamage -= rdamage;/* wont count towards total */ - if( sd && !sd->state.autocast ) { - change = true; - sd->state.autocast = 1; - } - enum autocast_type ac_type; if (sd != NULL) { @@ -5951,9 +5944,6 @@ static void battle_reflect_damage(struct block_list *target, struct block_list * if (sd != NULL) sd->autocast.type = ac_type; - if( change ) - sd->state.autocast = 0; - delay += 150;/* gradual increase so the numbers don't clip in the client */ if( (--sc->data[SC_LG_REFLECTDAMAGE]->val3) <= 0 ) @@ -6142,7 +6132,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)->state.autocast) + if (src->type != BL_PC || BL_UCCAST(BL_PC, src)->autocast.type != AUTOCAST_TEMP) skill->additional_effect(src, bl, CR_REFLECTSHIELD, 1, BF_WEAPON|BF_SHORT|BF_NORMAL,ATK_DEF,tick); map->freeblock_unlock(); } @@ -6466,12 +6456,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.h b/src/map/pc.h index 92444aa2a..7e69169f0 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -207,7 +207,6 @@ struct map_session_data { 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 autocast : 1; // Autospell flag [Inkfish] 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 abc5e60c4..dfc939c6f 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -1017,7 +1017,7 @@ static int skillnotok(uint16 skill_id, struct map_session_data *sd) // 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->state.autocast && sd->skillitem != skill_id && sd->canskill_tick && + if (sd->autocast.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; @@ -2090,11 +2090,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 ) continue; @@ -2145,13 +2143,12 @@ 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->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); if (ud) { @@ -2232,11 +2229,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 ) continue; @@ -2282,14 +2277,12 @@ static int skill_onskillusage(struct map_session_data *sd, struct block_list *bl !battle->check_range(&sd->bl, tbl, skill->get_range2(&sd->bl, temp,skill_lv) + (temp == RG_CLOSECONFINE?0:1)) ) continue; - 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; @@ -2458,11 +2451,9 @@ static int skill_counter_additional_effect(struct block_list *src, struct block_ if (attack_type&BF_LONG) 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 ) continue; @@ -2503,12 +2494,11 @@ 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->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); if (ud) { @@ -7512,7 +7502,7 @@ static int skill_castend_nodamage_id(struct block_list *src, struct block_list * break; } - if( sd->state.autocast || ( (sd->skillitem == AL_TELEPORT || battle_config.skip_teleport_lv1_menu) && skill_lv == 1 ) || skill_lv == 3 ) + if (sd->autocast.type == AUTOCAST_TEMP || ((sd->skillitem == AL_TELEPORT || battle_config.skip_teleport_lv1_menu) && skill_lv == 1) || skill_lv == 3) { if( skill_lv == 1 ) pc->randomwarp(sd,CLR_TELEPORT); @@ -15302,7 +15292,7 @@ static int skill_consume_requirement(struct map_session_data *sd, uint16 skill_i break; default: - if (sd->state.autocast == 1 || sd->skillitem == skill_id) /// Skill casting items and Hocus-Pocus skills don't consume SP. [Kenpachi] + if (sd->autocast.type != AUTOCAST_NONE) // Auto-cast skills don't consume SP. req.sp = 0; break; -- cgit v1.2.3-70-g09d2