Replace hp checks with IsBattlerAlive (#4429)
* add IsBattlerAlive to flame/toxic orb, convert a bunch of .hp != 0 and .hp == 0 checks to IsBattlerAlive * remove redundant IsBattlerAlive checks on flame/toxic orb * Update src/battle_util.c --------- Co-authored-by: ghoulslash <pokevoyager0@gmail.com> Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com>
This commit is contained in:
parent
da3d715f3b
commit
5538095785
@ -4072,7 +4072,7 @@ static void TryDoEventsBeforeFirstTurn(void)
|
||||
{
|
||||
struct Pokemon *party = GetBattlerParty(i);
|
||||
struct Pokemon *mon = &party[gBattlerPartyIndexes[i]];
|
||||
if (gBattleMons[i].hp == 0 || gBattleMons[i].species == SPECIES_NONE || GetMonData(mon, MON_DATA_IS_EGG))
|
||||
if (!IsBattlerAlive(i) || gBattleMons[i].species == SPECIES_NONE || GetMonData(mon, MON_DATA_IS_EGG))
|
||||
gAbsentBattlerFlags |= gBitTable[i];
|
||||
}
|
||||
}
|
||||
|
||||
@ -1273,7 +1273,7 @@ static void Cmd_attackcanceler(void)
|
||||
gCurrentActionFuncId = B_ACTION_FINISHED;
|
||||
return;
|
||||
}
|
||||
if (gBattleMons[gBattlerAttacker].hp == 0 && !(gHitMarker & HITMARKER_NO_ATTACKSTRING))
|
||||
if (!IsBattlerAlive(gBattlerAttacker) && !(gHitMarker & HITMARKER_NO_ATTACKSTRING))
|
||||
{
|
||||
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
|
||||
gBattlescriptCurrInstr = BattleScript_MoveEnd;
|
||||
@ -2798,7 +2798,7 @@ void SetMoveEffect(bool32 primary, bool32 certain)
|
||||
return;
|
||||
|
||||
if (gSpecialStatuses[gBattlerAttacker].parentalBondState == PARENTAL_BOND_1ST_HIT
|
||||
&& gBattleMons[gBattlerTarget].hp != 0
|
||||
&& IsBattlerAlive(gBattlerTarget)
|
||||
&& IsFinalStrikeEffect(gBattleScripting.moveEffect))
|
||||
{
|
||||
gBattlescriptCurrInstr++;
|
||||
@ -2862,7 +2862,7 @@ void SetMoveEffect(bool32 primary, bool32 certain)
|
||||
&& gBattleScripting.moveEffect != MOVE_EFFECT_CHARGING)
|
||||
INCREMENT_RESET_RETURN
|
||||
|
||||
if (gBattleMons[gEffectBattler].hp == 0 && !activateAfterFaint)
|
||||
if (!IsBattlerAlive(gEffectBattler) && !activateAfterFaint)
|
||||
INCREMENT_RESET_RETURN
|
||||
|
||||
if (DoesSubstituteBlockMove(gBattlerAttacker, gEffectBattler, gCurrentMove) && affectsUser != MOVE_EFFECT_AFFECTS_USER)
|
||||
@ -4010,7 +4010,7 @@ static void Cmd_tryfaintmon(void)
|
||||
faintScript = BattleScript_FaintTarget;
|
||||
}
|
||||
if (!(gAbsentBattlerFlags & gBitTable[battler])
|
||||
&& gBattleMons[battler].hp == 0)
|
||||
&& !IsBattlerAlive(battler))
|
||||
{
|
||||
gHitMarker |= HITMARKER_FAINTED(battler);
|
||||
BattleScriptPush(cmd->nextInstr);
|
||||
@ -4030,7 +4030,7 @@ static void Cmd_tryfaintmon(void)
|
||||
gBattleResults.lastOpponentSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES, NULL);
|
||||
gSideTimers[B_SIDE_OPPONENT].retaliateTimer = 2;
|
||||
}
|
||||
if ((gHitMarker & HITMARKER_DESTINYBOND) && gBattleMons[gBattlerAttacker].hp != 0
|
||||
if ((gHitMarker & HITMARKER_DESTINYBOND) && IsBattlerAlive(gBattlerAttacker)
|
||||
&& !IsDynamaxed(gBattlerAttacker))
|
||||
{
|
||||
gHitMarker &= ~HITMARKER_DESTINYBOND;
|
||||
@ -4041,7 +4041,7 @@ static void Cmd_tryfaintmon(void)
|
||||
if ((gStatuses3[gBattlerTarget] & STATUS3_GRUDGE)
|
||||
&& !(gHitMarker & HITMARKER_GRUDGE)
|
||||
&& GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget)
|
||||
&& gBattleMons[gBattlerAttacker].hp != 0
|
||||
&& IsBattlerAlive(gBattlerAttacker)
|
||||
&& gCurrentMove != MOVE_STRUGGLE)
|
||||
{
|
||||
u8 moveIndex = *(gBattleStruct->chosenMovePositions + gBattlerAttacker);
|
||||
@ -4083,7 +4083,7 @@ static void Cmd_cleareffectsonfaint(void)
|
||||
{
|
||||
u32 battler = GetBattlerForBattleScript(cmd->battler);
|
||||
const u8 *clearDataResult = NULL;
|
||||
if (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || gBattleMons[battler].hp == 0)
|
||||
if (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !IsBattlerAlive(battler))
|
||||
{
|
||||
gBattleMons[battler].status1 = 0;
|
||||
BtlController_EmitSetMonData(battler, BUFFER_A, REQUEST_STATUS_BATTLE, 0, sizeof(gBattleMons[battler].status1), &gBattleMons[battler].status1);
|
||||
@ -4106,7 +4106,7 @@ static void Cmd_jumpifstatus(void)
|
||||
u32 flags = cmd->flags;
|
||||
const u8 *jumpInstr = cmd->jumpInstr;
|
||||
|
||||
if (gBattleMons[battler].status1 & flags && gBattleMons[battler].hp != 0)
|
||||
if (gBattleMons[battler].status1 & flags && IsBattlerAlive(battler))
|
||||
gBattlescriptCurrInstr = jumpInstr;
|
||||
else
|
||||
gBattlescriptCurrInstr = cmd->nextInstr;
|
||||
@ -4120,7 +4120,7 @@ static void Cmd_jumpifstatus2(void)
|
||||
u32 flags = cmd->flags;
|
||||
const u8 *jumpInstr = cmd->jumpInstr;
|
||||
|
||||
if (gBattleMons[battler].status2 & flags && gBattleMons[battler].hp != 0)
|
||||
if (gBattleMons[battler].status2 & flags && IsBattlerAlive(battler))
|
||||
gBattlescriptCurrInstr = jumpInstr;
|
||||
else
|
||||
gBattlescriptCurrInstr = cmd->nextInstr;
|
||||
@ -5407,14 +5407,14 @@ static bool32 TryKnockOffBattleScript(u32 battlerDef)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define SYMBIOSIS_CHECK(battler, ally) \
|
||||
#define SYMBIOSIS_CHECK(battler, ally) \
|
||||
GetBattlerAbility(ally) == ABILITY_SYMBIOSIS \
|
||||
&& gBattleMons[battler].item == ITEM_NONE \
|
||||
&& gBattleMons[ally].item != ITEM_NONE \
|
||||
&& CanBattlerGetOrLoseItem(battler, gBattleMons[ally].item) \
|
||||
&& CanBattlerGetOrLoseItem(ally, gBattleMons[ally].item) \
|
||||
&& gBattleMons[battler].hp != 0 \
|
||||
&& gBattleMons[ally].hp != 0
|
||||
&& IsBattlerAlive(battler) \
|
||||
&& IsBattlerAlive(ally)
|
||||
|
||||
static u32 GetNextTarget(u32 moveTarget, bool32 excludeCurrent)
|
||||
{
|
||||
@ -5549,7 +5549,7 @@ static void Cmd_moveend(void)
|
||||
break;
|
||||
case MOVEEND_RAGE: // rage check
|
||||
if (gBattleMons[gBattlerTarget].status2 & STATUS2_RAGE
|
||||
&& gBattleMons[gBattlerTarget].hp != 0
|
||||
&& IsBattlerAlive(gBattlerTarget)
|
||||
&& gBattlerAttacker != gBattlerTarget
|
||||
&& GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget)
|
||||
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
|
||||
@ -5566,7 +5566,7 @@ static void Cmd_moveend(void)
|
||||
break;
|
||||
case MOVEEND_DEFROST: // defrosting check
|
||||
if (gBattleMons[gBattlerTarget].status1 & STATUS1_FREEZE
|
||||
&& gBattleMons[gBattlerTarget].hp != 0
|
||||
&& IsBattlerAlive(gBattlerTarget)
|
||||
&& gBattlerAttacker != gBattlerTarget
|
||||
&& (moveType == TYPE_FIRE || CanBurnHitThaw(gCurrentMove))
|
||||
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT))
|
||||
@ -5579,7 +5579,7 @@ static void Cmd_moveend(void)
|
||||
effect = TRUE;
|
||||
}
|
||||
if (gBattleMons[gBattlerTarget].status1 & STATUS1_FROSTBITE
|
||||
&& gBattleMons[gBattlerTarget].hp != 0
|
||||
&& IsBattlerAlive(gBattlerTarget)
|
||||
&& gBattlerAttacker != gBattlerTarget
|
||||
&& gMovesInfo[originallyUsedMove].thawsUser
|
||||
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT))
|
||||
@ -6453,7 +6453,7 @@ static void Cmd_switchindataupdate(void)
|
||||
monData[i] = gBattleResources->bufferB[battler][4 + i];
|
||||
|
||||
// Edge case: the sent out pokemon has 0 HP. This should never happen.
|
||||
if (gBattleMons[battler].hp == 0)
|
||||
if (!IsBattlerAlive(battler))
|
||||
{
|
||||
// If it's a test, mark it as invalid.
|
||||
if (gTestRunnerEnabled)
|
||||
@ -6506,7 +6506,7 @@ static void Cmd_switchindataupdate(void)
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_PALACE
|
||||
&& gBattleMons[battler].maxHP / 2 >= gBattleMons[battler].hp
|
||||
&& gBattleMons[battler].hp != 0
|
||||
&& IsBattlerAlive(battler)
|
||||
&& !(gBattleMons[battler].status1 & STATUS1_SLEEP))
|
||||
{
|
||||
gBattleStruct->palaceFlags |= gBitTable[battler];
|
||||
@ -8359,7 +8359,7 @@ static void Cmd_hpthresholds(void)
|
||||
if (result == 0)
|
||||
result = 1;
|
||||
|
||||
if (result > 69 || gBattleMons[opposingBattler].hp == 0)
|
||||
if (result > 69 || !IsBattlerAlive(opposingBattler))
|
||||
gBattleStruct->hpScale = 0;
|
||||
else if (result > 39)
|
||||
gBattleStruct->hpScale = 1;
|
||||
@ -9208,8 +9208,8 @@ static void Cmd_various(void)
|
||||
VARIOUS_ARGS();
|
||||
if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_DOUBLE))
|
||||
&& gBattleTypeFlags & BATTLE_TYPE_TRAINER
|
||||
&& gBattleMons[0].hp != 0
|
||||
&& gBattleMons[1].hp != 0)
|
||||
&& IsBattlerAlive(B_POSITION_PLAYER_LEFT)
|
||||
&& IsBattlerAlive(B_POSITION_OPPONENT_LEFT))
|
||||
{
|
||||
gHitMarker &= ~HITMARKER_PLAYER_FAINTED;
|
||||
}
|
||||
@ -9223,7 +9223,7 @@ static void Cmd_various(void)
|
||||
gBattleScripting.battler = battler = gBattleCommunication[1];
|
||||
if (!(gBattleStruct->palaceFlags & gBitTable[battler])
|
||||
&& gBattleMons[battler].maxHP / 2 >= gBattleMons[battler].hp
|
||||
&& gBattleMons[battler].hp != 0
|
||||
&& IsBattlerAlive(battler)
|
||||
&& !(gBattleMons[battler].status1 & STATUS1_SLEEP))
|
||||
{
|
||||
gBattleStruct->palaceFlags |= gBitTable[battler];
|
||||
@ -9323,7 +9323,7 @@ static void Cmd_various(void)
|
||||
{
|
||||
VARIOUS_ARGS();
|
||||
battler = 1;
|
||||
if (gBattleMons[battler].hp != 0)
|
||||
if (IsBattlerAlive(battler))
|
||||
{
|
||||
BtlController_EmitReturnMonToBall(battler, BUFFER_A, FALSE);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
@ -9336,7 +9336,7 @@ static void Cmd_various(void)
|
||||
if (gBattlersCount > 3)
|
||||
{
|
||||
battler = 3;
|
||||
if (gBattleMons[battler].hp != 0)
|
||||
if (IsBattlerAlive(battler))
|
||||
{
|
||||
BtlController_EmitReturnMonToBall(battler, BUFFER_A, FALSE);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
@ -11438,7 +11438,7 @@ static void Cmd_stockpiletobasedamage(void)
|
||||
if (gBattleCommunication[MISS_TYPE] != B_MSG_PROTECTED)
|
||||
gBattleScripting.animTurn = gDisableStructs[gBattlerAttacker].stockpileCounter;
|
||||
|
||||
if (!(gSpecialStatuses[gBattlerAttacker].parentalBondState == PARENTAL_BOND_1ST_HIT && gBattleMons[gBattlerTarget].hp != 0))
|
||||
if (!(gSpecialStatuses[gBattlerAttacker].parentalBondState == PARENTAL_BOND_1ST_HIT && IsBattlerAlive(gBattlerTarget)))
|
||||
{
|
||||
gBattleStruct->moveEffect2 = MOVE_EFFECT_STOCKPILE_WORE_OFF;
|
||||
}
|
||||
@ -13815,7 +13815,7 @@ static void Cmd_trydobeatup(void)
|
||||
CMD_ARGS(const u8 *endInstr, const u8 *failInstr);
|
||||
struct Pokemon *party = GetBattlerParty(gBattlerAttacker);
|
||||
|
||||
if (gBattleMons[gBattlerTarget].hp == 0)
|
||||
if (!IsBattlerAlive(gBattlerTarget))
|
||||
{
|
||||
gBattlescriptCurrInstr = cmd->endInstr;
|
||||
}
|
||||
@ -14640,7 +14640,7 @@ static void Cmd_jumpifhasnohp(void)
|
||||
|
||||
u32 battler = GetBattlerForBattleScript(cmd->battler);
|
||||
|
||||
if (gBattleMons[battler].hp == 0)
|
||||
if (!IsBattlerAlive(battler))
|
||||
gBattlescriptCurrInstr = cmd->jumpInstr;
|
||||
else
|
||||
gBattlescriptCurrInstr = cmd->nextInstr;
|
||||
@ -15903,7 +15903,7 @@ void BS_CheckParentalBondCounter(void)
|
||||
NATIVE_ARGS(u8 counter, const u8 *jumpInstr);
|
||||
// Some effects should only happen on the first or second strike of Parental Bond,
|
||||
// so a way to check this in battle scripts is useful
|
||||
if (gSpecialStatuses[gBattlerAttacker].parentalBondState == cmd->counter && gBattleMons[gBattlerTarget].hp != 0)
|
||||
if (gSpecialStatuses[gBattlerAttacker].parentalBondState == cmd->counter && IsBattlerAlive(gBattlerTarget))
|
||||
gBattlescriptCurrInstr = cmd->jumpInstr;
|
||||
else
|
||||
gBattlescriptCurrInstr = cmd->nextInstr;
|
||||
|
||||
@ -110,7 +110,7 @@ bool32 IsAffectedByFollowMe(u32 battlerAtk, u32 defSide, u32 move)
|
||||
u32 ability = GetBattlerAbility(battlerAtk);
|
||||
|
||||
if (gSideTimers[defSide].followmeTimer == 0
|
||||
|| gBattleMons[gSideTimers[defSide].followmeTarget].hp == 0
|
||||
|| !IsBattlerAlive(gSideTimers[defSide].followmeTarget)
|
||||
|| gMovesInfo[move].effect == EFFECT_SNIPE_SHOT
|
||||
|| gMovesInfo[move].effect == EFFECT_SKY_DROP
|
||||
|| ability == ABILITY_PROPELLER_TAIL || ability == ABILITY_STALWART)
|
||||
@ -191,7 +191,7 @@ void HandleAction_UseMove(void)
|
||||
gCurrentMove = gBattleStruct->zmove.toBeUsed[gBattlerAttacker];
|
||||
}
|
||||
|
||||
if (gBattleMons[gBattlerAttacker].hp != 0)
|
||||
if (IsBattlerAlive(gBattlerAttacker))
|
||||
{
|
||||
if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER)
|
||||
gBattleResults.lastUsedMovePlayer = gCurrentMove;
|
||||
@ -367,7 +367,7 @@ void HandleAction_UseMove(void)
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_PALACE && gProtectStructs[gBattlerAttacker].palaceUnableToUseMove)
|
||||
{
|
||||
// Battle Palace, select battle script for failure to use move
|
||||
if (gBattleMons[gBattlerAttacker].hp == 0)
|
||||
if (!IsBattlerAlive(gBattlerAttacker))
|
||||
{
|
||||
gCurrentActionFuncId = B_ACTION_FINISHED;
|
||||
return;
|
||||
@ -1941,7 +1941,7 @@ u8 DoFieldEndTurnEffects(void)
|
||||
u32 battler = gBattlerByTurnOrder[gBattleStruct->turnSideTracker];
|
||||
if (gWishFutureKnock.wishCounter[battler] != 0
|
||||
&& --gWishFutureKnock.wishCounter[battler] == 0
|
||||
&& gBattleMons[battler].hp != 0)
|
||||
&& IsBattlerAlive(battler))
|
||||
{
|
||||
gBattlerTarget = battler;
|
||||
BattleScriptExecute(BattleScript_WishComesTrue);
|
||||
@ -2415,7 +2415,7 @@ u8 DoBattlerEndTurnEffects(void)
|
||||
if ((gStatuses3[battler] & STATUS3_ROOTED)
|
||||
&& !BATTLER_MAX_HP(battler)
|
||||
&& !(gStatuses3[battler] & STATUS3_HEAL_BLOCK)
|
||||
&& gBattleMons[battler].hp != 0)
|
||||
&& IsBattlerAlive(battler))
|
||||
{
|
||||
gBattleMoveDamage = GetDrainedBigRootHp(battler, GetNonDynamaxMaxHP(battler) / 16);
|
||||
BattleScriptExecute(BattleScript_IngrainTurnHeal);
|
||||
@ -2427,7 +2427,7 @@ u8 DoBattlerEndTurnEffects(void)
|
||||
if ((gStatuses3[battler] & STATUS3_AQUA_RING)
|
||||
&& !BATTLER_MAX_HP(battler)
|
||||
&& !(gStatuses3[battler] & STATUS3_HEAL_BLOCK)
|
||||
&& gBattleMons[battler].hp != 0)
|
||||
&& IsBattlerAlive(battler))
|
||||
{
|
||||
gBattleMoveDamage = GetDrainedBigRootHp(battler, GetNonDynamaxMaxHP(battler) / 16);
|
||||
BattleScriptExecute(BattleScript_AquaRingHeal);
|
||||
@ -2457,8 +2457,8 @@ u8 DoBattlerEndTurnEffects(void)
|
||||
break;
|
||||
case ENDTURN_LEECH_SEED: // leech seed
|
||||
if ((gStatuses3[battler] & STATUS3_LEECHSEED)
|
||||
&& gBattleMons[gStatuses3[battler] & STATUS3_LEECHSEED_BATTLER].hp != 0
|
||||
&& gBattleMons[battler].hp != 0)
|
||||
&& IsBattlerAlive(gStatuses3[battler] & STATUS3_LEECHSEED_BATTLER)
|
||||
&& IsBattlerAlive(battler))
|
||||
{
|
||||
MAGIC_GUARD_CHECK;
|
||||
|
||||
@ -2475,7 +2475,7 @@ u8 DoBattlerEndTurnEffects(void)
|
||||
break;
|
||||
case ENDTURN_POISON: // poison
|
||||
if ((gBattleMons[battler].status1 & STATUS1_POISON)
|
||||
&& gBattleMons[battler].hp != 0)
|
||||
&& IsBattlerAlive(battler))
|
||||
{
|
||||
MAGIC_GUARD_CHECK;
|
||||
|
||||
@ -2504,7 +2504,7 @@ u8 DoBattlerEndTurnEffects(void)
|
||||
break;
|
||||
case ENDTURN_BAD_POISON: // toxic poison
|
||||
if ((gBattleMons[battler].status1 & STATUS1_TOXIC_POISON)
|
||||
&& gBattleMons[battler].hp != 0)
|
||||
&& IsBattlerAlive(battler))
|
||||
{
|
||||
MAGIC_GUARD_CHECK;
|
||||
|
||||
@ -2536,7 +2536,7 @@ u8 DoBattlerEndTurnEffects(void)
|
||||
break;
|
||||
case ENDTURN_BURN: // burn
|
||||
if ((gBattleMons[battler].status1 & STATUS1_BURN)
|
||||
&& gBattleMons[battler].hp != 0)
|
||||
&& IsBattlerAlive(battler))
|
||||
{
|
||||
MAGIC_GUARD_CHECK;
|
||||
gBattleMoveDamage = GetNonDynamaxMaxHP(battler) / (B_BURN_DAMAGE >= GEN_7 ? 16 : 8);
|
||||
@ -2555,7 +2555,7 @@ u8 DoBattlerEndTurnEffects(void)
|
||||
break;
|
||||
case ENDTURN_FROSTBITE: // burn
|
||||
if ((gBattleMons[battler].status1 & STATUS1_FROSTBITE)
|
||||
&& gBattleMons[battler].hp != 0)
|
||||
&& IsBattlerAlive(battler))
|
||||
{
|
||||
MAGIC_GUARD_CHECK;
|
||||
gBattleMoveDamage = GetNonDynamaxMaxHP(battler) / (B_BURN_DAMAGE >= GEN_7 ? 16 : 8);
|
||||
@ -2568,7 +2568,7 @@ u8 DoBattlerEndTurnEffects(void)
|
||||
break;
|
||||
case ENDTURN_NIGHTMARES: // spooky nightmares
|
||||
if ((gBattleMons[battler].status2 & STATUS2_NIGHTMARE)
|
||||
&& gBattleMons[battler].hp != 0)
|
||||
&& IsBattlerAlive(battler))
|
||||
{
|
||||
MAGIC_GUARD_CHECK;
|
||||
// R/S does not perform this sleep check, which causes the nightmare effect to
|
||||
@ -2590,7 +2590,7 @@ u8 DoBattlerEndTurnEffects(void)
|
||||
break;
|
||||
case ENDTURN_CURSE: // curse
|
||||
if ((gBattleMons[battler].status2 & STATUS2_CURSED)
|
||||
&& gBattleMons[battler].hp != 0)
|
||||
&& IsBattlerAlive(battler))
|
||||
{
|
||||
MAGIC_GUARD_CHECK;
|
||||
gBattleMoveDamage = GetNonDynamaxMaxHP(battler) / 4;
|
||||
@ -2602,7 +2602,7 @@ u8 DoBattlerEndTurnEffects(void)
|
||||
gBattleStruct->turnEffectsTracker++;
|
||||
break;
|
||||
case ENDTURN_WRAP: // wrap
|
||||
if ((gBattleMons[battler].status2 & STATUS2_WRAPPED) && gBattleMons[battler].hp != 0)
|
||||
if ((gBattleMons[battler].status2 & STATUS2_WRAPPED) && IsBattlerAlive(battler))
|
||||
{
|
||||
if (--gDisableStructs[battler].wrapTurns != 0) // damaged by wrap
|
||||
{
|
||||
@ -2908,7 +2908,7 @@ u8 DoBattlerEndTurnEffects(void)
|
||||
gBattleStruct->turnEffectsTracker++;
|
||||
break;
|
||||
case ENDTURN_SALT_CURE:
|
||||
if (gStatuses4[battler] & STATUS4_SALT_CURE && gBattleMons[battler].hp != 0)
|
||||
if (gStatuses4[battler] & STATUS4_SALT_CURE && IsBattlerAlive(battler))
|
||||
{
|
||||
gBattlerTarget = battler;
|
||||
if (IS_BATTLER_OF_TYPE(gBattlerTarget, TYPE_STEEL) || IS_BATTLER_OF_TYPE(gBattlerTarget, TYPE_WATER))
|
||||
@ -2924,7 +2924,7 @@ u8 DoBattlerEndTurnEffects(void)
|
||||
gBattleStruct->turnEffectsTracker++;
|
||||
break;
|
||||
case ENDTURN_SYRUP_BOMB:
|
||||
if ((gStatuses4[battler] & STATUS4_SYRUP_BOMB) && (gBattleMons[battler].hp != 0))
|
||||
if ((gStatuses4[battler] & STATUS4_SYRUP_BOMB) && (IsBattlerAlive(battler)))
|
||||
{
|
||||
if (gDisableStructs[battler].syrupBombTimer > 0 && --gDisableStructs[battler].syrupBombTimer == 0)
|
||||
gStatuses4[battler] &= ~STATUS4_SYRUP_BOMB;
|
||||
@ -3066,7 +3066,7 @@ bool32 HandleWishPerishSongOnTurnEnd(void)
|
||||
case 2:
|
||||
if ((gBattleTypeFlags & BATTLE_TYPE_ARENA)
|
||||
&& gBattleStruct->arenaTurnCounter == 2
|
||||
&& gBattleMons[0].hp != 0 && gBattleMons[1].hp != 0)
|
||||
&& IsBattlerAlive(B_POSITION_PLAYER_LEFT) && IsBattlerAlive(B_POSITION_OPPONENT_LEFT))
|
||||
{
|
||||
s32 i;
|
||||
|
||||
@ -4829,7 +4829,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
|
||||
}
|
||||
break;
|
||||
case ABILITYEFFECT_ENDTURN: // 1
|
||||
if (gBattleMons[battler].hp != 0)
|
||||
if (IsBattlerAlive(battler))
|
||||
{
|
||||
gBattlerAttacker = battler;
|
||||
switch (gLastUsedAbility)
|
||||
@ -5382,7 +5382,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
|
||||
&& TARGET_TURN_DAMAGED
|
||||
&& !IS_BATTLER_OF_TYPE(battler, moveType)
|
||||
&& moveType != TYPE_STELLAR
|
||||
&& gBattleMons[battler].hp != 0)
|
||||
&& IsBattlerAlive(battler))
|
||||
{
|
||||
SET_BATTLER_TYPE(battler, moveType);
|
||||
PREPARE_TYPE_BUFFER(gBattleTextBuff1, moveType);
|
||||
@ -5394,7 +5394,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
|
||||
case ABILITY_GOOEY:
|
||||
case ABILITY_TANGLING_HAIR:
|
||||
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
|
||||
&& gBattleMons[gBattlerAttacker].hp != 0
|
||||
&& IsBattlerAlive(gBattlerAttacker)
|
||||
&& (CompareStat(gBattlerAttacker, STAT_SPEED, MIN_STAT_STAGE, CMP_GREATER_THAN) || GetBattlerAbility(gBattlerAttacker) == ABILITY_MIRROR_ARMOR)
|
||||
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
|
||||
&& TARGET_TURN_DAMAGED
|
||||
@ -5412,7 +5412,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
|
||||
case ABILITY_ROUGH_SKIN:
|
||||
case ABILITY_IRON_BARBS:
|
||||
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
|
||||
&& gBattleMons[gBattlerAttacker].hp != 0
|
||||
&& IsBattlerAlive(gBattlerAttacker)
|
||||
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
|
||||
&& TARGET_TURN_DAMAGED
|
||||
&& GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS
|
||||
@ -5429,7 +5429,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
|
||||
break;
|
||||
case ABILITY_AFTERMATH:
|
||||
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
|
||||
&& gBattleMons[gBattlerTarget].hp == 0
|
||||
&& !IsBattlerAlive(gBattlerTarget)
|
||||
&& IsBattlerAlive(gBattlerAttacker)
|
||||
&& GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS
|
||||
&& IsMoveMakingContact(move, gBattlerAttacker))
|
||||
@ -5454,7 +5454,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
|
||||
break;
|
||||
case ABILITY_INNARDS_OUT:
|
||||
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
|
||||
&& gBattleMons[gBattlerTarget].hp == 0
|
||||
&& !IsBattlerAlive(gBattlerTarget)
|
||||
&& IsBattlerAlive(gBattlerAttacker))
|
||||
{
|
||||
gBattleMoveDamage = gSpecialStatuses[gBattlerTarget].shellBellDmg;
|
||||
@ -5475,7 +5475,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
|
||||
goto STATIC;
|
||||
// Sleep
|
||||
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
|
||||
&& gBattleMons[gBattlerAttacker].hp != 0
|
||||
&& IsBattlerAlive(gBattlerAttacker)
|
||||
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
|
||||
&& TARGET_TURN_DAMAGED
|
||||
&& CanSleep(gBattlerAttacker)
|
||||
@ -5495,7 +5495,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
|
||||
POISON_POINT:
|
||||
case ABILITY_POISON_POINT:
|
||||
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
|
||||
&& gBattleMons[gBattlerAttacker].hp != 0
|
||||
&& IsBattlerAlive(gBattlerAttacker)
|
||||
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
|
||||
&& TARGET_TURN_DAMAGED
|
||||
&& CanBePoisoned(gBattlerTarget, gBattlerAttacker)
|
||||
@ -5514,7 +5514,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
|
||||
STATIC:
|
||||
case ABILITY_STATIC:
|
||||
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
|
||||
&& gBattleMons[gBattlerAttacker].hp != 0
|
||||
&& IsBattlerAlive(gBattlerAttacker)
|
||||
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
|
||||
&& TARGET_TURN_DAMAGED
|
||||
&& CanBeParalyzed(gBattlerAttacker)
|
||||
@ -5531,7 +5531,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
|
||||
break;
|
||||
case ABILITY_FLAME_BODY:
|
||||
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
|
||||
&& gBattleMons[gBattlerAttacker].hp != 0
|
||||
&& IsBattlerAlive(gBattlerAttacker)
|
||||
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
|
||||
&& GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS
|
||||
&& (IsMoveMakingContact(move, gBattlerAttacker))
|
||||
@ -5548,10 +5548,10 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
|
||||
break;
|
||||
case ABILITY_CUTE_CHARM:
|
||||
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
|
||||
&& gBattleMons[gBattlerAttacker].hp != 0
|
||||
&& IsBattlerAlive(gBattlerAttacker)
|
||||
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
|
||||
&& TARGET_TURN_DAMAGED
|
||||
&& gBattleMons[gBattlerTarget].hp != 0
|
||||
&& IsBattlerAlive(gBattlerTarget)
|
||||
&& RandomWeighted(RNG_CUTE_CHARM, 2, 1)
|
||||
&& !(gBattleMons[gBattlerAttacker].status2 & STATUS2_INFATUATION)
|
||||
&& AreBattlersOfOppositeGender(gBattlerAttacker, gBattlerTarget)
|
||||
@ -5576,7 +5576,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
|
||||
break;
|
||||
case ABILITY_COTTON_DOWN:
|
||||
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
|
||||
&& gBattleMons[gBattlerAttacker].hp != 0
|
||||
&& IsBattlerAlive(gBattlerAttacker)
|
||||
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
|
||||
&& TARGET_TURN_DAMAGED)
|
||||
{
|
||||
@ -5754,7 +5754,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
|
||||
{
|
||||
case ABILITY_POISON_TOUCH:
|
||||
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
|
||||
&& gBattleMons[gBattlerTarget].hp != 0
|
||||
&& IsBattlerAlive(gBattlerTarget)
|
||||
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
|
||||
&& CanBePoisoned(gBattlerAttacker, gBattlerTarget)
|
||||
&& GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS
|
||||
@ -5772,7 +5772,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
|
||||
break;
|
||||
case ABILITY_STENCH:
|
||||
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
|
||||
&& gBattleMons[gBattlerTarget].hp != 0
|
||||
&& IsBattlerAlive(gBattlerTarget)
|
||||
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
|
||||
&& RandomWeighted(RNG_STENCH, 9, 1)
|
||||
&& TARGET_TURN_DAMAGED
|
||||
@ -6463,7 +6463,7 @@ bool32 HasEnoughHpToEatBerry(u32 battler, u32 hpFraction, u32 itemId)
|
||||
{
|
||||
bool32 isBerry = (ItemId_GetPocket(itemId) == POCKET_BERRIES);
|
||||
|
||||
if (gBattleMons[battler].hp == 0)
|
||||
if (!IsBattlerAlive(battler))
|
||||
return FALSE;
|
||||
if (gBattleScripting.overrideBerryRequirements)
|
||||
return TRUE;
|
||||
@ -7727,7 +7727,7 @@ u8 ItemBattleEffects(u8 caseID, u32 battler, bool32 moveTurn)
|
||||
break;
|
||||
case HOLD_EFFECT_BLUNDER_POLICY:
|
||||
if (gBattleStruct->blunderPolicy
|
||||
&& gBattleMons[gBattlerAttacker].hp != 0
|
||||
&& IsBattlerAlive(gBattlerAttacker)
|
||||
&& CompareStat(gBattlerAttacker, STAT_SPEED, MAX_STAT_STAGE, CMP_LESS_THAN))
|
||||
{
|
||||
gBattleStruct->blunderPolicy = FALSE;
|
||||
@ -7748,7 +7748,7 @@ u8 ItemBattleEffects(u8 caseID, u32 battler, bool32 moveTurn)
|
||||
if (gSpecialStatuses[gBattlerAttacker].damagedMons // Need to have done damage
|
||||
&& gBattlerAttacker != gBattlerTarget
|
||||
&& gBattleMons[gBattlerAttacker].hp != gBattleMons[gBattlerAttacker].maxHP
|
||||
&& gBattleMons[gBattlerAttacker].hp != 0
|
||||
&& IsBattlerAlive(gBattlerAttacker)
|
||||
&& (B_HEAL_BLOCKING < GEN_5 || !(gStatuses3[battler] & STATUS3_HEAL_BLOCK)))
|
||||
{
|
||||
gLastUsedItem = atkItem;
|
||||
@ -7781,7 +7781,7 @@ u8 ItemBattleEffects(u8 caseID, u32 battler, bool32 moveTurn)
|
||||
break;
|
||||
case HOLD_EFFECT_THROAT_SPRAY: // Does NOT need to be a damaging move
|
||||
if (gProtectStructs[gBattlerAttacker].targetAffected
|
||||
&& gBattleMons[gBattlerAttacker].hp != 0
|
||||
&& IsBattlerAlive(gBattlerAttacker)
|
||||
&& gMovesInfo[gCurrentMove].soundMove
|
||||
&& CompareStat(gBattlerAttacker, STAT_SPATK, MAX_STAT_STAGE, CMP_LESS_THAN)
|
||||
&& !NoAliveMonsForEitherParty()) // Don't activate if battle will end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user