[Bug] Fix some moves using illusion type instead of real type (#5772)

* fix revelation dance using the type of the illusion instead of the actual type

* fix other move that might get the illusion type as well

* fix other move that might get the illusion type as well

* fix abilities that might get the illusion type as well

* fix illusion icon in party ui handler

* Fix TSDoc for `Pokemon#getTypes`

* Remove now-unnecessary changes to `.getTypes()` calls

Revert `overrides.ts` changes

* Replace `|| false` with `!!`

---------

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
Lylian BALL 2025-05-06 03:31:11 +02:00 committed by GitHub
parent e677e2725e
commit 4f541a8dce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 69 additions and 49 deletions

View File

@ -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;

View File

@ -43,10 +43,9 @@ import { PokemonTransformPhase } from "#app/phases/pokemon-transform-phase";
import { allAbilities } from "#app/data/data-lists";
import { AbAttr } from "#app/data/abilities/ab-attrs/ab-attr";
import { Ability } from "#app/data/abilities/ability-class";
import { TrainerVariant } from "#app/field/trainer";
// Enum imports
import { Stat, type BattleStat , BATTLE_STATS, EFFECTIVE_STATS, getStatKey, type EffectiveStat } from "#enums/stat";
import { Stat, type BattleStat, BATTLE_STATS, EFFECTIVE_STATS, getStatKey, type EffectiveStat } from "#enums/stat";
import { PokemonType } from "#enums/pokemon-type";
import { PokemonAnimType } from "#enums/pokemon-anim-type";
import { StatusEffect } from "#enums/status-effect";

View File

@ -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;
} else {
return this.shiny;
}
}
isFusionShiny(useIllusion: boolean = false){
if (!useIllusion && this.summonData.illusion) {
return !!this.summonData.illusion.basePokemon?.fusionShiny;
} else {
return this.isFusion(useIllusion) && this.fusionShiny;
}
}
/**
*
* @param useIllusion - Whether we want the fake or real shininess (illusion ability).
@ -2053,14 +2074,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
* @param includeTeraType - `true` to include tera-formed type; Default: `false`
* @param forDefend - `true` if the pokemon is defending from an attack; Default: `false`
* @param ignoreOverride - If `true`, ignore ability changing effects; Default: `false`
* @param useIllusion - `true` to return the types of the illusion instead of the actual types; "AUTO" will depend on forDefend param; Default: "AUTO"
* @param useIllusion - `true` to return the types of the illusion instead of the actual types; Default: `false`
* @returns array of {@linkcode PokemonType}
*/
public getTypes(
includeTeraType = false,
forDefend: boolean = false,
ignoreOverride?: boolean,
useIllusion: boolean | "AUTO" = "AUTO"
ignoreOverride: boolean = false,
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

View File

@ -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());
}

View File

@ -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);