From 70985ed3d6898d8a5f34757485679843e9febbef Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Wed, 18 Oct 2023 06:29:53 -0500 Subject: [PATCH] Fixed and more accurate Ruin abilities (#3415) --- src/battle_util.c | 26 ++++++++++++++------------ test/battle/ability/beads_of_ruin.c | 2 +- test/battle/ability/sword_of_ruin.c | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 0dee43787299..3486b6a3b320 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -9022,18 +9022,6 @@ static inline u32 CalcMoveBasePowerAfterModifiers(u32 move, u32 battlerAtk, u32 modifier = uq4_12_multiply(modifier, UQ_4_12(1.33)); } - if (IsAbilityOnField(ABILITY_VESSEL_OF_RUIN) && atkAbility != ABILITY_VESSEL_OF_RUIN && IS_MOVE_SPECIAL(gCurrentMove)) - modifier = uq4_12_multiply(modifier, UQ_4_12(0.75)); - - if (IsAbilityOnField(ABILITY_SWORD_OF_RUIN) && defAbility != ABILITY_SWORD_OF_RUIN && IS_MOVE_PHYSICAL(gCurrentMove)) - modifier = uq4_12_multiply(modifier, UQ_4_12(1.25)); - - if (IsAbilityOnField(ABILITY_TABLETS_OF_RUIN) && atkAbility != ABILITY_TABLETS_OF_RUIN && IS_MOVE_PHYSICAL(gCurrentMove)) - modifier = uq4_12_multiply(modifier, UQ_4_12(0.75)); - - if (IsAbilityOnField(ABILITY_BEADS_OF_RUIN) && defAbility != ABILITY_BEADS_OF_RUIN && IS_MOVE_SPECIAL(gCurrentMove)) - modifier = uq4_12_multiply(modifier, UQ_4_12(1.25)); - // attacker partner's abilities if (IsBattlerAlive(BATTLE_PARTNER(battlerAtk))) { @@ -9322,6 +9310,13 @@ static inline u32 CalcAttackStat(u32 move, u32 battlerAtk, u32 battlerDef, u32 m } } + // field abilities + if (IsAbilityOnField(ABILITY_VESSEL_OF_RUIN) && atkAbility != ABILITY_VESSEL_OF_RUIN && IS_MOVE_SPECIAL(move)) + modifier = uq4_12_multiply_half_down(modifier, UQ_4_12(0.75)); + + if (IsAbilityOnField(ABILITY_TABLETS_OF_RUIN) && atkAbility != ABILITY_TABLETS_OF_RUIN && IS_MOVE_PHYSICAL(move)) + modifier = uq4_12_multiply_half_down(modifier, UQ_4_12(0.75)); + // attacker's hold effect switch (holdEffectAtk) { @@ -9471,6 +9466,13 @@ static inline u32 CalcDefenseStat(u32 move, u32 battlerAtk, u32 battlerDef, u32 } } + // field abilities + if (IsAbilityOnField(ABILITY_SWORD_OF_RUIN) && defAbility != ABILITY_SWORD_OF_RUIN && usesDefStat) + modifier = uq4_12_multiply_half_down(modifier, UQ_4_12(0.75)); + + if (IsAbilityOnField(ABILITY_BEADS_OF_RUIN) && defAbility != ABILITY_BEADS_OF_RUIN && !usesDefStat) + modifier = uq4_12_multiply_half_down(modifier, UQ_4_12(0.75)); + // target's hold effects switch (holdEffectDef) { diff --git a/test/battle/ability/beads_of_ruin.c b/test/battle/ability/beads_of_ruin.c index 1c6f740e8b11..b406a9ecf38c 100644 --- a/test/battle/ability/beads_of_ruin.c +++ b/test/battle/ability/beads_of_ruin.c @@ -25,7 +25,7 @@ SINGLE_BATTLE_TEST("Beads of Ruin reduces Sp. Def", s16 damage) } HP_BAR(opponent, captureDamage: &results[i].damage); } FINALLY { - EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.25), results[1].damage); + EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.33), results[1].damage); } } diff --git a/test/battle/ability/sword_of_ruin.c b/test/battle/ability/sword_of_ruin.c index 2abc0c04f730..35ba4f6e0d50 100644 --- a/test/battle/ability/sword_of_ruin.c +++ b/test/battle/ability/sword_of_ruin.c @@ -25,7 +25,7 @@ SINGLE_BATTLE_TEST("Sword of Ruin reduces Defense", s16 damage) } HP_BAR(opponent, captureDamage: &results[i].damage); } FINALLY { - EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.25), results[1].damage); + EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.33), results[1].damage); } }