summaryrefslogtreecommitdiff
path: root/src/map/battle.c
diff options
context:
space:
mode:
authorultramage <umage@netvor.sk>2016-01-21 13:57:27 +0100
committerultramage <umage@netvor.sk>2016-01-21 13:57:27 +0100
commit04d15f03e28b9f8b0ed9ffa2d3c0c6ef6625363a (patch)
treeb61a3a414aafb1e047ed339f4b28a67b33bd7477 /src/map/battle.c
parent0ed2d09e9aa88af01698707fd701363bdbd92b4b (diff)
downloadhercules-04d15f03e28b9f8b0ed9ffa2d3c0c6ef6625363a.tar.gz
hercules-04d15f03e28b9f8b0ed9ffa2d3c0c6ef6625363a.tar.bz2
hercules-04d15f03e28b9f8b0ed9ffa2d3c0c6ef6625363a.tar.xz
hercules-04d15f03e28b9f8b0ed9ffa2d3c0c6ef6625363a.zip
Add top-level s_sd variable to battle_calc_damage() to represent a player source of damage.
This cleans up the various badly-named duplicates that have accumulated in local scopes over time. The unusual name, s_sd (with underscore), was chosen to prevent interaction with any existing custom code.
Diffstat (limited to 'src/map/battle.c')
-rw-r--r--src/map/battle.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index 44adef051..d76a7a76c 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -2717,7 +2717,7 @@ 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 map_session_data *s_sd, *sd = NULL;
struct status_change *sc, *tsc;
struct status_change_entry *sce;
int div_, flag;
@@ -2725,6 +2725,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
nullpo_ret(bl);
nullpo_ret(d);
+ s_sd = BL_CAST(BL_PC, src);
sd = BL_CAST(BL_PC, bl);
div_ = d->div_;
flag = d->flag;
@@ -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 && sd && sc->data[SC_COLD] && flag&BF_WEAPON ){
+ switch(s_sd->status.weapon){
case W_MACE:
case W_2HMACE:
case W_1HAXE:
@@ -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);
@@ -3259,9 +3258,8 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
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 (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 */
@@ -3312,9 +3310,8 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
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;
}