diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index e8224b25fa..4f17840393 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6010,7 +6010,6 @@ BattleScript_RoarSuccessSwitch_Ret: swapattackerwithtarget @ continuation of RedCardActivates restoretarget restoreattacker - restoresavedmove setbyte sSWITCH_CASE, B_SWITCH_NORMAL return @@ -9492,7 +9491,6 @@ BattleScript_RedCardActivationNoSwitch:: removeitem BS_SCRIPTING restoretarget restoreattacker - restoresavedmove return BattleScript_RedCardActivates:: @@ -9515,6 +9513,7 @@ BattleScript_RedCardIngrainContinue: waitmessage B_WAIT_TIME_LONG removeitem BS_SCRIPTING restoretarget + restoreattacker return BattleScript_RedCardSuctionCups: printstring STRINGID_PKMNANCHORSITSELFWITH diff --git a/include/battle.h b/include/battle.h index 3e4907050b..823e4813e9 100644 --- a/include/battle.h +++ b/include/battle.h @@ -834,7 +834,6 @@ struct BattleStruct u8 usedMicleBerry; struct MessageStatus slideMessageStatus; u8 trainerSlideSpriteIds[MAX_BATTLERS_COUNT]; - u16 savedMove; // backup current move for mid-turn switching, e.g. Red Card u16 opponentMonCanTera:6; u16 opponentMonCanDynamax:6; u16 padding:4; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 014cef63a0..4837fb970e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7199,7 +7199,6 @@ static void Cmd_moveend(void) gLastUsedItem = gBattleMons[battler].item; SaveBattlerTarget(battler); // save battler with red card SaveBattlerAttacker(gBattlerAttacker); - gBattleStruct->savedMove = gCurrentMove; gBattleScripting.battler = battler; gEffectBattler = gBattlerAttacker; if (moveEffect == EFFECT_HIT_ESCAPE) @@ -7414,7 +7413,11 @@ static void Cmd_moveend(void) gBattleScripting.moveendState++; break; case MOVEEND_DANCER: // Special case because it's so annoying - if (IsDanceMove(gCurrentMove) && !gBattleStruct->snatchedMoveIsUsed) + if (gCurrentMove == MOVE_NONE) + originallyUsedMove = gChosenMove; // Fallback to chosen move in case attacker is switched out in the middle of an attack resolution (eg red card) + else + originallyUsedMove = gCurrentMove; + if (IsDanceMove(originallyUsedMove) && !gBattleStruct->snatchedMoveIsUsed) { u32 battler, nextDancer = 0; bool32 hasDancerTriggered = FALSE; @@ -7448,7 +7451,7 @@ static void Cmd_moveend(void) nextDancer = battler | 0x4; } } - if (nextDancer && AbilityBattleEffects(ABILITYEFFECT_MOVE_END_OTHER, nextDancer & 0x3, 0, 0, 0)) + if (nextDancer && AbilityBattleEffects(ABILITYEFFECT_MOVE_END_OTHER, nextDancer & 0x3, 0, 0, originallyUsedMove)) effect = TRUE; } } @@ -18779,15 +18782,3 @@ void BS_SetSteelsurge(void) gBattlescriptCurrInstr = cmd->nextInstr; } } - -void BS_RestoreSavedMove(void) -{ - NATIVE_ARGS(); - - if (gBattleStruct->savedMove == MOVE_NONE) - DebugPrintfLevel(MGBA_LOG_WARN, "restoresavedmove was called with no move saved!"); - - gCurrentMove = gBattleStruct->savedMove; - gBattleStruct->savedMove = MOVE_NONE; - gBattlescriptCurrInstr = cmd->nextInstr; -} diff --git a/src/battle_util.c b/src/battle_util.c index defe6e31d0..0a95f4e59c 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -6271,7 +6271,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32 { case ABILITY_DANCER: if (IsBattlerAlive(battler) - && IsDanceMove(gCurrentMove) + && IsDanceMove(move) && !gSpecialStatuses[battler].dancerUsedMove && gBattlerAttacker != battler) { @@ -6279,7 +6279,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32 gSpecialStatuses[battler].dancerUsedMove = TRUE; gSpecialStatuses[battler].dancerOriginalTarget = gBattleStruct->moveTarget[battler] | 0x4; gBattlerAttacker = gBattlerAbility = battler; - gCalledMove = gCurrentMove; + gCalledMove = move; // Set the target to the original target of the mon that first used a Dance move gBattlerTarget = gBattleScripting.savedBattler & 0x3;