mirror of
https://github.com/rh-hideout/pokeemerald-expansion.git
synced 2026-03-21 18:04:50 -05:00
Remove unnecessary IsBattlerAlive checks because notOnField considers ability/hold effect as none
This commit is contained in:
parent
8a5da7986b
commit
dc09234a31
|
|
@ -207,7 +207,6 @@ static bool32 HandleEndTurnAffection(enum BattlerId battler)
|
|||
gBattleStruct->eventState.endTurnBattler++;
|
||||
|
||||
if (!B_AFFECTION_MECHANICS
|
||||
|| !IsBattlerAlive(battler)
|
||||
|| !IsOnPlayerSide(battler))
|
||||
return effect;
|
||||
|
||||
|
|
|
|||
|
|
@ -256,8 +256,7 @@ static enum ItemEffect TryWeaknessPolicy(enum BattlerId battlerDef)
|
|||
{
|
||||
enum ItemEffect effect = ITEM_NO_EFFECT;
|
||||
|
||||
if (IsBattlerAlive(battlerDef)
|
||||
&& IsBattlerTurnDamaged(battlerDef, EXCLUDING_SUBSTITUTES)
|
||||
if (IsBattlerTurnDamaged(battlerDef, EXCLUDING_SUBSTITUTES)
|
||||
&& gBattleStruct->moveResultFlags[battlerDef] & MOVE_RESULT_SUPER_EFFECTIVE)
|
||||
{
|
||||
BattleScriptCall(BattleScript_WeaknessPolicy);
|
||||
|
|
@ -271,8 +270,7 @@ static enum ItemEffect TrySnowball(enum BattlerId battlerDef)
|
|||
{
|
||||
enum ItemEffect effect = ITEM_NO_EFFECT;
|
||||
|
||||
if (IsBattlerAlive(battlerDef)
|
||||
&& IsBattlerTurnDamaged(battlerDef, EXCLUDING_SUBSTITUTES)
|
||||
if (IsBattlerTurnDamaged(battlerDef, EXCLUDING_SUBSTITUTES)
|
||||
&& GetBattleMoveType(gCurrentMove) == TYPE_ICE)
|
||||
{
|
||||
BattleScriptCall(BattleScript_TargetItemStatRaise);
|
||||
|
|
@ -287,8 +285,7 @@ static enum ItemEffect TryLuminousMoss(enum BattlerId battlerDef)
|
|||
{
|
||||
enum ItemEffect effect = ITEM_NO_EFFECT;
|
||||
|
||||
if (IsBattlerAlive(battlerDef)
|
||||
&& IsBattlerTurnDamaged(battlerDef, EXCLUDING_SUBSTITUTES)
|
||||
if (IsBattlerTurnDamaged(battlerDef, EXCLUDING_SUBSTITUTES)
|
||||
&& GetBattleMoveType(gCurrentMove) == TYPE_WATER)
|
||||
{
|
||||
BattleScriptCall(BattleScript_TargetItemStatRaise);
|
||||
|
|
@ -303,8 +300,7 @@ static enum ItemEffect TryCellBattery(enum BattlerId battlerDef)
|
|||
{
|
||||
enum ItemEffect effect = ITEM_NO_EFFECT;
|
||||
|
||||
if (IsBattlerAlive(battlerDef)
|
||||
&& IsBattlerTurnDamaged(battlerDef, EXCLUDING_SUBSTITUTES)
|
||||
if (IsBattlerTurnDamaged(battlerDef, EXCLUDING_SUBSTITUTES)
|
||||
&& GetBattleMoveType(gCurrentMove) == TYPE_ELECTRIC)
|
||||
{
|
||||
BattleScriptCall(BattleScript_TargetItemStatRaise);
|
||||
|
|
@ -319,8 +315,7 @@ static enum ItemEffect TryAbsorbBulb(enum BattlerId battlerDef)
|
|||
{
|
||||
enum ItemEffect effect = ITEM_NO_EFFECT;
|
||||
|
||||
if (IsBattlerAlive(battlerDef)
|
||||
&& IsBattlerTurnDamaged(battlerDef, EXCLUDING_SUBSTITUTES)
|
||||
if (IsBattlerTurnDamaged(battlerDef, EXCLUDING_SUBSTITUTES)
|
||||
&& GetBattleMoveType(gCurrentMove) == TYPE_WATER)
|
||||
{
|
||||
effect = ITEM_STATS_CHANGE;
|
||||
|
|
@ -379,8 +374,7 @@ static enum ItemEffect TrySetEnigmaBerry(enum BattlerId battlerDef, enum Battler
|
|||
{
|
||||
enum ItemEffect effect = ITEM_NO_EFFECT;
|
||||
|
||||
if (IsBattlerAlive(battlerDef)
|
||||
&& !DoesSubstituteBlockMove(battlerAtk, battlerDef, gCurrentMove)
|
||||
if (!DoesSubstituteBlockMove(battlerAtk, battlerDef, gCurrentMove)
|
||||
&& ((IsBattlerTurnDamaged(battlerDef, EXCLUDING_SUBSTITUTES) && gBattleStruct->moveResultFlags[battlerDef] & MOVE_RESULT_SUPER_EFFECTIVE) || gBattleScripting.overrideBerryRequirements)
|
||||
&& !(gBattleScripting.overrideBerryRequirements && gBattleMons[battlerDef].hp == gBattleMons[battlerDef].maxHP)
|
||||
&& !(B_HEAL_BLOCKING >= GEN_5 && gBattleMons[battlerDef].volatiles.healBlock))
|
||||
|
|
@ -402,7 +396,6 @@ static enum ItemEffect TryBlunderPolicy(enum BattlerId battlerAtk)
|
|||
|
||||
if (gBattleStruct->blunderPolicy
|
||||
&& !gBattleStruct->battlerState[battlerAtk].redCardSwitched
|
||||
&& IsBattlerAlive(battlerAtk)
|
||||
&& CompareStat(battlerAtk, STAT_SPEED, MAX_STAT_STAGE, CMP_LESS_THAN, GetBattlerAbility(battlerAtk)))
|
||||
{
|
||||
gBattleStruct->blunderPolicy = FALSE;
|
||||
|
|
@ -480,7 +473,6 @@ static enum ItemEffect TryThroatSpray(enum BattlerId battlerAtk)
|
|||
|
||||
if (IsSoundMove(gCurrentMove)
|
||||
&& !gBattleStruct->battlerState[battlerAtk].redCardSwitched
|
||||
&& IsBattlerAlive(battlerAtk)
|
||||
&& !gBattleStruct->unableToUseMove
|
||||
&& (IsAnyTargetTurnDamaged(battlerAtk, INCLUDING_SUBSTITUTES) || (GetBattleMoveCategory(gCurrentMove) == DAMAGE_CATEGORY_STATUS && IsAnyTargetAffected()))
|
||||
&& CompareStat(battlerAtk, STAT_SPATK, MAX_STAT_STAGE, CMP_LESS_THAN, GetBattlerAbility(battlerAtk))
|
||||
|
|
@ -528,7 +520,6 @@ static enum ItemEffect TryShellBell(enum BattlerId battlerAtk)
|
|||
&& !gBattleStruct->unableToUseMove
|
||||
&& !gBattleStruct->battlerState[battlerAtk].redCardSwitched
|
||||
&& !IsBattlerAtMaxHp(battlerAtk)
|
||||
&& IsBattlerAlive(battlerAtk)
|
||||
&& GetMoveEffect(gCurrentMove) != EFFECT_PAIN_SPLIT
|
||||
&& !IsFutureSightAttackerInParty(battlerAtk, gBattlerTarget, gCurrentMove)
|
||||
&& !(B_HEAL_BLOCKING >= GEN_5 && gBattleMons[battlerAtk].volatiles.healBlock))
|
||||
|
|
@ -545,8 +536,7 @@ static enum ItemEffect TryLifeOrb(enum BattlerId battlerAtk)
|
|||
{
|
||||
enum ItemEffect effect = ITEM_NO_EFFECT;
|
||||
|
||||
if (IsBattlerAlive(battlerAtk)
|
||||
&& !gBattleStruct->unableToUseMove
|
||||
if (!gBattleStruct->unableToUseMove
|
||||
&& !gBattleStruct->battlerState[battlerAtk].redCardSwitched
|
||||
&& (IsAnyTargetTurnDamaged(battlerAtk, INCLUDING_SUBSTITUTES) || gBattleScripting.savedDmg > 0)
|
||||
&& !IsAbilityAndRecord(battlerAtk, GetBattlerAbility(battlerAtk), ABILITY_MAGIC_GUARD)
|
||||
|
|
|
|||
|
|
@ -824,9 +824,6 @@ static bool32 HandleMoveTargetRedirection(enum MoveTarget moveTarget)
|
|||
enum BattlerId battler;
|
||||
for (battler = 0; battler < gBattlersCount; battler++)
|
||||
{
|
||||
if (!IsBattlerAlive(battler) || gBattlerAttacker == battler)
|
||||
continue;
|
||||
|
||||
ability = GetBattlerAbility(battler);
|
||||
if ((B_REDIRECT_ABILITY_ALLIES >= GEN_4 || !IsBattlerAlly(gBattlerAttacker, battler))
|
||||
&& battler != gBattlerAttacker
|
||||
|
|
@ -952,7 +949,7 @@ static enum CancelerResult CancelerPPDeduction(struct BattleContext *ctx)
|
|||
{
|
||||
for (u32 i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
if (!IsBattlerAlly(i, ctx->battlerAtk) && IsBattlerAlive(i))
|
||||
if (!IsBattlerAlly(i, ctx->battlerAtk))
|
||||
ppToDeduct += (GetBattlerAbility(i) == ABILITY_PRESSURE);
|
||||
}
|
||||
}
|
||||
|
|
@ -2306,7 +2303,7 @@ static enum MoveEndResult MoveEndQueueDancer(void)
|
|||
|
||||
for (enum BattlerId battler = 0; battler < gBattlersCount; battler++)
|
||||
{
|
||||
if (battler == gBattlerAttacker || !IsBattlerAlive(battler))
|
||||
if (battler == gBattlerAttacker)
|
||||
continue;
|
||||
|
||||
if (GetBattlerAbility(battler) == ABILITY_DANCER)
|
||||
|
|
@ -3470,8 +3467,6 @@ static enum MoveEndResult MoveEndWhiteHerb(void)
|
|||
while (gBattleStruct->eventState.moveEndBattler < gBattlersCount)
|
||||
{
|
||||
enum BattlerId battler = gBattleStruct->eventState.moveEndBattler++;
|
||||
if (!IsBattlerAlive(battler))
|
||||
continue;
|
||||
|
||||
if (ItemBattleEffects(battler, 0, GetBattlerHoldEffect(battler), IsWhiteHerbActivation))
|
||||
return MOVEEND_RESULT_RUN_SCRIPT;
|
||||
|
|
@ -3487,8 +3482,7 @@ static enum MoveEndResult MoveEndOpportunist(void)
|
|||
while (gBattleStruct->eventState.moveEndBattler < gBattlersCount)
|
||||
{
|
||||
enum BattlerId battler = gBattleStruct->eventState.moveEndBattler++;
|
||||
if (!IsBattlerAlive(battler))
|
||||
continue;
|
||||
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_OPPORTUNIST, battler, GetBattlerAbility(battler), 0, TRUE))
|
||||
return MOVEEND_RESULT_RUN_SCRIPT;
|
||||
}
|
||||
|
|
@ -3503,8 +3497,6 @@ static enum MoveEndResult MoveEndMirrorHerb(void)
|
|||
while (gBattleStruct->eventState.moveEndBattler < gBattlersCount)
|
||||
{
|
||||
enum BattlerId battler = gBattleStruct->eventState.moveEndBattler++;
|
||||
if (!IsBattlerAlive(battler))
|
||||
continue;
|
||||
|
||||
if (ItemBattleEffects(battler, 0, GetBattlerHoldEffect(battler), IsMirrorHerbActivation))
|
||||
return MOVEEND_RESULT_RUN_SCRIPT;
|
||||
|
|
|
|||
|
|
@ -14604,9 +14604,6 @@ void BS_ActivateItemEffects(void)
|
|||
NATIVE_ARGS();
|
||||
for (enum BattlerId battler = 0; battler < gBattlersCount; battler++)
|
||||
{
|
||||
if (!IsBattlerAlive(battler))
|
||||
continue;
|
||||
|
||||
if (ItemBattleEffects(battler, 0, GetBattlerHoldEffect(battler), IsForceTriggerItemActivation))
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -349,9 +349,6 @@ static bool32 IsUnnerveAbilityOnOpposingSide(enum BattlerId battler)
|
|||
if (battler == battlerDef || IsBattlerAlly(battler, battlerDef))
|
||||
continue;
|
||||
|
||||
if (!IsBattlerAlive(battlerDef))
|
||||
continue;
|
||||
|
||||
enum Ability ability = GetBattlerAbility(battlerDef);
|
||||
switch (ability)
|
||||
{
|
||||
|
|
@ -1695,7 +1692,7 @@ u32 GetBattlerAffectionHearts(enum BattlerId battler)
|
|||
struct Pokemon *mon = GetBattlerMon(battler);
|
||||
u16 species = GetMonData(mon, MON_DATA_SPECIES);
|
||||
|
||||
if (!IsOnPlayerSide(battler))
|
||||
if (!IsOnPlayerSide(battler) || gBattleStruct->battlerState[battler].notOnField)
|
||||
return AFFECTION_NO_HEARTS;
|
||||
else if (gSpeciesInfo[species].isMegaEvolution
|
||||
|| (gBattleTypeFlags & (BATTLE_TYPE_EREADER_TRAINER
|
||||
|
|
@ -3819,7 +3816,6 @@ u32 AbilityBattleEffects(enum AbilityEffect caseID, enum BattlerId battler, enum
|
|||
{
|
||||
case ABILITY_COLOR_CHANGE:
|
||||
if (IsBattlerTurnDamaged(battler, EXCLUDING_SUBSTITUTES)
|
||||
&& IsBattlerAlive(battler)
|
||||
&& !IS_BATTLER_OF_TYPE(battler, moveType)
|
||||
&& move != MOVE_STRUGGLE
|
||||
&& moveType != TYPE_STELLAR
|
||||
|
|
@ -3834,7 +3830,6 @@ u32 AbilityBattleEffects(enum AbilityEffect caseID, enum BattlerId battler, enum
|
|||
break;
|
||||
case ABILITY_BERSERK:
|
||||
if (IsBattlerTurnDamaged(battler, EXCLUDING_SUBSTITUTES)
|
||||
&& IsBattlerAlive(battler)
|
||||
&& HadMoreThanHalfHpNowDoesnt(battler)
|
||||
&& CompareStat(battler, STAT_SPATK, MAX_STAT_STAGE, CMP_LESS_THAN, gLastUsedAbility))
|
||||
{
|
||||
|
|
@ -3846,7 +3841,6 @@ u32 AbilityBattleEffects(enum AbilityEffect caseID, enum BattlerId battler, enum
|
|||
break;
|
||||
case ABILITY_ANGER_SHELL:
|
||||
if (IsBattlerTurnDamaged(battler, EXCLUDING_SUBSTITUTES)
|
||||
&& IsBattlerAlive(battler)
|
||||
&& HadMoreThanHalfHpNowDoesnt(battler))
|
||||
{
|
||||
gEffectBattler = gBattlerAbility = battler;
|
||||
|
|
@ -4424,7 +4418,6 @@ u32 AbilityBattleEffects(enum AbilityEffect caseID, enum BattlerId battler, enum
|
|||
if (GetMoveEffect(move) != EFFECT_FLING
|
||||
&& GetMoveEffect(move) != EFFECT_NATURAL_GIFT
|
||||
&& gBattleMons[battler].item == ITEM_NONE
|
||||
&& IsBattlerAlive(battler)
|
||||
&& !gSpecialStatuses[battler].gemBoost) // In base game, gems are consumed after magician would activate.
|
||||
{
|
||||
u32 numMagicianTargets = 0;
|
||||
|
|
@ -4438,7 +4431,7 @@ u32 AbilityBattleEffects(enum AbilityEffect caseID, enum BattlerId battler, enum
|
|||
&& CanStealItem(battler, battlerDef, gBattleMons[battlerDef].item)
|
||||
&& !GetBattlerPartyState(battlerDef)->isKnockedOff
|
||||
&& !DoesSubstituteBlockMove(battler, battlerDef, move)
|
||||
&& (GetBattlerAbility(battlerDef) != ABILITY_STICKY_HOLD || !IsBattlerAlive(battlerDef)))
|
||||
&& GetBattlerAbility(battlerDef) != ABILITY_STICKY_HOLD)
|
||||
{
|
||||
magicianTargets |= 1u << battlerDef;
|
||||
numMagicianTargets++;
|
||||
|
|
@ -4478,7 +4471,7 @@ u32 AbilityBattleEffects(enum AbilityEffect caseID, enum BattlerId battler, enum
|
|||
case ABILITY_AS_ONE_SHADOW_RIDER:
|
||||
case ABILITY_BEAST_BOOST:
|
||||
{
|
||||
if (!IsBattlerAlive(battler) || NoAliveMonsForEitherParty())
|
||||
if (NoAliveMonsForEitherParty())
|
||||
break;
|
||||
|
||||
enum Stat stat = STAT_ATK;
|
||||
|
|
@ -4507,8 +4500,7 @@ u32 AbilityBattleEffects(enum AbilityEffect caseID, enum BattlerId battler, enum
|
|||
break;
|
||||
case ABILITY_BATTLE_BOND:
|
||||
{
|
||||
if (!IsBattlerAlive(battler)
|
||||
|| NoAliveMonsForEitherParty()
|
||||
if (NoAliveMonsForEitherParty()
|
||||
|| NumFaintedBattlersByAttacker(battler) == 0)
|
||||
break;
|
||||
|
||||
|
|
@ -4641,7 +4633,6 @@ u32 AbilityBattleEffects(enum AbilityEffect caseID, enum BattlerId battler, enum
|
|||
{
|
||||
case ABILITY_COMMANDER:
|
||||
if (IsBattlerAlive(partner)
|
||||
&& IsBattlerAlive(battler)
|
||||
&& gBattleStruct->battlerState[partner].commanderSpecies == SPECIES_NONE
|
||||
&& gBattleMons[partner].species == SPECIES_DONDOZO
|
||||
&& (gChosenActionByBattler[partner] != B_ACTION_SWITCH || HasBattlerActedThisTurn(partner))
|
||||
|
|
@ -4695,8 +4686,6 @@ u32 AbilityBattleEffects(enum AbilityEffect caseID, enum BattlerId battler, enum
|
|||
}
|
||||
break;
|
||||
case ABILITYEFFECT_ON_WEATHER: // For ability effects that activate when the battle weather changes.
|
||||
if (!IsBattlerAlive(battler))
|
||||
return effect;
|
||||
gLastUsedAbility = GetBattlerAbility(battler);
|
||||
switch (gLastUsedAbility)
|
||||
{
|
||||
|
|
@ -4741,8 +4730,6 @@ u32 AbilityBattleEffects(enum AbilityEffect caseID, enum BattlerId battler, enum
|
|||
}
|
||||
break;
|
||||
case ABILITYEFFECT_ON_TERRAIN: // For ability effects that activate when the field terrain changes.
|
||||
if (!IsBattlerAlive(battler))
|
||||
return effect;
|
||||
gLastUsedAbility = GetBattlerAbility(battler);
|
||||
switch (gLastUsedAbility)
|
||||
{
|
||||
|
|
@ -4930,9 +4917,6 @@ u32 IsAbilityPreventingEscape(enum BattlerId battler)
|
|||
if (battler == battlerDef || IsBattlerAlly(battler, battlerDef))
|
||||
continue;
|
||||
|
||||
if (!IsBattlerAlive(battlerDef))
|
||||
continue;
|
||||
|
||||
enum Ability ability = GetBattlerAbility(battlerDef);
|
||||
|
||||
if (ability == ABILITY_SHADOW_TAG && (B_SHADOW_TAG_ESCAPE <= GEN_3 || GetBattlerAbility(battler) != ABILITY_SHADOW_TAG))
|
||||
|
|
@ -9902,9 +9886,6 @@ bool32 HasWeatherEffect(void)
|
|||
{
|
||||
for (enum BattlerId battler = 0; battler < gBattlersCount; battler++)
|
||||
{
|
||||
if (!IsBattlerAlive(battler))
|
||||
continue;
|
||||
|
||||
enum Ability ability = GetBattlerAbility(battler);
|
||||
switch (ability)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user