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. * @param _pokemon {@link Pokemon} The starter pokemon to modify.
* @returns {@link boolean} Whether this function did anything. * @returns {@link boolean} Whether this function did anything.
*/ */
applyStarterSelectModify(_dexEntry: DexEntry, _starterDataEntry: StarterDataEntry): boolean { applyStarterSelectModify(_speciesId: SpeciesId, _dexEntry: DexEntry, _starterDataEntry: StarterDataEntry): boolean {
return false; return false;
} }
@ -809,7 +809,7 @@ export class FreshStartChallenge extends Challenge {
return true; return true;
} }
applyStarterSelectModify(dexEntry: DexEntry, starterDataEntry: StarterDataEntry): boolean { applyStarterSelectModify(speciesId: SpeciesId, dexEntry: DexEntry, starterDataEntry: StarterDataEntry): boolean {
// Remove all egg moves // Remove all egg moves
starterDataEntry.eggMoves = 0; starterDataEntry.eggMoves = 0;
console.log("I AM APPLYING, ", starterDataEntry.eggMoves); console.log("I AM APPLYING, ", starterDataEntry.eggMoves);
@ -834,9 +834,29 @@ export class FreshStartChallenge extends Challenge {
// Set all ivs to 15 // Set all ivs to 15
dexEntry.ivs = [15, 15, 15, 15, 15, 15]; dexEntry.ivs = [15, 15, 15, 15, 15, 15];
// Removes shiny, variants, and any unlocked forms // Removes shiny and variants
const defaultDexEntry = DexAttr.NON_SHINY | DexAttr.MALE | DexAttr.FEMALE | DexAttr.DEFAULT_FORM; dexEntry.caughtAttr &= ~DexAttr.SHINY;
dexEntry.caughtAttr &= defaultDexEntry; 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; return true;
} }

View File

@ -3717,20 +3717,23 @@ export class StarterSelectUiHandler extends MessageUiHandler {
const copiedDexEntry = { ...dexEntry }; const copiedDexEntry = { ...dexEntry };
const copiedStarterDataEntry = { ...starterDataEntry }; const copiedStarterDataEntry = { ...starterDataEntry };
if (applyChallenge) { if (applyChallenge) {
applyChallenges(ChallengeType.STARTER_SELECT_MODIFY, copiedDexEntry, copiedStarterDataEntry); applyChallenges(ChallengeType.STARTER_SELECT_MODIFY, speciesId, copiedDexEntry, copiedStarterDataEntry);
} }
return { dexEntry: { ...copiedDexEntry }, starterDataEntry: { ...copiedStarterDataEntry } }; return { dexEntry: { ...copiedDexEntry }, starterDataEntry: { ...copiedStarterDataEntry } };
} }
setSpeciesDetails(species: PokemonSpecies, options: SpeciesDetails = {}): void { setSpeciesDetails(species: PokemonSpecies, options: SpeciesDetails = {}): void {
let { shiny, formIndex, female, variant, abilityIndex, natureIndex, teraType } = options; let { shiny, formIndex, female, variant, abilityIndex, natureIndex, teraType } = options;
const { dexEntry, starterDataEntry } = this.getSpeciesData(species.speciesId);
const forSeen: boolean = options.forSeen ?? false; const forSeen: boolean = options.forSeen ?? false;
const oldProps = species ? globalScene.gameData.getSpeciesDexAttrProps(species, this.dexAttrCursor) : null; const oldProps = species ? globalScene.gameData.getSpeciesDexAttrProps(species, this.dexAttrCursor) : null;
const oldAbilityIndex = const oldAbilityIndex =
this.abilityCursor > -1 ? this.abilityCursor : globalScene.gameData.getStarterSpeciesDefaultAbilityIndex(species); this.abilityCursor > -1 ? this.abilityCursor : globalScene.gameData.getStarterSpeciesDefaultAbilityIndex(species);
const oldNatureIndex = let oldNatureIndex = -1;
if (species) {
const { dexEntry } = this.getSpeciesData(species.speciesId);
oldNatureIndex =
this.natureCursor > -1 ? this.natureCursor : globalScene.gameData.getSpeciesDefaultNature(species, dexEntry); this.natureCursor > -1 ? this.natureCursor : globalScene.gameData.getSpeciesDefaultNature(species, dexEntry);
}
this.dexAttrCursor = 0n; this.dexAttrCursor = 0n;
this.abilityCursor = -1; this.abilityCursor = -1;
this.natureCursor = -1; this.natureCursor = -1;
@ -3800,6 +3803,7 @@ export class StarterSelectUiHandler extends MessageUiHandler {
this.speciesStarterMoves = []; this.speciesStarterMoves = [];
if (species) { if (species) {
const { dexEntry, starterDataEntry } = this.getSpeciesData(species.speciesId);
const caughtAttr = dexEntry.caughtAttr || BigInt(0); const caughtAttr = dexEntry.caughtAttr || BigInt(0);
const abilityAttr = starterDataEntry.abilityAttr; const abilityAttr = starterDataEntry.abilityAttr;

View File

@ -51,12 +51,14 @@ export function applyChallenges(
/** /**
* Apply all challenges that modify selectable starter data. * Apply all challenges that modify selectable starter data.
* @param challengeType {@link ChallengeType} ChallengeType.STARTER_SELECT_MODIFY * @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 dexEntry {@link DexEntry} The pokedex data associated to the pokemon.
* @param starterDataEntry {@link StarterDataEntry} The starter data associated to the pokemon. * @param starterDataEntry {@link StarterDataEntry} The starter data associated to the pokemon.
* @returns True if any challenge was successfully applied. * @returns True if any challenge was successfully applied.
*/ */
export function applyChallenges( export function applyChallenges(
challengeType: ChallengeType.STARTER_SELECT_MODIFY, challengeType: ChallengeType.STARTER_SELECT_MODIFY,
speciesId: SpeciesId,
dexEntry: DexEntry, dexEntry: DexEntry,
starterDataEntry: StarterDataEntry, starterDataEntry: StarterDataEntry,
): boolean; ): boolean;
@ -283,7 +285,7 @@ export function applyChallenges(challengeType: ChallengeType, ...args: any[]): b
ret ||= c.applyStarterCost(args[0], args[1]); ret ||= c.applyStarterCost(args[0], args[1]);
break; break;
case ChallengeType.STARTER_SELECT_MODIFY: case ChallengeType.STARTER_SELECT_MODIFY:
ret ||= c.applyStarterSelectModify(args[0], args[1]); ret ||= c.applyStarterSelectModify(args[0], args[1], args[2]);
break; break;
case ChallengeType.STARTER_MODIFY: case ChallengeType.STARTER_MODIFY:
ret ||= c.applyStarterModify(args[0]); ret ||= c.applyStarterModify(args[0]);