From d9ebf99cdda0d7eca46d94e6f8378f295e0e7ccb Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 2 Apr 2024 10:13:00 -0400 Subject: [PATCH] Rework logic for defeat ability trigger --- src/phases.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index 77958335aaa..8ab5990b2f1 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2979,12 +2979,17 @@ export class VictoryPhase extends PokemonPhase { if (exp) { const partyMemberIndex = party.indexOf(expPartyMembers[pm]); this.scene.unshiftPhase(expPartyMembers[pm].isOnField() ? new ExpPhase(this.scene, partyMemberIndex, exp) : new ShowPartyExpBarPhase(this.scene, partyMemberIndex, exp)); - if (expPartyMembers[pm].isOnField()) - applyPostVictoryAbAttrs(PostVictoryAbAttr, expPartyMembers[pm]); } } } + const defeatedPokemon = this.getPokemon(); + if (defeatedPokemon.turnData?.attacksReceived?.length) { + const defeatSource = this.scene.getPokemonById(defeatedPokemon.turnData.attacksReceived[0].sourceId); + if (defeatSource?.isOnField()) + applyPostVictoryAbAttrs(PostVictoryAbAttr, defeatSource); + } + if (!this.scene.getEnemyParty().find(p => this.scene.currentBattle.battleType ? !p?.isFainted(true) : p.isOnField())) { this.scene.pushPhase(new BattleEndPhase(this.scene)); if (this.scene.currentBattle.battleType === BattleType.TRAINER)