Fixes Knock Off still activating when there is no Item (#7496)

This commit is contained in:
Alex 2025-08-13 15:00:04 +02:00 committed by GitHub
parent 18363207d9
commit 65b316625f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 24 additions and 6 deletions

View File

@ -2756,7 +2756,7 @@ static void Cmd_datahpupdate(void)
if (GetMoveEffect(gCurrentMove) == EFFECT_KNOCK_OFF
&& IsBattlerTurnDamaged(gBattlerTarget)
&& gBattleMons[gBattlerTarget].item != 0
&& gBattleMons[gBattlerTarget].item != ITEM_NONE
&& !DoesSubstituteBlockMove(gBattlerAttacker, battler, gCurrentMove)
&& CanBattlerGetOrLoseItem(gBattlerTarget, gBattleMons[gBattlerTarget].item)
&& !NoAliveMonsForEitherParty())
@ -6260,7 +6260,9 @@ static bool32 HandleMoveEndMoveBlock(u32 moveEffect)
switch (moveEffect)
{
case EFFECT_KNOCK_OFF:
if (gBattleStruct->battlerState[gBattlerTarget].itemCanBeKnockedOff && IsBattlerAlive(gBattlerAttacker))
if (gBattleStruct->battlerState[gBattlerTarget].itemCanBeKnockedOff
&& gBattleMons[gBattlerTarget].item != ITEM_NONE
&& IsBattlerAlive(gBattlerAttacker))
{
u32 side = GetBattlerSide(gBattlerTarget);
gLastUsedItem = gBattleMons[gBattlerTarget].item;
@ -6280,11 +6282,11 @@ static bool32 HandleMoveEndMoveBlock(u32 moveEffect)
gWishFutureKnock.knockedOffMons[side] |= 1u << gBattlerPartyIndexes[gBattlerTarget];
}
gBattleStruct->battlerState[gBattlerTarget].itemCanBeKnockedOff = FALSE;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_KnockedOff;
effect = TRUE;
}
gBattleStruct->battlerState[gBattlerTarget].itemCanBeKnockedOff = FALSE;
break;
case EFFECT_STEAL_ITEM:
if (!CanStealItem(gBattlerAttacker, gBattlerTarget, gBattleMons[gBattlerTarget].item)

View File

@ -21,7 +21,7 @@ SINGLE_BATTLE_TEST("Eject Pack does not cause the new Pokémon to lose HP due to
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Wobbuffet is switched out with the Eject Pack!");
SEND_IN_MESSAGE("Wynaut");
NOT MESSAGE("Wynaut was hurt by its Life Orb!");
NOT HP_BAR(player);
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, opponent);
}
}

View File

@ -455,7 +455,7 @@ SINGLE_BATTLE_TEST("Red Card does not cause the dragged out mon to lose hp due t
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent);
MESSAGE("The opposing Wobbuffet held up its Red Card against Wobbuffet!");
MESSAGE("Wynaut was dragged out!");
NOT MESSAGE("Wynaut was hurt by its Life Orb!");
NOT HP_BAR(player);
}
}

View File

@ -60,7 +60,7 @@ SINGLE_BATTLE_TEST("Future Sight is not boosted by Life Orb is original user if
ANIMATION(ANIM_TYPE_MOVE, MOVE_FUTURE_SIGHT, player);
MESSAGE("The opposing Regice took the Future Sight attack!");
HP_BAR(opponent, captureDamage: &futureSightDmg);
NOT MESSAGE("Raichu was hurt by its Life Orb!");
NOT HP_BAR(player);
} THEN {
EXPECT_EQ(seedFlareDmg, futureSightDmg);
}

View File

@ -394,3 +394,19 @@ SINGLE_BATTLE_TEST("Knock Off doesn't remove item if it's prevented by Sticky Ho
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent);
}
}
SINGLE_BATTLE_TEST("Knock Off does not activate if the item was previously consumed")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_AIR_BALLOON); }
} WHEN {
TURN { MOVE(player, MOVE_KNOCK_OFF); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_KNOCK_OFF, player);
MESSAGE("The opposing Wobbuffet's Air Balloon popped!");
NOT MESSAGE("Wobbuffet knocked off the opposing Wobbuffet's Air Balloon!");
} THEN {
EXPECT(opponent->item == ITEM_NONE);
}
}