From da9b421ae1df86345dc3bb7f5e1ea82b13e35c76 Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Tue, 25 Jul 2023 09:59:26 +0200 Subject: [PATCH] Fix Ruin ability calcs (#3171) --- src/battle_util.c | 8 ++--- test/ability_beads_of_ruin.c | 53 ++++++++++++++++++++++++++++++++++ test/ability_sword_of_ruin.c | 53 ++++++++++++++++++++++++++++++++++ test/ability_tablets_of_ruin.c | 53 ++++++++++++++++++++++++++++++++++ test/ability_vessel_of_ruin.c | 53 ++++++++++++++++++++++++++++++++++ 5 files changed, 216 insertions(+), 4 deletions(-) create mode 100644 test/ability_beads_of_ruin.c create mode 100644 test/ability_sword_of_ruin.c create mode 100644 test/ability_tablets_of_ruin.c create mode 100644 test/ability_vessel_of_ruin.c diff --git a/src/battle_util.c b/src/battle_util.c index 0a2a99447..d549b71b9 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -8908,16 +8908,16 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe } if (IsAbilityOnField(ABILITY_VESSEL_OF_RUIN) && atkAbility != ABILITY_VESSEL_OF_RUIN && IS_MOVE_SPECIAL(gCurrentMove)) - MulModifier(&modifier, UQ_4_12(0.25)); + MulModifier(&modifier, UQ_4_12(0.75)); if (IsAbilityOnField(ABILITY_SWORD_OF_RUIN) && defAbility != ABILITY_SWORD_OF_RUIN && IS_MOVE_PHYSICAL(gCurrentMove)) - MulModifier(&modifier, UQ_4_12(0.25)); + MulModifier(&modifier, UQ_4_12(1.25)); if (IsAbilityOnField(ABILITY_TABLETS_OF_RUIN) && atkAbility != ABILITY_TABLETS_OF_RUIN && IS_MOVE_PHYSICAL(gCurrentMove)) - MulModifier(&modifier, UQ_4_12(0.25)); + MulModifier(&modifier, UQ_4_12(0.75)); if (IsAbilityOnField(ABILITY_BEADS_OF_RUIN) && defAbility != ABILITY_BEADS_OF_RUIN && IS_MOVE_SPECIAL(gCurrentMove)) - MulModifier(&modifier, UQ_4_12(0.25)); + MulModifier(&modifier, UQ_4_12(1.25)); // attacker partner's abilities if (IsBattlerAlive(BATTLE_PARTNER(battlerAtk))) diff --git a/test/ability_beads_of_ruin.c b/test/ability_beads_of_ruin.c new file mode 100644 index 000000000..28b39a430 --- /dev/null +++ b/test/ability_beads_of_ruin.c @@ -0,0 +1,53 @@ +#include "global.h" +#include "test_battle.h" + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_WATER_GUN].split == SPLIT_SPECIAL); +} + +SINGLE_BATTLE_TEST("Beads of Ruin reduces Sp. Def", s16 damage) +{ + u32 ability; + + PARAMETRIZE { ability = ABILITY_SHADOW_TAG; } + PARAMETRIZE { ability = ABILITY_BEADS_OF_RUIN; } + + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { Ability(ability); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_WATER_GUN); } + } SCENE { + if (ability == ABILITY_BEADS_OF_RUIN) { + ABILITY_POPUP(player, ABILITY_BEADS_OF_RUIN); + MESSAGE("Wobbuffet's Beads of Ruin weakened the Sp. Def of all surrounding Pokémon!"); + } + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.25), results[1].damage); + } +} + +SINGLE_BATTLE_TEST("Beads of Ruin does not reduce Sp. Def if opposing mon has the same ability", s16 damage) +{ + u32 ability; + + PARAMETRIZE { ability = ABILITY_SHADOW_TAG; } + PARAMETRIZE { ability = ABILITY_BEADS_OF_RUIN; } + + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { Ability(ability); } + OPPONENT(SPECIES_WOBBUFFET) { Ability(ABILITY_BEADS_OF_RUIN); } + } WHEN { + TURN { MOVE(player, MOVE_WATER_GUN); } + } SCENE { + if (ability == ABILITY_BEADS_OF_RUIN) { + ABILITY_POPUP(player, ABILITY_BEADS_OF_RUIN); + MESSAGE("Wobbuffet's Beads of Ruin weakened the Sp. Def of all surrounding Pokémon!"); + } + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_EQ(results[0].damage, results[1].damage); + } +} diff --git a/test/ability_sword_of_ruin.c b/test/ability_sword_of_ruin.c new file mode 100644 index 000000000..6ec4f8fe8 --- /dev/null +++ b/test/ability_sword_of_ruin.c @@ -0,0 +1,53 @@ +#include "global.h" +#include "test_battle.h" + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_TACKLE].split == SPLIT_PHYSICAL); +} + +SINGLE_BATTLE_TEST("Sword of Ruin reduces Defense", s16 damage) +{ + u32 ability; + + PARAMETRIZE { ability = ABILITY_SHADOW_TAG; } + PARAMETRIZE { ability = ABILITY_SWORD_OF_RUIN; } + + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { Ability(ability); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_TACKLE); } + } SCENE { + if (ability == ABILITY_SWORD_OF_RUIN) { + ABILITY_POPUP(player, ABILITY_SWORD_OF_RUIN); + MESSAGE("Wobbuffet's Sword of Ruin weakened the Defense of all surrounding Pokémon!"); + } + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.25), results[1].damage); + } +} + +SINGLE_BATTLE_TEST("Sword of Ruin does not reduce Defense if opposing mon has the same ability", s16 damage) +{ + u32 ability; + + PARAMETRIZE { ability = ABILITY_SHADOW_TAG; } + PARAMETRIZE { ability = ABILITY_SWORD_OF_RUIN; } + + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { Ability(ability); } + OPPONENT(SPECIES_WOBBUFFET) { Ability(ABILITY_SWORD_OF_RUIN); } + } WHEN { + TURN { MOVE(player, MOVE_TACKLE); } + } SCENE { + if (ability == ABILITY_SWORD_OF_RUIN) { + ABILITY_POPUP(player, ABILITY_SWORD_OF_RUIN); + MESSAGE("Wobbuffet's Sword of Ruin weakened the Defense of all surrounding Pokémon!"); + } + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_EQ(results[0].damage, results[1].damage); + } +} diff --git a/test/ability_tablets_of_ruin.c b/test/ability_tablets_of_ruin.c new file mode 100644 index 000000000..38dcfc856 --- /dev/null +++ b/test/ability_tablets_of_ruin.c @@ -0,0 +1,53 @@ +#include "global.h" +#include "test_battle.h" + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_TACKLE].split == SPLIT_PHYSICAL); +} + +SINGLE_BATTLE_TEST("Tablets of Ruin reduces Attack", s16 damage) +{ + u32 ability; + + PARAMETRIZE { ability = ABILITY_SHADOW_TAG; } + PARAMETRIZE { ability = ABILITY_TABLETS_OF_RUIN; } + + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { Ability(ability); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponent, MOVE_TACKLE); } + } SCENE { + if (ability == ABILITY_TABLETS_OF_RUIN) { + ABILITY_POPUP(player, ABILITY_TABLETS_OF_RUIN); + MESSAGE("Wobbuffet's Tablets of Ruin weakened the Attack of all surrounding Pokémon!"); + } + HP_BAR(player, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(0.75), results[1].damage); + } +} + +SINGLE_BATTLE_TEST("Tablets of Ruin does not reduce Attack if an opposing mon has the same ability", s16 damage) +{ + u32 ability; + + PARAMETRIZE { ability = ABILITY_SHADOW_TAG; } + PARAMETRIZE { ability = ABILITY_TABLETS_OF_RUIN; } + + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { Ability(ability); } + OPPONENT(SPECIES_WOBBUFFET) { Ability(ABILITY_TABLETS_OF_RUIN); } + } WHEN { + TURN { MOVE(opponent, MOVE_TACKLE); } + } SCENE { + if (ability == ABILITY_TABLETS_OF_RUIN) { + ABILITY_POPUP(player, ABILITY_TABLETS_OF_RUIN); + MESSAGE("Wobbuffet's Tablets of Ruin weakened the Attack of all surrounding Pokémon!"); + } + HP_BAR(player, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_EQ(results[0].damage, results[1].damage); + } +} diff --git a/test/ability_vessel_of_ruin.c b/test/ability_vessel_of_ruin.c new file mode 100644 index 000000000..6c7b2664f --- /dev/null +++ b/test/ability_vessel_of_ruin.c @@ -0,0 +1,53 @@ +#include "global.h" +#include "test_battle.h" + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_WATER_GUN].split == SPLIT_SPECIAL); +} + +SINGLE_BATTLE_TEST("Vessel of Ruin reduces Sp. Atk", s16 damage) +{ + u32 ability; + + PARAMETRIZE { ability = ABILITY_SHADOW_TAG; } + PARAMETRIZE { ability = ABILITY_VESSEL_OF_RUIN; } + + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { Ability(ability); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponent, MOVE_WATER_GUN); } + } SCENE { + if (ability == ABILITY_VESSEL_OF_RUIN) { + ABILITY_POPUP(player, ABILITY_VESSEL_OF_RUIN); + MESSAGE("Wobbuffet's Vessel of Ruin weakened the Sp. Atk of all surrounding Pokémon!"); + } + HP_BAR(player, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(0.75), results[1].damage); + } +} + +SINGLE_BATTLE_TEST("Vessel of Ruin does not reduce Sp. Atk if opposing mon has the same ability", s16 damage) +{ + u32 ability; + + PARAMETRIZE { ability = ABILITY_SHADOW_TAG; } + PARAMETRIZE { ability = ABILITY_VESSEL_OF_RUIN; } + + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { Ability(ability); } + OPPONENT(SPECIES_WOBBUFFET) { Ability(ABILITY_VESSEL_OF_RUIN); } + } WHEN { + TURN { MOVE(opponent, MOVE_WATER_GUN); } + } SCENE { + if (ability == ABILITY_VESSEL_OF_RUIN) { + ABILITY_POPUP(player, ABILITY_VESSEL_OF_RUIN); + MESSAGE("Wobbuffet's Vessel of Ruin weakened the Sp. Atk of all surrounding Pokémon!"); + } + HP_BAR(player, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_EQ(results[0].damage, results[1].damage); + } +}