diff --git a/src/data/trainer-config.ts b/src/data/trainer-config.ts index df10923963a..30c9c016ad9 100644 --- a/src/data/trainer-config.ts +++ b/src/data/trainer-config.ts @@ -630,13 +630,15 @@ export class TrainerConfig { ? scene.anims.generateFrameNames(partnerTrainerKey, {zeroPad: 4,suffix: ".png",start: 1,end: 128}) : null; console.warn = originalWarn; - scene.anims.create({ - key: trainerKey, - frames: frameNames, - frameRate: 24, - repeat: -1 - }); - if (isDouble) { + if (!(scene.anims.exists(trainerKey))) { + scene.anims.create({ + key: trainerKey, + frames: frameNames, + frameRate: 24, + repeat: -1 + }); + } + if (isDouble && !(scene.anims.exists(partnerTrainerKey))) { scene.anims.create({ key: partnerTrainerKey, frames: partnerFrameNames, diff --git a/src/field/anims.ts b/src/field/anims.ts index db6a331cc20..52a15aa4f20 100644 --- a/src/field/anims.ts +++ b/src/field/anims.ts @@ -24,12 +24,14 @@ export function addPokeballOpenParticles(scene: BattleScene, x: number, y: numbe function doDefaultPbOpenParticles(scene: BattleScene, x: number, y: number, radius: number) { const pbOpenParticlesFrameNames = scene.anims.generateFrameNames("pb_particles", { start: 0, end: 3, suffix: ".png" }); - scene.anims.create({ - key: "pb_open_particle", - frames: pbOpenParticlesFrameNames, - frameRate: 16, - repeat: -1 - }); + if (!(scene.anims.exists("pb_open_particle"))) { + scene.anims.create({ + key: "pb_open_particle", + frames: pbOpenParticlesFrameNames, + frameRate: 16, + repeat: -1 + }); + } const addParticle = (index: integer) => { const particle = scene.add.sprite(x, y, "pb_open_particle"); diff --git a/src/field/arena.ts b/src/field/arena.ts index 3668eaa440e..b00b8054ee2 100644 --- a/src/field/arena.ts +++ b/src/field/arena.ts @@ -726,12 +726,14 @@ export class ArenaBase extends Phaser.GameObjects.Container { if (this.base.texture.frameTotal > 1) { const baseFrameNames = this.scene.anims.generateFrameNames(baseKey, { zeroPad: 4, suffix: ".png", start: 1, end: this.base.texture.frameTotal - 1 }); - this.scene.anims.create({ - key: baseKey, - frames: baseFrameNames, - frameRate: 12, - repeat: -1 - }); + if (!(this.scene.anims.exists(baseKey))) { + this.scene.anims.create({ + key: baseKey, + frames: baseFrameNames, + frameRate: 12, + repeat: -1 + }); + } this.base.play(baseKey); } else { this.base.stop(); @@ -751,12 +753,14 @@ export class ArenaBase extends Phaser.GameObjects.Container { if (hasProps && prop.texture.frameTotal > 1) { const propFrameNames = this.scene.anims.generateFrameNames(propKey, { zeroPad: 4, suffix: ".png", start: 1, end: prop.texture.frameTotal - 1 }); - this.scene.anims.create({ - key: propKey, - frames: propFrameNames, - frameRate: 12, - repeat: -1 - }); + if (!(this.scene.anims.exists(propKey))) { + this.scene.anims.create({ + key: propKey, + frames: propFrameNames, + frameRate: 12, + repeat: -1 + }); + } prop.play(propKey); } else { prop.stop(); diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 5cc4e54c5b4..c8ba9c86319 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -322,12 +322,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { console.warn = () => {}; const battleFrameNames = this.scene.anims.generateFrameNames(this.getBattleSpriteKey(), { zeroPad: 4, suffix: ".png", start: 1, end: 400 }); console.warn = originalWarn; - this.scene.anims.create({ - key: this.getBattleSpriteKey(), - frames: battleFrameNames, - frameRate: 12, - repeat: -1 - }); + if (!(this.scene.anims.exists(this.getBattleSpriteKey()))) { + this.scene.anims.create({ + key: this.getBattleSpriteKey(), + frames: battleFrameNames, + frameRate: 12, + repeat: -1 + }); + } } this.playAnim(); const updateFusionPaletteAndResolve = () => { @@ -524,13 +526,15 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { shinySparkle.setVisible(false); shinySparkle.setOrigin(0.5, 1); const frameNames = this.scene.anims.generateFrameNames(key, { suffix: ".png", end: 34 }); - this.scene.anims.create({ - key: `sparkle${keySuffix}`, - frames: frameNames, - frameRate: 32, - showOnStart: true, - hideOnComplete: true, - }); + if (!(this.scene.anims.exists(`sparkle${keySuffix}`))) { + this.scene.anims.create({ + key: `sparkle${keySuffix}`, + frames: frameNames, + frameRate: 32, + showOnStart: true, + hideOnComplete: true, + }); + } this.add(shinySparkle); this.shinySparkle = shinySparkle; diff --git a/src/phases.ts b/src/phases.ts index 231c9aacfa1..b05dfba05ca 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -4411,7 +4411,7 @@ export class PokemonHealPhase extends CommonAnimPhase { } const healAmount = new Utils.NumberHolder(Math.floor(this.hpHealed * hpRestoreMultiplier.value)); if (healAmount.value < 0) { - pokemon.damageAndUpdate(healAmount.value * -1, HitResult.HEAL); + pokemon.damageAndUpdate(healAmount.value * -1, HitResult.HEAL as DamageResult); healAmount.value = 0; } // Prevent healing to full if specified (in case of healing tokens so Sturdy doesn't cause a softlock) diff --git a/src/ui/egg-gacha-ui-handler.ts b/src/ui/egg-gacha-ui-handler.ts index 4cfd6813b41..9536df7dbed 100644 --- a/src/ui/egg-gacha-ui-handler.ts +++ b/src/ui/egg-gacha-ui-handler.ts @@ -61,16 +61,20 @@ export default class EggGachaUiHandler extends MessageUiHandler { this.eggGachaContainer.add(bg); const hatchFrameNames = this.scene.anims.generateFrameNames("gacha_hatch", { suffix: ".png", start: 1, end: 4 }); - this.scene.anims.create({ - key: "open", - frames: hatchFrameNames, - frameRate: 12 - }); - this.scene.anims.create({ - key: "close", - frames: hatchFrameNames.reverse(), - frameRate: 12 - }); + if (!(this.scene.anims.exists("open"))) { + this.scene.anims.create({ + key: "open", + frames: hatchFrameNames, + frameRate: 12 + }); + } + if (!(this.scene.anims.exists("close"))) { + this.scene.anims.create({ + key: "close", + frames: hatchFrameNames.reverse(), + frameRate: 12 + }); + } Utils.getEnumValues(GachaType).forEach((gachaType, g) => { const gachaTypeKey = GachaType[gachaType].toString().toLowerCase(); diff --git a/src/ui/egg-hatch-scene-handler.ts b/src/ui/egg-hatch-scene-handler.ts index 2277c3a4b64..5a4c984234c 100644 --- a/src/ui/egg-hatch-scene-handler.ts +++ b/src/ui/egg-hatch-scene-handler.ts @@ -16,11 +16,13 @@ export default class EggHatchSceneHandler extends UiHandler { this.scene.fieldUI.add(this.eggHatchContainer); const eggLightraysAnimFrames = this.scene.anims.generateFrameNames("egg_lightrays", { start: 0, end: 3 }); - this.scene.anims.create({ - key: "egg_lightrays", - frames: eggLightraysAnimFrames, - frameRate: 32 - }); + if (!(this.scene.anims.exists("egg_lightrays"))) { + this.scene.anims.create({ + key: "egg_lightrays", + frames: eggLightraysAnimFrames, + frameRate: 32 + }); + } } show(_args: any[]): boolean {