Expand usage of IsBattlerAlly (rename from IsAlly) (#6251)
This commit is contained in:
parent
2b2d703c8a
commit
de8d25da55
@ -1243,6 +1243,11 @@ static inline u32 GetBattlerSide(u32 battler)
|
||||
return GetBattlerPosition(battler) & BIT_SIDE;
|
||||
}
|
||||
|
||||
static inline bool32 IsBattlerAlly(u32 battlerAtk, u32 battlerDef)
|
||||
{
|
||||
return (GetBattlerSide(battlerAtk) == GetBattlerSide(battlerDef));
|
||||
}
|
||||
|
||||
static inline u32 GetOpposingSideBattler(u32 battler)
|
||||
{
|
||||
return GetBattlerAtPosition(BATTLE_OPPOSITE(GetBattlerSide(battler)));
|
||||
|
||||
@ -304,7 +304,7 @@ void DoMoveAnim(u16 move)
|
||||
// Make sure the anim target of moves hitting everyone is at the opposite side.
|
||||
if (GetBattlerMoveTargetType(gBattlerAttacker, move) & MOVE_TARGET_FOES_AND_ALLY && IsDoubleBattle())
|
||||
{
|
||||
while (GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget))
|
||||
while (IsBattlerAlly(gBattleAnimAttacker, gBattleAnimTarget))
|
||||
{
|
||||
if (++gBattleAnimTarget >= MAX_BATTLERS_COUNT)
|
||||
gBattleAnimTarget = 0;
|
||||
@ -563,7 +563,7 @@ static u8 GetBattleAnimMoveTargets(u8 battlerArgIndex, u8 *targets)
|
||||
case MOVE_TARGET_BOTH: // all opponents
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
if (i != ignoredTgt && !IsAlly(i, ignoredTgt) && IS_ALIVE_AND_PRESENT(i))
|
||||
if (i != ignoredTgt && !IsBattlerAlly(i, ignoredTgt) && IS_ALIVE_AND_PRESENT(i))
|
||||
targets[numTargets++] = i + MAX_BATTLERS_COUNT;
|
||||
}
|
||||
break;
|
||||
@ -2157,8 +2157,7 @@ static void Cmd_teamattack_moveback(void)
|
||||
sBattleAnimScriptPtr += 2;
|
||||
|
||||
// Apply to double battles when attacking own side
|
||||
if (!IsContest() && IsDoubleBattle()
|
||||
&& GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget))
|
||||
if (!IsContest() && IsDoubleBattle() && IsBattlerAlly(gBattleAnimAttacker, gBattleAnimTarget))
|
||||
{
|
||||
if (wantedBattler == ANIM_ATTACKER)
|
||||
{
|
||||
@ -2195,7 +2194,7 @@ static void Cmd_teamattack_movefwd(void)
|
||||
|
||||
// Apply to double battles when attacking own side
|
||||
if (!IsContest() && IsDoubleBattle()
|
||||
&& GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget))
|
||||
&& IsBattlerAlly(gBattleAnimAttacker, gBattleAnimTarget))
|
||||
{
|
||||
if (wantedBattler == ANIM_ATTACKER)
|
||||
{
|
||||
|
||||
@ -389,7 +389,7 @@ void AnimTranslateStinger(struct Sprite *sprite)
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsContest() && GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget))
|
||||
if (!IsContest() && IsBattlerAlly(gBattleAnimAttacker, gBattleAnimTarget))
|
||||
{
|
||||
if (GetBattlerPosition(gBattleAnimTarget) == B_POSITION_PLAYER_LEFT
|
||||
|| GetBattlerPosition(gBattleAnimTarget) == B_POSITION_OPPONENT_LEFT)
|
||||
|
||||
@ -4022,7 +4022,7 @@ static const union AffineAnimCmd *const sAffineAnims_TeraStarstormBeamRing[] =
|
||||
sAffineAnim_TeraStarstormBeamRing,
|
||||
};
|
||||
|
||||
const struct SpriteTemplate gTeraStarstormBeamSpriteTemplate =
|
||||
const struct SpriteTemplate gTeraStarstormBeamSpriteTemplate =
|
||||
{
|
||||
.tileTag = ANIM_TAG_STARSTORM,
|
||||
.paletteTag = ANIM_TAG_STARSTORM,
|
||||
@ -4170,7 +4170,7 @@ void AnimTranslateLinearSingleSineWave(struct Sprite *sprite)
|
||||
|
||||
sprite->data[5] = gBattleAnimArgs[5];
|
||||
InitAnimArcTranslation(sprite);
|
||||
if (GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget))
|
||||
if (IsBattlerAlly(gBattleAnimAttacker, gBattleAnimTarget))
|
||||
sprite->data[0] = 1;
|
||||
else
|
||||
sprite->data[0] = 0;
|
||||
@ -6845,10 +6845,12 @@ static void TrySwapWishBattlerIds(u32 battlerAtk, u32 battlerPartner)
|
||||
// if used future sight on opposing side, properly track who used it
|
||||
if (gSideStatuses[oppSide] & SIDE_STATUS_FUTUREATTACK)
|
||||
{
|
||||
u32 battlerAtkSide = GetBattlerSide(battlerAtk);
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
if (IsAlly(i,battlerAtk))
|
||||
if (battlerAtkSide == GetBattlerSide(i))
|
||||
continue; // only on opposing side
|
||||
|
||||
if (gWishFutureKnock.futureSightBattlerIndex[i] == battlerAtk)
|
||||
{
|
||||
// if target was attacked with future sight from us, now they'll be the partner slot
|
||||
|
||||
@ -717,7 +717,7 @@ static void AnimSunlight(struct Sprite *sprite)
|
||||
// arg 6: ? (todo: something related to which mon the pixel offsets are based on)
|
||||
static void AnimEmberFlare(struct Sprite *sprite)
|
||||
{
|
||||
if (GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget)
|
||||
if (IsBattlerAlly(gBattleAnimAttacker, gBattleAnimTarget)
|
||||
&& (gBattleAnimAttacker == GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT)
|
||||
|| gBattleAnimAttacker == GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT)))
|
||||
gBattleAnimArgs[2] = -gBattleAnimArgs[2];
|
||||
|
||||
@ -8896,7 +8896,7 @@ static void SpriteCB_AnimSpriteOnTargetSideCentre(struct Sprite *sprite)
|
||||
|
||||
if (!sprite->data[0])
|
||||
{
|
||||
if (IsAlly(gBattleAnimAttacker, target))
|
||||
if (IsBattlerAlly(gBattleAnimAttacker, target))
|
||||
{
|
||||
if (IsDoubleBattle())
|
||||
InitSpritePosToAnimAttackersCentre(sprite, FALSE);
|
||||
@ -9072,7 +9072,7 @@ static void SpriteCB_DragonEnergyShot(struct Sprite* sprite)
|
||||
u8 def1 = gBattleAnimTarget;
|
||||
u8 def2 = BATTLE_PARTNER(def1);
|
||||
|
||||
if (!IsDoubleBattle() || IsAlly(gBattleAnimAttacker, gBattleAnimTarget))
|
||||
if (!IsDoubleBattle() || IsBattlerAlly(gBattleAnimAttacker, gBattleAnimTarget))
|
||||
y = GetBattlerSpriteCoord(def1, BATTLER_COORD_Y_PIC_OFFSET);
|
||||
else
|
||||
{
|
||||
@ -9172,7 +9172,7 @@ static void SpriteCB_GlacialLance(struct Sprite* sprite)
|
||||
|
||||
sprite->data[0] = gBattleAnimArgs[6];
|
||||
|
||||
if (!IsDoubleBattle() || IsAlly(gBattleAnimAttacker, gBattleAnimTarget))
|
||||
if (!IsDoubleBattle() || IsBattlerAlly(gBattleAnimAttacker, gBattleAnimTarget))
|
||||
{
|
||||
sprite->data[2] = GetBattlerSpriteCoord(def1, BATTLER_COORD_X_2) + gBattleAnimArgs[2]; //Converge on target
|
||||
sprite->data[4] = GetBattlerSpriteCoord(def1, BATTLER_COORD_Y_PIC_OFFSET) + gBattleAnimArgs[3];
|
||||
|
||||
@ -501,7 +501,7 @@ static void AnimPsychoCut(struct Sprite *sprite)
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsContest() && GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget))
|
||||
if (!IsContest() && IsBattlerAlly(gBattleAnimAttacker, gBattleAnimTarget))
|
||||
{
|
||||
if (GetBattlerPosition(gBattleAnimTarget) == B_POSITION_PLAYER_LEFT
|
||||
|| GetBattlerPosition(gBattleAnimTarget) == B_POSITION_OPPONENT_LEFT)
|
||||
|
||||
@ -403,7 +403,7 @@ void AnimTask_CentredFrozenIceCube(u8 taskId)
|
||||
u8 battler1 = gBattleAnimTarget;
|
||||
u8 battler2 = BATTLE_PARTNER(battler1);
|
||||
|
||||
if (!IsDoubleBattle() || IsAlly(gBattleAnimAttacker, gBattleAnimTarget))
|
||||
if (!IsDoubleBattle() || IsBattlerAlly(gBattleAnimAttacker, gBattleAnimTarget))
|
||||
{
|
||||
x = GetBattlerSpriteCoord(battler1, BATTLER_COORD_X_2);
|
||||
y = GetBattlerSpriteCoord(battler1, BATTLER_COORD_Y_PIC_OFFSET);
|
||||
|
||||
@ -1036,7 +1036,7 @@ void AnimTask_SetAnimAttackerAndTargetForEffectTgt(u8 taskId)
|
||||
|
||||
void AnimTask_IsTargetSameSide(u8 taskId)
|
||||
{
|
||||
if (GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget))
|
||||
if (IsBattlerAlly(gBattleAnimAttacker, gBattleAnimTarget))
|
||||
gBattleAnimArgs[ARG_RET_ID] = TRUE;
|
||||
else
|
||||
gBattleAnimArgs[ARG_RET_ID] = FALSE;
|
||||
|
||||
@ -940,7 +940,7 @@ static void AnimHydroCannonBeam(struct Sprite *sprite)
|
||||
{
|
||||
bool8 animType;
|
||||
u8 coordType;
|
||||
if (GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget))
|
||||
if (IsBattlerAlly(gBattleAnimAttacker, gBattleAnimTarget))
|
||||
{
|
||||
gBattleAnimArgs[0] *= -1;
|
||||
if (GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_PLAYER_LEFT || GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_OPPONENT_LEFT)
|
||||
|
||||
@ -12489,7 +12489,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
|
||||
// Check Mirror Herb / Opportunist
|
||||
for (index = 0; index < gBattlersCount; index++)
|
||||
{
|
||||
if (GetBattlerSide(index) == GetBattlerSide(battler))
|
||||
if (IsBattlerAlly(index, battler))
|
||||
continue; // Only triggers on opposing side
|
||||
|
||||
if (GetBattlerAbility(index) == ABILITY_OPPORTUNIST
|
||||
@ -17959,7 +17959,7 @@ void BS_JumpIfSleepClause(void)
|
||||
NATIVE_ARGS(const u8 *jumpInstr);
|
||||
|
||||
// Can freely sleep own partner
|
||||
if (IsDoubleBattle() && IsSleepClauseEnabled() && GetBattlerSide(gBattlerAttacker) == GetBattlerSide(gBattlerTarget))
|
||||
if (IsDoubleBattle() && IsSleepClauseEnabled() && IsBattlerAlly(gBattlerAttacker, gBattlerTarget))
|
||||
{
|
||||
gBattleStruct->battlerState[gBattlerTarget].sleepClauseEffectExempt = TRUE;
|
||||
gBattlescriptCurrInstr = cmd->nextInstr;
|
||||
@ -18079,7 +18079,7 @@ void BS_TryWindRiderPower(void)
|
||||
|
||||
u32 battler = GetBattlerForBattleScript(cmd->battler);
|
||||
u16 ability = GetBattlerAbility(battler);
|
||||
if (GetBattlerSide(battler) == GetBattlerSide(gBattlerAttacker)
|
||||
if (IsBattlerAlly(battler, gBattlerAttacker)
|
||||
&& (ability == ABILITY_WIND_RIDER || ability == ABILITY_WIND_POWER))
|
||||
{
|
||||
gLastUsedAbility = ability;
|
||||
|
||||
@ -346,7 +346,7 @@ void HandleAction_UseMove(void)
|
||||
for (battler = 0; battler < gBattlersCount; battler++)
|
||||
{
|
||||
ability = GetBattlerAbility(battler);
|
||||
if ((B_REDIRECT_ABILITY_ALLIES >= GEN_4 || !IsAlly(gBattlerAttacker, battler))
|
||||
if ((B_REDIRECT_ABILITY_ALLIES >= GEN_4 || !IsBattlerAlly(gBattlerAttacker, battler))
|
||||
&& battler != gBattlerAttacker
|
||||
&& gBattleStruct->moveTarget[gBattlerAttacker] != battler
|
||||
&& ((ability == ABILITY_LIGHTNING_ROD && moveType == TYPE_ELECTRIC)
|
||||
@ -458,7 +458,7 @@ void HandleAction_UseMove(void)
|
||||
}
|
||||
}
|
||||
|
||||
if ((GetBattlerSide(gBattlerAttacker) == GetBattlerSide(gBattlerTarget))
|
||||
if ((IsBattlerAlly(gBattlerAttacker, gBattlerTarget))
|
||||
&& (!IsBattlerAlive(gBattlerTarget) || gProtectStructs[BATTLE_PARTNER(gBattlerAttacker)].usedAllySwitch))
|
||||
{
|
||||
gBattlescriptCurrInstr = BattleScript_FailedFromAtkCanceler;
|
||||
@ -4253,7 +4253,7 @@ bool32 CanAbilityBlockMove(u32 battlerAtk, u32 battlerDef, u32 move, u32 ability
|
||||
case ABILITY_DAZZLING:
|
||||
case ABILITY_QUEENLY_MAJESTY:
|
||||
case ABILITY_ARMOR_TAIL:
|
||||
if (atkPriority > 0 && !IsAlly(battlerAtk, battlerDef))
|
||||
if (atkPriority > 0 && !IsBattlerAlly(battlerAtk, battlerDef))
|
||||
{
|
||||
if (gBattleMons[battlerAtk].status2 & STATUS2_MULTIPLETURNS)
|
||||
gHitMarker |= HITMARKER_NO_PPDEDUCT;
|
||||
@ -4278,7 +4278,7 @@ bool32 CanAbilityBlockMove(u32 battlerAtk, u32 battlerDef, u32 move, u32 ability
|
||||
case ABILITY_DAZZLING:
|
||||
case ABILITY_QUEENLY_MAJESTY:
|
||||
case ABILITY_ARMOR_TAIL:
|
||||
if (atkPriority > 0 && !IsAlly(battlerAtk, BATTLE_PARTNER(battlerDef)))
|
||||
if (atkPriority > 0 && !IsBattlerAlly(battlerAtk, BATTLE_PARTNER(battlerDef)))
|
||||
{
|
||||
if (gBattleMons[battlerAtk].status2 & STATUS2_MULTIPLETURNS)
|
||||
gHitMarker |= HITMARKER_NO_PPDEDUCT;
|
||||
@ -6309,7 +6309,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
|
||||
SetTypeBeforeUsingMove(gCalledMove, battler);
|
||||
|
||||
// Make sure that the target isn't an ally - if it is, target the original user
|
||||
if (GetBattlerSide(gBattlerTarget) == GetBattlerSide(gBattlerAttacker))
|
||||
if (IsBattlerAlly(gBattlerTarget, gBattlerAttacker))
|
||||
gBattlerTarget = (gBattleScripting.savedBattler & 0xF0) >> 4;
|
||||
gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED;
|
||||
BattleScriptExecute(BattleScript_DancerActivates);
|
||||
@ -11677,7 +11677,7 @@ bool32 BlocksPrankster(u16 move, u32 battlerPrankster, u32 battlerDef, bool32 ch
|
||||
return FALSE;
|
||||
if (!gProtectStructs[battlerPrankster].pranksterElevated)
|
||||
return FALSE;
|
||||
if (GetBattlerSide(battlerPrankster) == GetBattlerSide(battlerDef))
|
||||
if (IsBattlerAlly(battlerPrankster, battlerDef))
|
||||
return FALSE;
|
||||
if (checkTarget && (GetBattlerMoveTargetType(battlerPrankster, move) & (MOVE_TARGET_OPPONENTS_FIELD | MOVE_TARGET_DEPENDS)))
|
||||
return FALSE;
|
||||
@ -11744,12 +11744,13 @@ u32 GetBattlerMoveTargetType(u32 battler, u32 move)
|
||||
bool32 CanTargetBattler(u32 battlerAtk, u32 battlerDef, u16 move)
|
||||
{
|
||||
if (GetMoveEffect(move) == EFFECT_HIT_ENEMY_HEAL_ALLY
|
||||
&& GetBattlerSide(battlerAtk) == GetBattlerSide(battlerDef)
|
||||
&& gStatuses3[battlerAtk] & STATUS3_HEAL_BLOCK)
|
||||
&& IsBattlerAlly(battlerAtk, battlerDef)
|
||||
&& gStatuses3[battlerAtk] & STATUS3_HEAL_BLOCK)
|
||||
return FALSE; // Pokémon affected by Heal Block cannot target allies with Pollen Puff
|
||||
if ((GetActiveGimmick(battlerAtk) == GIMMICK_DYNAMAX || IsGimmickSelected(battlerAtk, GIMMICK_DYNAMAX))
|
||||
&& GetBattlerSide(battlerAtk) == GetBattlerSide(battlerDef))
|
||||
if (IsBattlerAlly(battlerAtk, battlerDef) && (GetActiveGimmick(battlerAtk) == GIMMICK_DYNAMAX
|
||||
|| IsGimmickSelected(battlerAtk, GIMMICK_DYNAMAX)))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -11870,11 +11871,6 @@ bool32 MoveEffectIsGuaranteed(u32 battler, u32 battlerAbility, const struct Addi
|
||||
return additionalEffect->chance == 0 || CalcSecondaryEffectChance(battler, battlerAbility, additionalEffect) >= 100;
|
||||
}
|
||||
|
||||
bool32 IsAlly(u32 battlerAtk, u32 battlerDef)
|
||||
{
|
||||
return (GetBattlerSide(battlerAtk) == GetBattlerSide(battlerDef));
|
||||
}
|
||||
|
||||
bool32 IsGen6ExpShareEnabled(void)
|
||||
{
|
||||
if (I_EXP_SHARE_FLAG <= TEMP_FLAGS_END)
|
||||
|
||||
@ -2068,8 +2068,9 @@ void DeleteFirstMoveAndGiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move)
|
||||
|
||||
u8 CountAliveMonsInBattle(u8 caseId, u32 battler)
|
||||
{
|
||||
s32 i;
|
||||
u8 retVal = 0;
|
||||
u32 i;
|
||||
u32 battlerSide;
|
||||
u32 retVal = 0;
|
||||
|
||||
switch (caseId)
|
||||
{
|
||||
@ -2088,9 +2089,10 @@ u8 CountAliveMonsInBattle(u8 caseId, u32 battler)
|
||||
}
|
||||
break;
|
||||
case BATTLE_ALIVE_SIDE:
|
||||
battlerSide = GetBattlerSide(battler);
|
||||
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
|
||||
{
|
||||
if (GetBattlerSide(i) == GetBattlerSide(battler) && !(gAbsentBattlerFlags & (1u << i)))
|
||||
if (GetBattlerSide(i) == battlerSide && !(gAbsentBattlerFlags & (1u << i)))
|
||||
retVal++;
|
||||
}
|
||||
break;
|
||||
@ -7033,7 +7035,7 @@ u32 GetRegionalFormByRegion(u32 species, u32 region)
|
||||
{
|
||||
if (firstFoundSpecies == 0)
|
||||
firstFoundSpecies = formTable[formId];
|
||||
|
||||
|
||||
if (IsSpeciesRegionalFormFromRegion(formTable[formId], region))
|
||||
return formTable[formId];
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user