Fixes Life Orb damage still happening after attacker was unable to attack (#6940)

This commit is contained in:
Alex 2025-05-21 16:16:33 +02:00 committed by GitHub
parent ce9bbcc3b7
commit ce079cfcc8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 0 deletions

View File

@ -8167,6 +8167,7 @@ u32 ItemBattleEffects(enum ItemCaseId caseID, u32 battler, bool32 moveTurn)
{
case HOLD_EFFECT_SHELL_BELL:
if (gBattleScripting.savedDmg > 0
&& !(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE)
&& !(gBattleStruct->moveResultFlags[gBattlerTarget] & MOVE_RESULT_NO_EFFECT)
&& gBattlerAttacker != gBattlerTarget
&& !IsBattlerAtMaxHp(gBattlerAttacker)
@ -8188,6 +8189,7 @@ u32 ItemBattleEffects(enum ItemCaseId caseID, u32 battler, bool32 moveTurn)
break;
case HOLD_EFFECT_LIFE_ORB:
if (IsBattlerAlive(gBattlerAttacker)
&& !(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE)
&& !IsBattleMoveStatus(gCurrentMove)
&& (IsBattlerTurnDamaged(gBattlerTarget) || !(gBattleStruct->moveResultFlags[gBattlerTarget] & MOVE_RESULT_NO_EFFECT)) // Needs the second check in case of Substitute
&& !(TestIfSheerForceAffected(gBattlerAttacker, gCurrentMove))

View File

@ -1,6 +1,21 @@
#include "global.h"
#include "test/battle.h"
SINGLE_BATTLE_TEST("Life Orb activates when users attack is succesful")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_LIFE_ORB); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_POUND); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_POUND, player);
HP_BAR(opponent);
HP_BAR(player);
MESSAGE("Wobbuffet was hurt by the Life Orb!");
}
}
SINGLE_BATTLE_TEST("Life Orb activates if it hits a Substitute")
{
GIVEN {
@ -31,3 +46,21 @@ SINGLE_BATTLE_TEST("Life Orb does not activate if using a status move")
}
}
}
SINGLE_BATTLE_TEST("Life Orb doesn't cause any HP loss if user is unable to attack")
{
PASSES_RANDOMLY(25, 100, RNG_PARALYSIS);
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_LIFE_ORB); Status1(STATUS1_PARALYSIS); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_POUND); }
} SCENE {
NONE_OF {
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, player);
HP_BAR(opponent);
HP_BAR(player);
MESSAGE("Wobbuffet was hurt by the Life Orb!");
}
}
}