From 7fea709218a86216b8495dd1e800f02fa4503b6c Mon Sep 17 00:00:00 2001 From: Frederico Santos Date: Mon, 20 May 2024 04:06:48 +0100 Subject: [PATCH] Zero to Hero: form reset on biome/trainer --- src/battle-scene.ts | 30 ++++++++++++++++++++++++++++-- src/data/ability.ts | 6 +++--- src/data/pokemon-species.ts | 2 +- src/overrides.ts | 4 ++-- src/phases.ts | 8 +++----- 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 61f585cfa60..afca4340d5c 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -19,7 +19,7 @@ import { allMoves } from "./data/move"; import { initMoves } from './data/move'; import { ModifierPoolType, getDefaultModifierTypeForTier, getEnemyModifierTypesForWave, getLuckString, getLuckTextTint, getModifierPoolForType, getPartyLuckValue } from './modifier/modifier-type'; import AbilityBar from './ui/ability-bar'; -import { BlockItemTheftAbAttr, DoubleBattleChanceAbAttr, IncrementMovePriorityAbAttr, applyAbAttrs, initAbilities } from './data/ability'; +import { BlockItemTheftAbAttr, DoubleBattleChanceAbAttr, IncrementMovePriorityAbAttr, PostBattleInitFormChangeAbAttr, applyAbAttrs, applyPostBattleAbAttrs, applyPostBattleInitAbAttrs, initAbilities } from './data/ability'; import { Abilities } from "./data/enums/abilities"; import { allAbilities } from "./data/ability"; import Battle, { BattleType, FixedBattleConfig, fixedBattles } from './battle'; @@ -933,7 +933,7 @@ export default class BattleScene extends SceneBase { if (resetArenaState) { pokemon.resetBattleData(); - this.triggerPokemonFormChange(pokemon, SpeciesFormChangeManualTrigger); + this.resetPokemonFormChange(pokemon, SpeciesFormChangeManualTrigger); } this.triggerPokemonFormChange(pokemon, SpeciesFormChangeTimeOfDayTrigger); } @@ -1964,6 +1964,32 @@ export default class BattleScene extends SceneBase { return false; } + resetPokemonFormChange(pokemon: Pokemon, formChangeTriggerType: {new( ... args: any[]): SpeciesFormChangeTrigger}, delayed: boolean = false, modal: boolean = false): boolean { + if (pokemonFormChanges.hasOwnProperty(pokemon.species.speciesId)) { + + // Find the base form that matches the same ability + const matchingFormChange = pokemonFormChanges[pokemon.species.speciesId].find(fc => fc.findTrigger(formChangeTriggerType) && + fc.formKey === pokemon.species.forms[0].formKey && + fc.canChange(pokemon)); + if (matchingFormChange) { + let phase: Phase; + if (pokemon instanceof PlayerPokemon && !matchingFormChange.quiet) + phase = new FormChangePhase(this, pokemon, matchingFormChange, modal); + else + phase = new QuietFormChangePhase(this, pokemon, matchingFormChange); + if (pokemon instanceof PlayerPokemon && !matchingFormChange.quiet && modal) + this.overridePhase(phase); + else if (delayed) + this.pushPhase(phase); + else + this.unshiftPhase(phase); + return true; + } + } + + return false; + } + validateAchvs(achvType: { new(...args: any[]): Achv }, ...args: any[]): void { const filteredAchvs = Object.values(achvs).filter(a => a instanceof achvType); for (let achv of filteredAchvs) diff --git a/src/data/ability.ts b/src/data/ability.ts index d9dae04d1ce..e7d6d19b652 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -3595,9 +3595,9 @@ export function initAbilities() { .attr(UnsuppressableAbilityAbAttr) .attr(NoFusionAbilityAbAttr), new Ability(Abilities.POWER_CONSTRUCT, 7) // TODO: 10% Power Construct Zygarde isn't accounted for yet. If changed, update Zygarde's getSpeciesFormIndex entry accordingly - .attr(PostBattleInitFormChangeAbAttr, p => p.getHpRatio() <= 0.5 || p.getFormKey() === 'complete' ? 4 : 2) - .attr(PostSummonFormChangeAbAttr, p => p.getHpRatio() <= 0.5 || p.getFormKey() === 'complete' ? 4 : 2) - .attr(PostTurnFormChangeAbAttr, p => p.getHpRatio() <= 0.5 || p.getFormKey() === 'complete' ? 4 : 2) + .attr(PostBattleInitFormChangeAbAttr, p => p.getHpRatio() <= 0.5 || p.getFormKey() === 'complete' ? 4 : 0) + .attr(PostSummonFormChangeAbAttr, p => p.getHpRatio() <= 0.5 || p.getFormKey() === 'complete' ? 4 : 0) + .attr(PostTurnFormChangeAbAttr, p => p.getHpRatio() <= 0.5 || p.getFormKey() === 'complete' ? 4 : 0) .attr(UncopiableAbilityAbAttr) .attr(UnswappableAbilityAbAttr) .attr(UnsuppressableAbilityAbAttr) diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index 5032bd0dfbc..79f55d0780e 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -1942,9 +1942,9 @@ export function initSpecies() { ), new PokemonSpecies(Species.YVELTAL, 6, false, true, false, "Destruction Pokémon", Type.DARK, Type.FLYING, 5.8, 203, Abilities.DARK_AURA, Abilities.NONE, Abilities.NONE, 680, 126, 131, 95, 131, 98, 99, 45, 0, 340, GrowthRate.SLOW, null, false), new PokemonSpecies(Species.ZYGARDE, 6, false, true, false, "Order Pokémon", Type.DRAGON, Type.GROUND, 5, 305, Abilities.AURA_BREAK, Abilities.NONE, Abilities.NONE, 600, 108, 100, 121, 81, 95, 95, 3, 0, 300, GrowthRate.SLOW, null, false, false, + new PokemonForm("50% Forme Power Construct", "50-pc", Type.DRAGON, Type.GROUND, 5, 305, Abilities.POWER_CONSTRUCT, Abilities.NONE, Abilities.NONE, 600, 108, 100, 121, 81, 95, 95, 3, 0, 300, false, ""), new PokemonForm("50% Forme", "50", Type.DRAGON, Type.GROUND, 5, 305, Abilities.AURA_BREAK, Abilities.NONE, Abilities.NONE, 600, 108, 100, 121, 81, 95, 95, 3, 0, 300, false, ""), new PokemonForm("10% Forme", "10", Type.DRAGON, Type.GROUND, 1.2, 33.5, Abilities.AURA_BREAK, Abilities.NONE, Abilities.NONE, 486, 54, 100, 71, 61, 85, 115, 3, 0, 300), - new PokemonForm("50% Forme Power Construct", "50-pc", Type.DRAGON, Type.GROUND, 5, 305, Abilities.POWER_CONSTRUCT, Abilities.NONE, Abilities.NONE, 600, 108, 100, 121, 81, 95, 95, 3, 0, 300, false, ""), new PokemonForm("10% Forme Power Construct", "10-pc", Type.DRAGON, Type.GROUND, 1.2, 33.5, Abilities.POWER_CONSTRUCT, Abilities.NONE, Abilities.NONE, 486, 54, 100, 71, 61, 85, 115, 3, 0, 300, false, "10"), new PokemonForm("Complete Forme", "complete", Type.DRAGON, Type.GROUND, 4.5, 610, Abilities.POWER_CONSTRUCT, Abilities.NONE, Abilities.NONE, 708, 216, 100, 121, 91, 95, 85, 3, 0, 300), ), diff --git a/src/overrides.ts b/src/overrides.ts index 8a093f33f4c..b7307ab2f7f 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 = Species.PALAFIN; -export const ABILITY_OVERRIDE: Abilities = Abilities.ZERO_TO_HERO; +export const STARTER_SPECIES_OVERRIDE: Species | integer = 0; +export const ABILITY_OVERRIDE: Abilities = Abilities.NONE; export const PASSIVE_ABILITY_OVERRIDE: Abilities = Abilities.NONE; export const MOVESET_OVERRIDE: Array = []; export const SHINY_OVERRIDE: boolean = false; diff --git a/src/phases.ts b/src/phases.ts index 1d4d0ba5f34..744b6b5fb9d 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2056,12 +2056,10 @@ export class TurnStartPhase extends FieldPhase { this.scene.unshiftPhase(new AttemptCapturePhase(this.scene, turnCommand.targets[0] % 2, turnCommand.cursor)); break; case Command.POKEMON: + this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, pokemon.getFieldIndex(), turnCommand.cursor, true, turnCommand.args[0] as boolean, pokemon.isPlayer())); + break; case Command.RUN: - const isSwitch = turnCommand.command === Command.POKEMON; - if (isSwitch) - this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, pokemon.getFieldIndex(), turnCommand.cursor, true, turnCommand.args[0] as boolean, pokemon.isPlayer())); - else - this.scene.unshiftPhase(new AttemptRunPhase(this.scene, pokemon.getFieldIndex())); + this.scene.unshiftPhase(new AttemptRunPhase(this.scene, pokemon.getFieldIndex())); break; } }