From 4155c43a7c5831f1e168f72ce6ecdd7b133099d0 Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Sat, 16 Aug 2025 23:31:09 +0200 Subject: [PATCH] Excluded specific forms from fresh start, fixed bug with default nature --- src/data/challenge.ts | 30 ++++++++++++++++++++++++----- src/ui/starter-select-ui-handler.ts | 12 ++++++++---- src/utils/challenge-utils.ts | 4 +++- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/data/challenge.ts b/src/data/challenge.ts index 6a3097f9074..3ac09ae0be1 100644 --- a/src/data/challenge.ts +++ b/src/data/challenge.ts @@ -245,7 +245,7 @@ export abstract class Challenge { * @param _pokemon {@link Pokemon} The starter pokemon to modify. * @returns {@link boolean} Whether this function did anything. */ - applyStarterSelectModify(_dexEntry: DexEntry, _starterDataEntry: StarterDataEntry): boolean { + applyStarterSelectModify(_speciesId: SpeciesId, _dexEntry: DexEntry, _starterDataEntry: StarterDataEntry): boolean { return false; } @@ -809,7 +809,7 @@ export class FreshStartChallenge extends Challenge { return true; } - applyStarterSelectModify(dexEntry: DexEntry, starterDataEntry: StarterDataEntry): boolean { + applyStarterSelectModify(speciesId: SpeciesId, dexEntry: DexEntry, starterDataEntry: StarterDataEntry): boolean { // Remove all egg moves starterDataEntry.eggMoves = 0; console.log("I AM APPLYING, ", starterDataEntry.eggMoves); @@ -834,9 +834,29 @@ export class FreshStartChallenge extends Challenge { // Set all ivs to 15 dexEntry.ivs = [15, 15, 15, 15, 15, 15]; - // Removes shiny, variants, and any unlocked forms - const defaultDexEntry = DexAttr.NON_SHINY | DexAttr.MALE | DexAttr.FEMALE | DexAttr.DEFAULT_FORM; - dexEntry.caughtAttr &= defaultDexEntry; + // Removes shiny and variants + dexEntry.caughtAttr &= ~DexAttr.SHINY; + dexEntry.caughtAttr &= ~(DexAttr.VARIANT_2 | DexAttr.VARIANT_3); + + // Remove unlocked forms for specific species + if (speciesId === SpeciesId.ZYGARDE) { + const formMask = (DexAttr.DEFAULT_FORM << 2n) - 1n; // Sets 10%-PC to 10%-AB and 50%-PC to 50%-AB + dexEntry.caughtAttr &= formMask; + } + if ( + [ + SpeciesId.PIKACHU, + SpeciesId.EEVEE, + SpeciesId.PICHU, + SpeciesId.ROTOM, + SpeciesId.MELOETTA, + SpeciesId.FROAKIE, + SpeciesId.ROCKRUFF, + ].includes(speciesId) + ) { + const formMask = (DexAttr.DEFAULT_FORM << 1n) - 1n; // These mons are set to form 0 because they're meant to be unlocks or mid-run form changes + dexEntry.caughtAttr &= formMask; + } return true; } diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 3a6d1e297cd..82e9b8f4ce4 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -3717,20 +3717,23 @@ export class StarterSelectUiHandler extends MessageUiHandler { const copiedDexEntry = { ...dexEntry }; const copiedStarterDataEntry = { ...starterDataEntry }; if (applyChallenge) { - applyChallenges(ChallengeType.STARTER_SELECT_MODIFY, copiedDexEntry, copiedStarterDataEntry); + applyChallenges(ChallengeType.STARTER_SELECT_MODIFY, speciesId, copiedDexEntry, copiedStarterDataEntry); } return { dexEntry: { ...copiedDexEntry }, starterDataEntry: { ...copiedStarterDataEntry } }; } setSpeciesDetails(species: PokemonSpecies, options: SpeciesDetails = {}): void { let { shiny, formIndex, female, variant, abilityIndex, natureIndex, teraType } = options; - const { dexEntry, starterDataEntry } = this.getSpeciesData(species.speciesId); const forSeen: boolean = options.forSeen ?? false; const oldProps = species ? globalScene.gameData.getSpeciesDexAttrProps(species, this.dexAttrCursor) : null; const oldAbilityIndex = this.abilityCursor > -1 ? this.abilityCursor : globalScene.gameData.getStarterSpeciesDefaultAbilityIndex(species); - const oldNatureIndex = - this.natureCursor > -1 ? this.natureCursor : globalScene.gameData.getSpeciesDefaultNature(species, dexEntry); + let oldNatureIndex = -1; + if (species) { + const { dexEntry } = this.getSpeciesData(species.speciesId); + oldNatureIndex = + this.natureCursor > -1 ? this.natureCursor : globalScene.gameData.getSpeciesDefaultNature(species, dexEntry); + } this.dexAttrCursor = 0n; this.abilityCursor = -1; this.natureCursor = -1; @@ -3800,6 +3803,7 @@ export class StarterSelectUiHandler extends MessageUiHandler { this.speciesStarterMoves = []; if (species) { + const { dexEntry, starterDataEntry } = this.getSpeciesData(species.speciesId); const caughtAttr = dexEntry.caughtAttr || BigInt(0); const abilityAttr = starterDataEntry.abilityAttr; diff --git a/src/utils/challenge-utils.ts b/src/utils/challenge-utils.ts index 93768f673d9..b0c162a74ed 100644 --- a/src/utils/challenge-utils.ts +++ b/src/utils/challenge-utils.ts @@ -51,12 +51,14 @@ export function applyChallenges( /** * Apply all challenges that modify selectable starter data. * @param challengeType {@link ChallengeType} ChallengeType.STARTER_SELECT_MODIFY + * @param speciesId {@link SpeciesId} The speciesId of the pokemon * @param dexEntry {@link DexEntry} The pokedex data associated to the pokemon. * @param starterDataEntry {@link StarterDataEntry} The starter data associated to the pokemon. * @returns True if any challenge was successfully applied. */ export function applyChallenges( challengeType: ChallengeType.STARTER_SELECT_MODIFY, + speciesId: SpeciesId, dexEntry: DexEntry, starterDataEntry: StarterDataEntry, ): boolean; @@ -283,7 +285,7 @@ export function applyChallenges(challengeType: ChallengeType, ...args: any[]): b ret ||= c.applyStarterCost(args[0], args[1]); break; case ChallengeType.STARTER_SELECT_MODIFY: - ret ||= c.applyStarterSelectModify(args[0], args[1]); + ret ||= c.applyStarterSelectModify(args[0], args[1], args[2]); break; case ChallengeType.STARTER_MODIFY: ret ||= c.applyStarterModify(args[0]);