From a098631c86de6ca5c827f3c12d855fdfbe6bc95f Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 27 Oct 2023 11:18:12 +0200 Subject: [PATCH] Fixes dynamax move target and canceling in doubles --- src/battle_controller_player.c | 7 ++----- src/battle_main.c | 6 +++--- src/battle_util.c | 7 ++++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index e59ea5ba2871..e1041582e81f 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -707,11 +707,8 @@ static void HandleInputChooseMove(u32 battler) } // Status moves turn into Max Guard when Dynamaxed, targets user. - if ((IsDynamaxed(battler) || gBattleStruct->dynamax.playerSelect) - && gBattleMoves[moveInfo->moves[gMoveSelectionCursor[battler]]].split == SPLIT_STATUS) - { - moveTarget = MOVE_TARGET_USER; - } + if ((IsDynamaxed(battler) || gBattleStruct->dynamax.playerSelect)) + moveTarget = gBattleMoves[GetMaxMove(battler, moveInfo->moves[gMoveSelectionCursor[battler]])].target; if (moveTarget & MOVE_TARGET_USER) gMultiUsePlayerCursor = battler; diff --git a/src/battle_main.c b/src/battle_main.c index 173fc4546897..6b108506f32f 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4253,8 +4253,8 @@ static void HandleTurnActionSelectionState(void) gBattleStruct->mega.toEvolve &= ~(gBitTable[BATTLE_PARTNER(GetBattlerPosition(battler))]); gBattleStruct->burst.toBurst &= ~(gBitTable[BATTLE_PARTNER(GetBattlerPosition(battler))]); - gBattleStruct->dynamax.toDynamax &= ~(gBitTable[battler]); - gBattleStruct->dynamax.usingMaxMove[battler] = FALSE; + gBattleStruct->dynamax.toDynamax &= ~(gBitTable[BATTLE_PARTNER(GetBattlerPosition(battler))]); + gBattleStruct->dynamax.usingMaxMove[BATTLE_PARTNER(GetBattlerPosition(battler))] = FALSE; gBattleStruct->zmove.toBeUsed[BATTLE_PARTNER(GetBattlerPosition(battler))] = MOVE_NONE; BtlController_EmitEndBounceEffect(battler, BUFFER_A); MarkBattlerForControllerExec(battler); @@ -4354,7 +4354,7 @@ static void HandleTurnActionSelectionState(void) gBattleStruct->burst.toBurst |= gBitTable[battler]; else if (gBattleResources->bufferB[battler][2] & RET_DYNAMAX) gBattleStruct->dynamax.toDynamax |= gBitTable[battler]; - + // Max Move check if (ShouldUseMaxMove(battler, gChosenMoveByBattler[battler])) { diff --git a/src/battle_util.c b/src/battle_util.c index afef74b0f80f..007e4cfcab50 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -322,7 +322,6 @@ void HandleAction_UseMove(void) gCurrentMove = gBattleStruct->zmove.toBeUsed[gBattlerAttacker]; } - moveTarget = GetBattlerMoveTargetType(gBattlerAttacker, gCurrentMove); if (gBattleMons[gBattlerAttacker].hp != 0) { @@ -343,6 +342,8 @@ void HandleAction_UseMove(void) gBattleStruct->dynamax.activeSplit = gBattleStruct->dynamax.splits[gBattlerAttacker]; } + moveTarget = GetBattlerMoveTargetType(gBattlerAttacker, gCurrentMove); + // choose target side = BATTLE_OPPOSITE(GetBattlerSide(gBattlerAttacker)); if (IsAffectedByFollowMe(gBattlerAttacker, side, gCurrentMove) @@ -8193,10 +8194,10 @@ bool32 IsBattlerProtected(u32 battler, u32 move) // Z-Moves and Max Moves bypass protection (except Max Guard). if ((IsMaxMove(move) || gBattleStruct->zmove.active) - && (!gProtectStructs[battler].maxGuarded + && (!gProtectStructs[battler].maxGuarded || gBattleMoves[move].argument == MAX_EFFECT_BYPASS_PROTECT)) return FALSE; - + // Max Guard is silly about the moves it blocks, including Teatime. if (gProtectStructs[battler].maxGuarded && IsMoveBlockedByMaxGuard(move)) return TRUE;