From 474a9b5595df43f9b744021b49049ab3bcc8fcd0 Mon Sep 17 00:00:00 2001 From: Lylian Date: Thu, 17 Apr 2025 17:05:43 +0200 Subject: [PATCH] add illusion cry --- src/field/pokemon.ts | 12 ++++++------ test/abilities/illusion.test.ts | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index cdd48f7d940..472d833dbc2 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -699,6 +699,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * Generate an illusion of the last pokemon in the party, as other wild pokemon in the area. */ setIllusion(pokemon: Pokemon): boolean { + console.log("SET ILLUSION") if(!!this.summonData?.illusion){ this.breakIllusion(); } @@ -1099,9 +1100,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { /** * @param {boolean} useIllusion - Whether we want the speciesForm of the illusion or not. */ - getSpeciesForm(ignoreOverride?: boolean, useIllusion: boolean = false): PokemonSpeciesForm { + getSpeciesForm(ignoreOverride?: boolean, useIllusion: boolean = false, cry: boolean = false): PokemonSpeciesForm { const species: PokemonSpecies = useIllusion && !!this.summonData?.illusion ? getPokemonSpecies(this.summonData?.illusion.species) : this.species; - const formIndex: integer = useIllusion && !!this.summonData?.illusion ? this.summonData?.illusion.formIndex : this.formIndex; if (!ignoreOverride && this.summonData?.speciesForm) { @@ -5277,13 +5277,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { sceneOverride?: BattleScene, ): AnySound { const scene = sceneOverride ?? globalScene; // TODO: is `sceneOverride` needed? - const cry = this.getSpeciesForm().cry(soundConfig); + const cry = this.getSpeciesForm(undefined, true).cry(soundConfig); let duration = cry.totalDuration * 1000; if ( this.fusionSpecies && - this.getSpeciesForm() !== this.getFusionSpeciesForm() + this.getSpeciesForm(undefined, true) !== this.getFusionSpeciesForm(undefined, true) ) { - let fusionCry = this.getFusionSpeciesForm().cry(soundConfig, true); + let fusionCry = this.getFusionSpeciesForm(undefined, true).cry(soundConfig, true); duration = Math.min(duration, fusionCry.totalDuration * 1000); fusionCry.destroy(); scene.time.delayedCall(fixedInt(Math.ceil(duration * 0.4)), () => { @@ -5293,7 +5293,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { cry, fixedInt(Math.ceil(duration * 0.2)), ); - fusionCry = this.getFusionSpeciesForm().cry( + fusionCry = this.getFusionSpeciesForm(undefined, true).cry( Object.assign( { seek: Math.max(fusionCry.totalDuration * 0.4, 0) }, soundConfig, diff --git a/test/abilities/illusion.test.ts b/test/abilities/illusion.test.ts index aa77aa701b2..da435e4158d 100644 --- a/test/abilities/illusion.test.ts +++ b/test/abilities/illusion.test.ts @@ -7,6 +7,7 @@ import { Moves } from "#enums/moves"; import { Abilities } from "#enums/abilities"; import { PokeballType } from "#app/enums/pokeball"; import { Gender } from "#app/data/gender"; +import { BerryPhase } from "#app/phases/berry-phase"; describe("Abilities - Illusion", () => { let phaserGame: Phaser.Game; @@ -66,7 +67,21 @@ describe("Abilities - Illusion", () => { expect(!!zorua.summonData?.illusion).equals(false); }); - it("break if the ability is suppressed", async () => { + it("breaks when suppressed", async () => { + game.override.moveset(Moves.GASTRO_ACID); + await game.classicMode.startBattle([Species.MAGIKARP]); + const zorua = game.scene.getEnemyPokemon()!; + + expect(!!zorua.summonData?.illusion).toBe(true); + + game.move.select(Moves.GASTRO_ACID); + await game.phaseInterceptor.to(BerryPhase); + + expect(zorua.isFullHp()).toBe(true); + expect(!!zorua.summonData?.illusion).toBe(false); + }); + + it("break with neutralizing gas", async () => { game.override.enemyAbility(Abilities.NEUTRALIZING_GAS); await game.classicMode.startBattle([Species.KOFFING]);