mirror of
https://github.com/rh-hideout/pokeemerald-expansion.git
synced 2026-04-26 02:14:22 -05:00
Simplify some code by using GetBattlerParty (#8488)
This commit is contained in:
parent
0156589ad3
commit
c0d979e8a7
|
|
@ -64,7 +64,7 @@ bool32 IsAiVsAiBattle(void)
|
|||
bool32 BattlerIsPlayer(u32 battlerId)
|
||||
{
|
||||
return (gBattlerBattleController[battlerId] == BATTLE_CONTROLLER_PLAYER
|
||||
|| gBattlerBattleController[battlerId] == BATTLE_CONTROLLER_RECORDED_PLAYER);
|
||||
|| gBattlerBattleController[battlerId] == BATTLE_CONTROLLER_RECORDED_PLAYER);
|
||||
return (gBattlerBattleController[battlerId] == BATTLE_CONTROLLER_PLAYER
|
||||
|| gBattlerBattleController[battlerId] == BATTLE_CONTROLLER_RECORDED_PLAYER);
|
||||
}
|
||||
|
|
@ -108,10 +108,10 @@ bool32 BattlerHasAi(u32 battlerId)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (IsAiVsAiBattle())
|
||||
return TRUE;
|
||||
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -464,58 +464,27 @@ static void SetBattlePartyIds(void)
|
|||
{
|
||||
if (i < 2)
|
||||
{
|
||||
if (IsOnPlayerSide(i))
|
||||
if (IsValidForBattle(&GetBattlerParty(i)[j]))
|
||||
{
|
||||
if (IsValidForBattle(&gPlayerParty[j]))
|
||||
{
|
||||
gBattlerPartyIndexes[i] = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IsValidForBattle(&gEnemyParty[j]))
|
||||
{
|
||||
gBattlerPartyIndexes[i] = j;
|
||||
break;
|
||||
}
|
||||
gBattlerPartyIndexes[i] = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IsOnPlayerSide(i))
|
||||
if (gBattlerPartyIndexes[i - 2] == j)
|
||||
{
|
||||
if (gBattlerPartyIndexes[i - 2] == j)
|
||||
{
|
||||
// Exclude already assigned pokemon;
|
||||
}
|
||||
else if (IsValidForBattle(&gPlayerParty[j]))
|
||||
{
|
||||
gBattlerPartyIndexes[i] = j;
|
||||
break;
|
||||
}
|
||||
else if (IsValidForBattleButDead(&gPlayerParty[j]) && gBattlerPartyIndexes[i] < PARTY_SIZE)
|
||||
{
|
||||
// Put an "option" on a dead mon that can be revived;
|
||||
gBattlerPartyIndexes[i] = j + PARTY_SIZE;
|
||||
}
|
||||
// Exclude already assigned pokemon;
|
||||
}
|
||||
else
|
||||
else if (IsValidForBattle(&GetBattlerParty(i)[j]))
|
||||
{
|
||||
if (gBattlerPartyIndexes[i - 2] == j)
|
||||
{
|
||||
// Exclude already assigned pokemon;
|
||||
}
|
||||
else if (IsValidForBattle(&gEnemyParty[j]))
|
||||
{
|
||||
gBattlerPartyIndexes[i] = j;
|
||||
break;
|
||||
}
|
||||
else if (IsValidForBattleButDead(&gEnemyParty[j]) && gBattlerPartyIndexes[i] < PARTY_SIZE)
|
||||
{
|
||||
// Put an "option" on a dead mon that can be revived;
|
||||
gBattlerPartyIndexes[i] = j + PARTY_SIZE;
|
||||
}
|
||||
gBattlerPartyIndexes[i] = j;
|
||||
break;
|
||||
}
|
||||
else if (IsValidForBattleButDead(&GetBattlerParty(i)[j]) && gBattlerPartyIndexes[i] < PARTY_SIZE)
|
||||
{
|
||||
// Put an "option" on a dead mon that can be revived;
|
||||
gBattlerPartyIndexes[i] = j + PARTY_SIZE;
|
||||
}
|
||||
|
||||
if (gBattlerPartyIndexes[i] >= PARTY_SIZE)
|
||||
|
|
@ -2749,19 +2718,13 @@ void BtlController_HandlePlayFanfareOrBGM(u32 battler)
|
|||
|
||||
void BtlController_HandleFaintingCry(u32 battler)
|
||||
{
|
||||
struct Pokemon *party;
|
||||
struct Pokemon *party = GetBattlerParty(battler);
|
||||
s8 pan;
|
||||
|
||||
if (IsOnPlayerSide(battler))
|
||||
{
|
||||
party = gPlayerParty;
|
||||
pan = -25;
|
||||
}
|
||||
else
|
||||
{
|
||||
party = gEnemyParty;
|
||||
pan = 25;
|
||||
}
|
||||
|
||||
PlayCry_ByMode(GetMonData(&party[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES), pan, CRY_MODE_FAINT);
|
||||
BtlController_Complete(battler);
|
||||
|
|
|
|||
|
|
@ -267,16 +267,9 @@ static bool32 HandleEndTurnWish(u32 battler)
|
|||
gBattlerTarget = battler;
|
||||
PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, battler, gWishFutureKnock.wishPartyId[battler])
|
||||
if (B_WISH_HP_SOURCE >= GEN_5)
|
||||
{
|
||||
if (IsOnPlayerSide(battler))
|
||||
wishHeal = GetMonData(&gPlayerParty[gWishFutureKnock.wishPartyId[battler]], MON_DATA_MAX_HP) / 2;
|
||||
else
|
||||
wishHeal = GetMonData(&gEnemyParty[gWishFutureKnock.wishPartyId[battler]], MON_DATA_MAX_HP) / 2;
|
||||
}
|
||||
wishHeal = GetMonData(&GetBattlerParty(battler)[gWishFutureKnock.wishPartyId[battler]], MON_DATA_MAX_HP) / 2;
|
||||
else
|
||||
{
|
||||
wishHeal = GetNonDynamaxMaxHP(battler) / 2;
|
||||
}
|
||||
|
||||
SetHealAmount(battler, wishHeal);
|
||||
if (gBattleMons[battler].volatiles.healBlock)
|
||||
|
|
|
|||
|
|
@ -2273,7 +2273,7 @@ void BufferStringBattle(enum StringID stringID, u32 battler)
|
|||
stringPtr = sText_InGamePartnerWithdrewPkmn1;
|
||||
}
|
||||
}
|
||||
else if (BattlerIsLink(battler) || TRAINER_BATTLE_PARAM.opponentA == TRAINER_LINK_OPPONENT
|
||||
else if (BattlerIsLink(battler) || TRAINER_BATTLE_PARAM.opponentA == TRAINER_LINK_OPPONENT
|
||||
|| gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) // Link Opponent 1 and test opponent
|
||||
{
|
||||
stringPtr = sText_LinkTrainer1WithdrewPkmn;
|
||||
|
|
@ -2307,7 +2307,7 @@ void BufferStringBattle(enum StringID stringID, u32 battler)
|
|||
stringPtr = sText_InGamePartnerWithdrewPkmn2;
|
||||
}
|
||||
}
|
||||
else if (BattlerIsLink(battler) || TRAINER_BATTLE_PARAM.opponentA == TRAINER_LINK_OPPONENT
|
||||
else if (BattlerIsLink(battler) || TRAINER_BATTLE_PARAM.opponentA == TRAINER_LINK_OPPONENT
|
||||
|| TRAINER_BATTLE_PARAM.opponentB == TRAINER_LINK_OPPONENT || gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) // Link Opponent B and test opponent
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)
|
||||
|
|
@ -2350,7 +2350,7 @@ void BufferStringBattle(enum StringID stringID, u32 battler)
|
|||
stringPtr = sText_InGamePartnerSentOutPkmn1;
|
||||
}
|
||||
}
|
||||
else if (BattlerIsLink(gBattleScripting.battler) || TRAINER_BATTLE_PARAM.opponentA == TRAINER_LINK_OPPONENT
|
||||
else if (BattlerIsLink(gBattleScripting.battler) || TRAINER_BATTLE_PARAM.opponentA == TRAINER_LINK_OPPONENT
|
||||
|| gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) // Link Opponent 1 and test opponent
|
||||
{
|
||||
stringPtr = sText_LinkTrainerSentOutPkmn;
|
||||
|
|
@ -2384,7 +2384,7 @@ void BufferStringBattle(enum StringID stringID, u32 battler)
|
|||
stringPtr = sText_InGamePartnerSentOutPkmn2;
|
||||
}
|
||||
}
|
||||
else if (BattlerIsLink(gBattleScripting.battler) || TRAINER_BATTLE_PARAM.opponentA == TRAINER_LINK_OPPONENT
|
||||
else if (BattlerIsLink(gBattleScripting.battler) || TRAINER_BATTLE_PARAM.opponentA == TRAINER_LINK_OPPONENT
|
||||
|| TRAINER_BATTLE_PARAM.opponentB == TRAINER_LINK_OPPONENT || gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) // Link Opponent B and test opponent
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)
|
||||
|
|
@ -3109,12 +3109,8 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst, u32 dstSize)
|
|||
dstID++;
|
||||
toCpy++;
|
||||
}
|
||||
GetMonData(&gEnemyParty[gBattleStruct->scriptPartyIdx], MON_DATA_NICKNAME, text);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetMonData(&gPlayerParty[gBattleStruct->scriptPartyIdx], MON_DATA_NICKNAME, text);
|
||||
}
|
||||
GetMonData(&GetBattlerParty(gBattleScripting.battler)[gBattleStruct->scriptPartyIdx], MON_DATA_NICKNAME, text);
|
||||
StringGet_Nickname(text);
|
||||
toCpy = text;
|
||||
break;
|
||||
|
|
@ -3462,11 +3458,7 @@ void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst)
|
|||
break;
|
||||
case B_BUFF_MON_NICK_WITH_PREFIX: // poke nick with prefix
|
||||
case B_BUFF_MON_NICK_WITH_PREFIX_LOWER: // poke nick with lowercase prefix
|
||||
if (IsOnPlayerSide(src[srcID + 1]))
|
||||
{
|
||||
GetMonData(&gPlayerParty[src[srcID + 2]], MON_DATA_NICKNAME, nickname);
|
||||
}
|
||||
else
|
||||
if (!IsOnPlayerSide(src[srcID + 1]))
|
||||
{
|
||||
if (src[srcID] == B_BUFF_MON_NICK_WITH_PREFIX_LOWER)
|
||||
{
|
||||
|
|
@ -3482,9 +3474,8 @@ void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst)
|
|||
else
|
||||
StringAppend(dst, sText_WildPkmnPrefix);
|
||||
}
|
||||
|
||||
GetMonData(&gEnemyParty[src[srcID + 2]], MON_DATA_NICKNAME, nickname);
|
||||
}
|
||||
GetMonData(&GetBattlerParty(src[srcID + 1])[src[srcID + 2]], MON_DATA_NICKNAME, nickname);
|
||||
StringGet_Nickname(nickname);
|
||||
StringAppend(dst, nickname);
|
||||
srcID += 3;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user