Skip to content

Commit

Permalink
Updated/Simplified Damage Bonus Stacking (#8252)
Browse files Browse the repository at this point in the history
- Freezing Trap, Sand Attack, Gunslinger Mine, Flip Tatami and Excruciating Palm no longer are affected by +% dmg cards
- The skills that ignore +% dmg cards are now exactly those skills that also ignore EDP and the EDP/Magnum Break elemental damage bonus
- Non-players are now always affected by ATKpercent
- Simplified the code accordingly
- Fixes #8250
  • Loading branch information
Playtester committed Apr 14, 2024
1 parent d05e11a commit 089c305
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 36 deletions.
8 changes: 8 additions & 0 deletions db/pre-re/skill_db.yml
Expand Up @@ -4408,6 +4408,7 @@ Body:
TargetType: Ground
DamageFlags:
Splash: true
IgnoreAtkCard: true
Flags:
IsTrap: true
AlterRangeResearchTrap: true
Expand Down Expand Up @@ -5184,6 +5185,8 @@ Body:
MaxLevel: 1
Type: Weapon
TargetType: Attack
DamageFlags:
IgnoreAtkCard: true
Flags:
IsQuest: true
Range: 1
Expand Down Expand Up @@ -14295,6 +14298,7 @@ Body:
TargetType: Ground
DamageFlags:
Splash: true
IgnoreAtkCard: true
IgnoreFlee: true
Flags:
AlterRangeSnakeEye: true
Expand Down Expand Up @@ -14510,6 +14514,8 @@ Body:
MaxLevel: 5
Type: Weapon
TargetType: Self
DamageFlags:
IgnoreAtkCard: true
Hit: Single
HitCount: 1
Element: Weapon
Expand Down Expand Up @@ -17180,6 +17186,7 @@ Body:
TargetType: Attack
DamageFlags:
Splash: true
IgnoreAtkCard: true
Flags:
IsQuest: true
Range: -1
Expand Down Expand Up @@ -32584,6 +32591,7 @@ Body:
TargetType: Ground
DamageFlags:
Splash: true
IgnoreAtkCard: true
Flags:
IsTrap: true
AlterRangeResearchTrap: true
Expand Down
45 changes: 9 additions & 36 deletions src/map/battle.cpp
Expand Up @@ -3359,12 +3359,11 @@ static bool attack_ignores_def(struct Damage* wd, struct block_list *src, struct
/**
* This function lists which skills are unaffected by refine bonus, masteries, Star Crumbs and Spirit Spheres
* This function is also used to determine if atkpercent applies
* @param src: Source of the attack
* @param skill_id: Skill being used
* @param chk_flag: The bonus that is currently being checked for, see e_bonus_chk_flag
* @return true = bonus applies; false = bonus does not apply
*/
static bool battle_skill_stacks_masteries_vvs(struct block_list &src, uint16 skill_id, e_bonus_chk_flag chk_flag)
static bool battle_skill_stacks_masteries_vvs(uint16 skill_id, e_bonus_chk_flag chk_flag)
{
switch (skill_id) {
// PC skills that are unaffected
Expand All @@ -3389,33 +3388,7 @@ static bool battle_skill_stacks_masteries_vvs(struct block_list &src, uint16 ski
break;
case LK_SPIRALPIERCE:
// Spiral Pierce is influenced only by refine bonus and Star Crumbs for players
if (src.type == BL_PC && chk_flag != BCHK_REFINE && chk_flag != BCHK_STAR)
return false;
break;
}

return true;
}

/**
* This function lists which skills are unaffected by EDP and the elemental bonus from Magnum Break / EDP
* Unit skills (e.g. Bomb and Freezing Trap) are never affected.
* @param skill_id: Skill being used
* @return true = bonus applies; false = bonus does not apply
*/
static bool battle_skill_stacks_edp_element(uint16 skill_id)
{
switch (skill_id) {
case TF_SPRINKLESAND:
case AS_SPLASHER:
case ASC_METEORASSAULT:
case ASC_BREAKER:
case AS_VENOMKNIFE:
case AM_ACIDTERROR:
return false;
default:
//Unit skills
if (skill_get_unit_id(skill_id))
if (chk_flag != BCHK_REFINE && chk_flag != BCHK_STAR)
return false;
break;
}
Expand Down Expand Up @@ -3789,12 +3762,12 @@ static void battle_calc_element_damage(struct Damage* wd, struct block_list *src
// These mastery bonuses are non-elemental and should apply even if the attack misses
// They are still increased by the EDP/Magnum Break bonus damage (WATK_ELEMENT)
// In renewal these bonuses do not apply when the attack misses
if (sd && battle_skill_stacks_masteries_vvs(*src, skill_id, BCHK_STAR)) {
if (sd && battle_skill_stacks_masteries_vvs(skill_id, BCHK_STAR)) {
// Star Crumb bonus damage
ATK_ADD2(wd->damage, wd->damage2, sd->right_weapon.star, sd->left_weapon.star);
}
// Check if general mastery bonuses apply (above check is only for Star Crumb)
if (battle_skill_stacks_masteries_vvs(*src, skill_id, BCHK_ALL)) {
if (battle_skill_stacks_masteries_vvs(skill_id, BCHK_ALL)) {
// Spirit Sphere bonus damage
ATK_ADD(wd->damage, wd->damage2, battle_get_spiritball_damage(*wd, *src, skill_id));

Expand Down Expand Up @@ -3824,10 +3797,10 @@ static void battle_calc_element_damage(struct Damage* wd, struct block_list *src
}
}

// These bonuses do not apply to skills that ignore element, unit skills and skills that have their own base damage formula
// These bonuses do not apply to skills that ignore +% damage cards
// If damage was reduced below 0 and was not increased again to a positive value through mastery bonuses, these bonuses are ignored
// Any of these are only applied to your right hand weapon in pre-renewal
if (!nk[NK_IGNOREELEMENT] && (wd->damage > 0 || wd->damage2 > 0) && sc && battle_skill_stacks_edp_element(skill_id)) {
if (!nk[NK_IGNOREELEMENT] && !nk[NK_IGNOREATKCARD] && (wd->damage > 0 || wd->damage2 > 0) && sc) {

// EDP bonus damage
// This has to be applied after mastery bonuses but still before the elemental extra damage
Expand Down Expand Up @@ -3873,7 +3846,7 @@ static void battle_calc_attack_masteries(struct Damage* wd, struct block_list *s
}

// Check if mastery damage applies to current skill
if (sd && battle_skill_stacks_masteries_vvs(*src, skill_id, BCHK_ALL))
if (sd && battle_skill_stacks_masteries_vvs(skill_id, BCHK_ALL))
{ //Add mastery damage
uint16 skill;

Expand Down Expand Up @@ -4459,7 +4432,7 @@ static void battle_calc_multi_attack(struct Damage* wd, struct block_list *src,s
*/
static unsigned short battle_get_atkpercent(struct block_list& bl, uint16 skill_id, status_change& sc)
{
if (!battle_skill_stacks_masteries_vvs(bl, skill_id, BCHK_ALL))
if (bl.type == BL_PC && !battle_skill_stacks_masteries_vvs(skill_id, BCHK_ALL))
return 100;

int atkpercent = 100;
Expand Down Expand Up @@ -6709,7 +6682,7 @@ static void battle_calc_attack_post_defense(struct Damage* wd, struct block_list
#ifndef RENEWAL
//Refine bonus
if (sd) {
if (battle_skill_stacks_masteries_vvs(*src, skill_id, BCHK_REFINE)) {
if (battle_skill_stacks_masteries_vvs(skill_id, BCHK_REFINE)) {
ATK_ADD2(wd->damage, wd->damage2, sstatus->rhw.atk2, sstatus->lhw.atk2);
}
wd->basedamage += sstatus->rhw.atk2;
Expand Down

0 comments on commit 089c305

Please sign in to comment.