From 00a2d5bbe4967b6132c367bd16f70106cb463245 Mon Sep 17 00:00:00 2001 From: Luc Date: Thu, 2 May 2024 23:29:57 -0400 Subject: [PATCH] now properly reverts to zero form --- src/data/ability.ts | 17 ++++++++++------- src/data/pokemon-forms.ts | 1 + src/field/pokemon.ts | 1 + src/phases.ts | 1 + 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 21e171fc25b..3a85484cf25 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -1950,19 +1950,20 @@ export class PostTurnFormChangeAbAttr extends PostTurnAbAttr { } } -export class ZeroToHeroAbAttr extends PreSwitchOutAbAttr { - // .attr(PostBattleInitFormChangeAbAttr, p => p.getHpRatio() <= 0.9 ? 1 : 0) - //.attr(PostSummonFormChangeAbAttr, p => p.getHpRatio() <= 0.9 ? 1 : 0) - //.attr(PostTurnFormChangeAbAttr, p => p.getHpRatio() <= 0.9 ? 1 : 0) +export class PreSwitchOutFormChangeAbAttr extends PreSwitchOutAbAttr { + private formFunc: (p: Pokemon) => integer; + constructor(formFunc: ((p: Pokemon) => integer)) { super(); - //this.formFunc = formFunc; + this.formFunc = formFunc; } applyPreSwitchOut(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise { + console.log(pokemon.getFormKey()) - if (1 !== pokemon.formIndex && pokemon.species.name == "Palafin") { + const formIndex = this.formFunc(pokemon); + if (formIndex !== pokemon.formIndex) { pokemon.scene.triggerPokemonFormChange(pokemon, SpeciesFormChangeManualTrigger, false); return true; } @@ -3354,7 +3355,9 @@ export function initAbilities() { .attr(UnsuppressableAbilityAbAttr) .attr(NoTransformAbilityAbAttr) .attr(NoFusionAbilityAbAttr) - .attr(ZeroToHeroAbAttr, p => true ? 1 : 0), + .attr(PreSwitchOutFormChangeAbAttr, p => p.getFormKey() ? 1 : 0) + .attr(PostBattleInitFormChangeAbAttr, p => p.battleData.switchesMade === 0 ? 0 : 1) + .attr(PostSummonFormChangeAbAttr,p => p.battleData.switchesMade === 0 ? 0 : 1), new Ability(Abilities.COMMANDER, 9) .attr(UncopiableAbilityAbAttr) .attr(UnswappableAbilityAbAttr) diff --git a/src/data/pokemon-forms.ts b/src/data/pokemon-forms.ts index 445d79d8d28..a1ddeb5d4ef 100644 --- a/src/data/pokemon-forms.ts +++ b/src/data/pokemon-forms.ts @@ -683,6 +683,7 @@ export const pokemonFormChanges: PokemonFormChanges = { ], [Species.PALAFIN]: [ new SpeciesFormChange(Species.PALAFIN, 'zero', 'hero', new SpeciesFormChangeManualTrigger(), true), + new SpeciesFormChange(Species.PALAFIN, 'hero', 'zero', new SpeciesFormChangeManualTrigger(), true), ], [Species.OGERPON]: [ new SpeciesFormChange(Species.OGERPON, 'teal-mask', 'wellspring-mask', new SpeciesFormChangeItemTrigger(FormChangeItem.WELLSPRING_MASK)), diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index c5036ce72c6..10674b5cac6 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -3036,6 +3036,7 @@ export class PokemonBattleData { public hitCount: integer = 0; public endured: boolean = false; public berriesEaten: BerryType[] = []; + public switchesMade: integer = 0; } export class PokemonBattleSummonData { diff --git a/src/phases.ts b/src/phases.ts index 4c2f5536268..12163a511a3 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -1433,6 +1433,7 @@ export class SwitchSummonPhase extends SummonPhase { if (this.batonPass && pokemon) pokemon.transferSummon(this.lastPokemon); + this.lastPokemon.battleData.switchesMade++; this.lastPokemon?.resetSummonData(); this.scene.triggerPokemonFormChange(pokemon, SpeciesFormChangeActiveTrigger, true);