From 40439817aceefdd293469ec1966109079f8b442b Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 26 Dec 2023 01:29:05 -0500 Subject: [PATCH] Attempt fixing issue with gender-specific types --- src/battle-phases.ts | 3 +-- src/battle-scene.ts | 21 +++++++++++++++++---- src/data/egg.ts | 2 +- src/egg-hatch-phase.ts | 4 ++-- src/pokemon.ts | 11 ++++++++--- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/battle-phases.ts b/src/battle-phases.ts index b5b634304..c824dbe51 100644 --- a/src/battle-phases.ts +++ b/src/battle-phases.ts @@ -2784,8 +2784,7 @@ export class BerryPhase extends CommonAnimPhase { berryModifier.consumed = false; this.scene.updateModifiers(this.player); } - super.start(); - return; + return super.start(); } this.end(); diff --git a/src/battle-scene.ts b/src/battle-scene.ts index c78cc8b1d..f75e2ca6b 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -37,6 +37,7 @@ import InvertPostFX from './pipelines/invert'; import { Achv, ModifierAchv, achvs } from './system/achv'; import { GachaType } from './data/egg'; import { Voucher, vouchers } from './system/voucher'; +import { Gender } from './data/gender'; const enableAuto = true; const quickStart = false; @@ -781,7 +782,7 @@ export default class BattleScene extends Phaser.Scene { return this.arena; } - getSpeciesFormIndex(species: PokemonSpecies, ignoreArena?: boolean): integer { + getSpeciesFormIndex(species: PokemonSpecies, gender?: Gender, ignoreArena?: boolean): integer { if (!species.forms?.length) return 0; @@ -791,11 +792,23 @@ export default class BattleScene extends Phaser.Scene { case Species.SAWSBUCK: case Species.ORICORIO: return Utils.randSeedInt(species.forms.length); + case Species.MEOWSTIC: + case Species.INDEEDEE: + return gender === Gender.FEMALE ? 1 : 0; } - return !ignoreArena - ? this.arena.getSpeciesFormIndex(species) - : 0; + if (ignoreArena) { + switch (species.speciesId) { + case Species.BURMY: + case Species.WORMADAM: + case Species.LYCANROC: + case Species.CALYREX: + return Utils.randSeedInt(species.forms.length); + } + return 0; + } + + return this.arena.getSpeciesFormIndex(species); } trySpreadPokerus(): void { diff --git a/src/data/egg.ts b/src/data/egg.ts index 8824dc2b3..fada3a163 100644 --- a/src/data/egg.ts +++ b/src/data/egg.ts @@ -104,7 +104,7 @@ export function getLegendaryGachaSpeciesForTimestamp(scene: BattleScene, timesta } export function getTypeGachaTypeForTimestamp(scene: BattleScene, timestamp: integer): Type { - const types = Utils.getEnumValues(Type); + const types = Utils.getEnumValues(Type).slice(1); let ret: Type; scene.executeWithSeedOffset(() => { diff --git a/src/egg-hatch-phase.ts b/src/egg-hatch-phase.ts index eaf0621af..493c39c68 100644 --- a/src/egg-hatch-phase.ts +++ b/src/egg-hatch-phase.ts @@ -330,7 +330,7 @@ export class EggHatchPhase extends BattlePhase { if (speciesOverride) { this.scene.executeWithSeedOffset(() => { const pokemonSpecies = getPokemonSpecies(speciesOverride); - ret = new PlayerPokemon(this.scene, pokemonSpecies, 5, undefined, this.scene.getSpeciesFormIndex(pokemonSpecies, true), undefined, false); + ret = new PlayerPokemon(this.scene, pokemonSpecies, 5, undefined, undefined, undefined, false); }, this.egg.id, EGG_SEED.toString()); } else { let minStarterValue: integer; @@ -399,7 +399,7 @@ export class EggHatchPhase extends BattlePhase { const pokemonSpecies = getPokemonSpecies(species); - ret = new PlayerPokemon(this.scene, pokemonSpecies, 5, undefined, this.scene.getSpeciesFormIndex(pokemonSpecies, true), undefined, false); + ret = new PlayerPokemon(this.scene, pokemonSpecies, 5, undefined, undefined, undefined, false); }, this.egg.id, EGG_SEED.toString()); } diff --git a/src/pokemon.ts b/src/pokemon.ts index 877d09a1e..f57a1a90b 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -108,7 +108,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.abilityIndex = abilityIndex !== undefined ? abilityIndex : (species.abilityHidden && hasHiddenAbility ? species.ability2 ? 2 : 1 : species.ability2 ? randAbilityIndex : 0); - this.formIndex = formIndex || 0; + if (formIndex !== undefined) + this.formIndex = formIndex; if (gender !== undefined) this.gender = gender; if (shiny !== undefined) @@ -155,6 +156,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } + if (this.formIndex === undefined) + this.formIndex = this.scene.getSpeciesFormIndex(species, this.gender, this.isPlayer()); + if (this.shiny === undefined) this.trySetShiny(); @@ -748,7 +752,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { 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.fusionSpecies.malePercent === null) @@ -761,6 +764,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.fusionGender = Gender.FEMALE; } + this.fusionFormIndex = this.scene.getSpeciesFormIndex(this.fusionSpecies, this.fusionGender, true); + this.generateName(); } @@ -1861,7 +1866,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.getSpeciesFormIndex(species), + super(scene, 236, 84, species, level, dataSource?.abilityIndex, dataSource?.formIndex, dataSource?.gender, dataSource ? dataSource.shiny : false, null, dataSource); this.trainer = trainer;