mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-05 16:02:20 +02:00
fix illusion icon in party ui handler
This commit is contained in:
parent
c10f01c7ac
commit
b3d271a654
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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<Moves> = [];
|
||||
readonly OPP_MOVESET_OVERRIDE: Moves | Array<Moves> = [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[] = [];
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user