Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dynamax using Pokemon-specific animations #2217

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 39 additions & 27 deletions play.pokemonshowdown.com/src/battle-animations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -2473,8 +2473,41 @@ export class PokemonSprite extends Sprite {
});
}
}
animTransform(pokemon: Pokemon, isCustomAnim?: boolean, isPermanent?: boolean) {
if (!this.scene.animating && !isPermanent) return;
customAnimAndIfCry(speciesid: ID, isDynamaxing?: boolean): boolean {
const scene = this.scene;
if (isDynamaxing) {
BattleOtherAnims.megaevo.anim(scene, [this]);
alphazeba marked this conversation as resolved.
Show resolved Hide resolved
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,
Expand All @@ -2500,29 +2533,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 = $('<img src="' + sp.url + '" style="display:block;opacity:0;position:absolute"' + (sp.pixelated ? ' class="pixelated"' : '') + ' />');
Expand Down Expand Up @@ -2551,7 +2563,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,
Expand Down
2 changes: 1 addition & 1 deletion play.pokemonshowdown.com/src/battle-scene-stub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) { }
Expand Down
2 changes: 1 addition & 1 deletion play.pokemonshowdown.com/src/battle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, false, true);
break;
case 'powertrick':
this.scene.resultAnim(poke, 'Power Trick', 'neutral');
Expand Down
Loading