Changes target TURN_DAMAGED and MAX_HP to inlines (#5822)

This commit is contained in:
Alex 2024-12-17 23:21:12 +01:00 committed by GitHub
parent 3b594e2f38
commit a2aba3f86a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 98 additions and 90 deletions

View file

@ -869,10 +869,6 @@ STATIC_ASSERT(sizeof(((struct BattleStruct *)0)->palaceFlags) * 8 >= MAX_BATTLER
#define IS_MOVE_STATUS(move)(gMovesInfo[move].category == DAMAGE_CATEGORY_STATUS) #define IS_MOVE_STATUS(move)(gMovesInfo[move].category == DAMAGE_CATEGORY_STATUS)
#define IS_MOVE_RECOIL(move)(gMovesInfo[move].recoil > 0 || gMovesInfo[move].effect == EFFECT_RECOIL_IF_MISS) #define IS_MOVE_RECOIL(move)(gMovesInfo[move].recoil > 0 || gMovesInfo[move].effect == EFFECT_RECOIL_IF_MISS)
#define BATTLER_MAX_HP(battlerId)(gBattleMons[battlerId].hp == gBattleMons[battlerId].maxHP)
#define TARGET_TURN_DAMAGED ((gSpecialStatuses[gBattlerTarget].physicalDmg != 0 || gSpecialStatuses[gBattlerTarget].specialDmg != 0) || (gBattleStruct->enduredDamage & (1u << gBattlerTarget)))
#define BATTLER_TURN_DAMAGED(battlerId) ((gSpecialStatuses[battlerId].physicalDmg != 0 || gSpecialStatuses[battlerId].specialDmg != 0) || (gBattleStruct->enduredDamage & (1u << battler)))
/* Checks if 'battlerId' is any of the types. /* Checks if 'battlerId' is any of the types.
* Passing multiple types is more efficient than calling this multiple * Passing multiple types is more efficient than calling this multiple
* times with one type because it shares the 'GetBattlerTypes' result. */ * times with one type because it shares the 'GetBattlerTypes' result. */
@ -1196,6 +1192,18 @@ extern bool8 gLastUsedBallMenuPresent;
extern u8 gPartyCriticalHits[PARTY_SIZE]; extern u8 gPartyCriticalHits[PARTY_SIZE];
extern u8 gCategoryIconSpriteId; extern u8 gCategoryIconSpriteId;
static inline bool32 IsBattlerTurnDamaged(u32 battler)
{
return gSpecialStatuses[battler].physicalDmg != 0
|| gSpecialStatuses[battler].specialDmg != 0
|| gBattleStruct->enduredDamage & (1u << battler);
}
static inline bool32 IsBattlerAtMaxHp(u32 battler)
{
return gBattleMons[battler].hp == gBattleMons[battler].maxHP;
}
static inline u32 GetBattlerPosition(u32 battler) static inline u32 GetBattlerPosition(u32 battler)
{ {
return gBattlerPositions[battler]; return gBattlerPositions[battler];

View file

@ -44,7 +44,7 @@ void RestoreBattlerData(u32 battlerId);
u32 GetAIChosenMove(u32 battlerId); u32 GetAIChosenMove(u32 battlerId);
u32 GetTotalBaseStat(u32 species); u32 GetTotalBaseStat(u32 species);
bool32 IsTruantMonVulnerable(u32 battlerAI, u32 opposingBattler); bool32 IsTruantMonVulnerable(u32 battlerAI, u32 opposingBattler);
bool32 AtMaxHp(u32 battler); bool32 AI_BattlerAtMaxHp(u32 battler);
u32 GetHealthPercentage(u32 battler); u32 GetHealthPercentage(u32 battler);
bool32 IsBattlerTrapped(u32 battler, bool32 switching); bool32 IsBattlerTrapped(u32 battler, bool32 switching);
s32 AI_WhoStrikesFirst(u32 battlerAI, u32 battler2, u32 moveConsidered); s32 AI_WhoStrikesFirst(u32 battlerAI, u32 battler2, u32 moveConsidered);

View file

@ -1663,7 +1663,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
} }
else else
{ {
if (AtMaxHp(battlerAtk)) if (AI_BattlerAtMaxHp(battlerAtk))
ADJUST_SCORE(-10); ADJUST_SCORE(-10);
else if (aiData->hpPercents[battlerAtk] >= 80) else if (aiData->hpPercents[battlerAtk] >= 80)
ADJUST_SCORE(-5); // do it if nothing better ADJUST_SCORE(-5); // do it if nothing better
@ -1802,7 +1802,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
case EFFECT_RESTORE_HP: case EFFECT_RESTORE_HP:
case EFFECT_SOFTBOILED: case EFFECT_SOFTBOILED:
case EFFECT_ROOST: case EFFECT_ROOST:
if (AtMaxHp(battlerAtk)) if (AI_BattlerAtMaxHp(battlerAtk))
ADJUST_SCORE(-10); ADJUST_SCORE(-10);
else if (aiData->hpPercents[battlerAtk] >= 90) else if (aiData->hpPercents[battlerAtk] >= 90)
ADJUST_SCORE(-9); //No point in healing, but should at least do it if nothing better ADJUST_SCORE(-9); //No point in healing, but should at least do it if nothing better
@ -1812,7 +1812,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
case EFFECT_MOONLIGHT: case EFFECT_MOONLIGHT:
if ((AI_GetWeather(aiData) & (B_WEATHER_RAIN | B_WEATHER_SANDSTORM | B_WEATHER_HAIL | B_WEATHER_SNOW | B_WEATHER_FOG))) if ((AI_GetWeather(aiData) & (B_WEATHER_RAIN | B_WEATHER_SANDSTORM | B_WEATHER_HAIL | B_WEATHER_SNOW | B_WEATHER_FOG)))
ADJUST_SCORE(-3); ADJUST_SCORE(-3);
else if (AtMaxHp(battlerAtk)) else if (AI_BattlerAtMaxHp(battlerAtk))
ADJUST_SCORE(-10); ADJUST_SCORE(-10);
else if (aiData->hpPercents[battlerAtk] >= 90) else if (aiData->hpPercents[battlerAtk] >= 90)
ADJUST_SCORE(-9); //No point in healing, but should at least do it if nothing better ADJUST_SCORE(-9); //No point in healing, but should at least do it if nothing better
@ -1822,7 +1822,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
ADJUST_SCORE(-10); ADJUST_SCORE(-10);
else if (battlerDef == BATTLE_PARTNER(battlerAtk)) else if (battlerDef == BATTLE_PARTNER(battlerAtk))
break; //Always heal your ally break; //Always heal your ally
else if (AtMaxHp(battlerAtk)) else if (AI_BattlerAtMaxHp(battlerAtk))
ADJUST_SCORE(-10); ADJUST_SCORE(-10);
else if (aiData->hpPercents[battlerAtk] >= 90) else if (aiData->hpPercents[battlerAtk] >= 90)
ADJUST_SCORE(-8); //No point in healing, but should at least do it if nothing better ADJUST_SCORE(-8); //No point in healing, but should at least do it if nothing better
@ -2390,7 +2390,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
{ {
if (gStatuses3[battlerDef] & STATUS3_HEAL_BLOCK) if (gStatuses3[battlerDef] & STATUS3_HEAL_BLOCK)
return 0; // cannot even select return 0; // cannot even select
if (AtMaxHp(battlerDef)) if (AI_BattlerAtMaxHp(battlerDef))
ADJUST_SCORE(-10); ADJUST_SCORE(-10);
else if (gBattleMons[battlerDef].hp > gBattleMons[battlerDef].maxHP / 2) else if (gBattleMons[battlerDef].hp > gBattleMons[battlerDef].maxHP / 2)
ADJUST_SCORE(-5); ADJUST_SCORE(-5);
@ -2559,8 +2559,8 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
ADJUST_SCORE(-10); ADJUST_SCORE(-10);
break; break;
case EFFECT_JUNGLE_HEALING: case EFFECT_JUNGLE_HEALING:
if (AtMaxHp(battlerAtk) if (AI_BattlerAtMaxHp(battlerAtk)
&& AtMaxHp(BATTLE_PARTNER(battlerAtk)) && AI_BattlerAtMaxHp(BATTLE_PARTNER(battlerAtk))
&& !(gBattleMons[battlerAtk].status1 & STATUS1_ANY) && !(gBattleMons[battlerAtk].status1 & STATUS1_ANY)
&& !(gBattleMons[BATTLE_PARTNER(battlerAtk)].status1 & STATUS1_ANY)) && !(gBattleMons[BATTLE_PARTNER(battlerAtk)].status1 & STATUS1_ANY))
ADJUST_SCORE(-10); ADJUST_SCORE(-10);

View file

@ -290,7 +290,7 @@ u32 GetHealthPercentage(u32 battlerId)
return (u32)((100 * gBattleMons[battlerId].hp) / gBattleMons[battlerId].maxHP); return (u32)((100 * gBattleMons[battlerId].hp) / gBattleMons[battlerId].maxHP);
} }
bool32 AtMaxHp(u32 battlerId) bool32 AI_BattlerAtMaxHp(u32 battlerId)
{ {
if (AI_DATA->hpPercents[battlerId] == 100) if (AI_DATA->hpPercents[battlerId] == 100)
return TRUE; return TRUE;
@ -1142,7 +1142,7 @@ s32 AI_WhoStrikesFirst(u32 battlerAI, u32 battler, u32 moveConsidered)
static bool32 CanEndureHit(u32 battler, u32 battlerTarget, u32 move) static bool32 CanEndureHit(u32 battler, u32 battlerTarget, u32 move)
{ {
if (!BATTLER_MAX_HP(battlerTarget) || gMovesInfo[move].effect == EFFECT_MULTI_HIT) if (!AI_BattlerAtMaxHp(battlerTarget) || gMovesInfo[move].effect == EFFECT_MULTI_HIT)
return FALSE; return FALSE;
if (gMovesInfo[move].strikeCount > 1 && !(gMovesInfo[move].effect == EFFECT_DRAGON_DARTS && IsValidDoubleBattle(battlerTarget))) if (gMovesInfo[move].strikeCount > 1 && !(gMovesInfo[move].effect == EFFECT_DRAGON_DARTS && IsValidDoubleBattle(battlerTarget)))
return FALSE; return FALSE;
@ -1564,7 +1564,7 @@ bool32 ShouldTryOHKO(u32 battlerAtk, u32 battlerDef, u32 atkAbility, u32 defAbil
gPotentialItemEffectBattler = battlerDef; gPotentialItemEffectBattler = battlerDef;
if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < AI_DATA->holdEffectParams[battlerDef]) if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < AI_DATA->holdEffectParams[battlerDef])
return FALSE; //probabilistically speaking, focus band should activate so dont OHKO return FALSE; //probabilistically speaking, focus band should activate so dont OHKO
else if (holdEffect == HOLD_EFFECT_FOCUS_SASH && AtMaxHp(battlerDef)) else if (holdEffect == HOLD_EFFECT_FOCUS_SASH && AI_BattlerAtMaxHp(battlerDef))
return FALSE; return FALSE;
if (!DoesBattlerIgnoreAbilityChecks(atkAbility, move) && defAbility == ABILITY_STURDY) if (!DoesBattlerIgnoreAbilityChecks(atkAbility, move) && defAbility == ABILITY_STURDY)
@ -2761,7 +2761,7 @@ enum AIPivot ShouldPivot(u32 battlerAtk, u32 battlerDef, u32 defAbility, u32 mov
return SHOULD_PIVOT; // Won't get the two turns, pivot return SHOULD_PIVOT; // Won't get the two turns, pivot
if (!IS_MOVE_STATUS(move) && ((AI_DATA->shouldSwitch & (1u << battlerAtk)) if (!IS_MOVE_STATUS(move) && ((AI_DATA->shouldSwitch & (1u << battlerAtk))
|| (AtMaxHp(battlerDef) && (AI_DATA->holdEffects[battlerDef] == HOLD_EFFECT_FOCUS_SASH || (AI_BattlerAtMaxHp(battlerDef) && (AI_DATA->holdEffects[battlerDef] == HOLD_EFFECT_FOCUS_SASH
|| (B_STURDY >= GEN_5 && defAbility == ABILITY_STURDY) || (B_STURDY >= GEN_5 && defAbility == ABILITY_STURDY)
|| defAbility == ABILITY_MULTISCALE || defAbility == ABILITY_MULTISCALE
|| defAbility == ABILITY_SHADOW_SHIELD)))) || defAbility == ABILITY_SHADOW_SHIELD))))
@ -2769,7 +2769,7 @@ enum AIPivot ShouldPivot(u32 battlerAtk, u32 battlerDef, u32 defAbility, u32 mov
} }
else if (!hasStatBoost) else if (!hasStatBoost)
{ {
if (!IS_MOVE_STATUS(move) && (AtMaxHp(battlerDef) && (AI_DATA->holdEffects[battlerDef] == HOLD_EFFECT_FOCUS_SASH if (!IS_MOVE_STATUS(move) && (AI_BattlerAtMaxHp(battlerDef) && (AI_DATA->holdEffects[battlerDef] == HOLD_EFFECT_FOCUS_SASH
|| (B_STURDY >= GEN_5 && defAbility == ABILITY_STURDY) || (B_STURDY >= GEN_5 && defAbility == ABILITY_STURDY)
|| defAbility == ABILITY_MULTISCALE || defAbility == ABILITY_MULTISCALE
|| defAbility == ABILITY_SHADOW_SHIELD))) || defAbility == ABILITY_SHADOW_SHIELD)))
@ -2848,7 +2848,7 @@ enum AIPivot ShouldPivot(u32 battlerAtk, u32 battlerDef, u32 defAbility, u32 mov
// can knock out foe in 2 hits // can knock out foe in 2 hits
if (IS_MOVE_STATUS(move) && ((AI_DATA->shouldSwitch & (1u << battlerAtk)) //Damaging move if (IS_MOVE_STATUS(move) && ((AI_DATA->shouldSwitch & (1u << battlerAtk)) //Damaging move
//&& (switchScore >= SWITCHING_INCREASE_RESIST_ALL_MOVES + SWITCHING_INCREASE_KO_FOE //remove hazards //&& (switchScore >= SWITCHING_INCREASE_RESIST_ALL_MOVES + SWITCHING_INCREASE_KO_FOE //remove hazards
|| (AI_DATA->holdEffects[battlerDef] == HOLD_EFFECT_FOCUS_SASH && AtMaxHp(battlerDef)))) || (AI_DATA->holdEffects[battlerDef] == HOLD_EFFECT_FOCUS_SASH && AI_BattlerAtMaxHp(battlerDef))))
return DONT_PIVOT; // Pivot to break the sash return DONT_PIVOT; // Pivot to break the sash
else else
return CAN_TRY_PIVOT; return CAN_TRY_PIVOT;

View file

@ -4854,7 +4854,7 @@ s8 GetMovePriority(u32 battler, u16 move)
return gMovesInfo[MOVE_MAX_GUARD].priority; return gMovesInfo[MOVE_MAX_GUARD].priority;
if (ability == ABILITY_GALE_WINGS if (ability == ABILITY_GALE_WINGS
&& (B_GALE_WINGS < GEN_7 || BATTLER_MAX_HP(battler)) && (B_GALE_WINGS < GEN_7 || IsBattlerAtMaxHp(battler))
&& gMovesInfo[move].type == TYPE_FLYING) && gMovesInfo[move].type == TYPE_FLYING)
{ {
priority++; priority++;

View file

@ -2208,12 +2208,12 @@ static void Cmd_adjustdamage(void)
RecordItemEffectBattle(battlerDef, holdEffect); RecordItemEffectBattle(battlerDef, holdEffect);
gSpecialStatuses[battlerDef].focusBanded = TRUE; gSpecialStatuses[battlerDef].focusBanded = TRUE;
} }
else if (B_STURDY >= GEN_5 && GetBattlerAbility(battlerDef) == ABILITY_STURDY && BATTLER_MAX_HP(battlerDef)) else if (B_STURDY >= GEN_5 && GetBattlerAbility(battlerDef) == ABILITY_STURDY && IsBattlerAtMaxHp(battlerDef))
{ {
RecordAbilityBattle(battlerDef, ABILITY_STURDY); RecordAbilityBattle(battlerDef, ABILITY_STURDY);
gSpecialStatuses[battlerDef].sturdied = TRUE; gSpecialStatuses[battlerDef].sturdied = TRUE;
} }
else if (holdEffect == HOLD_EFFECT_FOCUS_SASH && BATTLER_MAX_HP(battlerDef)) else if (holdEffect == HOLD_EFFECT_FOCUS_SASH && IsBattlerAtMaxHp(battlerDef))
{ {
RecordItemEffectBattle(battlerDef, holdEffect); RecordItemEffectBattle(battlerDef, holdEffect);
gSpecialStatuses[battlerDef].focusSashed = TRUE; gSpecialStatuses[battlerDef].focusSashed = TRUE;
@ -5997,7 +5997,7 @@ static void Cmd_moveend(void)
&& gBattlerAttacker != gBattlerTarget && gBattlerAttacker != gBattlerTarget
&& GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget) && GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget)
&& MoveResultHasEffect(gBattlerTarget) && MoveResultHasEffect(gBattlerTarget)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& gMovesInfo[gCurrentMove].power != 0 && gMovesInfo[gCurrentMove].power != 0
&& CompareStat(gBattlerTarget, STAT_ATK, MAX_STAT_STAGE, CMP_LESS_THAN)) && CompareStat(gBattlerTarget, STAT_ATK, MAX_STAT_STAGE, CMP_LESS_THAN))
{ {
@ -6282,7 +6282,7 @@ static void Cmd_moveend(void)
if (gBattlerAttacker != gBattlerTarget if (gBattlerAttacker != gBattlerTarget
&& gMovesInfo[gCurrentMove].category != DAMAGE_CATEGORY_STATUS && gMovesInfo[gCurrentMove].category != DAMAGE_CATEGORY_STATUS
&& MoveResultHasEffect(gBattlerTarget) && MoveResultHasEffect(gBattlerTarget)
&& TARGET_TURN_DAMAGED) && IsBattlerTurnDamaged(gBattlerTarget))
{ {
gBattleStruct->timesGotHit[GetBattlerSide(gBattlerTarget)][gBattlerPartyIndexes[gBattlerTarget]]++; gBattleStruct->timesGotHit[GetBattlerSide(gBattlerTarget)][gBattlerPartyIndexes[gBattlerTarget]]++;
} }
@ -6563,7 +6563,7 @@ static void Cmd_moveend(void)
&& gBattleMons[gBattlerAttacker].item == ITEM_NONE && gBattleMons[gBattlerAttacker].item == ITEM_NONE
&& gBattleMons[gBattlerTarget].item != ITEM_NONE && gBattleMons[gBattlerTarget].item != ITEM_NONE
&& IsBattlerAlive(gBattlerAttacker) && IsBattlerAlive(gBattlerAttacker)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& CanStealItem(gBattlerAttacker, gBattlerTarget, gBattleMons[gBattlerTarget].item) && CanStealItem(gBattlerAttacker, gBattlerTarget, gBattleMons[gBattlerTarget].item)
&& !gSpecialStatuses[gBattlerAttacker].gemBoost // In base game, gems are consumed after magician would activate. && !gSpecialStatuses[gBattlerAttacker].gemBoost // In base game, gems are consumed after magician would activate.
&& !(gWishFutureKnock.knockedOffMons[GetBattlerSide(gBattlerTarget)] & (1u << gBattlerPartyIndexes[gBattlerTarget])) && !(gWishFutureKnock.knockedOffMons[GetBattlerSide(gBattlerTarget)] & (1u << gBattlerPartyIndexes[gBattlerTarget]))
@ -6609,7 +6609,7 @@ static void Cmd_moveend(void)
continue; continue;
// Since we check if battler was damaged, we don't need to check move result. // Since we check if battler was damaged, we don't need to check move result.
// In fact, doing so actually prevents multi-target moves from activating eject button properly // In fact, doing so actually prevents multi-target moves from activating eject button properly
if (!BATTLER_TURN_DAMAGED(battler)) if (!IsBattlerTurnDamaged(battler))
continue; continue;
} }
else if (ejectPackBattlers & (1u << battler)) else if (ejectPackBattlers & (1u << battler))
@ -6704,7 +6704,7 @@ static void Cmd_moveend(void)
if (redCardBattlers & (1u << battler) if (redCardBattlers & (1u << battler)
&& IsBattlerAlive(battler) && IsBattlerAlive(battler)
&& !DoesSubstituteBlockMove(gBattlerAttacker, battler, gCurrentMove) && !DoesSubstituteBlockMove(gBattlerAttacker, battler, gCurrentMove)
&& BATTLER_TURN_DAMAGED(battler) && IsBattlerTurnDamaged(battler)
&& CanBattlerSwitch(gBattlerAttacker)) && CanBattlerSwitch(gBattlerAttacker))
{ {
gLastUsedItem = gBattleMons[battler].item; gLastUsedItem = gBattleMons[battler].item;
@ -6753,7 +6753,7 @@ static void Cmd_moveend(void)
// Attacker is mon who made contact, battler is mon with pickpocket // Attacker is mon who made contact, battler is mon with pickpocket
if (battler != gBattlerAttacker // Cannot pickpocket yourself if (battler != gBattlerAttacker // Cannot pickpocket yourself
&& GetBattlerAbility(battler) == ABILITY_PICKPOCKET // Target must have pickpocket ability && GetBattlerAbility(battler) == ABILITY_PICKPOCKET // Target must have pickpocket ability
&& BATTLER_TURN_DAMAGED(battler) // Target needs to have been damaged && IsBattlerTurnDamaged(battler) // Target needs to have been damaged
&& !DoesSubstituteBlockMove(gBattlerAttacker, battler, gCurrentMove) // Subsitute unaffected && !DoesSubstituteBlockMove(gBattlerAttacker, battler, gCurrentMove) // Subsitute unaffected
&& IsBattlerAlive(battler) // Battler must be alive to pickpocket && IsBattlerAlive(battler) // Battler must be alive to pickpocket
&& gBattleMons[battler].item == ITEM_NONE // Pickpocketer can't have an item already && gBattleMons[battler].item == ITEM_NONE // Pickpocketer can't have an item already
@ -8514,7 +8514,7 @@ static bool32 TryCheekPouch(u32 battler, u32 itemId)
&& GetBattlerAbility(battler) == ABILITY_CHEEK_POUCH && GetBattlerAbility(battler) == ABILITY_CHEEK_POUCH
&& !(gStatuses3[battler] & STATUS3_HEAL_BLOCK) && !(gStatuses3[battler] & STATUS3_HEAL_BLOCK)
&& gBattleStruct->ateBerry[GetBattlerSide(battler)] & (1u << gBattlerPartyIndexes[battler]) && gBattleStruct->ateBerry[GetBattlerSide(battler)] & (1u << gBattlerPartyIndexes[battler])
&& !BATTLER_MAX_HP(battler)) && !IsBattlerAtMaxHp(battler))
{ {
gBattleStruct->moveDamage[battler] = GetNonDynamaxMaxHP(battler) / 3; gBattleStruct->moveDamage[battler] = GetNonDynamaxMaxHP(battler) / 3;
if (gBattleStruct->moveDamage[battler] == 0) if (gBattleStruct->moveDamage[battler] == 0)
@ -9585,7 +9585,7 @@ static void Cmd_various(void)
case VARIOUS_JUMP_IF_FULL_HP: case VARIOUS_JUMP_IF_FULL_HP:
{ {
VARIOUS_ARGS(const u8 *jumpInstr); VARIOUS_ARGS(const u8 *jumpInstr);
if (BATTLER_MAX_HP(battler)) if (IsBattlerAtMaxHp(battler))
gBattlescriptCurrInstr = cmd->jumpInstr; gBattlescriptCurrInstr = cmd->jumpInstr;
else else
gBattlescriptCurrInstr = cmd->nextInstr; gBattlescriptCurrInstr = cmd->nextInstr;
@ -9687,7 +9687,7 @@ static void Cmd_various(void)
{ {
VARIOUS_ARGS(const u8 *failInstr); VARIOUS_ARGS(const u8 *failInstr);
if ((gStatuses3[battler] & (STATUS3_SEMI_INVULNERABLE | STATUS3_HEAL_BLOCK)) if ((gStatuses3[battler] & (STATUS3_SEMI_INVULNERABLE | STATUS3_HEAL_BLOCK))
|| BATTLER_MAX_HP(battler) || IsBattlerAtMaxHp(battler)
|| !gBattleMons[battler].hp || !gBattleMons[battler].hp
|| !(IsBattlerGrounded(battler))) || !(IsBattlerGrounded(battler)))
{ {
@ -12696,7 +12696,7 @@ static void Cmd_tryKO(void)
gSpecialStatuses[gBattlerTarget].focusBanded = TRUE; gSpecialStatuses[gBattlerTarget].focusBanded = TRUE;
RecordItemEffectBattle(gBattlerTarget, holdEffect); RecordItemEffectBattle(gBattlerTarget, holdEffect);
} }
else if (holdEffect == HOLD_EFFECT_FOCUS_SASH && BATTLER_MAX_HP(gBattlerTarget)) else if (holdEffect == HOLD_EFFECT_FOCUS_SASH && IsBattlerAtMaxHp(gBattlerTarget))
{ {
gSpecialStatuses[gBattlerTarget].focusSashed = TRUE; gSpecialStatuses[gBattlerTarget].focusSashed = TRUE;
RecordItemEffectBattle(gBattlerTarget, holdEffect); RecordItemEffectBattle(gBattlerTarget, holdEffect);
@ -17238,7 +17238,7 @@ void BS_TryHealPulse(void)
{ {
NATIVE_ARGS(const u8 *failInstr); NATIVE_ARGS(const u8 *failInstr);
if (BATTLER_MAX_HP(gBattlerTarget)) if (IsBattlerAtMaxHp(gBattlerTarget))
{ {
gBattlescriptCurrInstr = cmd->failInstr; gBattlescriptCurrInstr = cmd->failInstr;
} }
@ -17495,7 +17495,7 @@ void BS_TryActivateGulpMissile(void)
if (MoveResultHasEffect(gBattlerTarget) if (MoveResultHasEffect(gBattlerTarget)
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& gBattleMons[gBattlerTarget].species != SPECIES_CRAMORANT && gBattleMons[gBattlerTarget].species != SPECIES_CRAMORANT
&& GetBattlerAbility(gBattlerTarget) == ABILITY_GULP_MISSILE) && GetBattlerAbility(gBattlerTarget) == ABILITY_GULP_MISSILE)
{ {
@ -17696,7 +17696,7 @@ void BS_TryHitSwitchTarget(void)
if (IsBattlerAlive(gBattlerAttacker) if (IsBattlerAlive(gBattlerAttacker)
&& IsBattlerAlive(gBattlerTarget) && IsBattlerAlive(gBattlerTarget)
&& MoveResultHasEffect(gBattlerTarget) && MoveResultHasEffect(gBattlerTarget)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& gSpecialStatuses[gBattlerAttacker].parentalBondState != PARENTAL_BOND_1ST_HIT && gSpecialStatuses[gBattlerAttacker].parentalBondState != PARENTAL_BOND_1ST_HIT
&& GetBattlerAbility(gBattlerTarget) != ABILITY_GUARD_DOG) && GetBattlerAbility(gBattlerTarget) != ABILITY_GUARD_DOG)
{ {

View file

@ -2255,7 +2255,7 @@ u8 DoBattlerEndTurnEffects(void)
else if (gBattleWeather & (B_WEATHER_HAIL | B_WEATHER_SNOW) else if (gBattleWeather & (B_WEATHER_HAIL | B_WEATHER_SNOW)
&& ability == ABILITY_ICE_BODY && ability == ABILITY_ICE_BODY
&& !(gStatuses3[battler] & (STATUS3_UNDERGROUND | STATUS3_UNDERWATER)) && !(gStatuses3[battler] & (STATUS3_UNDERGROUND | STATUS3_UNDERWATER))
&& !BATTLER_MAX_HP(battler) && !IsBattlerAtMaxHp(battler)
&& !(gStatuses3[battler] & STATUS3_HEAL_BLOCK)) && !(gStatuses3[battler] & STATUS3_HEAL_BLOCK))
{ {
gBattleScripting.battler = battler; gBattleScripting.battler = battler;
@ -2282,7 +2282,7 @@ u8 DoBattlerEndTurnEffects(void)
break; break;
case ENDTURN_INGRAIN: // ingrain case ENDTURN_INGRAIN: // ingrain
if ((gStatuses3[battler] & STATUS3_ROOTED) if ((gStatuses3[battler] & STATUS3_ROOTED)
&& !BATTLER_MAX_HP(battler) && !IsBattlerAtMaxHp(battler)
&& !(gStatuses3[battler] & STATUS3_HEAL_BLOCK) && !(gStatuses3[battler] & STATUS3_HEAL_BLOCK)
&& IsBattlerAlive(battler)) && IsBattlerAlive(battler))
{ {
@ -2294,7 +2294,7 @@ u8 DoBattlerEndTurnEffects(void)
break; break;
case ENDTURN_AQUA_RING: // aqua ring case ENDTURN_AQUA_RING: // aqua ring
if ((gStatuses3[battler] & STATUS3_AQUA_RING) if ((gStatuses3[battler] & STATUS3_AQUA_RING)
&& !BATTLER_MAX_HP(battler) && !IsBattlerAtMaxHp(battler)
&& !(gStatuses3[battler] & STATUS3_HEAL_BLOCK) && !(gStatuses3[battler] & STATUS3_HEAL_BLOCK)
&& IsBattlerAlive(battler)) && IsBattlerAlive(battler))
{ {
@ -2372,7 +2372,7 @@ u8 DoBattlerEndTurnEffects(void)
{ {
if (ability == ABILITY_POISON_HEAL) if (ability == ABILITY_POISON_HEAL)
{ {
if (!BATTLER_MAX_HP(battler) && !(gStatuses3[battler] & STATUS3_HEAL_BLOCK)) if (!IsBattlerAtMaxHp(battler) && !(gStatuses3[battler] & STATUS3_HEAL_BLOCK))
{ {
gBattleStruct->moveDamage[battler] = GetNonDynamaxMaxHP(battler) / 8; gBattleStruct->moveDamage[battler] = GetNonDynamaxMaxHP(battler) / 8;
if (gBattleStruct->moveDamage[battler] == 0) if (gBattleStruct->moveDamage[battler] == 0)
@ -2400,7 +2400,7 @@ u8 DoBattlerEndTurnEffects(void)
{ {
if (ability == ABILITY_POISON_HEAL) if (ability == ABILITY_POISON_HEAL)
{ {
if (!BATTLER_MAX_HP(battler) && !(gStatuses3[battler] & STATUS3_HEAL_BLOCK)) if (!IsBattlerAtMaxHp(battler) && !(gStatuses3[battler] & STATUS3_HEAL_BLOCK))
{ {
gBattleStruct->moveDamage[battler] = GetNonDynamaxMaxHP(battler) / 8; gBattleStruct->moveDamage[battler] = GetNonDynamaxMaxHP(battler) / 8;
if (gBattleStruct->moveDamage[battler] == 0) if (gBattleStruct->moveDamage[battler] == 0)
@ -5148,7 +5148,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
// Dry Skin works similarly to Rain Dish in Rain // Dry Skin works similarly to Rain Dish in Rain
case ABILITY_RAIN_DISH: case ABILITY_RAIN_DISH:
if (IsBattlerWeatherAffected(battler, B_WEATHER_RAIN) if (IsBattlerWeatherAffected(battler, B_WEATHER_RAIN)
&& !BATTLER_MAX_HP(battler) && !IsBattlerAtMaxHp(battler)
&& !(gStatuses3[battler] & STATUS3_HEAL_BLOCK)) && !(gStatuses3[battler] & STATUS3_HEAL_BLOCK))
{ {
BattleScriptPushCursorAndCallback(BattleScript_RainDishActivates); BattleScriptPushCursorAndCallback(BattleScript_RainDishActivates);
@ -5403,7 +5403,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
{ {
case MOVE_ABSORBED_BY_DRAIN_HP_ABILITY: case MOVE_ABSORBED_BY_DRAIN_HP_ABILITY:
gBattleStruct->pledgeMove = FALSE; gBattleStruct->pledgeMove = FALSE;
if (BATTLER_MAX_HP(battler) || (B_HEAL_BLOCKING >= GEN_5 && gStatuses3[battler] & STATUS3_HEAL_BLOCK)) if (IsBattlerAtMaxHp(battler) || (B_HEAL_BLOCKING >= GEN_5 && gStatuses3[battler] & STATUS3_HEAL_BLOCK))
{ {
if ((gProtectStructs[gBattlerAttacker].notFirstStrike)) if ((gProtectStructs[gBattlerAttacker].notFirstStrike))
gBattlescriptCurrInstr = BattleScript_MonMadeMoveUseless; gBattlescriptCurrInstr = BattleScript_MonMadeMoveUseless;
@ -5475,7 +5475,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
{ {
case ABILITY_JUSTIFIED: case ABILITY_JUSTIFIED:
if (MoveResultHasEffect(battler) if (MoveResultHasEffect(battler)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& IsBattlerAlive(battler) && IsBattlerAlive(battler)
&& moveType == TYPE_DARK && moveType == TYPE_DARK
&& CompareStat(battler, STAT_ATK, MAX_STAT_STAGE, CMP_LESS_THAN)) && CompareStat(battler, STAT_ATK, MAX_STAT_STAGE, CMP_LESS_THAN))
@ -5489,7 +5489,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
break; break;
case ABILITY_RATTLED: case ABILITY_RATTLED:
if (MoveResultHasEffect(battler) if (MoveResultHasEffect(battler)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& IsBattlerAlive(battler) && IsBattlerAlive(battler)
&& (moveType == TYPE_DARK || moveType == TYPE_BUG || moveType == TYPE_GHOST) && (moveType == TYPE_DARK || moveType == TYPE_BUG || moveType == TYPE_GHOST)
&& CompareStat(battler, STAT_SPEED, MAX_STAT_STAGE, CMP_LESS_THAN)) && CompareStat(battler, STAT_SPEED, MAX_STAT_STAGE, CMP_LESS_THAN))
@ -5503,7 +5503,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
break; break;
case ABILITY_WATER_COMPACTION: case ABILITY_WATER_COMPACTION:
if (MoveResultHasEffect(battler) if (MoveResultHasEffect(battler)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& IsBattlerAlive(battler) && IsBattlerAlive(battler)
&& moveType == TYPE_WATER && moveType == TYPE_WATER
&& CompareStat(battler, STAT_DEF, MAX_STAT_STAGE, CMP_LESS_THAN)) && CompareStat(battler, STAT_DEF, MAX_STAT_STAGE, CMP_LESS_THAN))
@ -5518,7 +5518,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
case ABILITY_STAMINA: case ABILITY_STAMINA:
if (MoveResultHasEffect(battler) if (MoveResultHasEffect(battler)
&& gBattlerAttacker != gBattlerTarget && gBattlerAttacker != gBattlerTarget
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& IsBattlerAlive(battler) && IsBattlerAlive(battler)
&& CompareStat(battler, STAT_DEF, MAX_STAT_STAGE, CMP_LESS_THAN)) && CompareStat(battler, STAT_DEF, MAX_STAT_STAGE, CMP_LESS_THAN))
{ {
@ -5531,7 +5531,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
break; break;
case ABILITY_BERSERK: case ABILITY_BERSERK:
if (MoveResultHasEffect(battler) if (MoveResultHasEffect(battler)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& IsBattlerAlive(battler) && IsBattlerAlive(battler)
&& HadMoreThanHalfHpNowDoesnt(battler) && HadMoreThanHalfHpNowDoesnt(battler)
&& (gMultiHitCounter == 0 || gMultiHitCounter == 1) && (gMultiHitCounter == 0 || gMultiHitCounter == 1)
@ -5548,7 +5548,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
case ABILITY_EMERGENCY_EXIT: case ABILITY_EMERGENCY_EXIT:
case ABILITY_WIMP_OUT: case ABILITY_WIMP_OUT:
if (MoveResultHasEffect(battler) if (MoveResultHasEffect(battler)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& IsBattlerAlive(battler) && IsBattlerAlive(battler)
// Had more than half of hp before, now has less // Had more than half of hp before, now has less
&& HadMoreThanHalfHpNowDoesnt(battler) && HadMoreThanHalfHpNowDoesnt(battler)
@ -5566,7 +5566,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
break; break;
case ABILITY_WEAK_ARMOR: case ABILITY_WEAK_ARMOR:
if (MoveResultHasEffect(battler) if (MoveResultHasEffect(battler)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& IsBattlerAlive(battler) && IsBattlerAlive(battler)
&& IS_MOVE_PHYSICAL(gCurrentMove) && IS_MOVE_PHYSICAL(gCurrentMove)
&& (CompareStat(battler, STAT_SPEED, MAX_STAT_STAGE, CMP_LESS_THAN) // Don't activate if both Speed and Defense cannot be raised. && (CompareStat(battler, STAT_SPEED, MAX_STAT_STAGE, CMP_LESS_THAN) // Don't activate if both Speed and Defense cannot be raised.
@ -5582,7 +5582,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
break; break;
case ABILITY_CURSED_BODY: case ABILITY_CURSED_BODY:
if (MoveResultHasEffect(battler) if (MoveResultHasEffect(battler)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& gDisableStructs[gBattlerAttacker].disabledMove == MOVE_NONE && gDisableStructs[gBattlerAttacker].disabledMove == MOVE_NONE
&& IsBattlerAlive(gBattlerAttacker) && IsBattlerAlive(gBattlerAttacker)
&& !IsAbilityOnSide(gBattlerAttacker, ABILITY_AROMA_VEIL) && !IsAbilityOnSide(gBattlerAttacker, ABILITY_AROMA_VEIL)
@ -5602,7 +5602,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
case ABILITY_MUMMY: case ABILITY_MUMMY:
if (MoveResultHasEffect(battler) if (MoveResultHasEffect(battler)
&& IsBattlerAlive(gBattlerAttacker) && IsBattlerAlive(gBattlerAttacker)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS && GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS
&& IsMoveMakingContact(move, gBattlerAttacker) && IsMoveMakingContact(move, gBattlerAttacker)
&& gBattleStruct->overwrittenAbilities[gBattlerAttacker] != GetBattlerAbility(gBattlerTarget) && gBattleStruct->overwrittenAbilities[gBattlerAttacker] != GetBattlerAbility(gBattlerTarget)
@ -5627,7 +5627,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
case ABILITY_WANDERING_SPIRIT: case ABILITY_WANDERING_SPIRIT:
if (MoveResultHasEffect(battler) if (MoveResultHasEffect(battler)
&& IsBattlerAlive(gBattlerAttacker) && IsBattlerAlive(gBattlerAttacker)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS && GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS
&& IsMoveMakingContact(move, gBattlerAttacker) && IsMoveMakingContact(move, gBattlerAttacker)
&& !(GetActiveGimmick(gBattlerTarget) == GIMMICK_DYNAMAX) && !(GetActiveGimmick(gBattlerTarget) == GIMMICK_DYNAMAX)
@ -5651,7 +5651,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
case ABILITY_ANGER_POINT: case ABILITY_ANGER_POINT:
if (MoveResultHasEffect(battler) if (MoveResultHasEffect(battler)
&& gSpecialStatuses[battler].criticalHit && gSpecialStatuses[battler].criticalHit
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& IsBattlerAlive(battler) && IsBattlerAlive(battler)
&& CompareStat(battler, STAT_ATK, MAX_STAT_STAGE, CMP_LESS_THAN)) && CompareStat(battler, STAT_ATK, MAX_STAT_STAGE, CMP_LESS_THAN))
{ {
@ -5665,7 +5665,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
if (MoveResultHasEffect(battler) if (MoveResultHasEffect(battler)
&& move != MOVE_STRUGGLE && move != MOVE_STRUGGLE
&& gMovesInfo[move].power != 0 && gMovesInfo[move].power != 0
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& !IS_BATTLER_OF_TYPE(battler, moveType) && !IS_BATTLER_OF_TYPE(battler, moveType)
&& moveType != TYPE_STELLAR && moveType != TYPE_STELLAR
&& moveType != TYPE_MYSTERY && moveType != TYPE_MYSTERY
@ -5684,7 +5684,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
&& IsBattlerAlive(gBattlerAttacker) && IsBattlerAlive(gBattlerAttacker)
&& (CompareStat(gBattlerAttacker, STAT_SPEED, MIN_STAT_STAGE, CMP_GREATER_THAN) || GetBattlerAbility(gBattlerAttacker) == ABILITY_MIRROR_ARMOR) && (CompareStat(gBattlerAttacker, STAT_SPEED, MIN_STAT_STAGE, CMP_GREATER_THAN) || GetBattlerAbility(gBattlerAttacker) == ABILITY_MIRROR_ARMOR)
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS && GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS
&& IsMoveMakingContact(move, gBattlerAttacker)) && IsMoveMakingContact(move, gBattlerAttacker))
{ {
@ -5701,7 +5701,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
if (MoveResultHasEffect(gBattlerTarget) if (MoveResultHasEffect(gBattlerTarget)
&& IsBattlerAlive(gBattlerAttacker) && IsBattlerAlive(gBattlerAttacker)
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS && GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS
&& IsMoveMakingContact(move, gBattlerAttacker)) && IsMoveMakingContact(move, gBattlerAttacker))
{ {
@ -5780,7 +5780,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
&& MoveResultHasEffect(gBattlerTarget) && MoveResultHasEffect(gBattlerTarget)
&& IsBattlerAlive(gBattlerAttacker) && IsBattlerAlive(gBattlerAttacker)
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& CanBeSlept(gBattlerAttacker, ability, NOT_BLOCKED_BY_SLEEP_CLAUSE) && CanBeSlept(gBattlerAttacker, ability, NOT_BLOCKED_BY_SLEEP_CLAUSE)
&& GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS && GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS
&& IsMoveMakingContact(move, gBattlerAttacker)) && IsMoveMakingContact(move, gBattlerAttacker))
@ -5804,7 +5804,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
if (MoveResultHasEffect(gBattlerTarget) if (MoveResultHasEffect(gBattlerTarget)
&& IsBattlerAlive(gBattlerAttacker) && IsBattlerAlive(gBattlerAttacker)
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& CanBePoisoned(gBattlerTarget, gBattlerAttacker, GetBattlerAbility(gBattlerAttacker)) && CanBePoisoned(gBattlerTarget, gBattlerAttacker, GetBattlerAbility(gBattlerAttacker))
&& GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS && GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS
&& IsMoveMakingContact(move, gBattlerAttacker)) && IsMoveMakingContact(move, gBattlerAttacker))
@ -5825,7 +5825,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
if (MoveResultHasEffect(gBattlerTarget) if (MoveResultHasEffect(gBattlerTarget)
&& IsBattlerAlive(gBattlerAttacker) && IsBattlerAlive(gBattlerAttacker)
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& CanBeParalyzed(gBattlerAttacker, GetBattlerAbility(gBattlerAttacker)) && CanBeParalyzed(gBattlerAttacker, GetBattlerAbility(gBattlerAttacker))
&& GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS && GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS
&& IsMoveMakingContact(move, gBattlerAttacker)) && IsMoveMakingContact(move, gBattlerAttacker))
@ -5845,7 +5845,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS && GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS
&& (IsMoveMakingContact(move, gBattlerAttacker)) && (IsMoveMakingContact(move, gBattlerAttacker))
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& CanBeBurned(gBattlerAttacker, GetBattlerAbility(gBattlerAttacker)) && CanBeBurned(gBattlerAttacker, GetBattlerAbility(gBattlerAttacker))
&& (B_ABILITY_TRIGGER_CHANCE >= GEN_4 ? RandomPercentage(RNG_FLAME_BODY, 30) : RandomChance(RNG_FLAME_BODY, 1, 3))) && (B_ABILITY_TRIGGER_CHANCE >= GEN_4 ? RandomPercentage(RNG_FLAME_BODY, 30) : RandomChance(RNG_FLAME_BODY, 1, 3)))
{ {
@ -5861,7 +5861,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
if (MoveResultHasEffect(gBattlerTarget) if (MoveResultHasEffect(gBattlerTarget)
&& IsBattlerAlive(gBattlerAttacker) && IsBattlerAlive(gBattlerAttacker)
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& IsBattlerAlive(gBattlerTarget) && IsBattlerAlive(gBattlerTarget)
&& (B_ABILITY_TRIGGER_CHANCE >= GEN_4 ? RandomPercentage(RNG_CUTE_CHARM, 30) : RandomChance(RNG_CUTE_CHARM, 1, 3)) && (B_ABILITY_TRIGGER_CHANCE >= GEN_4 ? RandomPercentage(RNG_CUTE_CHARM, 30) : RandomChance(RNG_CUTE_CHARM, 1, 3))
&& !(gBattleMons[gBattlerAttacker].status2 & STATUS2_INFATUATION) && !(gBattleMons[gBattlerAttacker].status2 & STATUS2_INFATUATION)
@ -5878,7 +5878,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
} }
break; break;
case ABILITY_ILLUSION: case ABILITY_ILLUSION:
if (gBattleStruct->illusion[gBattlerTarget].on && !gBattleStruct->illusion[gBattlerTarget].broken && TARGET_TURN_DAMAGED) if (gBattleStruct->illusion[gBattlerTarget].on && !gBattleStruct->illusion[gBattlerTarget].broken && IsBattlerTurnDamaged(gBattlerTarget))
{ {
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_IllusionOff; gBattlescriptCurrInstr = BattleScript_IllusionOff;
@ -5889,7 +5889,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
if (MoveResultHasEffect(gBattlerTarget) if (MoveResultHasEffect(gBattlerTarget)
&& IsBattlerAlive(gBattlerAttacker) && IsBattlerAlive(gBattlerAttacker)
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& TARGET_TURN_DAMAGED) && IsBattlerTurnDamaged(gBattlerTarget))
{ {
gEffectBattler = gBattlerTarget; gEffectBattler = gBattlerTarget;
BattleScriptPushCursor(); BattleScriptPushCursor();
@ -5899,7 +5899,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
break; break;
case ABILITY_STEAM_ENGINE: case ABILITY_STEAM_ENGINE:
if (MoveResultHasEffect(gBattlerTarget) if (MoveResultHasEffect(gBattlerTarget)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& IsBattlerAlive(battler) && IsBattlerAlive(battler)
&& CompareStat(battler, STAT_SPEED, MAX_STAT_STAGE, CMP_LESS_THAN) && CompareStat(battler, STAT_SPEED, MAX_STAT_STAGE, CMP_LESS_THAN)
&& (moveType == TYPE_FIRE || moveType == TYPE_WATER)) && (moveType == TYPE_FIRE || moveType == TYPE_WATER))
@ -5914,7 +5914,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
case ABILITY_SAND_SPIT: case ABILITY_SAND_SPIT:
if (MoveResultHasEffect(gBattlerTarget) if (MoveResultHasEffect(gBattlerTarget)
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& !(gBattleWeather & B_WEATHER_SANDSTORM && WEATHER_HAS_EFFECT)) && !(gBattleWeather & B_WEATHER_SANDSTORM && WEATHER_HAS_EFFECT))
{ {
if (gBattleWeather & B_WEATHER_PRIMAL_ANY && WEATHER_HAS_EFFECT) if (gBattleWeather & B_WEATHER_PRIMAL_ANY && WEATHER_HAS_EFFECT)
@ -5935,7 +5935,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
case ABILITY_PERISH_BODY: case ABILITY_PERISH_BODY:
if (MoveResultHasEffect(gBattlerTarget) if (MoveResultHasEffect(gBattlerTarget)
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& IsBattlerAlive(battler) && IsBattlerAlive(battler)
&& GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS && GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS
&& (IsMoveMakingContact(move, gBattlerAttacker)) && (IsMoveMakingContact(move, gBattlerAttacker))
@ -5956,7 +5956,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
case ABILITY_GULP_MISSILE: case ABILITY_GULP_MISSILE:
if (MoveResultHasEffect(gBattlerTarget) if (MoveResultHasEffect(gBattlerTarget)
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& IsBattlerAlive(battler) && IsBattlerAlive(battler)
&& gBattleMons[gBattlerTarget].species != SPECIES_CRAMORANT) && gBattleMons[gBattlerTarget].species != SPECIES_CRAMORANT)
{ {
@ -5987,7 +5987,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
case ABILITY_SEED_SOWER: case ABILITY_SEED_SOWER:
if (MoveResultHasEffect(gBattlerTarget) if (MoveResultHasEffect(gBattlerTarget)
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& IsBattlerAlive(gBattlerTarget) && IsBattlerAlive(gBattlerTarget)
&& TryChangeBattleTerrain(gBattlerTarget, STATUS_FIELD_GRASSY_TERRAIN, &gFieldTimers.terrainTimer)) && TryChangeBattleTerrain(gBattlerTarget, STATUS_FIELD_GRASSY_TERRAIN, &gFieldTimers.terrainTimer))
{ {
@ -5998,7 +5998,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
break; break;
case ABILITY_THERMAL_EXCHANGE: case ABILITY_THERMAL_EXCHANGE:
if (MoveResultHasEffect(gBattlerTarget) if (MoveResultHasEffect(gBattlerTarget)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& IsBattlerAlive(gBattlerTarget) && IsBattlerAlive(gBattlerTarget)
&& CompareStat(gBattlerTarget, STAT_ATK, MAX_STAT_STAGE, CMP_LESS_THAN) && CompareStat(gBattlerTarget, STAT_ATK, MAX_STAT_STAGE, CMP_LESS_THAN)
&& moveType == TYPE_FIRE) && moveType == TYPE_FIRE)
@ -6013,7 +6013,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
case ABILITY_ANGER_SHELL: case ABILITY_ANGER_SHELL:
if (MoveResultHasEffect(gBattlerTarget) if (MoveResultHasEffect(gBattlerTarget)
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& (gMultiHitCounter == 0 || gMultiHitCounter == 1) // Activates after all hits from a multi-hit move. && (gMultiHitCounter == 0 || gMultiHitCounter == 1) // Activates after all hits from a multi-hit move.
&& IsBattlerAlive(gBattlerTarget) && IsBattlerAlive(gBattlerTarget)
&& HadMoreThanHalfHpNowDoesnt(gBattlerTarget) && HadMoreThanHalfHpNowDoesnt(gBattlerTarget)
@ -6031,7 +6031,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
case ABILITY_ELECTROMORPHOSIS: case ABILITY_ELECTROMORPHOSIS:
if (MoveResultHasEffect(gBattlerTarget) if (MoveResultHasEffect(gBattlerTarget)
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& IsBattlerAlive(gBattlerTarget)) && IsBattlerAlive(gBattlerTarget))
{ {
BattleScriptPushCursor(); BattleScriptPushCursor();
@ -6044,7 +6044,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
&& (!gBattleStruct->isSkyBattle) && (!gBattleStruct->isSkyBattle)
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& IS_MOVE_PHYSICAL(gCurrentMove) && IS_MOVE_PHYSICAL(gCurrentMove)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& (gSideTimers[GetBattlerSide(gBattlerAttacker)].toxicSpikesAmount != 2)) && (gSideTimers[GetBattlerSide(gBattlerAttacker)].toxicSpikesAmount != 2))
{ {
SWAP(gBattlerAttacker, gBattlerTarget, i); SWAP(gBattlerAttacker, gBattlerTarget, i);
@ -6065,7 +6065,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
&& CanBePoisoned(gBattlerAttacker, gBattlerTarget, GetBattlerAbility(gBattlerTarget)) && CanBePoisoned(gBattlerAttacker, gBattlerTarget, GetBattlerAbility(gBattlerTarget))
&& GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS && GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS
&& IsMoveMakingContact(move, gBattlerAttacker) && IsMoveMakingContact(move, gBattlerAttacker)
&& TARGET_TURN_DAMAGED // Need to actually hit the target && IsBattlerTurnDamaged(gBattlerTarget) // Need to actually hit the target
&& RandomPercentage(RNG_POISON_TOUCH, 30)) && RandomPercentage(RNG_POISON_TOUCH, 30))
{ {
gBattleScripting.moveEffect = MOVE_EFFECT_POISON; gBattleScripting.moveEffect = MOVE_EFFECT_POISON;
@ -6081,7 +6081,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
&& IsBattlerAlive(gBattlerTarget) && IsBattlerAlive(gBattlerTarget)
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& CanBePoisoned(gBattlerAttacker, gBattlerTarget, GetBattlerAbility(gBattlerTarget)) && CanBePoisoned(gBattlerAttacker, gBattlerTarget, GetBattlerAbility(gBattlerTarget))
&& TARGET_TURN_DAMAGED // Need to actually hit the target && IsBattlerTurnDamaged(gBattlerTarget) // Need to actually hit the target
&& RandomWeighted(RNG_TOXIC_CHAIN, 7, 3)) && RandomWeighted(RNG_TOXIC_CHAIN, 7, 3))
{ {
gBattleScripting.moveEffect = MOVE_EFFECT_TOXIC; gBattleScripting.moveEffect = MOVE_EFFECT_TOXIC;
@ -6097,7 +6097,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
&& IsBattlerAlive(gBattlerTarget) && IsBattlerAlive(gBattlerTarget)
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& RandomChance(RNG_STENCH, 1, 10) && RandomChance(RNG_STENCH, 1, 10)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& !MoveHasAdditionalEffect(gCurrentMove, MOVE_EFFECT_FLINCH)) && !MoveHasAdditionalEffect(gCurrentMove, MOVE_EFFECT_FLINCH))
{ {
gBattleScripting.moveEffect = MOVE_EFFECT_FLINCH; gBattleScripting.moveEffect = MOVE_EFFECT_FLINCH;
@ -6109,7 +6109,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
break; break;
case ABILITY_GULP_MISSILE: case ABILITY_GULP_MISSILE:
if ((gBattleMons[gBattlerAttacker].species == SPECIES_CRAMORANT) if ((gBattleMons[gBattlerAttacker].species == SPECIES_CRAMORANT)
&& ((gCurrentMove == MOVE_SURF && TARGET_TURN_DAMAGED) || gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER) && ((gCurrentMove == MOVE_SURF && IsBattlerTurnDamaged(gBattlerTarget)) || gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER)
&& TryBattleFormChange(gBattlerAttacker, FORM_CHANGE_BATTLE_HP_PERCENT)) && TryBattleFormChange(gBattlerAttacker, FORM_CHANGE_BATTLE_HP_PERCENT))
{ {
BattleScriptPushCursor(); BattleScriptPushCursor();
@ -6911,7 +6911,7 @@ static u8 TrySetEnigmaBerry(u32 battler)
{ {
if (IsBattlerAlive(battler) if (IsBattlerAlive(battler)
&& !DoesSubstituteBlockMove(gBattlerAttacker, battler, gCurrentMove) && !DoesSubstituteBlockMove(gBattlerAttacker, battler, gCurrentMove)
&& ((BATTLER_TURN_DAMAGED(battler) && gBattleStruct->moveResultFlags[battler] & MOVE_RESULT_SUPER_EFFECTIVE) || gBattleScripting.overrideBerryRequirements) && ((IsBattlerTurnDamaged(battler) && gBattleStruct->moveResultFlags[battler] & MOVE_RESULT_SUPER_EFFECTIVE) || gBattleScripting.overrideBerryRequirements)
&& !(gBattleScripting.overrideBerryRequirements && gBattleMons[battler].hp == gBattleMons[battler].maxHP) && !(gBattleScripting.overrideBerryRequirements && gBattleMons[battler].hp == gBattleMons[battler].maxHP)
&& (B_HEAL_BLOCKING < GEN_5 || !(gStatuses3[battler] & STATUS3_HEAL_BLOCK))) && (B_HEAL_BLOCKING < GEN_5 || !(gStatuses3[battler] & STATUS3_HEAL_BLOCK)))
{ {
@ -6935,7 +6935,7 @@ static u8 DamagedStatBoostBerryEffect(u32 battler, u8 statId, u8 category)
|| (!DoesSubstituteBlockMove(gBattlerAttacker, battler, gCurrentMove) || (!DoesSubstituteBlockMove(gBattlerAttacker, battler, gCurrentMove)
&& GetBattleMoveCategory(gCurrentMove) == category && GetBattleMoveCategory(gCurrentMove) == category
&& battler != gBattlerAttacker && battler != gBattlerAttacker
&& BATTLER_TURN_DAMAGED(battler))) && IsBattlerTurnDamaged(battler)))
) )
{ {
BufferStatChange(battler, statId, STRINGID_STATROSE); BufferStatChange(battler, statId, STRINGID_STATROSE);
@ -7992,7 +7992,7 @@ u32 ItemBattleEffects(enum ItemEffect caseID, u32 battler, bool32 moveTurn)
atkHoldEffectParam *= 2; atkHoldEffectParam *= 2;
if (gBattleStruct->moveDamage[battler] != 0 // Need to have done damage if (gBattleStruct->moveDamage[battler] != 0 // Need to have done damage
&& MoveResultHasEffect(gBattlerTarget) && MoveResultHasEffect(gBattlerTarget)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& !gMovesInfo[gCurrentMove].ignoresKingsRock && !gMovesInfo[gCurrentMove].ignoresKingsRock
&& gBattleMons[gBattlerTarget].hp && gBattleMons[gBattlerTarget].hp
&& RandomPercentage(RNG_HOLD_EFFECT_FLINCH, atkHoldEffectParam) && RandomPercentage(RNG_HOLD_EFFECT_FLINCH, atkHoldEffectParam)
@ -8084,7 +8084,7 @@ u32 ItemBattleEffects(enum ItemEffect caseID, u32 battler, bool32 moveTurn)
switch (battlerHoldEffect) switch (battlerHoldEffect)
{ {
case HOLD_EFFECT_AIR_BALLOON: case HOLD_EFFECT_AIR_BALLOON:
if (TARGET_TURN_DAMAGED) if (IsBattlerTurnDamaged(gBattlerTarget))
{ {
effect = ITEM_EFFECT_OTHER; effect = ITEM_EFFECT_OTHER;
BattleScriptPushCursor(); BattleScriptPushCursor();
@ -8092,7 +8092,7 @@ u32 ItemBattleEffects(enum ItemEffect caseID, u32 battler, bool32 moveTurn)
} }
break; break;
case HOLD_EFFECT_ROCKY_HELMET: case HOLD_EFFECT_ROCKY_HELMET:
if (TARGET_TURN_DAMAGED if (IsBattlerTurnDamaged(gBattlerTarget)
&& GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS && GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS
&& IsMoveMakingContact(gCurrentMove, gBattlerAttacker) && IsMoveMakingContact(gCurrentMove, gBattlerAttacker)
&& IsBattlerAlive(gBattlerAttacker) && IsBattlerAlive(gBattlerAttacker)
@ -8110,7 +8110,7 @@ u32 ItemBattleEffects(enum ItemEffect caseID, u32 battler, bool32 moveTurn)
break; break;
case HOLD_EFFECT_WEAKNESS_POLICY: case HOLD_EFFECT_WEAKNESS_POLICY:
if (IsBattlerAlive(battler) if (IsBattlerAlive(battler)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& gBattleStruct->moveResultFlags[gBattlerTarget] & MOVE_RESULT_SUPER_EFFECTIVE) && gBattleStruct->moveResultFlags[gBattlerTarget] & MOVE_RESULT_SUPER_EFFECTIVE)
{ {
effect = ITEM_STATS_CHANGE; effect = ITEM_STATS_CHANGE;
@ -8120,7 +8120,7 @@ u32 ItemBattleEffects(enum ItemEffect caseID, u32 battler, bool32 moveTurn)
break; break;
case HOLD_EFFECT_SNOWBALL: case HOLD_EFFECT_SNOWBALL:
if (IsBattlerAlive(battler) if (IsBattlerAlive(battler)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& moveType == TYPE_ICE) && moveType == TYPE_ICE)
{ {
effect = ITEM_STATS_CHANGE; effect = ITEM_STATS_CHANGE;
@ -8131,7 +8131,7 @@ u32 ItemBattleEffects(enum ItemEffect caseID, u32 battler, bool32 moveTurn)
break; break;
case HOLD_EFFECT_LUMINOUS_MOSS: case HOLD_EFFECT_LUMINOUS_MOSS:
if (IsBattlerAlive(battler) if (IsBattlerAlive(battler)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& moveType == TYPE_WATER) && moveType == TYPE_WATER)
{ {
effect = ITEM_STATS_CHANGE; effect = ITEM_STATS_CHANGE;
@ -8142,7 +8142,7 @@ u32 ItemBattleEffects(enum ItemEffect caseID, u32 battler, bool32 moveTurn)
break; break;
case HOLD_EFFECT_CELL_BATTERY: case HOLD_EFFECT_CELL_BATTERY:
if (IsBattlerAlive(battler) if (IsBattlerAlive(battler)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& moveType == TYPE_ELECTRIC) && moveType == TYPE_ELECTRIC)
{ {
effect = ITEM_STATS_CHANGE; effect = ITEM_STATS_CHANGE;
@ -8153,7 +8153,7 @@ u32 ItemBattleEffects(enum ItemEffect caseID, u32 battler, bool32 moveTurn)
break; break;
case HOLD_EFFECT_ABSORB_BULB: case HOLD_EFFECT_ABSORB_BULB:
if (IsBattlerAlive(battler) if (IsBattlerAlive(battler)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& moveType == TYPE_WATER) && moveType == TYPE_WATER)
{ {
effect = ITEM_STATS_CHANGE; effect = ITEM_STATS_CHANGE;
@ -8167,7 +8167,7 @@ u32 ItemBattleEffects(enum ItemEffect caseID, u32 battler, bool32 moveTurn)
break; break;
case HOLD_EFFECT_JABOCA_BERRY: // consume and damage attacker if used physical move case HOLD_EFFECT_JABOCA_BERRY: // consume and damage attacker if used physical move
if (IsBattlerAlive(battler) if (IsBattlerAlive(battler)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& !DoesSubstituteBlockMove(gBattlerAttacker, battler, gCurrentMove) && !DoesSubstituteBlockMove(gBattlerAttacker, battler, gCurrentMove)
&& IS_MOVE_PHYSICAL(gCurrentMove) && IS_MOVE_PHYSICAL(gCurrentMove)
&& GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD)
@ -8187,7 +8187,7 @@ u32 ItemBattleEffects(enum ItemEffect caseID, u32 battler, bool32 moveTurn)
break; break;
case HOLD_EFFECT_ROWAP_BERRY: // consume and damage attacker if used special move case HOLD_EFFECT_ROWAP_BERRY: // consume and damage attacker if used special move
if (IsBattlerAlive(battler) if (IsBattlerAlive(battler)
&& TARGET_TURN_DAMAGED && IsBattlerTurnDamaged(gBattlerTarget)
&& !DoesSubstituteBlockMove(gBattlerAttacker, battler, gCurrentMove) && !DoesSubstituteBlockMove(gBattlerAttacker, battler, gCurrentMove)
&& IS_MOVE_SPECIAL(gCurrentMove) && IS_MOVE_SPECIAL(gCurrentMove)
&& GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD)
@ -8224,7 +8224,7 @@ u32 ItemBattleEffects(enum ItemEffect caseID, u32 battler, bool32 moveTurn)
} }
break; break;
case HOLD_EFFECT_STICKY_BARB: case HOLD_EFFECT_STICKY_BARB:
if (TARGET_TURN_DAMAGED if (IsBattlerTurnDamaged(gBattlerTarget)
&& MoveResultHasEffect(gBattlerTarget) && MoveResultHasEffect(gBattlerTarget)
&& GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS && GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS
&& IsMoveMakingContact(gCurrentMove, gBattlerAttacker) && IsMoveMakingContact(gCurrentMove, gBattlerAttacker)
@ -10101,7 +10101,7 @@ static inline uq4_12_t GetDefenderAbilitiesModifier(u32 move, u32 moveType, u32
{ {
case ABILITY_MULTISCALE: case ABILITY_MULTISCALE:
case ABILITY_SHADOW_SHIELD: case ABILITY_SHADOW_SHIELD:
if (BATTLER_MAX_HP(battlerDef)) if (IsBattlerAtMaxHp(battlerDef))
return UQ_4_12(0.5); return UQ_4_12(0.5);
break; break;
case ABILITY_FILTER: case ABILITY_FILTER: