[Misc] Ability Charms no longer affect the number of RNG rolls (#6652)

This commit is contained in:
NightKev 2025-10-16 11:25:39 -07:00 committed by GitHub
parent 904086c73a
commit 95cc9f6d49
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -604,20 +604,18 @@ export abstract class Pokemon extends Phaser.GameObjects.Container {
/** Generate `abilityIndex` based on species and hidden ability if not pre-defined. */
private generateAbilityIndex(): number {
// Roll for hidden ability chance, applying any ability charms for enemy mons
const hiddenAbilityChance = new NumberHolder(BASE_HIDDEN_ABILITY_CHANCE);
// Ability Charms should only affect wild Pokemon
// TODO: move this `if` check into the ability charm code
if (!this.hasTrainer()) {
globalScene.applyModifiers(HiddenAbilityRateBoosterModifier, true, hiddenAbilityChance);
}
// If the roll succeeded and we have one, use HA; otherwise pick a random ability
const hasHiddenAbility = !randSeedInt(hiddenAbilityChance.value);
if (this.species.abilityHidden && hasHiddenAbility) {
return 2;
}
// Neither RNG roll depends on the outcome of the other, so that Ability Charms do not affect RNG.
const regularAbility = this.species.ability2 !== this.species.ability1 ? randSeedInt(2) : 0;
const useHiddenAbility = this.species.abilityHidden ? !randSeedInt(hiddenAbilityChance.value) : false;
// only use random ability if species has a second ability
return this.species.ability2 !== this.species.ability1 ? randSeedInt(2) : 0;
return useHiddenAbility ? 2 : regularAbility;
}
/**