diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/atcommand.c | 7 | ||||
-rw-r--r-- | src/map/battle.c | 167 | ||||
-rw-r--r-- | src/map/battle.h | 245 | ||||
-rw-r--r-- | src/map/clif.c | 10 | ||||
-rw-r--r-- | src/map/elemental.c | 14 | ||||
-rw-r--r-- | src/map/map.c | 12 | ||||
-rw-r--r-- | src/map/mob.c | 41 | ||||
-rw-r--r-- | src/map/pc.c | 4 | ||||
-rw-r--r-- | src/map/pet.c | 7 | ||||
-rw-r--r-- | src/map/script.c | 6 | ||||
-rw-r--r-- | src/map/skill.c | 204 | ||||
-rw-r--r-- | src/map/status.c | 12 | ||||
-rw-r--r-- | src/map/unit.c | 24 |
13 files changed, 404 insertions, 349 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index dbf66b6aa..b4233ea0b 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -3701,7 +3701,7 @@ ACMD_FUNC(reloadbattleconf) struct Battle_Config prev_config; memcpy(&prev_config, &battle_config, sizeof(prev_config)); - battle_config_read(BATTLE_CONF_FILENAME); + battle->config_read(BATTLE_CONF_FILENAME); if( prev_config.item_rate_mvp != battle_config.item_rate_mvp || prev_config.item_rate_common != battle_config.item_rate_common @@ -6471,10 +6471,9 @@ ACMD_FUNC(setbattleflag) if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) { clif_displaymessage(fd, msg_txt(1231)); // Usage: @setbattleflag <flag> <value> return -1; - } + } - if (battle_set_value(flag, value) == 0) - { + if (battle->config_set_value(flag, value) == 0) { clif_displaymessage(fd, msg_txt(1232)); // Unknown battle_config flag. return -1; } diff --git a/src/map/battle.c b/src/map/battle.c index 949b91a29..33fe10cb5 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -132,7 +132,7 @@ static int battle_getenemy_sub(struct block_list *bl, va_list ap) { if (status_isdead(bl)) return 0; - if (battle_check_target(target, bl, BCT_ENEMY) > 0) { + if (battle->check_target(target, bl, BCT_ENEMY) > 0) { bl_list[(*c)++] = bl; return 1; } @@ -174,7 +174,7 @@ static int battle_getenemyarea_sub(struct block_list *bl, va_list ap) { if( status_isdead(bl) ) return 0; - if( battle_check_target(src, bl, BCT_ENEMY) > 0 ) {// Is Enemy!... + if( battle->check_target(src, bl, BCT_ENEMY) > 0 ) {// Is Enemy!... bl_list[(*c)++] = bl; return 1; } @@ -334,7 +334,7 @@ int battle_attr_fix(struct block_list *src, struct block_list *target, int damag ratio += enchant_eff[sc->data[SC_DELUGE]->val1-1]; } if( target && target->type == BL_SKILL ) { - if( atk_elem == ELE_FIRE && battle_getcurrentskill(target) == GN_WALLOFTHORN ) { + if( atk_elem == ELE_FIRE && battle->get_current_skill(target) == GN_WALLOFTHORN ) { struct skill_unit *su = (struct skill_unit*)target; struct skill_unit_group *sg; struct block_list *src; @@ -1145,7 +1145,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag struct block_list *s_bl = map_id2bl(sc->data[SC__SHADOWFORM]->val2); if( !s_bl ) { // If the shadow form target is not present remove the sc. status_change_end(bl, SC__SHADOWFORM, INVALID_TIMER); - } else if( status_isdead(s_bl) || !battle_check_target(src,s_bl,BCT_ENEMY)) { // If the shadow form target is dead or not your enemy remove the sc in both. + } else if( status_isdead(s_bl) || !battle->check_target(src,s_bl,BCT_ENEMY)) { // If the shadow form target is dead or not your enemy remove the sc in both. status_change_end(bl, SC__SHADOWFORM, INVALID_TIMER); if( s_bl->type == BL_PC ) ((TBL_PC*)s_bl)->shadowform_id = 0; @@ -1398,7 +1398,7 @@ int battle_addmastery(struct map_session_data *sd,struct block_list *target,int if((skill = pc_checkskill(sd,AL_DEMONBANE)) > 0 && target->type == BL_MOB && //This bonus doesnt work against players. - (battle_check_undead(status->race,status->def_ele) || status->race==RC_DEMON) ) + (battle->check_undead(status->race,status->def_ele) || status->race==RC_DEMON) ) damage += (skill*(int)(3+(sd->status.base_level+1)*0.05)); // submitted by orn //damage += (skill * 3); if( (skill = pc_checkskill(sd, RA_RANGERMAIN)) > 0 && (status->race == RC_BRUTE || status->race == RC_PLANT || status->race == RC_FISH) ) @@ -1658,7 +1658,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * /*========================================== * battle_calc_weapon_attack (by Skotlex) *------------------------------------------*/ -static struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int wflag) +struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int wflag) { unsigned int skillratio = 100; //Skill dmg modifiers. short skill=0; @@ -3236,7 +3236,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo #else vit_def = def2; #endif - if((battle_check_undead(sstatus->race,sstatus->def_ele) || sstatus->race==RC_DEMON) && //This bonus already doesnt work vs players + if((battle->check_undead(sstatus->race,sstatus->def_ele) || sstatus->race==RC_DEMON) && //This bonus already doesnt work vs players src->type == BL_MOB && (skill=pc_checkskill(tsd,AL_DP)) > 0) vit_def += skill*(int)(3 +(tsd->status.base_level+1)*0.04); // submitted by orn if( src->type == BL_MOB && (skill=pc_checkskill(tsd,RA_RANGERMAIN))>0 && @@ -3382,23 +3382,23 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo { //Elemental attribute fix if( wd.damage > 0 ) { - wd.damage=battle_attr_fix(src,target,wd.damage,s_ele,tstatus->def_ele, tstatus->ele_lv); + wd.damage=battle->attr_fix(src,target,wd.damage,s_ele,tstatus->def_ele, tstatus->ele_lv); if( skill_id == MC_CARTREVOLUTION ) //Cart Revolution applies the element fix once more with neutral element - wd.damage = battle_attr_fix(src,target,wd.damage,ELE_NEUTRAL,tstatus->def_ele, tstatus->ele_lv); + wd.damage = battle->attr_fix(src,target,wd.damage,ELE_NEUTRAL,tstatus->def_ele, tstatus->ele_lv); if( skill_id== GS_GROUNDDRIFT ) //Additional 50*lv Neutral damage. - wd.damage += battle_attr_fix(src,target,50*skill_lv,ELE_NEUTRAL,tstatus->def_ele, tstatus->ele_lv); + wd.damage += battle->attr_fix(src,target,50*skill_lv,ELE_NEUTRAL,tstatus->def_ele, tstatus->ele_lv); } if( flag.lh && wd.damage2 > 0 ) - wd.damage2 = battle_attr_fix(src,target,wd.damage2,s_ele_,tstatus->def_ele, tstatus->ele_lv); + wd.damage2 = battle->attr_fix(src,target,wd.damage2,s_ele_,tstatus->def_ele, tstatus->ele_lv); if( sc && sc->data[SC_WATK_ELEMENT] ) { // Descriptions indicate this means adding a percent of a normal attack in another element. [Skotlex] int damage = battle_calc_base_damage(sstatus, &sstatus->rhw, sc, tstatus->size, sd, (flag.arrow?2:0)) * sc->data[SC_WATK_ELEMENT]->val2 / 100; - wd.damage += battle_attr_fix(src, target, damage, sc->data[SC_WATK_ELEMENT]->val1, tstatus->def_ele, tstatus->ele_lv); + wd.damage += battle->attr_fix(src, target, damage, sc->data[SC_WATK_ELEMENT]->val1, tstatus->def_ele, tstatus->ele_lv); if( flag.lh ) { damage = battle_calc_base_damage(sstatus, &sstatus->lhw, sc, tstatus->size, sd, (flag.arrow?2:0)) * sc->data[SC_WATK_ELEMENT]->val2 / 100; - wd.damage2 += battle_attr_fix(src, target, damage, sc->data[SC_WATK_ELEMENT]->val1, tstatus->def_ele, tstatus->ele_lv); + wd.damage2 += battle->attr_fix(src, target, damage, sc->data[SC_WATK_ELEMENT]->val1, tstatus->def_ele, tstatus->ele_lv); } } #ifdef RENEWAL @@ -3425,9 +3425,9 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo } //Card Fix, sd side - wd.damage = battle_calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage, 2, wd.flag); + wd.damage = battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage, 2, wd.flag); if( flag.lh ) - wd.damage2 = battle_calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage2, 3, wd.flag); + wd.damage2 = battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage2, 3, wd.flag); if( skill_id == CR_SHIELDBOOMERANG || skill_id == PA_SHIELDCHAIN ) { //Refine bonus applies after cards and elements. @@ -3439,7 +3439,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo //Card Fix, tsd side if(tsd) - wd.damage = battle_calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage, flag.lh, wd.flag); + wd.damage = battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage, flag.lh, wd.flag); if( flag.infdef ) { //Plants receive 1 damage when hit @@ -3450,12 +3450,12 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo wd.damage2 = wd.div_; if( flag.hit && class_ == MOBID_EMPERIUM ) { if(wd.damage2 > 0) { - wd.damage2 = battle_attr_fix(src,target,wd.damage2,s_ele_,tstatus->def_ele, tstatus->ele_lv); - wd.damage2 = battle_calc_gvg_damage(src,target,wd.damage2,wd.div_,skill_id,skill_lv,wd.flag); + wd.damage2 = battle->attr_fix(src,target,wd.damage2,s_ele_,tstatus->def_ele, tstatus->ele_lv); + wd.damage2 = battle->calc_gvg_damage(src,target,wd.damage2,wd.div_,skill_id,skill_lv,wd.flag); } else if(wd.damage > 0) { - wd.damage = battle_attr_fix(src,target,wd.damage,s_ele_,tstatus->def_ele, tstatus->ele_lv); - wd.damage = battle_calc_gvg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); + wd.damage = battle->attr_fix(src,target,wd.damage,s_ele_,tstatus->def_ele, tstatus->ele_lv); + wd.damage = battle->calc_gvg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); } return wd; } @@ -3504,28 +3504,28 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo { //There is a total damage value if(!wd.damage2) { - wd.damage = battle_calc_damage(src,target,&wd,wd.damage,skill_id,skill_lv); + wd.damage = battle->calc_damage(src,target,&wd,wd.damage,skill_id,skill_lv); if( map_flag_gvg2(target->m) ) - wd.damage=battle_calc_gvg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); + wd.damage=battle->calc_gvg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); else if( map[target->m].flag.battleground ) - wd.damage=battle_calc_bg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); + wd.damage=battle->calc_bg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); } else if(!wd.damage) { - wd.damage2 = battle_calc_damage(src,target,&wd,wd.damage2,skill_id,skill_lv); + wd.damage2 = battle->calc_damage(src,target,&wd,wd.damage2,skill_id,skill_lv); if( map_flag_gvg2(target->m) ) - wd.damage2 = battle_calc_gvg_damage(src,target,wd.damage2,wd.div_,skill_id,skill_lv,wd.flag); + wd.damage2 = battle->calc_gvg_damage(src,target,wd.damage2,wd.div_,skill_id,skill_lv,wd.flag); else if( map[target->m].flag.battleground ) - wd.damage = battle_calc_bg_damage(src,target,wd.damage2,wd.div_,skill_id,skill_lv,wd.flag); + wd.damage = battle->calc_bg_damage(src,target,wd.damage2,wd.div_,skill_id,skill_lv,wd.flag); } else { int d1 = wd.damage + wd.damage2,d2 = wd.damage2; - wd.damage = battle_calc_damage(src,target,&wd,d1,skill_id,skill_lv); + wd.damage = battle->calc_damage(src,target,&wd,d1,skill_id,skill_lv); if( map_flag_gvg2(target->m) ) - wd.damage = battle_calc_gvg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); + wd.damage = battle->calc_gvg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); else if( map[target->m].flag.battleground ) - wd.damage = battle_calc_bg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); + wd.damage = battle->calc_bg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); wd.damage2 = d2*100/d1 * wd.damage/100; if(wd.damage > 1 && wd.damage2 < 1) wd.damage2 = 1; wd.damage-=wd.damage2; @@ -3671,7 +3671,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list case MG_FIREWALL: case NJ_KAENSIN: ad.dmotion = 0; //No flinch animation. - if ( tstatus->def_ele == ELE_FIRE || battle_check_undead(tstatus->race, tstatus->def_ele) ) + if ( tstatus->def_ele == ELE_FIRE || battle->check_undead(tstatus->race, tstatus->def_ele) ) ad.blewcount = 0; //No knockback break; case PR_SANCTUARY: @@ -3767,7 +3767,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list #endif break; case MG_SOULSTRIKE: - if (battle_check_undead(tstatus->race,tstatus->def_ele)) + if (battle->check_undead(tstatus->race,tstatus->def_ele)) skillratio += 5*skill_lv; break; case MG_FIREWALL: @@ -4106,7 +4106,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list } } #ifdef RENEWAL - ad.damage = battle_calc_cardfix(BF_MAGIC, src, target, nk, s_ele, 0, ad.damage, 0, ad.flag); + ad.damage = battle->calc_cardfix(BF_MAGIC, src, target, nk, s_ele, 0, ad.damage, 0, ad.flag); #endif if(sd) { //Damage bonuses @@ -4186,12 +4186,12 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list } if (!(nk&NK_NO_ELEFIX)) - ad.damage=battle_attr_fix(src, target, ad.damage, s_ele, tstatus->def_ele, tstatus->ele_lv); + ad.damage=battle->attr_fix(src, target, ad.damage, s_ele, tstatus->def_ele, tstatus->ele_lv); if( skill_id == CR_GRANDCROSS || skill_id == NPC_GRANDDARKNESS ) { //Apply the physical part of the skill's damage. [Skotlex] - struct Damage wd = battle_calc_weapon_attack(src,target,skill_id,skill_lv,mflag); - ad.damage = battle_attr_fix(src, target, wd.damage + ad.damage, s_ele, tstatus->def_ele, tstatus->ele_lv) * (100 + 40*skill_lv)/100; + struct Damage wd = battle->calc_weapon_attack(src,target,skill_id,skill_lv,mflag); + ad.damage = battle->attr_fix(src, target, wd.damage + ad.damage, s_ele, tstatus->def_ele, tstatus->ele_lv) * (100 + 40*skill_lv)/100; if( src == target ) { if( src->type == BL_PC ) @@ -4202,7 +4202,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list } #ifndef RENEWAL - ad.damage = battle_calc_cardfix(BF_MAGIC, src, target, nk, s_ele, 0, ad.damage, 0, ad.flag); + ad.damage = battle->calc_cardfix(BF_MAGIC, src, target, nk, s_ele, 0, ad.damage, 0, ad.flag); #endif } @@ -4211,15 +4211,15 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list if (flag.infdef && ad.damage) ad.damage = ad.damage>0?1:-1; - ad.damage=battle_calc_damage(src,target,&ad,ad.damage,skill_id,skill_lv); + ad.damage=battle->calc_damage(src,target,&ad,ad.damage,skill_id,skill_lv); if( map_flag_gvg2(target->m) ) - ad.damage=battle_calc_gvg_damage(src,target,ad.damage,ad.div_,skill_id,skill_lv,ad.flag); + ad.damage=battle->calc_gvg_damage(src,target,ad.damage,ad.div_,skill_id,skill_lv,ad.flag); else if( map[target->m].flag.battleground ) - ad.damage=battle_calc_bg_damage(src,target,ad.damage,ad.div_,skill_id,skill_lv,ad.flag); + ad.damage=battle->calc_bg_damage(src,target,ad.damage,ad.div_,skill_id,skill_lv,ad.flag); switch( skill_id ) { /* post-calc modifiers */ case SO_VARETYR_SPEAR: { // Physical damage. - struct Damage wd = battle_calc_weapon_attack(src,target,skill_id,skill_lv,mflag); + struct Damage wd = battle->calc_weapon_attack(src,target,skill_id,skill_lv,mflag); if(!flag.infdef && ad.damage > 1) ad.damage += wd.damage; break; @@ -4427,7 +4427,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * break; case KO_HAPPOKUNAI: { - struct Damage wd = battle_calc_weapon_attack(src,target,skill_id,skill_lv,mflag); + struct Damage wd = battle->calc_weapon_attack(src,target,skill_id,skill_lv,mflag); short totaldef = tstatus->def2 + (short)status_get_def(target); md.damage = wd.damage * 60 * (5 + skill_lv) / 100; md.damage -= totaldef; @@ -4491,7 +4491,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * } } - md.damage = battle_calc_cardfix(BF_MISC, src, target, nk, s_ele, 0, md.damage, 0, md.flag); + md.damage = battle->calc_cardfix(BF_MISC, src, target, nk, s_ele, 0, md.damage, 0, md.flag); if (sd && (i = pc_skillatk_bonus(sd, skill_id))) md.damage += md.damage*i/100; @@ -4521,13 +4521,13 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * } if(!(nk&NK_NO_ELEFIX)) - md.damage=battle_attr_fix(src, target, md.damage, s_ele, tstatus->def_ele, tstatus->ele_lv); + md.damage=battle->attr_fix(src, target, md.damage, s_ele, tstatus->def_ele, tstatus->ele_lv); - md.damage=battle_calc_damage(src,target,&md,md.damage,skill_id,skill_lv); + md.damage=battle->calc_damage(src,target,&md,md.damage,skill_id,skill_lv); if( map_flag_gvg2(target->m) ) - md.damage=battle_calc_gvg_damage(src,target,md.damage,md.div_,skill_id,skill_lv,md.flag); + md.damage=battle->calc_gvg_damage(src,target,md.damage,md.div_,skill_id,skill_lv,md.flag); else if( map[target->m].flag.battleground ) - md.damage=battle_calc_bg_damage(src,target,md.damage,md.div_,skill_id,skill_lv,md.flag); + md.damage=battle->calc_bg_damage(src,target,md.damage,md.div_,skill_id,skill_lv,md.flag); switch( skill_id ) { case RA_FIRINGTRAP: @@ -4706,12 +4706,12 @@ int battle_damage_area( struct block_list *bl, va_list ap) { damage=va_arg(ap,int); if( bl->type == BL_MOB && ((TBL_MOB*)bl)->class_ == MOBID_EMPERIUM ) return 0; - if( bl != src && battle_check_target(src,bl,BCT_ENEMY) > 0 ) { + if( bl != src && battle->check_target(src,bl,BCT_ENEMY) > 0 ) { map_freeblock_lock(); if( src->type == BL_PC ) - battle_drain((TBL_PC*)src, bl, damage, damage, status_get_race(bl), is_boss(bl)); + battle->drain((TBL_PC*)src, bl, damage, damage, status_get_race(bl), is_boss(bl)); if( amotion ) - battle_delay_damage(tick, amotion,src,bl,0,CR_REFLECTSHIELD,0,damage,ATK_DEF,0,true); + battle->delay_damage(tick, amotion,src,bl,0,CR_REFLECTSHIELD,0,damage,ATK_DEF,0,true); else status_fix_damage(src,bl,damage,0); clif_damage(bl,bl,tick,amotion,dmotion,damage,1,ATK_BLOCK,0); @@ -4886,7 +4886,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t if(tsc && tsc->data[SC_KAAHI] && tsc->data[SC_KAAHI]->val4 == INVALID_TIMER && tstatus->hp < tstatus->max_hp) tsc->data[SC_KAAHI]->val4 = add_timer(tick + skill_get_time2(SL_KAAHI,tsc->data[SC_KAAHI]->val1), kaahi_heal_timer, target->id, SC_KAAHI); //Activate heal. - wd = battle_calc_attack(BF_WEAPON, src, target, 0, 0, flag); + wd = battle->calc_attack(BF_WEAPON, src, target, 0, 0, flag); if( sc && sc->count ) { if (sc->data[SC_EXEEDBREAK]) { @@ -4895,7 +4895,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t } if( sc->data[SC_SPELLFIST] ) { if( --(sc->data[SC_SPELLFIST]->val1) >= 0 ){ - struct Damage ad = battle_calc_attack(BF_MAGIC,src,target,sc->data[SC_SPELLFIST]->val3,sc->data[SC_SPELLFIST]->val4,flag|BF_SHORT); + struct Damage ad = battle->calc_attack(BF_MAGIC,src,target,sc->data[SC_SPELLFIST]->val3,sc->data[SC_SPELLFIST]->val4,flag|BF_SHORT); wd.damage = ad.damage; }else status_change_end(src,SC_SPELLFIST,INVALID_TIMER); @@ -4909,7 +4909,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t } } if (sd && sd->state.arrow_atk) //Consume arrow. - battle_consume_ammo(sd, 0, 0); + battle->consume_ammo(sd, 0, 0); damage = wd.damage + wd.damage2; if( damage > 0 && src != target ) @@ -4924,7 +4924,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t skill_attack(skill_get_type(skill_id), src, src, target, skill_id, sc->data[SC_DUPLELIGHT]->val1, tick, SD_LEVEL); } - rdamage = battle_calc_return_damage(target,src, &damage, wd.flag, 0); + rdamage = battle->calc_return_damage(target,src, &damage, wd.flag, 0); if( rdamage > 0 ) { if( tsc && tsc->data[SC_REFLECTDAMAGE] ) { if( src != target )// Don't reflect your own damage (Grand Cross) @@ -4948,7 +4948,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t } map_freeblock_lock(); - battle_delay_damage(tick, wd.amotion, src, target, wd.flag, 0, 0, damage, wd.dmg_lv, wd.dmotion, true); + battle->delay_damage(tick, wd.amotion, src, target, wd.flag, 0, 0, damage, wd.dmg_lv, wd.dmotion, true); if( tsc ) { if( tsc->data[SC_DEVOTION] ) { struct status_change_entry *sce = tsc->data[SC_DEVOTION]; @@ -5069,15 +5069,15 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t if (wd.flag & BF_WEAPON && src != target && damage > 0) { if (battle_config.left_cardfix_to_right) - battle_drain(sd, target, wd.damage, wd.damage, tstatus->race, is_boss(target)); + battle->drain(sd, target, wd.damage, wd.damage, tstatus->race, is_boss(target)); else - battle_drain(sd, target, wd.damage, wd.damage2, tstatus->race, is_boss(target)); + battle->drain(sd, target, wd.damage, wd.damage2, tstatus->race, is_boss(target)); } } if (rdamage > 0 && !(tsc && tsc->data[SC_REFLECTDAMAGE])) { //By sending attack type "none" skill_additional_effect won't be invoked. [Skotlex] if(tsd && src != target) - battle_drain(tsd, src, rdamage, rdamage, sstatus->race, is_boss(src)); - battle_delay_damage(tick, wd.amotion, target, src, 0, CR_REFLECTSHIELD, 0, rdamage, ATK_DEF, rdelay, true); + battle->drain(tsd, src, rdamage, rdamage, sstatus->race, is_boss(src)); + battle->delay_damage(tick, wd.amotion, target, src, 0, CR_REFLECTSHIELD, 0, rdamage, ATK_DEF, rdelay, true); } if (tsc) { @@ -5180,10 +5180,10 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f //t_bl/s_bl hold the 'master' of the attack, while src/target are the actual //objects involved. - if( (t_bl = battle_get_master(target)) == NULL ) + if( (t_bl = battle->get_master(target)) == NULL ) t_bl = target; - if( (s_bl = battle_get_master(src)) == NULL ) + if( (s_bl = battle->get_master(src)) == NULL ) s_bl = src; if ( s_bl->type == BL_PC ) { @@ -5227,7 +5227,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if( !su->group ) return 0; if( skill_get_inf2(su->group->skill_id)&INF2_TRAP ) { //Only a few skills can target traps... - switch( battle_getcurrentskill(src) ) { + switch( battle->get_current_skill(src) ) { case RK_DRAGONBREATH:// it can only hit traps in pvp/gvg maps if( !map[m].flag.pvp && !map[m].flag.gvg ) break; @@ -6135,7 +6135,7 @@ int battle_config_read(const char* cfgName) static int count = 0; if (count == 0) - battle_set_defaults(); + battle->config_set_defaults(); count++; @@ -6152,9 +6152,9 @@ int battle_config_read(const char* cfgName) if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2) continue; if (strcmpi(w1, "import") == 0) - battle_config_read(w2); + battle->config_read(w2); else - if (battle_set_value(w1, w2) == 0) + if (battle->config_set_value(w1, w2) == 0) ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName); } @@ -6169,8 +6169,7 @@ int battle_config_read(const char* cfgName) return 0; } -void do_init_battle(void) -{ +void do_init_battle(void) { delay_damage_ers = ers_new(sizeof(struct delay_damage),"battle.c::delay_damage_ers",ERS_OPT_CLEAR); add_timer_func_list(battle_delay_damage_sub, "battle_delay_damage_sub"); @@ -6181,7 +6180,39 @@ void do_init_battle(void) } -void do_final_battle(void) -{ +void do_final_battle(void) { ers_destroy(delay_damage_ers); } + +/* initialize the interface */ +void battle_defaults(void) { + battle = &battle_s; + battle->init = do_init_battle; + battle->final = do_final_battle; + battle->calc_attack = battle_calc_attack; + battle->calc_damage = battle_calc_damage; + battle->calc_gvg_damage = battle_calc_gvg_damage; + battle->calc_bg_damage = battle_calc_bg_damage; + battle->weapon_attack = battle_weapon_attack; + battle->delay_damage = battle_delay_damage; + battle->drain = battle_drain; + battle->calc_return_damage = battle_calc_return_damage; + battle->attr_ratio = battle_attr_ratio; + battle->attr_fix = battle_attr_fix; + battle->calc_cardfix = battle_calc_cardfix; + battle->get_master = battle_get_master; + battle->get_targeted = battle_gettargeted; + battle->get_enemy = battle_getenemy; + battle->get_target = battle_gettarget; + battle->get_current_skill = battle_getcurrentskill; + battle->check_undead = battle_check_undead; + battle->check_target = battle_check_target; + battle->check_range = battle_check_range; + battle->consume_ammo = battle_consume_ammo; + battle->config_read = battle_config_read; + battle->config_set_defaults = battle_set_defaults; + battle->config_set_value = battle_set_value; + battle->config_get_value = battle_get_value; + battle->get_enemy_area = battle_getenemyarea; + battle->damage_area = battle_damage_area; +}
\ No newline at end of file diff --git a/src/map/battle.h b/src/map/battle.h index 0e888fc9e..848c9c3db 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -5,49 +5,28 @@ #ifndef _BATTLE_H_ #define _BATTLE_H_ -// state of a single attack attempt; used in flee/def penalty calculations when mobbed -typedef enum damage_lv { - ATK_NONE, // not an attack - ATK_LUCKY, // attack was lucky-dodged - ATK_FLEE, // attack was dodged - ATK_MISS, // attack missed because of element/race modifier. - ATK_BLOCK, // attack was blocked by some skills. - ATK_DEF // attack connected -} damage_lv; - -// dammage structure -struct Damage { - int damage,damage2; //right, left dmg - int type,div_; //chk clif_damage for type @TODO add an enum ? ; nb of hit - int amotion,dmotion; - int blewcount; //nb of knockback - int flag; //chk BF_* flag, (enum below) - enum damage_lv dmg_lv; //ATK_LUCKY,ATK_FLEE,ATK_DEF -}; - -//(Used in read pc.c,) attribute table (battle_attr_fix) -extern int attr_fix_table[4][10][10]; - +/** + * Declarations + **/ struct map_session_data; struct mob_data; struct block_list; -// Damage Calculation - -struct Damage battle_calc_attack(int attack_type,struct block_list *bl,struct block_list *target,uint16 skill_id,uint16 skill_lv,int count); - -int battle_calc_return_damage(struct block_list *bl, struct block_list *src, int *, int flag, uint16 skill_id); - -void battle_drain(struct map_session_data *sd, struct block_list *tbl, int rdamage, int ldamage, int race, int boss); +/** + * Defines + **/ +#define MIN_HAIR_STYLE battle_config.min_hair_style +#define MAX_HAIR_STYLE battle_config.max_hair_style +#define MIN_HAIR_COLOR battle_config.min_hair_color +#define MAX_HAIR_COLOR battle_config.max_hair_color +#define MIN_CLOTH_COLOR battle_config.min_cloth_color +#define MAX_CLOTH_COLOR battle_config.max_cloth_color -int battle_attr_ratio(int atk_elem,int def_type, int def_lv); -int battle_attr_fix(struct block_list *src, struct block_list *target, int damage,int atk_elem,int def_type, int def_lv); -int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_list *target, int nk, int s_ele, int s_ele_, int damage, int left, int flag); +#define is_boss(bl) (status_get_mode(bl)&MD_BOSS) // Can refine later [Aru] -// Final calculation Damage -int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damage *d,int damage,uint16 skill_id,uint16 skill_lv); -int battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int damage,int div_,uint16 skill_id,uint16 skill_lv,int flag); -int battle_calc_bg_damage(struct block_list *src,struct block_list *bl,int damage,int div_,uint16 skill_id,uint16 skill_lv,int flag); +/** + * Enumerations + **/ enum { // Flag of the final calculation BF_WEAPON = 0x0001, @@ -62,20 +41,17 @@ enum { // Flag of the final calculation BF_SKILLMASK= 0x0f00, }; -int battle_delay_damage (unsigned int tick, int amotion, struct block_list *src, struct block_list *target, int attack_type, uint16 skill_id, uint16 skill_lv, int damage, enum damage_lv dmg_lv, int ddelay, bool additional_effects); - -// Summary normal attack treatment (basic attack) -enum damage_lv battle_weapon_attack( struct block_list *bl,struct block_list *target,unsigned int tick,int flag); - -// Accessors -struct block_list* battle_get_master(struct block_list *src); -struct block_list* battle_gettargeted(struct block_list *target); -struct block_list* battle_getenemy(struct block_list *target, int type, int range); -int battle_gettarget(struct block_list *bl); -int battle_getcurrentskill(struct block_list *bl); +// state of a single attack attempt; used in flee/def penalty calculations when mobbed +typedef enum damage_lv { + ATK_NONE, // not an attack + ATK_LUCKY, // attack was lucky-dodged + ATK_FLEE, // attack was dodged + ATK_MISS, // attack missed because of element/race modifier. + ATK_BLOCK, // attack was blocked by some skills. + ATK_DEF // attack connected +} damage_lv; -enum e_battle_check_target -{//New definitions [Skotlex] +enum e_battle_check_target { //New definitions [Skotlex] BCT_ENEMY = 0x020000, BCT_NOENEMY = 0x1d0000, //This should be (~BCT_ENEMY&BCT_ALL) BCT_PARTY = 0x040000, @@ -88,24 +64,22 @@ enum e_battle_check_target BCT_NEUTRAL = 0x100000, }; -#define is_boss(bl) (status_get_mode(bl)&MD_BOSS) // Can refine later [Aru] - -int battle_check_undead(int race,int element); -int battle_check_target(struct block_list *src, struct block_list *target,int flag); -bool battle_check_range(struct block_list *src,struct block_list *bl,int range); -void battle_consume_ammo(struct map_session_data* sd, int skill, int lv); -// Settings +/** + * Structures + **/ -#define MIN_HAIR_STYLE battle_config.min_hair_style -#define MAX_HAIR_STYLE battle_config.max_hair_style -#define MIN_HAIR_COLOR battle_config.min_hair_color -#define MAX_HAIR_COLOR battle_config.max_hair_color -#define MIN_CLOTH_COLOR battle_config.min_cloth_color -#define MAX_CLOTH_COLOR battle_config.max_cloth_color +// dammage structure +struct Damage { + int damage,damage2; //right, left dmg + int type,div_; //chk clif_damage for type @TODO add an enum ? ; nb of hit + int amotion,dmotion; + int blewcount; //nb of knockback + int flag; //chk BF_* flag, (enum below) + enum damage_lv dmg_lv; //ATK_LUCKY,ATK_FLEE,ATK_DEF +}; -extern struct Battle_Config -{ +struct Battle_Config { int warp_point_debug; int enable_critical; int mob_critical_rate; @@ -185,7 +159,7 @@ extern struct Battle_Config int emergency_call; int guild_aura; int pc_invincible_time; - + int pet_catch_rate; int pet_rename; int pet_friendly_rate; @@ -205,7 +179,7 @@ extern struct Battle_Config int pet_max_atk2; //[Skotlex] int pet_no_gvg; //Disables pets in gvg. [Skotlex] int pet_equip_required; - + int skill_min_damage; int finger_offensive_type; int heal_exp; @@ -286,9 +260,9 @@ extern struct Battle_Config int show_picker_item_type; int attack_attr_none; int item_rate_mvp, item_rate_common, item_rate_common_boss, item_rate_card, item_rate_card_boss, - item_rate_equip, item_rate_equip_boss, item_rate_heal, item_rate_heal_boss, item_rate_use, - item_rate_use_boss, item_rate_treasure, item_rate_adddrop; - + item_rate_equip, item_rate_equip_boss, item_rate_heal, item_rate_heal_boss, item_rate_use, + item_rate_use_boss, item_rate_treasure, item_rate_adddrop; + int logarithmic_drops; int item_drop_common_min,item_drop_common_max; // Added by TyrNemesis^ int item_drop_card_min,item_drop_card_max; @@ -298,9 +272,9 @@ extern struct Battle_Config int item_drop_use_min,item_drop_use_max; //End int item_drop_treasure_min,item_drop_treasure_max; //by [Skotlex] int item_drop_adddrop_min,item_drop_adddrop_max; //[Skotlex] - + int prevent_logout; // Added by RoVeRT - + int alchemist_summon_reward; // [Valaris] int drops_by_luk; int drops_by_luk2; @@ -311,10 +285,10 @@ extern struct Battle_Config int max_exp_gain_rate; //Max amount of exp bar % you can get in one go. int pk_mode; int pk_level_range; - + int manner_system; // end additions [Valaris] int show_mob_info; - + int gx_allhit; int gx_disptype; int devotion_level_difference; @@ -330,14 +304,14 @@ extern struct Battle_Config int bone_drop; int buyer_name; int dancing_weaponswitch_fix; - -// eAthena additions + + // eAthena additions int night_at_start; // added by [Yor] int day_duration; // added by [Yor] int night_duration; // added by [Yor] int ban_hack_trade; // added by [Yor] int packet_ver_flag; // added by [Yor] - + int min_hair_style; // added by [MouseJstr] int max_hair_style; // added by [MouseJstr] int min_hair_color; // added by [MouseJstr] @@ -345,12 +319,12 @@ extern struct Battle_Config int min_cloth_color; // added by [MouseJstr] int max_cloth_color; // added by [MouseJstr] int pet_hair_style; // added by [Skotlex] - + int castrate_dex_scale; // added by [MouseJstr] int area_size; // added by [MouseJstr] - + int max_def, over_def_bonus; //added by [Skotlex] - + int zeny_from_mobs; // [Valaris] int mobs_level_up; // [Valaris] int mobs_level_up_exp_rate; // [Valaris] @@ -372,12 +346,12 @@ extern struct Battle_Config int delay_battle_damage; int hide_woe_damage; int display_version; - + int display_hallucination; // [Skotlex] int use_statpoint_table; // [Skotlex] - + int ignore_items_gender; //[Lupus] - + int copyskill_restrict; // [Aru] int berserk_cancels_buffs; // [Aru] int debuff_on_logout; // Removes a few "official" negative Scs on logout. [Skotlex] @@ -388,26 +362,26 @@ extern struct Battle_Config int mob_remove_delay; // Dynamic Mobs - delay before removing mobs from a map [Skotlex] int mob_active_time; //Duration through which mobs execute their Hard AI after players leave their area of sight. int boss_active_time; - + int show_hp_sp_drain, show_hp_sp_gain; //[Skotlex] - + int mob_npc_event_type; //Determines on who the npc_event is executed. [Skotlex] - + int character_size; // if riders have size=2, and baby class riders size=1 [Lupus] int mob_max_skilllvl; // Max possible skill level [Lupus] int rare_drop_announce; // chance <= to show rare drops global announces - + int retaliate_to_master; //Whether when a mob is attacked by another mob, it will retaliate versus the mob or the mob's master. [Skotlex] - + int duel_allow_pvp; // [LuzZza] int duel_allow_gvg; // [LuzZza] int duel_allow_teleport; // [LuzZza] int duel_autoleave_when_die; // [LuzZza] int duel_time_interval; // [LuzZza] int duel_only_on_same_map; // [Toms] - + int skip_teleport_lv1_menu; // possibility to disable (skip) Teleport Lv1 menu, that have only two lines `Random` and `Cancel` [LuzZza] - + int allow_skill_without_day; // [Komurka] int allow_es_magic_pc; // [Skotlex] int skill_wall_check; // [Skotlex] @@ -420,7 +394,7 @@ extern struct Battle_Config int mob_luk_sc_def; int pc_max_sc_def; int mob_max_sc_def; - + int sg_angel_skill_ratio; int sg_miracle_skill_ratio; int sg_miracle_skill_duration; @@ -460,7 +434,7 @@ extern struct Battle_Config int client_limit_unit_lv; int hom_max_level; int hom_S_max_level; - + // [BattleGround Settings] int bg_update_interval; int bg_short_damage_rate; @@ -469,20 +443,20 @@ extern struct Battle_Config int bg_magic_damage_rate; int bg_misc_damage_rate; int bg_flee_penalty; - + // rAthena int max_third_parameter; int max_baby_third_parameter; int atcommand_max_stat_bypass; int max_third_aspd; int vcast_stat_scale; - + int mvp_tomb_enabled; - + int atcommand_suggestions_enabled; int min_npc_vending_distance; int atcommand_mobinfo_type; - + int mob_size_influence; // Enable modifications on earned experience, drop rates and monster status depending on monster size. [mkbu95] /** Hercules **/ @@ -493,19 +467,76 @@ extern struct Battle_Config } battle_config; -void do_init_battle(void); -void do_final_battle(void); -extern int battle_config_read(const char *cfgName); -extern void battle_validate_conf(void); -extern void battle_set_defaults(void); -int battle_set_value(const char* w1, const char* w2); -int battle_get_value(const char* w1); -// -struct block_list* battle_getenemyarea(struct block_list *src, int x, int y, int range, int type, int ignore_id); /** - * Royal Guard + * Misc Vars **/ -int battle_damage_area( struct block_list *bl, va_list ap); +//attribute table +extern int attr_fix_table[4][10][10]; +/** + * Battle.c Interface + **/ +struct battle_interface { + /* init */ + void (*init) (void); + /* final */ + void (*final) (void); + /* damage calculation */ + struct Damage (*calc_attack) (int attack_type, struct block_list *bl, struct block_list *target, uint16 skill_id, uint16 skill_lv, int count); + /* generic final damage calculation */ + int (*calc_damage) (struct block_list *src, struct block_list *bl, struct Damage *d, int damage, uint16 skill_id, uint16 skill_lv); + /* gvg final damage calculation */ + int (*calc_gvg_damage) (struct block_list *src, struct block_list *bl, int damage, int div_, uint16 skill_id, uint16 skill_lv, int flag); + /* battlegrounds final damage calculation */ + int (*calc_bg_damage) (struct block_list *src, struct block_list *bl, int damage, int div_, uint16 skill_id, uint16 skill_lv, int flag); + /* normal weapon attack */ + enum damage_lv (*weapon_attack) (struct block_list *bl, struct block_list *target, unsigned int tick, int flag); + /* calculate weapon attack */ + struct Damage (*calc_weapon_attack) (struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int wflag); + /* delays damage or skills by a timer */ + int (*delay_damage) (unsigned int tick, int amotion, struct block_list *src, struct block_list *target, int attack_type, uint16 skill_id, uint16 skill_lv, int damage, enum damage_lv dmg_lv, int ddelay, bool additional_effects); + /* drain damage */ + void (*drain) (struct map_session_data *sd, struct block_list *tbl, int rdamage, int ldamage, int race, int boss); + /* damage return/reflect */ + int (*calc_return_damage) (struct block_list *bl, struct block_list *src, int *, int flag, uint16 skill_id); + /* attribute rate */ + int (*attr_ratio) (int atk_elem, int def_type, int def_lv); + /* applies attribute modifiers */ + int (*attr_fix) (struct block_list *src, struct block_list *target, int damage, int atk_elem, int def_type, int def_lv); + /* applies card modifiers */ + int (*calc_cardfix) (int attack_type, struct block_list *src, struct block_list *target, int nk, int s_ele, int s_ele_, int damage, int left, int flag); + /* get master (who does this unit respond to?) */ + struct block_list *(*get_master) (struct block_list *src); + /* returns a random unit who is targeting this unit */ + struct block_list *(*get_targeted) (struct block_list *target); + /* picks a random enemy unit who is in the area of sight */ + struct block_list *(*get_enemy) (struct block_list *target, int type, int range); + /* the target id (if any) of this unit */ + int (*get_target) (struct block_list *bl); + /* the current skill being processed/casted by this unit */ + int (*get_current_skill) (struct block_list *bl); + /* is either this race or element enough to be considered undead? */ + int (*check_undead) (int race,int element); + /* check if src and target are part of flag (e.g. enemies or allies) */ + int (*check_target) (struct block_list *src, struct block_list *target,int flag); + /* is src and bl within range? */ + bool (*check_range) (struct block_list *src,struct block_list *bl,int range); + /* consume amo for this skill and lv */ + void (*consume_ammo) (struct map_session_data* sd, int skill, int lv); + /* - battle_config */ + int (*config_read) (const char *cfgName); + void (*config_set_defaults) (void); + int (*config_set_value) (const char* w1, const char* w2); + int (*config_get_value) (const char* w1); + /* ----------------------------------------- */ + /* picks a random enemy within the specified range */ + struct block_list* (*get_enemy_area) (struct block_list *src, int x, int y, int range, int type, int ignore_id); + /* damages area, originally for royal guard's reflect damage */ + int (*damage_area) ( struct block_list *bl, va_list ap); +} battle_s; + +struct battle_interface *battle; + +void battle_defaults(void); #endif /* _BATTLE_H_ */ diff --git a/src/map/clif.c b/src/map/clif.c index ea05baa3c..e89d1aba5 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -5227,7 +5227,7 @@ void clif_skill_estimation(struct map_session_data *sd,struct block_list *dst) +(battle_config.estimation_type&2?status->mdef2:0); WBUFW(buf,18)= status->def_ele; for(i=0;i<9;i++) - WBUFB(buf,20+i)= (unsigned char)battle_attr_ratio(i+1,status->def_ele, status->ele_lv); + WBUFB(buf,20+i)= (unsigned char)battle->attr_ratio(i+1,status->def_ele, status->ele_lv); // The following caps negative attributes to 0 since the client displays them as 255-fix. [Skotlex] // WBUFB(buf,20+i)= (unsigned char)((fix=battle_attr_ratio(i+1,status->def_ele, status->ele_lv))<0?0:fix); @@ -10207,10 +10207,10 @@ void clif_parse_EquipItem(int fd,struct map_session_data *sd) if (index < 0 || index >= MAX_INVENTORY) return; //Out of bounds check. - if( sd->npc_id ) + if( sd->npc_id ) { if ( !sd->npc_item_flag ) return; - else if ( sd->state.storage_flag || sd->sc.opt1 ) + } else if ( sd->state.storage_flag || sd->sc.opt1 ) ; //You can equip/unequip stuff while storage is open/under status changes else if ( pc_cant_act2(sd) ) return; @@ -10247,10 +10247,10 @@ void clif_parse_UnequipItem(int fd,struct map_session_data *sd) return; } - if( sd->npc_id ) + if( sd->npc_id ) { if ( !sd->npc_item_flag ) return; - else if ( sd->state.storage_flag || sd->sc.opt1 ) + } else if ( sd->state.storage_flag || sd->sc.opt1 ) ; //You can equip/unequip stuff while storage is open/under status changes else if ( pc_cant_act2(sd) ) return; diff --git a/src/map/elemental.c b/src/map/elemental.c index 453845288..fc7d1cd36 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -288,7 +288,7 @@ int elemental_clean_single_effect(struct elemental_data *ed, uint16 skill_id) { nullpo_ret(ed); - bl = battle_get_master(&ed->bl); + bl = battle->get_master(&ed->bl); if( type ) { switch( type ) { @@ -422,7 +422,7 @@ int elemental_action(struct elemental_data *ed, struct block_list *bl, unsigned ed->last_thinktime = tick; // Not in skill range. - if( !battle_check_range(&ed->bl,bl,skill_get_range(skill_id,skill_lv)) ) { + if( !battle->check_range(&ed->bl,bl,skill_get_range(skill_id,skill_lv)) ) { // Try to walk to the target. if( !unit_walktobl(&ed->bl, bl, skill_get_range(skill_id,skill_lv), 2) ) elemental_unlocktarget(ed); @@ -444,7 +444,7 @@ int elemental_action(struct elemental_data *ed, struct block_list *bl, unsigned req = elemental_skill_get_requirements(skill_id, skill_lv); if(req.hp || req.sp){ - struct map_session_data *sd = BL_CAST(BL_PC, battle_get_master(&ed->bl)); + struct map_session_data *sd = BL_CAST(BL_PC, battle->get_master(&ed->bl)); if( sd ){ if( sd->skill_id_old != SO_EL_ACTION && //regardless of remaining HP/SP it can be cast (status_get_hp(&ed->bl) < req.hp || status_get_sp(&ed->bl) < req.sp) ) @@ -615,7 +615,7 @@ static int elemental_ai_sub_timer_activesearch(struct block_list *bl, va_list ap if( (*target) == bl || !status_check_skilluse(&ed->bl, bl, 0, 0) ) return 0; - if( battle_check_target(&ed->bl,bl,BCT_ENEMY) <= 0 ) + if( battle->check_target(&ed->bl,bl,BCT_ENEMY) <= 0 ) return 0; switch( bl->type ) { @@ -624,7 +624,7 @@ static int elemental_ai_sub_timer_activesearch(struct block_list *bl, va_list ap return 0; default: dist = distance_bl(&ed->bl, bl); - if( ((*target) == NULL || !check_distance_bl(&ed->bl, *target, dist)) && battle_check_range(&ed->bl,bl,ed->db->range2) ) { //Pick closest target? + if( ((*target) == NULL || !check_distance_bl(&ed->bl, *target, dist)) && battle->check_range(&ed->bl,bl,ed->db->range2) ) { //Pick closest target? (*target) = bl; ed->target_id = bl->id; ed->min_chase = dist + ed->db->range3; @@ -723,7 +723,7 @@ static int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_ return 1; } - if( battle_check_range(&ed->bl,target,view_range) && rnd()%100 < 2 ) { // 2% chance to cast attack skill. + if( battle->check_range(&ed->bl,target,view_range) && rnd()%100 < 2 ) { // 2% chance to cast attack skill. if( elemental_action(ed,target,tick) ) return 1; } @@ -733,7 +733,7 @@ static int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_ if( ed->ud.target == target->id && ed->ud.attacktimer != INVALID_TIMER ) //Already locked. return 1; - if( battle_check_range(&ed->bl, target, ed->base_status.rhw.range) ) {//Target within range, engage + if( battle->check_range(&ed->bl, target, ed->base_status.rhw.range) ) {//Target within range, engage unit_attack(&ed->bl,target->id,1); return 1; } diff --git a/src/map/map.c b/src/map/map.c index b43fc2f1a..8cd8bee95 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -525,7 +525,7 @@ struct skill_unit* map_find_skill_unit_oncell(struct block_list* target,int16 x, unit = (struct skill_unit *) bl; if( unit == out_unit || !unit->alive || !unit->group || unit->group->skill_id != skill_id ) continue; - if( !(flag&1) || battle_check_target(&unit->bl,target,unit->group->target_flag) > 0 ) + if( !(flag&1) || battle->check_target(&unit->bl,target,unit->group->target_flag) > 0 ) return unit; } return NULL; @@ -3639,7 +3639,7 @@ void do_final(void) chrif_flush_fifo(); do_final_atcommand(); - do_final_battle(); + battle->final(); do_final_chrif(); do_final_clif(); do_final_npc(); @@ -3919,7 +3919,9 @@ int do_init(int argc, char *argv[]) chrif_setip(ip_str); } - battle_config_read(BATTLE_CONF_FILENAME); + battle_defaults(); + + battle->config_read(BATTLE_CONF_FILENAME); msg_config_read(MSG_CONF_NAME); script_config_read(SCRIPT_CONF_NAME); inter_config_read(INTER_CONF_NAME); @@ -3943,7 +3945,7 @@ int do_init(int argc, char *argv[]) mapindex_init(); if(enable_grf) grfio_init(GRF_PATH_FILENAME); - + map_readallmaps(); add_timer_func_list(map_freeblock_timer, "map_freeblock_timer"); @@ -3952,7 +3954,7 @@ int do_init(int argc, char *argv[]) add_timer_interval(gettick()+1000, map_freeblock_timer, 0, 0, 60*1000); do_init_atcommand(); - do_init_battle(); + battle->init(); do_init_instance(); do_init_chrif(); do_init_clif(); diff --git a/src/map/mob.c b/src/map/mob.c index 96c27cf4e..d723bfe0b 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -356,14 +356,14 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target) if( !(md = BL_CAST(BL_MOB,target)) ) return false; // Tarjet is not MOB - if( (s_bl = battle_get_master(src)) == NULL ) + if( (s_bl = battle->get_master(src)) == NULL ) s_bl = src; if( !(sd = BL_CAST(BL_PC,s_bl)) ) return false; // Master is not PC t_bl = map_id2bl(md->target_id); - if( !t_bl || (s_bl = battle_get_master(t_bl)) == NULL ) + if( !t_bl || (s_bl = battle->get_master(t_bl)) == NULL ) s_bl = t_bl; t_sd = BL_CAST(BL_PC,s_bl); @@ -1068,7 +1068,7 @@ static int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) if ((mode&MD_TARGETWEAK) && status_get_lv(bl) >= md->level-5) return 0; - if(battle_check_target(&md->bl,bl,BCT_ENEMY)<=0) + if(battle->check_target(&md->bl,bl,BCT_ENEMY)<=0) return 0; switch (bl->type) @@ -1085,7 +1085,7 @@ static int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) dist = distance_bl(&md->bl, bl); if( ((*target) == NULL || !check_distance_bl(&md->bl, *target, dist)) && - battle_check_range(&md->bl,bl,md->db->range2) + battle->check_range(&md->bl,bl,md->db->range2) ) { //Pick closest target? if( map[bl->m].icewall_num && @@ -1122,12 +1122,11 @@ static int mob_ai_sub_hard_changechase(struct block_list *bl,va_list ap) //If can't seek yet, not an enemy, or you can't attack it, skip. if ((*target) == bl || - battle_check_target(&md->bl,bl,BCT_ENEMY)<=0 || + battle->check_target(&md->bl,bl,BCT_ENEMY)<=0 || !status_check_skilluse(&md->bl, bl, 0, 0)) return 0; - if(battle_check_range (&md->bl, bl, md->status.rhw.range)) - { + if(battle->check_range (&md->bl, bl, md->status.rhw.range)) { (*target) = bl; md->target_id=bl->id; md->min_chase= md->db->range3; @@ -1146,7 +1145,7 @@ static int mob_ai_sub_hard_bg_ally(struct block_list *bl,va_list ap) { md=va_arg(ap,struct mob_data *); target= va_arg(ap,struct block_list**); - if( status_check_skilluse(&md->bl, bl, 0, 0) && battle_check_target(&md->bl,bl,BCT_ENEMY)<=0 ) { + if( status_check_skilluse(&md->bl, bl, 0, 0) && battle->check_target(&md->bl,bl,BCT_ENEMY)<=0 ) { (*target) = bl; } return 1; @@ -1269,7 +1268,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) else if (ud->skilltarget) { tbl = map_id2bl(ud->skilltarget); //Required check as skilltarget is not always an enemy. [Skotlex] - if (tbl && battle_check_target(&md->bl, tbl, BCT_ENEMY) <= 0) + if (tbl && battle->check_target(&md->bl, tbl, BCT_ENEMY) <= 0) tbl = NULL; } if (tbl && status_check_skilluse(&md->bl, tbl, 0, 0)) { @@ -1462,7 +1461,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) { if( md->attacked_id == md->target_id ) { //Rude attacked check. - if( !battle_check_range(&md->bl, tbl, md->status.rhw.range) + if( !battle->check_range(&md->bl, tbl, md->status.rhw.range) && ( //Can't attack back and can't reach back. (!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0 && (battle_config.mob_ai&0x2 || (md->sc.data[SC_SPIDERWEB] && md->sc.data[SC_SPIDERWEB]->val1) || md->sc.data[SC_BITE] || md->sc.data[SC_VACUUM_EXTREME] || md->sc.data[SC_THORNSTRAP] @@ -1483,9 +1482,9 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) int dist; if( md->bl.m != abl->m || abl->prev == NULL || (dist = distance_bl(&md->bl, abl)) >= MAX_MINCHASE // Attacker longer than visual area - || battle_check_target(&md->bl, abl, BCT_ENEMY) <= 0 // Attacker is not enemy of mob + || battle->check_target(&md->bl, abl, BCT_ENEMY) <= 0 // Attacker is not enemy of mob || (battle_config.mob_ai&0x2 && !status_check_skilluse(&md->bl, abl, 0, 0)) // Cannot normal attack back to Attacker - || (!battle_check_range(&md->bl, abl, md->status.rhw.range) // Not on Melee Range and ... + || (!battle->check_range(&md->bl, abl, md->status.rhw.range) // Not on Melee Range and ... && ( // Reach check (!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0 && (battle_config.mob_ai&0x2 || (md->sc.data[SC_SPIDERWEB] && md->sc.data[SC_SPIDERWEB]->val1) || md->sc.data[SC_BITE] || md->sc.data[SC_VACUUM_EXTREME] || md->sc.data[SC_THORNSTRAP] @@ -1511,7 +1510,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) else { //Attackable if (!tbl || dist < md->status.rhw.range || !check_distance_bl(&md->bl, tbl, dist) - || battle_gettarget(tbl) != md->bl.id) + || battle->get_target(tbl) != md->bl.id) { //Change if the new target is closer than the actual one //or if the previous target is not attacking the mob. [Skotlex] md->target_id = md->attacked_id; // set target @@ -1629,7 +1628,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) if (md->ud.target == tbl->id && md->ud.attacktimer != INVALID_TIMER) //Already locked. return true; - if (battle_check_range (&md->bl, tbl, md->status.rhw.range)) + if (battle->check_range (&md->bl, tbl, md->status.rhw.range)) { //Target within range, engage if(tbl->type == BL_PC) @@ -2988,7 +2987,7 @@ int mob_getfriendhprate_sub(struct block_list *bl,va_list ap) if ((*fr) != NULL) //A friend was already found. return 0; - if (battle_check_target(&md->bl,bl,BCT_ENEMY)>0) + if (battle->check_target(&md->bl,bl,BCT_ENEMY)>0) return 0; rate = get_percentage(status_get_hp(bl), status_get_max_hp(bl)); @@ -3040,7 +3039,7 @@ int mob_getfriendstatus_sub(struct block_list *bl,va_list ap) if( mmd->bl.id == bl->id && !(battle_config.mob_ai&0x10) ) return 0; - if (battle_check_target(&mmd->bl,bl,BCT_ENEMY)>0) + if (battle->check_target(&mmd->bl,bl,BCT_ENEMY)>0) return 0; cond1=va_arg(ap,int); cond2=va_arg(ap,int); @@ -3182,7 +3181,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) short x, y; switch (ms[i].target) { case MST_RANDOM: //Pick a random enemy within skill range. - bl = battle_getenemy(&md->bl, DEFAULT_ENEMY_TYPE(md), + bl = battle->get_enemy(&md->bl, DEFAULT_ENEMY_TYPE(md), skill_get_range2(&md->bl, ms[i].skill_id, ms[i].skill_lv)); break; case MST_TARGET: @@ -3218,7 +3217,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) } md->skill_idx = i; map_freeblock_lock(); - if( !battle_check_range(&md->bl,bl,skill_get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) || + if( !battle->check_range(&md->bl,bl,skill_get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) || !unit_skilluse_pos2(&md->bl, x, y,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) ) { map_freeblock_unlock(); @@ -3228,7 +3227,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) //Targetted skill switch (ms[i].target) { case MST_RANDOM: //Pick a random enemy within skill range. - bl = battle_getenemy(&md->bl, DEFAULT_ENEMY_TYPE(md), + bl = battle->get_enemy(&md->bl, DEFAULT_ENEMY_TYPE(md), skill_get_range2(&md->bl, ms[i].skill_id, ms[i].skill_lv)); break; case MST_TARGET: @@ -3256,7 +3255,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) md->skill_idx = i; map_freeblock_lock(); - if( !battle_check_range(&md->bl,bl,skill_get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) || + if( !battle->check_range(&md->bl,bl,skill_get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) || !unit_skilluse_id2(&md->bl, bl->id,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) ) { map_freeblock_unlock(); @@ -3313,7 +3312,7 @@ int mobskill_event(struct mob_data *md, struct block_list *src, unsigned int tic //Restore previous target only if skill condition failed to trigger. [Skotlex] md->target_id = target_id; //Otherwise check if the target is an enemy, and unlock if needed. - else if (battle_check_target(&md->bl, src, BCT_ENEMY) <= 0) + else if (battle->check_target(&md->bl, src, BCT_ENEMY) <= 0) md->target_id = target_id; return res; diff --git a/src/map/pc.c b/src/map/pc.c index a3b1335c9..ff696b76e 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -6647,7 +6647,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) clif_charnameack(0, &md->bl); } } - src = battle_get_master(src); // Maybe Player Summon + src = battle->get_master(src); // Maybe Player Summon } break; case BL_PET: //Pass on to master... @@ -8747,7 +8747,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) { status_calc_pc(sd,0); } - if(sd->sc.data[SC_SIGNUMCRUCIS] && !battle_check_undead(sd->battle_status.race,sd->battle_status.def_ele)) + if(sd->sc.data[SC_SIGNUMCRUCIS] && !battle->check_undead(sd->battle_status.race,sd->battle_status.def_ele)) status_change_end(&sd->bl, SC_SIGNUMCRUCIS, INVALID_TIMER); //OnUnEquip script [Skotlex] diff --git a/src/map/pet.c b/src/map/pet.c index f64012e69..cc58aff9a 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -1,5 +1,6 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena Dev Teams #include "../common/db.h" #include "../common/timer.h" @@ -901,7 +902,7 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns if (target->type != BL_ITEM) { //enemy targetted - if(!battle_check_range(&pd->bl,target,pd->status.rhw.range)) + if(!battle->check_range(&pd->bl,target,pd->status.rhw.range)) { //Chase if(!unit_walktobl(&pd->bl, target, pd->status.rhw.range, 2)) pet_unlocktarget(pd); //Unreachable target. diff --git a/src/map/script.c b/src/map/script.c index 604872dfd..07b2459d6 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -13494,7 +13494,7 @@ BUILDIN_FUNC(setbattleflag) flag = script_getstr(st,2); value = script_getstr(st,3); // HACK: Retrieve number as string (auto-converted) for battle_set_value - if (battle_set_value(flag, value) == 0) + if (battle->config_set_value(flag, value) == 0) ShowWarning("buildin_setbattleflag: unknown battle_config flag '%s'\n",flag); else ShowInfo("buildin_setbattleflag: battle_config flag '%s' is now set to '%s'.\n",flag,value); @@ -13506,7 +13506,7 @@ BUILDIN_FUNC(getbattleflag) { const char *flag; flag = script_getstr(st,2); - script_pushint(st,battle_get_value(flag)); + script_pushint(st,battle->config_get_value(flag)); return 0; } @@ -16625,7 +16625,7 @@ static int buildin_mobuseskill_sub(struct block_list *bl,va_list ap) case 0: tbl = map_id2bl(md->bl.id); break; case 1: tbl = map_id2bl(md->target_id); break; case 2: tbl = map_id2bl(md->master_id); break; - default:tbl = battle_getenemy(&md->bl, DEFAULT_ENEMY_TYPE(md),skill_get_range2(&md->bl, skill_id, skill_lv)); break; + default:tbl = battle->get_enemy(&md->bl, DEFAULT_ENEMY_TYPE(md),skill_get_range2(&md->bl, skill_id, skill_lv)); break; } if( !tbl ) diff --git a/src/map/skill.c b/src/map/skill.c index 8fdc09cb7..bb9e29be4 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -982,7 +982,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint case CR_GRANDCROSS: case NPC_GRANDDARKNESS: //Chance to cause blind status vs demon and undead element, but not against players - if(!dstsd && (battle_check_undead(tstatus->race,tstatus->def_ele) || tstatus->race == RC_DEMON)) + if(!dstsd && (battle->check_undead(tstatus->race,tstatus->def_ele) || tstatus->race == RC_DEMON)) sc_start(bl,SC_BLIND,100,skill_lv,skill_get_time2(skill_id,skill_lv)); attack_type |= BF_WEAPON; break; @@ -1105,7 +1105,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint break; case LK_HEADCRUSH: //Headcrush has chance of causing Bleeding status, except on demon and undead element - if (!(battle_check_undead(tstatus->race, tstatus->def_ele) || tstatus->race == RC_DEMON)) + if (!(battle->check_undead(tstatus->race, tstatus->def_ele) || tstatus->race == RC_DEMON)) sc_start2(bl, SC_BLEEDING,50, skill_lv, src->id, skill_get_time2(skill_id,skill_lv)); break; @@ -1290,7 +1290,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint sc_start(bl,SC_STOP,100,skill_lv,skill_get_time(skill_id,skill_lv)); break; case LG_RAYOFGENESIS: // 50% chance to cause Blind on Undead and Demon monsters. - if ( battle_check_undead(tstatus->race, tstatus->def_ele) || tstatus->race == RC_DEMON ) + if ( battle->check_undead(tstatus->race, tstatus->def_ele) || tstatus->race == RC_DEMON ) sc_start(bl, SC_BLIND,50, skill_lv, skill_get_time(skill_id,skill_lv)); break; case LG_EARTHDRIVE: @@ -1557,7 +1557,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint } } if( battle_config.autospell_check_range && - !battle_check_range(src, tbl, skill_get_range2(src, skill,skill_lv) + (skill == RG_CLOSECONFINE?0:1)) ) + !battle->check_range(src, tbl, skill_get_range2(src, skill,skill_lv) + (skill == RG_CLOSECONFINE?0:1)) ) continue; if (skill == AS_SONICBLOW) @@ -1697,7 +1697,7 @@ int skill_onskillusage(struct map_session_data *sd, struct block_list *bl, uint1 } } if( battle_config.autospell_check_range && - !battle_check_range(&sd->bl, tbl, skill_get_range2(&sd->bl, skill,skill_lv) + (skill == RG_CLOSECONFINE?0:1)) ) + !battle->check_range(&sd->bl, tbl, skill_get_range2(&sd->bl, skill,skill_lv) + (skill == RG_CLOSECONFINE?0:1)) ) continue; sd->state.autocast = 1; @@ -1904,7 +1904,7 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list * } } - if( !battle_check_range(src, tbl, skill_get_range2(src, skill_id,skill_lv) + (skill_id == RG_CLOSECONFINE?0:1)) && battle_config.autospell_check_range ) + if( !battle->check_range(src, tbl, skill_get_range2(src, skill_id,skill_lv) + (skill_id == RG_CLOSECONFINE?0:1)) && battle_config.autospell_check_range ) continue; dstsd->state.autocast = 1; @@ -2226,7 +2226,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds if (sc && sc->data[SC_TRICKDEAD]) return 0; - dmg = battle_calc_attack(attack_type,src,bl,skill_id,skill_lv,flag&0xFFF); + dmg = battle->calc_attack(attack_type,src,bl,skill_id,skill_lv,flag&0xFFF); //Skotlex: Adjusted to the new system if(src->type==BL_PET) @@ -2238,7 +2238,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds /*if (skill_id == -1) Does it ever worked? element = sstatus->rhw.ele;*/ if (element != ELE_NEUTRAL || !(battle_config.attack_attr_none&BL_PET)) - dmg.damage=battle_attr_fix(src, bl, skill_lv, element, tstatus->def_ele, tstatus->ele_lv); + dmg.damage = battle->attr_fix(src, bl, skill_lv, element, tstatus->def_ele, tstatus->ele_lv); else dmg.damage= skill_lv; dmg.damage2=0; @@ -2282,7 +2282,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds **/ #if MAGIC_REFLECTION_TYPE if( dmg.dmg_lv != ATK_MISS )//Wiz SL cancelled and consumed fragment - dmg = battle_calc_attack(BF_MAGIC,bl,bl,skill_id,skill_lv,flag&0xFFF); + dmg = battle->calc_attack(BF_MAGIC,bl,bl,skill_id,skill_lv,flag&0xFFF); #endif } if(sc && sc->data[SC_MAGICROD] && src == dsrc) { @@ -2305,11 +2305,11 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds if( damage > 0 && (( dmg.flag&BF_WEAPON && src != bl && ( src == dsrc || ( dsrc->type == BL_SKILL && ( skill_id == SG_SUN_WARM || skill_id == SG_MOON_WARM || skill_id == SG_STAR_WARM ) ) )) || (sc && sc->data[SC_REFLECTDAMAGE])) ) - rdamage = battle_calc_return_damage(bl,src, &damage, dmg.flag, skill_id); + rdamage = battle->calc_return_damage(bl,src, &damage, dmg.flag, skill_id); if( damage && sc && sc->data[SC_GENSOU] && dmg.flag&BF_MAGIC ){ struct block_list *nbl; - nbl = battle_getenemyarea(bl,bl->x,bl->y,2,BL_CHAR,bl->id); + nbl = battle->get_enemy_area(bl,bl->x,bl->y,2,BL_CHAR,bl->id); if( nbl ){ // Only one target is chosen. damage = damage / 2; // Deflect half of the damage to a target nearby clif_skill_damage(bl, nbl, tick, status_get_amotion(src), 0, status_fix_damage(bl,nbl,damage,0), dmg.div_, OB_OBOROGENSOU_TRANSITION_ATK, -1, 6); @@ -2695,7 +2695,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds //Delayed damage must be dealt after the knockback (it needs to know actual position of target) if (dmg.amotion) - battle_delay_damage(tick, dmg.amotion,src,bl,dmg.flag,skill_id,skill_lv,damage,dmg.dmg_lv,dmg.dmotion, additional_effects); + battle->delay_damage(tick, dmg.amotion,src,bl,dmg.flag,skill_id,skill_lv,damage,dmg.dmg_lv,dmg.dmotion, additional_effects); if( sc && sc->data[SC_DEVOTION] && skill_id != PA_PRESSURE ) { struct status_change_entry *sce = sc->data[SC_DEVOTION]; @@ -2740,24 +2740,24 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds (dmg.flag&BF_MISC && (skill_id == RA_CLUSTERBOMB || skill_id == RA_FIRINGTRAP || skill_id == RA_ICEBOUNDTRAP || skill_id == RK_DRAGONBREATH)) ) ) { if (battle_config.left_cardfix_to_right) - battle_drain(sd, bl, dmg.damage, dmg.damage, tstatus->race, tstatus->mode&MD_BOSS); + battle->drain(sd, bl, dmg.damage, dmg.damage, tstatus->race, tstatus->mode&MD_BOSS); else - battle_drain(sd, bl, dmg.damage, dmg.damage2, tstatus->race, tstatus->mode&MD_BOSS); + battle->drain(sd, bl, dmg.damage, dmg.damage2, tstatus->race, tstatus->mode&MD_BOSS); } if( rdamage > 0 ) { if( sc && sc->data[SC_REFLECTDAMAGE] ) { if( src != bl )// Don't reflect your own damage (Grand Cross) - map_foreachinshootrange(battle_damage_area,bl,skill_get_splash(LG_REFLECTDAMAGE,1),BL_CHAR,tick,bl,dmg.amotion,sstatus->dmotion,rdamage,tstatus->race); + map_foreachinshootrange(battle->damage_area,bl,skill_get_splash(LG_REFLECTDAMAGE,1),BL_CHAR,tick,bl,dmg.amotion,sstatus->dmotion,rdamage,tstatus->race); } else { if( dmg.amotion ) - battle_delay_damage(tick, dmg.amotion,bl,src,0,CR_REFLECTSHIELD,0,rdamage,ATK_DEF,0,additional_effects); + battle->delay_damage(tick, dmg.amotion,bl,src,0,CR_REFLECTSHIELD,0,rdamage,ATK_DEF,0,additional_effects); else status_fix_damage(bl,src,rdamage,0); clif_damage(src,src,tick, dmg.amotion,0,rdamage,1,4,0); // in aegis damage reflected is shown in single hit. //Use Reflect Shield to signal this kind of skill trigger. [Skotlex] if( tsd && src != bl ) - battle_drain(tsd, src, rdamage, rdamage, sstatus->race, is_boss(src)); + battle->drain(tsd, src, rdamage, rdamage, sstatus->race, is_boss(src)); skill_additional_effect(bl, src, CR_REFLECTSHIELD, 1, BF_WEAPON|BF_SHORT|BF_NORMAL,ATK_DEF,tick); } } @@ -2829,8 +2829,7 @@ int skill_area_sub (struct block_list *bl, va_list ap) flag=va_arg(ap,int); func=va_arg(ap,SkillFunc); - if(battle_check_target(src,bl,flag) > 0) - { + if(battle->check_target(src,bl,flag) > 0) { // several splash skills need this initial dummy packet to display correctly if (flag&SD_PREAMBLE && skill_area_temp[2] == 0) clif_skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); @@ -3201,15 +3200,13 @@ static int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) struct block_list *nbl = NULL; // Next Target of Chain skill_attack(BF_MAGIC,src,src,target,skl->skill_id,skl->skill_lv,tick,skl->flag); // Hit a Lightning on the current Target skill_toggle_magicpower(src, skl->skill_id); // only the first hit will be amplify - if( skl->type > 1 ) - { // Remaining Chains Hit - nbl = battle_getenemyarea(src,target->x,target->y,2,BL_CHAR|BL_SKILL,target->id); // Search for a new Target around current one... - if( nbl == NULL && skl->x > 1 ) - { + if( skl->type > 1 ) { // Remaining Chains Hit + nbl = battle->get_enemy_area(src,target->x,target->y,2,BL_CHAR|BL_SKILL,target->id); // Search for a new Target around current one... + if( nbl == NULL && skl->x > 1 ) { nbl = target; skl->x--; - } - else skl->x = 3; + } else + skl->x = 3; } if( nbl ) @@ -3926,7 +3923,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case PR_TURNUNDEAD: case ALL_RESURRECTION: - if (!battle_check_undead(tstatus->race, tstatus->def_ele)) + if (!battle->check_undead(tstatus->race, tstatus->def_ele)) break; skill_attack(BF_MAGIC,src,src,bl,skill_id,skill_lv,tick,flag); break; @@ -4015,7 +4012,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case PR_BENEDICTIO: //Should attack undead and demons. [Skotlex] - if (battle_check_undead(tstatus->race, tstatus->def_ele) || tstatus->race == RC_DEMON) + if (battle->check_undead(tstatus->race, tstatus->def_ele) || tstatus->race == RC_DEMON) skill_attack(BF_MAGIC, src, src, bl, skill_id, skill_lv, tick, flag); break; @@ -4117,7 +4114,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint clif_skill_nodamage(src,bl,skill_id,skill_lv,1); skill_blown(src,bl,distance_bl(src,bl)-1,unit_getdir(src),0); - if( battle_check_target(src,bl,BCT_ENEMY) ) + if( battle->check_target(src,bl,BCT_ENEMY) ) skill_attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); break; @@ -4528,7 +4525,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint skill_attack(skill_get_type(skill_id+1),src,src,bl,skill_id+1,skill_lv,tick,flag); else { int i = skill_get_splash(skill_id,skill_lv); - clif_skill_nodamage(src,battle_get_master(src),skill_id,skill_lv,1); + clif_skill_nodamage(src,battle->get_master(src),skill_id,skill_lv,1); clif_skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); if( rnd()%100 < 30 ) map_foreachinrange(skill_area_sub,bl,i,BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill_castend_damage_id); @@ -4538,7 +4535,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint break; case EL_ROCK_CRUSHER: - clif_skill_nodamage(src,battle_get_master(src),skill_id,skill_lv,1); + clif_skill_nodamage(src,battle->get_master(src),skill_id,skill_lv,1); clif_skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); if( rnd()%100 < 50 ) skill_attack(BF_MAGIC,src,src,bl,skill_id,skill_lv,tick,flag); @@ -4551,7 +4548,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint skill_attack(skill_get_type(skill_id),src,src,bl,skill_id,skill_lv,tick,flag); else { int i = skill_get_splash(skill_id,skill_lv); - clif_skill_nodamage(src,battle_get_master(src),skill_id,skill_lv,1); + clif_skill_nodamage(src,battle->get_master(src),skill_id,skill_lv,1); clif_skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); if( rnd()%100 < 30 ) map_foreachinrange(skill_area_sub,bl,i,BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill_castend_damage_id); @@ -4564,7 +4561,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case EL_ICE_NEEDLE: case EL_WIND_SLASH: case EL_STONE_HAMMER: - clif_skill_nodamage(src,battle_get_master(src),skill_id,skill_lv,1); + clif_skill_nodamage(src,battle->get_master(src),skill_id,skill_lv,1); clif_skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); skill_attack(skill_get_type(skill_id),src,src,bl,skill_id,skill_lv,tick,flag); break; @@ -4577,7 +4574,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint sc_type type = status_skill2sc(skill_id), type2; type2 = type-1; - clif_skill_nodamage(src,battle_get_master(src),skill_id,skill_lv,1); + clif_skill_nodamage(src,battle->get_master(src),skill_id,skill_lv,1); clif_skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); if( (sc && sc->data[type2]) || (tsc && tsc->data[type]) ) { elemental_clean_single_effect(ele, skill_id); @@ -4586,7 +4583,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint skill_attack(skill_get_type(skill_id),src,src,bl,skill_id,skill_lv,tick,flag); else { sc_start(src,type2,100,skill_lv,skill_get_time(skill_id,skill_lv)); - sc_start(battle_get_master(src),type,100,ele->bl.id,skill_get_time(skill_id,skill_lv)); + sc_start(battle->get_master(src),type,100,ele->bl.id,skill_get_time(skill_id,skill_lv)); } clif_skill_nodamage(src,src,skill_id,skill_lv,1); } @@ -4657,7 +4654,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint if( sd->state.arrow_atk ) {// consume arrow on last invocation to this skill. - battle_consume_ammo(sd, skill_id, skill_lv); + battle->consume_ammo(sd, skill_id, skill_lv); } // perform skill requirement consumption @@ -4738,8 +4735,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case AB_RENOVATIO: case AB_HIGHNESSHEAL: //Apparently only player casted skills can be offensive like this. - if (sd && battle_check_undead(tstatus->race,tstatus->def_ele)) { - if (battle_check_target(src, bl, BCT_ENEMY) < 1) { + if (sd && battle->check_undead(tstatus->race,tstatus->def_ele)) { + if (battle->check_target(src, bl, BCT_ENEMY) < 1) { //Offensive heal does not works on non-enemies. [Skotlex] clif_skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; @@ -4750,7 +4747,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case NPC_SMOKING: //Since it is a self skill, this one ends here rather than in damage_id. [Skotlex] return skill_castend_damage_id (src, bl, skill_id, skill_lv, tick, flag); case MH_STEINWAND: { - struct block_list *s_src = battle_get_master(src); + struct block_list *s_src = battle->get_master(src); short ret = 0; if(!skill_check_unit_range(src, src->x, src->y, skill_id, skill_lv)) //prevent reiteration ret = skill_castend_pos2(src,src->x,src->y,skill_id,skill_lv,tick,flag); //cast on homon @@ -4774,7 +4771,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (src!=bl && type > -1 && (i = skill_get_ele(skill_id, skill_lv)) > ELE_NEUTRAL && skill_get_inf(skill_id) != INF_SUPPORT_SKILL && - battle_attr_fix(NULL, NULL, 100, i, tstatus->def_ele, tstatus->ele_lv) <= 0) + battle->attr_fix(NULL, NULL, 100, i, tstatus->def_ele, tstatus->ele_lv) <= 0) return 1; //Skills that cause an status should be blocked if the target element blocks its element. map_freeblock_lock(); @@ -5212,7 +5209,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case TK_JUMPKICK: /* Check if the target is an enemy; if not, skill should fail so the character doesn't unit_movepos (exploitable) */ - if( battle_check_target(src, bl, BCT_ENEMY) > 0 ) + if( battle->check_target(src, bl, BCT_ENEMY) > 0 ) { if( unit_movepos(src, bl->x, bl->y, 1, 1) ) { @@ -5308,7 +5305,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui int bonus = 25 + 10 * skill_lv; bonus += (pc_checkskill(sd, SA_FLAMELAUNCHER)+pc_checkskill(sd, SA_FROSTWEAPON)+pc_checkskill(sd, SA_LIGHTNINGLOADER)+pc_checkskill(sd, SA_SEISMICWEAPON))*5; clif_skill_nodamage( src, bl, skill_id, skill_lv, - battle_check_target(src,bl,BCT_PARTY) ? + battle->check_target(src,bl,BCT_PARTY) ? sc_start2(bl, type, 100, skill_lv, bonus, skill_get_time(skill_id,skill_lv)) : 0 ); @@ -5432,7 +5429,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case SM_PROVOKE: case SM_SELFPROVOKE: case MER_PROVOKE: - if( (tstatus->mode&MD_BOSS) || battle_check_undead(tstatus->race,tstatus->def_ele) ) + if( (tstatus->mode&MD_BOSS) || battle->check_undead(tstatus->race,tstatus->def_ele) ) { map_freeblock_unlock(); return 1; @@ -5950,8 +5947,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui status_change_end(bl, SC_WHITEIMPRISON, INVALID_TIMER); } //Is this equation really right? It looks so... special. - if(battle_check_undead(tstatus->race,tstatus->def_ele)) - { + if( battle->check_undead(tstatus->race,tstatus->def_ele) ) { status_change_start(bl, SC_BLIND, 100*(100-(tstatus->int_/2+tstatus->vit/3+tstatus->luk/10)), 1,0,0,0, @@ -6691,7 +6687,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (md && md->master_id > 0) { struct block_list *mbl, *tbl; if ((mbl = map_id2bl(md->master_id)) == NULL || - (tbl = battle_gettargeted(mbl)) == NULL) + (tbl = battle->get_targeted(mbl)) == NULL) break; md->state.provoke_flag = tbl->id; mob_target(md, tbl, sstatus->rhw.range); @@ -6920,8 +6916,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case PF_MINDBREAKER: { - if(tstatus->mode&MD_BOSS || battle_check_undead(tstatus->race,tstatus->def_ele)) - { + if(tstatus->mode&MD_BOSS || battle->check_undead(tstatus->race,tstatus->def_ele) ) { map_freeblock_unlock(); return 1; } @@ -7369,9 +7364,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if(r<per[i][0]) //Self bl = src; else if(r<per[i][1]) //Master - bl = battle_get_master(src); + bl = battle->get_master(src); else //Enemy - bl = map_id2bl(battle_gettarget(src)); + bl = map_id2bl(battle->get_target(src)); if (!bl) bl = src; i = skill_calc_heal(src, bl, skill_id, 1+rnd()%skill_lv, true); @@ -7668,10 +7663,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case AB_CHEAL: - if( sd == NULL || sd->status.party_id == 0 || flag&1 ) - { - if( sd && tstatus && !battle_check_undead(tstatus->race, tstatus->def_ele) ) - { + if( sd == NULL || sd->status.party_id == 0 || flag&1 ) { + if( sd && tstatus && !battle->check_undead(tstatus->race, tstatus->def_ele) ) { i = skill_calc_heal(src, bl, AL_HEAL, pc_checkskill(sd, AL_HEAL), true); if( (dstsd && pc_ismadogear(dstsd)) || status_isimmune(bl)) @@ -7829,7 +7822,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case WL_WHITEIMPRISON: - if( (src == bl || battle_check_target(src, bl, BCT_ENEMY)) && !is_boss(bl) )// Should not work with bosses. + if( (src == bl || battle->check_target(src, bl, BCT_ENEMY)) && !is_boss(bl) )// Should not work with bosses. { int rate = ( sd? sd->status.job_level : 50 ) / 4; @@ -8459,7 +8452,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( !(tsc && tsc->data[type]) ) sc_start(bl, type, 100, skill_lv,skill_get_time(skill_id, skill_lv)); } else if( flag&2 ) { - if( src->id != bl->id && battle_check_target(src,bl,BCT_ENEMY) > 0 ) + if( src->id != bl->id && battle->check_target(src,bl,BCT_ENEMY) > 0 ) status_fix_damage(src,bl,9999,clif_damage(src,bl,tick,0,0,9999,0,0,0)); } else if( sd ) { short chance = sstatus->int_/6 + sd->status.job_level/5 + skill_lv*4; @@ -8749,7 +8742,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; sd->itemid = ammo_id; if( itemdb_is_GNbomb(ammo_id) ) { - if(battle_check_target(src,bl,BCT_ENEMY) > 0) {// Only attack if the target is an enemy. + if(battle->check_target(src,bl,BCT_ENEMY) > 0) {// Only attack if the target is an enemy. if( ammo_id == 13263 ) map_foreachincell(skill_area_sub,bl->m,bl->x,bl->y,BL_CHAR,src,GN_SLINGITEM_RANGEMELEEATK,skill_lv,tick,flag|BCT_ENEMY|1,skill_castend_damage_id); else @@ -8901,7 +8894,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case KO_GENWAKU: - if ( !map_flag_gvg(src->m) && ( dstsd || dstmd ) && battle_check_target(src,bl,BCT_ENEMY) > 0 ) { + if ( !map_flag_gvg(src->m) && ( dstsd || dstmd ) && battle->check_target(src,bl,BCT_ENEMY) > 0 ) { int x = src->x, y = src->y; if( sd && rnd()%100 > ((45+5*skill_lv) - status_get_int(bl)/10) ){//[(Base chance of success) - (Intelligence Objectives / 10)]%. @@ -8968,7 +8961,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case MH_SILENT_BREEZE: { struct status_change *ssc = status_get_sc(src); - struct block_list *m_bl = battle_get_master(src); + struct block_list *m_bl = battle->get_master(src); const enum sc_type scs[] = { SC_MANDRAGORA, SC_HARMONIZE, SC_DEEPSLEEP, SC_VOICEOFSIREN, SC_SLEEP, SC_CONFUSION, SC_HALLUCINATION }; @@ -8997,7 +8990,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case MH_OVERED_BOOST: if (hd){ - struct block_list *s_bl = battle_get_master(src); + struct block_list *s_bl = battle->get_master(src); if(hd->homunculus.hunger>50) //reduce hunger hd->homunculus.hunger = hd->homunculus.hunger/2; else @@ -9013,10 +9006,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case MH_GRANITIC_ARMOR: case MH_PYROCLASTIC: { - struct block_list *s_bl = battle_get_master(src); - if(s_bl) sc_start2(s_bl, type, 100, skill_lv, hd->homunculus.level, skill_get_time(skill_id, skill_lv)); //start on master + struct block_list *s_bl = battle->get_master(src); + if(s_bl) + sc_start2(s_bl, type, 100, skill_lv, hd->homunculus.level, skill_get_time(skill_id, skill_lv)); //start on master sc_start2(bl, type, 100, skill_lv, hd->homunculus.level, skill_get_time(skill_id, skill_lv)); - if (hd) skill_blockhomun_start(hd, skill_id, skill_get_cooldown(skill_id, skill_lv)); + if (hd) + skill_blockhomun_start(hd, skill_id, skill_get_cooldown(skill_id, skill_lv)); } break; @@ -9079,7 +9074,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( sd->state.arrow_atk ) {// consume arrow on last invocation to this skill. - battle_consume_ammo(sd, skill_id, skill_lv); + battle->consume_ammo(sd, skill_id, skill_lv); } skill_onskillusage(sd, bl, skill_id, tick); // perform skill requirement consumption @@ -9183,10 +9178,9 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) } } - if( ud->skill_id == PR_TURNUNDEAD ) - { + if( ud->skill_id == PR_TURNUNDEAD ) { struct status_data *tstatus = status_get_status_data(target); - if( !battle_check_undead(tstatus->race, tstatus->def_ele) ) + if( !battle->check_undead(tstatus->race, tstatus->def_ele) ) break; } @@ -9198,7 +9192,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) if( ud->skill_id == PR_LEXDIVINA || ud->skill_id == MER_LEXDIVINA ) { sc = status_get_sc(target); - if( battle_check_target(src,target, BCT_ENEMY) <= 0 && (!sc || !sc->data[SC_SILENCE]) ) + if( battle->check_target(src,target, BCT_ENEMY) <= 0 && (!sc || !sc->data[SC_SILENCE]) ) { //If it's not an enemy, and not silenced, you can't use the skill on them. [Skotlex] clif_skill_nodamage (src, target, ud->skill_id, ud->skill_lv, 0); break; @@ -9237,7 +9231,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) if( ((TBL_MOB*)target)->class_ == MOBID_EMPERIUM ) break; } - else if (inf && battle_check_target(src, target, inf) <= 0){ + else if (inf && battle->check_target(src, target, inf) <= 0){ if (sd) clif_skill_fail(sd,ud->skill_id,USESKILL_FAIL_LEVEL,0); break; } @@ -10286,7 +10280,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui if( sd->state.arrow_atk && !(flag&1) ) {// consume arrow if this is a ground skill - battle_consume_ammo(sd, skill_id, skill_lv); + battle->consume_ammo(sd, skill_id, skill_lv); } // perform skill requirement consumption @@ -11076,7 +11070,7 @@ static int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, un // If you are fiberlocked and can't move, it will only increase your fireweakness level. [Inkfish] sc->data[SC_SPIDERWEB]->val2++; break; - } else if( sc && battle_check_target(&sg->unit->bl,bl,sg->target_flag) > 0 ) { + } else if( sc && battle->check_target(&sg->unit->bl,bl,sg->target_flag) > 0 ) { int sec = skill_get_time2(sg->skill_id,sg->skill_lv); if( status_change_start(bl,type,10000,sg->skill_lv,1,sg->group_id,0,sec,8) ) { const struct TimerData* td = sc->data[type]?get_timer(sc->data[type]->timer):NULL; @@ -11150,7 +11144,7 @@ static int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, un break; case UNT_QUAGMIRE: - if( !sce && battle_check_target(&sg->unit->bl,bl,sg->target_flag) > 0 ) + if( !sce && battle->check_target(&sg->unit->bl,bl,sg->target_flag) > 0 ) sc_start4(bl,type,100,sg->skill_lv,sg->group_id,0,0,sg->limit); break; @@ -11164,12 +11158,12 @@ static int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, un case UNT_SUITON: if(!sce) sc_start4(bl,type,100,sg->skill_lv, - map_flag_vs(bl->m) || battle_check_target(&src->bl,bl,BCT_ENEMY)>0?1:0, //Send val3 =1 to reduce agi. + map_flag_vs(bl->m) || battle->check_target(&src->bl,bl,BCT_ENEMY)>0?1:0, //Send val3 =1 to reduce agi. 0,0,sg->limit); break; case UNT_HERMODE: - if (sg->src_id!=bl->id && battle_check_target(&src->bl,bl,BCT_PARTY|BCT_GUILD) > 0) + if (sg->src_id!=bl->id && battle->check_target(&src->bl,bl,BCT_PARTY|BCT_GUILD) > 0) status_change_clear_buffs(bl,1); //Should dispell only allies. case UNT_RICHMANKIM: case UNT_ETERNALCHAOS: @@ -11210,7 +11204,7 @@ static int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, un if (!sce) { sc_start4(bl, type, 100, sg->skill_lv, sg->val1, sg->val2, sg->group_id, sg->limit); - if (battle_check_target(&src->bl,bl,BCT_ENEMY)>0) + if (battle->check_target(&src->bl,bl,BCT_ENEMY)>0) skill_additional_effect (ss, bl, sg->skill_id, sg->skill_lv, BF_MISC, ATK_DEF, tick); } break; @@ -11239,7 +11233,7 @@ static int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, un case UNT_WALLOFTHORN: if( status_get_mode(bl)&MD_BOSS ) break; // iRO Wiki says that this skill don't affect to Boss monsters. - if( map_flag_vs(bl->m) || bl->id == src->bl.id || battle_check_target(&src->bl,bl, BCT_ENEMY) == 1 ) + if( map_flag_vs(bl->m) || bl->id == src->bl.id || battle->check_target(&src->bl,bl, BCT_ENEMY) == 1 ) skill_attack(skill_get_type(sg->skill_id), ss, &src->bl, bl, sg->skill_id, sg->skill_lv, tick, 0); break; @@ -11339,13 +11333,11 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns break; case UNT_SANCTUARY: - if( battle_check_undead(tstatus->race, tstatus->def_ele) || tstatus->race==RC_DEMON ) + if( battle->check_undead(tstatus->race, tstatus->def_ele) || tstatus->race==RC_DEMON ) { //Only damage enemies with offensive Sanctuary. [Skotlex] - if( battle_check_target(&src->bl,bl,BCT_ENEMY) > 0 && skill_attack(BF_MAGIC, ss, &src->bl, bl, sg->skill_id, sg->skill_lv, tick, 0) ) + if( battle->check_target(&src->bl,bl,BCT_ENEMY) > 0 && skill_attack(BF_MAGIC, ss, &src->bl, bl, sg->skill_id, sg->skill_lv, tick, 0) ) sg->val1 -= 2; // reduce healing count if this was meant for damaging [hekate] - } - else - { + } else { int heal = skill_calc_heal(ss,bl,sg->skill_id,sg->skill_lv,true); struct mob_data *md = BL_CAST(BL_MOB, bl); #ifdef RENEWAL @@ -11371,9 +11363,9 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns case UNT_EVILLAND: //Will heal demon and undead element monsters, but not players. - if ((bl->type == BL_PC) || (!battle_check_undead(tstatus->race, tstatus->def_ele) && tstatus->race!=RC_DEMON)) + if ((bl->type == BL_PC) || (!battle->check_undead(tstatus->race, tstatus->def_ele) && tstatus->race!=RC_DEMON)) { //Damage enemies - if(battle_check_target(&src->bl,bl,BCT_ENEMY)>0) + if(battle->check_target(&src->bl,bl,BCT_ENEMY)>0) skill_attack(BF_MISC, ss, &src->bl, bl, sg->skill_id, sg->skill_lv, tick, 0); } else { int heal = skill_calc_heal(ss,bl,sg->skill_id,sg->skill_lv,true); @@ -11387,7 +11379,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns break; case UNT_MAGNUS: - if (!battle_check_undead(tstatus->race,tstatus->def_ele) && tstatus->race!=RC_DEMON) + if (!battle->check_undead(tstatus->race,tstatus->def_ele) && tstatus->race!=RC_DEMON) break; skill_attack(BF_MAGIC,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick,0); break; @@ -11594,7 +11586,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns case UNT_GOSPEL: if (rnd()%100 > sg->skill_lv*10 || ss == bl) break; - if (battle_check_target(ss,bl,BCT_PARTY)>0) + if (battle->check_target(ss,bl,BCT_PARTY)>0) { // Support Effect only on party, not guild int heal; int i = rnd()%13; // Positive buff count @@ -11655,7 +11647,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns break; } } - else if (battle_check_target(&src->bl,bl,BCT_ENEMY)>0) + else if (battle->check_target(&src->bl,bl,BCT_ENEMY)>0) { // Offensive Effect int i = rnd()%9; // Negative buff count int time = skill_get_time2(sg->skill_id, sg->skill_lv); @@ -11694,7 +11686,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns case UNT_BASILICA: { - int i = battle_check_target(&src->bl, bl, BCT_ENEMY); + int i = battle->check_target(&src->bl, bl, BCT_ENEMY); if( i > 0 && !(status_get_mode(bl)&MD_BOSS) ) { // knock-back any enemy except Boss skill_blown(&src->bl, bl, 2, unit_getdir(bl), 0); @@ -11730,12 +11722,12 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns * 3rd stuff **/ case UNT_POISONSMOKE: - if( battle_check_target(ss,bl,BCT_ENEMY) > 0 && !(tsc && tsc->data[sg->val2]) && rnd()%100 < 20 ) + if( battle->check_target(ss,bl,BCT_ENEMY) > 0 && !(tsc && tsc->data[sg->val2]) && rnd()%100 < 20 ) sc_start(bl,sg->val2,100,sg->val3,skill_get_time2(GC_POISONINGWEAPON, 1)); break; case UNT_EPICLESIS: - if( bl->type == BL_PC && !battle_check_undead(tstatus->race, tstatus->def_ele) && tstatus->race != RC_DEMON ) + if( bl->type == BL_PC && !battle->check_undead(tstatus->race, tstatus->def_ele) && tstatus->race != RC_DEMON ) { if( ++sg->val2 % 3 == 0 ) { int hp, sp; @@ -11758,7 +11750,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns } } /* Enable this if kRO fix the current skill. Currently no damage on undead and demon monster. [Jobbie] - else if( battle_check_target(ss, bl, BCT_ENEMY) > 0 && battle_check_undead(tstatus->race, tstatus->def_ele) ) + else if( battle->check_target(ss, bl, BCT_ENEMY) > 0 && battle_check_undead(tstatus->race, tstatus->def_ele) ) skill_castend_damage_id(&src->bl, bl, sg->skill_id, sg->skill_lv, 0, 0);*/ break; @@ -11784,11 +11776,11 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns break; case UNT_SEVERE_RAINSTORM: - if( battle_check_target(&src->bl, bl, BCT_ENEMY) ) + if( battle->check_target(&src->bl, bl, BCT_ENEMY) ) skill_attack(BF_WEAPON,ss,&src->bl,bl,WM_SEVERE_RAINSTORM_MELEE,sg->skill_lv,tick,0); break; case UNT_NETHERWORLD: - if( !(status_get_mode(bl)&MD_BOSS) && ss != bl && battle_check_target(&src->bl, bl, BCT_PARTY) ) { + if( !(status_get_mode(bl)&MD_BOSS) && ss != bl && battle->check_target(&src->bl, bl, BCT_PARTY) ) { if( !(tsc && tsc->data[type]) ){ sc_start(bl, type, 100, sg->skill_lv, skill_get_time2(sg->skill_id,sg->skill_lv)); sg->limit = DIFF_TICK(tick,sg->tick); @@ -11844,7 +11836,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns break; case UNT_HELLS_PLANT: - if( battle_check_target(&src->bl,bl,BCT_ENEMY) > 0 ) + if( battle->check_target(&src->bl,bl,BCT_ENEMY) > 0 ) skill_attack(skill_get_type(GN_HELLS_PLANT_ATK), ss, &src->bl, bl, GN_HELLS_PLANT_ATK, sg->skill_lv, tick, 0); if( ss != bl) //The caster is the only one who can step on the Plants, without destroying them sg->limit = DIFF_TICK(tick, sg->tick) + 100; @@ -11857,7 +11849,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns break; case UNT_WARMER: - if( bl->type == BL_PC && !battle_check_undead(tstatus->race, tstatus->def_ele) && tstatus->race != RC_DEMON ) { + if( bl->type == BL_PC && !battle->check_undead(tstatus->race, tstatus->def_ele) && tstatus->race != RC_DEMON ) { int hp = 125 * sg->skill_lv; // Officially is 125 * skill_lv. struct status_change *ssc = status_get_sc(ss); if( ssc && ssc->data[SC_HEATER_OPTION] ) @@ -11877,7 +11869,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns case UNT_EARTH_INSIGNIA: case UNT_ZEPHYR: sc_start(bl,type, 100, sg->skill_lv, sg->interval); - if (sg->unit_id != UNT_ZEPHYR && !battle_check_undead(tstatus->race, tstatus->def_ele)) { + if (sg->unit_id != UNT_ZEPHYR && !battle->check_undead(tstatus->race, tstatus->def_ele)) { int hp = tstatus->max_hp / 100; //+1% each 5s if ((sg->val3) % 5) { //each 5s if (tstatus->def_ele == skill_get_ele(sg->skill_id,sg->skill_lv)){ @@ -11925,7 +11917,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns break; case UNT_FIRE_MANTLE: - if( battle_check_target(&src->bl, bl, BCT_ENEMY) ) + if( battle->check_target(&src->bl, bl, BCT_ENEMY) ) skill_attack(BF_MAGIC,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick,0); break; @@ -11933,7 +11925,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns case UNT_ZENKAI_LAND: case UNT_ZENKAI_FIRE: case UNT_ZENKAI_WIND: - if( battle_check_target(&src->bl,bl,BCT_ENEMY) > 0 ){ + if( battle->check_target(&src->bl,bl,BCT_ENEMY) > 0 ){ switch( sg->unit_id ){ case UNT_ZENKAI_WATER: sc_start(bl, SC_CRYSTALIZE, sg->val1*5, sg->skill_lv, skill_get_time2(sg->skill_id, sg->skill_lv)); @@ -12172,7 +12164,7 @@ static int skill_unit_effect (struct block_list* bl, va_list ap) //Necessary in case the group is deleted after calling on_place/on_out [Skotlex] skill_id = group->skill_id; //Target-type check. - if( !(group->bl_flag&bl->type && battle_check_target(&unit->bl,bl,group->target_flag)>0) && (flag&4) ) { + if( !(group->bl_flag&bl->type && battle->check_target(&unit->bl,bl,group->target_flag)>0) && (flag&4) ) { if( group->state.song_dance&0x1 || (group->src_id == bl->id && group->state.song_dance&0x2) ) skill_unit_onleft(skill_id, bl, tick);//Ensemble check to terminate it. } else { @@ -14216,7 +14208,7 @@ void skill_repairweapon (struct map_session_data *sd, int idx) { if( item->nameid <= 0 || item->attribute == 0 ) return; //Again invalid item.... - if( sd != target_sd && !battle_check_range(&sd->bl,&target_sd->bl, skill_get_range2(&sd->bl, sd->menuskill_id,sd->menuskill_val2) ) ){ + if( sd != target_sd && !battle->check_range(&sd->bl,&target_sd->bl, skill_get_range2(&sd->bl, sd->menuskill_id,sd->menuskill_val2) ) ){ clif_item_repaireffect(sd,idx,1); return; } @@ -14500,9 +14492,9 @@ int skill_frostjoke_scream (struct block_list *bl, va_list ap) return 0;//Frost Joke / Scream cannot target invisible or MADO Gear characters [Ind] } //It has been reported that Scream/Joke works the same regardless of woe-setting. [Skotlex] - if(battle_check_target(src,bl,BCT_ENEMY) > 0) + if(battle->check_target(src,bl,BCT_ENEMY) > 0) skill_additional_effect(src,bl,skill_id,skill_lv,BF_MISC,ATK_DEF,tick); - else if(battle_check_target(src,bl,BCT_PARTY) > 0 && rnd()%100 < 10) + else if(battle->check_target(src,bl,BCT_PARTY) > 0 && rnd()%100 < 10) skill_additional_effect(src,bl,skill_id,skill_lv,BF_MISC,ATK_DEF,tick); return 0; @@ -14546,7 +14538,7 @@ int skill_attack_area (struct block_list *bl, va_list ap) if (skill_area_temp[1] == bl->id) //This is the target of the skill, do a full attack and skip target checks. return skill_attack(atk_type,src,dsrc,bl,skill_id,skill_lv,tick,flag); - if(battle_check_target(dsrc,bl,type) <= 0 || + if(battle->check_target(dsrc,bl,type) <= 0 || !status_check_skilluse(NULL, bl, skill_id, 2)) return 0; @@ -14854,7 +14846,7 @@ static int skill_trap_splash (struct block_list *bl, va_list ap) nullpo_ret(sg = unit->group); nullpo_ret(ss = map_id2bl(sg->src_id)); - if(battle_check_target(src,bl,sg->target_flag) <= 0) + if(battle->check_target(src,bl,sg->target_flag) <= 0) return 0; switch(sg->unit_id){ @@ -15322,7 +15314,7 @@ int skill_delunitgroup_(struct skill_unit_group *group, const char* file, int li } if (src->type==BL_PC && group->state.ammo_consume) - battle_consume_ammo((TBL_PC*)src, group->skill_id, group->skill_lv); + battle->consume_ammo((TBL_PC*)src, group->skill_id, group->skill_lv); group->alive_count=0; @@ -15432,7 +15424,7 @@ int skill_unit_timer_sub_onplace (struct block_list* bl, va_list ap) if( !(skill_get_inf2(group->skill_id)&(INF2_SONG_DANCE|INF2_TRAP|INF2_NOLP)) && map_getcell(bl->m, bl->x, bl->y, CELL_CHKLANDPROTECTOR) ) return 0; //AoE skills are ineffective. [Skotlex] - if( battle_check_target(&unit->bl,bl,group->target_flag) <= 0 ) + if( battle->check_target(&unit->bl,bl,group->target_flag) <= 0 ) return 0; skill_unit_onplace_timer(unit,bl,tick); @@ -15714,7 +15706,7 @@ int skill_unit_move_sub (struct block_list* bl, va_list ap) } //Target-type check. - if( !(group->bl_flag&target->type && battle_check_target(&unit->bl,target,group->target_flag) > 0) ) + if( !(group->bl_flag&target->type && battle->check_target(&unit->bl,target,group->target_flag) > 0) ) { if( group->src_id == target->id && group->state.song_dance&0x2 ) { //Ensemble check to see if they went out/in of the area [Skotlex] diff --git a/src/map/status.c b/src/map/status.c index 01f3fda1e..2f4b11e13 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1752,9 +1752,9 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin case BL_HOM: case BL_MER: case BL_ELEM: - if( target->type == BL_HOM && skill_id && battle_config.hom_setting&0x1 && skill_get_inf(skill_id)&INF_SUPPORT_SKILL && battle_get_master(target) != src ) + if( target->type == BL_HOM && skill_id && battle_config.hom_setting&0x1 && skill_get_inf(skill_id)&INF_SUPPORT_SKILL && battle->get_master(target) != src ) return 0; // Can't use support skills on Homunculus (only Master/Self) - if( target->type == BL_MER && (skill_id == PR_ASPERSIO || (skill_id >= SA_FLAMELAUNCHER && skill_id <= SA_SEISMICWEAPON)) && battle_get_master(target) != src ) + if( target->type == BL_MER && (skill_id == PR_ASPERSIO || (skill_id >= SA_FLAMELAUNCHER && skill_id <= SA_SEISMICWEAPON)) && battle->get_master(target) != src ) return 0; // Can't use Weapon endow skills on Mercenary (only Master) if( skill_id == AM_POTIONPITCHER && ( target->type == BL_MER || target->type == BL_ELEM) ) return 0; // Can't use Potion Pitcher on Mercenaries @@ -6516,7 +6516,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val if( !tick ) return 0; } - undead_flag = battle_check_undead(status->race,status->def_ele); + undead_flag = battle->check_undead(status->race,status->def_ele); //Check for inmunities / sc fails switch (type) { case SC_ANGRIFFS_MODUS: @@ -10571,7 +10571,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) case SC_STONE_SHIELD: case SC_SOLID_SKIN: if( !status_charge(bl,0,sce->val2) ){ - struct block_list *s_bl = battle_get_master(bl); + struct block_list *s_bl = battle->get_master(bl); if( s_bl ) status_change_end(s_bl,type+1,INVALID_TIMER); status_change_end(bl,type,INVALID_TIMER); @@ -10668,7 +10668,7 @@ int status_change_timer_sub(struct block_list* bl, va_list ap) status_change_end(bl, SC_CAMOUFLAGE, INVALID_TIMER); status_change_end(bl, SC_CLOAKINGEXCEED, INVALID_TIMER); status_change_end(bl, SC__INVISIBILITY, INVALID_TIMER); - if(battle_check_target( src, bl, BCT_ENEMY ) > 0) + if(battle->check_target( src, bl, BCT_ENEMY ) > 0) skill_attack(BF_MAGIC,src,src,bl,AL_RUWACH,1,tick,0); } if( tsc && tsc->data[SC__SHADOWFORM] && (sce && sce->val4 >0 && sce->val4%2000 == 0) && // for every 2 seconds do the checking @@ -10676,7 +10676,7 @@ int status_change_timer_sub(struct block_list* bl, va_list ap) status_change_end(bl, SC__SHADOWFORM, INVALID_TIMER); break; case SC_SIGHTBLASTER: - if (battle_check_target( src, bl, BCT_ENEMY ) > 0 && + if (battle->check_target( src, bl, BCT_ENEMY ) > 0 && status_check_skilluse(src, bl, WZ_SIGHTBLASTER, 2)) { if (sce && !(bl->type&BL_SKILL) //The hit is not counted if it's against a trap diff --git a/src/map/unit.c b/src/map/unit.c index b1ca64d4c..b2d4f569a 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1092,7 +1092,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui case HLIF_AVOID: case HAMI_DEFENCE: case HAMI_CASTLE: - target = battle_get_master(src); + target = battle->get_master(src); if (!target) return 0; target_id = target->id; } @@ -1141,7 +1141,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui sd->skill_id_old = skill_id; break; case WL_WHITEIMPRISON: - if( battle_check_target(src,target,BCT_SELF|BCT_ENEMY) < 0 ) { + if( battle->check_target(src,target,BCT_SELF|BCT_ENEMY) < 0 ) { clif_skill_fail(sd,skill_id,USESKILL_FAIL_TOTARGET,0); return 0; } @@ -1179,9 +1179,9 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui if( !unit_can_reach_bl(src, target, range + 1, 1, NULL, NULL) ) return 0; // Walk-path check failed. } else if( src->type == BL_MER && skill_id == MA_REMOVETRAP ) { - if( !battle_check_range(battle_get_master(src), target, range + 1) ) + if( !battle->check_range(battle->get_master(src), target, range + 1) ) return 0; // Aegis calc remove trap based on Master position, ignoring mercenary O.O - } else if( !battle_check_range(src, target, range + (skill_id == RG_CLOSECONFINE?0:2)) ) { + } else if( !battle->check_range(src, target, range + (skill_id == RG_CLOSECONFINE?0:2)) ) { return 0; // Arrow-path check failed. } } @@ -1198,7 +1198,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui switch(skill_id){ case ALL_RESURRECTION: - if(battle_check_undead(tstatus->race,tstatus->def_ele)) { + if(battle->check_undead(tstatus->race,tstatus->def_ele)) { temp = 1; } else if (!status_isdead(target)) return 0; //Can't cast on non-dead characters. @@ -1262,7 +1262,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui case EL_WATER_SCREW: case EL_TIDAL_WEAPON: if( src->type == BL_ELEM ){ - sd = BL_CAST(BL_PC, battle_get_master(src)); + sd = BL_CAST(BL_PC, battle->get_master(src)); if( sd && sd->skill_id_old == SO_EL_ACTION ){ casttime = -1; sd->skill_id_old = 0; @@ -1294,7 +1294,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui TBL_MOB *md = (TBL_MOB*)target; mobskill_event(md, src, tick, -1); //Cast targetted skill event. if (tstatus->mode&(MD_CASTSENSOR_IDLE|MD_CASTSENSOR_CHASE) && - battle_check_target(target, src, BCT_ENEMY) > 0) + battle->check_target(target, src, BCT_ENEMY) > 0) { switch (md->state.skillstate) { case MSS_RUSH: @@ -1437,7 +1437,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui if( !unit_can_reach_bl(src, &bl, range + 1, 1, NULL, NULL) ) return 0; //Walk-path check failed. } - else if( !battle_check_range(src, &bl, range + 1) ) + else if( !battle->check_range(src, &bl, range + 1) ) return 0; //Arrow-path check failed. unit_stop_attack(src); @@ -1580,7 +1580,7 @@ int unit_attack(struct block_list *src,int target_id,int continuous) return 0; } } - if( battle_check_target(src,target,BCT_ENEMY) <= 0 || !status_check_skilluse(src, target, 0, 0) ) { + if( battle->check_target(src,target,BCT_ENEMY) <= 0 || !status_check_skilluse(src, target, 0, 0) ) { unit_unattackable(src); return 1; } @@ -1765,7 +1765,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t return 0; if( status_isdead(src) || status_isdead(target) || - battle_check_target(src,target,BCT_ENEMY) <= 0 || !status_check_skilluse(src, target, 0, 0) + battle->check_target(src,target,BCT_ENEMY) <= 0 || !status_check_skilluse(src, target, 0, 0) #ifdef OFFICIAL_WALKPATH || !path_search_long(NULL, src->m, src->x, src->y, target->x, target->y, CELL_CHKWALL) #endif @@ -1811,7 +1811,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t unit_walktobl(src,target,ud->chaserange,ud->state.walk_easy|2); return 1; } - if( !battle_check_range(src,target,range) ) { + if( !battle->check_range(src,target,range) ) { //Within range, but no direct line of attack if( ud->state.attack_continue ) { if(ud->chaserange > 2) ud->chaserange-=2; @@ -1843,7 +1843,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t return 1; map_freeblock_lock(); - ud->attacktarget_lv = battle_weapon_attack(src,target,tick,0); + ud->attacktarget_lv = battle->weapon_attack(src,target,tick,0); if(sd && sd->status.pet_id > 0 && sd->pd && battle_config.pet_attack_support) pet_target_check(sd,target,0); |