diff --git a/include/battle.h b/include/battle.h index d0d8f4d8fb..d59623410d 100644 --- a/include/battle.h +++ b/include/battle.h @@ -547,6 +547,7 @@ struct BattleStruct u8 soulheartBattlerId; u8 friskedBattler; // Frisk needs to identify 2 battlers in double battles. bool8 friskedAbility; // If identifies two mons, show the ability pop-up only once. + u8 sameMoveTurns[MAX_BATTLERS_COUNT]; // For Metronome, number of times the same moves has been SUCCESFULLY used. }; #define GET_MOVE_TYPE(move, typeArg) \ diff --git a/src/battle_main.c b/src/battle_main.c index f200a3b548..5716950951 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3045,6 +3045,7 @@ void SwitchInClearSetData(void) gLastHitBy[gActiveBattler] = 0xFF; gBattleStruct->lastTakenMove[gActiveBattler] = 0; + gBattleStruct->sameMoveTurns[gActiveBattler] = 0; gBattleStruct->lastTakenMoveFrom[gActiveBattler][0] = 0; gBattleStruct->lastTakenMoveFrom[gActiveBattler][1] = 0; gBattleStruct->lastTakenMoveFrom[gActiveBattler][2] = 0; @@ -3130,6 +3131,7 @@ void FaintClearSetData(void) gLastHitBy[gActiveBattler] = 0xFF; gBattleStruct->choicedMove[gActiveBattler] = 0; + gBattleStruct->sameMoveTurns[gActiveBattler] = 0; gBattleStruct->lastTakenMove[gActiveBattler] = 0; gBattleStruct->lastTakenMoveFrom[gActiveBattler][0] = 0; gBattleStruct->lastTakenMoveFrom[gActiveBattler][1] = 0; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 4e30a3d4d4..a78d4497c6 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1447,6 +1447,13 @@ static void Cmd_ppreduce(void) if (!(gHitMarker & (HITMARKER_NO_PPDEDUCT | HITMARKER_NO_ATTACKSTRING)) && gBattleMons[gBattlerAttacker].pp[gCurrMovePos]) { gProtectStructs[gBattlerAttacker].notFirstStrike = 1; + // For item Metronome + if (gCurrentMove == gLastResultingMoves[gBattlerAttacker] + && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && !WasUnableToUseMove(gBattlerAttacker)) + gBattleStruct->sameMoveTurns[gBattlerAttacker]++; + else + gBattleStruct->sameMoveTurns[gBattlerAttacker] = 0; if (gBattleMons[gBattlerAttacker].pp[gCurrMovePos] > ppToDeduct) gBattleMons[gBattlerAttacker].pp[gCurrMovePos] -= ppToDeduct; @@ -4806,7 +4813,7 @@ static void Cmd_moveend(void) } gBattleScripting.moveendState++; break; - case MOVEEND_CLEAR_BITS: // Clear bits active while using a move for all targets and all hits. + 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; if (gSpecialStatuses[gBattlerAttacker].dancerOriginalTarget) diff --git a/src/battle_util.c b/src/battle_util.c index e857fb8bf9..daf0e08f16 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -6131,6 +6131,7 @@ static u32 CalcDefenseStat(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, static u32 CalcFinalDmg(u32 dmg, u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, u16 typeEffectivenessModifier, bool32 isCrit, bool32 updateFlags) { + u32 percentBoost; u32 abilityAtk = GetBattlerAbility(battlerAtk); u32 abilityDef = GetBattlerAbility(battlerDef); u32 defSide = GET_BATTLER_SIDE(battlerDef); @@ -6237,7 +6238,8 @@ static u32 CalcFinalDmg(u32 dmg, u16 move, u8 battlerAtk, u8 battlerDef, u8 move switch (GetBattlerHoldEffect(battlerAtk, TRUE)) { case HOLD_EFFECT_METRONOME: - // todo + percentBoost = min((gBattleStruct->sameMoveTurns[battlerAtk] * GetBattlerHoldEffectParam(battlerAtk)), 100); + MulModifier(&finalModifier, UQ_4_12(1.0) + sPercentToModifier[percentBoost]); break; case HOLD_EFFECT_EXPERT_BELT: if (typeEffectivenessModifier >= UQ_4_12(2.0))