now properly reverts to zero form

This commit is contained in:
Luc 2024-05-02 23:29:57 -04:00
parent ca6c3448eb
commit 00a2d5bbe4
4 changed files with 13 additions and 7 deletions

View File

@ -1950,19 +1950,20 @@ export class PostTurnFormChangeAbAttr extends PostTurnAbAttr {
} }
} }
export class ZeroToHeroAbAttr extends PreSwitchOutAbAttr { export class PreSwitchOutFormChangeAbAttr extends PreSwitchOutAbAttr {
// .attr(PostBattleInitFormChangeAbAttr, p => p.getHpRatio() <= 0.9 ? 1 : 0) private formFunc: (p: Pokemon) => integer;
//.attr(PostSummonFormChangeAbAttr, p => p.getHpRatio() <= 0.9 ? 1 : 0)
//.attr(PostTurnFormChangeAbAttr, p => p.getHpRatio() <= 0.9 ? 1 : 0)
constructor(formFunc: ((p: Pokemon) => integer)) { constructor(formFunc: ((p: Pokemon) => integer)) {
super(); super();
//this.formFunc = formFunc; this.formFunc = formFunc;
} }
applyPreSwitchOut(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise<boolean> { applyPreSwitchOut(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise<boolean> {
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); pokemon.scene.triggerPokemonFormChange(pokemon, SpeciesFormChangeManualTrigger, false);
return true; return true;
} }
@ -3354,7 +3355,9 @@ export function initAbilities() {
.attr(UnsuppressableAbilityAbAttr) .attr(UnsuppressableAbilityAbAttr)
.attr(NoTransformAbilityAbAttr) .attr(NoTransformAbilityAbAttr)
.attr(NoFusionAbilityAbAttr) .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) new Ability(Abilities.COMMANDER, 9)
.attr(UncopiableAbilityAbAttr) .attr(UncopiableAbilityAbAttr)
.attr(UnswappableAbilityAbAttr) .attr(UnswappableAbilityAbAttr)

View File

@ -683,6 +683,7 @@ export const pokemonFormChanges: PokemonFormChanges = {
], ],
[Species.PALAFIN]: [ [Species.PALAFIN]: [
new SpeciesFormChange(Species.PALAFIN, 'zero', 'hero', new SpeciesFormChangeManualTrigger(), true), new SpeciesFormChange(Species.PALAFIN, 'zero', 'hero', new SpeciesFormChangeManualTrigger(), true),
new SpeciesFormChange(Species.PALAFIN, 'hero', 'zero', new SpeciesFormChangeManualTrigger(), true),
], ],
[Species.OGERPON]: [ [Species.OGERPON]: [
new SpeciesFormChange(Species.OGERPON, 'teal-mask', 'wellspring-mask', new SpeciesFormChangeItemTrigger(FormChangeItem.WELLSPRING_MASK)), new SpeciesFormChange(Species.OGERPON, 'teal-mask', 'wellspring-mask', new SpeciesFormChangeItemTrigger(FormChangeItem.WELLSPRING_MASK)),

View File

@ -3036,6 +3036,7 @@ export class PokemonBattleData {
public hitCount: integer = 0; public hitCount: integer = 0;
public endured: boolean = false; public endured: boolean = false;
public berriesEaten: BerryType[] = []; public berriesEaten: BerryType[] = [];
public switchesMade: integer = 0;
} }
export class PokemonBattleSummonData { export class PokemonBattleSummonData {

View File

@ -1433,6 +1433,7 @@ export class SwitchSummonPhase extends SummonPhase {
if (this.batonPass && pokemon) if (this.batonPass && pokemon)
pokemon.transferSummon(this.lastPokemon); pokemon.transferSummon(this.lastPokemon);
this.lastPokemon.battleData.switchesMade++;
this.lastPokemon?.resetSummonData(); this.lastPokemon?.resetSummonData();
this.scene.triggerPokemonFormChange(pokemon, SpeciesFormChangeActiveTrigger, true); this.scene.triggerPokemonFormChange(pokemon, SpeciesFormChangeActiveTrigger, true);