[Bug] Moved RNG call if the Pokemon's ability hasn't been determined (#3966)

Co-authored-by: frutescens <info@laptop>
This commit is contained in:
Mumble 2024-09-01 21:09:46 -07:00 committed by GitHub
parent 8edb9ca65b
commit c4c9cf939e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -133,9 +133,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.scene.applyModifiers(HiddenAbilityRateBoosterModifier, true, hiddenAbilityChance);
}
const hasHiddenAbility = !Utils.randSeedInt(hiddenAbilityChance.value);
const randAbilityIndex = Utils.randSeedInt(2);
this.species = species;
this.pokeball = dataSource?.pokeball || PokeballType.POKEBALL;
this.level = level;
@ -146,6 +143,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.abilityIndex = abilityIndex; // Use the provided ability index if it is defined
} else {
// If abilityIndex is not provided, determine it based on species and hidden ability
const hasHiddenAbility = !Utils.randSeedInt(hiddenAbilityChance.value);
const randAbilityIndex = Utils.randSeedInt(2);
if (species.abilityHidden && hasHiddenAbility) {
// If the species has a hidden ability and the hidden ability is present
this.abilityIndex = 2;