From 03eda5749d06e0dc7368f10904a2204b10d73585 Mon Sep 17 00:00:00 2001 From: Pawkkie <61265402+Pawkkie@users.noreply.github.com> Date: Tue, 22 Oct 2024 13:02:28 -0400 Subject: [PATCH] Healer ability tests (#5559) --- include/random.h | 1 + src/battle_util.c | 2 +- test/battle/ability/healer.c | 53 ++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 test/battle/ability/healer.c diff --git a/include/random.h b/include/random.h index 81fdbce896..bdfbe95181 100644 --- a/include/random.h +++ b/include/random.h @@ -169,6 +169,7 @@ enum RandomTag RNG_AI_SWITCH_SEEDED, RNG_SHELL_SIDE_ARM, RNG_RANDOM_TARGET, + RNG_HEALER, }; #define RandomWeighted(tag, ...) \ diff --git a/src/battle_util.c b/src/battle_util.c index 880c066cf9..103f45050c 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5225,7 +5225,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32 gBattleScripting.battler = BATTLE_PARTNER(battler); if (IsBattlerAlive(gBattleScripting.battler) && gBattleMons[gBattleScripting.battler].status1 & STATUS1_ANY - && (Random() % 100) < 30) + && RandomPercentage(RNG_HEALER, 30)) { BattleScriptPushCursorAndCallback(BattleScript_HealerActivates); effect++; diff --git a/test/battle/ability/healer.c b/test/battle/ability/healer.c new file mode 100644 index 0000000000..9626783ec5 --- /dev/null +++ b/test/battle/ability/healer.c @@ -0,0 +1,53 @@ +#include "global.h" +#include "test/battle.h" + +DOUBLE_BATTLE_TEST("Healer cures adjacent ally's status condition 30% of the time") +{ + u16 status; + PARAMETRIZE { status = STATUS1_SLEEP; } + PARAMETRIZE { status = STATUS1_POISON; } + PARAMETRIZE { status = STATUS1_BURN; } + // PARAMETRIZE { status = STATUS1_FREEZE; } + PARAMETRIZE { status = STATUS1_PARALYSIS; } + PARAMETRIZE { status = STATUS1_TOXIC_POISON; } + PARAMETRIZE { status = STATUS1_FROSTBITE; } + PASSES_RANDOMLY(30, 100, RNG_HEALER); + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET) { Status1(status); } + OPPONENT(SPECIES_CHANSEY) { Ability(ABILITY_HEALER); } + } WHEN { + TURN { } + } SCENE { + MESSAGE("The opposing Chansey's Healer cured the opposing Wobbuffet's problem!"); + } +} + +DOUBLE_BATTLE_TEST("Healer cures status condition before burn or poison damage is dealt") +{ + KNOWN_FAILING; // According to Bulbapedia, Healer should trigger before status damage and Wobbuffet should live + // Source: https://bulbapedia.bulbagarden.net/wiki/Healer_(Ability)#Effect + u16 status; + PARAMETRIZE { status = STATUS1_POISON; } + PARAMETRIZE { status = STATUS1_BURN; } + PARAMETRIZE { status = STATUS1_TOXIC_POISON; } + PARAMETRIZE { status = STATUS1_FROSTBITE; } + PASSES_RANDOMLY(30, 100, RNG_HEALER); + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET) { HP(1); Status1(status); } + OPPONENT(SPECIES_CHANSEY) { Ability(ABILITY_HEALER); } + } WHEN { + TURN {} + } SCENE { + NOT { + MESSAGE("The opposing Wobbuffet fainted!"); + } + MESSAGE("The opposing Chansey's Healer cured Foe Wobbuffet's problem!"); + } +} + +// Triple battles +TO_DO_BATTLE_TEST("Healer has a 30% chance of curing each of its ally's status conditions independently");