diff --git a/include/battle_ai_util.h b/include/battle_ai_util.h index 5e66577e30..11eba7b661 100644 --- a/include/battle_ai_util.h +++ b/include/battle_ai_util.h @@ -5,7 +5,7 @@ #define AI_IS_FASTER 0 #define AI_IS_SLOWER 1 -#define FOE(battler) ((battler ^ BIT_SIDE) & BIT_SIDE) +#define FOE(battler) ((BATTLE_OPPOSITE(battler)) & BIT_SIDE) bool32 AI_RandLessThan(u8 val); void RecordLastUsedMoveByTarget(void); diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index f496b90e81..af642aa8dc 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -486,7 +486,7 @@ static u8 ChooseMoveOrAction_Doubles(void) bestMovePointsForTarget[i] = mostViableMovesScores[0]; // Don't use a move against ally if it has less than 100 points. - if (i == (sBattler_AI ^ BIT_FLANK) && bestMovePointsForTarget[i] < 100) + if (i == BATTLE_PARTNER(sBattler_AI) && bestMovePointsForTarget[i] < 100) { bestMovePointsForTarget[i] = -1; mostViableMovesScores[0] = mostViableMovesScores[0]; // Needed to match. diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index 25c7f3b9d5..98fcf948a3 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -3248,7 +3248,7 @@ s32 CountUsablePartyMons(u8 battlerId) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { battlerOnField1 = gBattlerPartyIndexes[battlerId]; - battlerOnField2 = gBattlerPartyIndexes[GetBattlerAtPosition(GetBattlerPosition(battlerId) ^ BIT_FLANK)]; + battlerOnField2 = gBattlerPartyIndexes[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(battlerId)))]; } else // In singles there's only one battlerId by side. { diff --git a/src/battle_anim_new.c b/src/battle_anim_new.c index 35c1244670..0a3d433b46 100644 --- a/src/battle_anim_new.c +++ b/src/battle_anim_new.c @@ -6523,7 +6523,7 @@ const struct SpriteTemplate gSoulStealZStarSpriteTemplate = //general void AnimTask_IsTargetPartner(u8 taskId) { - if (gBattleAnimTarget == (gBattleAnimAttacker ^ BIT_FLANK)) + if (gBattleAnimTarget == BATTLE_PARTNER(gBattleAnimAttacker)) gBattleAnimArgs[0] = 1; else gBattleAnimArgs[0] = 0; diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index d249fc38be..8f02fb3e35 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -226,7 +226,7 @@ static void Intro_DelayAndEnd(void) static bool32 TwoIntroMons(u32 battlerId) // Double battle with both player pokemon active. { - return (IsDoubleBattle() && IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[battlerId ^ BIT_FLANK]])); + return (IsDoubleBattle() && IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)]])); } static void Intro_WaitForShinyAnimAndHealthbox(void) diff --git a/src/battle_message.c b/src/battle_message.c index 7b263ea657..8298accf1f 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -2703,7 +2703,7 @@ void BufferStringBattle(u16 stringID) { if (gBattleTypeFlags & BATTLE_TYPE_LEGENDARY) stringPtr = sText_LegendaryPkmnAppeared; - else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]])) // interesting, looks like they had something planned for wild double battles + else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]])) // interesting, looks like they had something planned for wild double battles stringPtr = sText_TwoWildPkmnAppeared; else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL) stringPtr = sText_WildPkmnAppearedPause; @@ -2714,7 +2714,7 @@ void BufferStringBattle(u16 stringID) case STRINGID_INTROSENDOUT: // poke first send-out if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { - if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && IsValidForBattle(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]])) + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && IsValidForBattle(&gPlayerParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]])) { if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) stringPtr = sText_InGamePartnerSentOutZGoN; @@ -2732,7 +2732,7 @@ void BufferStringBattle(u16 stringID) } else { - if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]])) + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]])) { if (BATTLE_TWO_VS_ONE_OPPONENT) stringPtr = sText_Trainer1SentOutTwoPkmn; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index c485f40172..5c4ba2c401 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -10730,7 +10730,7 @@ static void Cmd_forcerandomswitch(void) monsCount = 6; minNeeded = 2; battler2PartyId = gBattlerPartyIndexes[gBattlerTarget]; - battler1PartyId = gBattlerPartyIndexes[gBattlerTarget ^ BIT_FLANK]; + battler1PartyId = gBattlerPartyIndexes[BATTLE_PARTNER(gBattlerTarget)]; } else if ((gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER && gBattleTypeFlags & BATTLE_TYPE_LINK) || (gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER && gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) diff --git a/src/battle_util.c b/src/battle_util.c index d39b03215b..1c1cf685d9 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5817,7 +5817,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move { if (gBattleMons[i].ability == ABILITY_TRACE && (gBattleResources->flags->flags[i] & RESOURCE_FLAG_TRACED)) { - u8 side = (GetBattlerPosition(i) ^ BIT_SIDE) & BIT_SIDE; // side of the opposing pokemon + u8 side = (BATTLE_OPPOSITE(GetBattlerPosition(i))) & BIT_SIDE; // side of the opposing pokemon u8 target1 = GetBattlerAtPosition(side); u8 target2 = GetBattlerAtPosition(side + BIT_FLANK);