From 61be88e50c3fe0becd2c10045aa0d331764fc7bf Mon Sep 17 00:00:00 2001 From: Frederico Santos Date: Sun, 19 May 2024 18:21:03 +0100 Subject: [PATCH] Implemented Zero-To-Hero --- src/data/ability.ts | 33 ++++++++++++++++++++++++++++++++- src/data/pokemon-forms.ts | 4 ++++ src/overrides.ts | 4 ++-- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index b5e4a91a11c..e1e3b3bc8ce 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -1702,6 +1702,37 @@ export class PreSwitchOutHealAbAttr extends PreSwitchOutAbAttr { } } +/** + * + */ +export class PreSwitchOutFormChangeAbAttr extends PreSwitchOutAbAttr { + private formFunc: (p: Pokemon) => integer; + + constructor(formFunc: ((p: Pokemon) => integer)) { + super(); + + this.formFunc = formFunc; + } + + /** + * + * @param pokemon + * @param passive + * @param args + * @returns + */ + applyPreSwitchOut(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise { + const formIndex = this.formFunc(pokemon); + if (formIndex !== pokemon.formIndex) { + pokemon.scene.triggerPokemonFormChange(pokemon, SpeciesFormChangeManualTrigger, false); + return true; + } + + return false; + } + +} + export class PreStatChangeAbAttr extends AbAttr { applyPreStatChange(pokemon: Pokemon, passive: boolean, stat: BattleStat, cancelled: Utils.BooleanHolder, args: any[]): boolean | Promise { return false; @@ -3790,7 +3821,7 @@ export function initAbilities() { .attr(UnsuppressableAbilityAbAttr) .attr(NoTransformAbilityAbAttr) .attr(NoFusionAbilityAbAttr) - .unimplemented(), + .attr(PreSwitchOutFormChangeAbAttr, p => p.getFormKey() ? 1 : 0), new Ability(Abilities.COMMANDER, 9) .attr(UncopiableAbilityAbAttr) .attr(UnswappableAbilityAbAttr) diff --git a/src/data/pokemon-forms.ts b/src/data/pokemon-forms.ts index a8bc07e92df..f867b986901 100644 --- a/src/data/pokemon-forms.ts +++ b/src/data/pokemon-forms.ts @@ -556,6 +556,10 @@ export const pokemonFormChanges: PokemonFormChanges = { new SpeciesFormChange(Species.GRENINJA, 'battle-bond', 'ash', new SpeciesFormChangeManualTrigger(), true), new SpeciesFormChange(Species.GRENINJA, 'ash', 'battle-bond', new SpeciesFormChangeManualTrigger(), true) ], + [Species.PALAFIN] : [ + new SpeciesFormChange(Species.PALAFIN, 'zero', 'hero', new SpeciesFormChangeManualTrigger(), true), + new SpeciesFormChange(Species.PALAFIN, 'hero', 'zero', new SpeciesFormChangeManualTrigger(), true) + ], [Species.AEGISLASH]: [ new SpeciesFormChange(Species.AEGISLASH, 'blade', 'shield', new SpeciesFormChangePreMoveTrigger(Moves.KINGS_SHIELD), true, new SpeciesFormChangeCondition(p => p.hasAbility(Abilities.STANCE_CHANGE))), new SpeciesFormChange(Species.AEGISLASH, 'shield', 'blade', new SpeciesFormChangePreMoveTrigger(m => allMoves[m].category !== MoveCategory.STATUS), true, new SpeciesFormChangeCondition(p => p.hasAbility(Abilities.STANCE_CHANGE))), diff --git a/src/overrides.ts b/src/overrides.ts index b7307ab2f7f..8a093f33f4c 100644 --- a/src/overrides.ts +++ b/src/overrides.ts @@ -54,8 +54,8 @@ export const STARTING_LEVEL_OVERRIDE: integer = 0; * default is 0 to not override * @example SPECIES_OVERRIDE = Species.Bulbasaur; */ -export const STARTER_SPECIES_OVERRIDE: Species | integer = 0; -export const ABILITY_OVERRIDE: Abilities = Abilities.NONE; +export const STARTER_SPECIES_OVERRIDE: Species | integer = Species.PALAFIN; +export const ABILITY_OVERRIDE: Abilities = Abilities.ZERO_TO_HERO; export const PASSIVE_ABILITY_OVERRIDE: Abilities = Abilities.NONE; export const MOVESET_OVERRIDE: Array = []; export const SHINY_OVERRIDE: boolean = false;