Add counterRedirectAttr to other counter-like moves

This commit is contained in:
Sirz Benjie 2025-08-18 21:23:50 -05:00
parent 7207c3b6ab
commit d74a70a529
No known key found for this signature in database
GPG Key ID: 4A524B4D196C759E
2 changed files with 7 additions and 5 deletions

View File

@ -1851,21 +1851,18 @@ export class CounterRedirectAttr extends MoveAttr {
// check if the target is still alive
if (
globalScene.currentBattle.double &&
!globalScene.getField()[desiredTarget]?.isActive
!globalScene.getField()[desiredTarget]?.isActive(true)
) {
const targetField = desiredTarget >= BattlerIndex.ENEMY ? globalScene.getEnemyField() : globalScene.getPlayerField();
args[0].value = targetField.find(p => p.hp > 0)?.getBattlerIndex() ?? BattlerIndex.ATTACKER;
} else {
args[0].value = desiredTarget;
}
console.log(`CounterRedirectAttr: Redirecting move to battler index ${BattlerIndex[args[0].value]}`);
return true;
}
return false;
}
override canApply(user: Pokemon, target: Pokemon, move: Move, args: [NumberHolder, ...any[]]): boolean {
return args[0].value === BattlerIndex.ATTACKER;
}
}
export class LevelDamageAttr extends FixedDamageAttr {
@ -9387,6 +9384,7 @@ export function initMoves() {
.bitingMove(),
new AttackMove(MoveId.MIRROR_COAT, PokemonType.PSYCHIC, MoveCategory.SPECIAL, -1, 100, 20, -1, -5, 2)
.attr(CounterDamageAttr, 2, MoveCategory.SPECIAL)
.attr(CounterRedirectAttr, MoveCategory.SPECIAL)
.condition(counterAttackCondition_Special, 3)
.target(MoveTarget.ATTACKER),
new StatusMove(MoveId.PSYCH_UP, PokemonType.NORMAL, -1, 10, -1, 0, 2)
@ -9805,6 +9803,7 @@ export function initMoves() {
.target(MoveTarget.USER_OR_NEAR_ALLY),
new AttackMove(MoveId.METAL_BURST, PokemonType.STEEL, MoveCategory.PHYSICAL, -1, 100, 10, -1, 0, 4)
.attr(CounterDamageAttr, 1.5)
.attr(CounterRedirectAttr)
.condition(counterAttackCondition_Both, 3)
.makesContact(false)
.target(MoveTarget.ATTACKER),
@ -11622,6 +11621,7 @@ export function initMoves() {
.restriction(ConsecutiveUseRestriction),
new AttackMove(MoveId.COMEUPPANCE, PokemonType.DARK, MoveCategory.PHYSICAL, -1, 100, 10, -1, 0, 9)
.attr(CounterDamageAttr, 1.5)
.attr(CounterRedirectAttr)
.condition(counterAttackCondition_Both, 3)
.target(MoveTarget.ATTACKER),
new AttackMove(MoveId.AQUA_CUTTER, PokemonType.WATER, MoveCategory.PHYSICAL, 70, 100, 20, -1, 0, 9)

View File

@ -912,6 +912,7 @@ export class MovePhase extends BattlePhase {
*/
protected resolveCounterAttackTarget(): void {
if (this.targets.length !== 1 || this.targets[0] !== BattlerIndex.ATTACKER) {
console.log("%cSkipping counter attack target resolution", "color: blue");
return;
}
@ -920,6 +921,7 @@ export class MovePhase extends BattlePhase {
applyMoveAttrs("CounterRedirectAttr", this.pokemon, null, this.move.getMove(), targetHolder);
this.targets[0] = targetHolder.value;
if (targetHolder.value === BattlerIndex.ATTACKER) {
console.log("%cSkipping counter attack target resolution", "color: red");
this.fail();
}
}