From aa421b5d109a32f1bb9a1c7152b5a95da78c79c3 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Thu, 4 Apr 2024 09:45:25 -0400 Subject: [PATCH] Fix move animation defaults not working (fixes Tackle crash) --- src/battle-scene.ts | 4 +++- src/data/battle-anims.ts | 12 +++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 52490cd1649..ac1d3e629ae 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -429,10 +429,12 @@ export default class BattleScene extends SceneBase { ui.setup(); + const defaultMoves = [ Moves.TACKLE, Moves.TAIL_WHIP, Moves.FOCUS_ENERGY, Moves.STRUGGLE ]; + Promise.all([ Promise.all(loadPokemonAssets), initCommonAnims().then(() => loadCommonAnimAssets(this, true)), - initMoveAnim(Moves.STRUGGLE).then(() => loadMoveAnimAssets(this, [ Moves.STRUGGLE ], true)) + Promise.all([ Moves.TACKLE, Moves.TAIL_WHIP, Moves.FOCUS_ENERGY, Moves.STRUGGLE ].map(m => initMoveAnim(m))).then(() => loadMoveAnimAssets(this, defaultMoves, true)) ]).then(() => { this.pushPhase(new LoginPhase(this)); this.pushPhase(new TitlePhase(this)); diff --git a/src/data/battle-anims.ts b/src/data/battle-anims.ts index a3af386d097..9583b47f18f 100644 --- a/src/data/battle-anims.ts +++ b/src/data/battle-anims.ts @@ -455,16 +455,14 @@ export function initMoveAnim(move: Moves): Promise { } else { moveAnims.set(move, null); const defaultMoveAnim = allMoves[move] instanceof AttackMove ? Moves.TACKLE : allMoves[move] instanceof SelfStatusMove ? Moves.FOCUS_ENERGY : Moves.TAIL_WHIP; + const moveName = Moves[move].toLowerCase().replace(/\_/g, '-'); const fetchAnimAndResolve = (move: Moves) => { - fetch(`./battle-anims/${Moves[move].toLowerCase().replace(/\_/g, '-')}.json`) + fetch(`./battle-anims/${moveName}.json`) .then(response => { if (!response.ok) { - console.error(response.status, response.statusText); - if (move !== defaultMoveAnim) - fetchAnimAndResolve(defaultMoveAnim); - else - resolve(); - return; + console.error(`Could not load animation file for move '${moveName}'`, response.status, response.statusText); + populateMoveAnim(move, moveAnims.get(defaultMoveAnim)); + return resolve(); } return response.json(); })