Fix Kings Rock not being ignored by flinch moves (#8327)

This commit is contained in:
Alex 2025-11-23 10:27:55 +01:00 committed by GitHub
parent 9b0a36e1d3
commit 7c20fbd76b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 55 additions and 5 deletions

View File

@ -6934,17 +6934,17 @@ u32 ItemBattleEffects(enum ItemCaseId caseID, u32 battler)
switch (atkHoldEffect)
{
case HOLD_EFFECT_FLINCH:
if (!MoveIgnoresKingsRock(gCurrentMove)
&& !MoveHasAdditionalEffect(gCurrentMove, MOVE_EFFECT_FLINCH)
&& IsBattlerTurnDamaged(gBattlerTarget)
&& IsBattlerAlive(gBattlerTarget))
{
u16 ability = GetBattlerAbility(gBattlerAttacker);
if (B_SERENE_GRACE_BOOST >= GEN_5 && ability == ABILITY_SERENE_GRACE)
atkHoldEffectParam *= 2;
if (gSideStatuses[GetBattlerSide(battler)] & SIDE_STATUS_RAINBOW && gCurrentMove != MOVE_SECRET_POWER)
atkHoldEffectParam *= 2;
if (IsBattlerTurnDamaged(gBattlerTarget)
&& !MoveIgnoresKingsRock(gCurrentMove)
&& gBattleMons[gBattlerTarget].hp
&& RandomPercentage(RNG_HOLD_EFFECT_FLINCH, atkHoldEffectParam)
&& ability != ABILITY_STENCH)
if (ability != ABILITY_STENCH && RandomPercentage(RNG_HOLD_EFFECT_FLINCH, atkHoldEffectParam))
{
gBattleScripting.moveEffect = MOVE_EFFECT_FLINCH;
BattleScriptPushCursor();

View File

@ -0,0 +1,36 @@
#include "global.h"
#include "test/battle.h"
ASSUMPTIONS
{
ASSUME(gItemsInfo[ITEM_KINGS_ROCK].holdEffect == HOLD_EFFECT_FLINCH);
}
SINGLE_BATTLE_TEST("Kings Rock holder will flinch the target 10% of the time")
{
PASSES_RANDOMLY(10, 100, RNG_HOLD_EFFECT_FLINCH);
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_KINGS_ROCK); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_SCRATCH); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_SCRATCH, player);
MESSAGE("The opposing Wobbuffet flinched and couldn't move!");
}
}
SINGLE_BATTLE_TEST("Kings Rock does not increase flinch chance of a move that has the flinch effect")
{
PASSES_RANDOMLY(30, 100, RNG_SECONDARY_EFFECT);
GIVEN {
ASSUME(MoveHasAdditionalEffect(MOVE_HEADBUTT, MOVE_EFFECT_FLINCH));
PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_KINGS_ROCK); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_HEADBUTT); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_HEADBUTT, player);
MESSAGE("The opposing Wobbuffet flinched and couldn't move!");
}
}

View File

@ -69,3 +69,17 @@ SINGLE_BATTLE_TEST("Protect always works when used after flinching")
NOT ANIMATION(ANIM_TYPE_MOVE, MOVE_HEADBUTT, opponent);
}
}
SINGLE_BATTLE_TEST("Headbutt flinches 30% of the time")
{
PASSES_RANDOMLY(30, 100, RNG_SECONDARY_EFFECT);
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_HEADBUTT); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_HEADBUTT, player);
MESSAGE("The opposing Wobbuffet flinched and couldn't move!");
}
}