Skip to content

Commit

Permalink
Fix Smack Down anim + move anim tests (#4774)
Browse files Browse the repository at this point in the history
* Fix Smack Down anim + move anim tests

* really agbcc

* fix undefined reference

* hopefully everything works
  • Loading branch information
DizzyEggg committed Jun 13, 2024
1 parent f868de0 commit 84d13d0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
1 change: 0 additions & 1 deletion data/battle_anim_scripts.s
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions include/test/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ struct BattleTestData
struct BattleTestRunnerState
{
u8 battlersCount;
bool8 forceMoveAnim;
u16 parametersCount; // Valid only in BattleTest_Setup.
u16 parameters;
u16 runParameter;
Expand Down Expand Up @@ -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__) })
Expand Down
8 changes: 6 additions & 2 deletions src/battle_anim.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand All @@ -458,7 +462,7 @@ static u8 GetBattleAnimMoveTargets(u8 battlerArgIndex, u8 *targets)
ignoredTgt = gBattlerAttacker;
break;
}

switch (target)
{
case MOVE_TARGET_FOES_AND_ALLY:
Expand Down
25 changes: 25 additions & 0 deletions test/battle/move_animations/smack_down.c
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 84d13d0

Please sign in to comment.