From e0065fca7c5df12b29e022f26e96a954555902c8 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Sun, 22 Oct 2023 10:13:03 -0400 Subject: [PATCH] Fix issues with Pokemon sprites persisting after some moves --- src/data/battle-anims.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/data/battle-anims.ts b/src/data/battle-anims.ts index d1340be0e..63b86f320 100644 --- a/src/data/battle-anims.ts +++ b/src/data/battle-anims.ts @@ -760,12 +760,15 @@ export abstract class BattleAnim { for (let i of targets) { const count = i === AnimFrameTarget.GRAPHIC ? g : i === AnimFrameTarget.USER ? u : t; if (count < spriteCache[i].length) { - const removedSprites = spriteCache[i].splice(count, spriteCache[i].length - count); - if (i === AnimFrameTarget.GRAPHIC) - spritePriorities.splice(count, spriteCache[i].length - count); - for (let rs of removedSprites) { - if (!rs.getData('locked') as boolean) + const spritesToRemove = spriteCache[i].slice(count, spriteCache[i].length); + for (let rs of spritesToRemove) { + if (!rs.getData('locked') as boolean) { + const spriteCacheIndex = spriteCache[i].indexOf(rs); + spriteCache[i].splice(spriteCacheIndex, 1); + if (i === AnimFrameTarget.GRAPHIC) + spritePriorities.splice(spriteCacheIndex, 1); rs.destroy(); + } } } }