Skip to content

Commit

Permalink
[Bug] Ability changing on evolution fix (pagefaultgames#2995)
Browse files Browse the repository at this point in the history
* Prevent Pokemon with their second ability from evolving into their HA

* Add check for fusions too
  • Loading branch information
DayKev authored Jul 22, 2024
1 parent 32d1b6b commit 86ebd0c
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/field/pokemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3295,14 +3295,26 @@ export class PlayerPokemon extends Pokemon {
}
this.generateName();
if (!isFusion) {
// If a pokemon has its second ability and it evolves into a pokemon that doesn't have a second ability, switch to its first ability instead of its hidden ability
if (this.getSpeciesForm().ability2 === Abilities.NONE && this.abilityIndex === 1) {
this.abilityIndex = 0;
}
// Prevent pokemon with an illegal ability value from breaking things too badly
const abilityCount = this.getSpeciesForm().getAbilityCount();
if (this.abilityIndex >= abilityCount) { // Shouldn't happen
this.abilityIndex = abilityCount - 1;
if (this.abilityIndex >= abilityCount) {
console.warn("this.abilityIndex is somehow an illegal value, please report this");
console.warn(this.abilityIndex);
this.abilityIndex = 0;
}
} else { // Do the same as above, but for fusions
if (this.getFusionSpeciesForm().ability2 === Abilities.NONE && this.fusionAbilityIndex === 1) {
this.fusionAbilityIndex = 0;
}
} else {
const abilityCount = this.getFusionSpeciesForm().getAbilityCount();
if (this.fusionAbilityIndex >= abilityCount) {// Shouldn't happen
this.fusionAbilityIndex = abilityCount - 1;
if (this.fusionAbilityIndex >= abilityCount) {
console.warn("this.fusionAbilityIndex is somehow an illegal value, please report this");
console.warn(this.fusionAbilityIndex);
this.fusionAbilityIndex = 0;
}
}
this.compatibleTms.splice(0, this.compatibleTms.length);
Expand Down

0 comments on commit 86ebd0c

Please sign in to comment.