summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2016-02-29 00:22:23 +0100
committerHaru <haru@dotalux.com>2016-02-29 00:22:23 +0100
commit844d429119e671f8abbdb335233eba1bb156721c (patch)
treeeb15d4f98ad85c609adb803c96c71043fc6d0924
parent37fefe0d863f74a8229dd57c72a6cef6c1071730 (diff)
parente820b348bada58b7d57ab4fd800c536aecf52eac (diff)
downloadhercules-844d429119e671f8abbdb335233eba1bb156721c.tar.gz
hercules-844d429119e671f8abbdb335233eba1bb156721c.tar.bz2
hercules-844d429119e671f8abbdb335233eba1bb156721c.tar.xz
hercules-844d429119e671f8abbdb335233eba1bb156721c.zip
Merge pull request #1115 from theultramage/bcdrenaming
more meaningful variable names in battle_calc_damage()
-rw-r--r--src/map/battle.c87
1 files changed, 42 insertions, 45 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index cb1541f66..a7a6f4719 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -2717,15 +2717,16 @@ void battle_calc_skillratio_weapon_unknown(int *attack_type, struct block_list *
* After this we apply bg/gvg reduction
*------------------------------------------*/
int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damage *d,int64 damage,uint16 skill_id,uint16 skill_lv) {
- struct map_session_data *sd = NULL;
- struct status_change *sc, *tsc;
+ struct map_session_data *s_sd, *t_sd;
+ struct status_change *s_sc, *sc;
struct status_change_entry *sce;
int div_, flag;
nullpo_ret(bl);
nullpo_ret(d);
- sd = BL_CAST(BL_PC, bl);
+ s_sd = BL_CAST(BL_PC, src);
+ t_sd = BL_CAST(BL_PC, bl);
div_ = d->div_;
flag = d->flag;
@@ -2735,22 +2736,22 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
return 0;
if( battle_config.ksprotection && mob->ksprotected(src, bl) )
return 0;
- if (sd != NULL) {
+ if (t_sd != NULL) {
//Special no damage states
- if(flag&BF_WEAPON && sd->special_state.no_weapon_damage)
- damage -= damage * sd->special_state.no_weapon_damage / 100;
+ if(flag&BF_WEAPON && t_sd->special_state.no_weapon_damage)
+ damage -= damage * t_sd->special_state.no_weapon_damage / 100;
- if(flag&BF_MAGIC && sd->special_state.no_magic_damage)
- damage -= damage * sd->special_state.no_magic_damage / 100;
+ if(flag&BF_MAGIC && t_sd->special_state.no_magic_damage)
+ damage -= damage * t_sd->special_state.no_magic_damage / 100;
- if(flag&BF_MISC && sd->special_state.no_misc_damage)
- damage -= damage * sd->special_state.no_misc_damage / 100;
+ if(flag&BF_MISC && t_sd->special_state.no_misc_damage)
+ damage -= damage * t_sd->special_state.no_misc_damage / 100;
if(!damage) return 0;
}
+ s_sc = status->get_sc(src);
sc = status->get_sc(bl);
- tsc = status->get_sc(src);
if( sc && sc->data[SC_INVINCIBLE] && !sc->data[SC_INVINCIBLEOFF] )
return 1;
@@ -2838,7 +2839,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
}
if( sc->data[SC__MAELSTROM] && (flag&BF_MAGIC) && skill_id && (skill->get_inf(skill_id)&INF_GROUND_SKILL) ) {
// {(Maelstrom Skill LevelxAbsorbed Skill Level)+(Caster's Job/5)}/2
- int sp = (sc->data[SC__MAELSTROM]->val1 * skill_lv + (sd ? sd->status.job_level / 5 : 0)) / 2;
+ int sp = (sc->data[SC__MAELSTROM]->val1 * skill_lv + (t_sd ? t_sd->status.job_level / 5 : 0)) / 2;
status->heal(bl, 0, sp, 3);
d->dmg_lv = ATK_BLOCK;
return 0;
@@ -2916,7 +2917,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
if(sc->data[SC_DODGE_READY] && ( !sc->opt1 || sc->opt1 == OPT1_BURNING ) &&
(flag&BF_LONG || sc->data[SC_STRUP])
&& rnd()%100 < 20) {
- if (sd && pc_issit(sd)) pc->setstand(sd); //Stand it to dodge.
+ if (t_sd && pc_issit(t_sd)) pc->setstand(t_sd); //Stand it to dodge.
clif->skill_nodamage(bl,bl,TK_DODGE,1,1);
if (!sc->data[SC_COMBOATTACK])
sc_start4(src, bl, SC_COMBOATTACK, 100, TK_JUMPKICK, src->id, 1, 0, 2000);
@@ -2987,13 +2988,12 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
#endif
if( damage ) {
- struct map_session_data *tsd = BL_CAST(BL_PC, src);
if( sc->data[SC_DEEP_SLEEP] ) {
damage += damage / 2; // 1.5 times more damage while in Deep Sleep.
status_change_end(bl,SC_DEEP_SLEEP,INVALID_TIMER);
}
- if( tsd && sd && sc->data[SC_COLD] && flag&BF_WEAPON ){
- switch(tsd->status.weapon){
+ if( s_sd && t_sd && sc->data[SC_COLD] && flag&BF_WEAPON ){
+ switch(s_sd->status.weapon){
case W_MACE:
case W_2HMACE:
case W_1HAXE:
@@ -3002,7 +3002,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
break;
case W_MUSICAL:
case W_WHIP:
- if(!sd->state.arrow_atk)
+ if(!t_sd->state.arrow_atk)
break;
case W_BOW:
case W_REVOLVER:
@@ -3131,8 +3131,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
if( (sce = sc->data[SC_STONEHARDSKIN]) && flag&(BF_SHORT|BF_WEAPON) && damage > 0 ) {
sce->val2 -= (int)cap_value(damage,INT_MIN,INT_MAX);
if( src->type == BL_PC ) {
- struct map_session_data *ssd = BL_CAST(BL_PC, src);
- if (ssd && ssd->status.weapon != W_BOW)
+ if (s_sd && s_sd->status.weapon != W_BOW)
skill->break_equip(src, EQP_WEAPON, 3000, BCT_SELF);
} else
skill->break_equip(src, EQP_WEAPON, 3000, BCT_SELF);
@@ -3209,31 +3208,31 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
if( sc->data[SC__DEADLYINFECT] && flag&BF_SHORT && damage > 0 && rnd()%100 < 30 + 10 * sc->data[SC__DEADLYINFECT]->val1 && !is_boss(src) )
status->change_spread(bl, src); // Deadly infect attacked side
- if (sd && damage > 0 && (sce = sc->data[SC_GENTLETOUCH_ENERGYGAIN]) != NULL) {
+ if (t_sd && damage > 0 && (sce = sc->data[SC_GENTLETOUCH_ENERGYGAIN]) != NULL) {
if ( rnd() % 100 < sce->val2 )
- pc->addspiritball(sd, skill->get_time(MO_CALLSPIRITS, 1), pc->getmaxspiritball(sd, 0));
+ pc->addspiritball(t_sd, skill->get_time(MO_CALLSPIRITS, 1), pc->getmaxspiritball(t_sd, 0));
}
}
//SC effects from caster side.
- if (tsc && tsc->count) {
- if( tsc->data[SC_INVINCIBLE] && !tsc->data[SC_INVINCIBLEOFF] )
+ if (s_sc && s_sc->count) {
+ if( s_sc->data[SC_INVINCIBLE] && !s_sc->data[SC_INVINCIBLEOFF] )
damage += damage * 75 / 100;
// [Epoque]
if (bl->type == BL_MOB) {
const struct mob_data *md = BL_UCCAST(BL_MOB, bl);
int i;
- if (((sce=tsc->data[SC_MANU_ATK]) != NULL && (flag&BF_WEAPON))
- || ((sce=tsc->data[SC_MANU_MATK]) != NULL && (flag&BF_MAGIC))) {
+ if (((sce=s_sc->data[SC_MANU_ATK]) != NULL && (flag&BF_WEAPON))
+ || ((sce=s_sc->data[SC_MANU_MATK]) != NULL && (flag&BF_MAGIC))) {
for (i = 0; i < ARRAYLENGTH(mob->manuk); i++)
if (md->class_ == mob->manuk[i]) {
damage += damage * sce->val1 / 100;
break;
}
}
- if (((sce=tsc->data[SC_SPL_ATK]) != NULL && (flag&BF_WEAPON))
- || ((sce=tsc->data[SC_SPL_MATK]) != NULL && (flag&BF_MAGIC))) {
+ if (((sce=s_sc->data[SC_SPL_ATK]) != NULL && (flag&BF_WEAPON))
+ || ((sce=s_sc->data[SC_SPL_MATK]) != NULL && (flag&BF_MAGIC))) {
for (i = 0; i < ARRAYLENGTH(mob->splendide); i++)
if (md->class_ == mob->splendide[i]) {
damage += damage * sce->val1 / 100;
@@ -3241,31 +3240,30 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
}
}
}
- if( tsc->data[SC_POISONINGWEAPON] ) {
+ if( s_sc->data[SC_POISONINGWEAPON] ) {
struct status_data *tstatus = status->get_status_data(bl);
- if ( !(flag&BF_SKILL) && (flag&BF_WEAPON) && damage > 0 && rnd()%100 < tsc->data[SC_POISONINGWEAPON]->val3 ) {
+ if ( !(flag&BF_SKILL) && (flag&BF_WEAPON) && damage > 0 && rnd()%100 < s_sc->data[SC_POISONINGWEAPON]->val3 ) {
short rate = 100;
- if ( tsc->data[SC_POISONINGWEAPON]->val1 == 9 ) // Oblivion Curse gives a 2nd success chance after the 1st one passes which is reducible. [Rytech]
+ if ( s_sc->data[SC_POISONINGWEAPON]->val1 == 9 ) // Oblivion Curse gives a 2nd success chance after the 1st one passes which is reducible. [Rytech]
rate = 100 - tstatus->int_ * 4 / 5;
- sc_start(src,bl,tsc->data[SC_POISONINGWEAPON]->val2,rate,tsc->data[SC_POISONINGWEAPON]->val1,skill->get_time2(GC_POISONINGWEAPON,1) - (tstatus->vit + tstatus->luk) / 2 * 1000);
+ sc_start(src,bl,s_sc->data[SC_POISONINGWEAPON]->val2,rate,s_sc->data[SC_POISONINGWEAPON]->val1,skill->get_time2(GC_POISONINGWEAPON,1) - (tstatus->vit + tstatus->luk) / 2 * 1000);
}
}
- if( tsc->data[SC__DEADLYINFECT] && flag&BF_SHORT && damage > 0 && rnd()%100 < 30 + 10 * tsc->data[SC__DEADLYINFECT]->val1 && !is_boss(src) )
+ if( s_sc->data[SC__DEADLYINFECT] && flag&BF_SHORT && damage > 0 && rnd()%100 < 30 + 10 * s_sc->data[SC__DEADLYINFECT]->val1 && !is_boss(src) )
status->change_spread(src, bl);
- if (tsc->data[SC_SHIELDSPELL_REF] && tsc->data[SC_SHIELDSPELL_REF]->val1 == 1 && damage > 0)
+ if (s_sc->data[SC_SHIELDSPELL_REF] && s_sc->data[SC_SHIELDSPELL_REF]->val1 == 1 && damage > 0)
skill->break_equip(bl,EQP_ARMOR,10000,BCT_ENEMY );
- if (tsc->data[SC_STYLE_CHANGE] && rnd()%2) {
+ if (s_sc->data[SC_STYLE_CHANGE] && rnd()%2) {
struct homun_data *hd = BL_CAST(BL_HOM,bl);
if (hd) homun->addspiritball(hd, 10);
}
- if (src->type == BL_PC && damage > 0 && (sce = tsc->data[SC_GENTLETOUCH_ENERGYGAIN]) != NULL) {
- struct map_session_data *tsd = BL_UCAST(BL_PC, src);
- if (tsd != NULL && rnd() % 100 < sce->val2)
- pc->addspiritball(tsd, skill->get_time(MO_CALLSPIRITS, 1), pc->getmaxspiritball(tsd, 0));
+ if (src->type == BL_PC && damage > 0 && (sce = s_sc->data[SC_GENTLETOUCH_ENERGYGAIN]) != NULL) {
+ if (s_sd != NULL && rnd() % 100 < sce->val2)
+ pc->addspiritball(s_sd, skill->get_time(MO_CALLSPIRITS, 1), pc->getmaxspiritball(s_sd, 0));
}
}
/* no data claims these settings affect anything other than players */
- if( damage && sd && bl->type == BL_PC ) {
+ if( damage && t_sd && bl->type == BL_PC ) {
switch( skill_id ) {
//case PA_PRESSURE: /* pressure also belongs to this list but it doesn't reach this area -- so don't worry about it */
case HW_GRAVITATION:
@@ -3307,14 +3305,13 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
if (skill_id)
mob->skill_event(md, src, timer->gettick(), MSC_SKILLUSED|(skill_id<<16));
}
- if (sd && pc_ismadogear(sd) && rnd()%100 < 50) {
+ if (t_sd && pc_ismadogear(t_sd) && rnd()%100 < 50) {
int element = -1;
if (!skill_id || (element = skill->get_ele(skill_id, skill_lv)) == -1) {
// Take weapon's element
struct status_data *sstatus = NULL;
- struct map_session_data *ssd = BL_CAST(BL_PC, src);
- if (src->type == BL_PC && ssd->bonus.arrow_ele != 0) {
- element = ssd->bonus.arrow_ele;
+ if (s_sd != NULL && s_sd->bonus.arrow_ele != 0) {
+ element = s_sd->bonus.arrow_ele;
} else if ((sstatus = status->get_status_data(src)) != NULL) {
element = sstatus->rhw.ele;
}
@@ -3326,9 +3323,9 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
element = rnd()%ELE_MAX;
}
if (element == ELE_FIRE)
- pc->overheat(sd, 1);
+ pc->overheat(t_sd, 1);
else if (element == ELE_WATER)
- pc->overheat(sd, -1);
+ pc->overheat(t_sd, -1);
}
return damage;