diff --git a/include/battle.h b/include/battle.h index 1729c76b3d..91233c8fe8 100644 --- a/include/battle.h +++ b/include/battle.h @@ -184,9 +184,9 @@ struct ProtectStruct u32 powderSelfDmg:1; u32 usedThroatChopPreventedMove:1; u32 statRaised:1; - u32 usedMicleBerry:1; u32 usedCustapBerry:1; // also quick claw u32 touchedProtectLike:1; + u32 unused:1; // End of 32-bit bitfield u16 disableEjectPack:1; u16 statFell:1; @@ -802,6 +802,7 @@ struct BattleStruct u32 stellarBoostFlags[NUM_BATTLE_SIDES]; // stored as a bitfield of flags for all types for each side u8 fickleBeamBoosted:1; u8 obedienceResult:3; + u8 usedMicleBerry; }; // The palaceFlags member of struct BattleStruct contains 1 flag per move to indicate which moves the AI should consider, diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index c33fce7fae..04f3c966bb 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1689,9 +1689,8 @@ u32 GetTotalAccuracy(u32 battlerAtk, u32 battlerDef, u32 move, u32 atkAbility, u break; } - if (gProtectStructs[battlerAtk].usedMicleBerry) + if (gBattleStruct->usedMicleBerry & 1u << battlerAtk) { - gProtectStructs[battlerAtk].usedMicleBerry = FALSE; if (atkAbility == ABILITY_RIPEN) calc = (calc * 140) / 100; // ripen gives 40% acc boost else @@ -6417,7 +6416,6 @@ static void Cmd_moveend(void) DebugPrintfLevel(MGBA_LOG_WARN, "savedTargetCount is greater than 0! More calls to SaveBattlerTarget than RestoreBattlerTarget!"); // #endif } - gBattleStruct->targetsDone[gBattlerAttacker] = 0; gProtectStructs[gBattlerAttacker].targetAffected = FALSE; gProtectStructs[gBattlerAttacker].shellTrap = FALSE; @@ -6438,6 +6436,7 @@ static void Cmd_moveend(void) gBattleStruct->poisonPuppeteerConfusion = FALSE; gBattleStruct->fickleBeamBoosted = FALSE; gBattleStruct->distortedTypeMatchups = 0; + gBattleStruct->usedMicleBerry &= ~(1u << gBattlerAttacker); if (gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE) gBattleStruct->pledgeMove = FALSE; if (GetActiveGimmick(gBattlerAttacker) == GIMMICK_Z_MOVE) diff --git a/src/battle_util.c b/src/battle_util.c index 78491d2756..a3711f161c 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -6825,8 +6825,7 @@ static u8 TrySetMicleBerry(u32 battler, u32 itemId, bool32 end2) { if (HasEnoughHpToEatBerry(battler, 4, itemId)) { - gProtectStructs[battler].usedMicleBerry = TRUE; // battler's next attack has increased accuracy - + gBattleStruct->usedMicleBerry |= 1u << battler; if (end2) { BattleScriptExecute(BattleScript_MicleBerryActivateEnd2); diff --git a/test/battle/hold_effect/micle_berry.c b/test/battle/hold_effect/micle_berry.c index 2bc44c8069..87f6742609 100644 --- a/test/battle/hold_effect/micle_berry.c +++ b/test/battle/hold_effect/micle_berry.c @@ -64,3 +64,36 @@ SINGLE_BATTLE_TEST("Micle Berry raises the holder's accuracy by 1.2") ANIMATION(ANIM_TYPE_MOVE, MOVE_SUBMISSION, player); } } + +SINGLE_BATTLE_TEST("Micle Berry increases the accuracy of the next used move across turns") +{ + GIVEN { + ASSUME(gMovesInfo[MOVE_ROCK_SLIDE].accuracy == 90); + PASSES_RANDOMLY(100, 100, RNG_ACCURACY); + PLAYER(SPECIES_WOBBUFFET) { MaxHP(100); HP(26); Item(ITEM_MICLE_BERRY); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponent, MOVE_TACKLE); } + TURN { MOVE(player, MOVE_ROCK_SLIDE); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player); + ANIMATION(ANIM_TYPE_MOVE, MOVE_ROCK_SLIDE, player); + } +} + +SINGLE_BATTLE_TEST("Micle Berry increases the accuracy of the next used move the same turn the berry was triggered") +{ + GIVEN { + ASSUME(gMovesInfo[MOVE_ROCK_SLIDE].accuracy == 90); + PASSES_RANDOMLY(100, 100, RNG_ACCURACY); + PLAYER(SPECIES_WOBBUFFET) { MaxHP(100); HP(26); Item(ITEM_MICLE_BERRY); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponent, MOVE_TACKLE); MOVE(player, MOVE_ROCK_SLIDE); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player); + ANIMATION(ANIM_TYPE_MOVE, MOVE_ROCK_SLIDE, player); + } +}