From 546177692058d5e4514466e7715984b352aa0520 Mon Sep 17 00:00:00 2001 From: arnhom Date: Mon, 22 Jan 2024 23:26:26 -0800 Subject: [PATCH 1/3] Fix dynamax using pokemon specific animations the term "customAnimation" was overloaded meaning dynamax or a number of other form changes within animTransform. I've added a "isDynamax" flag to force dynamax animation. I figure this is worth the flag since every pokemon can dynamax. The bug report https://github.com/smogon/pokemon-showdown/projects/3#card-85878145 notes that it happens on zygard but it actually would occur on any pokemon with a custom animation. --- .../src/battle-animations.ts | 67 +++++++++++-------- .../src/battle-scene-stub.ts | 2 +- play.pokemonshowdown.com/src/battle.ts | 2 +- 3 files changed, 42 insertions(+), 29 deletions(-) diff --git a/play.pokemonshowdown.com/src/battle-animations.ts b/play.pokemonshowdown.com/src/battle-animations.ts index d07e134fe4..a0d7ba77e5 100644 --- a/play.pokemonshowdown.com/src/battle-animations.ts +++ b/play.pokemonshowdown.com/src/battle-animations.ts @@ -1489,8 +1489,8 @@ export class BattleScene implements BattleSceneStub { updateStatbarIfExists(pokemon: Pokemon, updatePrevhp?: boolean, updateHp?: boolean) { return pokemon.sprite.updateStatbarIfExists(pokemon, updatePrevhp, updateHp); } - animTransform(pokemon: Pokemon, isCustomAnim?: boolean, isPermanent?: boolean) { - return pokemon.sprite.animTransform(pokemon, isCustomAnim, isPermanent); + animTransform(pokemon: Pokemon, isCustomAnim?: boolean, isPermanent?: boolean, isDynamaxing?: boolean) { + return pokemon.sprite.animTransform(pokemon, isCustomAnim, isPermanent, isDynamaxing); } clearEffects(pokemon: Pokemon) { return pokemon.sprite.clearEffects(); @@ -2473,8 +2473,42 @@ export class PokemonSprite extends Sprite { }); } } - animTransform(pokemon: Pokemon, isCustomAnim?: boolean, isPermanent?: boolean) { - if (!this.scene.animating && !isPermanent) return; + customAnimAndIfCry(speciesid: ID, isDynamaxing?: boolean): boolean { + console.log("customAnimAndIfCry is running"); + const scene = this.scene; + if (isDynamaxing) { + BattleOtherAnims.megaevo.anim(scene, [this]); + return true; + } + switch (speciesid) { + case 'kyogreprimal': + BattleOtherAnims.primalalpha.anim(scene, [this]); + return true; + case 'groudonprimal': + BattleOtherAnims.primalomega.anim(scene, [this]); + return true; + case 'necrozmaultra': + BattleOtherAnims.ultraburst.anim(scene, [this]); + return true; + case 'zygardecomplete': + BattleOtherAnims.powerconstruct.anim(scene, [this]); + return false; + case 'wishiwashischool': case 'greninjaash': + BattleOtherAnims.schoolingin.anim(scene, [this]); + return false; + case 'wishiwashi': + BattleOtherAnims.schoolingout.anim(scene, [this]); + return false; + case 'mimikyubusted': case 'mimikyubustedtotem': + // standard animation + return false; + default: + BattleOtherAnims.megaevo.anim(scene, [this]); + return true; + } + } + animTransform(pokemon: Pokemon, isCustomAnim?: boolean, isPermanent?: boolean, isDynamaxing?: boolean) { + if (!(this.scene.animating || isPermanent)) return; let sp = Dex.getSpriteData(pokemon, this.isFrontSprite, { gen: this.scene.gen, mod: this.scene.mod, @@ -2500,29 +2534,8 @@ export class PokemonSprite extends Sprite { if (!this.scene.animating) return; let speciesid = toID(pokemon.getSpeciesForme()); let doCry = false; - const scene = this.scene; if (isCustomAnim) { - if (speciesid === 'kyogreprimal') { - BattleOtherAnims.primalalpha.anim(scene, [this]); - doCry = true; - } else if (speciesid === 'groudonprimal') { - BattleOtherAnims.primalomega.anim(scene, [this]); - doCry = true; - } else if (speciesid === 'necrozmaultra') { - BattleOtherAnims.ultraburst.anim(scene, [this]); - doCry = true; - } else if (speciesid === 'zygardecomplete') { - BattleOtherAnims.powerconstruct.anim(scene, [this]); - } else if (speciesid === 'wishiwashischool' || speciesid === 'greninjaash') { - BattleOtherAnims.schoolingin.anim(scene, [this]); - } else if (speciesid === 'wishiwashi') { - BattleOtherAnims.schoolingout.anim(scene, [this]); - } else if (speciesid === 'mimikyubusted' || speciesid === 'mimikyubustedtotem') { - // standard animation - } else { - BattleOtherAnims.megaevo.anim(scene, [this]); - doCry = true; - } + doCry = this.customAnimAndIfCry(speciesid, isDynamaxing); } // Constructing here gives us 300ms extra time to preload the new sprite let $newEl = $(''); @@ -2551,7 +2564,7 @@ export class PokemonSprite extends Sprite { } this.$el.replaceWith($newEl); this.$el = $newEl; - this.$el.animate(scene.pos({ + this.$el.animate(this.scene.pos({ x: this.x, y: this.y, z: this.z, diff --git a/play.pokemonshowdown.com/src/battle-scene-stub.ts b/play.pokemonshowdown.com/src/battle-scene-stub.ts index 44b2ab4189..00189d32b4 100644 --- a/play.pokemonshowdown.com/src/battle-scene-stub.ts +++ b/play.pokemonshowdown.com/src/battle-scene-stub.ts @@ -67,7 +67,7 @@ export class BattleSceneStub { resetStatbar(pokemon: Pokemon, startHidden?: boolean) { } updateStatbar(pokemon: Pokemon, updatePrevhp?: boolean, updateHp?: boolean) { } updateStatbarIfExists(pokemon: Pokemon, updatePrevhp?: boolean, updateHp?: boolean) { } - animTransform(pokemon: Pokemon, isCustomAnim?: boolean, isPermanent?: boolean) { } + animTransform(pokemon: Pokemon, isCustomAnim?: boolean, isPermanent?: boolean, isDynamaxing?: boolean) { } clearEffects(pokemon: Pokemon) { } removeTransform(pokemon: Pokemon) { } animFaint(pokemon: Pokemon) { } diff --git a/play.pokemonshowdown.com/src/battle.ts b/play.pokemonshowdown.com/src/battle.ts index 04ca1b915a..30dcddb6ca 100644 --- a/play.pokemonshowdown.com/src/battle.ts +++ b/play.pokemonshowdown.com/src/battle.ts @@ -2560,7 +2560,7 @@ export class Battle { break; case 'dynamax': poke.addVolatile('dynamax' as ID, !!args[3]); - this.scene.animTransform(poke, true); + this.scene.animTransform(poke, true, undefined, true); break; case 'powertrick': this.scene.resultAnim(poke, 'Power Trick', 'neutral'); From befe3b85b5ef8f48de8fddbd4d27d6b8136b2745 Mon Sep 17 00:00:00 2001 From: alphazeba <33792307+alphazeba@users.noreply.github.com> Date: Wed, 24 Jan 2024 13:58:36 -0800 Subject: [PATCH 2/3] Update play.pokemonshowdown.com/src/battle-animations.ts remove log statement Co-authored-by: Guangcong Luo --- play.pokemonshowdown.com/src/battle-animations.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/play.pokemonshowdown.com/src/battle-animations.ts b/play.pokemonshowdown.com/src/battle-animations.ts index a0d7ba77e5..4a2e149e6f 100644 --- a/play.pokemonshowdown.com/src/battle-animations.ts +++ b/play.pokemonshowdown.com/src/battle-animations.ts @@ -2474,7 +2474,6 @@ export class PokemonSprite extends Sprite { } } customAnimAndIfCry(speciesid: ID, isDynamaxing?: boolean): boolean { - console.log("customAnimAndIfCry is running"); const scene = this.scene; if (isDynamaxing) { BattleOtherAnims.megaevo.anim(scene, [this]); From 9261b263968cf8d984f518d2f0b30da36cd853f8 Mon Sep 17 00:00:00 2001 From: Kris Johnson <11083252+KrisXV@users.noreply.github.com> Date: Mon, 26 Feb 2024 13:40:57 -0700 Subject: [PATCH 3/3] Update play.pokemonshowdown.com/src/battle.ts --- play.pokemonshowdown.com/src/battle.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/play.pokemonshowdown.com/src/battle.ts b/play.pokemonshowdown.com/src/battle.ts index 30dcddb6ca..ce53731e70 100644 --- a/play.pokemonshowdown.com/src/battle.ts +++ b/play.pokemonshowdown.com/src/battle.ts @@ -2560,7 +2560,7 @@ export class Battle { break; case 'dynamax': poke.addVolatile('dynamax' as ID, !!args[3]); - this.scene.animTransform(poke, true, undefined, true); + this.scene.animTransform(poke, true, false, true); break; case 'powertrick': this.scene.resultAnim(poke, 'Power Trick', 'neutral');