Skip to content

Commit

Permalink
Fix Transform Palafin-Hero interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Zarel committed Sep 4, 2024
1 parent 2b095bd commit d706436
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
19 changes: 14 additions & 5 deletions play.pokemonshowdown.com/src/battle-animations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1516,8 +1516,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, useSpeciesAnim?: boolean, isPermanent?: boolean) {
return pokemon.sprite.animTransform(pokemon, useSpeciesAnim, isPermanent);
}
clearEffects(pokemon: Pokemon) {
return pokemon.sprite.clearEffects();
Expand Down Expand Up @@ -2500,7 +2500,12 @@ export class PokemonSprite extends Sprite {
});
}
}
animTransform(pokemon: Pokemon, isCustomAnim?: boolean, isPermanent?: boolean) {
/**
* @param pokemon
* @param useSpeciesAnim false = Transform the move or Imposter the ability
* @param isPermanent false = reverts on switch-out
*/
animTransform(pokemon: Pokemon, useSpeciesAnim?: boolean, isPermanent?: boolean) {
if (!this.scene.animating && !isPermanent) return;
let sp = Dex.getSpriteData(pokemon, this.isFrontSprite, {
gen: this.scene.gen,
Expand All @@ -2527,8 +2532,9 @@ export class PokemonSprite extends Sprite {
if (!this.scene.animating) return;
let speciesid = toID(pokemon.getSpeciesForme());
let doCry = false;
let skipAnim = false;
const scene = this.scene;
if (isCustomAnim) {
if (useSpeciesAnim) {
if (speciesid === 'kyogreprimal') {
BattleOtherAnims.primalalpha.anim(scene, [this]);
doCry = true;
Expand All @@ -2546,6 +2552,8 @@ export class PokemonSprite extends Sprite {
BattleOtherAnims.schoolingout.anim(scene, [this]);
} else if (speciesid === 'mimikyubusted' || speciesid === 'mimikyubustedtotem') {
// standard animation
} else if (speciesid === 'palafinhero') {
skipAnim = true;
} else {
BattleOtherAnims.megaevo.anim(scene, [this]);
doCry = true;
Expand All @@ -2561,9 +2569,10 @@ export class PokemonSprite extends Sprite {
xscale: 0,
opacity: 0,
}, sp));
if (speciesid === 'palafinhero') {
if (skipAnim) {
this.$el.replaceWith($newEl);
this.$el = $newEl;
this.animReset();
} else {
this.$el.animate(this.scene.pos({
x: this.x,
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, useSpeciesAnim?: boolean, isPermanent?: boolean) { }
clearEffects(pokemon: Pokemon) { }
removeTransform(pokemon: Pokemon) { }
animFaint(pokemon: Pokemon) { }
Expand Down
6 changes: 2 additions & 4 deletions play.pokemonshowdown.com/src/battle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2450,8 +2450,7 @@ export class Battle {
poke.details = args[2];
poke.searchid = args[1].substr(0, 2) + args[1].substr(3) + '|' + args[2];

let isCustomAnim = species.id !== 'palafinhero';
this.scene.animTransform(poke, isCustomAnim, true);
this.scene.animTransform(poke, true, true);
this.log(args, kwArgs);
break;
}
Expand Down Expand Up @@ -2489,7 +2488,6 @@ export class Battle {
let poke = this.getPokemon(args[1])!;
let species = Dex.species.get(args[2]);
let fromeffect = Dex.getEffect(kwArgs.from);
let isCustomAnim = species.name.startsWith('Wishiwashi');
if (!poke.getSpeciesForme().endsWith('-Gmax') && !species.name.endsWith('-Gmax')) {
poke.removeVolatile('typeadd' as ID);
poke.removeVolatile('typechange' as ID);
Expand All @@ -2500,7 +2498,7 @@ export class Battle {
this.activateAbility(poke, fromeffect);
}
poke.addVolatile('formechange' as ID, species.name); // the formechange volatile reminds us to revert the sprite change on switch-out
this.scene.animTransform(poke, isCustomAnim);
this.scene.animTransform(poke, true);
this.log(args, kwArgs);
break;
}
Expand Down

0 comments on commit d706436

Please sign in to comment.