fixes Micle Berry not increasing accuracy on the next turn (#5358)
* fixes Micle Berry not increasing accuracy on the next turn * adds bitfield instead of using protect struct * test from pawkkie * ndebug * renaming * delete redundant comment * typo * micle berry more detailed descriptions
This commit is contained in:
parent
9d483cee5d
commit
0d7c193e4c
4 changed files with 38 additions and 6 deletions
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue