From 831c0feb320676f7c810f20df31ef9b53875efa7 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 19 Dec 2023 13:18:20 +0100 Subject: [PATCH] Fixes Item Metronome damage --- include/constants/battle_script_commands.h | 5 +++-- src/battle_script_commands.c | 15 +++++++++------ test/battle/hold_effect/metronome.c | 2 -- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 7e95ea785b9e..4899d3703693 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -317,8 +317,9 @@ #define MOVEEND_EMERGENCY_EXIT 33 #define MOVEEND_SYMBIOSIS 34 #define MOVEEND_OPPORTUNIST 35 // Occurs after other stat change items/abilities to try and copy the boosts -#define MOVEEND_CLEAR_BITS 36 -#define MOVEEND_COUNT 37 +#define MOVEEND_SAME_MOVE_TURNS 36 +#define MOVEEND_CLEAR_BITS 37 +#define MOVEEND_COUNT 38 // switch cases #define B_SWITCH_NORMAL 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index a0bb282c8ccb..3fc710896e99 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1858,13 +1858,9 @@ static void Cmd_ppreduce(void) if (!(gHitMarker & (HITMARKER_NO_PPDEDUCT | HITMARKER_NO_ATTACKSTRING)) && gBattleMons[gBattlerAttacker].pp[gCurrMovePos]) { gProtectStructs[gBattlerAttacker].notFirstStrike = TRUE; + // For item Metronome, echoed voice - if (gCurrentMove == gLastResultingMoves[gBattlerAttacker] - && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && !WasUnableToUseMove(gBattlerAttacker) - && gSpecialStatuses[gBattlerAttacker].parentalBondState != PARENTAL_BOND_1ST_HIT) // Don't increment counter on first hit - gBattleStruct->sameMoveTurns[gBattlerAttacker]++; - else + if (gCurrentMove != gLastResultingMoves[gBattlerAttacker] || WasUnableToUseMove(gBattlerAttacker)) gBattleStruct->sameMoveTurns[gBattlerAttacker] = 0; if (gBattleMons[gBattlerAttacker].pp[gCurrMovePos] > ppToDeduct) @@ -6079,6 +6075,13 @@ static void Cmd_moveend(void) } gBattleScripting.moveendState++; break; + case MOVEEND_SAME_MOVE_TURNS: + if (gCurrentMove != gLastResultingMoves[gBattlerAttacker] || gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + gBattleStruct->sameMoveTurns[gBattlerAttacker] = 0; + else if (gCurrentMove == gLastResultingMoves[gBattlerAttacker] && gSpecialStatuses[gBattlerAttacker].parentalBondState != PARENTAL_BOND_1ST_HIT) + gBattleStruct->sameMoveTurns[gBattlerAttacker]++; + gBattleScripting.moveendState++; + break; case MOVEEND_CLEAR_BITS: // Clear/Set bits for things like using a move for all targets and all hits. if (gSpecialStatuses[gBattlerAttacker].instructedChosenTarget) *(gBattleStruct->moveTarget + gBattlerAttacker) = gSpecialStatuses[gBattlerAttacker].instructedChosenTarget & 0x3; diff --git a/test/battle/hold_effect/metronome.c b/test/battle/hold_effect/metronome.c index 63a0bb3eaea3..5b089703e9d3 100644 --- a/test/battle/hold_effect/metronome.c +++ b/test/battle/hold_effect/metronome.c @@ -67,7 +67,6 @@ SINGLE_BATTLE_TEST("Metronome Item's boost is reset if the attacker uses a diffe SINGLE_BATTLE_TEST("Metronome Item's boost is reset if the move fails") { s16 damage[2]; - KNOWN_FAILING; //https://github.com/rh-hideout/pokeemerald-expansion/issues/3251 GIVEN { PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_METRONOME); } OPPONENT(SPECIES_WOBBUFFET); @@ -110,7 +109,6 @@ SINGLE_BATTLE_TEST("Metronome Item counts charging turn of moves for its attacki { u32 item; - KNOWN_FAILING; // https://github.com/rh-hideout/pokeemerald-expansion/issues/3250 PARAMETRIZE {item = ITEM_NONE; } PARAMETRIZE {item = ITEM_METRONOME; } GIVEN {