Zoroark keep illusion between battles

This commit is contained in:
Lylian 2025-03-02 22:09:57 +01:00
parent 382b0cdd0e
commit e522ab3d31
5 changed files with 35 additions and 29 deletions

View File

@ -811,8 +811,20 @@ export default class BattleScene extends SceneBase {
return true;
}
public getPlayerParty(): PlayerPokemon[] {
return this.party;
public getPlayerParty(fakeShininess: boolean = true): PlayerPokemon[] {
const party = this.party
if(!fakeShininess){
party.map(pokemon => {
pokemon.shiny = pokemon.isShiny()
pokemon.variant = pokemon.getVariant()
pokemon.name = pokemon.getNameToRender()
if(pokemon.isFusion()){
pokemon.fusionVariant = pokemon.battleData?.illusion.basePokemon!.fusionVariant ?? pokemon.fusionVariant;
pokemon.fusionShiny = pokemon.battleData?.illusion.basePokemon!.fusionShiny ?? pokemon.fusionShiny;
}
});
}
return party;
}
/**

View File

@ -4778,28 +4778,13 @@ export class IllusionPostBattleAbAttr extends PostBattleAbAttr {
* @returns {boolean} - Whether the illusion was applied.
*/
applyPostBattle(pokemon: Pokemon, passive: boolean, simulated:boolean, args: any[]): boolean {
console.log("POSTBATTLE")
pokemon.breakIllusion();
pokemon.battleData.illusion.available = true;
return true;
}
}
export class IllusionDisableAbAttr extends PostSummonAbAttr {
/**
* Illusion will be disabled if the pokemon is summoned with an illusion.
* So the pokemon can use 1 illusion per battle.
*
* @param {Pokemon} pokemon - The Pokémon with the Illusion ability.
* @param {boolean} passive - N/A
* @param {...any} args - N/A
* @returns {boolean}
*/
applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean {
pokemon.battleData.illusion.available = false;
return true;
}
}
/**
* If a Pokémon with this Ability selects a damaging move, it has a 30% chance of going first in its priority bracket. If the Ability activates, this is announced at the start of the turn (after move selection).
@ -5905,8 +5890,6 @@ export function initAbilities() {
.conditionalAttr((pokemon) => pokemon.battleData.illusion.active, IllusionBreakAbAttr, true)
//Illusion is available again after a battle
.conditionalAttr((pokemon) => pokemon.isAllowedInBattle(), IllusionPostBattleAbAttr, false)
//Illusion is not available after summon
.attr(IllusionDisableAbAttr, false)
.bypassFaint(),
new Ability(Abilities.IMPOSTER, 5)
.attr(PostSummonTransformAbAttr)

View File

@ -437,7 +437,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
const lastPokemon: Pokemon = party.filter(p => p !== this).at(-1) || this;
const speciesId = lastPokemon.species.speciesId;
if ( lastPokemon === this || this.battleData?.illusion.active ||
if ( lastPokemon === this || this.battleData.illusion.active ||
((speciesId === Species.OGERPON || speciesId === Species.TERAPAGOS) && (lastPokemon.isTerastallized() || this.isTerastallized()))) {
return false;
}
@ -455,6 +455,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
fusionGender: lastPokemon.fusionGender
};
console.log("GENERATE ILLUSION ", this.battleData.illusion.basePokemon!.name)
this.name = lastPokemon.name;
this.nickname = lastPokemon.nickname;
this.shiny = lastPokemon.shiny;
@ -465,6 +467,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.initShinySparkle();
}
this.loadAssets(false, true).then(() => this.playAnim());
this.updateInfo();
} else {
let availables: Species[] = [];
let randomIllusion: PokemonSpecies = globalScene.arena.randomSpecies(globalScene.currentBattle.waveIndex, this.level);
@ -488,11 +491,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
return true;
}
breakIllusion(): boolean {
breakIllusion(toSave: boolean = false): boolean {
console.log("breakIllusion");
if (!this.battleData?.illusion.active) {
return false;
}
this.name = this.battleData?.illusion.basePokemon!.name;
this.nickname = this.battleData?.illusion.basePokemon!.nickname;
this.shiny = this.battleData?.illusion.basePokemon!.shiny;
@ -506,8 +509,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
if (this.shiny) {
this.initShinySparkle();
}
this.loadAssets(false).then(() => this.playAnim());
this.updateInfo(true);
if(!toSave){
this.loadAssets(false).then(() => this.playAnim());
this.updateInfo(true);
}
return true;
}
@ -3961,10 +3966,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
}
resetBattleData(): void {
const illusionActive: boolean = this.battleData?.illusion.active ?? false;
console.log("RESETBATTLEDATA : ", this.getNameToRender(false))
const illusionActive: boolean = this.battleData?.illusion.active;
this.breakIllusion();
this.battleData = new PokemonBattleData();
illusionActive ? this.generateIllusion() : null;
if(illusionActive){
this.generateIllusion()
}
}
resetBattleSummonData(): void {

View File

@ -11,7 +11,7 @@ import { TrainerSlot } from "#app/data/trainer-config";
import { getRandomWeatherType } from "#app/data/weather";
import { EncounterPhaseEvent } from "#app/events/battle-scene";
import type Pokemon from "#app/field/pokemon";
import { FieldPosition } from "#app/field/pokemon";
import { FieldPosition, PlayerPokemon } from "#app/field/pokemon";
import { getPokemonNameWithAffix } from "#app/messages";
import { BoostBugSpawnModifier, IvScannerModifier, TurnHeldItemTransferModifier } from "#app/modifier/modifier";
import { ModifierPoolType, regenerateModifierPoolThresholds } from "#app/modifier/modifier-type";
@ -203,6 +203,9 @@ export class EncounterPhase extends BattlePhase {
}
if (e < (battle.double ? 2 : 1)) {
if (battle.battleType === BattleType.WILD) {
for(const pokemon of globalScene.getPlayerField()){
applyPreSummonAbAttrs(PreSummonAbAttr, pokemon, []);
}
applyPreSummonAbAttrs(PreSummonAbAttr, enemyPokemon, []);
globalScene.field.add(enemyPokemon);
battle.seenEnemyPartyMemberIds.add(enemyPokemon.id);

View File

@ -949,7 +949,7 @@ export class GameData {
seed: globalScene.seed,
playTime: globalScene.sessionPlayTime,
gameMode: globalScene.gameMode.modeId,
party: globalScene.getPlayerParty().map(p => new PokemonData(p)),
party: globalScene.getPlayerParty(false).map(p => new PokemonData(p)),
enemyParty: globalScene.getEnemyParty().map(p => new PokemonData(p)),
modifiers: globalScene.findModifiers(() => true).map(m => new PersistentModifierData(m, true)),
enemyModifiers: globalScene.findModifiers(() => true, false).map(m => new PersistentModifierData(m, false)),