Add ability pop-up for when Propeller Tail/Stalwart proc.

This commit is contained in:
unknown 2024-05-10 10:41:45 -04:00
parent abbf28d872
commit 282db5e15f

View File

@ -2211,14 +2211,20 @@ export class MovePhase extends BattlePhase {
? new Utils.IntegerHolder(this.targets[0]) ? new Utils.IntegerHolder(this.targets[0])
: null; : null;
if (moveTarget) { if (moveTarget) {
//If user has an ability preventing moves from being redirected, or is using a move that can not be redirected (i.e. Snipe Shot), don't redirect it. var oldTarget = moveTarget.value;
if (!(this.pokemon.hasAbilityWithAttr(BlockRedirectAbAttr) || this.move.getMove().getAttrs(BypassRedirectAttr).length) )
{
this.scene.getField(true).filter(p => p !== this.pokemon).forEach(p => applyAbAttrs(RedirectMoveAbAttr, p, null, this.move.moveId, moveTarget)); this.scene.getField(true).filter(p => p !== this.pokemon).forEach(p => applyAbAttrs(RedirectMoveAbAttr, p, null, this.move.moveId, moveTarget));
//Check if this move is immune to being redirected, and restore its target to the intended target if it is.
if ((this.pokemon.hasAbilityWithAttr(BlockRedirectAbAttr) || this.move.getMove().getAttrs(BypassRedirectAttr).length)) {
//If an ability prevented this move from being redirected, display its ability pop up.
if ((this.pokemon.hasAbilityWithAttr(BlockRedirectAbAttr) && !this.move.getMove().getAttrs(BypassRedirectAttr).length) && oldTarget != moveTarget.value) {
this.scene.unshiftPhase(new ShowAbilityPhase(this.scene, this.pokemon.getBattlerIndex(), this.pokemon.getPassiveAbility().hasAttr(BlockRedirectAbAttr)));
}
moveTarget.value = oldTarget;
} }
this.targets[0] = moveTarget.value; this.targets[0] = moveTarget.value;
} }
if (this.targets.length === 1 && this.targets[0] === BattlerIndex.ATTACKER) { if (this.targets.length === 1 && this.targets[0] === BattlerIndex.ATTACKER) {
if (this.pokemon.turnData.attacksReceived.length) { if (this.pokemon.turnData.attacksReceived.length) {
const attacker = this.pokemon.turnData.attacksReceived.length ? this.pokemon.scene.getPokemonById(this.pokemon.turnData.attacksReceived[0].sourceId) : null; const attacker = this.pokemon.turnData.attacksReceived.length ? this.pokemon.scene.getPokemonById(this.pokemon.turnData.attacksReceived[0].sourceId) : null;