From f4be01f0acc2b563f53eb1c2a3d8664c1a71fc43 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 30 Oct 2023 11:58:15 +0100 Subject: [PATCH] Fix strength sap on substitute (#3486) * tests for strenth sap * fix strength sap on substitute --------- Co-authored-by: ghoulslash --- data/battle_scripts_1.s | 1 + test/battle/move_effect/strength_sap.c | 59 ++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 test/battle/move_effect/strength_sap.c diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 51090237bc..5d2e18cb4b 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1452,6 +1452,7 @@ BattleScript_StrengthSapHp: jumpifstatus3 BS_ATTACKER, STATUS3_HEAL_BLOCK, BattleScript_MoveEnd jumpiffullhp BS_ATTACKER, BattleScript_MoveEnd manipulatedamage DMG_BIG_ROOT + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER printstring STRINGID_PKMNENERGYDRAINED diff --git a/test/battle/move_effect/strength_sap.c b/test/battle/move_effect/strength_sap.c new file mode 100644 index 0000000000..c549e4c332 --- /dev/null +++ b/test/battle/move_effect/strength_sap.c @@ -0,0 +1,59 @@ +#include "global.h" +#include "test/battle.h" + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_STRENGTH_SAP].effect == EFFECT_STRENGTH_SAP); +} + +SINGLE_BATTLE_TEST("Strength Sap lowers Attack by 1 and restores HP based on target's Attack Stat", s16 hp) +{ + u32 atkStat = 0; + + PARAMETRIZE{ atkStat = 100; } + PARAMETRIZE{ atkStat = 50; } + + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { HP(200); } + OPPONENT(SPECIES_WOBBUFFET) { Attack(atkStat); } + } WHEN { + TURN { MOVE(player, MOVE_STRENGTH_SAP); } + } SCENE { + MESSAGE("Wobbuffet used Strength Sap!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_STRENGTH_SAP, player); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponent); + MESSAGE("Foe Wobbuffet's Attack fell!"); + HP_BAR(player, captureDamage: &results[i].hp); + MESSAGE("Foe Wobbuffet had its energy drained!"); + } THEN { + EXPECT_EQ(results[i].hp * -1, atkStat); + } +} + +// Same as above, but Substitute is used before Strength Sap. +SINGLE_BATTLE_TEST("Strength Sap works exactly the same when attacker is behind substitute", s16 hp) +{ + u32 atkStat = 0; + + PARAMETRIZE{ atkStat = 100; } + PARAMETRIZE{ atkStat = 50; } + + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { HP(200); } + OPPONENT(SPECIES_WOBBUFFET) { Attack(atkStat); } + } WHEN { + TURN { MOVE(player, MOVE_SUBSTITUTE); } + TURN { MOVE(player, MOVE_STRENGTH_SAP); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_SUBSTITUTE, player); + MESSAGE("Wobbuffet used Strength Sap!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_STRENGTH_SAP, player); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponent); + MESSAGE("Foe Wobbuffet's Attack fell!"); + HP_BAR(player, captureDamage: &results[i].hp); + NOT MESSAGE("The SUBSTITUTE took damage for Foe Wobbuffet!"); + MESSAGE("Foe Wobbuffet had its energy drained!"); + } THEN { + EXPECT_EQ(results[i].hp * -1, atkStat); + } +}