Adjust fusion evolutions for starters

This commit is contained in:
Flashfyre 2023-11-08 18:36:30 -05:00
parent 2257d8d2f2
commit d0a60a7f86
5 changed files with 50 additions and 24 deletions

View File

@ -111,6 +111,8 @@ export class SelectStarterPhase extends BattlePhase {
const starterPokemon = new PlayerPokemon(this.scene, starter.species, startingLevel, starter.abilityIndex, starter.formIndex, starterGender, starter.shiny);
if (starter.pokerus)
starterPokemon.pokerus = true;
if (this.scene.gameMode === GameMode.SPLICED_ENDLESS)
starterPokemon.generateFusionSpecies(true);
starterPokemon.setVisible(false);
party.push(starterPokemon);
loadPokemonAssets.push(starterPokemon.loadAssets());
@ -245,7 +247,7 @@ export class EncounterPhase extends BattlePhase {
if (battle.battleType === BattleType.TRAINER)
battle.enemyParty[e] = battle.trainer.genPartyMember(e);
else {
const enemySpecies = this.scene.randomSpecies(battle.waveIndex, level, null, true);
const enemySpecies = this.scene.randomSpecies(battle.waveIndex, level, true);
battle.enemyParty[e] = new EnemyPokemon(this.scene, enemySpecies, level, false);
}
}

View File

@ -456,7 +456,7 @@ export default class BattleScene extends Phaser.Scene {
if (this.quickStart) {
for (let s = 0; s < 3; s++) {
const playerSpecies = this.randomSpecies(startingWave, startingLevel, null, false);
const playerSpecies = this.randomSpecies(startingWave, startingLevel);
const playerPokemon = new PlayerPokemon(this, playerSpecies, startingLevel, 0, 0);
playerPokemon.setVisible(false);
this.party.push(playerPokemon);
@ -815,15 +815,20 @@ export default class BattleScene extends Phaser.Scene {
return Math.min(Math.ceil(baseLevel / 2) * 2 + 2, 10000);
}
randomSpecies(waveIndex: integer, level: integer, speciesFilter?: PokemonSpeciesFilter, fromArenaPool?: boolean): PokemonSpecies {
randomSpecies(waveIndex: integer, level: integer, fromArenaPool?: boolean, speciesFilter?: PokemonSpeciesFilter, filterAllEvolutions?: boolean): PokemonSpecies {
if (fromArenaPool)
return this.arena.randomSpecies(waveIndex, level);
const filteredSpecies = speciesFilter ? [...new Set(allSpecies.slice(0, -1).filter(speciesFilter).map(s => {
if (!filterAllEvolutions) {
while (pokemonPrevolutions.hasOwnProperty(s.speciesId))
s = getPokemonSpecies(pokemonPrevolutions[s.speciesId]);
}
return s;
}))] : allSpecies.slice(0, -1);
return getPokemonSpecies(filteredSpecies[Utils.randSeedInt(filteredSpecies.length)].getSpeciesForLevel(level, true));
let ret = filteredSpecies[Utils.randSeedInt(filteredSpecies.length)];
if (!filterAllEvolutions)
ret = getPokemonSpecies(ret.getSpeciesForLevel(level, true));
return ret;
}
checkInput(): boolean {

View File

@ -531,7 +531,7 @@ function getSpeciesFilterRandomPartyMemberFunc(speciesFilter: PokemonSpeciesFilt
const originalSpeciesFilter = speciesFilter;
speciesFilter = (species: PokemonSpecies) => allowLegendaries || (!species.legendary && !species.pseudoLegendary && !species.mythical) && originalSpeciesFilter(species);
return (scene: BattleScene, level: integer) => {
const ret = new EnemyPokemon(scene, scene.randomSpecies(scene.currentBattle.waveIndex, level, speciesFilter), level, true);
const ret = new EnemyPokemon(scene, scene.randomSpecies(scene.currentBattle.waveIndex, level, false, speciesFilter), level, true);
if (postProcess)
postProcess(ret);
return ret;

View File

@ -154,22 +154,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.winCount = 0;
this.pokerus = false;
if (scene.gameMode === GameMode.SPLICED_ENDLESS) {
this.fusionSpecies = scene.randomSpecies(scene.currentBattle?.waveIndex || 0, level, this.species.getCompatibleFusionSpeciesFilter(), false);
this.fusionAbilityIndex = (this.fusionSpecies.abilityHidden && hasHiddenAbility ? this.fusionSpecies.ability2 ? 2 : 1 : this.fusionSpecies.ability2 ? randAbilityIndex : 0);
this.fusionFormIndex = scene.getSpeciesFormIndex(this.fusionSpecies);
this.fusionShiny = this.shiny;
if (this.getFusionSpeciesForm().malePercent === null)
this.fusionGender = Gender.GENDERLESS;
else {
const genderChance = (this.id % 256) * 0.390625;
if (genderChance < this.getFusionSpeciesForm().malePercent)
this.fusionGender = Gender.MALE;
else
this.fusionGender = Gender.FEMALE;
}
}
if (scene.gameMode === GameMode.SPLICED_ENDLESS)
this.generateFusionSpecies();
}
if (!species.isObtainable())
@ -597,6 +583,39 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
return this.shiny;
}
generateFusionSpecies(forStarter?: boolean): void {
const hiddenAbilityChance = new Utils.IntegerHolder(256);
if (!this.hasTrainer())
this.scene.applyModifiers(HiddenAbilityRateBoosterModifier, true, hiddenAbilityChance);
const hasHiddenAbility = !Utils.randSeedInt(hiddenAbilityChance.value);
const randAbilityIndex = Utils.randSeedInt(2);
const filter = !forStarter ? this.species.getCompatibleFusionSpeciesFilter()
: species => {
return pokemonEvolutions.hasOwnProperty(species.speciesId)
&& !pokemonPrevolutions.hasOwnProperty(species.speciesId)
&& !species.pseudoLegendary
&& !species.legendary
&& !species.mythical
};
this.fusionSpecies = this.scene.randomSpecies(this.scene.currentBattle?.waveIndex || 0, this.level, false, filter, true);
this.fusionAbilityIndex = (this.fusionSpecies.abilityHidden && hasHiddenAbility ? this.fusionSpecies.ability2 ? 2 : 1 : this.fusionSpecies.ability2 ? randAbilityIndex : 0);
this.fusionFormIndex = this.scene.getSpeciesFormIndex(this.fusionSpecies);
this.fusionShiny = this.shiny;
if (this.getFusionSpeciesForm().malePercent === null)
this.fusionGender = Gender.GENDERLESS;
else {
const genderChance = (this.id % 256) * 0.390625;
if (genderChance < this.getFusionSpeciesForm().malePercent)
this.fusionGender = Gender.MALE;
else
this.fusionGender = Gender.FEMALE;
}
}
generateAndPopulateMoveset(): void {
this.moveset = [];
const movePool = [];

View File

@ -153,7 +153,7 @@ export default class Trainer extends Phaser.GameObjects.Container {
const tierPool = this.config.speciesPools[tier];
ret = getPokemonSpecies(getPokemonSpecies(Phaser.Math.RND.pick(tierPool)).getSpeciesForLevel(level, true));
} else
ret = getPokemonSpecies(this.scene.randomSpecies(battle.waveIndex, level, this.config.speciesFilter).getSpeciesForLevel(level));
ret = getPokemonSpecies(this.scene.randomSpecies(battle.waveIndex, level, false, this.config.speciesFilter).getSpeciesForLevel(level));
if (template.isBalanced(battle.enemyParty.length)) {
const partyMemberTypes = battle.enemyParty.map(p => p.getTypes()).flat();