Fixes Blunder Policy (#5722)
This commit is contained in:
parent
88cdd8bdfb
commit
0cd0e0b005
2 changed files with 74 additions and 2 deletions
|
@ -1767,8 +1767,6 @@ static void AccuracyCheck(bool32 recalcDragonDarts, const u8 *nextInstr, const u
|
|||
if (!RandomPercentage(RNG_ACCURACY, accuracy))
|
||||
{
|
||||
gMoveResultFlags |= MOVE_RESULT_MISSED;
|
||||
if (holdEffectAtk == HOLD_EFFECT_BLUNDER_POLICY)
|
||||
gBattleStruct->blunderPolicy = TRUE; // Only activates from missing through acc/evasion checks
|
||||
|
||||
if (gMovesInfo[gCurrentMove].effect == EFFECT_DRAGON_DARTS
|
||||
&& !recalcDragonDarts // So we don't jump back and forth between targets
|
||||
|
@ -2532,6 +2530,13 @@ static void Cmd_resultmessage(void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (gMoveResultFlags & MOVE_RESULT_MISSED && !(gMoveResultFlags & (MOVE_RESULT_DOESNT_AFFECT_FOE | MOVE_RESULT_FAILED)))
|
||||
{
|
||||
if (GetBattlerHoldEffect(gBattlerAttacker, TRUE) == HOLD_EFFECT_BLUNDER_POLICY
|
||||
&& !IsBattlerProtected(gBattlerAttacker, gBattlerTarget, gCurrentMove))
|
||||
gBattleStruct->blunderPolicy = TRUE; // Only activates from missing through acc/evasion checks
|
||||
}
|
||||
|
||||
if (gMoveResultFlags & MOVE_RESULT_MISSED && (!(gMoveResultFlags & MOVE_RESULT_DOESNT_AFFECT_FOE) || gBattleCommunication[MISS_TYPE] > B_MSG_AVOIDED_ATK))
|
||||
{
|
||||
if (gBattleCommunication[MISS_TYPE] > B_MSG_AVOIDED_ATK) // Wonder Guard or Levitate - show the ability pop-up
|
||||
|
|
67
test/battle/hold_effect/blunder_policy.c
Normal file
67
test/battle/hold_effect/blunder_policy.c
Normal file
|
@ -0,0 +1,67 @@
|
|||
#include "global.h"
|
||||
#include "test/battle.h"
|
||||
|
||||
ASSUMPTIONS
|
||||
{
|
||||
ASSUME(gItemsInfo[ITEM_BLUNDER_POLICY].holdEffect == HOLD_EFFECT_BLUNDER_POLICY);
|
||||
}
|
||||
|
||||
SINGLE_BATTLE_TEST("Blunder Policy raises the users speed by 2 stages if the user misses")
|
||||
{
|
||||
PASSES_RANDOMLY(3, 10, RNG_ACCURACY);
|
||||
GIVEN {
|
||||
ASSUME(gMovesInfo[MOVE_FOCUS_BLAST].accuracy == 70);
|
||||
PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_BLUNDER_POLICY); }
|
||||
OPPONENT(SPECIES_WOBBUFFET);
|
||||
} WHEN {
|
||||
TURN { MOVE(player, MOVE_FOCUS_BLAST); }
|
||||
} SCENE {
|
||||
NOT ANIMATION(ANIM_TYPE_MOVE, MOVE_FOCUS_BLAST, player);
|
||||
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
|
||||
} THEN {
|
||||
EXPECT(player->item == ITEM_NONE);
|
||||
EXPECT_EQ(player->statStages[STAT_SPEED], DEFAULT_STAT_STAGE + 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SINGLE_BATTLE_TEST("Blunder Policy will never trigger if the move fails due to an immunity")
|
||||
{
|
||||
PASSES_RANDOMLY(10, 10, RNG_ACCURACY);
|
||||
GIVEN {
|
||||
ASSUME(gMovesInfo[MOVE_FOCUS_BLAST].accuracy == 70);
|
||||
PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_BLUNDER_POLICY); }
|
||||
OPPONENT(SPECIES_GASTLY);
|
||||
} WHEN {
|
||||
TURN { MOVE(player, MOVE_FOCUS_BLAST); }
|
||||
} SCENE {
|
||||
NONE_OF {
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_FOCUS_BLAST, player);
|
||||
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
|
||||
}
|
||||
} THEN {
|
||||
EXPECT(player->item == ITEM_BLUNDER_POLICY);
|
||||
EXPECT_EQ(player->statStages[STAT_SPEED], DEFAULT_STAT_STAGE);
|
||||
}
|
||||
}
|
||||
|
||||
SINGLE_BATTLE_TEST("Blunder Policy will never trigger if the move fails due to Protect")
|
||||
{
|
||||
PASSES_RANDOMLY(10, 10, RNG_ACCURACY);
|
||||
GIVEN {
|
||||
ASSUME(gMovesInfo[MOVE_FOCUS_BLAST].accuracy == 70);
|
||||
PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_BLUNDER_POLICY); }
|
||||
OPPONENT(SPECIES_WOBBUFFET);
|
||||
} WHEN {
|
||||
TURN { MOVE(opponent, MOVE_PROTECT); MOVE(player, MOVE_FOCUS_BLAST); }
|
||||
} SCENE {
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_PROTECT, opponent);
|
||||
NONE_OF {
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_FOCUS_BLAST, player);
|
||||
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
|
||||
}
|
||||
} THEN {
|
||||
EXPECT(player->item == ITEM_BLUNDER_POLICY);
|
||||
EXPECT_EQ(player->statStages[STAT_SPEED], DEFAULT_STAT_STAGE);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue