Excluded specific forms from fresh start, fixed bug with default nature

This commit is contained in:
Wlowscha 2025-08-16 23:31:09 +02:00
parent e45f24c124
commit 4155c43a7c
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
3 changed files with 36 additions and 10 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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]);