From b3d271a654f5904fe6bd34384376728729d64e3b Mon Sep 17 00:00:00 2001 From: Lylian Date: Mon, 5 May 2025 12:03:23 +0200 Subject: [PATCH] fix illusion icon in party ui handler --- src/battle-scene.ts | 17 ++++---- src/field/pokemon.ts | 88 ++++++++++++++++++++++++---------------- src/modifier/modifier.ts | 2 +- src/overrides.ts | 2 +- src/ui/battle-info.ts | 4 +- 5 files changed, 67 insertions(+), 46 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index db036847994..39bd1dd64cf 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -1046,31 +1046,32 @@ export default class BattleScene extends SceneBase { originX = 0.5, originY = 0.5, ignoreOverride = false, + useIllusion = false, ): Phaser.GameObjects.Container { const container = this.add.container(x, y); container.setName(`${pokemon.name}-icon`); - const icon = this.add.sprite(0, 0, pokemon.getIconAtlasKey(ignoreOverride)); + const icon = this.add.sprite(0, 0, pokemon.getIconAtlasKey(ignoreOverride, useIllusion)); icon.setName(`sprite-${pokemon.name}-icon`); - icon.setFrame(pokemon.getIconId(true)); + icon.setFrame(pokemon.getIconId(true, useIllusion)); // Temporary fix to show pokemon's default icon if variant icon doesn't exist - if (icon.frame.name !== pokemon.getIconId(true)) { + if (icon.frame.name !== pokemon.getIconId(true, useIllusion)) { console.log(`${pokemon.name}'s variant icon does not exist. Replacing with default.`); const temp = pokemon.shiny; pokemon.shiny = false; - icon.setTexture(pokemon.getIconAtlasKey(ignoreOverride)); - icon.setFrame(pokemon.getIconId(true)); + icon.setTexture(pokemon.getIconAtlasKey(ignoreOverride, useIllusion)); + icon.setFrame(pokemon.getIconId(true, useIllusion)); pokemon.shiny = temp; } icon.setOrigin(0.5, 0); container.add(icon); - if (pokemon.isFusion(true)) { - const fusionIcon = this.add.sprite(0, 0, pokemon.getFusionIconAtlasKey(ignoreOverride)); + if (pokemon.isFusion(useIllusion)) { + const fusionIcon = this.add.sprite(0, 0, pokemon.getFusionIconAtlasKey(ignoreOverride, useIllusion)); fusionIcon.setName("sprite-fusion-icon"); fusionIcon.setOrigin(0.5, 0); - fusionIcon.setFrame(pokemon.getFusionIconId(true)); + fusionIcon.setFrame(pokemon.getFusionIconId(true, useIllusion)); const originalWidth = icon.width; const originalHeight = icon.height; diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index b9c64ad071c..0bbaa3ac6b4 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1115,40 +1115,45 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { ); } - getIconAtlasKey(ignoreOverride?: boolean): string { - const formIndex = this.summonData.illusion?.formIndex ?? this.formIndex; - return this.getSpeciesForm(ignoreOverride, true).getIconAtlasKey( + getIconAtlasKey(ignoreOverride?: boolean, useIllusion: boolean = true): string { + const formIndex = useIllusion && this.summonData.illusion?.formIndex ? this.summonData.illusion?.formIndex : this.formIndex; + const variant = !useIllusion && !!this.summonData.illusion ? this.summonData.illusion?.basePokemon.variant : this.variant; + return this.getSpeciesForm(ignoreOverride, useIllusion).getIconAtlasKey( formIndex, - this.shiny, - this.variant + this.isBaseShiny(useIllusion), + variant ); } - getFusionIconAtlasKey(ignoreOverride?: boolean): string { - return this.getFusionSpeciesForm(ignoreOverride, true).getIconAtlasKey( - this.fusionFormIndex, - this.fusionShiny, - this.fusionVariant - ); - } - - getIconId(ignoreOverride?: boolean): string { - const formIndex = this.summonData.illusion?.formIndex ?? this.formIndex; - return this.getSpeciesForm(ignoreOverride, true).getIconId( - this.getGender(ignoreOverride, true) === Gender.FEMALE, - formIndex, - this.shiny, - this.variant - ); - } - - getFusionIconId(ignoreOverride?: boolean): string { - const fusionFormIndex = this.summonData.illusion?.fusionFormIndex ?? this.fusionFormIndex; - return this.getFusionSpeciesForm(ignoreOverride, true).getIconId( - this.getFusionGender(ignoreOverride, true) === Gender.FEMALE, + getFusionIconAtlasKey(ignoreOverride?: boolean, useIllusion: boolean = true): string { + const fusionFormIndex = useIllusion && this.summonData.illusion?.fusionFormIndex ? this.summonData.illusion?.fusionFormIndex : this.fusionFormIndex; + const fusionVariant = !useIllusion && !!this.summonData.illusion ? this.summonData.illusion?.basePokemon.fusionVariant : this.fusionVariant; + return this.getFusionSpeciesForm(ignoreOverride, useIllusion).getIconAtlasKey( fusionFormIndex, - this.fusionShiny, - this.fusionVariant + this.isFusionShiny(), + fusionVariant + ); + } + + getIconId(ignoreOverride?: boolean, useIllusion: boolean = true): string { + const formIndex = useIllusion && this.summonData.illusion?.formIndex ? this.summonData.illusion?.formIndex : this.formIndex; + const variant = !useIllusion && !!this.summonData.illusion ? this.summonData.illusion?.basePokemon.variant : this.variant; + return this.getSpeciesForm(ignoreOverride, useIllusion).getIconId( + this.getGender(ignoreOverride, useIllusion) === Gender.FEMALE, + formIndex, + this.isBaseShiny(), + variant + ); + } + + getFusionIconId(ignoreOverride?: boolean, useIllusion: boolean = true): string { + const fusionFormIndex = useIllusion && this.summonData.illusion?.fusionFormIndex ? this.summonData.illusion?.fusionFormIndex : this.fusionFormIndex; + const fusionVariant = !useIllusion && !!this.summonData.illusion ? this.summonData.illusion?.basePokemon.fusionVariant : this.fusionVariant; + return this.getFusionSpeciesForm(ignoreOverride, useIllusion).getIconId( + this.getFusionGender(ignoreOverride, useIllusion) === Gender.FEMALE, + fusionFormIndex, + this.isFusionShiny(), + fusionVariant ); } @@ -1885,6 +1890,22 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } + isBaseShiny(useIllusion: boolean = false){ + if (!useIllusion && this.summonData.illusion) { + return this.summonData.illusion.basePokemon?.shiny || false; + } else { + return this.shiny; + } + } + + isFusionShiny(useIllusion: boolean = false){ + if (!useIllusion && this.summonData.illusion) { + return this.summonData.illusion.basePokemon?.fusionShiny || false; + } else { + return this.isFusion(useIllusion) && this.fusionShiny; + } + } + /** * * @param useIllusion - Whether we want the fake or real shininess (illusion ability). @@ -2060,7 +2081,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { includeTeraType = false, forDefend: boolean = false, ignoreOverride?: boolean, - useIllusion: boolean | "AUTO" = "AUTO" + useIllusion: boolean = false ): PokemonType[] { const types: PokemonType[] = []; @@ -2076,17 +2097,16 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } if (!types.length || !includeTeraType) { - const doIllusion: boolean = (useIllusion === "AUTO") ? !forDefend : useIllusion; if ( !ignoreOverride && this.summonData.types && this.summonData.types.length > 0 && - (!this.summonData.illusion || !doIllusion) + (!this.summonData.illusion || !useIllusion) ) { this.summonData.types.forEach(t => types.push(t)); } else { - const speciesForm = this.getSpeciesForm(ignoreOverride, doIllusion); - const fusionSpeciesForm = this.getFusionSpeciesForm(ignoreOverride, doIllusion); + const speciesForm = this.getSpeciesForm(ignoreOverride, useIllusion); + const fusionSpeciesForm = this.getFusionSpeciesForm(ignoreOverride, useIllusion); const customTypes = this.customPokemonData.types?.length > 0; // First type, checking for "permanently changed" types from ME diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index 9df7aa7813f..763b40c8555 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -710,7 +710,7 @@ export abstract class PokemonHeldItemModifier extends PersistentModifier { if (!forSummary) { const pokemon = this.getPokemon(); if (pokemon) { - const pokemonIcon = globalScene.addPokemonIcon(pokemon, -2, 10, 0, 0.5); + const pokemonIcon = globalScene.addPokemonIcon(pokemon, -2, 10, 0, 0.5, undefined, true); container.add(pokemonIcon); container.setName(pokemon.id.toString()); } diff --git a/src/overrides.ts b/src/overrides.ts index 5bbd29b355f..534a98036bd 100644 --- a/src/overrides.ts +++ b/src/overrides.ts @@ -174,7 +174,7 @@ class DefaultOverrides { readonly OPP_HAS_PASSIVE_ABILITY_OVERRIDE: boolean | null = null; readonly OPP_STATUS_OVERRIDE: StatusEffect = StatusEffect.NONE; readonly OPP_GENDER_OVERRIDE: Gender | null = null; - readonly OPP_MOVESET_OVERRIDE: Moves | Array = []; + readonly OPP_MOVESET_OVERRIDE: Moves | Array = [Moves.THUNDER_WAVE, Moves.THUNDER_WAVE, Moves.THUNDER_WAVE, Moves.THUNDER_WAVE]; readonly OPP_SHINY_OVERRIDE: boolean | null = null; readonly OPP_VARIANT_OVERRIDE: Variant | null = null; readonly OPP_IVS_OVERRIDE: number | number[] = []; diff --git a/src/ui/battle-info.ts b/src/ui/battle-info.ts index cabe897d7b6..329719689f3 100644 --- a/src/ui/battle-info.ts +++ b/src/ui/battle-info.ts @@ -465,7 +465,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { this.shinyIcon.setVisible(pokemon.isShiny()); - const types = pokemon.getTypes(true); + const types = pokemon.getTypes(true, false, undefined, true); this.type1Icon.setTexture(`pbinfo_${this.player ? "player" : "enemy"}_type${types.length > 1 ? "1" : ""}`); this.type1Icon.setFrame(PokemonType[types[0]].toLowerCase()); this.type2Icon.setVisible(types.length > 1); @@ -685,7 +685,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { this.statusIndicator.setVisible(!!this.lastStatus); } - const types = pokemon.getTypes(true); + const types = pokemon.getTypes(true, false, undefined, true); this.type1Icon.setTexture(`pbinfo_${this.player ? "player" : "enemy"}_type${types.length > 1 ? "1" : ""}`); this.type1Icon.setFrame(PokemonType[types[0]].toLowerCase()); this.type2Icon.setVisible(types.length > 1);