Fix fainted ally targeted attacks redirecting to self

pull/34/head
Flashfyre 2024-04-04 14:42:20 -04:00
parent 48ff8b248b
commit 23a8fb1fc9
2 changed files with 2 additions and 2 deletions

View File

@ -623,7 +623,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm {
getFormSpriteKey(formIndex?: integer) { getFormSpriteKey(formIndex?: integer) {
if (this.forms.length && formIndex >= this.forms.length) { if (this.forms.length && formIndex >= this.forms.length) {
console.warn(`Attempted accessing form with index ${formIndex} of species ${this.getName()} with only ${this.forms?.length || 0} forms`); console.warn(`Attempted accessing form with index ${formIndex} of species ${this.getName()} with only ${this.forms.length || 0} forms`);
formIndex = Math.min(formIndex, this.forms.length - 1); formIndex = Math.min(formIndex, this.forms.length - 1);
} }
return this.forms?.length return this.forms?.length

View File

@ -2850,7 +2850,7 @@ export class FaintPhase extends PokemonPhase {
if (allyPokemon?.isActive(true)) { if (allyPokemon?.isActive(true)) {
let targetingMovePhase: MovePhase; let targetingMovePhase: MovePhase;
do { do {
targetingMovePhase = this.scene.findPhase(mp => mp instanceof MovePhase && mp.targets.length === 1 && mp.targets[0] === pokemon.getBattlerIndex()) as MovePhase; targetingMovePhase = this.scene.findPhase(mp => mp instanceof MovePhase && mp.targets.length === 1 && mp.targets[0] === pokemon.getBattlerIndex() && mp.pokemon.isPlayer() !== allyPokemon.isPlayer()) as MovePhase;
if (targetingMovePhase && targetingMovePhase.targets[0] !== allyPokemon.getBattlerIndex()) if (targetingMovePhase && targetingMovePhase.targets[0] !== allyPokemon.getBattlerIndex())
targetingMovePhase.targets[0] = allyPokemon.getBattlerIndex(); targetingMovePhase.targets[0] = allyPokemon.getBattlerIndex();
} while (targetingMovePhase); } while (targetingMovePhase);