From 3ba4d9e7db696fa857e81d6096c374c4a8d31f13 Mon Sep 17 00:00:00 2001 From: gruxor Date: Thu, 3 Aug 2023 14:26:53 -0400 Subject: [PATCH 1/7] Remove redundant side check macros/funcs --- include/battle.h | 3 +- include/battle_anim.h | 1 - src/battle_ai_main.c | 2 +- src/battle_ai_switch_items.c | 30 ++++++++--------- src/battle_ai_util.c | 4 +-- src/battle_anim.c | 20 ++++++------ src/battle_anim_bug.c | 4 +-- src/battle_anim_dark.c | 2 +- src/battle_anim_effects_1.c | 2 +- src/battle_anim_effects_2.c | 2 +- src/battle_anim_effects_3.c | 4 +-- src/battle_anim_fight.c | 4 +-- src/battle_anim_ice.c | 8 ++--- src/battle_anim_mons.c | 19 ++++------- src/battle_anim_poison.c | 2 +- src/battle_anim_psychic.c | 4 +-- src/battle_anim_utility_funcs.c | 8 ++--- src/battle_anim_water.c | 2 +- src/battle_controller_link_opponent.c | 16 ++++----- src/battle_controller_link_partner.c | 8 ++--- src/battle_controller_opponent.c | 14 ++++---- src/battle_controller_player.c | 20 ++++++------ src/battle_controller_player_partner.c | 8 ++--- src/battle_controller_recorded_opponent.c | 12 +++---- src/battle_controller_recorded_player.c | 16 ++++----- src/battle_controller_safari.c | 2 +- src/battle_controller_wally.c | 6 ++-- src/battle_controllers.c | 4 +-- src/battle_gfx_sfx_util.c | 10 +++--- src/battle_interface.c | 22 ++++++------- src/battle_main.c | 40 +++++++++++------------ src/battle_message.c | 6 ++-- src/battle_script_commands.c | 30 ++++++++--------- src/battle_tv.c | 10 +++--- src/battle_util.c | 24 +++++++------- src/battle_z_move.c | 6 ++-- src/pokeball.c | 2 +- src/reshow_battle_screen.c | 10 +++--- 38 files changed, 190 insertions(+), 197 deletions(-) diff --git a/include/battle.h b/include/battle.h index 00893d105e99..7fb52a9499a1 100644 --- a/include/battle.h +++ b/include/battle.h @@ -15,8 +15,7 @@ #include "pokeball.h" #include "battle_debug.h" -#define GET_BATTLER_SIDE(battler) (GetBattlerPosition(battler) & BIT_SIDE) -#define GET_BATTLER_SIDE2(battler) (gBattlerPositions[battler] & BIT_SIDE) +#define GET_BATTLER_SIDE(battler) (gBattlerPositions[battler] & BIT_SIDE) // Used to exclude moves learned temporarily by Transform or Mimic #define MOVE_IS_PERMANENT(battler, moveSlot) \ diff --git a/include/battle_anim.h b/include/battle_anim.h index 8a1e76a8a53e..361ab341cb95 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -166,7 +166,6 @@ void DestroyAnimVisualTaskAndDisableBlend(u8 taskId); void DestroySpriteAndFreeResources_(struct Sprite *sprite); void SetBattlerSpriteYOffsetFromOtherYScale(u8 spriteId, u8 otherSpriteId); u8 GetBattlerSide(u8 battler); -u8 GetBattlerPosition(u8 battler); u8 GetBattlerAtPosition(u8 position); void ConvertPosDataToTranslateLinearData(struct Sprite *sprite); void InitAnimFastLinearTranslationWithSpeedAndPos(struct Sprite *sprite); diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 9243bacb9c83..62f780c7f482 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -326,7 +326,7 @@ void Ai_UpdateSwitchInData(u32 battler) ClearBattlerMoveHistory(battler); ClearBattlerAbilityHistory(battler); ClearBattlerItemEffectHistory(battler); - CopyBattlerDataToAIParty(GetBattlerPosition(battler), side); + CopyBattlerDataToAIParty(gBattlerPositions[battler], side); } } diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index 73d7ecb645a6..5a1cbbcb7a3c 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -85,7 +85,7 @@ static bool8 ShouldSwitchIfWonderGuard(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) return FALSE; - opposingPosition = BATTLE_OPPOSITE(GetBattlerPosition(gActiveBattler)); + opposingPosition = BATTLE_OPPOSITE(gBattlerPositions[gActiveBattler]); if (GetBattlerAbility(GetBattlerAtPosition(opposingPosition)) != ABILITY_WONDER_GUARD) return FALSE; @@ -163,10 +163,10 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { battlerIn1 = gActiveBattler; - if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))]) + if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))]) battlerIn2 = gActiveBattler; else - battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))); + battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler])); } else { @@ -233,7 +233,7 @@ static bool8 ShouldSwitchIfGameStatePrompt(void) bool8 switchMon = FALSE; u16 monAbility = AI_DATA->abilities[gActiveBattler]; u16 holdEffect = AI_DATA->holdEffects[gActiveBattler]; - u8 opposingPosition = BATTLE_OPPOSITE(GetBattlerPosition(gActiveBattler)); + u8 opposingPosition = BATTLE_OPPOSITE(gBattlerPositions[gActiveBattler]); u8 opposingBattler = GetBattlerAtPosition(opposingPosition); s32 moduloChance = 4; //25% Chance Default s32 chanceReducer = 1; //No Reduce default. Increase to reduce @@ -405,7 +405,7 @@ static bool8 ShouldSwitchIfAbilityBenefit(void) s32 monToSwitchId; s32 moduloChance = 4; //25% Chance Default s32 chanceReducer = 1; //No Reduce default. Increase to reduce - u8 battlerId = GetBattlerPosition(gActiveBattler); + u8 battlerId = gBattlerPositions[gActiveBattler]; if (AnyStatIsRaised(battlerId)) chanceReducer = 5; // Reduce switchout probability by factor of 5 if setup @@ -460,7 +460,7 @@ static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng) s32 i; u16 move; - opposingPosition = BATTLE_OPPOSITE(GetBattlerPosition(gActiveBattler)); + opposingPosition = BATTLE_OPPOSITE(gBattlerPositions[gActiveBattler]); opposingBattler = GetBattlerAtPosition(opposingPosition); if (!(gAbsentBattlerFlags & gBitTable[opposingBattler])) @@ -541,10 +541,10 @@ static bool8 FindMonWithFlagsAndSuperEffective(u16 flags, u8 moduloPercent) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { battlerIn1 = gActiveBattler; - if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))]) + if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))]) battlerIn2 = gActiveBattler; else - battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))); + battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler])); } else { @@ -630,10 +630,10 @@ bool32 ShouldSwitch(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { battlerIn1 = gActiveBattler; - if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))]) + if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))]) battlerIn2 = gActiveBattler; else - battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))); + battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler])); } else { @@ -720,7 +720,7 @@ void AI_TrySwitchOrUseItem(void) u8 battlerIn1, battlerIn2; s32 firstId; s32 lastId; // + 1 - u8 battlerIdentity = GetBattlerPosition(gActiveBattler); + u8 battlerIdentity = gBattlerPositions[gActiveBattler]; if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) party = gPlayerParty; @@ -928,10 +928,10 @@ u8 GetMostSuitableMonToSwitchInto(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { battlerIn1 = gActiveBattler; - if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))]) + if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))]) battlerIn2 = gActiveBattler; else - battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))); + battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler])); opposingBattler = BATTLE_OPPOSITE(battlerIn1); if (gAbsentBattlerFlags & gBitTable[opposingBattler]) @@ -939,7 +939,7 @@ u8 GetMostSuitableMonToSwitchInto(void) } else { - opposingBattler = GetBattlerAtPosition(BATTLE_OPPOSITE(GetBattlerPosition(gActiveBattler))); + opposingBattler = GetBattlerAtPosition(BATTLE_OPPOSITE(gBattlerPositions[gActiveBattler])); battlerIn1 = gActiveBattler; battlerIn2 = gActiveBattler; } @@ -1023,7 +1023,7 @@ static bool8 ShouldUseItem(void) bool8 shouldUse = FALSE; // If teaming up with player and Pokemon is on the right, or Pokemon is currently held by Sky Drop - if ((gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_RIGHT) + if ((gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && gBattlerPositions[gActiveBattler] == B_POSITION_PLAYER_RIGHT) || gStatuses3[gActiveBattler] & STATUS3_SKY_DROPPED) return FALSE; diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index c18209314bbf..1f78b87d001b 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -442,7 +442,7 @@ void RecordLastUsedMoveByTarget(void) bool32 BattlerHasAi(u32 battlerId) { - switch (GetBattlerPosition(battlerId)) + switch (gBattlerPositions[battlerId]) { case B_POSITION_PLAYER_LEFT: default: @@ -3404,7 +3404,7 @@ s32 CountUsablePartyMons(u8 battlerId) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { battlerOnField1 = gBattlerPartyIndexes[battlerId]; - battlerOnField2 = gBattlerPartyIndexes[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(battlerId)))]; + battlerOnField2 = gBattlerPartyIndexes[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[battlerId]))]; } else // In singles there's only one battlerId by side. { diff --git a/src/battle_anim.c b/src/battle_anim.c index 5691e21e2a2a..9cbfb22d7b90 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -852,7 +852,7 @@ static void Cmd_monbg(void) // Move designated battler to background if (IsBattlerSpriteVisible(battlerId)) { - u8 position = GetBattlerPosition(battlerId); + u8 position = gBattlerPositions[battlerId]; if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) toBG_2 = FALSE; else @@ -872,7 +872,7 @@ static void Cmd_monbg(void) battlerId ^= BIT_FLANK; if (IsBattlerSpriteVisible(battlerId)) { - u8 position = GetBattlerPosition(battlerId); + u8 position = gBattlerPositions[battlerId]; if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) toBG_2 = FALSE; else @@ -970,7 +970,7 @@ void MoveBattlerSpriteToBG(u8 battlerId, bool8 toBG_2, bool8 setSpriteInvisible) if (IsContest()) battlerPosition = 0; else - battlerPosition = GetBattlerPosition(battlerId); + battlerPosition = gBattlerPositions[battlerId]; DrawBattlerOnBg(1, 0, 0, battlerPosition, animBg.paletteId, animBg.bgTiles, animBg.bgTilemap, animBg.tilesOffset); @@ -1002,7 +1002,7 @@ void MoveBattlerSpriteToBG(u8 battlerId, bool8 toBG_2, bool8 setSpriteInvisible) LoadPalette(&gPlttBufferUnfaded[OBJ_PLTT_ID(battlerId)], BG_PLTT_ID(9), PLTT_SIZE_4BPP); CpuCopy32(&gPlttBufferUnfaded[OBJ_PLTT_ID(battlerId)], (void *)(BG_PLTT + PLTT_OFFSET_4BPP(9)), PLTT_SIZE_4BPP); - DrawBattlerOnBg(2, 0, 0, GetBattlerPosition(battlerId), animBg.paletteId, animBg.bgTiles + 0x1000, animBg.bgTilemap + 0x400, animBg.tilesOffset); + DrawBattlerOnBg(2, 0, 0, gBattlerPositions[battlerId], animBg.paletteId, animBg.bgTiles + 0x1000, animBg.bgTilemap + 0x400, animBg.tilesOffset); } } @@ -1146,7 +1146,7 @@ static void Task_ClearMonBg(u8 taskId) if (gTasks[taskId].data[1] != 1) { u8 to_BG2; - u8 position = GetBattlerPosition(gTasks[taskId].data[2]); + u8 position = gBattlerPositions[gTasks[taskId].data[2]]; if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) to_BG2 = FALSE; else @@ -1191,7 +1191,7 @@ static void Cmd_monbg_static(void) if (IsBattlerSpriteVisible(battlerId)) { - u8 position = GetBattlerPosition(battlerId); + u8 position = gBattlerPositions[battlerId]; if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) toBG_2 = FALSE; else @@ -1203,7 +1203,7 @@ static void Cmd_monbg_static(void) battlerId ^= BIT_FLANK; if (animBattlerId > 1 && IsBattlerSpriteVisible(battlerId)) { - u8 position = GetBattlerPosition(battlerId); + u8 position = gBattlerPositions[battlerId]; if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) toBG_2 = FALSE; else @@ -1255,7 +1255,7 @@ static void Task_ClearMonBgStatic(u8 taskId) { bool8 toBG_2; u8 battlerId = gTasks[taskId].data[2]; - u8 position = GetBattlerPosition(battlerId); + u8 position = gBattlerPositions[battlerId]; if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) toBG_2 = FALSE; else @@ -1961,7 +1961,7 @@ static void Cmd_splitbgprio(void) battlerId = gBattleAnimAttacker; // Apply only if the given battler is the lead (on left from team's perspective) - battlerPosition = GetBattlerPosition(battlerId); + battlerPosition = gBattlerPositions[battlerId]; if (!IsContest() && (battlerPosition == B_POSITION_PLAYER_LEFT || battlerPosition == B_POSITION_OPPONENT_RIGHT)) { SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1); @@ -1997,7 +1997,7 @@ static void Cmd_splitbgprio_foes(void) battlerId = gBattleAnimAttacker; // Apply only if the given battler is the lead (on left from team's perspective) - battlerPosition = GetBattlerPosition(battlerId); + battlerPosition = gBattlerPositions[battlerId]; if (!IsContest() && (battlerPosition == B_POSITION_PLAYER_LEFT || battlerPosition == B_POSITION_OPPONENT_RIGHT)) { SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1); diff --git a/src/battle_anim_bug.c b/src/battle_anim_bug.c index bd91f18d1934..0b7e18934878 100644 --- a/src/battle_anim_bug.c +++ b/src/battle_anim_bug.c @@ -392,8 +392,8 @@ static void AnimTranslateStinger(struct Sprite *sprite) if (!IsContest() && GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget)) { - if (GetBattlerPosition(gBattleAnimTarget) == B_POSITION_PLAYER_LEFT - || GetBattlerPosition(gBattleAnimTarget) == B_POSITION_OPPONENT_LEFT) + if (gBattlerPositions[gBattleAnimTarget] == B_POSITION_PLAYER_LEFT + || gBattlerPositions[gBattleAnimTarget] == B_POSITION_OPPONENT_LEFT) { gBattleAnimArgs[2] *= -1; gBattleAnimArgs[0] *= -1; diff --git a/src/battle_anim_dark.c b/src/battle_anim_dark.c index 2400c22aafde..778b88a16654 100644 --- a/src/battle_anim_dark.c +++ b/src/battle_anim_dark.c @@ -916,7 +916,7 @@ void AnimTask_MetallicShine(u8 taskId) if (IsDoubleBattle() && !IsContest()) { - if (GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_OPPONENT_RIGHT || GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_PLAYER_LEFT) + if (gBattlerPositions[gBattleAnimAttacker] == B_POSITION_OPPONENT_RIGHT || gBattlerPositions[gBattleAnimAttacker] == B_POSITION_PLAYER_LEFT) { if (IsBattlerSpriteVisible(BATTLE_PARTNER(gBattleAnimAttacker)) == TRUE) { diff --git a/src/battle_anim_effects_1.c b/src/battle_anim_effects_1.c index 63aea3f8083c..80f8ea27d9e6 100644 --- a/src/battle_anim_effects_1.c +++ b/src/battle_anim_effects_1.c @@ -3009,7 +3009,7 @@ const struct SpriteTemplate gSeedFlareGreenCirclesTemplate = // functions static void AnimGrassKnot(struct Sprite *sprite) { - if (BATTLE_PARTNER(gBattleAnimAttacker) == gBattleAnimTarget && GetBattlerPosition(gBattleAnimTarget) < B_POSITION_PLAYER_RIGHT) + if (BATTLE_PARTNER(gBattleAnimAttacker) == gBattleAnimTarget && gBattlerPositions[gBattleAnimTarget] < B_POSITION_PLAYER_RIGHT) gBattleAnimArgs[0] *= -1; InitSpritePosToAnimTarget(sprite, TRUE); diff --git a/src/battle_anim_effects_2.c b/src/battle_anim_effects_2.c index 716069944d2d..bb2ee4def120 100755 --- a/src/battle_anim_effects_2.c +++ b/src/battle_anim_effects_2.c @@ -1704,7 +1704,7 @@ void AnimTask_AirCutterProjectile(u8 taskId) } else { - if (GET_BATTLER_SIDE2(gBattleAnimTarget) == B_SIDE_PLAYER) + if (GET_BATTLER_SIDE(gBattleAnimTarget) == B_SIDE_PLAYER) { gTasks[taskId].data[4] = 1; gBattleAnimArgs[0] = -gBattleAnimArgs[0]; diff --git a/src/battle_anim_effects_3.c b/src/battle_anim_effects_3.c index 3d89c3614414..c9f2aef1b204 100755 --- a/src/battle_anim_effects_3.c +++ b/src/battle_anim_effects_3.c @@ -2369,7 +2369,7 @@ void AnimTask_TransformMon(u8 taskId) if (IsContest()) position = B_POSITION_PLAYER_LEFT; else - position = GetBattlerPosition(gBattleAnimAttacker); + position = gBattlerPositions[gBattleAnimAttacker]; src = gMonSpritesGfxPtr->sprites.ptr[position]; dest = animBg.bgTiles; @@ -2652,7 +2652,7 @@ void AnimTask_DoomDesireLightBeam(u8 taskId) } else { - u8 position = GetBattlerPosition(gBattleAnimTarget); + u8 position = gBattlerPositions[gBattleAnimTarget]; if (IsDoubleBattle() == TRUE) { if (position == B_POSITION_OPPONENT_LEFT) diff --git a/src/battle_anim_fight.c b/src/battle_anim_fight.c index 9ffe2d3c22ca..ee6cc3258c8d 100644 --- a/src/battle_anim_fight.c +++ b/src/battle_anim_fight.c @@ -564,7 +564,7 @@ static void AnimFistOrFootRandomPos(struct Sprite *sprite) if (Random2() & 1) y *= -1; - if (GET_BATTLER_SIDE2(battler) == B_SIDE_PLAYER) + if (GET_BATTLER_SIDE(battler) == B_SIDE_PLAYER) y += 0xFFF0; sprite->x += x; @@ -639,7 +639,7 @@ static void AnimCrossChopHand_Step(struct Sprite *sprite) // Rolling Kick / Low Kick static void AnimSlidingKick(struct Sprite *sprite) { - if (BATTLE_PARTNER(gBattleAnimAttacker) == gBattleAnimTarget && GetBattlerPosition(gBattleAnimTarget) < B_POSITION_PLAYER_RIGHT) + if (BATTLE_PARTNER(gBattleAnimAttacker) == gBattleAnimTarget && gBattlerPositions[gBattleAnimTarget] < B_POSITION_PLAYER_RIGHT) gBattleAnimArgs[0] *= -1; InitSpritePosToAnimTarget(sprite, TRUE); diff --git a/src/battle_anim_ice.c b/src/battle_anim_ice.c index d4e4442023cb..12b2dc0984f8 100644 --- a/src/battle_anim_ice.c +++ b/src/battle_anim_ice.c @@ -1276,12 +1276,12 @@ static void InitPoisonGasCloudAnim(struct Sprite *sprite) if (GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2) < GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2)) sprite->data[7] = 0x8000; - if (GET_BATTLER_SIDE2(gBattleAnimTarget) == B_SIDE_PLAYER) + if (GET_BATTLER_SIDE(gBattleAnimTarget) == B_SIDE_PLAYER) { gBattleAnimArgs[1] = -gBattleAnimArgs[1]; gBattleAnimArgs[3] = -gBattleAnimArgs[3]; - if ((sprite->data[7] & 0x8000) && GET_BATTLER_SIDE2(gBattleAnimAttacker) == B_SIDE_PLAYER) + if ((sprite->data[7] & 0x8000) && GET_BATTLER_SIDE(gBattleAnimAttacker) == B_SIDE_PLAYER) sprite->subpriority = gSprites[GetAnimBattlerSpriteId(ANIM_TARGET)].subpriority + 1; sprite->data[6] = 1; @@ -1362,7 +1362,7 @@ static void MovePoisonGasCloud(struct Sprite *sprite) sprite->data[7]++; if (IsContest()) sprite->data[5] = 80; - else if (GET_BATTLER_SIDE2(gBattleAnimTarget) != B_SIDE_PLAYER) + else if (GET_BATTLER_SIDE(gBattleAnimTarget) != B_SIDE_PLAYER) sprite->data[5] = 204; else sprite->data[5] = 80; @@ -1408,7 +1408,7 @@ static void MovePoisonGasCloud(struct Sprite *sprite) sprite->data[4] = sprite->y + 4; if (IsContest()) sprite->data[2] = -0x10; - else if (GET_BATTLER_SIDE2(gBattleAnimTarget) != B_SIDE_PLAYER) + else if (GET_BATTLER_SIDE(gBattleAnimTarget) != B_SIDE_PLAYER) sprite->data[2] = 0x100; else sprite->data[2] = -0x10; diff --git a/src/battle_anim_mons.c b/src/battle_anim_mons.c index f2016dd5e279..6a09888bd983 100644 --- a/src/battle_anim_mons.c +++ b/src/battle_anim_mons.c @@ -101,10 +101,10 @@ u8 GetBattlerSpriteCoord(u8 battlerId, u8 coordType) { case BATTLER_COORD_X: case BATTLER_COORD_X_2: - retVal = sBattlerCoords[WhichBattleCoords(battlerId)][GetBattlerPosition(battlerId)].x; + retVal = sBattlerCoords[WhichBattleCoords(battlerId)][gBattlerPositions[battlerId]].x; break; case BATTLER_COORD_Y: - retVal = sBattlerCoords[WhichBattleCoords(battlerId)][GetBattlerPosition(battlerId)].y; + retVal = sBattlerCoords[WhichBattleCoords(battlerId)][gBattlerPositions[battlerId]].y; break; case BATTLER_COORD_Y_PIC_OFFSET: case BATTLER_COORD_Y_PIC_OFFSET_DEFAULT: @@ -235,7 +235,7 @@ u8 GetBattlerSpriteFinal_Y(u8 battlerId, u16 species, bool8 a3) offset = GetBattlerYDelta(battlerId, species); offset -= GetBattlerElevation(battlerId, species); } - y = offset + sBattlerCoords[WhichBattleCoords(battlerId)][GetBattlerPosition(battlerId)].y; + y = offset + sBattlerCoords[WhichBattleCoords(battlerId)][gBattlerPositions[battlerId]].y; if (a3) { if (GetBattlerSide(battlerId) == B_SIDE_PLAYER) @@ -847,12 +847,7 @@ bool32 InitSpritePosToAnimBattler(u32 animBattlerId, struct Sprite *sprite, bool u8 GetBattlerSide(u8 battlerId) { - return GET_BATTLER_SIDE2(battlerId); -} - -u8 GetBattlerPosition(u8 battlerId) -{ - return gBattlerPositions[battlerId]; + return GET_BATTLER_SIDE(battlerId); } u8 GetBattlerAtPosition(u8 position) @@ -2048,7 +2043,7 @@ u8 GetBattlerSpriteSubpriority(u8 battlerId) } else { - position = GetBattlerPosition(battlerId); + position = gBattlerPositions[battlerId]; if (position == B_POSITION_PLAYER_LEFT) subpriority = 30; else if (position == B_POSITION_PLAYER_RIGHT) @@ -2064,7 +2059,7 @@ u8 GetBattlerSpriteSubpriority(u8 battlerId) u8 GetBattlerSpriteBGPriority(u8 battlerId) { - u8 position = GetBattlerPosition(battlerId); + u8 position = gBattlerPositions[battlerId]; if (IsContest()) return 2; @@ -2078,7 +2073,7 @@ u8 GetBattlerSpriteBGPriorityRank(u8 battlerId) { if (!IsContest()) { - u8 position = GetBattlerPosition(battlerId); + u8 position = gBattlerPositions[battlerId]; if (position == B_POSITION_PLAYER_LEFT || position == B_POSITION_OPPONENT_RIGHT) return 2; else diff --git a/src/battle_anim_poison.c b/src/battle_anim_poison.c index 8905f5c475af..68b8be3822ce 100644 --- a/src/battle_anim_poison.c +++ b/src/battle_anim_poison.c @@ -362,7 +362,7 @@ static void AnimGunkShotParticlesStep(struct Sprite *sprite) static void AnimSuckerPunch(struct Sprite *sprite) { - if (BATTLE_PARTNER(gBattleAnimAttacker) == gBattleAnimTarget && GetBattlerPosition(gBattleAnimTarget) < B_POSITION_PLAYER_RIGHT) + if (BATTLE_PARTNER(gBattleAnimAttacker) == gBattleAnimTarget && gBattlerPositions[gBattleAnimTarget] < B_POSITION_PLAYER_RIGHT) gBattleAnimArgs[0] *= -1; InitSpritePosToAnimTarget(sprite, TRUE); diff --git a/src/battle_anim_psychic.c b/src/battle_anim_psychic.c index 1c998e9c56e9..bb8e4e2a1e43 100644 --- a/src/battle_anim_psychic.c +++ b/src/battle_anim_psychic.c @@ -490,8 +490,8 @@ static void AnimPsychoCut(struct Sprite *sprite) if (!IsContest() && GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget)) { - if (GetBattlerPosition(gBattleAnimTarget) == B_POSITION_PLAYER_LEFT - || GetBattlerPosition(gBattleAnimTarget) == B_POSITION_OPPONENT_LEFT) + if (gBattlerPositions[gBattleAnimTarget] == B_POSITION_PLAYER_LEFT + || gBattlerPositions[gBattleAnimTarget] == B_POSITION_OPPONENT_LEFT) { s16 temp1, temp2; diff --git a/src/battle_anim_utility_funcs.c b/src/battle_anim_utility_funcs.c index 4885a7ef371b..d98846e4000e 100644 --- a/src/battle_anim_utility_funcs.c +++ b/src/battle_anim_utility_funcs.c @@ -304,8 +304,8 @@ void AnimTask_DrawFallingWhiteLinesOnAttacker(u8 taskId) if (IsDoubleBattle() && !IsContest()) { - if (GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_OPPONENT_RIGHT - || GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_PLAYER_LEFT) + if (gBattlerPositions[gBattleAnimAttacker] == B_POSITION_OPPONENT_RIGHT + || gBattlerPositions[gBattleAnimAttacker] == B_POSITION_PLAYER_LEFT) { if (IsBattlerSpriteVisible(BATTLE_PARTNER(gBattleAnimAttacker)) == TRUE) { @@ -427,8 +427,8 @@ static void StatsChangeAnimation_Step1(u8 taskId) if (IsDoubleBattle() && sAnimStatsChangeData->data[3] == 0) { - if (GetBattlerPosition(sAnimStatsChangeData->battler1) == B_POSITION_OPPONENT_RIGHT - || GetBattlerPosition(sAnimStatsChangeData->battler1) == B_POSITION_PLAYER_LEFT) + if (gBattlerPositions[sAnimStatsChangeData->battler1] == B_POSITION_OPPONENT_RIGHT + || gBattlerPositions[sAnimStatsChangeData->battler1] == B_POSITION_PLAYER_LEFT) { if (IsBattlerSpriteVisible(sAnimStatsChangeData->battler2) == TRUE) { diff --git a/src/battle_anim_water.c b/src/battle_anim_water.c index 961f154baa2b..103e7ee703c2 100644 --- a/src/battle_anim_water.c +++ b/src/battle_anim_water.c @@ -924,7 +924,7 @@ static void AnimHydroCannonBeam(struct Sprite *sprite) if (GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget)) { gBattleAnimArgs[0] *= -1; - if (GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_PLAYER_LEFT || GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_OPPONENT_LEFT) + if (gBattlerPositions[gBattleAnimAttacker] == B_POSITION_PLAYER_LEFT || gBattlerPositions[gBattleAnimAttacker] == B_POSITION_OPPONENT_LEFT) gBattleAnimArgs[0] *= -1; } if ((gBattleAnimArgs[5] & 0xFF00) == 0) diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index 69e2f6bde43a..8a5b74e2cdbe 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -260,7 +260,7 @@ static void Intro_WaitForShinyAnimAndHealthbox(void) gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE; - if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_RIGHT) + if (gBattlerPositions[gActiveBattler] == B_POSITION_OPPONENT_RIGHT) { FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS); FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS); @@ -317,7 +317,7 @@ static void Intro_TryShinyAnimShowHealthbox(void) { if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) { - if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_LEFT) + if (gBattlerPositions[gActiveBattler] == B_POSITION_OPPONENT_LEFT) m4aMPlayContinue(&gMPlayInfo_BGM); } else @@ -335,7 +335,7 @@ static void Intro_TryShinyAnimShowHealthbox(void) if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { - if (gBattleTypeFlags & BATTLE_TYPE_MULTI && GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_RIGHT) + if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattlerPositions[gActiveBattler] == B_POSITION_OPPONENT_RIGHT) { if (++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == 1) return; @@ -1119,7 +1119,7 @@ static void LinkOpponentHandleLoadMonSprite(void) u16 species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); - SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(gActiveBattler, BATTLER_COORD_X_2), @@ -1154,7 +1154,7 @@ static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit) species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId); - SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); + SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[battlerId]); gBattlerSpriteIds[battlerId] = CreateSprite( &gMultiuseSpriteTemplate, @@ -1224,7 +1224,7 @@ static void LinkOpponentHandleDrawTrainerPic(void) if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon + if ((gBattlerPositions[gActiveBattler] & BIT_FLANK) != 0) // second mon xPos = 152; else // first mon xPos = 200; @@ -1290,7 +1290,7 @@ static void LinkOpponentHandleDrawTrainerPic(void) } DecompressTrainerFrontPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, (8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 40, @@ -1315,7 +1315,7 @@ static void LinkOpponentHandleTrainerSlide(void) trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_B); DecompressTrainerFrontPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, 176, (8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 40, 0x1E); gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = 96; diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c index 8684ba70ebe5..046592bec519 100644 --- a/src/battle_controller_link_partner.c +++ b/src/battle_controller_link_partner.c @@ -1016,7 +1016,7 @@ static void LinkPartnerHandleLoadMonSprite(void) BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES); - SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(gActiveBattler, BATTLER_COORD_X_2), @@ -1046,7 +1046,7 @@ static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit) gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1]; species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); - SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); + SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[battlerId]); gBattlerSpriteIds[battlerId] = CreateSprite( &gMultiuseSpriteTemplate, @@ -1115,7 +1115,7 @@ static void LinkPartnerHandleDrawTrainerPic(void) if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon + if ((gBattlerPositions[gActiveBattler] & BIT_FLANK) != 0) // second mon xPos = 90; else // first mon xPos = 32; @@ -1141,7 +1141,7 @@ static void LinkPartnerHandleDrawTrainerPic(void) } DecompressTrainerBackPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, (8 - gTrainerBackPicCoords[trainerPicId].size) * 4 + 80, GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index f316f19ea879..91b432376b73 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -277,7 +277,7 @@ static void Intro_WaitForShinyAnimAndHealthbox(void) } else if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim) { - if (GetBattlerPosition(gActiveBattler) == 3) + if (gBattlerPositions[gActiveBattler] == 3) { if (!gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].triedShinyMonAnim && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].finishedShinyMonAnim) @@ -345,7 +345,7 @@ static void Intro_TryShinyAnimShowHealthbox(void) { if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) { - if (GetBattlerPosition(gActiveBattler) == 1) + if (gBattlerPositions[gActiveBattler] == 1) m4aMPlayContinue(&gMPlayInfo_BGM); } else @@ -1149,7 +1149,7 @@ static void OpponentHandleLoadMonSprite(void) u16 species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); - SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(gActiveBattler, BATTLER_COORD_X_2), @@ -1186,7 +1186,7 @@ static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit) species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId); - SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); + SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[battlerId]); gBattlerSpriteIds[battlerId] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(battlerId, BATTLER_COORD_X_2), @@ -1308,7 +1308,7 @@ static void OpponentHandleDrawTrainerPic(void) if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_TWO_OPPONENTS) && !BATTLE_TWO_VS_ONE_OPPONENT) { - if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon + if ((gBattlerPositions[gActiveBattler] & BIT_FLANK) != 0) // second mon xPos = 152; else // first mon xPos = 200; @@ -1319,7 +1319,7 @@ static void OpponentHandleDrawTrainerPic(void) } DecompressTrainerFrontPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, (8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 40, @@ -1391,7 +1391,7 @@ static void OpponentHandleTrainerSlide(void) } DecompressTrainerFrontPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, 176, (8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 40, 0x1E); gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = 96; diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index eb47db444ccd..c9f0c0f83be7 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -308,7 +308,7 @@ static void HandleInputChooseAction(void) else if (JOY_NEW(B_BUTTON) || gPlayerDpadHoldFrames > 59) { if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) - && GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_RIGHT + && gBattlerPositions[gActiveBattler] == B_POSITION_PLAYER_RIGHT && !(gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]) && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { @@ -405,7 +405,7 @@ static void HandleInputChooseTarget(void) { do { - u8 currSelIdentity = GetBattlerPosition(gMultiUsePlayerCursor); + u8 currSelIdentity = gBattlerPositions[gMultiUsePlayerCursor]; for (i = 0; i < MAX_BATTLERS_COUNT; i++) { @@ -420,7 +420,7 @@ static void HandleInputChooseTarget(void) } while (gMultiUsePlayerCursor == gBattlersCount); i = 0; - switch (GetBattlerPosition(gMultiUsePlayerCursor)) + switch (gBattlerPositions[gMultiUsePlayerCursor]) { case B_POSITION_PLAYER_LEFT: case B_POSITION_PLAYER_RIGHT: @@ -455,7 +455,7 @@ static void HandleInputChooseTarget(void) { do { - u8 currSelIdentity = GetBattlerPosition(gMultiUsePlayerCursor); + u8 currSelIdentity = gBattlerPositions[gMultiUsePlayerCursor]; for (i = 0; i < MAX_BATTLERS_COUNT; i++) { @@ -470,7 +470,7 @@ static void HandleInputChooseTarget(void) } while (gMultiUsePlayerCursor == gBattlersCount); i = 0; - switch (GetBattlerPosition(gMultiUsePlayerCursor)) + switch (gBattlerPositions[gMultiUsePlayerCursor]) { case B_POSITION_PLAYER_LEFT: case B_POSITION_PLAYER_RIGHT: @@ -2421,7 +2421,7 @@ static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit) gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1]; species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); - SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); + SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[battlerId]); gBattlerSpriteIds[battlerId] = CreateSprite( &gMultiuseSpriteTemplate, @@ -2516,7 +2516,7 @@ static void PlayerHandleDrawTrainerPic(void) if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != B_FLANK_LEFT) // Second mon, on the right. + if ((gBattlerPositions[gActiveBattler] & BIT_FLANK) != B_FLANK_LEFT) // Second mon, on the right. xPos = 90; else // First mon, on the left. xPos = 32; @@ -2543,7 +2543,7 @@ static void PlayerHandleDrawTrainerPic(void) { trainerPicId = PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender); DecompressTrainerFrontPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerFront(trainerPicId, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToTrainerFront(trainerPicId, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); @@ -2558,7 +2558,7 @@ static void PlayerHandleDrawTrainerPic(void) else { DecompressTrainerBackPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; @@ -2597,7 +2597,7 @@ static void PlayerHandleTrainerSlide(void) } DecompressTrainerBackPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, 80, (8 - gTrainerBackPicCoords[trainerPicId].size) * 4 + 80, 30); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index 3a4beeca93fa..5bda597ac79f 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -1204,7 +1204,7 @@ static void PlayerPartnerHandleLoadMonSprite(void) BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES); - SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(gActiveBattler, BATTLER_COORD_X_2), @@ -1234,7 +1234,7 @@ static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit) gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1]; species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); - SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); + SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[battlerId]); gBattlerSpriteIds[battlerId] = CreateSprite( &gMultiuseSpriteTemplate, @@ -1327,7 +1327,7 @@ static void PlayerPartnerHandleDrawTrainerPic(void) if (gPartnerTrainerId == TRAINER_STEVEN_PARTNER || gPartnerTrainerId >= TRAINER_CUSTOM_PARTNER) { DecompressTrainerBackPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; @@ -1338,7 +1338,7 @@ static void PlayerPartnerHandleDrawTrainerPic(void) else // otherwise use front sprite { DecompressTrainerFrontPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerFront(trainerPicId, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToTrainerFront(trainerPicId, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index 283388fcfdf5..ffb6c9e0313f 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -239,7 +239,7 @@ static void Intro_WaitForShinyAnimAndHealthbox(void) if (healthboxAnimDone) { - if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_LEFT) + if (gBattlerPositions[gActiveBattler] == B_POSITION_OPPONENT_LEFT) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim) return; @@ -298,7 +298,7 @@ static void Intro_TryShinyAnimShowHealthbox(void) { if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) { - if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_LEFT) + if (gBattlerPositions[gActiveBattler] == B_POSITION_OPPONENT_LEFT) m4aMPlayContinue(&gMPlayInfo_BGM); } else @@ -1108,7 +1108,7 @@ static void RecordedOpponentHandleLoadMonSprite(void) u16 species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); - SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(gActiveBattler, BATTLER_COORD_X_2), @@ -1141,7 +1141,7 @@ static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit) species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId); - SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); + SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[battlerId]); gBattlerSpriteIds[battlerId] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(battlerId, BATTLER_COORD_X_2), @@ -1210,7 +1210,7 @@ static void RecordedOpponentHandleDrawTrainerPic(void) if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon + if ((gBattlerPositions[gActiveBattler] & BIT_FLANK) != 0) // second mon xPos = 152; else // first mon xPos = 200; @@ -1241,7 +1241,7 @@ static void RecordedOpponentHandleDrawTrainerPic(void) } DecompressTrainerFrontPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, (8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 40, diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index 86cb49198655..584931150ecf 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -208,7 +208,7 @@ static void Intro_WaitForShinyAnimAndHealthbox(void) { bool32 healthboxAnimDone = FALSE; - if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT) + if (gBattlerPositions[gActiveBattler] == B_POSITION_PLAYER_LEFT) { if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) { @@ -275,7 +275,7 @@ static void Intro_TryShinyAnimShowHealthbox(void) { bool32 bgmRestored = FALSE; - if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT) + if (gBattlerPositions[gActiveBattler] == B_POSITION_PLAYER_LEFT) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) @@ -313,7 +313,7 @@ static void Intro_TryShinyAnimShowHealthbox(void) { if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && (gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT) + if (gBattlerPositions[gActiveBattler] == B_POSITION_PLAYER_LEFT) m4aMPlayContinue(&gMPlayInfo_BGM); } else @@ -1092,7 +1092,7 @@ static void RecordedPlayerHandleLoadMonSprite(void) BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES); - SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(gActiveBattler, BATTLER_COORD_X_2), @@ -1122,7 +1122,7 @@ static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit) gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1]; species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); - SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); + SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[battlerId]); gBattlerSpriteIds[battlerId] = CreateSprite( &gMultiuseSpriteTemplate, @@ -1203,7 +1203,7 @@ static void RecordedPlayerHandleDrawTrainerPic(void) if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon + if ((gBattlerPositions[gActiveBattler] & BIT_FLANK) != 0) // second mon xPos = 90; else // first mon xPos = 32; @@ -1229,7 +1229,7 @@ static void RecordedPlayerHandleDrawTrainerPic(void) { trainerPicId = PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender); DecompressTrainerFrontPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerFront(trainerPicId, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToTrainerFront(trainerPicId, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); @@ -1243,7 +1243,7 @@ static void RecordedPlayerHandleDrawTrainerPic(void) else { DecompressTrainerBackPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c index 1542838dbb07..5c5dbb616e14 100644 --- a/src/battle_controller_safari.c +++ b/src/battle_controller_safari.c @@ -355,7 +355,7 @@ static void SafariHandleReturnMonToBall(void) static void SafariHandleDrawTrainerPic(void) { DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(gSaveBlock2Ptr->playerGender, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToTrainerBack(gSaveBlock2Ptr->playerGender, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite( &gMultiuseSpriteTemplate, 80, diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c index 00a825dba5a5..20f33dfd19c2 100644 --- a/src/battle_controller_wally.c +++ b/src/battle_controller_wally.c @@ -1037,7 +1037,7 @@ static void WallyHandleReturnMonToBall(void) static void WallyHandleDrawTrainerPic(void) { DecompressTrainerBackPic(TRAINER_BACK_PIC_WALLY, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(TRAINER_BACK_PIC_WALLY, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToTrainerBack(TRAINER_BACK_PIC_WALLY, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, 80, 80 + 4 * (8 - gTrainerBackPicCoords[TRAINER_BACK_PIC_WALLY].size), @@ -1052,7 +1052,7 @@ static void WallyHandleDrawTrainerPic(void) static void WallyHandleTrainerSlide(void) { DecompressTrainerBackPic(TRAINER_BACK_PIC_WALLY, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(TRAINER_BACK_PIC_WALLY, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToTrainerBack(TRAINER_BACK_PIC_WALLY, gBattlerPositions[gActiveBattler]); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, 80, 80 + 4 * (8 - gTrainerBackPicCoords[TRAINER_BACK_PIC_WALLY].size), @@ -1461,7 +1461,7 @@ static void StartSendOutAnim(u8 battlerId) gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1]; species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); - SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); + SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[battlerId]); gBattlerSpriteIds[battlerId] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(battlerId, BATTLER_COORD_X_2), GetBattlerSpriteDefault_Y(battlerId), diff --git a/src/battle_controllers.c b/src/battle_controllers.c index d7ca18c6a1a6..aaccfb74006b 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -606,7 +606,7 @@ static void SetBattlePartyIds(void) { if (i < 2) { - if (GET_BATTLER_SIDE2(i) == B_SIDE_PLAYER) + if (GET_BATTLER_SIDE(i) == B_SIDE_PLAYER) { if (IsValidForBattle(&gPlayerParty[j])) { @@ -625,7 +625,7 @@ static void SetBattlePartyIds(void) } else { - if (GET_BATTLER_SIDE2(i) == B_SIDE_PLAYER) + if (GET_BATTLER_SIDE(i) == B_SIDE_PLAYER) { if (IsValidForBattle(&gPlayerParty[j]) && gBattlerPartyIndexes[i - 2] != j) { diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index b7cf2c238999..6a6cbe494d13 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -576,7 +576,7 @@ static void BattleLoadMonSpriteGfx(struct Pokemon *mon, u32 battlerId, bool32 op #endif } - position = GetBattlerPosition(battlerId); + position = gBattlerPositions[battlerId]; if (opponent) { HandleLoadSpecialPokePic(TRUE, @@ -625,7 +625,7 @@ void BattleGfxSfxDummy2(u16 species) void DecompressTrainerFrontPic(u16 frontPicId, u8 battlerId) { - u8 position = GetBattlerPosition(battlerId); + u8 position = gBattlerPositions[battlerId]; DecompressPicFromTable(&gTrainerFrontPicTable[frontPicId], gMonSpritesGfxPtr->sprites.ptr[position], SPECIES_NONE); @@ -634,7 +634,7 @@ void DecompressTrainerFrontPic(u16 frontPicId, u8 battlerId) void DecompressTrainerBackPic(u16 backPicId, u8 battlerId) { - u8 position = GetBattlerPosition(battlerId); + u8 position = gBattlerPositions[battlerId]; DecompressPicFromTable(&gTrainerBackPicTable[backPicId], gMonSpritesGfxPtr->sprites.ptr[position], SPECIES_NONE); @@ -867,7 +867,7 @@ void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool32 megaEvo, bo } else { - position = GetBattlerPosition(battlerAtk); + position = gBattlerPositions[battlerAtk]; if (GetBattlerSide(battlerDef) == B_SIDE_OPPONENT) targetSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerDef]], MON_DATA_SPECIES); @@ -948,7 +948,7 @@ void BattleLoadSubstituteOrMonSpriteGfx(u8 battlerId, bool8 loadMonSprite) if (IsContest()) position = B_POSITION_PLAYER_LEFT; else - position = GetBattlerPosition(battlerId); + position = gBattlerPositions[battlerId]; if (IsContest()) LZDecompressVram(gSubstituteDollBackGfx, gMonSpritesGfxPtr->sprites.ptr[position]); diff --git a/src/battle_interface.c b/src/battle_interface.c index 7ac936b2f7f4..52858b24de50 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -705,11 +705,11 @@ static void InitLastUsedBallAssets(void) // The same goes for a 2 vs 1 where opponent has only one pokemon. u32 WhichBattleCoords(u32 battlerId) // 0 - singles, 1 - doubles { - if (GetBattlerPosition(battlerId) == B_POSITION_PLAYER_LEFT + if (gBattlerPositions[battlerId] == B_POSITION_PLAYER_LEFT && gPlayerPartyCount == 1 && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) return 0; - else if (GetBattlerPosition(battlerId) == B_POSITION_OPPONENT_LEFT + else if (gBattlerPositions[battlerId] == B_POSITION_OPPONENT_LEFT && gEnemyPartyCount == 1 && !(gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)) return 0; @@ -754,8 +754,8 @@ u8 CreateBattlerHealthboxSprites(u8 battlerId) { if (GetBattlerSide(battlerId) == B_SIDE_PLAYER) { - healthboxLeftSpriteId = CreateSprite(&sHealthboxPlayerSpriteTemplates[GetBattlerPosition(battlerId) / 2], DISPLAY_WIDTH, DISPLAY_HEIGHT, 1); - healthboxRightSpriteId = CreateSpriteAtEnd(&sHealthboxPlayerSpriteTemplates[GetBattlerPosition(battlerId) / 2], DISPLAY_WIDTH, DISPLAY_HEIGHT, 1); + healthboxLeftSpriteId = CreateSprite(&sHealthboxPlayerSpriteTemplates[gBattlerPositions[battlerId] / 2], DISPLAY_WIDTH, DISPLAY_HEIGHT, 1); + healthboxRightSpriteId = CreateSpriteAtEnd(&sHealthboxPlayerSpriteTemplates[gBattlerPositions[battlerId] / 2], DISPLAY_WIDTH, DISPLAY_HEIGHT, 1); gSprites[healthboxLeftSpriteId].oam.affineParam = healthboxRightSpriteId; @@ -767,8 +767,8 @@ u8 CreateBattlerHealthboxSprites(u8 battlerId) } else { - healthboxLeftSpriteId = CreateSprite(&sHealthboxOpponentSpriteTemplates[GetBattlerPosition(battlerId) / 2], DISPLAY_WIDTH, DISPLAY_HEIGHT, 1); - healthboxRightSpriteId = CreateSpriteAtEnd(&sHealthboxOpponentSpriteTemplates[GetBattlerPosition(battlerId) / 2], DISPLAY_WIDTH, DISPLAY_HEIGHT, 1); + healthboxLeftSpriteId = CreateSprite(&sHealthboxOpponentSpriteTemplates[gBattlerPositions[battlerId] / 2], DISPLAY_WIDTH, DISPLAY_HEIGHT, 1); + healthboxRightSpriteId = CreateSpriteAtEnd(&sHealthboxOpponentSpriteTemplates[gBattlerPositions[battlerId] / 2], DISPLAY_WIDTH, DISPLAY_HEIGHT, 1); gSprites[healthboxLeftSpriteId].oam.affineParam = healthboxRightSpriteId; @@ -956,7 +956,7 @@ void GetBattlerHealthboxCoords(u8 battler, s16 *x, s16 *y) } else { - switch (GetBattlerPosition(battler)) + switch (gBattlerPositions[battler]) { case B_POSITION_PLAYER_LEFT: *x = 159, *y = 76; @@ -1183,7 +1183,7 @@ static void PrintSafariMonInfo(u8 healthboxSpriteId, struct Pokemon *mon) u8 i, var, nature, healthBarSpriteId; memcpy(text, sEmptyWhiteText_GrayHighlight, sizeof(sEmptyWhiteText_GrayHighlight)); - barFontGfx = &gMonSpritesGfxPtr->barFontGfx[0x520 + (GetBattlerPosition(gSprites[healthboxSpriteId].hMain_Battler) * 384)]; + barFontGfx = &gMonSpritesGfxPtr->barFontGfx[0x520 + (gBattlerPositions[gSprites[healthboxSpriteId].hMain_Battler] * 384)]; var = 5; nature = GetNature(mon); StringCopy(&text[6], gNatureNamePointers[nature]); @@ -1578,7 +1578,7 @@ static void MegaIndicator_CreateSprite(u32 battlerId, u32 healthboxSpriteId) s16 xHealthbox = 0, y = 0; s32 x = 0; - position = GetBattlerPosition(battlerId); + position = gBattlerPositions[battlerId]; GetBattlerHealthboxCoords(battlerId, &xHealthbox, &y); x = sIndicatorPositions[position][0]; @@ -1624,7 +1624,7 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo, u8 ballIconSpritesIds[PARTY_SIZE]; u8 taskId; - if (!skipPlayer || GetBattlerPosition(battlerId) != B_POSITION_OPPONENT_RIGHT) + if (!skipPlayer || gBattlerPositions[battlerId] != B_POSITION_OPPONENT_RIGHT) { if (GetBattlerSide(battlerId) == B_SIDE_PLAYER) { @@ -3078,7 +3078,7 @@ void CreateAbilityPopUp(u8 battlerId, u32 ability, bool32 isDoubleBattle) LoadSpritePalette(&sSpritePalette_AbilityPopUp); } gBattleStruct->activeAbilityPopUps |= gBitTable[battlerId]; - battlerPosition = GetBattlerPosition(battlerId); + battlerPosition = gBattlerPositions[battlerId]; if (isDoubleBattle) coords = sAbilityPopUpCoordsDoubles; diff --git a/src/battle_main.c b/src/battle_main.c index eea745356a01..3678c5cb368d 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -2851,7 +2851,7 @@ static void SpriteCB_AnimFaintOpponent(struct Sprite *sprite) } else // Erase bottom part of the sprite to create a smooth illusion of mon falling down. { - u8 *dst = gMonSpritesGfxPtr->sprites.byte[GetBattlerPosition(sprite->sBattler)] + (sprite->data[3] << 8); + u8 *dst = gMonSpritesGfxPtr->sprites.byte[gBattlerPositions[sprite->sBattler]] + (sprite->data[3] << 8); for (i = 0; i < 0x100; i++) *(dst++) = 0; @@ -3529,7 +3529,7 @@ static void DoBattleIntro(void) } // Draw sprite. - switch (GetBattlerPosition(gActiveBattler)) + switch (gBattlerPositions[gActiveBattler]) { case B_POSITION_PLAYER_LEFT: // player sprite BtlController_EmitDrawTrainerPic(BUFFER_A); @@ -4052,7 +4052,7 @@ u8 IsRunningFromBattleImpossible(void) gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_DONT_LEAVE_BIRCH; return BATTLE_RUN_FORBIDDEN; } - if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_RIGHT && WILD_DOUBLE_BATTLE + if (gBattlerPositions[gActiveBattler] == B_POSITION_PLAYER_RIGHT && WILD_DOUBLE_BATTLE && IsBattlerAlive(GetBattlerAtPosition(B_POSITION_PLAYER_LEFT))) // The second pokemon cannot run from a double wild battle, unless it's the only alive mon. { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_CANT_ESCAPE; @@ -4136,7 +4136,7 @@ static void HandleTurnActionSelectionState(void) gBattleCommunication[ACTIONS_CONFIRMED_COUNT] = 0; for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - u8 position = GetBattlerPosition(gActiveBattler); + u8 position = gBattlerPositions[gActiveBattler]; switch (gBattleCommunication[gActiveBattler]) { case STATE_TURN_START_RECORD: // Recorded battle related action on start of every turn. @@ -4312,42 +4312,42 @@ static void HandleTurnActionSelectionState(void) break; case B_ACTION_CANCEL_PARTNER: gBattleCommunication[gActiveBattler] = STATE_WAIT_SET_BEFORE_ACTION; - gBattleCommunication[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))] = STATE_BEFORE_ACTION_CHOSEN; + gBattleCommunication[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))] = STATE_BEFORE_ACTION_CHOSEN; RecordedBattle_ClearBattlerAction(gActiveBattler, 1); - if (gBattleMons[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))].status2 & STATUS2_MULTIPLETURNS - || gBattleMons[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))].status2 & STATUS2_RECHARGE) + if (gBattleMons[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))].status2 & STATUS2_MULTIPLETURNS + || gBattleMons[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))].status2 & STATUS2_RECHARGE) { BtlController_EmitEndBounceEffect(BUFFER_A); MarkBattlerForControllerExec(gActiveBattler); return; } - else if (gChosenActionByBattler[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))] == B_ACTION_SWITCH) + else if (gChosenActionByBattler[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))] == B_ACTION_SWITCH) { - RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))), 2); + RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler])), 2); } - else if (gChosenActionByBattler[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))] == B_ACTION_RUN) + else if (gChosenActionByBattler[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))] == B_ACTION_RUN) { - RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))), 1); + RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler])), 1); } - else if (gChosenActionByBattler[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))] == B_ACTION_USE_MOVE - && (gProtectStructs[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))].noValidMoves - || gDisableStructs[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))].encoredMove)) + else if (gChosenActionByBattler[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))] == B_ACTION_USE_MOVE + && (gProtectStructs[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))].noValidMoves + || gDisableStructs[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))].encoredMove)) { - RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))), 1); + RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler])), 1); } else if (gBattleTypeFlags & BATTLE_TYPE_PALACE - && gChosenActionByBattler[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))] == B_ACTION_USE_MOVE) + && gChosenActionByBattler[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))] == B_ACTION_USE_MOVE) { gRngValue = gBattlePalaceMoveSelectionRngValue; - RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))), 1); + RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler])), 1); } else { - RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))), 3); + RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler])), 3); } - gBattleStruct->mega.toEvolve &= ~(gBitTable[BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))]); - gBattleStruct->zmove.toBeUsed[BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))] = MOVE_NONE; + gBattleStruct->mega.toEvolve &= ~(gBitTable[BATTLE_PARTNER(gBattlerPositions[gActiveBattler])]); + gBattleStruct->zmove.toBeUsed[BATTLE_PARTNER(gBattlerPositions[gActiveBattler])] = MOVE_NONE; BtlController_EmitEndBounceEffect(BUFFER_A); MarkBattlerForControllerExec(gActiveBattler); return; diff --git a/src/battle_message.c b/src/battle_message.c index 172f5a11f881..28eadccf68ff 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -3053,7 +3053,7 @@ static const u8 *BattleStringGetOpponentName(u8 *text, u8 multiplayerId, u8 batt { const u8 *toCpy; - switch (GetBattlerPosition(battlerId)) + switch (gBattlerPositions[battlerId]) { case B_POSITION_OPPONENT_LEFT: toCpy = BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_A, text, multiplayerId, battlerId); @@ -3073,7 +3073,7 @@ static const u8 *BattleStringGetPlayerName(u8 *text, u8 battlerId) { const u8 *toCpy; - switch (GetBattlerPosition(battlerId)) + switch (gBattlerPositions[battlerId]) { case B_POSITION_PLAYER_LEFT: if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) @@ -3499,7 +3499,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst) toCpy = BattleStringGetTrainerName(text, multiplayerId, gBattlerAttacker); break; case B_TXT_ATK_TRAINER_CLASS: - switch (GetBattlerPosition(gBattlerAttacker)) + switch (gBattlerPositions[gBattlerAttacker]) { case B_POSITION_PLAYER_RIGHT: if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 63bc9cd350f2..155186c90f9f 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1934,7 +1934,7 @@ static void Cmd_critcalc(void) // Counter for EVO_CRITICAL_HITS. partySlot = gBattlerPartyIndexes[gBattlerAttacker]; if (gIsCriticalHit && GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER - && !(gBattleTypeFlags & BATTLE_TYPE_MULTI && GetBattlerPosition(gBattlerAttacker) == B_POSITION_PLAYER_LEFT)) + && !(gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattlerPositions[gBattlerAttacker] == B_POSITION_PLAYER_LEFT)) gPartyCriticalHits[partySlot]++; gBattlescriptCurrInstr = cmd->nextInstr; @@ -6714,7 +6714,7 @@ static void Cmd_openpartyscreen(void) gBattlescriptCurrInstr = cmd->nextInstr; - if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT && gBattleResults.playerSwitchesCounter < 255) + if (gBattlerPositions[gActiveBattler] == B_POSITION_PLAYER_LEFT && gBattleResults.playerSwitchesCounter < 255) gBattleResults.playerSwitchesCounter++; if (gBattleTypeFlags & BATTLE_TYPE_MULTI) @@ -6730,7 +6730,7 @@ static void Cmd_openpartyscreen(void) } else { - gActiveBattler = GetBattlerAtPosition(BATTLE_OPPOSITE(GetBattlerPosition(battlerId))); + gActiveBattler = GetBattlerAtPosition(BATTLE_OPPOSITE(gBattlerPositions[battlerId])); if (gAbsentBattlerFlags & gBitTable[gActiveBattler]) gActiveBattler ^= BIT_FLANK; @@ -8560,7 +8560,7 @@ static void HandleScriptMegaPrimal(u32 caseId, u32 battlerId, bool32 isMega) { struct Pokemon *party = GetBattlerParty(battlerId); struct Pokemon *mon = &party[gBattlerPartyIndexes[battlerId]]; - u32 position = GetBattlerPosition(battlerId); + u32 position = gBattlerPositions[battlerId]; u32 side = GET_BATTLER_SIDE(battlerId); // Change species. @@ -8783,7 +8783,7 @@ static void Cmd_various(void) while (gBattleStruct->friskedBattler < gBattlersCount) { gBattlerTarget = gBattleStruct->friskedBattler++; - if (GET_BATTLER_SIDE2(gActiveBattler) != GET_BATTLER_SIDE2(gBattlerTarget) + if (GET_BATTLER_SIDE(gActiveBattler) != GET_BATTLER_SIDE(gBattlerTarget) && IsBattlerAlive(gBattlerTarget) && gBattleMons[gBattlerTarget].item != ITEM_NONE) { @@ -10435,11 +10435,11 @@ static void Cmd_various(void) if (gBattleMons[gBattlerAttacker].species == SPECIES_GRENINJA_BATTLE_BOND && HasAttackerFaintedTarget() && CalculateEnemyPartyCount() > 1 - && !(gBattleStruct->battleBondTransformed[GET_BATTLER_SIDE2(gBattlerAttacker)] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]])) + && !(gBattleStruct->battleBondTransformed[GET_BATTLER_SIDE(gBattlerAttacker)] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]])) { - gBattleStruct->battleBondTransformed[GET_BATTLER_SIDE2(gBattlerAttacker)] |= gBitTable[gBattlerPartyIndexes[gBattlerAttacker]]; + gBattleStruct->battleBondTransformed[GET_BATTLER_SIDE(gBattlerAttacker)] |= gBitTable[gBattlerPartyIndexes[gBattlerAttacker]]; PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBattlerAttacker].species); - gBattleStruct->changedSpecies[GET_BATTLER_SIDE2(gBattlerAttacker)][gBattlerPartyIndexes[gBattlerAttacker]] = gBattleMons[gBattlerAttacker].species; + gBattleStruct->changedSpecies[GET_BATTLER_SIDE(gBattlerAttacker)][gBattlerPartyIndexes[gBattlerAttacker]] = gBattleMons[gBattlerAttacker].species; gBattleMons[gBattlerAttacker].species = SPECIES_GRENINJA_ASH; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_BattleBondActivatesOnMoveEndAttacker; @@ -12564,7 +12564,7 @@ static void Cmd_updatestatusicon(void) } if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) { - gActiveBattler = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerAttacker))); + gActiveBattler = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gBattlerAttacker])); if (!(gAbsentBattlerFlags & gBitTable[gActiveBattler])) { BtlController_EmitStatusIconUpdate(BUFFER_A, gBattleMons[gActiveBattler].status1, gBattleMons[gActiveBattler].status2); @@ -13265,7 +13265,7 @@ static void Cmd_healpartystatus(void) gBattleCommunication[MULTISTRING_CHOOSER] |= B_MSG_BELL_SOUNDPROOF_ATTACKER; } - gActiveBattler = gBattleScripting.battler = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerAttacker))); + gActiveBattler = gBattleScripting.battler = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gBattlerAttacker])); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && !(gAbsentBattlerFlags & gBitTable[gActiveBattler])) @@ -13315,7 +13315,7 @@ static void Cmd_healpartystatus(void) gBattleMons[gBattlerAttacker].status1 = 0; gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_NIGHTMARE; - gActiveBattler = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerAttacker))); + gActiveBattler = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gBattlerAttacker])); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && !(gAbsentBattlerFlags & gBitTable[gActiveBattler])) { @@ -14143,7 +14143,7 @@ static void Cmd_trysethelpinghand(void) { CMD_ARGS(const u8 *failInstr); - gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerAttacker))); + gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gBattlerAttacker])); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && !(gAbsentBattlerFlags & gBitTable[gBattlerTarget]) @@ -15059,7 +15059,7 @@ static void Cmd_pursuitdoubles(void) { CMD_ARGS(const u8 *failInstr); - gActiveBattler = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerAttacker))); + gActiveBattler = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gBattlerAttacker])); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && !(gAbsentBattlerFlags & gBitTable[gActiveBattler]) @@ -16184,8 +16184,8 @@ u8 GetFirstFaintedPartyIndex(u8 battlerId) if ((GetBattlerSide(battlerId) == B_SIDE_PLAYER && gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) || (GetBattlerSide(battlerId) == B_SIDE_OPPONENT && gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)) { - if (GetBattlerPosition(battlerId) == B_POSITION_OPPONENT_LEFT - || GetBattlerPosition(battlerId) == B_POSITION_PLAYER_LEFT) + if (gBattlerPositions[battlerId] == B_POSITION_OPPONENT_LEFT + || gBattlerPositions[battlerId] == B_POSITION_PLAYER_LEFT) { end = PARTY_SIZE / 2; } diff --git a/src/battle_tv.c b/src/battle_tv.c index d28239351615..03f279de85c7 100644 --- a/src/battle_tv.c +++ b/src/battle_tv.c @@ -763,9 +763,9 @@ void BattleTv_SetDataBasedOnString(u16 stringId) statStringId = (u16 *)(gBattleTextBuff2 + 2); finishedMoveId = (u16 *)(gBattleTextBuff1 + 2); - atkFlank = GetBattlerPosition(gBattlerAttacker) / 2; - defFlank = GetBattlerPosition(gBattlerTarget) / 2; - effFlank = GetBattlerPosition(gEffectBattler) / 2; + atkFlank = gBattlerPositions[gBattlerAttacker] / 2; + defFlank = gBattlerPositions[gBattlerTarget] / 2; + effFlank = gBattlerPositions[gEffectBattler] / 2; switch (stringId) { @@ -1172,8 +1172,8 @@ void BattleTv_SetDataBasedOnMove(u16 move, u16 weatherFlags, struct DisableStruc return; } - tvPtr->pos[defSide][GetBattlerPosition(gBattlerAttacker) / 2].attackedByMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - tvPtr->pos[defSide][GetBattlerPosition(gBattlerAttacker) / 2].attackedByMoveSlot = moveSlot; + tvPtr->pos[defSide][gBattlerPositions[gBattlerAttacker] / 2].attackedByMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->pos[defSide][gBattlerPositions[gBattlerAttacker] / 2].attackedByMoveSlot = moveSlot; tvPtr->side[atkSide].usedMoveSlot = moveSlot; AddMovePoints(PTS_MOVE_EFFECT, moveSlot, gBattleMoves[move].effect, 0); AddPointsBasedOnWeather(weatherFlags, move, moveSlot); diff --git a/src/battle_util.c b/src/battle_util.c index 2ec783a87a1d..f2f64e3efb47 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -404,13 +404,13 @@ void HandleAction_UseMove(void) { if (GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget)) { - gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerTarget))); + gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gBattlerTarget])); } else { - gBattlerTarget = GetBattlerAtPosition(BATTLE_OPPOSITE(GetBattlerPosition(gBattlerAttacker))); + gBattlerTarget = GetBattlerAtPosition(BATTLE_OPPOSITE(gBattlerPositions[gBattlerAttacker])); if (!IsBattlerAlive(gBattlerTarget)) - gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerTarget))); + gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gBattlerTarget])); } } } @@ -449,7 +449,7 @@ void HandleAction_UseMove(void) if (gAbsentBattlerFlags & gBitTable[gBattlerTarget] && GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget)) { - gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerTarget))); + gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gBattlerTarget])); } } else if (moveTarget == MOVE_TARGET_ALLY) @@ -477,13 +477,13 @@ void HandleAction_UseMove(void) { if (GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget)) { - gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerTarget))); + gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gBattlerTarget])); } else { - gBattlerTarget = GetBattlerAtPosition(BATTLE_OPPOSITE(GetBattlerPosition(gBattlerAttacker))); + gBattlerTarget = GetBattlerAtPosition(BATTLE_OPPOSITE(gBattlerPositions[gBattlerAttacker])); if (!IsBattlerAlive(gBattlerTarget)) - gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerTarget))); + gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gBattlerTarget])); } } } @@ -5873,7 +5873,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 = (BATTLE_OPPOSITE(GetBattlerPosition(i))) & BIT_SIDE; // side of the opposing pokemon + u8 side = (BATTLE_OPPOSITE(gBattlerPositions[i])) & BIT_SIDE; // side of the opposing pokemon u8 target1 = GetBattlerAtPosition(side); u8 target2 = GetBattlerAtPosition(side + BIT_FLANK); @@ -7952,7 +7952,7 @@ u8 IsMonDisobedient(void) if (IsBattlerModernFatefulEncounter(gBattlerAttacker)) // only false if illegal Mew or Deoxys { - if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gBattlerAttacker) == 2) + if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && gBattlerPositions[gBattlerAttacker] == 2) return 0; if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) return 0; @@ -9971,12 +9971,12 @@ bool32 CanMegaEvolve(u8 battlerId) { u32 itemId, holdEffect, species; struct Pokemon *mon; - u8 battlerPosition = GetBattlerPosition(battlerId); - u8 partnerPosition = GetBattlerPosition(BATTLE_PARTNER(battlerId)); + u8 battlerPosition = gBattlerPositions[battlerId]; + u8 partnerPosition = gBattlerPositions[BATTLE_PARTNER(battlerId)]; struct MegaEvolutionData *mega = &(((struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]))->mega); // Check if Player has a Mega Ring - if ((GetBattlerPosition(battlerId) == B_POSITION_PLAYER_LEFT || (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) && GetBattlerPosition(battlerId) == B_POSITION_PLAYER_RIGHT)) + if ((gBattlerPositions[battlerId] == B_POSITION_PLAYER_LEFT || (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) && gBattlerPositions[battlerId] == B_POSITION_PLAYER_RIGHT)) && !CheckBagHasItem(ITEM_MEGA_RING, 1)) return FALSE; diff --git a/src/battle_z_move.c b/src/battle_z_move.c index 55cc157bee6b..c849346046f6 100644 --- a/src/battle_z_move.c +++ b/src/battle_z_move.c @@ -160,8 +160,8 @@ bool32 IsViableZMove(u8 battlerId, u16 move) { struct Pokemon *mon; struct MegaEvolutionData *mega = &(((struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]))->mega); - u8 battlerPosition = GetBattlerPosition(battlerId); - u8 partnerPosition = GetBattlerPosition(BATTLE_PARTNER(battlerId)); + u8 battlerPosition = gBattlerPositions[battlerId]; + u8 partnerPosition = gBattlerPositions[BATTLE_PARTNER(battlerId)]; u32 item; u16 holdEffect; u16 species; @@ -182,7 +182,7 @@ bool32 IsViableZMove(u8 battlerId, u16 move) if (gBattleTypeFlags & (BATTLE_TYPE_SAFARI | BATTLE_TYPE_WALLY_TUTORIAL | BATTLE_TYPE_FRONTIER)) return FALSE; - if ((GetBattlerPosition(battlerId) == B_POSITION_PLAYER_LEFT || (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) && GetBattlerPosition(battlerId) == B_POSITION_PLAYER_RIGHT)) && !CheckBagHasItem(ITEM_Z_POWER_RING, 1)) + if ((gBattlerPositions[battlerId] == B_POSITION_PLAYER_LEFT || (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) && gBattlerPositions[battlerId] == B_POSITION_PLAYER_RIGHT)) && !CheckBagHasItem(ITEM_Z_POWER_RING, 1)) return FALSE; if (mega->alreadyEvolved[battlerPosition]) diff --git a/src/pokeball.c b/src/pokeball.c index 2e556ec22523..7f5534702c1d 100644 --- a/src/pokeball.c +++ b/src/pokeball.c @@ -1445,7 +1445,7 @@ void StartHealthboxSlideIn(u8 battlerId) healthboxSprite->y2 = -healthboxSprite->y2; } gSprites[healthboxSprite->data[5]].callback(&gSprites[healthboxSprite->data[5]]); - if (GetBattlerPosition(battlerId) == B_POSITION_PLAYER_RIGHT) + if (gBattlerPositions[battlerId] == B_POSITION_PLAYER_RIGHT) healthboxSprite->callback = SpriteCB_HealthboxSlideInDelayed; } diff --git a/src/reshow_battle_screen.c b/src/reshow_battle_screen.c index 9ea0b1180502..40ca8b65bd2d 100644 --- a/src/reshow_battle_screen.c +++ b/src/reshow_battle_screen.c @@ -223,7 +223,7 @@ static void CreateBattlerSprite(u8 battler) if (gBattleScripting.monCaught) // Don't create opponent sprite if it has been caught. return; - SetMultiuseSpriteTemplateToPokemon(GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES), GetBattlerPosition(battler)); + SetMultiuseSpriteTemplateToPokemon(GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES), gBattlerPositions[battler]); gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(battler, BATTLER_COORD_X_2), posY, GetBattlerSpriteSubpriority(battler)); gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler; gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy; @@ -234,7 +234,7 @@ static void CreateBattlerSprite(u8 battler) } else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && battler == B_POSITION_PLAYER_LEFT) { - SetMultiuseSpriteTemplateToTrainerBack(gSaveBlock2Ptr->playerGender, GetBattlerPosition(B_POSITION_PLAYER_LEFT)); + SetMultiuseSpriteTemplateToTrainerBack(gSaveBlock2Ptr->playerGender, gBattlerPositions[B_POSITION_PLAYER_LEFT]); gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate, 0x50, (8 - gTrainerBackPicCoords[gSaveBlock2Ptr->playerGender].size) * 4 + 80, GetBattlerSpriteSubpriority(0)); @@ -244,7 +244,7 @@ static void CreateBattlerSprite(u8 battler) } else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && battler == B_POSITION_PLAYER_LEFT) { - SetMultiuseSpriteTemplateToTrainerBack(TRAINER_BACK_PIC_WALLY, GetBattlerPosition(0)); + SetMultiuseSpriteTemplateToTrainerBack(TRAINER_BACK_PIC_WALLY, gBattlerPositions[0]); gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate, 0x50, (8 - gTrainerBackPicCoords[TRAINER_BACK_PIC_WALLY].size) * 4 + 80, GetBattlerSpriteSubpriority(0)); @@ -257,7 +257,7 @@ static void CreateBattlerSprite(u8 battler) if (!IsValidForBattle(&gPlayerParty[gBattlerPartyIndexes[battler]])) return; - SetMultiuseSpriteTemplateToPokemon(GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES), GetBattlerPosition(battler)); + SetMultiuseSpriteTemplateToPokemon(GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES), gBattlerPositions[battler]); gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(battler, BATTLER_COORD_X_2), posY, GetBattlerSpriteSubpriority(battler)); gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler; gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy; @@ -295,7 +295,7 @@ static void CreateHealthboxSprite(u8 battler) else UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL); - if (GetBattlerPosition(battler) == B_POSITION_OPPONENT_RIGHT || GetBattlerPosition(battler) == B_POSITION_PLAYER_RIGHT) + if (gBattlerPositions[battler] == B_POSITION_OPPONENT_RIGHT || gBattlerPositions[battler] == B_POSITION_PLAYER_RIGHT) DummyBattleInterfaceFunc(gHealthboxSpriteIds[battler], TRUE); else DummyBattleInterfaceFunc(gHealthboxSpriteIds[battler], FALSE); From 38deba8ecd6ae0313e4eff740f91dddbbd329338 Mon Sep 17 00:00:00 2001 From: gruxor Date: Thu, 3 Aug 2023 14:42:12 -0400 Subject: [PATCH 2/7] Removed existing macro --- include/battle.h | 2 - src/battle_ai_main.c | 4 +- src/battle_anim.c | 2 +- src/battle_anim_effects_2.c | 2 +- src/battle_anim_fight.c | 2 +- src/battle_anim_ice.c | 8 ++-- src/battle_anim_mons.c | 2 +- src/battle_controller_player.c | 2 +- src/battle_controllers.c | 4 +- src/battle_debug.c | 16 +++---- src/battle_gfx_sfx_util.c | 2 +- src/battle_main.c | 2 +- src/battle_message.c | 2 +- src/battle_script_commands.c | 80 +++++++++++++++++----------------- src/battle_util.c | 12 ++--- src/pokemon.c | 2 +- 16 files changed, 71 insertions(+), 73 deletions(-) diff --git a/include/battle.h b/include/battle.h index 7fb52a9499a1..25c0e8de2160 100644 --- a/include/battle.h +++ b/include/battle.h @@ -15,8 +15,6 @@ #include "pokeball.h" #include "battle_debug.h" -#define GET_BATTLER_SIDE(battler) (gBattlerPositions[battler] & BIT_SIDE) - // Used to exclude moves learned temporarily by Transform or Mimic #define MOVE_IS_PERMANENT(battler, moveSlot) \ (!(gBattleMons[battler].status2 & STATUS2_TRANSFORMED) \ diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 62f780c7f482..da19a186e914 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -332,7 +332,7 @@ void Ai_UpdateSwitchInData(u32 battler) void Ai_UpdateFaintData(u32 battler) { - struct AiPartyMon *aiMon = &AI_PARTY->mons[GET_BATTLER_SIDE(battler)][gBattlerPartyIndexes[battler]]; + struct AiPartyMon *aiMon = &AI_PARTY->mons[GetBattlerSide(battler)][gBattlerPartyIndexes[battler]]; ClearBattlerMoveHistory(battler); ClearBattlerAbilityHistory(battler); ClearBattlerItemEffectHistory(battler); @@ -2563,7 +2563,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) score -= 10; break; case EFFECT_LUCKY_CHANT: - if (gSideTimers[GET_BATTLER_SIDE(battlerAtk)].luckyChantTimer != 0 + if (gSideTimers[GetBattlerSide(battlerAtk)].luckyChantTimer != 0 || PartnerMoveIsSameNoTarget(BATTLE_PARTNER(battlerAtk), move, AI_DATA->partnerMove)) score -= 10; break; diff --git a/src/battle_anim.c b/src/battle_anim.c index 9cbfb22d7b90..5ee2a1521d49 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -216,7 +216,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 (GET_BATTLER_SIDE(gBattleAnimAttacker) == GET_BATTLER_SIDE(gBattleAnimTarget)) + while (GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget)) { if (++gBattleAnimTarget >= MAX_BATTLERS_COUNT) gBattleAnimTarget = 0; diff --git a/src/battle_anim_effects_2.c b/src/battle_anim_effects_2.c index bb2ee4def120..3709302b19e9 100755 --- a/src/battle_anim_effects_2.c +++ b/src/battle_anim_effects_2.c @@ -1704,7 +1704,7 @@ void AnimTask_AirCutterProjectile(u8 taskId) } else { - if (GET_BATTLER_SIDE(gBattleAnimTarget) == B_SIDE_PLAYER) + if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER) { gTasks[taskId].data[4] = 1; gBattleAnimArgs[0] = -gBattleAnimArgs[0]; diff --git a/src/battle_anim_fight.c b/src/battle_anim_fight.c index ee6cc3258c8d..bc7dee754a0e 100644 --- a/src/battle_anim_fight.c +++ b/src/battle_anim_fight.c @@ -564,7 +564,7 @@ static void AnimFistOrFootRandomPos(struct Sprite *sprite) if (Random2() & 1) y *= -1; - if (GET_BATTLER_SIDE(battler) == B_SIDE_PLAYER) + if (GetBattlerSide(battler) == B_SIDE_PLAYER) y += 0xFFF0; sprite->x += x; diff --git a/src/battle_anim_ice.c b/src/battle_anim_ice.c index 12b2dc0984f8..da90e428fdf8 100644 --- a/src/battle_anim_ice.c +++ b/src/battle_anim_ice.c @@ -1276,12 +1276,12 @@ static void InitPoisonGasCloudAnim(struct Sprite *sprite) if (GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2) < GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2)) sprite->data[7] = 0x8000; - if (GET_BATTLER_SIDE(gBattleAnimTarget) == B_SIDE_PLAYER) + if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER) { gBattleAnimArgs[1] = -gBattleAnimArgs[1]; gBattleAnimArgs[3] = -gBattleAnimArgs[3]; - if ((sprite->data[7] & 0x8000) && GET_BATTLER_SIDE(gBattleAnimAttacker) == B_SIDE_PLAYER) + if ((sprite->data[7] & 0x8000) && GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER) sprite->subpriority = gSprites[GetAnimBattlerSpriteId(ANIM_TARGET)].subpriority + 1; sprite->data[6] = 1; @@ -1362,7 +1362,7 @@ static void MovePoisonGasCloud(struct Sprite *sprite) sprite->data[7]++; if (IsContest()) sprite->data[5] = 80; - else if (GET_BATTLER_SIDE(gBattleAnimTarget) != B_SIDE_PLAYER) + else if (GetBattlerSide(gBattleAnimTarget) != B_SIDE_PLAYER) sprite->data[5] = 204; else sprite->data[5] = 80; @@ -1408,7 +1408,7 @@ static void MovePoisonGasCloud(struct Sprite *sprite) sprite->data[4] = sprite->y + 4; if (IsContest()) sprite->data[2] = -0x10; - else if (GET_BATTLER_SIDE(gBattleAnimTarget) != B_SIDE_PLAYER) + else if (GetBattlerSide(gBattleAnimTarget) != B_SIDE_PLAYER) sprite->data[2] = 0x100; else sprite->data[2] = -0x10; diff --git a/src/battle_anim_mons.c b/src/battle_anim_mons.c index 6a09888bd983..d390566a3643 100644 --- a/src/battle_anim_mons.c +++ b/src/battle_anim_mons.c @@ -847,7 +847,7 @@ bool32 InitSpritePosToAnimBattler(u32 animBattlerId, struct Sprite *sprite, bool u8 GetBattlerSide(u8 battlerId) { - return GET_BATTLER_SIDE(battlerId); + return GetBattlerSide(battlerId); } u8 GetBattlerAtPosition(u8 position) diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index c9f0c0f83be7..8dfa62b3ade7 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -626,7 +626,7 @@ static void HandleInputChooseMove(void) if (moveTarget & MOVE_TARGET_USER) gMultiUsePlayerCursor = gActiveBattler; else - gMultiUsePlayerCursor = GetBattlerAtPosition(BATTLE_OPPOSITE(GET_BATTLER_SIDE(gActiveBattler))); + gMultiUsePlayerCursor = GetBattlerAtPosition(BATTLE_OPPOSITE(GetBattlerSide(gActiveBattler))); if (!gBattleResources->bufferA[gActiveBattler][1]) // not a double battle { diff --git a/src/battle_controllers.c b/src/battle_controllers.c index aaccfb74006b..6196b84464a7 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -606,7 +606,7 @@ static void SetBattlePartyIds(void) { if (i < 2) { - if (GET_BATTLER_SIDE(i) == B_SIDE_PLAYER) + if (GetBattlerSide(i) == B_SIDE_PLAYER) { if (IsValidForBattle(&gPlayerParty[j])) { @@ -625,7 +625,7 @@ static void SetBattlePartyIds(void) } else { - if (GET_BATTLER_SIDE(i) == B_SIDE_PLAYER) + if (GetBattlerSide(i) == B_SIDE_PLAYER) { if (IsValidForBattle(&gPlayerParty[j]) && gBattlerPartyIndexes[i - 2] != j) { diff --git a/src/battle_debug.c b/src/battle_debug.c index 3e704b5863a3..92c108238332 100644 --- a/src/battle_debug.c +++ b/src/battle_debug.c @@ -855,7 +855,7 @@ static void PutAiInfoText(struct BattleDebugMenu *data) // items info for (i = 0; i < gBattlersCount; i++) { - if (GET_BATTLER_SIDE(i) == B_SIDE_PLAYER && IsBattlerAlive(i)) + if (GetBattlerSide(i) == B_SIDE_PLAYER && IsBattlerAlive(i)) { u16 ability = AI_GetAbility(i); u16 holdEffect = AI_GetHoldEffect(i); @@ -875,10 +875,10 @@ static void PutAiPartyText(struct BattleDebugMenu *data) { u32 i, j, count; u8 *text = Alloc(0x50), *txtPtr; - struct AiPartyMon *aiMons = AI_PARTY->mons[GET_BATTLER_SIDE(data->aiBattlerId)]; + struct AiPartyMon *aiMons = AI_PARTY->mons[GetBattlerSide(data->aiBattlerId)]; FillWindowPixelBuffer(data->aiMovesWindowId, 0x11); - count = AI_PARTY->count[GET_BATTLER_SIDE(data->aiBattlerId)]; + count = AI_PARTY->count[GetBattlerSide(data->aiBattlerId)]; for (i = 0; i < count; i++) { if (aiMons[i].wasSentInBattle) @@ -941,7 +941,7 @@ static void Task_ShowAiKnowledge(u8 taskId) LoadMonIconPalettes(); for (count = 0, i = 0; i < MAX_BATTLERS_COUNT; i++) { - if (GET_BATTLER_SIDE(i) == B_SIDE_PLAYER && IsBattlerAlive(i)) + if (GetBattlerSide(i) == B_SIDE_PLAYER && IsBattlerAlive(i)) { data->spriteIds.aiIconSpriteIds[i] = CreateMonIcon(gBattleMons[i].species, SpriteCallbackDummy, @@ -1000,8 +1000,8 @@ static void Task_ShowAiParty(u8 taskId) LoadMonIconPalettes(); LoadPartyMenuAilmentGfx(); data->aiBattlerId = data->battlerId; - aiMons = AI_PARTY->mons[GET_BATTLER_SIDE(data->aiBattlerId)]; - for (i = 0; i < AI_PARTY->count[GET_BATTLER_SIDE(data->aiBattlerId)]; i++) + aiMons = AI_PARTY->mons[GetBattlerSide(data->aiBattlerId)]; + for (i = 0; i < AI_PARTY->count[GetBattlerSide(data->aiBattlerId)]; i++) { u16 species = SPECIES_NONE; // Question mark if (aiMons[i].wasSentInBattle && aiMons[i].species) @@ -1626,7 +1626,7 @@ static void ValueToCharDigits(u8 *charDigits, u32 newValue, u8 maxDigits) static u8 *GetSideStatusValue(struct BattleDebugMenu *data, bool32 changeStatus, bool32 statusTrue) { - struct SideTimer *sideTimer = &gSideTimers[GET_BATTLER_SIDE(data->battlerId)]; + struct SideTimer *sideTimer = &gSideTimers[GetBattlerSide(data->battlerId)]; switch (data->currentSecondaryListItemId) { @@ -1909,7 +1909,7 @@ static void SetUpModifyArrows(struct BattleDebugMenu *data) data->modifyArrows.maxValue = 9; data->modifyArrows.maxDigits = 2; - data->modifyArrows.modifiedValPtr = &gSideStatuses[GET_BATTLER_SIDE(data->battlerId)]; + data->modifyArrows.modifiedValPtr = &gSideStatuses[GetBattlerSide(data->battlerId)]; data->modifyArrows.typeOfVal = VAR_SIDE_STATUS; data->modifyArrows.currValue = *GetSideStatusValue(data, FALSE, FALSE); break; diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index 6a6cbe494d13..7cdcfa029be0 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -254,7 +254,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void) else if (moveTarget == MOVE_TARGET_SELECTED) chosenMoveId |= GetBattlePalaceTarget(); else - chosenMoveId |= (GetBattlerAtPosition(BATTLE_OPPOSITE(GET_BATTLER_SIDE(gActiveBattler))) << 8); + chosenMoveId |= (GetBattlerAtPosition(BATTLE_OPPOSITE(GetBattlerSide(gActiveBattler))) << 8); return chosenMoveId; } diff --git a/src/battle_main.c b/src/battle_main.c index 3678c5cb368d..7250b0b638e1 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4710,7 +4710,7 @@ u32 GetBattlerTotalSpeedStat(u8 battlerId) speed *= 2; // various effects - if (gSideStatuses[GET_BATTLER_SIDE(battlerId)] & SIDE_STATUS_TAILWIND) + if (gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_TAILWIND) speed *= 2; if (gBattleResources->flags->flags[battlerId] & RESOURCE_FLAG_UNBURDEN) speed *= 2; diff --git a/src/battle_message.c b/src/battle_message.c index 28eadccf68ff..6b74dad5f8b5 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -2968,7 +2968,7 @@ static void GetBattlerNick(u32 battlerId, u8 *dst) { struct Pokemon *mon, *illusionMon; - if (GET_BATTLER_SIDE(battlerId) == B_SIDE_PLAYER) + if (GetBattlerSide(battlerId) == B_SIDE_PLAYER) mon = &gPlayerParty[gBattlerPartyIndexes[battlerId]]; else mon = &gEnemyParty[gBattlerPartyIndexes[battlerId]]; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 155186c90f9f..8a0538b8d1a4 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -2778,7 +2778,7 @@ void SetMoveEffect(bool32 primary, u32 certain) INCREMENT_RESET_RETURN } - if (gSideStatuses[GET_BATTLER_SIDE(gEffectBattler)] & SIDE_STATUS_SAFEGUARD && !(gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + if (gSideStatuses[GetBattlerSide(gEffectBattler)] & SIDE_STATUS_SAFEGUARD && !(gHitMarker & HITMARKER_IGNORE_SAFEGUARD) && !primary && gBattleScripting.moveEffect <= MOVE_EFFECT_CONFUSION) INCREMENT_RESET_RETURN @@ -3119,7 +3119,7 @@ void SetMoveEffect(bool32 primary, u32 certain) break; case MOVE_EFFECT_PAYDAY: // Don't scatter coins on the second hit of Parental Bond - if (GET_BATTLER_SIDE(gBattlerAttacker) == B_SIDE_PLAYER && gSpecialStatuses[gBattlerAttacker].parentalBondState!= PARENTAL_BOND_2ND_HIT) + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER && gSpecialStatuses[gBattlerAttacker].parentalBondState!= PARENTAL_BOND_2ND_HIT) { u16 payday = gPaydayMoney; gPaydayMoney += (gBattleMons[gBattlerAttacker].level * 5); @@ -3135,7 +3135,7 @@ void SetMoveEffect(bool32 primary, u32 certain) } break; case MOVE_EFFECT_HAPPY_HOUR: - if (GET_BATTLER_SIDE(gBattlerAttacker) == B_SIDE_PLAYER && !gBattleStruct->moneyMultiplierMove) + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER && !gBattleStruct->moneyMultiplierMove) { gBattleStruct->moneyMultiplier *= 2; gBattleStruct->moneyMultiplierMove = 1; @@ -3930,9 +3930,9 @@ static void Cmd_jumpifsideaffecting(void) const u8 *jumpInstr; if (cmd->battler == BS_ATTACKER) - side = GET_BATTLER_SIDE(gBattlerAttacker); + side = GetBattlerSide(gBattlerAttacker); else - side = GET_BATTLER_SIDE(gBattlerTarget); + side = GetBattlerSide(gBattlerTarget); flags = cmd->flags; jumpInstr = cmd->jumpInstr; @@ -5123,7 +5123,7 @@ static void Cmd_playstatchangeanimation(void) changeableStatsCount++; } } - else if (!gSideTimers[GET_BATTLER_SIDE(gActiveBattler)].mistTimer + else if (!gSideTimers[GetBattlerSide(gActiveBattler)].mistTimer && GetBattlerHoldEffect(gActiveBattler, TRUE) != HOLD_EFFECT_CLEAR_AMULET && ability != ABILITY_CLEAR_BODY && ability != ABILITY_FULL_METAL_BODY @@ -8561,7 +8561,7 @@ static void HandleScriptMegaPrimal(u32 caseId, u32 battlerId, bool32 isMega) struct Pokemon *party = GetBattlerParty(battlerId); struct Pokemon *mon = &party[gBattlerPartyIndexes[battlerId]]; u32 position = gBattlerPositions[battlerId]; - u32 side = GET_BATTLER_SIDE(battlerId); + u32 side = GetBattlerSide(battlerId); // Change species. if (caseId == 0) @@ -8783,7 +8783,7 @@ static void Cmd_various(void) while (gBattleStruct->friskedBattler < gBattlersCount) { gBattlerTarget = gBattleStruct->friskedBattler++; - if (GET_BATTLER_SIDE(gActiveBattler) != GET_BATTLER_SIDE(gBattlerTarget) + if (GetBattlerSide(gActiveBattler) != GetBattlerSide(gBattlerTarget) && IsBattlerAlive(gBattlerTarget) && gBattleMons[gBattlerTarget].item != ITEM_NONE) { @@ -9417,11 +9417,11 @@ static void Cmd_various(void) case VARIOUS_SET_LUCKY_CHANT: { VARIOUS_ARGS(const u8 *failInstr); - if (!(gSideStatuses[GET_BATTLER_SIDE(gActiveBattler)] & SIDE_STATUS_LUCKY_CHANT)) + if (!(gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_LUCKY_CHANT)) { - gSideStatuses[GET_BATTLER_SIDE(gActiveBattler)] |= SIDE_STATUS_LUCKY_CHANT; - gSideTimers[GET_BATTLER_SIDE(gActiveBattler)].luckyChantBattlerId = gActiveBattler; - gSideTimers[GET_BATTLER_SIDE(gActiveBattler)].luckyChantTimer = 5; + gSideStatuses[GetBattlerSide(gActiveBattler)] |= SIDE_STATUS_LUCKY_CHANT; + gSideTimers[GetBattlerSide(gActiveBattler)].luckyChantBattlerId = gActiveBattler; + gSideTimers[GetBattlerSide(gActiveBattler)].luckyChantTimer = 5; gBattlescriptCurrInstr = cmd->nextInstr; } else @@ -10022,7 +10022,7 @@ static void Cmd_various(void) case VARIOUS_SET_AURORA_VEIL: { VARIOUS_ARGS(); - if (gSideStatuses[GET_BATTLER_SIDE(gActiveBattler)] & SIDE_STATUS_AURORA_VEIL + if (gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_AURORA_VEIL || !(WEATHER_HAS_EFFECT && gBattleWeather & (B_WEATHER_HAIL | B_WEATHER_SNOW))) { gMoveResultFlags |= MOVE_RESULT_MISSED; @@ -10030,12 +10030,12 @@ static void Cmd_various(void) } else { - gSideStatuses[GET_BATTLER_SIDE(gActiveBattler)] |= SIDE_STATUS_AURORA_VEIL; + gSideStatuses[GetBattlerSide(gActiveBattler)] |= SIDE_STATUS_AURORA_VEIL; if (GetBattlerHoldEffect(gActiveBattler, TRUE) == HOLD_EFFECT_LIGHT_CLAY) - gSideTimers[GET_BATTLER_SIDE(gActiveBattler)].auroraVeilTimer = 8; + gSideTimers[GetBattlerSide(gActiveBattler)].auroraVeilTimer = 8; else - gSideTimers[GET_BATTLER_SIDE(gActiveBattler)].auroraVeilTimer = 5; - gSideTimers[GET_BATTLER_SIDE(gActiveBattler)].auroraVeilBattlerId = gActiveBattler; + gSideTimers[GetBattlerSide(gActiveBattler)].auroraVeilTimer = 5; + gSideTimers[GetBattlerSide(gActiveBattler)].auroraVeilBattlerId = gActiveBattler; if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && CountAliveMonsInBattle(BATTLE_ALIVE_ATK_SIDE) == 2) gBattleCommunication[MULTISTRING_CHOOSER] = 5; @@ -10435,11 +10435,11 @@ static void Cmd_various(void) if (gBattleMons[gBattlerAttacker].species == SPECIES_GRENINJA_BATTLE_BOND && HasAttackerFaintedTarget() && CalculateEnemyPartyCount() > 1 - && !(gBattleStruct->battleBondTransformed[GET_BATTLER_SIDE(gBattlerAttacker)] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]])) + && !(gBattleStruct->battleBondTransformed[GetBattlerSide(gBattlerAttacker)] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]])) { - gBattleStruct->battleBondTransformed[GET_BATTLER_SIDE(gBattlerAttacker)] |= gBitTable[gBattlerPartyIndexes[gBattlerAttacker]]; + gBattleStruct->battleBondTransformed[GetBattlerSide(gBattlerAttacker)] |= gBitTable[gBattlerPartyIndexes[gBattlerAttacker]]; PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBattlerAttacker].species); - gBattleStruct->changedSpecies[GET_BATTLER_SIDE(gBattlerAttacker)][gBattlerPartyIndexes[gBattlerAttacker]] = gBattleMons[gBattlerAttacker].species; + gBattleStruct->changedSpecies[GetBattlerSide(gBattlerAttacker)][gBattlerPartyIndexes[gBattlerAttacker]] = gBattleMons[gBattlerAttacker].species; gBattleMons[gBattlerAttacker].species = SPECIES_GRENINJA_ASH; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_BattleBondActivatesOnMoveEndAttacker; @@ -11248,19 +11248,19 @@ static void Cmd_setreflect(void) { CMD_ARGS(); - if (gSideStatuses[GET_BATTLER_SIDE(gBattlerAttacker)] & SIDE_STATUS_REFLECT) + if (gSideStatuses[GetBattlerSide(gBattlerAttacker)] & SIDE_STATUS_REFLECT) { gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SIDE_STATUS_FAILED; } else { - gSideStatuses[GET_BATTLER_SIDE(gBattlerAttacker)] |= SIDE_STATUS_REFLECT; + gSideStatuses[GetBattlerSide(gBattlerAttacker)] |= SIDE_STATUS_REFLECT; if (GetBattlerHoldEffect(gBattlerAttacker, TRUE) == HOLD_EFFECT_LIGHT_CLAY) - gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].reflectTimer = 8; + gSideTimers[GetBattlerSide(gBattlerAttacker)].reflectTimer = 8; else - gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].reflectTimer = 5; - gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].reflectBattlerId = gBattlerAttacker; + gSideTimers[GetBattlerSide(gBattlerAttacker)].reflectTimer = 5; + gSideTimers[GetBattlerSide(gBattlerAttacker)].reflectBattlerId = gBattlerAttacker; if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && CountAliveMonsInBattle(BATTLE_ALIVE_ATK_SIDE) == 2) gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SET_REFLECT_DOUBLE; @@ -11664,7 +11664,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr if (statValue <= -1) // Stat decrease. { - if (gSideTimers[GET_BATTLER_SIDE(gActiveBattler)].mistTimer + if (gSideTimers[GetBattlerSide(gActiveBattler)].mistTimer && !certain && gCurrentMove != MOVE_CURSE && !(gActiveBattler == gBattlerTarget && GetBattlerAbility(gBattlerAttacker) == ABILITY_INFILTRATOR)) { @@ -12306,19 +12306,19 @@ static void Cmd_setlightscreen(void) { CMD_ARGS(); - if (gSideStatuses[GET_BATTLER_SIDE(gBattlerAttacker)] & SIDE_STATUS_LIGHTSCREEN) + if (gSideStatuses[GetBattlerSide(gBattlerAttacker)] & SIDE_STATUS_LIGHTSCREEN) { gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SIDE_STATUS_FAILED; } else { - gSideStatuses[GET_BATTLER_SIDE(gBattlerAttacker)] |= SIDE_STATUS_LIGHTSCREEN; + gSideStatuses[GetBattlerSide(gBattlerAttacker)] |= SIDE_STATUS_LIGHTSCREEN; if (GetBattlerHoldEffect(gBattlerAttacker, TRUE) == HOLD_EFFECT_LIGHT_CLAY) - gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].lightscreenTimer = 8; + gSideTimers[GetBattlerSide(gBattlerAttacker)].lightscreenTimer = 8; else - gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].lightscreenTimer = 5; - gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].lightscreenBattlerId = gBattlerAttacker; + gSideTimers[GetBattlerSide(gBattlerAttacker)].lightscreenTimer = 5; + gSideTimers[GetBattlerSide(gBattlerAttacker)].lightscreenBattlerId = gBattlerAttacker; if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && CountAliveMonsInBattle(BATTLE_ALIVE_ATK_SIDE) == 2) gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SET_LIGHTSCREEN_DOUBLE; @@ -12579,16 +12579,16 @@ static void Cmd_setmist(void) { CMD_ARGS(); - if (gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].mistTimer) + if (gSideTimers[GetBattlerSide(gBattlerAttacker)].mistTimer) { gMoveResultFlags |= MOVE_RESULT_FAILED; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MIST_FAILED; } else { - gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].mistTimer = 5; - gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].mistBattlerId = gBattlerAttacker; - gSideStatuses[GET_BATTLER_SIDE(gBattlerAttacker)] |= SIDE_STATUS_MIST; + gSideTimers[GetBattlerSide(gBattlerAttacker)].mistTimer = 5; + gSideTimers[GetBattlerSide(gBattlerAttacker)].mistBattlerId = gBattlerAttacker; + gSideStatuses[GetBattlerSide(gBattlerAttacker)] |= SIDE_STATUS_MIST; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SET_MIST; } gBattlescriptCurrInstr = cmd->nextInstr; @@ -13539,16 +13539,16 @@ static void Cmd_setsafeguard(void) { CMD_ARGS(); - if (gSideStatuses[GET_BATTLER_SIDE(gBattlerAttacker)] & SIDE_STATUS_SAFEGUARD) + if (gSideStatuses[GetBattlerSide(gBattlerAttacker)] & SIDE_STATUS_SAFEGUARD) { gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SIDE_STATUS_FAILED; } else { - gSideStatuses[GET_BATTLER_SIDE(gBattlerAttacker)] |= SIDE_STATUS_SAFEGUARD; - gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].safeguardTimer = 5; - gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].safeguardBattlerId = gBattlerAttacker; + gSideStatuses[GetBattlerSide(gBattlerAttacker)] |= SIDE_STATUS_SAFEGUARD; + gSideTimers[GetBattlerSide(gBattlerAttacker)].safeguardTimer = 5; + gSideTimers[GetBattlerSide(gBattlerAttacker)].safeguardBattlerId = gBattlerAttacker; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SET_SAFEGUARD; } @@ -13859,7 +13859,7 @@ static void Cmd_trysetfutureattack(void) } else { - gSideStatuses[GET_BATTLER_SIDE(gBattlerTarget)] |= SIDE_STATUS_FUTUREATTACK; + gSideStatuses[GetBattlerSide(gBattlerTarget)] |= SIDE_STATUS_FUTUREATTACK; gWishFutureKnock.futureSightMove[gBattlerTarget] = gCurrentMove; gWishFutureKnock.futureSightAttacker[gBattlerTarget] = gBattlerAttacker; gWishFutureKnock.futureSightCounter[gBattlerTarget] = 3; diff --git a/src/battle_util.c b/src/battle_util.c index f2f64e3efb47..d18a617e9552 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3144,7 +3144,7 @@ bool8 HandleWishPerishSongOnTurnEnd(void) if (gWishFutureKnock.futureSightCounter[gActiveBattler] == 0 && gWishFutureKnock.futureSightCounter[BATTLE_PARTNER(gActiveBattler)] == 0) { - gSideStatuses[GET_BATTLER_SIDE(gBattlerTarget)] &= ~SIDE_STATUS_FUTUREATTACK; + gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~SIDE_STATUS_FUTUREATTACK; } return TRUE; } @@ -7897,7 +7897,7 @@ u32 GetMoveTarget(u16 move, u8 setTarget) case MOVE_TARGET_BOTH: case MOVE_TARGET_FOES_AND_ALLY: case MOVE_TARGET_OPPONENTS_FIELD: - targetBattler = GetBattlerAtPosition(BATTLE_OPPOSITE(GET_BATTLER_SIDE(gBattlerAttacker))); + targetBattler = GetBattlerAtPosition(BATTLE_OPPOSITE(GetBattlerSide(gBattlerAttacker))); if (!IsBattlerAlive(targetBattler)) targetBattler ^= BIT_FLANK; break; @@ -7908,7 +7908,7 @@ u32 GetMoveTarget(u16 move, u8 setTarget) else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && moveTarget & MOVE_TARGET_RANDOM) targetBattler = SetRandomTarget(gBattlerAttacker); else - targetBattler = GetBattlerAtPosition(BATTLE_OPPOSITE(GET_BATTLER_SIDE(gBattlerAttacker))); + targetBattler = GetBattlerAtPosition(BATTLE_OPPOSITE(GetBattlerSide(gBattlerAttacker))); break; case MOVE_TARGET_USER_OR_SELECTED: case MOVE_TARGET_USER: @@ -8688,7 +8688,7 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe u16 basePower = CalcMoveBasePower(move, battlerAtk, battlerDef); uq4_12_t holdEffectModifier; uq4_12_t modifier = UQ_4_12(1.0); - u32 atkSide = GET_BATTLER_SIDE(battlerAtk); + u32 atkSide = GetBattlerSide(battlerAtk); u16 atkAbility = GetBattlerAbility(battlerAtk); u16 defAbility = GetBattlerAbility(battlerDef); @@ -9439,7 +9439,7 @@ static u32 CalcFinalDmg(u32 dmg, u16 move, u8 battlerAtk, u8 battlerDef, u8 move u32 percentBoost; u32 abilityAtk = GetBattlerAbility(battlerAtk); u32 abilityDef = GetBattlerAbility(battlerDef); - u32 defSide = GET_BATTLER_SIDE(battlerDef); + u32 defSide = GetBattlerSide(battlerDef); uq4_12_t finalModifier = UQ_4_12(1.0); u16 itemDef = gBattleMons[battlerDef].item; u16 holdEffectAtk = GetBattlerHoldEffect(battlerAtk, TRUE); @@ -10147,7 +10147,7 @@ bool32 CanBattlerFormChange(u8 battlerId, u16 method) bool32 TryBattleFormChange(u8 battlerId, u16 method) { u8 monId = gBattlerPartyIndexes[battlerId]; - u8 side = GET_BATTLER_SIDE(battlerId); + u8 side = GetBattlerSide(battlerId); struct Pokemon *party = GetBattlerParty(battlerId); u16 targetSpecies; diff --git a/src/pokemon.c b/src/pokemon.c index 3ded30679100..4ef3eed59793 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -4449,7 +4449,7 @@ u8 CountAliveMonsInBattle(u8 caseId) u8 GetDefaultMoveTarget(u8 battlerId) { - u8 opposing = BATTLE_OPPOSITE(GET_BATTLER_SIDE(battlerId)); + u8 opposing = BATTLE_OPPOSITE(GetBattlerSide(battlerId)); if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) return GetBattlerAtPosition(opposing); From 5ae31e91235a0eda0a6b8aae42bffe8955ec0214 Mon Sep 17 00:00:00 2001 From: gruxor Date: Thu, 3 Aug 2023 14:50:19 -0400 Subject: [PATCH 3/7] inline, whoops --- include/battle_anim.h | 2 +- src/battle_anim_mons.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/battle_anim.h b/include/battle_anim.h index 361ab341cb95..e05ae9df1de0 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -165,7 +165,7 @@ void Trade_MoveSelectedMonToTarget(struct Sprite *sprite); void DestroyAnimVisualTaskAndDisableBlend(u8 taskId); void DestroySpriteAndFreeResources_(struct Sprite *sprite); void SetBattlerSpriteYOffsetFromOtherYScale(u8 spriteId, u8 otherSpriteId); -u8 GetBattlerSide(u8 battler); +inline u8 GetBattlerSide(u8 battler); u8 GetBattlerAtPosition(u8 position); void ConvertPosDataToTranslateLinearData(struct Sprite *sprite); void InitAnimFastLinearTranslationWithSpeedAndPos(struct Sprite *sprite); diff --git a/src/battle_anim_mons.c b/src/battle_anim_mons.c index d390566a3643..353117c8932f 100644 --- a/src/battle_anim_mons.c +++ b/src/battle_anim_mons.c @@ -845,7 +845,7 @@ bool32 InitSpritePosToAnimBattler(u32 animBattlerId, struct Sprite *sprite, bool return TRUE; } -u8 GetBattlerSide(u8 battlerId) +inline u8 GetBattlerSide(u8 battlerId) { return GetBattlerSide(battlerId); } From b226da183fdf8f6e7deb7e056ce357e0986bad0f Mon Sep 17 00:00:00 2001 From: gruxor Date: Thu, 3 Aug 2023 14:58:08 -0400 Subject: [PATCH 4/7] whoops again --- src/battle_anim_mons.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_anim_mons.c b/src/battle_anim_mons.c index 353117c8932f..776b6bcf4b00 100644 --- a/src/battle_anim_mons.c +++ b/src/battle_anim_mons.c @@ -847,7 +847,7 @@ bool32 InitSpritePosToAnimBattler(u32 animBattlerId, struct Sprite *sprite, bool inline u8 GetBattlerSide(u8 battlerId) { - return GetBattlerSide(battlerId); + return gBattlerPositions[battlerId] & BIT_SIDE; } u8 GetBattlerAtPosition(u8 position) From 98cfa78ef52e10f203cc0de7e6a1008589ac1859 Mon Sep 17 00:00:00 2001 From: gruxor Date: Thu, 3 Aug 2023 15:17:13 -0400 Subject: [PATCH 5/7] fixed (for real this time) --- include/battle.h | 27 ++++++++++++++++----------- include/battle_anim.h | 1 - src/battle_anim_mons.c | 5 ----- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/include/battle.h b/include/battle.h index 25c0e8de2160..908b85bc89c5 100644 --- a/include/battle.h +++ b/include/battle.h @@ -727,17 +727,6 @@ struct BattleStruct #define SET_STATCHANGER(statId, stage, goesDown)(gBattleScripting.statChanger = (statId) + ((stage) << 3) + (goesDown << 7)) #define SET_STATCHANGER2(dst, statId, stage, goesDown)(dst = (statId) + ((stage) << 3) + (goesDown << 7)) -static inline struct Pokemon *GetSideParty(u32 side) -{ - return side == B_SIDE_PLAYER ? gPlayerParty : gEnemyParty; -} - -static inline struct Pokemon *GetBattlerParty(u32 battlerId) -{ - extern u8 GetBattlerSide(u8 battler); - return GetSideParty(GetBattlerSide(battlerId)); -} - // NOTE: The members of this struct have hard-coded offsets // in include/constants/battle_script_commands.h struct BattleScripting @@ -1009,4 +998,20 @@ extern u8 gLastUsedBall; extern u16 gLastThrownBall; extern u8 gPartyCriticalHits[PARTY_SIZE]; +static inline u8 GetBattlerSide(u8 battlerId) +{ + return gBattlerPositions[battlerId] & BIT_SIDE; +} + +static inline struct Pokemon *GetSideParty(u32 side) +{ + return side == B_SIDE_PLAYER ? gPlayerParty : gEnemyParty; +} + +static inline struct Pokemon *GetBattlerParty(u32 battlerId) +{ + extern u8 GetBattlerSide(u8 battler); + return GetSideParty(GetBattlerSide(battlerId)); +} + #endif // GUARD_BATTLE_H diff --git a/include/battle_anim.h b/include/battle_anim.h index e05ae9df1de0..f9fbbed71738 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -165,7 +165,6 @@ void Trade_MoveSelectedMonToTarget(struct Sprite *sprite); void DestroyAnimVisualTaskAndDisableBlend(u8 taskId); void DestroySpriteAndFreeResources_(struct Sprite *sprite); void SetBattlerSpriteYOffsetFromOtherYScale(u8 spriteId, u8 otherSpriteId); -inline u8 GetBattlerSide(u8 battler); u8 GetBattlerAtPosition(u8 position); void ConvertPosDataToTranslateLinearData(struct Sprite *sprite); void InitAnimFastLinearTranslationWithSpeedAndPos(struct Sprite *sprite); diff --git a/src/battle_anim_mons.c b/src/battle_anim_mons.c index 776b6bcf4b00..1ff7f684dc0a 100644 --- a/src/battle_anim_mons.c +++ b/src/battle_anim_mons.c @@ -845,11 +845,6 @@ bool32 InitSpritePosToAnimBattler(u32 animBattlerId, struct Sprite *sprite, bool return TRUE; } -inline u8 GetBattlerSide(u8 battlerId) -{ - return gBattlerPositions[battlerId] & BIT_SIDE; -} - u8 GetBattlerAtPosition(u8 position) { u8 i; From 1529d0d5ec08f3944a46a65278d9c2dff65a730c Mon Sep 17 00:00:00 2001 From: gruxor Date: Thu, 3 Aug 2023 15:32:03 -0400 Subject: [PATCH 6/7] additional clarity parentheses --- include/battle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/battle.h b/include/battle.h index 908b85bc89c5..28c95c8d5e12 100644 --- a/include/battle.h +++ b/include/battle.h @@ -1005,7 +1005,7 @@ static inline u8 GetBattlerSide(u8 battlerId) static inline struct Pokemon *GetSideParty(u32 side) { - return side == B_SIDE_PLAYER ? gPlayerParty : gEnemyParty; + return (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; } static inline struct Pokemon *GetBattlerParty(u32 battlerId) From a6714f207b07527d5d2ba8f2f24a36cea6efd161 Mon Sep 17 00:00:00 2001 From: gruxor Date: Thu, 3 Aug 2023 15:55:53 -0400 Subject: [PATCH 7/7] Inline encapsulation getter on gBattlerPositions --- include/battle.h | 7 +++- src/battle_ai_main.c | 2 +- src/battle_ai_switch_items.c | 30 ++++++++--------- src/battle_ai_util.c | 4 +-- src/battle_anim.c | 20 ++++++------ src/battle_anim_bug.c | 4 +-- src/battle_anim_dark.c | 2 +- src/battle_anim_effects_1.c | 2 +- src/battle_anim_effects_3.c | 4 +-- src/battle_anim_fight.c | 2 +- src/battle_anim_mons.c | 16 ++++----- src/battle_anim_poison.c | 2 +- src/battle_anim_psychic.c | 4 +-- src/battle_anim_utility_funcs.c | 8 ++--- src/battle_anim_water.c | 2 +- src/battle_controller_link_opponent.c | 16 ++++----- src/battle_controller_link_partner.c | 8 ++--- src/battle_controller_opponent.c | 14 ++++---- src/battle_controller_player.c | 20 ++++++------ src/battle_controller_player_partner.c | 8 ++--- src/battle_controller_recorded_opponent.c | 12 +++---- src/battle_controller_recorded_player.c | 16 ++++----- src/battle_controller_safari.c | 2 +- src/battle_controller_wally.c | 6 ++-- src/battle_gfx_sfx_util.c | 26 +++++++-------- src/battle_interface.c | 22 ++++++------- src/battle_main.c | 40 +++++++++++------------ src/battle_message.c | 6 ++-- src/battle_script_commands.c | 22 ++++++------- src/battle_tv.c | 10 +++--- src/battle_util.c | 24 +++++++------- src/battle_z_move.c | 6 ++-- src/pokeball.c | 2 +- src/reshow_battle_screen.c | 10 +++--- 34 files changed, 192 insertions(+), 187 deletions(-) diff --git a/include/battle.h b/include/battle.h index 28c95c8d5e12..40b38f0d6e40 100644 --- a/include/battle.h +++ b/include/battle.h @@ -998,9 +998,14 @@ extern u8 gLastUsedBall; extern u16 gLastThrownBall; extern u8 gPartyCriticalHits[PARTY_SIZE]; +static inline u8 GetBattlerPosition(u8 battlerId) +{ + return gBattlerPositions[battlerId]; +} + static inline u8 GetBattlerSide(u8 battlerId) { - return gBattlerPositions[battlerId] & BIT_SIDE; + return GetBattlerPosition(battlerId) & BIT_SIDE; } static inline struct Pokemon *GetSideParty(u32 side) diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index da19a186e914..a2b616386816 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -326,7 +326,7 @@ void Ai_UpdateSwitchInData(u32 battler) ClearBattlerMoveHistory(battler); ClearBattlerAbilityHistory(battler); ClearBattlerItemEffectHistory(battler); - CopyBattlerDataToAIParty(gBattlerPositions[battler], side); + CopyBattlerDataToAIParty(GetBattlerPosition(battler), side); } } diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index 5a1cbbcb7a3c..73d7ecb645a6 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -85,7 +85,7 @@ static bool8 ShouldSwitchIfWonderGuard(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) return FALSE; - opposingPosition = BATTLE_OPPOSITE(gBattlerPositions[gActiveBattler]); + opposingPosition = BATTLE_OPPOSITE(GetBattlerPosition(gActiveBattler)); if (GetBattlerAbility(GetBattlerAtPosition(opposingPosition)) != ABILITY_WONDER_GUARD) return FALSE; @@ -163,10 +163,10 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { battlerIn1 = gActiveBattler; - if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))]) + if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))]) battlerIn2 = gActiveBattler; else - battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler])); + battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))); } else { @@ -233,7 +233,7 @@ static bool8 ShouldSwitchIfGameStatePrompt(void) bool8 switchMon = FALSE; u16 monAbility = AI_DATA->abilities[gActiveBattler]; u16 holdEffect = AI_DATA->holdEffects[gActiveBattler]; - u8 opposingPosition = BATTLE_OPPOSITE(gBattlerPositions[gActiveBattler]); + u8 opposingPosition = BATTLE_OPPOSITE(GetBattlerPosition(gActiveBattler)); u8 opposingBattler = GetBattlerAtPosition(opposingPosition); s32 moduloChance = 4; //25% Chance Default s32 chanceReducer = 1; //No Reduce default. Increase to reduce @@ -405,7 +405,7 @@ static bool8 ShouldSwitchIfAbilityBenefit(void) s32 monToSwitchId; s32 moduloChance = 4; //25% Chance Default s32 chanceReducer = 1; //No Reduce default. Increase to reduce - u8 battlerId = gBattlerPositions[gActiveBattler]; + u8 battlerId = GetBattlerPosition(gActiveBattler); if (AnyStatIsRaised(battlerId)) chanceReducer = 5; // Reduce switchout probability by factor of 5 if setup @@ -460,7 +460,7 @@ static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng) s32 i; u16 move; - opposingPosition = BATTLE_OPPOSITE(gBattlerPositions[gActiveBattler]); + opposingPosition = BATTLE_OPPOSITE(GetBattlerPosition(gActiveBattler)); opposingBattler = GetBattlerAtPosition(opposingPosition); if (!(gAbsentBattlerFlags & gBitTable[opposingBattler])) @@ -541,10 +541,10 @@ static bool8 FindMonWithFlagsAndSuperEffective(u16 flags, u8 moduloPercent) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { battlerIn1 = gActiveBattler; - if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))]) + if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))]) battlerIn2 = gActiveBattler; else - battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler])); + battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))); } else { @@ -630,10 +630,10 @@ bool32 ShouldSwitch(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { battlerIn1 = gActiveBattler; - if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))]) + if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))]) battlerIn2 = gActiveBattler; else - battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler])); + battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))); } else { @@ -720,7 +720,7 @@ void AI_TrySwitchOrUseItem(void) u8 battlerIn1, battlerIn2; s32 firstId; s32 lastId; // + 1 - u8 battlerIdentity = gBattlerPositions[gActiveBattler]; + u8 battlerIdentity = GetBattlerPosition(gActiveBattler); if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) party = gPlayerParty; @@ -928,10 +928,10 @@ u8 GetMostSuitableMonToSwitchInto(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { battlerIn1 = gActiveBattler; - if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))]) + if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))]) battlerIn2 = gActiveBattler; else - battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler])); + battlerIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))); opposingBattler = BATTLE_OPPOSITE(battlerIn1); if (gAbsentBattlerFlags & gBitTable[opposingBattler]) @@ -939,7 +939,7 @@ u8 GetMostSuitableMonToSwitchInto(void) } else { - opposingBattler = GetBattlerAtPosition(BATTLE_OPPOSITE(gBattlerPositions[gActiveBattler])); + opposingBattler = GetBattlerAtPosition(BATTLE_OPPOSITE(GetBattlerPosition(gActiveBattler))); battlerIn1 = gActiveBattler; battlerIn2 = gActiveBattler; } @@ -1023,7 +1023,7 @@ static bool8 ShouldUseItem(void) bool8 shouldUse = FALSE; // If teaming up with player and Pokemon is on the right, or Pokemon is currently held by Sky Drop - if ((gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && gBattlerPositions[gActiveBattler] == B_POSITION_PLAYER_RIGHT) + if ((gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_RIGHT) || gStatuses3[gActiveBattler] & STATUS3_SKY_DROPPED) return FALSE; diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index 1f78b87d001b..c18209314bbf 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -442,7 +442,7 @@ void RecordLastUsedMoveByTarget(void) bool32 BattlerHasAi(u32 battlerId) { - switch (gBattlerPositions[battlerId]) + switch (GetBattlerPosition(battlerId)) { case B_POSITION_PLAYER_LEFT: default: @@ -3404,7 +3404,7 @@ s32 CountUsablePartyMons(u8 battlerId) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { battlerOnField1 = gBattlerPartyIndexes[battlerId]; - battlerOnField2 = gBattlerPartyIndexes[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[battlerId]))]; + battlerOnField2 = gBattlerPartyIndexes[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(battlerId)))]; } else // In singles there's only one battlerId by side. { diff --git a/src/battle_anim.c b/src/battle_anim.c index 5ee2a1521d49..538ec930b6d5 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -852,7 +852,7 @@ static void Cmd_monbg(void) // Move designated battler to background if (IsBattlerSpriteVisible(battlerId)) { - u8 position = gBattlerPositions[battlerId]; + u8 position = GetBattlerPosition(battlerId); if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) toBG_2 = FALSE; else @@ -872,7 +872,7 @@ static void Cmd_monbg(void) battlerId ^= BIT_FLANK; if (IsBattlerSpriteVisible(battlerId)) { - u8 position = gBattlerPositions[battlerId]; + u8 position = GetBattlerPosition(battlerId); if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) toBG_2 = FALSE; else @@ -970,7 +970,7 @@ void MoveBattlerSpriteToBG(u8 battlerId, bool8 toBG_2, bool8 setSpriteInvisible) if (IsContest()) battlerPosition = 0; else - battlerPosition = gBattlerPositions[battlerId]; + battlerPosition = GetBattlerPosition(battlerId); DrawBattlerOnBg(1, 0, 0, battlerPosition, animBg.paletteId, animBg.bgTiles, animBg.bgTilemap, animBg.tilesOffset); @@ -1002,7 +1002,7 @@ void MoveBattlerSpriteToBG(u8 battlerId, bool8 toBG_2, bool8 setSpriteInvisible) LoadPalette(&gPlttBufferUnfaded[OBJ_PLTT_ID(battlerId)], BG_PLTT_ID(9), PLTT_SIZE_4BPP); CpuCopy32(&gPlttBufferUnfaded[OBJ_PLTT_ID(battlerId)], (void *)(BG_PLTT + PLTT_OFFSET_4BPP(9)), PLTT_SIZE_4BPP); - DrawBattlerOnBg(2, 0, 0, gBattlerPositions[battlerId], animBg.paletteId, animBg.bgTiles + 0x1000, animBg.bgTilemap + 0x400, animBg.tilesOffset); + DrawBattlerOnBg(2, 0, 0, GetBattlerPosition(battlerId), animBg.paletteId, animBg.bgTiles + 0x1000, animBg.bgTilemap + 0x400, animBg.tilesOffset); } } @@ -1146,7 +1146,7 @@ static void Task_ClearMonBg(u8 taskId) if (gTasks[taskId].data[1] != 1) { u8 to_BG2; - u8 position = gBattlerPositions[gTasks[taskId].data[2]]; + u8 position = GetBattlerPosition(gTasks[taskId].data[2]); if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) to_BG2 = FALSE; else @@ -1191,7 +1191,7 @@ static void Cmd_monbg_static(void) if (IsBattlerSpriteVisible(battlerId)) { - u8 position = gBattlerPositions[battlerId]; + u8 position = GetBattlerPosition(battlerId); if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) toBG_2 = FALSE; else @@ -1203,7 +1203,7 @@ static void Cmd_monbg_static(void) battlerId ^= BIT_FLANK; if (animBattlerId > 1 && IsBattlerSpriteVisible(battlerId)) { - u8 position = gBattlerPositions[battlerId]; + u8 position = GetBattlerPosition(battlerId); if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) toBG_2 = FALSE; else @@ -1255,7 +1255,7 @@ static void Task_ClearMonBgStatic(u8 taskId) { bool8 toBG_2; u8 battlerId = gTasks[taskId].data[2]; - u8 position = gBattlerPositions[battlerId]; + u8 position = GetBattlerPosition(battlerId); if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) toBG_2 = FALSE; else @@ -1961,7 +1961,7 @@ static void Cmd_splitbgprio(void) battlerId = gBattleAnimAttacker; // Apply only if the given battler is the lead (on left from team's perspective) - battlerPosition = gBattlerPositions[battlerId]; + battlerPosition = GetBattlerPosition(battlerId); if (!IsContest() && (battlerPosition == B_POSITION_PLAYER_LEFT || battlerPosition == B_POSITION_OPPONENT_RIGHT)) { SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1); @@ -1997,7 +1997,7 @@ static void Cmd_splitbgprio_foes(void) battlerId = gBattleAnimAttacker; // Apply only if the given battler is the lead (on left from team's perspective) - battlerPosition = gBattlerPositions[battlerId]; + battlerPosition = GetBattlerPosition(battlerId); if (!IsContest() && (battlerPosition == B_POSITION_PLAYER_LEFT || battlerPosition == B_POSITION_OPPONENT_RIGHT)) { SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1); diff --git a/src/battle_anim_bug.c b/src/battle_anim_bug.c index 0b7e18934878..bd91f18d1934 100644 --- a/src/battle_anim_bug.c +++ b/src/battle_anim_bug.c @@ -392,8 +392,8 @@ static void AnimTranslateStinger(struct Sprite *sprite) if (!IsContest() && GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget)) { - if (gBattlerPositions[gBattleAnimTarget] == B_POSITION_PLAYER_LEFT - || gBattlerPositions[gBattleAnimTarget] == B_POSITION_OPPONENT_LEFT) + if (GetBattlerPosition(gBattleAnimTarget) == B_POSITION_PLAYER_LEFT + || GetBattlerPosition(gBattleAnimTarget) == B_POSITION_OPPONENT_LEFT) { gBattleAnimArgs[2] *= -1; gBattleAnimArgs[0] *= -1; diff --git a/src/battle_anim_dark.c b/src/battle_anim_dark.c index 778b88a16654..2400c22aafde 100644 --- a/src/battle_anim_dark.c +++ b/src/battle_anim_dark.c @@ -916,7 +916,7 @@ void AnimTask_MetallicShine(u8 taskId) if (IsDoubleBattle() && !IsContest()) { - if (gBattlerPositions[gBattleAnimAttacker] == B_POSITION_OPPONENT_RIGHT || gBattlerPositions[gBattleAnimAttacker] == B_POSITION_PLAYER_LEFT) + if (GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_OPPONENT_RIGHT || GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_PLAYER_LEFT) { if (IsBattlerSpriteVisible(BATTLE_PARTNER(gBattleAnimAttacker)) == TRUE) { diff --git a/src/battle_anim_effects_1.c b/src/battle_anim_effects_1.c index 80f8ea27d9e6..63aea3f8083c 100644 --- a/src/battle_anim_effects_1.c +++ b/src/battle_anim_effects_1.c @@ -3009,7 +3009,7 @@ const struct SpriteTemplate gSeedFlareGreenCirclesTemplate = // functions static void AnimGrassKnot(struct Sprite *sprite) { - if (BATTLE_PARTNER(gBattleAnimAttacker) == gBattleAnimTarget && gBattlerPositions[gBattleAnimTarget] < B_POSITION_PLAYER_RIGHT) + if (BATTLE_PARTNER(gBattleAnimAttacker) == gBattleAnimTarget && GetBattlerPosition(gBattleAnimTarget) < B_POSITION_PLAYER_RIGHT) gBattleAnimArgs[0] *= -1; InitSpritePosToAnimTarget(sprite, TRUE); diff --git a/src/battle_anim_effects_3.c b/src/battle_anim_effects_3.c index c9f2aef1b204..3d89c3614414 100755 --- a/src/battle_anim_effects_3.c +++ b/src/battle_anim_effects_3.c @@ -2369,7 +2369,7 @@ void AnimTask_TransformMon(u8 taskId) if (IsContest()) position = B_POSITION_PLAYER_LEFT; else - position = gBattlerPositions[gBattleAnimAttacker]; + position = GetBattlerPosition(gBattleAnimAttacker); src = gMonSpritesGfxPtr->sprites.ptr[position]; dest = animBg.bgTiles; @@ -2652,7 +2652,7 @@ void AnimTask_DoomDesireLightBeam(u8 taskId) } else { - u8 position = gBattlerPositions[gBattleAnimTarget]; + u8 position = GetBattlerPosition(gBattleAnimTarget); if (IsDoubleBattle() == TRUE) { if (position == B_POSITION_OPPONENT_LEFT) diff --git a/src/battle_anim_fight.c b/src/battle_anim_fight.c index bc7dee754a0e..90bd9391e3fe 100644 --- a/src/battle_anim_fight.c +++ b/src/battle_anim_fight.c @@ -639,7 +639,7 @@ static void AnimCrossChopHand_Step(struct Sprite *sprite) // Rolling Kick / Low Kick static void AnimSlidingKick(struct Sprite *sprite) { - if (BATTLE_PARTNER(gBattleAnimAttacker) == gBattleAnimTarget && gBattlerPositions[gBattleAnimTarget] < B_POSITION_PLAYER_RIGHT) + if (BATTLE_PARTNER(gBattleAnimAttacker) == gBattleAnimTarget && GetBattlerPosition(gBattleAnimTarget) < B_POSITION_PLAYER_RIGHT) gBattleAnimArgs[0] *= -1; InitSpritePosToAnimTarget(sprite, TRUE); diff --git a/src/battle_anim_mons.c b/src/battle_anim_mons.c index 1ff7f684dc0a..4d97cd2c7565 100644 --- a/src/battle_anim_mons.c +++ b/src/battle_anim_mons.c @@ -101,10 +101,10 @@ u8 GetBattlerSpriteCoord(u8 battlerId, u8 coordType) { case BATTLER_COORD_X: case BATTLER_COORD_X_2: - retVal = sBattlerCoords[WhichBattleCoords(battlerId)][gBattlerPositions[battlerId]].x; + retVal = sBattlerCoords[WhichBattleCoords(battlerId)][GetBattlerPosition(battlerId)].x; break; case BATTLER_COORD_Y: - retVal = sBattlerCoords[WhichBattleCoords(battlerId)][gBattlerPositions[battlerId]].y; + retVal = sBattlerCoords[WhichBattleCoords(battlerId)][GetBattlerPosition(battlerId)].y; break; case BATTLER_COORD_Y_PIC_OFFSET: case BATTLER_COORD_Y_PIC_OFFSET_DEFAULT: @@ -235,7 +235,7 @@ u8 GetBattlerSpriteFinal_Y(u8 battlerId, u16 species, bool8 a3) offset = GetBattlerYDelta(battlerId, species); offset -= GetBattlerElevation(battlerId, species); } - y = offset + sBattlerCoords[WhichBattleCoords(battlerId)][gBattlerPositions[battlerId]].y; + y = offset + sBattlerCoords[WhichBattleCoords(battlerId)][GetBattlerPosition(battlerId)].y; if (a3) { if (GetBattlerSide(battlerId) == B_SIDE_PLAYER) @@ -851,7 +851,7 @@ u8 GetBattlerAtPosition(u8 position) for (i = 0; i < gBattlersCount; i++) { - if (gBattlerPositions[i] == position) + if (GetBattlerPosition(i) == position) break; } return i; @@ -870,7 +870,7 @@ bool8 IsBattlerSpritePresent(u8 battlerId) } else { - if (gBattlerPositions[battlerId] == 0xff) + if (GetBattlerPosition(battlerId) == 0xff) return FALSE; if (!gBattleStruct->spriteIgnore0Hp) @@ -2038,7 +2038,7 @@ u8 GetBattlerSpriteSubpriority(u8 battlerId) } else { - position = gBattlerPositions[battlerId]; + position = GetBattlerPosition(battlerId); if (position == B_POSITION_PLAYER_LEFT) subpriority = 30; else if (position == B_POSITION_PLAYER_RIGHT) @@ -2054,7 +2054,7 @@ u8 GetBattlerSpriteSubpriority(u8 battlerId) u8 GetBattlerSpriteBGPriority(u8 battlerId) { - u8 position = gBattlerPositions[battlerId]; + u8 position = GetBattlerPosition(battlerId); if (IsContest()) return 2; @@ -2068,7 +2068,7 @@ u8 GetBattlerSpriteBGPriorityRank(u8 battlerId) { if (!IsContest()) { - u8 position = gBattlerPositions[battlerId]; + u8 position = GetBattlerPosition(battlerId); if (position == B_POSITION_PLAYER_LEFT || position == B_POSITION_OPPONENT_RIGHT) return 2; else diff --git a/src/battle_anim_poison.c b/src/battle_anim_poison.c index 68b8be3822ce..8905f5c475af 100644 --- a/src/battle_anim_poison.c +++ b/src/battle_anim_poison.c @@ -362,7 +362,7 @@ static void AnimGunkShotParticlesStep(struct Sprite *sprite) static void AnimSuckerPunch(struct Sprite *sprite) { - if (BATTLE_PARTNER(gBattleAnimAttacker) == gBattleAnimTarget && gBattlerPositions[gBattleAnimTarget] < B_POSITION_PLAYER_RIGHT) + if (BATTLE_PARTNER(gBattleAnimAttacker) == gBattleAnimTarget && GetBattlerPosition(gBattleAnimTarget) < B_POSITION_PLAYER_RIGHT) gBattleAnimArgs[0] *= -1; InitSpritePosToAnimTarget(sprite, TRUE); diff --git a/src/battle_anim_psychic.c b/src/battle_anim_psychic.c index bb8e4e2a1e43..1c998e9c56e9 100644 --- a/src/battle_anim_psychic.c +++ b/src/battle_anim_psychic.c @@ -490,8 +490,8 @@ static void AnimPsychoCut(struct Sprite *sprite) if (!IsContest() && GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget)) { - if (gBattlerPositions[gBattleAnimTarget] == B_POSITION_PLAYER_LEFT - || gBattlerPositions[gBattleAnimTarget] == B_POSITION_OPPONENT_LEFT) + if (GetBattlerPosition(gBattleAnimTarget) == B_POSITION_PLAYER_LEFT + || GetBattlerPosition(gBattleAnimTarget) == B_POSITION_OPPONENT_LEFT) { s16 temp1, temp2; diff --git a/src/battle_anim_utility_funcs.c b/src/battle_anim_utility_funcs.c index d98846e4000e..4885a7ef371b 100644 --- a/src/battle_anim_utility_funcs.c +++ b/src/battle_anim_utility_funcs.c @@ -304,8 +304,8 @@ void AnimTask_DrawFallingWhiteLinesOnAttacker(u8 taskId) if (IsDoubleBattle() && !IsContest()) { - if (gBattlerPositions[gBattleAnimAttacker] == B_POSITION_OPPONENT_RIGHT - || gBattlerPositions[gBattleAnimAttacker] == B_POSITION_PLAYER_LEFT) + if (GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_OPPONENT_RIGHT + || GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_PLAYER_LEFT) { if (IsBattlerSpriteVisible(BATTLE_PARTNER(gBattleAnimAttacker)) == TRUE) { @@ -427,8 +427,8 @@ static void StatsChangeAnimation_Step1(u8 taskId) if (IsDoubleBattle() && sAnimStatsChangeData->data[3] == 0) { - if (gBattlerPositions[sAnimStatsChangeData->battler1] == B_POSITION_OPPONENT_RIGHT - || gBattlerPositions[sAnimStatsChangeData->battler1] == B_POSITION_PLAYER_LEFT) + if (GetBattlerPosition(sAnimStatsChangeData->battler1) == B_POSITION_OPPONENT_RIGHT + || GetBattlerPosition(sAnimStatsChangeData->battler1) == B_POSITION_PLAYER_LEFT) { if (IsBattlerSpriteVisible(sAnimStatsChangeData->battler2) == TRUE) { diff --git a/src/battle_anim_water.c b/src/battle_anim_water.c index 103e7ee703c2..961f154baa2b 100644 --- a/src/battle_anim_water.c +++ b/src/battle_anim_water.c @@ -924,7 +924,7 @@ static void AnimHydroCannonBeam(struct Sprite *sprite) if (GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget)) { gBattleAnimArgs[0] *= -1; - if (gBattlerPositions[gBattleAnimAttacker] == B_POSITION_PLAYER_LEFT || gBattlerPositions[gBattleAnimAttacker] == B_POSITION_OPPONENT_LEFT) + if (GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_PLAYER_LEFT || GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_OPPONENT_LEFT) gBattleAnimArgs[0] *= -1; } if ((gBattleAnimArgs[5] & 0xFF00) == 0) diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index 8a5b74e2cdbe..69e2f6bde43a 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -260,7 +260,7 @@ static void Intro_WaitForShinyAnimAndHealthbox(void) gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE; - if (gBattlerPositions[gActiveBattler] == B_POSITION_OPPONENT_RIGHT) + if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_RIGHT) { FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS); FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS); @@ -317,7 +317,7 @@ static void Intro_TryShinyAnimShowHealthbox(void) { if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) { - if (gBattlerPositions[gActiveBattler] == B_POSITION_OPPONENT_LEFT) + if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_LEFT) m4aMPlayContinue(&gMPlayInfo_BGM); } else @@ -335,7 +335,7 @@ static void Intro_TryShinyAnimShowHealthbox(void) if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { - if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattlerPositions[gActiveBattler] == B_POSITION_OPPONENT_RIGHT) + if (gBattleTypeFlags & BATTLE_TYPE_MULTI && GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_RIGHT) { if (++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == 1) return; @@ -1119,7 +1119,7 @@ static void LinkOpponentHandleLoadMonSprite(void) u16 species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); - SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(gActiveBattler, BATTLER_COORD_X_2), @@ -1154,7 +1154,7 @@ static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit) species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId); - SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[battlerId]); + SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); gBattlerSpriteIds[battlerId] = CreateSprite( &gMultiuseSpriteTemplate, @@ -1224,7 +1224,7 @@ static void LinkOpponentHandleDrawTrainerPic(void) if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - if ((gBattlerPositions[gActiveBattler] & BIT_FLANK) != 0) // second mon + if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon xPos = 152; else // first mon xPos = 200; @@ -1290,7 +1290,7 @@ static void LinkOpponentHandleDrawTrainerPic(void) } DecompressTrainerFrontPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, (8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 40, @@ -1315,7 +1315,7 @@ static void LinkOpponentHandleTrainerSlide(void) trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_B); DecompressTrainerFrontPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, 176, (8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 40, 0x1E); gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = 96; diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c index 046592bec519..8684ba70ebe5 100644 --- a/src/battle_controller_link_partner.c +++ b/src/battle_controller_link_partner.c @@ -1016,7 +1016,7 @@ static void LinkPartnerHandleLoadMonSprite(void) BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES); - SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(gActiveBattler, BATTLER_COORD_X_2), @@ -1046,7 +1046,7 @@ static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit) gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1]; species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); - SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[battlerId]); + SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); gBattlerSpriteIds[battlerId] = CreateSprite( &gMultiuseSpriteTemplate, @@ -1115,7 +1115,7 @@ static void LinkPartnerHandleDrawTrainerPic(void) if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - if ((gBattlerPositions[gActiveBattler] & BIT_FLANK) != 0) // second mon + if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon xPos = 90; else // first mon xPos = 32; @@ -1141,7 +1141,7 @@ static void LinkPartnerHandleDrawTrainerPic(void) } DecompressTrainerBackPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, (8 - gTrainerBackPicCoords[trainerPicId].size) * 4 + 80, GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 91b432376b73..f316f19ea879 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -277,7 +277,7 @@ static void Intro_WaitForShinyAnimAndHealthbox(void) } else if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim) { - if (gBattlerPositions[gActiveBattler] == 3) + if (GetBattlerPosition(gActiveBattler) == 3) { if (!gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].triedShinyMonAnim && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].finishedShinyMonAnim) @@ -345,7 +345,7 @@ static void Intro_TryShinyAnimShowHealthbox(void) { if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) { - if (gBattlerPositions[gActiveBattler] == 1) + if (GetBattlerPosition(gActiveBattler) == 1) m4aMPlayContinue(&gMPlayInfo_BGM); } else @@ -1149,7 +1149,7 @@ static void OpponentHandleLoadMonSprite(void) u16 species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); - SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(gActiveBattler, BATTLER_COORD_X_2), @@ -1186,7 +1186,7 @@ static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit) species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId); - SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[battlerId]); + SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); gBattlerSpriteIds[battlerId] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(battlerId, BATTLER_COORD_X_2), @@ -1308,7 +1308,7 @@ static void OpponentHandleDrawTrainerPic(void) if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_TWO_OPPONENTS) && !BATTLE_TWO_VS_ONE_OPPONENT) { - if ((gBattlerPositions[gActiveBattler] & BIT_FLANK) != 0) // second mon + if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon xPos = 152; else // first mon xPos = 200; @@ -1319,7 +1319,7 @@ static void OpponentHandleDrawTrainerPic(void) } DecompressTrainerFrontPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, (8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 40, @@ -1391,7 +1391,7 @@ static void OpponentHandleTrainerSlide(void) } DecompressTrainerFrontPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, 176, (8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 40, 0x1E); gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = 96; diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 8dfa62b3ade7..3848d8c01e80 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -308,7 +308,7 @@ static void HandleInputChooseAction(void) else if (JOY_NEW(B_BUTTON) || gPlayerDpadHoldFrames > 59) { if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) - && gBattlerPositions[gActiveBattler] == B_POSITION_PLAYER_RIGHT + && GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_RIGHT && !(gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]) && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { @@ -405,7 +405,7 @@ static void HandleInputChooseTarget(void) { do { - u8 currSelIdentity = gBattlerPositions[gMultiUsePlayerCursor]; + u8 currSelIdentity = GetBattlerPosition(gMultiUsePlayerCursor); for (i = 0; i < MAX_BATTLERS_COUNT; i++) { @@ -420,7 +420,7 @@ static void HandleInputChooseTarget(void) } while (gMultiUsePlayerCursor == gBattlersCount); i = 0; - switch (gBattlerPositions[gMultiUsePlayerCursor]) + switch (GetBattlerPosition(gMultiUsePlayerCursor)) { case B_POSITION_PLAYER_LEFT: case B_POSITION_PLAYER_RIGHT: @@ -455,7 +455,7 @@ static void HandleInputChooseTarget(void) { do { - u8 currSelIdentity = gBattlerPositions[gMultiUsePlayerCursor]; + u8 currSelIdentity = GetBattlerPosition(gMultiUsePlayerCursor); for (i = 0; i < MAX_BATTLERS_COUNT; i++) { @@ -470,7 +470,7 @@ static void HandleInputChooseTarget(void) } while (gMultiUsePlayerCursor == gBattlersCount); i = 0; - switch (gBattlerPositions[gMultiUsePlayerCursor]) + switch (GetBattlerPosition(gMultiUsePlayerCursor)) { case B_POSITION_PLAYER_LEFT: case B_POSITION_PLAYER_RIGHT: @@ -2421,7 +2421,7 @@ static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit) gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1]; species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); - SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[battlerId]); + SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); gBattlerSpriteIds[battlerId] = CreateSprite( &gMultiuseSpriteTemplate, @@ -2516,7 +2516,7 @@ static void PlayerHandleDrawTrainerPic(void) if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - if ((gBattlerPositions[gActiveBattler] & BIT_FLANK) != B_FLANK_LEFT) // Second mon, on the right. + if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != B_FLANK_LEFT) // Second mon, on the right. xPos = 90; else // First mon, on the left. xPos = 32; @@ -2543,7 +2543,7 @@ static void PlayerHandleDrawTrainerPic(void) { trainerPicId = PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender); DecompressTrainerFrontPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerFront(trainerPicId, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToTrainerFront(trainerPicId, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); @@ -2558,7 +2558,7 @@ static void PlayerHandleDrawTrainerPic(void) else { DecompressTrainerBackPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; @@ -2597,7 +2597,7 @@ static void PlayerHandleTrainerSlide(void) } DecompressTrainerBackPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, 80, (8 - gTrainerBackPicCoords[trainerPicId].size) * 4 + 80, 30); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index 5bda597ac79f..3a4beeca93fa 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -1204,7 +1204,7 @@ static void PlayerPartnerHandleLoadMonSprite(void) BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES); - SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(gActiveBattler, BATTLER_COORD_X_2), @@ -1234,7 +1234,7 @@ static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit) gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1]; species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); - SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[battlerId]); + SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); gBattlerSpriteIds[battlerId] = CreateSprite( &gMultiuseSpriteTemplate, @@ -1327,7 +1327,7 @@ static void PlayerPartnerHandleDrawTrainerPic(void) if (gPartnerTrainerId == TRAINER_STEVEN_PARTNER || gPartnerTrainerId >= TRAINER_CUSTOM_PARTNER) { DecompressTrainerBackPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; @@ -1338,7 +1338,7 @@ static void PlayerPartnerHandleDrawTrainerPic(void) else // otherwise use front sprite { DecompressTrainerFrontPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerFront(trainerPicId, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToTrainerFront(trainerPicId, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index ffb6c9e0313f..283388fcfdf5 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -239,7 +239,7 @@ static void Intro_WaitForShinyAnimAndHealthbox(void) if (healthboxAnimDone) { - if (gBattlerPositions[gActiveBattler] == B_POSITION_OPPONENT_LEFT) + if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_LEFT) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim) return; @@ -298,7 +298,7 @@ static void Intro_TryShinyAnimShowHealthbox(void) { if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) { - if (gBattlerPositions[gActiveBattler] == B_POSITION_OPPONENT_LEFT) + if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_LEFT) m4aMPlayContinue(&gMPlayInfo_BGM); } else @@ -1108,7 +1108,7 @@ static void RecordedOpponentHandleLoadMonSprite(void) u16 species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); - SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(gActiveBattler, BATTLER_COORD_X_2), @@ -1141,7 +1141,7 @@ static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit) species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId); - SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[battlerId]); + SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); gBattlerSpriteIds[battlerId] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(battlerId, BATTLER_COORD_X_2), @@ -1210,7 +1210,7 @@ static void RecordedOpponentHandleDrawTrainerPic(void) if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - if ((gBattlerPositions[gActiveBattler] & BIT_FLANK) != 0) // second mon + if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon xPos = 152; else // first mon xPos = 200; @@ -1241,7 +1241,7 @@ static void RecordedOpponentHandleDrawTrainerPic(void) } DecompressTrainerFrontPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, (8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 40, diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index 584931150ecf..86cb49198655 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -208,7 +208,7 @@ static void Intro_WaitForShinyAnimAndHealthbox(void) { bool32 healthboxAnimDone = FALSE; - if (gBattlerPositions[gActiveBattler] == B_POSITION_PLAYER_LEFT) + if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT) { if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) { @@ -275,7 +275,7 @@ static void Intro_TryShinyAnimShowHealthbox(void) { bool32 bgmRestored = FALSE; - if (gBattlerPositions[gActiveBattler] == B_POSITION_PLAYER_LEFT) + if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) @@ -313,7 +313,7 @@ static void Intro_TryShinyAnimShowHealthbox(void) { if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && (gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - if (gBattlerPositions[gActiveBattler] == B_POSITION_PLAYER_LEFT) + if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT) m4aMPlayContinue(&gMPlayInfo_BGM); } else @@ -1092,7 +1092,7 @@ static void RecordedPlayerHandleLoadMonSprite(void) BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES); - SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(gActiveBattler, BATTLER_COORD_X_2), @@ -1122,7 +1122,7 @@ static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit) gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1]; species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); - SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[battlerId]); + SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); gBattlerSpriteIds[battlerId] = CreateSprite( &gMultiuseSpriteTemplate, @@ -1203,7 +1203,7 @@ static void RecordedPlayerHandleDrawTrainerPic(void) if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - if ((gBattlerPositions[gActiveBattler] & BIT_FLANK) != 0) // second mon + if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon xPos = 90; else // first mon xPos = 32; @@ -1229,7 +1229,7 @@ static void RecordedPlayerHandleDrawTrainerPic(void) { trainerPicId = PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender); DecompressTrainerFrontPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerFront(trainerPicId, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToTrainerFront(trainerPicId, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); @@ -1243,7 +1243,7 @@ static void RecordedPlayerHandleDrawTrainerPic(void) else { DecompressTrainerBackPic(trainerPicId, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c index 5c5dbb616e14..1542838dbb07 100644 --- a/src/battle_controller_safari.c +++ b/src/battle_controller_safari.c @@ -355,7 +355,7 @@ static void SafariHandleReturnMonToBall(void) static void SafariHandleDrawTrainerPic(void) { DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(gSaveBlock2Ptr->playerGender, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToTrainerBack(gSaveBlock2Ptr->playerGender, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite( &gMultiuseSpriteTemplate, 80, diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c index 20f33dfd19c2..00a825dba5a5 100644 --- a/src/battle_controller_wally.c +++ b/src/battle_controller_wally.c @@ -1037,7 +1037,7 @@ static void WallyHandleReturnMonToBall(void) static void WallyHandleDrawTrainerPic(void) { DecompressTrainerBackPic(TRAINER_BACK_PIC_WALLY, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(TRAINER_BACK_PIC_WALLY, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToTrainerBack(TRAINER_BACK_PIC_WALLY, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, 80, 80 + 4 * (8 - gTrainerBackPicCoords[TRAINER_BACK_PIC_WALLY].size), @@ -1052,7 +1052,7 @@ static void WallyHandleDrawTrainerPic(void) static void WallyHandleTrainerSlide(void) { DecompressTrainerBackPic(TRAINER_BACK_PIC_WALLY, gActiveBattler); - SetMultiuseSpriteTemplateToTrainerBack(TRAINER_BACK_PIC_WALLY, gBattlerPositions[gActiveBattler]); + SetMultiuseSpriteTemplateToTrainerBack(TRAINER_BACK_PIC_WALLY, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, 80, 80 + 4 * (8 - gTrainerBackPicCoords[TRAINER_BACK_PIC_WALLY].size), @@ -1461,7 +1461,7 @@ static void StartSendOutAnim(u8 battlerId) gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1]; species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); - SetMultiuseSpriteTemplateToPokemon(species, gBattlerPositions[battlerId]); + SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); gBattlerSpriteIds[battlerId] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(battlerId, BATTLER_COORD_X_2), GetBattlerSpriteDefault_Y(battlerId), diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index 7cdcfa029be0..c976a5ad6650 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -576,7 +576,7 @@ static void BattleLoadMonSpriteGfx(struct Pokemon *mon, u32 battlerId, bool32 op #endif } - position = gBattlerPositions[battlerId]; + position = GetBattlerPosition(battlerId); if (opponent) { HandleLoadSpecialPokePic(TRUE, @@ -625,7 +625,7 @@ void BattleGfxSfxDummy2(u16 species) void DecompressTrainerFrontPic(u16 frontPicId, u8 battlerId) { - u8 position = gBattlerPositions[battlerId]; + u8 position = GetBattlerPosition(battlerId); DecompressPicFromTable(&gTrainerFrontPicTable[frontPicId], gMonSpritesGfxPtr->sprites.ptr[position], SPECIES_NONE); @@ -634,7 +634,7 @@ void DecompressTrainerFrontPic(u16 frontPicId, u8 battlerId) void DecompressTrainerBackPic(u16 backPicId, u8 battlerId) { - u8 position = gBattlerPositions[battlerId]; + u8 position = GetBattlerPosition(battlerId); DecompressPicFromTable(&gTrainerBackPicTable[backPicId], gMonSpritesGfxPtr->sprites.ptr[position], SPECIES_NONE); @@ -674,7 +674,7 @@ void BattleLoadAllHealthBoxesGfxAtOnce(void) numberOfBattlers = MAX_BATTLERS_COUNT; } for (i = 0; i < numberOfBattlers; i++) - LoadCompressedSpriteSheet(&sSpriteSheets_HealthBar[gBattlerPositions[i]]); + LoadCompressedSpriteSheet(&sSpriteSheets_HealthBar[GetBattlerPosition(i)]); } bool8 BattleLoadAllHealthBoxesGfx(u8 state) @@ -701,9 +701,9 @@ bool8 BattleLoadAllHealthBoxesGfx(u8 state) else if (state == 3) LoadCompressedSpriteSheet(&sSpriteSheet_SinglesOpponentHealthbox); else if (state == 4) - LoadCompressedSpriteSheet(&sSpriteSheets_HealthBar[gBattlerPositions[0]]); + LoadCompressedSpriteSheet(&sSpriteSheets_HealthBar[GetBattlerPosition(0)]); else if (state == 5) - LoadCompressedSpriteSheet(&sSpriteSheets_HealthBar[gBattlerPositions[1]]); + LoadCompressedSpriteSheet(&sSpriteSheets_HealthBar[GetBattlerPosition(1)]); else retVal = TRUE; } @@ -723,13 +723,13 @@ bool8 BattleLoadAllHealthBoxesGfx(u8 state) else if (state == 5) LoadCompressedSpriteSheet(&sSpriteSheets_DoublesOpponentHealthbox[1]); else if (state == 6) - LoadCompressedSpriteSheet(&sSpriteSheets_HealthBar[gBattlerPositions[0]]); + LoadCompressedSpriteSheet(&sSpriteSheets_HealthBar[GetBattlerPosition(0)]); else if (state == 7) - LoadCompressedSpriteSheet(&sSpriteSheets_HealthBar[gBattlerPositions[1]]); + LoadCompressedSpriteSheet(&sSpriteSheets_HealthBar[GetBattlerPosition(1)]); else if (state == 8) - LoadCompressedSpriteSheet(&sSpriteSheets_HealthBar[gBattlerPositions[2]]); + LoadCompressedSpriteSheet(&sSpriteSheets_HealthBar[GetBattlerPosition(2)]); else if (state == 9) - LoadCompressedSpriteSheet(&sSpriteSheets_HealthBar[gBattlerPositions[3]]); + LoadCompressedSpriteSheet(&sSpriteSheets_HealthBar[GetBattlerPosition(3)]); else retVal = TRUE; } @@ -782,7 +782,7 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *battlerId) break; case 4: InitBattlerHealthboxCoords(*battlerId); - if (gBattlerPositions[*battlerId] <= B_POSITION_OPPONENT_LEFT) + if (GetBattlerPosition(*battlerId) <= B_POSITION_OPPONENT_LEFT) DummyBattleInterfaceFunc(gHealthboxSpriteIds[*battlerId], FALSE); else DummyBattleInterfaceFunc(gHealthboxSpriteIds[*battlerId], TRUE); @@ -867,7 +867,7 @@ void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool32 megaEvo, bo } else { - position = gBattlerPositions[battlerAtk]; + position = GetBattlerPosition(battlerAtk); if (GetBattlerSide(battlerDef) == B_SIDE_OPPONENT) targetSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerDef]], MON_DATA_SPECIES); @@ -948,7 +948,7 @@ void BattleLoadSubstituteOrMonSpriteGfx(u8 battlerId, bool8 loadMonSprite) if (IsContest()) position = B_POSITION_PLAYER_LEFT; else - position = gBattlerPositions[battlerId]; + position = GetBattlerPosition(battlerId); if (IsContest()) LZDecompressVram(gSubstituteDollBackGfx, gMonSpritesGfxPtr->sprites.ptr[position]); diff --git a/src/battle_interface.c b/src/battle_interface.c index 52858b24de50..7ac936b2f7f4 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -705,11 +705,11 @@ static void InitLastUsedBallAssets(void) // The same goes for a 2 vs 1 where opponent has only one pokemon. u32 WhichBattleCoords(u32 battlerId) // 0 - singles, 1 - doubles { - if (gBattlerPositions[battlerId] == B_POSITION_PLAYER_LEFT + if (GetBattlerPosition(battlerId) == B_POSITION_PLAYER_LEFT && gPlayerPartyCount == 1 && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) return 0; - else if (gBattlerPositions[battlerId] == B_POSITION_OPPONENT_LEFT + else if (GetBattlerPosition(battlerId) == B_POSITION_OPPONENT_LEFT && gEnemyPartyCount == 1 && !(gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)) return 0; @@ -754,8 +754,8 @@ u8 CreateBattlerHealthboxSprites(u8 battlerId) { if (GetBattlerSide(battlerId) == B_SIDE_PLAYER) { - healthboxLeftSpriteId = CreateSprite(&sHealthboxPlayerSpriteTemplates[gBattlerPositions[battlerId] / 2], DISPLAY_WIDTH, DISPLAY_HEIGHT, 1); - healthboxRightSpriteId = CreateSpriteAtEnd(&sHealthboxPlayerSpriteTemplates[gBattlerPositions[battlerId] / 2], DISPLAY_WIDTH, DISPLAY_HEIGHT, 1); + healthboxLeftSpriteId = CreateSprite(&sHealthboxPlayerSpriteTemplates[GetBattlerPosition(battlerId) / 2], DISPLAY_WIDTH, DISPLAY_HEIGHT, 1); + healthboxRightSpriteId = CreateSpriteAtEnd(&sHealthboxPlayerSpriteTemplates[GetBattlerPosition(battlerId) / 2], DISPLAY_WIDTH, DISPLAY_HEIGHT, 1); gSprites[healthboxLeftSpriteId].oam.affineParam = healthboxRightSpriteId; @@ -767,8 +767,8 @@ u8 CreateBattlerHealthboxSprites(u8 battlerId) } else { - healthboxLeftSpriteId = CreateSprite(&sHealthboxOpponentSpriteTemplates[gBattlerPositions[battlerId] / 2], DISPLAY_WIDTH, DISPLAY_HEIGHT, 1); - healthboxRightSpriteId = CreateSpriteAtEnd(&sHealthboxOpponentSpriteTemplates[gBattlerPositions[battlerId] / 2], DISPLAY_WIDTH, DISPLAY_HEIGHT, 1); + healthboxLeftSpriteId = CreateSprite(&sHealthboxOpponentSpriteTemplates[GetBattlerPosition(battlerId) / 2], DISPLAY_WIDTH, DISPLAY_HEIGHT, 1); + healthboxRightSpriteId = CreateSpriteAtEnd(&sHealthboxOpponentSpriteTemplates[GetBattlerPosition(battlerId) / 2], DISPLAY_WIDTH, DISPLAY_HEIGHT, 1); gSprites[healthboxLeftSpriteId].oam.affineParam = healthboxRightSpriteId; @@ -956,7 +956,7 @@ void GetBattlerHealthboxCoords(u8 battler, s16 *x, s16 *y) } else { - switch (gBattlerPositions[battler]) + switch (GetBattlerPosition(battler)) { case B_POSITION_PLAYER_LEFT: *x = 159, *y = 76; @@ -1183,7 +1183,7 @@ static void PrintSafariMonInfo(u8 healthboxSpriteId, struct Pokemon *mon) u8 i, var, nature, healthBarSpriteId; memcpy(text, sEmptyWhiteText_GrayHighlight, sizeof(sEmptyWhiteText_GrayHighlight)); - barFontGfx = &gMonSpritesGfxPtr->barFontGfx[0x520 + (gBattlerPositions[gSprites[healthboxSpriteId].hMain_Battler] * 384)]; + barFontGfx = &gMonSpritesGfxPtr->barFontGfx[0x520 + (GetBattlerPosition(gSprites[healthboxSpriteId].hMain_Battler) * 384)]; var = 5; nature = GetNature(mon); StringCopy(&text[6], gNatureNamePointers[nature]); @@ -1578,7 +1578,7 @@ static void MegaIndicator_CreateSprite(u32 battlerId, u32 healthboxSpriteId) s16 xHealthbox = 0, y = 0; s32 x = 0; - position = gBattlerPositions[battlerId]; + position = GetBattlerPosition(battlerId); GetBattlerHealthboxCoords(battlerId, &xHealthbox, &y); x = sIndicatorPositions[position][0]; @@ -1624,7 +1624,7 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo, u8 ballIconSpritesIds[PARTY_SIZE]; u8 taskId; - if (!skipPlayer || gBattlerPositions[battlerId] != B_POSITION_OPPONENT_RIGHT) + if (!skipPlayer || GetBattlerPosition(battlerId) != B_POSITION_OPPONENT_RIGHT) { if (GetBattlerSide(battlerId) == B_SIDE_PLAYER) { @@ -3078,7 +3078,7 @@ void CreateAbilityPopUp(u8 battlerId, u32 ability, bool32 isDoubleBattle) LoadSpritePalette(&sSpritePalette_AbilityPopUp); } gBattleStruct->activeAbilityPopUps |= gBitTable[battlerId]; - battlerPosition = gBattlerPositions[battlerId]; + battlerPosition = GetBattlerPosition(battlerId); if (isDoubleBattle) coords = sAbilityPopUpCoordsDoubles; diff --git a/src/battle_main.c b/src/battle_main.c index 7250b0b638e1..52219b4960d6 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -2851,7 +2851,7 @@ static void SpriteCB_AnimFaintOpponent(struct Sprite *sprite) } else // Erase bottom part of the sprite to create a smooth illusion of mon falling down. { - u8 *dst = gMonSpritesGfxPtr->sprites.byte[gBattlerPositions[sprite->sBattler]] + (sprite->data[3] << 8); + u8 *dst = gMonSpritesGfxPtr->sprites.byte[GetBattlerPosition(sprite->sBattler)] + (sprite->data[3] << 8); for (i = 0; i < 0x100; i++) *(dst++) = 0; @@ -3529,7 +3529,7 @@ static void DoBattleIntro(void) } // Draw sprite. - switch (gBattlerPositions[gActiveBattler]) + switch (GetBattlerPosition(gActiveBattler)) { case B_POSITION_PLAYER_LEFT: // player sprite BtlController_EmitDrawTrainerPic(BUFFER_A); @@ -4052,7 +4052,7 @@ u8 IsRunningFromBattleImpossible(void) gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_DONT_LEAVE_BIRCH; return BATTLE_RUN_FORBIDDEN; } - if (gBattlerPositions[gActiveBattler] == B_POSITION_PLAYER_RIGHT && WILD_DOUBLE_BATTLE + if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_RIGHT && WILD_DOUBLE_BATTLE && IsBattlerAlive(GetBattlerAtPosition(B_POSITION_PLAYER_LEFT))) // The second pokemon cannot run from a double wild battle, unless it's the only alive mon. { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_CANT_ESCAPE; @@ -4136,7 +4136,7 @@ static void HandleTurnActionSelectionState(void) gBattleCommunication[ACTIONS_CONFIRMED_COUNT] = 0; for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - u8 position = gBattlerPositions[gActiveBattler]; + u8 position = GetBattlerPosition(gActiveBattler); switch (gBattleCommunication[gActiveBattler]) { case STATE_TURN_START_RECORD: // Recorded battle related action on start of every turn. @@ -4312,42 +4312,42 @@ static void HandleTurnActionSelectionState(void) break; case B_ACTION_CANCEL_PARTNER: gBattleCommunication[gActiveBattler] = STATE_WAIT_SET_BEFORE_ACTION; - gBattleCommunication[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))] = STATE_BEFORE_ACTION_CHOSEN; + gBattleCommunication[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))] = STATE_BEFORE_ACTION_CHOSEN; RecordedBattle_ClearBattlerAction(gActiveBattler, 1); - if (gBattleMons[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))].status2 & STATUS2_MULTIPLETURNS - || gBattleMons[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))].status2 & STATUS2_RECHARGE) + if (gBattleMons[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))].status2 & STATUS2_MULTIPLETURNS + || gBattleMons[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))].status2 & STATUS2_RECHARGE) { BtlController_EmitEndBounceEffect(BUFFER_A); MarkBattlerForControllerExec(gActiveBattler); return; } - else if (gChosenActionByBattler[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))] == B_ACTION_SWITCH) + else if (gChosenActionByBattler[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))] == B_ACTION_SWITCH) { - RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler])), 2); + RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))), 2); } - else if (gChosenActionByBattler[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))] == B_ACTION_RUN) + else if (gChosenActionByBattler[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))] == B_ACTION_RUN) { - RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler])), 1); + RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))), 1); } - else if (gChosenActionByBattler[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))] == B_ACTION_USE_MOVE - && (gProtectStructs[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))].noValidMoves - || gDisableStructs[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))].encoredMove)) + else if (gChosenActionByBattler[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))] == B_ACTION_USE_MOVE + && (gProtectStructs[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))].noValidMoves + || gDisableStructs[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))].encoredMove)) { - RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler])), 1); + RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))), 1); } else if (gBattleTypeFlags & BATTLE_TYPE_PALACE - && gChosenActionByBattler[GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler]))] == B_ACTION_USE_MOVE) + && gChosenActionByBattler[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))] == B_ACTION_USE_MOVE) { gRngValue = gBattlePalaceMoveSelectionRngValue; - RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler])), 1); + RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))), 1); } else { - RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gActiveBattler])), 3); + RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))), 3); } - gBattleStruct->mega.toEvolve &= ~(gBitTable[BATTLE_PARTNER(gBattlerPositions[gActiveBattler])]); - gBattleStruct->zmove.toBeUsed[BATTLE_PARTNER(gBattlerPositions[gActiveBattler])] = MOVE_NONE; + gBattleStruct->mega.toEvolve &= ~(gBitTable[BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))]); + gBattleStruct->zmove.toBeUsed[BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))] = MOVE_NONE; BtlController_EmitEndBounceEffect(BUFFER_A); MarkBattlerForControllerExec(gActiveBattler); return; diff --git a/src/battle_message.c b/src/battle_message.c index 6b74dad5f8b5..00545ecaf9b9 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -3053,7 +3053,7 @@ static const u8 *BattleStringGetOpponentName(u8 *text, u8 multiplayerId, u8 batt { const u8 *toCpy; - switch (gBattlerPositions[battlerId]) + switch (GetBattlerPosition(battlerId)) { case B_POSITION_OPPONENT_LEFT: toCpy = BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_A, text, multiplayerId, battlerId); @@ -3073,7 +3073,7 @@ static const u8 *BattleStringGetPlayerName(u8 *text, u8 battlerId) { const u8 *toCpy; - switch (gBattlerPositions[battlerId]) + switch (GetBattlerPosition(battlerId)) { case B_POSITION_PLAYER_LEFT: if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) @@ -3499,7 +3499,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst) toCpy = BattleStringGetTrainerName(text, multiplayerId, gBattlerAttacker); break; case B_TXT_ATK_TRAINER_CLASS: - switch (gBattlerPositions[gBattlerAttacker]) + switch (GetBattlerPosition(gBattlerAttacker)) { case B_POSITION_PLAYER_RIGHT: if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 8a0538b8d1a4..0aa78e7f26f0 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1934,7 +1934,7 @@ static void Cmd_critcalc(void) // Counter for EVO_CRITICAL_HITS. partySlot = gBattlerPartyIndexes[gBattlerAttacker]; if (gIsCriticalHit && GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER - && !(gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattlerPositions[gBattlerAttacker] == B_POSITION_PLAYER_LEFT)) + && !(gBattleTypeFlags & BATTLE_TYPE_MULTI && GetBattlerPosition(gBattlerAttacker) == B_POSITION_PLAYER_LEFT)) gPartyCriticalHits[partySlot]++; gBattlescriptCurrInstr = cmd->nextInstr; @@ -6714,7 +6714,7 @@ static void Cmd_openpartyscreen(void) gBattlescriptCurrInstr = cmd->nextInstr; - if (gBattlerPositions[gActiveBattler] == B_POSITION_PLAYER_LEFT && gBattleResults.playerSwitchesCounter < 255) + if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT && gBattleResults.playerSwitchesCounter < 255) gBattleResults.playerSwitchesCounter++; if (gBattleTypeFlags & BATTLE_TYPE_MULTI) @@ -6730,7 +6730,7 @@ static void Cmd_openpartyscreen(void) } else { - gActiveBattler = GetBattlerAtPosition(BATTLE_OPPOSITE(gBattlerPositions[battlerId])); + gActiveBattler = GetBattlerAtPosition(BATTLE_OPPOSITE(GetBattlerPosition(battlerId))); if (gAbsentBattlerFlags & gBitTable[gActiveBattler]) gActiveBattler ^= BIT_FLANK; @@ -8560,7 +8560,7 @@ static void HandleScriptMegaPrimal(u32 caseId, u32 battlerId, bool32 isMega) { struct Pokemon *party = GetBattlerParty(battlerId); struct Pokemon *mon = &party[gBattlerPartyIndexes[battlerId]]; - u32 position = gBattlerPositions[battlerId]; + u32 position = GetBattlerPosition(battlerId); u32 side = GetBattlerSide(battlerId); // Change species. @@ -12564,7 +12564,7 @@ static void Cmd_updatestatusicon(void) } if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) { - gActiveBattler = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gBattlerAttacker])); + gActiveBattler = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerAttacker))); if (!(gAbsentBattlerFlags & gBitTable[gActiveBattler])) { BtlController_EmitStatusIconUpdate(BUFFER_A, gBattleMons[gActiveBattler].status1, gBattleMons[gActiveBattler].status2); @@ -13265,7 +13265,7 @@ static void Cmd_healpartystatus(void) gBattleCommunication[MULTISTRING_CHOOSER] |= B_MSG_BELL_SOUNDPROOF_ATTACKER; } - gActiveBattler = gBattleScripting.battler = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gBattlerAttacker])); + gActiveBattler = gBattleScripting.battler = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerAttacker))); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && !(gAbsentBattlerFlags & gBitTable[gActiveBattler])) @@ -13315,7 +13315,7 @@ static void Cmd_healpartystatus(void) gBattleMons[gBattlerAttacker].status1 = 0; gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_NIGHTMARE; - gActiveBattler = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gBattlerAttacker])); + gActiveBattler = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerAttacker))); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && !(gAbsentBattlerFlags & gBitTable[gActiveBattler])) { @@ -14143,7 +14143,7 @@ static void Cmd_trysethelpinghand(void) { CMD_ARGS(const u8 *failInstr); - gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gBattlerAttacker])); + gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerAttacker))); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && !(gAbsentBattlerFlags & gBitTable[gBattlerTarget]) @@ -15059,7 +15059,7 @@ static void Cmd_pursuitdoubles(void) { CMD_ARGS(const u8 *failInstr); - gActiveBattler = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gBattlerAttacker])); + gActiveBattler = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerAttacker))); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && !(gAbsentBattlerFlags & gBitTable[gActiveBattler]) @@ -16184,8 +16184,8 @@ u8 GetFirstFaintedPartyIndex(u8 battlerId) if ((GetBattlerSide(battlerId) == B_SIDE_PLAYER && gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) || (GetBattlerSide(battlerId) == B_SIDE_OPPONENT && gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)) { - if (gBattlerPositions[battlerId] == B_POSITION_OPPONENT_LEFT - || gBattlerPositions[battlerId] == B_POSITION_PLAYER_LEFT) + if (GetBattlerPosition(battlerId) == B_POSITION_OPPONENT_LEFT + || GetBattlerPosition(battlerId) == B_POSITION_PLAYER_LEFT) { end = PARTY_SIZE / 2; } diff --git a/src/battle_tv.c b/src/battle_tv.c index 03f279de85c7..d28239351615 100644 --- a/src/battle_tv.c +++ b/src/battle_tv.c @@ -763,9 +763,9 @@ void BattleTv_SetDataBasedOnString(u16 stringId) statStringId = (u16 *)(gBattleTextBuff2 + 2); finishedMoveId = (u16 *)(gBattleTextBuff1 + 2); - atkFlank = gBattlerPositions[gBattlerAttacker] / 2; - defFlank = gBattlerPositions[gBattlerTarget] / 2; - effFlank = gBattlerPositions[gEffectBattler] / 2; + atkFlank = GetBattlerPosition(gBattlerAttacker) / 2; + defFlank = GetBattlerPosition(gBattlerTarget) / 2; + effFlank = GetBattlerPosition(gEffectBattler) / 2; switch (stringId) { @@ -1172,8 +1172,8 @@ void BattleTv_SetDataBasedOnMove(u16 move, u16 weatherFlags, struct DisableStruc return; } - tvPtr->pos[defSide][gBattlerPositions[gBattlerAttacker] / 2].attackedByMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - tvPtr->pos[defSide][gBattlerPositions[gBattlerAttacker] / 2].attackedByMoveSlot = moveSlot; + tvPtr->pos[defSide][GetBattlerPosition(gBattlerAttacker) / 2].attackedByMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->pos[defSide][GetBattlerPosition(gBattlerAttacker) / 2].attackedByMoveSlot = moveSlot; tvPtr->side[atkSide].usedMoveSlot = moveSlot; AddMovePoints(PTS_MOVE_EFFECT, moveSlot, gBattleMoves[move].effect, 0); AddPointsBasedOnWeather(weatherFlags, move, moveSlot); diff --git a/src/battle_util.c b/src/battle_util.c index d18a617e9552..2ebe3246b10a 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -404,13 +404,13 @@ void HandleAction_UseMove(void) { if (GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget)) { - gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gBattlerTarget])); + gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerTarget))); } else { - gBattlerTarget = GetBattlerAtPosition(BATTLE_OPPOSITE(gBattlerPositions[gBattlerAttacker])); + gBattlerTarget = GetBattlerAtPosition(BATTLE_OPPOSITE(GetBattlerPosition(gBattlerAttacker))); if (!IsBattlerAlive(gBattlerTarget)) - gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gBattlerTarget])); + gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerTarget))); } } } @@ -449,7 +449,7 @@ void HandleAction_UseMove(void) if (gAbsentBattlerFlags & gBitTable[gBattlerTarget] && GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget)) { - gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gBattlerTarget])); + gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerTarget))); } } else if (moveTarget == MOVE_TARGET_ALLY) @@ -477,13 +477,13 @@ void HandleAction_UseMove(void) { if (GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget)) { - gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gBattlerTarget])); + gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerTarget))); } else { - gBattlerTarget = GetBattlerAtPosition(BATTLE_OPPOSITE(gBattlerPositions[gBattlerAttacker])); + gBattlerTarget = GetBattlerAtPosition(BATTLE_OPPOSITE(GetBattlerPosition(gBattlerAttacker))); if (!IsBattlerAlive(gBattlerTarget)) - gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(gBattlerPositions[gBattlerTarget])); + gBattlerTarget = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerTarget))); } } } @@ -5873,7 +5873,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 = (BATTLE_OPPOSITE(gBattlerPositions[i])) & 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); @@ -7952,7 +7952,7 @@ u8 IsMonDisobedient(void) if (IsBattlerModernFatefulEncounter(gBattlerAttacker)) // only false if illegal Mew or Deoxys { - if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && gBattlerPositions[gBattlerAttacker] == 2) + if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gBattlerAttacker) == 2) return 0; if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) return 0; @@ -9971,12 +9971,12 @@ bool32 CanMegaEvolve(u8 battlerId) { u32 itemId, holdEffect, species; struct Pokemon *mon; - u8 battlerPosition = gBattlerPositions[battlerId]; - u8 partnerPosition = gBattlerPositions[BATTLE_PARTNER(battlerId)]; + u8 battlerPosition = GetBattlerPosition(battlerId); + u8 partnerPosition = GetBattlerPosition(BATTLE_PARTNER(battlerId)); struct MegaEvolutionData *mega = &(((struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]))->mega); // Check if Player has a Mega Ring - if ((gBattlerPositions[battlerId] == B_POSITION_PLAYER_LEFT || (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) && gBattlerPositions[battlerId] == B_POSITION_PLAYER_RIGHT)) + if ((GetBattlerPosition(battlerId) == B_POSITION_PLAYER_LEFT || (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) && GetBattlerPosition(battlerId) == B_POSITION_PLAYER_RIGHT)) && !CheckBagHasItem(ITEM_MEGA_RING, 1)) return FALSE; diff --git a/src/battle_z_move.c b/src/battle_z_move.c index c849346046f6..55cc157bee6b 100644 --- a/src/battle_z_move.c +++ b/src/battle_z_move.c @@ -160,8 +160,8 @@ bool32 IsViableZMove(u8 battlerId, u16 move) { struct Pokemon *mon; struct MegaEvolutionData *mega = &(((struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]))->mega); - u8 battlerPosition = gBattlerPositions[battlerId]; - u8 partnerPosition = gBattlerPositions[BATTLE_PARTNER(battlerId)]; + u8 battlerPosition = GetBattlerPosition(battlerId); + u8 partnerPosition = GetBattlerPosition(BATTLE_PARTNER(battlerId)); u32 item; u16 holdEffect; u16 species; @@ -182,7 +182,7 @@ bool32 IsViableZMove(u8 battlerId, u16 move) if (gBattleTypeFlags & (BATTLE_TYPE_SAFARI | BATTLE_TYPE_WALLY_TUTORIAL | BATTLE_TYPE_FRONTIER)) return FALSE; - if ((gBattlerPositions[battlerId] == B_POSITION_PLAYER_LEFT || (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) && gBattlerPositions[battlerId] == B_POSITION_PLAYER_RIGHT)) && !CheckBagHasItem(ITEM_Z_POWER_RING, 1)) + if ((GetBattlerPosition(battlerId) == B_POSITION_PLAYER_LEFT || (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) && GetBattlerPosition(battlerId) == B_POSITION_PLAYER_RIGHT)) && !CheckBagHasItem(ITEM_Z_POWER_RING, 1)) return FALSE; if (mega->alreadyEvolved[battlerPosition]) diff --git a/src/pokeball.c b/src/pokeball.c index 7f5534702c1d..2e556ec22523 100644 --- a/src/pokeball.c +++ b/src/pokeball.c @@ -1445,7 +1445,7 @@ void StartHealthboxSlideIn(u8 battlerId) healthboxSprite->y2 = -healthboxSprite->y2; } gSprites[healthboxSprite->data[5]].callback(&gSprites[healthboxSprite->data[5]]); - if (gBattlerPositions[battlerId] == B_POSITION_PLAYER_RIGHT) + if (GetBattlerPosition(battlerId) == B_POSITION_PLAYER_RIGHT) healthboxSprite->callback = SpriteCB_HealthboxSlideInDelayed; } diff --git a/src/reshow_battle_screen.c b/src/reshow_battle_screen.c index 40ca8b65bd2d..9ea0b1180502 100644 --- a/src/reshow_battle_screen.c +++ b/src/reshow_battle_screen.c @@ -223,7 +223,7 @@ static void CreateBattlerSprite(u8 battler) if (gBattleScripting.monCaught) // Don't create opponent sprite if it has been caught. return; - SetMultiuseSpriteTemplateToPokemon(GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES), gBattlerPositions[battler]); + SetMultiuseSpriteTemplateToPokemon(GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES), GetBattlerPosition(battler)); gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(battler, BATTLER_COORD_X_2), posY, GetBattlerSpriteSubpriority(battler)); gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler; gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy; @@ -234,7 +234,7 @@ static void CreateBattlerSprite(u8 battler) } else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && battler == B_POSITION_PLAYER_LEFT) { - SetMultiuseSpriteTemplateToTrainerBack(gSaveBlock2Ptr->playerGender, gBattlerPositions[B_POSITION_PLAYER_LEFT]); + SetMultiuseSpriteTemplateToTrainerBack(gSaveBlock2Ptr->playerGender, GetBattlerPosition(B_POSITION_PLAYER_LEFT)); gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate, 0x50, (8 - gTrainerBackPicCoords[gSaveBlock2Ptr->playerGender].size) * 4 + 80, GetBattlerSpriteSubpriority(0)); @@ -244,7 +244,7 @@ static void CreateBattlerSprite(u8 battler) } else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && battler == B_POSITION_PLAYER_LEFT) { - SetMultiuseSpriteTemplateToTrainerBack(TRAINER_BACK_PIC_WALLY, gBattlerPositions[0]); + SetMultiuseSpriteTemplateToTrainerBack(TRAINER_BACK_PIC_WALLY, GetBattlerPosition(0)); gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate, 0x50, (8 - gTrainerBackPicCoords[TRAINER_BACK_PIC_WALLY].size) * 4 + 80, GetBattlerSpriteSubpriority(0)); @@ -257,7 +257,7 @@ static void CreateBattlerSprite(u8 battler) if (!IsValidForBattle(&gPlayerParty[gBattlerPartyIndexes[battler]])) return; - SetMultiuseSpriteTemplateToPokemon(GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES), gBattlerPositions[battler]); + SetMultiuseSpriteTemplateToPokemon(GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES), GetBattlerPosition(battler)); gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(battler, BATTLER_COORD_X_2), posY, GetBattlerSpriteSubpriority(battler)); gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler; gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy; @@ -295,7 +295,7 @@ static void CreateHealthboxSprite(u8 battler) else UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL); - if (gBattlerPositions[battler] == B_POSITION_OPPONENT_RIGHT || gBattlerPositions[battler] == B_POSITION_PLAYER_RIGHT) + if (GetBattlerPosition(battler) == B_POSITION_OPPONENT_RIGHT || GetBattlerPosition(battler) == B_POSITION_PLAYER_RIGHT) DummyBattleInterfaceFunc(gHealthboxSpriteIds[battler], TRUE); else DummyBattleInterfaceFunc(gHealthboxSpriteIds[battler], FALSE);