From 3d8b912087e5e49db5999911dfd526bb511dd895 Mon Sep 17 00:00:00 2001 From: wiz1989 <80073265+wiz1989@users.noreply.github.com> Date: Sat, 12 Apr 2025 00:01:29 +0200 Subject: [PATCH] Ability imposter (#6552) --- src/battle_util.c | 23 ++++++++++++++--------- test/battle/ability/commander.c | 4 ++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 8d5902d558..b012b177e3 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4763,16 +4763,21 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32 } break; case ABILITY_IMPOSTER: - if (IsBattlerAlive(BATTLE_OPPOSITE(battler)) - && !(gBattleMons[BATTLE_OPPOSITE(battler)].status2 & (STATUS2_TRANSFORMED | STATUS2_SUBSTITUTE)) - && !(gBattleMons[battler].status2 & STATUS2_TRANSFORMED) - && !(gBattleStruct->illusion[BATTLE_OPPOSITE(battler)].on) - && !(gStatuses3[BATTLE_OPPOSITE(battler)] & STATUS3_SEMI_INVULNERABLE_NO_COMMANDER)) { - gBattlerAttacker = battler; - gBattlerTarget = BATTLE_OPPOSITE(battler); - BattleScriptPushCursorAndCallback(BattleScript_ImposterActivates); - effect++; + u32 diagonalBattler = BATTLE_OPPOSITE(battler); + if (IsDoubleBattle()) + diagonalBattler = BATTLE_PARTNER(diagonalBattler); + if (IsBattlerAlive(diagonalBattler) + && !(gBattleMons[diagonalBattler].status2 & (STATUS2_TRANSFORMED | STATUS2_SUBSTITUTE)) + && !(gBattleMons[battler].status2 & STATUS2_TRANSFORMED) + && !(gBattleStruct->illusion[diagonalBattler].on) + && !(gStatuses3[diagonalBattler] & STATUS3_SEMI_INVULNERABLE_NO_COMMANDER)) + { + gBattlerAttacker = battler; + gBattlerTarget = diagonalBattler; + BattleScriptPushCursorAndCallback(BattleScript_ImposterActivates); + effect++; + } } break; case ABILITY_MOLD_BREAKER: diff --git a/test/battle/ability/commander.c b/test/battle/ability/commander.c index 2220fb9ec2..d4b31f23b8 100644 --- a/test/battle/ability/commander.c +++ b/test/battle/ability/commander.c @@ -245,11 +245,11 @@ DOUBLE_BATTLE_TEST("Commander doesn't prevent Imposter from working on a Command OPPONENT(SPECIES_DITTO) { Ability(ABILITY_IMPOSTER); } } WHEN { TURN { } - TURN { SWITCH(opponentRight, 2); } + TURN { SWITCH(opponentLeft, 2); } } SCENE { ABILITY_POPUP(playerRight, ABILITY_COMMANDER); MESSAGE("Tatsugiri was swallowed by Dondozo and became Dondozo's commander!"); - ABILITY_POPUP(opponentRight, ABILITY_IMPOSTER); + ABILITY_POPUP(opponentLeft, ABILITY_IMPOSTER); MESSAGE("The opposing Ditto transformed into Tatsugiri using Imposter!"); } }