From 84d13d0abf173fd59ce50188cf6b0c10f81f7510 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 13 Jun 2024 21:30:28 +0200 Subject: [PATCH] Fix Smack Down anim + move anim tests (#4774) * Fix Smack Down anim + move anim tests * really agbcc * fix undefined reference * hopefully everything works --- data/battle_anim_scripts.s | 1 - include/test/battle.h | 3 +++ src/battle_anim.c | 8 ++++++-- test/battle/move_animations/smack_down.c | 25 ++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 test/battle/move_animations/smack_down.c diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index 61e5d94650..aa62732c7d 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -5168,7 +5168,6 @@ Move_SMACK_DOWN:: createvisualtask AnimTask_SmokescreenImpact, 0x8, 0x400, 0x1902 fadetobg BG_IN_AIR waitbgfadeout - createvisualtask AnimTask_StartSlidingBg, 5, 0x0, 0x0, 0x0, 0xffff createvisualtask AnimTask_SeismicTossBgAccelerateDownAtEnd, 3 goto SeismicTossWeak diff --git a/include/test/battle.h b/include/test/battle.h index b44186ed3d..514e3bca49 100644 --- a/include/test/battle.h +++ b/include/test/battle.h @@ -695,6 +695,7 @@ struct BattleTestData struct BattleTestRunnerState { u8 battlersCount; + bool8 forceMoveAnim; u16 parametersCount; // Valid only in BattleTest_Setup. u16 parameters; u16 runParameter; @@ -996,6 +997,8 @@ void SendOut(u32 sourceLine, struct BattlePokemon *, u32 partyIndex); #define NONE_OF for (OpenQueueGroup(__LINE__, QUEUE_GROUP_NONE_OF); gBattleTestRunnerState->data.queueGroupType != QUEUE_GROUP_NONE; CloseQueueGroup(__LINE__)) #define NOT NONE_OF +#define FORCE_MOVE_ANIM(set) gBattleTestRunnerState->forceMoveAnim = (set) + #define ABILITY_POPUP(battler, ...) QueueAbility(__LINE__, battler, (struct AbilityEventContext) { __VA_ARGS__ }) #define ANIMATION(type, id, ...) QueueAnimation(__LINE__, type, id, (struct AnimationEventContext) { __VA_ARGS__ }) #define HP_BAR(battler, ...) QueueHP(__LINE__, battler, (struct HPEventContext) { APPEND_TRUE(__VA_ARGS__) }) diff --git a/src/battle_anim.c b/src/battle_anim.c index af1a5a262a..77f16cd3d7 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -18,6 +18,7 @@ #include "sprite.h" #include "task.h" #include "test_runner.h" +#include "test/battle.h" #include "constants/battle_anim.h" #include "constants/moves.h" @@ -239,6 +240,9 @@ void LaunchBattleAnimation(u32 animType, u32 animId) TestRunner_Battle_RecordAnimation(animType, animId); // Play Transform and Ally Switch even in Headless as these move animations also change mon data. if (gTestRunnerHeadless + #if TESTING // Because gBattleTestRunnerState is not seen outside of test env. + && !gBattleTestRunnerState->forceMoveAnim + #endif // TESTING && !(animType == ANIM_TYPE_MOVE && (animId == MOVE_TRANSFORM || animId == MOVE_ALLY_SWITCH))) { gAnimScriptCallback = Nop; @@ -446,7 +450,7 @@ static u8 GetBattleAnimMoveTargets(u8 battlerArgIndex, u8 *targets) u32 i; u32 ignoredTgt = gBattlerAttacker; u32 target = GetBattlerMoveTargetType(gBattleAnimAttacker, gAnimMoveIndex); - + switch (battlerAnimId) { case ANIM_ATTACKER: @@ -458,7 +462,7 @@ static u8 GetBattleAnimMoveTargets(u8 battlerArgIndex, u8 *targets) ignoredTgt = gBattlerAttacker; break; } - + switch (target) { case MOVE_TARGET_FOES_AND_ALLY: diff --git a/test/battle/move_animations/smack_down.c b/test/battle/move_animations/smack_down.c new file mode 100644 index 0000000000..acd97e9505 --- /dev/null +++ b/test/battle/move_animations/smack_down.c @@ -0,0 +1,25 @@ +#include "global.h" +#include "test/battle.h" + +SINGLE_BATTLE_TEST("Move Animation Test: Smack Down works when used 15 times in a row") +{ + u16 j, nTurns = 15; + FORCE_MOVE_ANIM(TRUE); + + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + for (j = 0; j < nTurns; j++) + { + TURN { MOVE(player, MOVE_SMACK_DOWN); MOVE(opponent, MOVE_HELPING_HAND); } // Helping Hand, so there's no anim on the opponent's side. + } + } SCENE { + for (j = 0; j < nTurns; j++) + { + ANIMATION(ANIM_TYPE_MOVE, MOVE_SMACK_DOWN, player); + } + } THEN { + FORCE_MOVE_ANIM(FALSE); + } +}