summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-07-12 23:12:12 +0300
committerAndrei Karas <akaras@inbox.ru>2016-07-12 23:22:59 +0300
commitec700e101d420286caa149bd2858c3e159e55998 (patch)
treed0731b1158ffdb12eb2db23c762576cb37251792
parentddca9bf6efe551a7d7dbc3d12a7d638453defcd6 (diff)
downloadhercules-ec700e101d420286caa149bd2858c3e159e55998.tar.gz
hercules-ec700e101d420286caa149bd2858c3e159e55998.tar.bz2
hercules-ec700e101d420286caa149bd2858c3e159e55998.tar.xz
hercules-ec700e101d420286caa149bd2858c3e159e55998.zip
Extract some code from battle_calc_damage into battle_calc_pc_damage.
-rw-r--r--src/map/battle.c58
-rw-r--r--src/map/battle.h2
2 files changed, 36 insertions, 24 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index 6e8ff3ba9..879776871 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -3263,30 +3263,8 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
}
}
/* no data claims these settings affect anything other than players */
- 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:
- case NJ_ZENYNAGE:
- case KO_MUCHANAGE:
- break;
- default:
- if (flag & BF_SKILL) { //Skills get a different reduction than non-skills. [Skotlex]
- if (flag&BF_WEAPON)
- damage = damage * map->list[bl->m].weapon_damage_rate / 100;
- if (flag&BF_MAGIC)
- damage = damage * map->list[bl->m].magic_damage_rate / 100;
- if (flag&BF_MISC)
- damage = damage * map->list[bl->m].misc_damage_rate / 100;
- } else { //Normal attacks get reductions based on range.
- if (flag & BF_SHORT)
- damage = damage * map->list[bl->m].short_damage_rate / 100;
- if (flag & BF_LONG)
- damage = damage * map->list[bl->m].long_damage_rate / 100;
- }
- if(!damage) damage = 1;
- break;
- }
+ if (damage && t_sd && bl->type == BL_PC) {
+ damage = battle->calc_pc_damage(src, bl, d, damage, skill_id, skill_lv);
}
if(battle_config.skill_min_damage && damage > 0 && damage < div_)
@@ -3331,6 +3309,37 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
return damage;
}
+int64 battle_calc_pc_damage(struct block_list *src, struct block_list *bl, struct Damage *d, int64 damage, uint16 skill_id, uint16 skill_lv)
+{
+ int flag = d->flag;
+
+ 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:
+ case NJ_ZENYNAGE:
+ case KO_MUCHANAGE:
+ break;
+ default:
+ if (flag & BF_SKILL) { //Skills get a different reduction than non-skills. [Skotlex]
+ if (flag & BF_WEAPON)
+ damage = damage * map->list[bl->m].weapon_damage_rate / 100;
+ if (flag & BF_MAGIC)
+ damage = damage * map->list[bl->m].magic_damage_rate / 100;
+ if (flag & BF_MISC)
+ damage = damage * map->list[bl->m].misc_damage_rate / 100;
+ } else { //Normal attacks get reductions based on range.
+ if (flag & BF_SHORT)
+ damage = damage * map->list[bl->m].short_damage_rate / 100;
+ if (flag & BF_LONG)
+ damage = damage * map->list[bl->m].long_damage_rate / 100;
+ }
+ if (!damage)
+ damage = 1;
+ break;
+ }
+ return damage;
+}
+
/*==========================================
* Calculates BG related damage adjustments.
*------------------------------------------*/
@@ -7590,6 +7599,7 @@ void battle_defaults(void) {
battle->calc_attack = battle_calc_attack;
battle->calc_damage = battle_calc_damage;
+ battle->calc_pc_damage = battle_calc_pc_damage;
battle->calc_gvg_damage = battle_calc_gvg_damage;
battle->calc_bg_damage = battle_calc_bg_damage;
battle->weapon_attack = battle_weapon_attack;
diff --git a/src/map/battle.h b/src/map/battle.h
index 6fa600ada..cb15e3b90 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -587,6 +587,8 @@ struct battle_interface {
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 */
int64 (*calc_damage) (struct block_list *src, struct block_list *bl, struct Damage *d, int64 damage, uint16 skill_id, uint16 skill_lv);
+ /* pc special damage calculation */
+ int64 (*calc_pc_damage) (struct block_list *src, struct block_list *bl, struct Damage *d, int64 damage, uint16 skill_id, uint16 skill_lv);
/* gvg final damage calculation */
int64 (*calc_gvg_damage) (struct block_list *src, struct block_list *bl, int64 damage, int div_, uint16 skill_id, uint16 skill_lv, int flag);
/* battlegrounds final damage calculation */