Add WiP changes for Nuzlocke mode

This commit is contained in:
Flashfyre 2024-05-13 14:01:49 -04:00
parent 62224aa3c9
commit 6a1da862d4
15 changed files with 2210 additions and 33 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@ -626,6 +626,7 @@ export default class BattleScene extends SceneBase {
}
if (postProcess)
postProcess(pokemon);
pokemon.calculateStats();
pokemon.init();
return pokemon;
}
@ -805,7 +806,7 @@ export default class BattleScene extends SceneBase {
const playerField = this.getPlayerField();
if (this.gameMode.hasFixedBattles && fixedBattles.hasOwnProperty(newWaveIndex) && trainerData === undefined) {
if (this.gameMode.hasFixedBattles && fixedBattles.hasOwnProperty(newWaveIndex) && fixedBattles[newWaveIndex].condition(this) && trainerData === undefined) {
battleConfig = fixedBattles[newWaveIndex];
newDouble = battleConfig.double;
newBattleType = battleConfig.battleType;
@ -816,14 +817,14 @@ export default class BattleScene extends SceneBase {
if (!this.gameMode.hasTrainers)
newBattleType = BattleType.WILD;
else if (battleType === undefined)
newBattleType = this.gameMode.isWaveTrainer(newWaveIndex, this.arena) ? BattleType.TRAINER : BattleType.WILD;
newBattleType = this.gameMode.isWaveTrainer(newWaveIndex, this) ? BattleType.TRAINER : BattleType.WILD;
else
newBattleType = battleType;
if (newBattleType === BattleType.TRAINER) {
const trainerType = this.arena.randomTrainerType(newWaveIndex);
let doubleTrainer = false;
if (trainerConfigs[trainerType].doubleOnly)
if (trainerConfigs[trainerType].doubleOnly && trainerConfigs[trainerType].hasGenders)
doubleTrainer = true;
else if (trainerConfigs[trainerType].hasDouble) {
const doubleChance = new Utils.IntegerHolder(newWaveIndex % 10 === 0 ? 32 : 8);
@ -884,7 +885,7 @@ export default class BattleScene extends SceneBase {
isNewBiome = !Utils.randSeedInt(6 - biomeWaves);
}, lastBattle.waveIndex << 4);
}
const resetArenaState = (isNewBiome || this.currentBattle.battleType === BattleType.TRAINER || this.currentBattle.battleSpec === BattleSpec.FINAL_BOSS) && !this.gameMode.hasNoReturns;
const resetArenaState = (isNewBiome || this.currentBattle.battleType === BattleType.TRAINER || [ BattleSpec.FINAL_BOSS, BattleSpec.NUZLOCKE_BOSS ].includes(this.currentBattle.battleSpec)) && !this.gameMode.hasNoReturns;
this.getEnemyParty().forEach(enemyPokemon => enemyPokemon.destroy());
this.trySpreadPokerus();
if (!isNewBiome && (newWaveIndex % 10) == 5)

View File

@ -92,7 +92,7 @@ export default class Battle {
let spec = BattleSpec.DEFAULT;
if (this.gameMode.isClassic) {
if (this.waveIndex === 200)
spec = BattleSpec.FINAL_BOSS;
spec = !this.gameMode.isNuzlocke ? BattleSpec.FINAL_BOSS : BattleSpec.NUZLOCKE_BOSS;
}
this.battleSpec = spec;
}
@ -186,7 +186,7 @@ export default class Battle {
if (!this.started && this.trainer.config.encounterBgm && this.trainer.getEncounterMessages()?.length)
return `encounter_${this.trainer.getEncounterBgm()}`;
return this.trainer.getBattleBgm();
} else if (this.gameMode.isClassic && this.waveIndex > 195 && this.battleSpec !== BattleSpec.FINAL_BOSS)
} else if (this.gameMode.isClassic && this.waveIndex > 195 && ![ BattleSpec.FINAL_BOSS, BattleSpec.NUZLOCKE_BOSS ].includes(this.battleSpec))
return 'end_summit';
for (let pokemon of battlers) {
if (this.battleSpec === BattleSpec.FINAL_BOSS) {
@ -256,6 +256,7 @@ export class FixedBattleConfig {
public getTrainer: GetTrainerFunc;
public getEnemyParty: GetEnemyPartyFunc;
public seedOffsetWaveIndex: integer;
public condition: (scene: BattleScene) => boolean;
setBattleType(battleType: BattleType): FixedBattleConfig {
this.battleType = battleType;
@ -281,6 +282,11 @@ export class FixedBattleConfig {
this.seedOffsetWaveIndex = seedOffsetWaveIndex;
return this;
}
setCondition(condition: (scene: BattleScene) => boolean): FixedBattleConfig {
this.condition = condition;
return this;
}
}
function getRandomTrainerFunc(trainerPool: (TrainerType | TrainerType[])[]): GetTrainerFunc {
@ -325,5 +331,8 @@ export const fixedBattles: FixedBattleConfigs = {
[190]: new FixedBattleConfig().setBattleType(BattleType.TRAINER).setSeedOffsetWave(182)
.setGetTrainerFunc(getRandomTrainerFunc([ TrainerType.BLUE, [ TrainerType.RED, TrainerType.LANCE_CHAMPION ], [ TrainerType.STEVEN, TrainerType.WALLACE ], TrainerType.CYNTHIA, [ TrainerType.ALDER, TrainerType.IRIS ], TrainerType.DIANTHA, TrainerType.HAU, [ TrainerType.GEETA, TrainerType.NEMONA ], TrainerType.KIERAN, TrainerType.LEON ])),
[195]: new FixedBattleConfig().setBattleType(BattleType.TRAINER)
.setGetTrainerFunc(scene => new Trainer(scene, TrainerType.RIVAL_6, scene.gameData.gender === PlayerGender.MALE ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT))
.setGetTrainerFunc(scene => new Trainer(scene, TrainerType.RIVAL_6, scene.gameData.gender === PlayerGender.MALE ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT)),
[200]: new FixedBattleConfig().setBattleType(BattleType.TRAINER)
.setGetTrainerFunc(scene => new Trainer(scene, TrainerType.NUZLEAF, TrainerVariant.DEFAULT))
.setCondition(scene => scene.gameMode.isNuzlocke)
};

View File

@ -2269,7 +2269,12 @@ export const trainerTypeDialogue = {
$@c{smile_ehalf}Thank you.`
]
}
]
],
[TrainerType.NUZLEAF]: {
encounter: [
`You've done well to make it this far.\nI am Nuzleaf, and this is your final test.`
]
}
};
export const battleSpecDialogue = {
@ -2299,15 +2304,15 @@ export function initTrainerTypeDialogue(): void {
const trainerTypes = Object.keys(trainerTypeDialogue).map(t => parseInt(t) as TrainerType);
for (let trainerType of trainerTypes) {
const messages = trainerTypeDialogue[trainerType];
const messageTypes = [ 'encounter', 'victory', 'defeat' ];
for (let messageType of messageTypes) {
if (Array.isArray(messages)) {
if (messages[0][messageType])
trainerConfigs[trainerType][`${messageType}Messages`] = messages[0][messageType];
if (messages.length > 1)
trainerConfigs[trainerType][`female${messageType.slice(0, 1).toUpperCase()}${messageType.slice(1)}Messages`] = messages[1][messageType];
} else
trainerConfigs[trainerType][`${messageType}Messages`] = messages[messageType];
}
const messageTypes = [ 'encounter', 'victory', 'defeat' ];
for (let messageType of messageTypes) {
if (Array.isArray(messages)) {
if (messages[0][messageType])
trainerConfigs[trainerType][`${messageType}Messages`] = messages[0][messageType];
if (messages.length > 1)
trainerConfigs[trainerType][`female${messageType.slice(0, 1).toUpperCase()}${messageType.slice(1)}Messages`] = messages[1][messageType];
} else
trainerConfigs[trainerType][`${messageType}Messages`] = messages[messageType];
}
}
}

View File

@ -180,5 +180,6 @@ export enum TrainerType {
RIVAL_3,
RIVAL_4,
RIVAL_5,
RIVAL_6
RIVAL_6,
NUZLEAF = 400
}

View File

@ -6,7 +6,7 @@ import { TrainerType } from "./enums/trainer-type";
import { Moves } from "./enums/moves";
import { PokeballType } from "./pokeball";
import { pokemonEvolutions, pokemonPrevolutions } from "./pokemon-evolutions";
import PokemonSpecies, { PokemonSpeciesFilter, getPokemonSpecies } from "./pokemon-species";
import PokemonSpecies, { PokemonSpeciesFilter, SpeciesFormKey, getPokemonSpecies } from "./pokemon-species";
import { Species } from "./enums/species";
import { tmSpecies } from "./tms";
import { Type } from "./type";
@ -155,7 +155,9 @@ export const trainerPartyTemplates = {
RIVAL_3: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE, false, true), new TrainerPartyTemplate(1, PartyMemberStrength.WEAK, false, true)),
RIVAL_4: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), new TrainerPartyTemplate(2, PartyMemberStrength.AVERAGE, false, true), new TrainerPartyTemplate(1, PartyMemberStrength.WEAK, false, true)),
RIVAL_5: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), new TrainerPartyTemplate(3, PartyMemberStrength.AVERAGE, false, true), new TrainerPartyTemplate(1, PartyMemberStrength.STRONG)),
RIVAL_6: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), new TrainerPartyTemplate(3, PartyMemberStrength.AVERAGE, false, true), new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER))
RIVAL_6: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), new TrainerPartyTemplate(3, PartyMemberStrength.AVERAGE, false, true), new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER)),
NUZLEAF: new TrainerPartyTemplate(1, PartyMemberStrength.STRONG, false, true)//new TrainerPartyTemplate(5, PartyMemberStrength.STRONG, false, true),
};
type PartyTemplateFunc = (scene: BattleScene) => TrainerPartyTemplate;
@ -867,11 +869,45 @@ export const trainerConfigs: TrainerConfigs = {
p.shiny = true;
p.variant = 1;
p.formIndex = 1;
p.generateName();
}))
.setGenModifiersFunc(party => {
const starter = party[0];
return [ modifierTypes.TERA_SHARD().generateType(null, [ starter.species.type1 ]).withIdFromFunc(modifierTypes.TERA_SHARD).newModifier(starter) as PersistentModifier ];
}),
[TrainerType.NUZLEAF]: new TrainerConfig((t = TrainerType.NUZLEAF)).setName('Nuzleaf').setBoss().setEncounterBgm('final').setBattleBgm('battle_final').setPartyTemplates(trainerPartyTemplates.NUZLEAF)
.setPartyMemberFunc(0, getSpeciesFilterRandomPartyMemberFunc((species: PokemonSpecies) => species.baseTotal >= 540, TrainerSlot.TRAINER, false,
(p => {
p.level = 200;
p.setBoss(true, 1);
})))
.setPartyMemberFunc(1, getSpeciesFilterRandomPartyMemberFunc((species: PokemonSpecies) => species.baseTotal >= 540, TrainerSlot.TRAINER, false,
(p => {
p.level = 200;
p.setBoss(true, 1);
})))
.setPartyMemberFunc(2, getSpeciesFilterRandomPartyMemberFunc((species: PokemonSpecies) => !pokemonEvolutions.hasOwnProperty(species.speciesId) && species.forms.some(f => f.formKey.includes(SpeciesFormKey.MEGA)), TrainerSlot.TRAINER, false,
(p => {
p.level = 200;
p.formIndex = p.species.forms.findIndex(f => f.formKey.includes(SpeciesFormKey.MEGA));
p.setBoss(true, 2);
p.generateName();
})
))
.setPartyMemberFunc(3, getSpeciesFilterRandomPartyMemberFunc((species: PokemonSpecies) => !pokemonEvolutions.hasOwnProperty(species.speciesId) && species.forms.some(f => f.formKey.includes(SpeciesFormKey.GIGANTAMAX)), TrainerSlot.TRAINER, false,
(p => {
p.level = 200;
p.formIndex = p.species.forms.findIndex(f => f.formKey.includes(SpeciesFormKey.GIGANTAMAX));
p.setBoss(true, 2);
p.generateName();
})
))
.setPartyMemberFunc(4, getSpeciesFilterRandomPartyMemberFunc((species: PokemonSpecies) => species.baseTotal >= 540, TrainerSlot.TRAINER, false,
(p => {
p.level = 200;
p.setBoss(true, 1);
})))
.setSpeciesFilter(species => species.baseTotal >= 540)
};
(function() {

View File

@ -1,4 +1,5 @@
export enum BattleSpec {
DEFAULT,
FINAL_BOSS
FINAL_BOSS,
NUZLOCKE_BOSS
}

View File

@ -1795,6 +1795,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
transitionIndex = i;
i = 0;
rate = 0.85;
let frameProgress = 0;
@ -1810,6 +1811,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
delay: Utils.fixedInt(delay),
repeat: -1,
callback: () => {
++i;
frameThreshold = sprite.anims.msPerFrame / rate;
frameProgress += delay;
while (frameProgress > frameThreshold) {
@ -2658,7 +2660,7 @@ export class EnemyPokemon extends Pokemon {
this.trainerSlot = trainerSlot;
if (boss)
this.setBoss();
this.setBoss(true, dataSource?.bossSegments);
if (!dataSource) {
this.generateAndPopulateMoveset();

View File

@ -184,9 +184,11 @@ export default class Trainer extends Phaser.GameObjects.Container {
return ret;
}
genPartyMember(index: integer): EnemyPokemon {
genPartyMember(index: integer, retryCount: integer = 0): EnemyPokemon {
const battle = this.scene.currentBattle;
const level = battle.enemyLevels[index];
let retry = false;
let ret: EnemyPokemon;
@ -196,10 +198,20 @@ export default class Trainer extends Phaser.GameObjects.Container {
if (this.config.partyMemberFuncs.hasOwnProperty(index)) {
ret = this.config.partyMemberFuncs[index](this.scene, level, strength);
if (template.isBalanced(index)) {
const partyMemberTypes = battle.enemyParty.map(p => p.getTypes(true)).flat();
if (partyMemberTypes.indexOf(ret.species.type1) > -1 || (ret.species.type2 !== null && partyMemberTypes.indexOf(ret.species.type2) > -1))
retry = true;
}
return;
}
if (this.config.partyMemberFuncs.hasOwnProperty(index - template.size)) {
ret = this.config.partyMemberFuncs[index - template.size](this.scene, level, template.getStrength(index));
ret = this.config.partyMemberFuncs[index - template.size](this.scene, level, strength);
if (template.isBalanced(index - template.size)) {
const partyMemberTypes = battle.enemyParty.map(p => p.getTypes(true)).flat();
if (partyMemberTypes.indexOf(ret.species.type1) > -1 || (ret.species.type2 !== null && partyMemberTypes.indexOf(ret.species.type2) > -1))
retry = true;
}
return;
}
@ -218,7 +230,10 @@ export default class Trainer extends Phaser.GameObjects.Container {
: this.genNewPartyMemberSpecies(level, strength);
ret = this.scene.addEnemyPokemon(species, level, !this.isDouble() || !(index % 2) ? TrainerSlot.TRAINER : TrainerSlot.TRAINER_PARTNER);
}, this.config.hasStaticParty ? this.config.getDerivedType() + ((index + 1) << 8) : this.scene.currentBattle.waveIndex + (this.config.getDerivedType() << 10) + (((!this.config.useSameSeedForAllMembers ? index : 0) + 1) << 8));
}, this.config.hasStaticParty ? this.config.getDerivedType() + ((index + 1 + retryCount * 6) << 8) : this.scene.currentBattle.waveIndex + (this.config.getDerivedType() << 10) + (((!this.config.useSameSeedForAllMembers ? index : 0) + 1 + retryCount * 6) << 8));
if (retry && ++retryCount < 10)
return this.genPartyMember(index, retryCount);
return ret;
}
@ -311,7 +326,7 @@ export default class Trainer extends Phaser.GameObjects.Container {
}
getNextSummonIndex(trainerSlot: TrainerSlot = TrainerSlot.NONE, partyMemberScores: [integer, integer][] = this.getPartyMemberMatchupScores(trainerSlot)): integer {
if (trainerSlot && !this.isDouble())
if (trainerSlot && !this.isDouble() || !this.config.hasGenders)
trainerSlot = TrainerSlot.NONE;
const sortedPartyMemberScores = this.getSortedPartyMemberMatchupScores(partyMemberScores);

View File

@ -90,9 +90,10 @@ export class GameMode implements GameModeConfig {
}
}
isWaveTrainer(waveIndex: integer, arena: Arena): boolean {
isWaveTrainer(waveIndex: integer, scene: BattleScene): boolean {
if (this.isDaily)
return waveIndex % 10 === 5 || (!(waveIndex % 10) && waveIndex > 10 && !this.isWaveFinal(waveIndex));
const arena = scene.arena;
if ((waveIndex % 30) === (arena.scene.offsetGym ? 0 : 20) && !this.isWaveFinal(waveIndex))
return true;
else if (waveIndex % 10 !== 1 && waveIndex % 10) {
@ -103,7 +104,7 @@ export class GameMode implements GameModeConfig {
for (let w = Math.max(waveIndex - 3, waveBase + 2); w <= Math.min(waveIndex + 3, waveBase + 9); w++) {
if (w === waveIndex)
continue;
if ((w % 30) === (arena.scene.offsetGym ? 0 : 20) || fixedBattles.hasOwnProperty(w)) {
if ((w % 30) === (arena.scene.offsetGym ? 0 : 20) || (fixedBattles.hasOwnProperty(w) && fixedBattles[w].condition(scene))) {
allowTrainerBattle = false;
break;
} else if (w < waveIndex) {

View File

@ -160,7 +160,7 @@ export class LoadingScene extends SceneBase {
Utils.getEnumValues(TrainerType).map(tt => {
const config = trainerConfigs[tt];
this.loadAtlas(config.getSpriteKey(), 'trainer');
if (config.doubleOnly || config.hasDouble)
if ((config.doubleOnly || config.hasDouble) && config.hasGenders)
this.loadAtlas(config.getSpriteKey(true), 'trainer');
});

View File

@ -9,6 +9,7 @@ export function getPokemonPrefix(pokemon: Pokemon): string {
let prefix: string;
switch (pokemon.scene.currentBattle.battleSpec) {
case BattleSpec.DEFAULT:
case BattleSpec.NUZLOCKE_BOSS:
prefix = !pokemon.isPlayer() ? pokemon.hasTrainer() ? 'Foe ' : 'Wild ' : '';
break;
case BattleSpec.FINAL_BOSS:

View File

@ -740,11 +740,13 @@ export class EncounterPhase extends BattlePhase {
if (this.scene.gameMode.isClassic && (battle.battleSpec === BattleSpec.FINAL_BOSS || this.scene.gameMode.isWaveFinal(battle.waveIndex))) {
if (battle.battleSpec !== BattleSpec.FINAL_BOSS) {
enemyPokemon.formIndex = 1;
enemyPokemon.calculateStats();
enemyPokemon.updateScale();
}
enemyPokemon.setBoss();
} else if (!(battle.waveIndex % 1000)) {
enemyPokemon.formIndex = 1;
enemyPokemon.calculateStats();
enemyPokemon.updateScale();
}
}
@ -3346,8 +3348,13 @@ export class VictoryPhase extends PokemonPhase {
if (!this.scene.getEnemyParty().find(p => this.scene.currentBattle.battleType ? !p?.isFainted(true) : p.isOnField())) {
this.scene.pushPhase(new BattleEndPhase(this.scene));
if (this.scene.currentBattle.battleType === BattleType.TRAINER)
if (this.scene.currentBattle.battleType === BattleType.TRAINER) {
if (this.scene.currentBattle.battleSpec === BattleSpec.NUZLOCKE_BOSS) {
this.scene.pushPhase(new NuzlockeBossSwitchPhase(this.scene));
return this.end();
}
this.scene.pushPhase(new TrainerVictoryPhase(this.scene));
}
if (this.scene.gameMode.isEndless || !this.scene.gameMode.isWaveFinal(this.scene.currentBattle.waveIndex)) {
this.scene.pushPhase(new EggLapsePhase(this.scene));
if (this.scene.currentBattle.waveIndex % 10)
@ -4599,6 +4606,65 @@ export class ScanIvsPhase extends PokemonPhase {
}
}
export class NuzlockeBossSwitchPhase extends BattlePhase {
start(): void {
super.start();
this.scene.currentBattle.addBattleScore(this.scene);
this.scene.gameData.gameStats.trainersDefeated++;
this.scene.clearEnemyHeldItemModifiers();
const pokemon = this.scene.addEnemyPokemon(getPokemonSpecies(Species.NUZLEAF), 300, TrainerSlot.NONE, true);
pokemon.setAlpha(0);
pokemon.x += 16;
pokemon.y -= 16;
pokemon.setBoss(true, 5);
this.scene.currentBattle.battleType = BattleType.WILD;
this.scene.currentBattle.enemyParty = [ pokemon ];
pokemon.loadAssets().then(() => {
this.scene.add.existing(pokemon);
this.scene.field.add(pokemon);
this.scene.gameData.setPokemonSeen(pokemon, true, false);
const playerPokemon = this.scene.getPlayerPokemon() as Pokemon;
if (playerPokemon?.visible)
this.scene.field.moveBelow(pokemon, playerPokemon);
this.scene.currentBattle.seenEnemyPartyMemberIds.add(pokemon.id);
pokemon.initBattleInfo();
regenerateModifierPoolThresholds(this.scene.getEnemyField(), ModifierPoolType.WILD);
this.scene.generateEnemyModifiers();
this.scene.updateModifiers(false);
this.scene.updateFieldScale();
pokemon.showInfo();
pokemon.playAnim();
pokemon.setVisible(true);
pokemon.getSprite().setVisible(true);
this.scene.updateFieldScale();
this.scene.tweens.add({
targets: pokemon,
duration: 250,
ease: 'Sine.easeIn',
alpha: 1,
x: '-=16',
y: '+=16',
onComplete: () => {
pokemon.cry();
pokemon.resetSummonData();
this.scene.time.delayedCall(1000, () => this.end());
}
});
});
}
}
export class TrainerMessageTestPhase extends BattlePhase {
private trainerTypes: TrainerType[];

View File

@ -49,6 +49,7 @@ export default class PokemonData {
public fusionLuck: integer;
public boss: boolean;
public bossSegments: integer;
public summonData: PokemonSummonData;
@ -90,8 +91,10 @@ export default class PokemonData {
this.fusionGender = source.fusionGender;
this.fusionLuck = source.fusionLuck !== undefined ? source.fusionLuck : (source.fusionShiny ? source.fusionVariant + 1 : 0);
if (!forHistory)
this.boss = (source instanceof EnemyPokemon && !!source.bossSegments) || (!this.player && !!source.boss);
if (!forHistory) {
this.bossSegments = !this.player ? source?.bossSegments || 0 : 0;
this.boss = !!this.bossSegments || !!source?.boss;
}
if (sourcePokemon) {
this.moveset = sourcePokemon.moveset;