Metronome item

This commit is contained in:
DizzyEggg 2020-04-22 12:49:25 +02:00
parent c8ba013539
commit e2524bed49
4 changed files with 14 additions and 2 deletions

View File

@ -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) \

View File

@ -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;

View File

@ -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)

View File

@ -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))