mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-25 19:24:16 +01:00
GetSideParty/GetBattlerParty (#2910)
This commit is contained in:
commit
5afe3f5e20
@ -727,6 +727,17 @@ 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
|
||||
|
@ -188,7 +188,6 @@ bool32 SetIllusionMon(struct Pokemon *mon, u32 battlerId);
|
||||
bool8 ShouldGetStatBadgeBoost(u16 flagId, u8 battlerId);
|
||||
u8 GetBattleMoveSplit(u32 moveId);
|
||||
bool32 TestMoveFlags(u16 move, u32 flag);
|
||||
struct Pokemon *GetBattlerPartyData(u8 battlerId);
|
||||
bool32 CanFling(u8 battlerId);
|
||||
bool32 IsTelekinesisBannedSpecies(u16 species);
|
||||
bool32 IsHealBlockPreventingMove(u32 battler, u32 move);
|
||||
|
@ -3420,7 +3420,7 @@ bool32 IsPartyFullyHealedExceptBattler(u8 battlerId)
|
||||
bool32 PartyHasMoveSplit(u8 battlerId, u8 split)
|
||||
{
|
||||
u8 firstId, lastId;
|
||||
struct Pokemon* party = GetBattlerPartyData(battlerId);
|
||||
struct Pokemon *party = GetBattlerParty(battlerId);
|
||||
u32 i, j;
|
||||
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
|
@ -7897,9 +7897,6 @@ void AnimTask_TerrainPulse(u8 taskId)
|
||||
|
||||
void AnimTask_AffectionHangedOn(u8 taskId)
|
||||
{
|
||||
int side = GetBattlerSide(gBattleAnimTarget);
|
||||
struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
|
||||
|
||||
gBattleAnimArgs[0] = GetBattlerFriendshipScore(gBattleAnimTarget);
|
||||
DestroyAnimVisualTask(taskId);
|
||||
}
|
||||
|
@ -3800,7 +3800,9 @@ static void TryDoEventsBeforeFirstTurn(void)
|
||||
{
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
if (gBattleMons[i].hp == 0 || gBattleMons[i].species == SPECIES_NONE || GetMonData(GetBattlerPartyData(i), MON_DATA_IS_EGG))
|
||||
struct Pokemon *party = GetBattlerParty(i);
|
||||
struct Pokemon *mon = &party[gBattlerPartyIndexes[i]];
|
||||
if (gBattleMons[i].hp == 0 || gBattleMons[i].species == SPECIES_NONE || GetMonData(mon, MON_DATA_IS_EGG))
|
||||
gAbsentBattlerFlags |= gBitTable[i];
|
||||
}
|
||||
}
|
||||
@ -5047,7 +5049,8 @@ static void CheckMegaEvolutionBeforeTurn(void)
|
||||
if (gBattleStruct->mega.toEvolve & gBitTable[gActiveBattler]
|
||||
&& !(gProtectStructs[gActiveBattler].noValidMoves))
|
||||
{
|
||||
struct Pokemon *mon = GetBattlerPartyData(gActiveBattler);
|
||||
struct Pokemon *party = GetBattlerParty(gActiveBattler);
|
||||
struct Pokemon *mon = &party[gBattlerPartyIndexes[gActiveBattler]];
|
||||
|
||||
gBattleStruct->mega.toEvolve &= ~(gBitTable[gActiveBattler]);
|
||||
gLastUsedItem = gBattleMons[gActiveBattler].item;
|
||||
|
@ -6515,10 +6515,7 @@ bool32 CanBattlerSwitch(u32 battlerId)
|
||||
}
|
||||
else if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
|
||||
{
|
||||
if (GetBattlerSide(battlerId) == B_SIDE_OPPONENT)
|
||||
party = gEnemyParty;
|
||||
else
|
||||
party = gPlayerParty;
|
||||
party = GetBattlerParty(battlerId);
|
||||
|
||||
lastMonId = 0;
|
||||
if (battlerId & 2)
|
||||
@ -6559,10 +6556,7 @@ bool32 CanBattlerSwitch(u32 battlerId)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetBattlerSide(battlerId) == B_SIDE_OPPONENT)
|
||||
party = gEnemyParty;
|
||||
else
|
||||
party = gPlayerParty;
|
||||
party = GetBattlerParty(battlerId);
|
||||
|
||||
lastMonId = 0;
|
||||
if (GetLinkTrainerFlankId(GetBattlerMultiplayerId(battlerId)) == TRUE)
|
||||
@ -7716,10 +7710,7 @@ static void Cmd_drawpartystatussummary(void)
|
||||
|
||||
gActiveBattler = GetBattlerForBattleScript(cmd->battler);
|
||||
|
||||
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
|
||||
party = gPlayerParty;
|
||||
else
|
||||
party = gEnemyParty;
|
||||
party = GetBattlerParty(gActiveBattler);
|
||||
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
@ -8793,7 +8784,8 @@ static bool32 CourtChangeSwapSideStatuses(void)
|
||||
|
||||
static void HandleScriptMegaPrimal(u32 caseId, u32 battlerId, bool32 isMega)
|
||||
{
|
||||
struct Pokemon *mon = GetBattlerPartyData(battlerId);
|
||||
struct Pokemon *party = GetBattlerParty(battlerId);
|
||||
struct Pokemon *mon = &party[gBattlerPartyIndexes[battlerId]];
|
||||
u32 position = GetBattlerPosition(battlerId);
|
||||
u32 side = GET_BATTLER_SIDE(battlerId);
|
||||
|
||||
@ -8861,8 +8853,7 @@ static void HandleScriptMegaPrimal(u32 caseId, u32 battlerId, bool32 isMega)
|
||||
|
||||
static bool32 CanTeleport(u8 battlerId)
|
||||
{
|
||||
u8 side = GetBattlerSide(battlerId);
|
||||
struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
|
||||
struct Pokemon *party = GetBattlerParty(battlerId);
|
||||
u32 species, count, i;
|
||||
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
@ -11289,7 +11280,7 @@ static void Cmd_various(void)
|
||||
// Battler selected! Revive and go to next instruction.
|
||||
if (gSelectedMonPartyId != PARTY_SIZE)
|
||||
{
|
||||
struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
|
||||
struct Pokemon *party = GetSideParty(side);
|
||||
|
||||
u16 hp = GetMonData(&party[gSelectedMonPartyId], MON_DATA_MAX_HP) / 2;
|
||||
BtlController_EmitSetMonData(BUFFER_A, REQUEST_HP_BATTLE, gBitTable[gSelectedMonPartyId], sizeof(hp), &hp);
|
||||
@ -12397,10 +12388,7 @@ static void Cmd_forcerandomswitch(void)
|
||||
|| redCardForcedSwitch
|
||||
)
|
||||
{
|
||||
if (GetBattlerSide(gBattlerTarget) == B_SIDE_PLAYER)
|
||||
party = gPlayerParty;
|
||||
else
|
||||
party = gEnemyParty;
|
||||
party = GetBattlerParty(gBattlerTarget);
|
||||
|
||||
if (BATTLE_TWO_VS_ONE_OPPONENT && GetBattlerSide(gBattlerTarget) == B_SIDE_OPPONENT)
|
||||
{
|
||||
@ -13599,16 +13587,11 @@ static void Cmd_healpartystatus(void)
|
||||
|
||||
if (gCurrentMove == MOVE_HEAL_BELL)
|
||||
{
|
||||
struct Pokemon *party;
|
||||
struct Pokemon *party = GetBattlerParty(gBattlerAttacker);
|
||||
s32 i;
|
||||
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_BELL;
|
||||
|
||||
if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER)
|
||||
party = gPlayerParty;
|
||||
else
|
||||
party = gEnemyParty;
|
||||
|
||||
if (GetBattlerAbility(gBattlerAttacker) != ABILITY_SOUNDPROOF)
|
||||
{
|
||||
gBattleMons[gBattlerAttacker].status1 = 0;
|
||||
@ -14236,12 +14219,7 @@ static void Cmd_trydobeatup(void)
|
||||
gBattleStruct->beatUpSlot++;
|
||||
gBattlescriptCurrInstr = cmd->nextInstr;
|
||||
#else
|
||||
struct Pokemon *party;
|
||||
|
||||
if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER)
|
||||
party = gPlayerParty;
|
||||
else
|
||||
party = gEnemyParty;
|
||||
struct Pokemon *party = GetBattlerParty(gBattlerAttacker);
|
||||
|
||||
if (gBattleMons[gBattlerTarget].hp == 0)
|
||||
{
|
||||
@ -14935,10 +14913,7 @@ static void Cmd_assistattackselect(void)
|
||||
|
||||
if (validMoves != NULL)
|
||||
{
|
||||
if (GET_BATTLER_SIDE(gBattlerAttacker) != B_SIDE_PLAYER)
|
||||
party = gEnemyParty;
|
||||
else
|
||||
party = gPlayerParty;
|
||||
party = GetBattlerParty(gBattlerAttacker);
|
||||
|
||||
for (monId = 0; monId < PARTY_SIZE; monId++)
|
||||
{
|
||||
@ -16467,7 +16442,7 @@ u8 GetFirstFaintedPartyIndex(u8 battlerId)
|
||||
u32 i;
|
||||
u32 start = 0;
|
||||
u32 end = PARTY_SIZE;
|
||||
struct Pokemon *party = (GetBattlerSide(battlerId) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
|
||||
struct Pokemon *party = GetBattlerParty(battlerId);
|
||||
|
||||
// Check whether partner is separate trainer.
|
||||
if ((GetBattlerSide(battlerId) == B_SIDE_PLAYER && gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
|
||||
@ -16506,7 +16481,7 @@ void BS_ItemRestoreHP(void) {
|
||||
u32 battlerId = MAX_BATTLERS_COUNT;
|
||||
u32 healParam = GetItemEffect(gLastUsedItem)[6];
|
||||
u32 side = GetBattlerSide(gBattlerAttacker);
|
||||
struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
|
||||
struct Pokemon *party = GetSideParty(side);
|
||||
u16 hp = GetMonData(&party[gBattleStruct->itemPartyIndex[gBattlerAttacker]], MON_DATA_HP);
|
||||
u16 maxHP = GetMonData(&party[gBattleStruct->itemPartyIndex[gBattlerAttacker]], MON_DATA_MAX_HP);
|
||||
gBattleCommunication[MULTIUSE_STATE] = 0;
|
||||
@ -16564,7 +16539,7 @@ void BS_ItemRestoreHP(void) {
|
||||
|
||||
void BS_ItemCureStatus(void) {
|
||||
NATIVE_ARGS();
|
||||
struct Pokemon *party = (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
|
||||
struct Pokemon *party = GetBattlerParty(gBattlerAttacker);
|
||||
|
||||
// Heal Status1 conditions.
|
||||
HealStatusConditions(&party[gBattleStruct->itemPartyIndex[gBattlerAttacker]], gBattleStruct->itemPartyIndex[gBattlerAttacker], GetItemStatus1Mask(gLastUsedItem), gBattlerAttacker);
|
||||
|
@ -226,14 +226,9 @@ static const u16 sEntrainmentTargetSimpleBeamBannedAbilities[] =
|
||||
|
||||
static u8 CalcBeatUpPower(void)
|
||||
{
|
||||
struct Pokemon *party;
|
||||
u8 basePower;
|
||||
u16 species;
|
||||
|
||||
if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER)
|
||||
party = gPlayerParty;
|
||||
else
|
||||
party = gEnemyParty;
|
||||
struct Pokemon *party = GetBattlerParty(gBattlerAttacker);
|
||||
|
||||
// Party slot is incremented by the battle script for Beat Up after this damage calculation
|
||||
species = GetMonData(&party[gBattleStruct->beatUpSlot], MON_DATA_SPECIES);
|
||||
@ -1995,7 +1990,7 @@ u8 GetImprisonedMovesCount(u8 battlerId, u16 move)
|
||||
u32 GetBattlerFriendshipScore(u8 battlerId)
|
||||
{
|
||||
u8 side = GetBattlerSide(battlerId);
|
||||
struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
|
||||
struct Pokemon *party = GetSideParty(side);
|
||||
u16 species = GetMonData(&party[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
|
||||
|
||||
if (side != B_SIDE_PLAYER)
|
||||
@ -3755,14 +3750,9 @@ u8 AtkCanceller_UnableToUseMove(void)
|
||||
#if B_BEAT_UP >= GEN_5
|
||||
else if (gBattleMoves[gCurrentMove].effect == EFFECT_BEAT_UP)
|
||||
{
|
||||
struct Pokemon* party;
|
||||
struct Pokemon* party = GetBattlerParty(gBattlerAttacker);
|
||||
int i;
|
||||
|
||||
if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER)
|
||||
party = gPlayerParty;
|
||||
else
|
||||
party = gEnemyParty;
|
||||
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
if (GetMonData(&party[i], MON_DATA_HP)
|
||||
@ -3859,10 +3849,7 @@ bool8 HasNoMonsToSwitch(u8 battler, u8 partyIdBattlerOn1, u8 partyIdBattlerOn2)
|
||||
}
|
||||
else if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
|
||||
{
|
||||
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
|
||||
party = gPlayerParty;
|
||||
else
|
||||
party = gEnemyParty;
|
||||
party = GetBattlerParty(battler);
|
||||
|
||||
playerId = ((battler & BIT_FLANK) / 2);
|
||||
for (i = playerId * MULTI_PARTY_SIZE; i < playerId * MULTI_PARTY_SIZE + MULTI_PARTY_SIZE; i++)
|
||||
@ -3896,12 +3883,7 @@ bool8 HasNoMonsToSwitch(u8 battler, u8 partyIdBattlerOn1, u8 partyIdBattlerOn2)
|
||||
else
|
||||
{
|
||||
flankId = GetBattlerMultiplayerId(battler);
|
||||
|
||||
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
|
||||
party = gPlayerParty;
|
||||
else
|
||||
party = gEnemyParty;
|
||||
|
||||
party = GetBattlerParty(battler);
|
||||
playerId = GetLinkTrainerFlankId(flankId);
|
||||
}
|
||||
|
||||
@ -4070,7 +4052,7 @@ static void ShouldChangeFormInWeather(u8 battler)
|
||||
{
|
||||
int i;
|
||||
int side = GetBattlerSide(battler);
|
||||
struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
|
||||
struct Pokemon *party = GetSideParty(side);
|
||||
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
@ -4261,8 +4243,7 @@ bool8 ChangeTypeBasedOnTerrain(u8 battlerId)
|
||||
static u16 GetSupremeOverlordModifier(u8 battlerId)
|
||||
{
|
||||
u32 i;
|
||||
u8 side = GetBattlerSide(battlerId);
|
||||
struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
|
||||
struct Pokemon *party = GetBattlerParty(battlerId);
|
||||
u16 modifier = UQ_4_12(1.0);
|
||||
bool8 appliedFirstBoost = FALSE;
|
||||
|
||||
@ -7291,11 +7272,11 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
case HOLD_EFFECT_RESTORE_PP:
|
||||
if (!moveTurn)
|
||||
{
|
||||
struct Pokemon *mon;
|
||||
struct Pokemon *party = GetBattlerParty(battlerId);
|
||||
struct Pokemon *mon = &party[gBattlerPartyIndexes[battlerId]];
|
||||
u8 ppBonuses;
|
||||
u16 move;
|
||||
|
||||
mon = GetBattlerPartyData(battlerId);
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
move = GetMonData(mon, MON_DATA_MOVE1 + i);
|
||||
@ -10169,7 +10150,7 @@ void UndoMegaEvolution(u32 monId)
|
||||
void UndoFormChange(u32 monId, u32 side, bool32 isSwitchingOut)
|
||||
{
|
||||
u32 i, currSpecies, targetSpecies;
|
||||
struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
|
||||
struct Pokemon *party = GetSideParty(side);
|
||||
static const u16 species[][3] =
|
||||
{
|
||||
// Changed Form ID Default Form ID Should change on switch
|
||||
@ -10304,10 +10285,7 @@ bool32 SetIllusionMon(struct Pokemon *mon, u32 battlerId)
|
||||
if (GetMonAbility(mon) != ABILITY_ILLUSION)
|
||||
return FALSE;
|
||||
|
||||
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
|
||||
party = gPlayerParty;
|
||||
else
|
||||
party = gEnemyParty;
|
||||
party = GetBattlerParty(battlerId);
|
||||
|
||||
if (IsBattlerAlive(BATTLE_PARTNER(battlerId)))
|
||||
partnerMon = &party[gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)]];
|
||||
@ -10432,17 +10410,6 @@ bool32 TestMoveFlags(u16 move, u32 flag)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
struct Pokemon *GetBattlerPartyData(u8 battlerId)
|
||||
{
|
||||
struct Pokemon *mon;
|
||||
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
|
||||
mon = &gPlayerParty[gBattlerPartyIndexes[battlerId]];
|
||||
else
|
||||
mon = &gEnemyParty[gBattlerPartyIndexes[battlerId]];
|
||||
|
||||
return mon;
|
||||
}
|
||||
|
||||
static u8 GetFlingPowerFromItemId(u16 itemId)
|
||||
{
|
||||
if (itemId >= ITEM_TM01 && itemId <= ITEM_HM08)
|
||||
|
Loading…
Reference in New Issue
Block a user