diff --git a/src/arena.ts b/src/arena.ts index 8cf9c736deb..79f7ca85eb0 100644 --- a/src/arena.ts +++ b/src/arena.ts @@ -117,9 +117,7 @@ export class Arena { return !tierPool.length ? TrainerType.BREEDER : tierPool[Utils.randSeedInt(tierPool.length)]; } - getFormIndex(species: PokemonSpecies) { - if (!species.canChangeForm && species.forms?.length) - return Utils.randSeedInt(species.forms.length); + getSpeciesFormIndex(species: PokemonSpecies): integer { switch (species.speciesId) { case Species.BURMY: case Species.WORMADAM: @@ -131,6 +129,7 @@ export class Arena { } break; } + return 0; } diff --git a/src/battle-scene.ts b/src/battle-scene.ts index e42a392440a..4ab72ab37b0 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -32,6 +32,7 @@ import PokeballTray from './ui/pokeball-tray'; import { Setting, settingOptions } from './system/settings'; import SettingsUiHandler from './ui/settings-ui-handler'; import MessageUiHandler from './ui/message-ui-handler'; +import { Species } from './data/species'; const enableAuto = true; const quickStart = false; @@ -733,6 +734,20 @@ export default class BattleScene extends Phaser.Scene { return this.arena; } + getSpeciesFormIndex(species: PokemonSpecies): integer { + if (!species.forms?.length) + return 0; + + switch (species.speciesId) { + case Species.UNOWN: + case Species.DEERLING: + case Species.SAWSBUCK: + return Utils.randSeedInt(species.forms.length); + } + + return this.arena.getSpeciesFormIndex(species); + } + trySpreadPokerus(): void { const party = this.getParty(); const infectedIndexes: integer[] = []; @@ -953,7 +968,7 @@ export default class BattleScene extends Phaser.Scene { } pauseBgm(): boolean { - if (this.bgm && this.bgm.isPlaying) { + if (this.bgm && !this.bgm.pendingRemove && this.bgm.isPlaying) { this.bgm.pause(); return true; } @@ -961,7 +976,7 @@ export default class BattleScene extends Phaser.Scene { } resumeBgm(): boolean { - if (this.bgm && this.bgm.isPaused) { + if (this.bgm && !this.bgm.pendingRemove && this.bgm.isPaused) { this.bgm.resume(); return true; } diff --git a/src/data/trainer-type.ts b/src/data/trainer-type.ts index 61bfabb3f35..b90a0066e30 100644 --- a/src/data/trainer-type.ts +++ b/src/data/trainer-type.ts @@ -735,7 +735,7 @@ export const trainerConfigs: TrainerConfigs = { .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEOT, Species.NOCTOWL, Species.SWELLOW, Species.STARAPTOR, Species.UNFEZANT ])) .setPartyMemberFunc(2, getSpeciesFilterRandomPartyMemberFunc((species: PokemonSpecies) => !pokemonEvolutions.hasOwnProperty(species.speciesId) && !pokemonPrevolutions.hasOwnProperty(species.speciesId) && species.baseTotal >= 450)) .setSpeciesFilter(species => species.baseTotal >= 540) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.RAYQUAZA ], p => p.formIndex = 0)), + .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.RAYQUAZA ])), [TrainerType.RIVAL_6]: new TrainerConfig(++t).setBoss().setStaticParty().setEncounterBgm('final').setBattleBgm('battle_rival_3').setPartyTemplates(trainerPartyTemplates.RIVAL_6) .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.VENUSAUR, Species.CHARIZARD, Species.BLASTOISE, Species.MEGANIUM, Species.TYPHLOSION, Species.FERALIGATR, Species.SCEPTILE, Species.BLAZIKEN, Species.SWAMPERT, Species.TORTERRA, Species.INFERNAPE, Species.EMPOLEON, Species.SERPERIOR, Species.EMBOAR, Species.SAMUROTT ])) .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEOT, Species.NOCTOWL, Species.SWELLOW, Species.STARAPTOR, Species.UNFEZANT ])) diff --git a/src/pokemon.ts b/src/pokemon.ts index aea04291624..a1842f8c7e9 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -1205,7 +1205,7 @@ export class EnemyPokemon extends Pokemon { public aiType: AiType; constructor(scene: BattleScene, species: PokemonSpecies, level: integer, trainer: boolean, dataSource?: PokemonData) { - super(scene, 236, 84, species, level, dataSource?.abilityIndex, dataSource ? dataSource.formIndex : scene.arena.getFormIndex(species), + super(scene, 236, 84, species, level, dataSource?.abilityIndex, dataSource ? dataSource.formIndex : scene.getSpeciesFormIndex(species), dataSource?.gender, dataSource?.shiny, dataSource); this.trainer = trainer;