diff options
author | shennetsind <ind@henn.et> | 2013-01-28 13:21:11 -0200 |
---|---|---|
committer | shennetsind <ind@henn.et> | 2013-01-28 13:21:11 -0200 |
commit | 5bc48c6e9eb26ed30016ec2c4911a84837fd73fc (patch) | |
tree | 1f4ebf498d7415a420cc224da5851e3ab699d7bf /src/map/battle.c | |
parent | 0af9e036d582113f861f845995fa971751dc9df1 (diff) | |
download | hercules-5bc48c6e9eb26ed30016ec2c4911a84837fd73fc.tar.gz hercules-5bc48c6e9eb26ed30016ec2c4911a84837fd73fc.tar.bz2 hercules-5bc48c6e9eb26ed30016ec2c4911a84837fd73fc.tar.xz hercules-5bc48c6e9eb26ed30016ec2c4911a84837fd73fc.zip |
Performance Improvement on Battle/Damage
Dropping MarkZD's INT64 megalomania, his usage of int64 was completely unnecessary and was only taking additional processing time and spawning twice the amount of bytes it actually needed. Also dropping the poorly designed DAMAGE_ macros.
Updating battle.c header to outline Hercules as made by Jman.
Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/map/battle.c')
-rw-r--r-- | src/map/battle.c | 197 |
1 files changed, 93 insertions, 104 deletions
diff --git a/src/map/battle.c b/src/map/battle.c index 487cf4854..d04eb1aa8 100644 --- a/src/map/battle.c +++ b/src/map/battle.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 team #include "../common/cbasetypes.h" #include "../common/timer.h" @@ -40,9 +41,6 @@ int attr_fix_table[4][ELE_MAX][ELE_MAX]; struct Battle_Config battle_config; static struct eri *delay_damage_ers; //For battle delay damage structures. -#define DAMAGE_RATE(a){damage = (int64)damage * (a)/100;} -#define DAMAGE_SUBRATE(a){damage -= (int64)damage * (a)/100;} -#define DAMAGE_ADDRATE(a){damage += (int64)damage * (a)/100;} int battle_getcurrentskill(struct block_list *bl) { //Returns the current/last skill in use by this bl. struct unit_data *ud; @@ -366,7 +364,7 @@ int battle_attr_fix(struct block_list *src, struct block_list *target, int damag if( tsc->data[SC_THORNSTRAP]) status_change_end(target, SC_THORNSTRAP, INVALID_TIMER); if( tsc->data[SC_FIRE_CLOAK_OPTION]) - DAMAGE_SUBRATE(tsc->data[SC_FIRE_CLOAK_OPTION]->val2) + damage -= damage * tsc->data[SC_FIRE_CLOAK_OPTION]->val2 / 100; if( tsc->data[SC_CRYSTALIZE] && target->type != BL_MOB) status_change_end(target, SC_CRYSTALIZE, INVALID_TIMER); if( tsc->data[SC_EARTH_INSIGNIA]) damage += damage/2; @@ -406,9 +404,9 @@ int battle_attr_fix(struct block_list *src, struct block_list *target, int damag ARR_FIND(1, 6, t, tsd->talisman[t] > 0); if( t < 5 && atk_elem == t ) - DAMAGE_SUBRATE(tsd->talisman[t] * 3) // -3% custom value + damage -= damage * ( tsd->talisman[t] * 3 ) / 100;// -3% custom value } - return (int64)damage*ratio/100; + return damage*ratio/100; } /*========================================== @@ -431,7 +429,6 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li tstatus = status_get_status_data(target); s_race2 = status_get_race2(src); -#define bccDAMAGE_RATE(a){ damage = (int64)damage * (a)/1000;} switch(attack_type){ case BF_MAGIC: if ( sd && !(nk&NK_NO_CARDFIX_ATK) ) { @@ -448,7 +445,7 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li } } if (cardfix != 1000) - bccDAMAGE_RATE(cardfix) + damage = damage * cardfix / 1000; } if( tsd && !(nk&NK_NO_CARDFIX_DEF) ) @@ -492,7 +489,7 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li cardfix = cardfix * ( 100 - tsd->sc.data[SC_MDEF_RATE]->val1 ) / 100; if (cardfix != 1000) - bccDAMAGE_RATE(cardfix) + damage = damage * cardfix / 1000; } break; case BF_WEAPON: @@ -626,9 +623,9 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li } #endif if( (left&1) && cardfix_ != 1000 ) - bccDAMAGE_RATE(cardfix_) + damage = damage * cardfix / 1000; else if( cardfix != 1000 ) - bccDAMAGE_RATE(cardfix) + damage = damage * cardfix / 1000; }else if( tsd && !(nk&NK_NO_CARDFIX_DEF) ){ if( !(nk&NK_NO_ELEFIX) ) @@ -682,7 +679,7 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li cardfix = cardfix * ( 100 - tsd->sc.data[SC_DEF_RATE]->val1 ) / 100; if( cardfix != 1000 ) - bccDAMAGE_RATE(cardfix) + damage = damage * cardfix / 1000; } break; case BF_MISC: @@ -716,7 +713,7 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li cardfix = cardfix * ( 100 - tsd->bonus.long_attack_def_rate ) / 100; if (cardfix != 10000) - bccDAMAGE_RATE(cardfix) + damage = damage * cardfix / 1000; } break; } @@ -747,13 +744,13 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag sd=(struct map_session_data *)bl; //Special no damage states if(flag&BF_WEAPON && sd->special_state.no_weapon_damage) - DAMAGE_SUBRATE(sd->special_state.no_weapon_damage) + damage -= damage * sd->special_state.no_weapon_damage / 100; if(flag&BF_MAGIC && sd->special_state.no_magic_damage) - DAMAGE_SUBRATE(sd->special_state.no_magic_damage) + damage -= damage * sd->special_state.no_magic_damage / 100; if(flag&BF_MISC && sd->special_state.no_misc_damage) - DAMAGE_SUBRATE(sd->special_state.no_misc_damage) + damage -= damage * sd->special_state.no_misc_damage / 100; if(!damage) return 0; } @@ -947,9 +944,8 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag } #ifdef RENEWAL - if( sc->data[SC_RAID] ) - { - DAMAGE_ADDRATE(20) + if( sc->data[SC_RAID] ) { + damage += damage * 20 / 100; if (--sc->data[SC_RAID]->val1 == 0) status_change_end(bl, SC_RAID, INVALID_TIMER); @@ -968,7 +964,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag case W_2HMACE: case W_1HAXE: case W_2HAXE: - DAMAGE_RATE(150) + damage = damage * 150/100; break; case W_MUSICAL: case W_WHIP: @@ -983,7 +979,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag case W_DAGGER: case W_1HSWORD: case W_2HSWORD: - DAMAGE_RATE(50) + damage = damage * 50/100; break; } } @@ -997,7 +993,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag #ifndef RENEWAL if( sc->data[SC_ASSUMPTIO] ) { if( map_flag_vs(bl->m) ) - damage = (int64)damage*2/3; //Receive 66% damage + damage = damage*2/3; //Receive 66% damage else damage >>= 1; //Receive 50% damage } @@ -1005,15 +1001,15 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag if(sc->data[SC_DEFENDER] && (flag&(BF_LONG|BF_WEAPON)) == (BF_LONG|BF_WEAPON)) - DAMAGE_RATE(100-sc->data[SC_DEFENDER]->val2) + damage = damage * ( 100 - sc->data[SC_DEFENDER]->val2 ) / 100; if(sc->data[SC_ADJUSTMENT] && (flag&(BF_LONG|BF_WEAPON)) == (BF_LONG|BF_WEAPON)) - DAMAGE_SUBRATE(20) + damage -= damage * 20 / 100; if(sc->data[SC_FOGWALL] && skill_id != RK_DRAGONBREATH) { if(flag&BF_SKILL) //25% reduction - DAMAGE_SUBRATE(25) + damage -= damage * 25 / 100; else if ((flag&(BF_LONG|BF_WEAPON)) == (BF_LONG|BF_WEAPON)) damage >>= 2; //75% reduction } @@ -1024,20 +1020,20 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag if (sc->data[SC_MANU_DEF]) for (i=0;ARRAYLENGTH(mob_manuk)>i;i++) if (mob_manuk[i]==((TBL_MOB*)src)->class_) { - DAMAGE_SUBRATE(sc->data[SC_MANU_DEF]->val1) + damage -= damage * sc->data[SC_MANU_DEF]->val1 / 100; break; } if (sc->data[SC_SPL_DEF]) for (i=0;ARRAYLENGTH(mob_splendide)>i;i++) if (mob_splendide[i]==((TBL_MOB*)src)->class_) { - DAMAGE_SUBRATE(sc->data[SC_SPL_DEF]->val1) + damage -= damage * sc->data[SC_SPL_DEF]->val1 / 100; break; } } if((sce=sc->data[SC_ARMOR]) && //NPC_DEFENDER sce->val3&flag && sce->val4&flag) - DAMAGE_SUBRATE(sc->data[SC_ARMOR]->val2) + damage -= damage * sc->data[SC_ARMOR]->val2 / 100; #ifdef RENEWAL if(sc->data[SC_ENERGYCOAT] && (flag&BF_WEAPON || flag&BF_MAGIC) && skill_id != WS_CARTTERMINATION) @@ -1052,13 +1048,13 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag if (!status_charge(bl, 0, (10+5*per)*status->max_sp/1000)) status_change_end(bl, SC_ENERGYCOAT, INVALID_TIMER); //Reduction: 6% + 6% every 20% - DAMAGE_SUBRATE(6 * (1+per)) + damage -= damage * (6 * (1+per)) / 100; } if(sc->data[SC_GRANITIC_ARMOR]){ - DAMAGE_SUBRATE(sc->data[SC_GRANITIC_ARMOR]->val2) + damage -= damage * sc->data[SC_GRANITIC_ARMOR]->val2 / 100; } if(sc->data[SC_PAIN_KILLER]){ - DAMAGE_SUBRATE(sc->data[SC_PAIN_KILLER]->val3) + damage -= damage * sc->data[SC_PAIN_KILLER]->val3 / 100; } if((sce=sc->data[SC_MAGMA_FLOW]) && (rnd()%100 <= sce->val2) ){ skill_castend_damage_id(bl,src,MH_MAGMA_FLOW,sce->val1,gettick(),0); @@ -1117,7 +1113,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag //(since battle_drain is strictly for players currently) if ((sce=sc->data[SC_BLOODLUST]) && flag&BF_WEAPON && damage > 0 && rnd()%100 < sce->val3) - status_heal(src, (int64)damage*sce->val4/100, 0, 3); + status_heal(src, damage*sce->val4/100, 0, 3); if( sd && (sce = sc->data[SC_FORCEOFVANGUARD]) && flag&BF_WEAPON && rnd()%100 < sce->val2 ) pc_addspiritball(sd,skill_get_time(LG_FORCEOFVANGUARD,sce->val1),sce->val3); @@ -1154,13 +1150,11 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag //SC effects from caster side. sc = status_get_sc(src); - if (sc && sc->count) - { + if (sc && sc->count) { if( sc->data[SC_INVINCIBLE] && !sc->data[SC_INVINCIBLEOFF] ) - DAMAGE_ADDRATE(75) + damage += damage * 75 / 100; // [Epoque] - if (bl->type == BL_MOB) - { + if (bl->type == BL_MOB) { int i; if ( ((sce=sc->data[SC_MANU_ATK]) && (flag&BF_WEAPON)) || @@ -1168,7 +1162,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag ) for (i=0;ARRAYLENGTH(mob_manuk)>i;i++) if (((TBL_MOB*)bl)->class_==mob_manuk[i]) { - DAMAGE_ADDRATE(sce->val1) + damage += damage * sce->val1 / 100; break; } if ( ((sce=sc->data[SC_SPL_ATK]) && (flag&BF_WEAPON)) || @@ -1176,7 +1170,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag ) for (i=0;ARRAYLENGTH(mob_splendide)>i;i++) if (((TBL_MOB*)bl)->class_==mob_splendide[i]) { - DAMAGE_ADDRATE(sce->val1) + damage += damage * sce->val1 / 100; break; } } @@ -1194,16 +1188,16 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag { if (flag & BF_SKILL) { //Skills get a different reduction than non-skills. [Skotlex] if (flag&BF_WEAPON) - DAMAGE_RATE(battle_config.pk_weapon_damage_rate) + damage = damage * battle_config.pk_weapon_damage_rate / 100; if (flag&BF_MAGIC) - DAMAGE_RATE(battle_config.pk_magic_damage_rate) + damage = damage * battle_config.pk_magic_damage_rate / 100; if (flag&BF_MISC) - DAMAGE_RATE(battle_config.pk_misc_damage_rate) + damage = damage * battle_config.pk_misc_damage_rate / 100; } else { //Normal attacks get reductions based on range. if (flag & BF_SHORT) - DAMAGE_RATE(battle_config.pk_short_damage_rate) + damage = damage * battle_config.pk_short_damage_rate / 100; if (flag & BF_LONG) - DAMAGE_RATE(battle_config.pk_long_damage_rate) + damage = damage * battle_config.pk_long_damage_rate / 100; } if(!damage) damage = 1; } @@ -1254,39 +1248,36 @@ int battle_calc_bg_damage(struct block_list *src, struct block_list *bl, int dam if( !damage ) return 0; - if( bl->type == BL_MOB ) - { + if( bl->type == BL_MOB ) { struct mob_data* md = BL_CAST(BL_MOB, bl); + if( map[bl->m].flag.battleground && (md->class_ == MOBID_BLUE_CRYST || md->class_ == MOBID_PINK_CRYST) && flag&BF_SKILL ) return 0; // Crystal cannot receive skill damage on battlegrounds } - switch( skill_id ) - { + switch( skill_id ) { case PA_PRESSURE: case HW_GRAVITATION: case NJ_ZENYNAGE: case KO_MUCHANAGE: break; default: - if( flag&BF_SKILL ) - { //Skills get a different reduction than non-skills. [Skotlex] + if( flag&BF_SKILL ) { //Skills get a different reduction than non-skills. [Skotlex] if( flag&BF_WEAPON ) - DAMAGE_RATE(battle_config.bg_weapon_damage_rate) + damage = damage * battle_config.bg_weapon_damage_rate / 100; if( flag&BF_MAGIC ) - DAMAGE_RATE(battle_config.bg_magic_damage_rate) + damage = damage * battle_config.bg_magic_damage_rate / 100; if( flag&BF_MISC ) - DAMAGE_RATE(battle_config.bg_misc_damage_rate) - } - else - { //Normal attacks get reductions based on range. + damage = damage * battle_config.bg_misc_damage_rate / 100; + } else { //Normal attacks get reductions based on range. if( flag&BF_SHORT ) - DAMAGE_RATE(battle_config.bg_short_damage_rate) + damage = damage * battle_config.bg_short_damage_rate / 100; if( flag&BF_LONG ) - DAMAGE_RATE(battle_config.bg_long_damage_rate) + damage = damage * battle_config.bg_long_damage_rate / 100; } - if( !damage ) damage = 1; + if( !damage ) + damage = 1; } return damage; @@ -1342,16 +1333,16 @@ int battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int dama */ if (flag & BF_SKILL) { //Skills get a different reduction than non-skills. [Skotlex] if (flag&BF_WEAPON) - DAMAGE_RATE(battle_config.gvg_weapon_damage_rate) + damage = damage * battle_config.gvg_weapon_damage_rate / 100; if (flag&BF_MAGIC) - DAMAGE_RATE(battle_config.gvg_magic_damage_rate) + damage = damage * battle_config.gvg_magic_damage_rate / 100; if (flag&BF_MISC) - DAMAGE_RATE(battle_config.gvg_misc_damage_rate) + damage = damage * battle_config.gvg_misc_damage_rate / 100; } else { //Normal attacks get reductions based on range. if (flag & BF_SHORT) - DAMAGE_RATE(battle_config.gvg_short_damage_rate) + damage = damage * battle_config.gvg_short_damage_rate / 100; if (flag & BF_LONG) - DAMAGE_RATE(battle_config.gvg_long_damage_rate) + damage = damage * battle_config.gvg_long_damage_rate / 100; } if(!damage) damage = 1; } @@ -1366,7 +1357,7 @@ static int battle_calc_drain(int damage, int rate, int per) int diff = 0; if (per && rnd()%1000 < rate) { - diff = ((int64)damage * per) / 100; + diff = (damage * per) / 100; if (diff == 0) { if (per > 0) diff = 1; @@ -1553,9 +1544,7 @@ static int battle_calc_base_damage(struct status_data *status, struct weapon_atk //SizeFix only for players if (!(sd->special_state.no_sizefix || (flag&8))) - DAMAGE_RATE(type==EQI_HAND_L? - sd->left_weapon.atkmods[t_size]: - sd->right_weapon.atkmods[t_size]) + damage = damage * ( type == EQI_HAND_L ? sd->left_weapon.atkmods[t_size] : sd->right_weapon.atkmods[t_size] ) / 100; } //Finally, add baseatk @@ -1571,12 +1560,12 @@ static int battle_calc_base_damage(struct status_data *status, struct weapon_atk if(sd->left_weapon.overrefine) damage += rnd()%sd->left_weapon.overrefine+1; if (sd->weapon_atk_rate[sd->weapontype2]) - DAMAGE_ADDRATE(sd->weapon_atk_rate[sd->weapontype2]) + damage += damage * sd->weapon_atk_rate[sd->weapontype2] / 100; } else { //Right hand if(sd->right_weapon.overrefine) damage += rnd()%sd->right_weapon.overrefine+1; if (sd->weapon_atk_rate[sd->weapontype1]) - DAMAGE_ADDRATE(sd->weapon_atk_rate[sd->weapontype1]) + damage += damage * sd->weapon_atk_rate[sd->weapontype1] / 100; } } return damage; @@ -2064,8 +2053,8 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo //ATK_RATE scales the damage. 100 = no change. 50 is halved, 200 is doubled, etc #define ATK_RATE( a ) { wd.damage= wd.damage*(a)/100 ; if(flag.lh) wd.damage2= wd.damage2*(a)/100; } #define ATK_RATE2( a , b ) { wd.damage= wd.damage*(a)/100 ; if(flag.lh) wd.damage2= wd.damage2*(b)/100; } -#define ATK_RATER(a){ wd.damage = (int64)wd.damage*(a)/100;} -#define ATK_RATEL(a){ wd.damage2 = (int64)wd.damage2*(a)/100;} +#define ATK_RATER(a){ wd.damage = wd.damage*(a)/100;} +#define ATK_RATEL(a){ wd.damage2 = wd.damage2*(a)/100;} //Adds dmg%. 100 = +100% (double) damage. 10 = +10% damage #define ATK_ADDRATE( a ) { wd.damage+= wd.damage*(a)/100 ; if(flag.lh) wd.damage2+= wd.damage2*(a)/100; } #define ATK_ADDRATE2( a , b ) { wd.damage+= wd.damage*(a)/100 ; if(flag.lh) wd.damage2+= wd.damage2*(b)/100; } @@ -2076,7 +2065,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo switch (skill_id) { //Calc base damage according to skill case PA_SACRIFICE: - wd.damage = (int64)sstatus->max_hp* 9/100; + wd.damage = sstatus->max_hp* 9/100; wd.damage2 = 0; break; #ifndef RENEWAL @@ -2787,11 +2776,11 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo break; case SR_TIGERCANNON:// ATK [((Caster consumed HP + SP) / 4) x Caster Base Level / 100] % { - int hp = (int64)sstatus->max_hp * (10 + 2 * skill_lv) / 100, - sp = (int64)sstatus->max_sp * (6 + skill_lv) / 100; - skillratio = ((int64)hp+sp) / 4; + int hp = sstatus->max_hp * (10 + 2 * skill_lv) / 100, + sp = sstatus->max_sp * (6 + skill_lv) / 100; + skillratio = (hp+sp) / 4; if( sc && sc->data[SC_COMBO] && sc->data[SC_COMBO]->val1 == SR_FALLENEMPIRE ) // ATK [((Caster consumed HP + SP) / 2) x Caster Base Level / 100] % - skillratio = (int64)hp+sp / 2; + skillratio = hp+sp / 2; RE_LVL_DMOD(100); } break; @@ -3008,9 +2997,9 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo case SR_GATEOFHELL: ATK_ADD (sstatus->max_hp - status_get_hp(src)); if(sc && sc->data[SC_COMBO] && sc->data[SC_COMBO]->val1 == SR_FALLENEMPIRE){ - ATK_ADD ( ((int64)sstatus->max_sp * (1 + skill_lv * 2 / 10)) + 40 * status_get_lv(src) ); + ATK_ADD ( (sstatus->max_sp * (1 + skill_lv * 2 / 10)) + 40 * status_get_lv(src) ); }else{ - ATK_ADD ( ((int64)sstatus->sp * (1 + skill_lv * 2 / 10)) + 10 * status_get_lv(src) ); + ATK_ADD ( (sstatus->sp * (1 + skill_lv * 2 / 10)) + 10 * status_get_lv(src) ); } break; case SR_TIGERCANNON: // (Tiger Cannon skill level x 240) + (Target Base Level x 40) @@ -3258,8 +3247,8 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo #else if (def1 > 100) def1 = 100; ATK_RATE2( - flag.idef ?100:(flag.pdef ? (int64)flag.pdef*(def1+vit_def) : (100-def1)), - flag.idef2?100:(flag.pdef2? (int64)flag.pdef2*(def1+vit_def) : (100-def1)) + flag.idef ?100:(flag.pdef ? flag.pdef*(def1+vit_def) : (100-def1)), + flag.idef2?100:(flag.pdef2? flag.pdef2*(def1+vit_def) : (100-def1)) ); ATK_ADD2( flag.idef ||flag.pdef ?0:-vit_def, @@ -3462,7 +3451,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo } } else if(sd->status.weapon == W_KATAR && !skill_id) { //Katars (offhand damage only applies to normal attacks, tested on Aegis 10.2) skill = pc_checkskill(sd,TF_DOUBLE); - wd.damage2 = (int64)wd.damage * (1 + (skill * 2))/100; + wd.damage2 = wd.damage * (1 + (skill * 2))/100; if(wd.damage && !wd.damage2) wd.damage2 = 1; flag.lh = 1; @@ -3501,7 +3490,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo 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.damage2 = (int64)d2*100/d1 * wd.damage/100; + wd.damage2 = d2*100/d1 * wd.damage/100; if(wd.damage > 1 && wd.damage2 < 1) wd.damage2 = 1; wd.damage-=wd.damage2; } @@ -3531,7 +3520,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo int hp= sstatus->max_hp; if (sd && tsd) { hp = 8*hp/100; - if (((int64)sstatus->hp * 100) <= ((int64)sstatus->max_hp * 20)) + if ((sstatus->hp * 100) <= (sstatus->max_hp * 20)) hp = sstatus->hp; } else hp = 2*hp/100; //2% hp loss per hit @@ -4086,7 +4075,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list if(sd) { //Damage bonuses if ((i = pc_skillatk_bonus(sd, skill_id))) - ad.damage += (int64)ad.damage*i/100; + ad.damage += ad.damage*i/100; //Ignore Defense? if (!flag.imdef && ( @@ -4289,7 +4278,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * damage_div_fix(md.damage, skill); //Falcon Assault Modifier - md.damage=(int64)md.damage*(150+70*skill_lv)/100; + md.damage=md.damage*(150+70*skill_lv)/100; } break; case TF_THROWSTONE: @@ -4318,7 +4307,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * break; case CR_ACIDDEMONSTRATION: // updated the formula based on a Japanese formula found to be exact [Reddozen] if(tstatus->vit+sstatus->int_) //crash fix - md.damage = (int)((int64)7*tstatus->vit*sstatus->int_*sstatus->int_ / (10*(tstatus->vit+sstatus->int_))); + md.damage = (int)(7*tstatus->vit*sstatus->int_*sstatus->int_ / (10*(tstatus->vit+sstatus->int_))); else md.damage = 0; if (tsd) md.damage>>=1; @@ -4341,7 +4330,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * md.damage = sd?sd->status.job_level:status_get_lv(src); break; case HVAN_EXPLOSION: //[orn] - md.damage = (int64)sstatus->max_hp * (50 + 50 * skill_lv) / 100; + md.damage = sstatus->max_hp * (50 + 50 * skill_lv) / 100; break ; case ASC_BREAKER: md.damage = 500+rnd()%500 + 5*skill_lv * sstatus->int_; @@ -4357,7 +4346,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * case RK_DRAGONBREATH: md.damage = ((status_get_hp(src) / 50) + (status_get_max_sp(src) / 4)) * skill_lv; RE_LVL_MDMOD(150); - if (sd) md.damage = (int64)md.damage * (100 + 5 * (pc_checkskill(sd,RK_DRAGONTRAINING) - 1)) / 100; + if (sd) md.damage = md.damage * (100 + 5 * (pc_checkskill(sd,RK_DRAGONTRAINING) - 1)) / 100; md.flag |= BF_LONG|BF_WEAPON; break; /** @@ -4372,11 +4361,11 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * { int researchskill_lv = pc_checkskill(sd,RA_RESEARCHTRAP); if(researchskill_lv) - md.damage = (int64)md.damage * 20 * researchskill_lv / (skill_id == RA_CLUSTERBOMB?50:100); + md.damage = md.damage * 20 * researchskill_lv / (skill_id == RA_CLUSTERBOMB?50:100); else md.damage = 0; }else - md.damage = (int64)md.damage * 200 / (skill_id == RA_CLUSTERBOMB?50:100); + md.damage = md.damage * 200 / (skill_id == RA_CLUSTERBOMB?50:100); break; /** @@ -4401,7 +4390,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * { 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 = (int64)wd.damage * 60 * (5 + skill_lv) / 100; + md.damage = wd.damage * 60 * (5 + skill_lv) / 100; md.damage -= totaldef; } break; @@ -4466,7 +4455,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); if (sd && (i = pc_skillatk_bonus(sd, skill_id))) - md.damage += (int64)md.damage*i/100; + md.damage += md.damage*i/100; if(md.damage < 0) md.damage = 0; @@ -4557,14 +4546,14 @@ int battle_calc_return_damage(struct block_list* bl, struct block_list *src, int sc = status_get_sc(bl); if( sc && sc->data[SC_REFLECTDAMAGE] ) { - int max_damage = (int64)status_get_max_hp(bl) * status_get_lv(bl) / 100; - rdamage = (int64)(*dmg) * sc->data[SC_REFLECTDAMAGE]->val2 / 100; + int max_damage = status_get_max_hp(bl) * status_get_lv(bl) / 100; + rdamage = (*dmg) * sc->data[SC_REFLECTDAMAGE]->val2 / 100; if( rdamage > max_damage ) rdamage = max_damage; }else if( sc && sc->data[SC_CRESCENTELBOW] && !is_boss(src) && rnd()%100 < sc->data[SC_CRESCENTELBOW]->val2 ){ //ATK [{(Target HP / 100) x Skill Level} x Caster Base Level / 125] % + [Received damage x {1 + (Skill Level x 0.2)}] - int ratio = (int64)(status_get_hp(src) / 100) * sc->data[SC_CRESCENTELBOW]->val1 * status_get_lv(bl) / 125; + int ratio = (status_get_hp(src) / 100) * sc->data[SC_CRESCENTELBOW]->val1 * status_get_lv(bl) / 125; if (ratio > 5000) ratio = 5000; // Maximum of 5000% ATK - rdamage = (int64)rdamage * ratio / 100 + (*dmg) * (10 + sc->data[SC_CRESCENTELBOW]->val1 * 20 / 10) / 10; + rdamage = rdamage * ratio / 100 + (*dmg) * (10 + sc->data[SC_CRESCENTELBOW]->val1 * 20 / 10) / 10; skill_blown(bl, src, skill_get_blewcount(SR_CRESCENTELBOW_AUTOSPELL, sc->data[SC_CRESCENTELBOW]->val1), unit_getdir(src), 0); clif_skill_damage(bl, src, gettick(), status_get_amotion(src), 0, rdamage, 1, SR_CRESCENTELBOW_AUTOSPELL, sc->data[SC_CRESCENTELBOW]->val1, 6); // This is how official does @@ -4574,12 +4563,12 @@ int battle_calc_return_damage(struct block_list* bl, struct block_list *src, int return 0; // Just put here to minimize redundancy }else if (flag & BF_SHORT) {//Bounces back part of the damage. if ( sd && sd->bonus.short_weapon_damage_return ) { - rdamage += (int64)damage * sd->bonus.short_weapon_damage_return / 100; + rdamage += damage * sd->bonus.short_weapon_damage_return / 100; if(rdamage < 1) rdamage = 1; } if( sc && sc->count ) { if ( sc->data[SC_REFLECTSHIELD] && skill_id != WS_CARTTERMINATION ) { - rdamage += (int64)damage * sc->data[SC_REFLECTSHIELD]->val2 / 100; + rdamage += damage * sc->data[SC_REFLECTSHIELD]->val2 / 100; if (rdamage < 1) rdamage = 1; } if(sc->data[SC_DEATHBOUND] && skill_id != WS_CARTTERMINATION && !(src->type == BL_MOB && is_boss(src)) ) { @@ -4588,8 +4577,8 @@ int battle_calc_return_damage(struct block_list* bl, struct block_list *src, int int rd1 = 0; if( distance_bl(src,bl) <= 0 || !map_check_dir(dir,t_dir) ) { - rd1 = (int64)min(damage,status_get_max_hp(bl)) * sc->data[SC_DEATHBOUND]->val2 / 100; // Amplify damage. - *dmg = (int64)rd1 * 30 / 100; // Received damage = 30% of amplifly damage. + rd1 = min(damage,status_get_max_hp(bl)) * sc->data[SC_DEATHBOUND]->val2 / 100; // Amplify damage. + *dmg = rd1 * 30 / 100; // Received damage = 30% of amplifly damage. clif_skill_damage(src,bl,gettick(), status_get_amotion(src), 0, -30000, 1, RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1,6); status_change_end(bl,SC_DEATHBOUND,INVALID_TIMER); rdamage += rd1; @@ -4599,7 +4588,7 @@ int battle_calc_return_damage(struct block_list* bl, struct block_list *src, int } } else { if (sd && sd->bonus.long_weapon_damage_return) { - rdamage += (int64)damage * sd->bonus.long_weapon_damage_return / 100; + rdamage += damage * sd->bonus.long_weapon_damage_return / 100; if (rdamage < 1) rdamage = 1; } } |