Allow for preset moves

This commit is contained in:
AJ Fontaine 2025-05-13 14:45:49 -04:00
parent 02cac77853
commit 02183cee84
2 changed files with 41 additions and 35 deletions

View File

@ -3629,9 +3629,9 @@ export default class BattleScene extends SceneBase {
) as TurnHeldItemTransferModifier; ) as TurnHeldItemTransferModifier;
finalBossMBH.setTransferrableFalse(); finalBossMBH.setTransferrableFalse();
this.addEnemyModifier(finalBossMBH, false, true); this.addEnemyModifier(finalBossMBH, false, true);
pokemon.generateAndPopulateMoveset(1);
this.setFieldScale(0.75); this.setFieldScale(0.75);
this.triggerPokemonFormChange(pokemon, SpeciesFormChangeManualTrigger, false); this.triggerPokemonFormChange(pokemon, SpeciesFormChangeManualTrigger, false);
pokemon.generateAndPopulateMoveset();
this.currentBattle.double = true; this.currentBattle.double = true;
const availablePartyMembers = this.getPlayerParty().filter(p => p.isAllowedInBattle()); const availablePartyMembers = this.getPlayerParty().filter(p => p.isAllowedInBattle());
if (availablePartyMembers.length > 1) { if (availablePartyMembers.length > 1) {

View File

@ -3481,8 +3481,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
} }
/** Generates a semi-random moveset for a Pokemon */ /** Generates a semi-random moveset for a Pokemon */
public generateAndPopulateMoveset(): void { public generateAndPopulateMoveset(...presetMoves: Moves[]): void {
this.moveset = []; this.moveset = presetMoves.map(m => new PokemonMove(m));
if (presetMoves.length === 4) {
return; // Return early if all moves are set
}
let movePool: [Moves, number][] = []; let movePool: [Moves, number][] = [];
const allLevelMoves = this.getLevelMoves(1, true, true); const allLevelMoves = this.getLevelMoves(1, true, true);
if (!allLevelMoves) { if (!allLevelMoves) {
@ -3669,6 +3672,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
)), )),
]); ]);
// Filter out preset moves, do it here so they still have an impact on the weight of other moves
movePool = movePool.filter(m => !this.moveset.some(
pm => pm.moveId === m[0]
));
// Weight damaging moves against the lower stat. This uses a non-linear relationship. // Weight damaging moves against the lower stat. This uses a non-linear relationship.
// If the higher stat is 1 - 1.09x higher, no change. At higher stat ~1.38x lower stat, off-stat moves have half weight. // If the higher stat is 1 - 1.09x higher, no change. At higher stat ~1.38x lower stat, off-stat moves have half weight.
// One third weight at ~1.58x higher, one quarter weight at ~1.73x higher, one fifth at ~1.87x, and one tenth at ~2.35x higher. // One third weight at ~1.58x higher, one quarter weight at ~1.73x higher, one fifth at ~1.87x, and one tenth at ~2.35x higher.
@ -3700,7 +3708,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
]); ]);
// Trainers and bosses always force a stab move // Trainers and bosses always force a stab move
if (this.hasTrainer() || this.isBoss()) { if ((this.hasTrainer() || this.isBoss()) && !presetMoves.some(m => this.isOfType(allMoves[m].type))) {
const stabMovePool = baseWeights.filter( const stabMovePool = baseWeights.filter(
m => m =>
allMoves[m[0]].category !== MoveCategory.STATUS && allMoves[m[0]].category !== MoveCategory.STATUS &&
@ -7177,37 +7185,35 @@ export class EnemyPokemon extends Pokemon {
} }
} }
generateAndPopulateMoveset(formIndex?: number): void { generateAndPopulateMoveset(...presetMoves: Moves[]): void {
switch (true) { if (this.species.speciesId === Species.SMEARGLE) {
case this.species.speciesId === Species.SMEARGLE: this.moveset = [
this.moveset = [ new PokemonMove(Moves.SKETCH),
new PokemonMove(Moves.SKETCH), new PokemonMove(Moves.SKETCH),
new PokemonMove(Moves.SKETCH), new PokemonMove(Moves.SKETCH),
new PokemonMove(Moves.SKETCH), new PokemonMove(Moves.SKETCH),
new PokemonMove(Moves.SKETCH), ];
]; }
break; else if (this.species.speciesId === Species.ETERNATUS) {
case this.species.speciesId === Species.ETERNATUS: this.moveset = this.formIndex === 1
this.moveset = (formIndex !== undefined ? formIndex : this.formIndex) ? [
? [ new PokemonMove(Moves.DYNAMAX_CANNON),
new PokemonMove(Moves.DYNAMAX_CANNON), new PokemonMove(Moves.CROSS_POISON),
new PokemonMove(Moves.CROSS_POISON), new PokemonMove(Moves.FLAMETHROWER),
new PokemonMove(Moves.FLAMETHROWER), new PokemonMove(Moves.RECOVER, 0, -4),
new PokemonMove(Moves.RECOVER, 0, -4), ]
] : [
: [ new PokemonMove(Moves.ETERNABEAM),
new PokemonMove(Moves.ETERNABEAM), new PokemonMove(Moves.SLUDGE_BOMB),
new PokemonMove(Moves.SLUDGE_BOMB), new PokemonMove(Moves.FLAMETHROWER),
new PokemonMove(Moves.FLAMETHROWER), new PokemonMove(Moves.COSMIC_POWER),
new PokemonMove(Moves.COSMIC_POWER), ];
]; if (globalScene.gameMode.hasChallenge(Challenges.INVERSE_BATTLE)) {
if (globalScene.gameMode.hasChallenge(Challenges.INVERSE_BATTLE)) { this.moveset[2] = new PokemonMove(Moves.THUNDERBOLT);
this.moveset[2] = new PokemonMove(Moves.THUNDERBOLT); }
} }
break; else {
default: super.generateAndPopulateMoveset(...presetMoves);
super.generateAndPopulateMoveset();
break;
} }
} }