Adds a function to assist with PK damage

* Re-implement battle_calc_pk_damage to help determine when to adjust damage when PK mode is enabled.
* Implement INF2_IGNOREPKREDUCTION skill flag to make skills bypass the damage adjustments.
This commit is contained in:
aleos 2024-01-14 16:08:55 -05:00
parent 08068bf3a4
commit 31cc8c5115
5 changed files with 37 additions and 8 deletions

View File

@ -80,6 +80,7 @@ IsShadowSpell - Make skill available for SC_AUTOSHADOWSPELL.
IsChorus - Chorus skill.
IgnoreBgReduction - Ignore Battleground reduction.
IgnoreGvgReduction - Ignore GvG reduction.
IgnorePKReduction - Ignore PK reduction.
DisableNearNpc - Disable self/ground skills near NPC. In tandem with NoNearNpc node.
TargetTrap - Damage traps. If TargetType is Trap.
IgnoreLandProtector - Ignore SA_LANDPROTECTOR.

View File

@ -1574,8 +1574,8 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
#endif
case SP_SOULEXPLOSION:
// Adjust these based on any possible PK damage rates.
if (battle_config.pk_mode > 0 && src->type == BL_PC && bl->type == BL_PC && damage > 0 && map_getmapflag(bl->m, MF_PVP))
damage = battle_calc_zone_damage_rate(*bl, damage, flag);
if (battle_config.pk_mode > 0 && map_getmapflag(bl->m, MF_PVP))
damage = battle_calc_pk_damage(*src, *bl, damage, skill_id, flag);
return damage; //These skills bypass everything else.
}
@ -1584,8 +1584,8 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
// So can defense sphere's but what the heck is that??? [Rytech]
if (skill_id == SJ_NOVAEXPLOSING && !(tsc && (tsc->getSCE(SC_SAFETYWALL) || tsc->getSCE(SC_MILLENNIUMSHIELD)))) {
// Adjust this based on any possible PK damage rates.
if (battle_config.pk_mode > 0 && src->type == BL_PC && bl->type == BL_PC && damage > 0 && map_getmapflag(bl->m, MF_PVP))
damage = battle_calc_zone_damage_rate(*bl, damage, flag);
if (battle_config.pk_mode > 0 && map_getmapflag(bl->m, MF_PVP))
damage = battle_calc_pk_damage(*src, *bl, damage, skill_id, flag);
return damage;
}
@ -1944,8 +1944,8 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
} //End of caster SC_ check
//PK damage rates
if (battle_config.pk_mode > 0 && src->type == BL_PC && bl->type == BL_PC && damage > 0 && map_getmapflag(bl->m, MF_PVP))
damage = battle_calc_zone_damage_rate(*bl, damage, flag);
if (battle_config.pk_mode > 0 && map_getmapflag(bl->m, MF_PVP))
damage = battle_calc_pk_damage(*src, *bl, damage, skill_id, flag);
if(battle_config.skill_min_damage && damage > 0 && damage < div_) {
if ((flag&BF_WEAPON && battle_config.skill_min_damage&1)
@ -2098,6 +2098,31 @@ int64 battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int64
return i64max(battle_calc_zone_damage_rate(*bl, damage, flag), 1);
}
/**
* Calculates PK related damage adjustments (between players only).
* @param src: Source object
* @param bl: Target object
* @param damage: Damage being done
* @param skill_id: Skill used
* @param flag: Battle flag type
* @return Modified damage
*/
int64 battle_calc_pk_damage(block_list &src, block_list &bl, int64 damage, uint16 skill_id, int flag) {
if (damage == 0) // No reductions to make.
return 0;
if (battle_config.pk_mode == 0) // PK mode is disabled.
return damage;
if (skill_get_inf2(skill_id, INF2_IGNOREPKREDUCTION)) //Skills with no pk damage reduction.
return damage;
if (src.type == BL_PC && bl.type == BL_PC)
return i64max(battle_calc_zone_damage_rate(bl, damage, flag), 1);
else
return damage;
}
/**
* HP/SP drain calculation
* @param damage Damage inflicted to the enemy
@ -8878,8 +8903,8 @@ int64 battle_calc_return_damage(struct block_list* tbl, struct block_list *src,
rdamage = battle_calc_gvg_damage(src, tbl, rdamage, skill_id, flag);
else if (mapdata->getMapFlag(MF_BATTLEGROUND))
rdamage = battle_calc_bg_damage(src, tbl, rdamage, skill_id, flag);
else if (battle_config.pk_mode > 0 && src->type == BL_PC && tbl->type == BL_PC && damage > 0 && mapdata->getMapFlag(MF_PVP))
rdamage = battle_calc_zone_damage_rate(*tbl, damage, flag);
else if (battle_config.pk_mode > 0 && mapdata->getMapFlag(MF_PVP))
damage = battle_calc_pk_damage(*src, *tbl, damage, skill_id, flag);
// Skill damage adjustment
int skill_damage = battle_skill_damage(src, tbl, skill_id);

View File

@ -102,6 +102,7 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li
int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damage *d,int64 damage,uint16 skill_id,uint16 skill_lv);
int64 battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int64 damage,uint16 skill_id,int flag);
int64 battle_calc_bg_damage(struct block_list *src,struct block_list *bl,int64 damage,uint16 skill_id,int flag);
int64 battle_calc_pk_damage(block_list &src, block_list &bl, int64 damage, uint16 skill_id, int flag);
void battle_damage(struct block_list *src, struct block_list *target, int64 damage, t_tick delay, uint16 skill_lv, uint16 skill_id, enum damage_lv dmg_lv, unsigned short attack_type, bool additional_effects, t_tick tick, bool spdamage);
int battle_delay_damage (t_tick tick, int amotion, struct block_list *src, struct block_list *target, int attack_type, uint16 skill_id, uint16 skill_lv, int64 damage, enum damage_lv dmg_lv, t_tick ddelay, bool additional_effects, bool spdamage);

View File

@ -9837,6 +9837,7 @@
export_constant(INF2_SHOWSCALE);
export_constant(INF2_IGNOREGTB);
export_constant(INF2_TOGGLEABLE);
export_constant(INF2_IGNOREPKREDUCTION);
/* skill no near npc flags */
export_constant(SKILL_NONEAR_WARPPORTAL);

View File

@ -110,6 +110,7 @@ enum e_skill_inf2 : uint8 {
INF2_SHOWSCALE, // Skill shows AoE area while casting
INF2_IGNOREGTB, // Skill ignores effect of GTB
INF2_TOGGLEABLE, // Skill can be toggled on and off (won't consume HP/SP when toggled off)
INF2_IGNOREPKREDUCTION, // Skill that ignore pk reduction
INF2_MAX,
};