remove active battler from other files

This commit is contained in:
DizzyEggg 2023-08-30 10:18:31 +02:00
parent 77dd5150f5
commit 4683783a92
16 changed files with 566 additions and 570 deletions

View File

@ -22,7 +22,7 @@
u8 ComputeBattleAiScores(u8 battler);
void BattleAI_SetupItems(void);
void BattleAI_SetupFlags(void);
void BattleAI_SetupAIData(u8 defaultScoreMoves);
void BattleAI_SetupAIData(u8 defaultScoreMoves, u32 battler);
u8 BattleAI_ChooseMoveOrAction(void);
void Ai_InitPartyStruct(void);
void Ai_UpdateSwitchInData(u32 battler);

View File

@ -239,13 +239,13 @@ enum
TRAINER_SLIDE_BEFORE_FIRST_TURN,
};
void BufferStringBattle(u16 stringID);
void BufferStringBattle(u16 stringID, u32 battler);
u32 BattleStringExpandPlaceholdersToDisplayedString(const u8 *src);
u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst);
void BattlePutTextOnWindow(const u8 *text, u8 windowId);
void SetPpNumbersPaletteInMoveSelection(void);
void SetPpNumbersPaletteInMoveSelection(u32 battler);
u8 GetCurrentPpToMaxPpState(u8 currentPp, u8 maxPp);
u32 ShouldDoTrainerSlide(u32 battlerId, u32 which); // return 1 for TrainerA, 2 forTrainerB
u32 ShouldDoTrainerSlide(u32 battler, u32 which); // return 1 for TrainerA, 2 forTrainerB
void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst);
extern struct BattleMsgData *gBattleMsgDataPtr;

View File

@ -114,22 +114,22 @@ u8 GetBattlerForBattleScript(u8 caseId);
void PressurePPLose(u8 target, u8 attacker, u16 move);
void PressurePPLoseOnUsingPerishSong(u8 attacker);
void PressurePPLoseOnUsingImprison(u8 attacker);
bool32 IsBattlerMarkedForControllerExec(u8 battlerId);
void MarkBattlerForControllerExec(u8 battlerId);
void MarkBattlerReceivedLinkData(u8 battlerId);
void CancelMultiTurnMoves(u8 battlerId);
bool8 WasUnableToUseMove(u8 battlerId);
void PrepareStringBattle(u16 stringId, u8 battlerId);
bool32 IsBattlerMarkedForControllerExec(u8 battler);
void MarkBattlerForControllerExec(u8 battler);
void MarkBattlerReceivedLinkData(u8 battler);
void CancelMultiTurnMoves(u8 battler);
bool8 WasUnableToUseMove(u8 battler);
void PrepareStringBattle(u16 stringId, u8 battler);
void ResetSentPokesToOpponentValue(void);
void OpponentSwitchInResetSentPokesToOpponentValue(u8 battlerId);
void UpdateSentPokesToOpponentValue(u8 battlerId);
void OpponentSwitchInResetSentPokesToOpponentValue(u8 battler);
void UpdateSentPokesToOpponentValue(u8 battler);
void BattleScriptPush(const u8 *bsPtr);
void BattleScriptPushCursor(void);
void BattleScriptPop(void);
u8 TrySetCantSelectMoveBattleScript(void);
u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u16 check);
bool8 AreAllMovesUnusable(void);
u8 GetImprisonedMovesCount(u8 battlerId, u16 move);
u32 TrySetCantSelectMoveBattleScript(u32 battler);
u8 CheckMoveLimitations(u8 battler, u8 unusableMoves, u16 check);
bool32 AreAllMovesUnusable(u32 battler);
u8 GetImprisonedMovesCount(u8 battler, u16 move);
u8 DoFieldEndTurnEffects(void);
s32 GetDrainedBigRootHp(u32 battler, s32 hp);
u8 DoBattlerEndTurnEffects(void);
@ -139,34 +139,34 @@ void TryClearRageAndFuryCutter(void);
u8 AtkCanceller_UnableToUseMove(u32 moveType);
void SetAtkCancellerForCalledMove(void);
u8 AtkCanceller_UnableToUseMove2(void);
bool8 HasNoMonsToSwitch(u8 battlerId, u8 r1, u8 r2);
bool8 HasNoMonsToSwitch(u8 battler, u8 r1, u8 r2);
bool32 TryChangeBattleWeather(u8 battler, u32 weatherEnumId, bool32 viaAbility);
u8 AbilityBattleEffects(u8 caseID, u8 battlerId, u16 ability, u8 special, u16 moveArg);
bool32 TryPrimalReversion(u8 battlerId);
u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 moveArg);
bool32 TryPrimalReversion(u8 battler);
bool32 IsNeutralizingGasOnField(void);
u32 GetBattlerAbility(u8 battlerId);
u32 IsAbilityOnSide(u32 battlerId, u32 ability);
u32 IsAbilityOnOpposingSide(u32 battlerId, u32 ability);
u32 GetBattlerAbility(u8 battler);
u32 IsAbilityOnSide(u32 battler, u32 ability);
u32 IsAbilityOnOpposingSide(u32 battler, u32 ability);
u32 IsAbilityOnField(u32 ability);
u32 IsAbilityOnFieldExcept(u32 battlerId, u32 ability);
u32 IsAbilityPreventingEscape(u32 battlerId);
bool32 IsBattlerProtected(u8 battlerId, u16 move);
bool32 CanBattlerEscape(u32 battlerId); // no ability check
u32 IsAbilityOnFieldExcept(u32 battler, u32 ability);
u32 IsAbilityPreventingEscape(u32 battler);
bool32 IsBattlerProtected(u8 battler, u16 move);
bool32 CanBattlerEscape(u32 battler); // no ability check
void BattleScriptExecute(const u8 *BS_ptr);
void BattleScriptPushCursorAndCallback(const u8 *BS_ptr);
u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn);
void ClearFuryCutterDestinyBondGrudge(u8 battlerId);
u8 ItemBattleEffects(u8 caseID, u8 battler, bool8 moveTurn);
void ClearFuryCutterDestinyBondGrudge(u8 battler);
void HandleAction_RunBattleScript(void);
u32 SetRandomTarget(u32 battlerId);
u32 SetRandomTarget(u32 battler);
u32 GetMoveTarget(u16 move, u8 setTarget);
u8 IsMonDisobedient(void);
u32 GetBattlerHoldEffect(u8 battlerId, bool32 checkNegating);
u32 GetBattlerHoldEffectParam(u8 battlerId);
u32 GetBattlerHoldEffect(u8 battler, bool32 checkNegating);
u32 GetBattlerHoldEffectParam(u8 battler);
bool32 IsMoveMakingContact(u16 move, u8 battlerAtk);
bool32 IsBattlerGrounded(u8 battlerId);
bool32 IsBattlerAlive(u8 battlerId);
bool32 IsBattlerGrounded(u8 battler);
bool32 IsBattlerAlive(u8 battler);
u8 GetBattleMonMoveSlot(struct BattlePokemon *battleMon, u16 move);
u32 GetBattlerWeight(u8 battlerId);
u32 GetBattlerWeight(u8 battler);
u32 CalcRolloutBasePower(u32 battlerAtk, u32 basePower, u32 rolloutTimer);
u32 CalcFuryCutterBasePower(u32 basePower, u32 furyCutterCounter);
s32 CalculateMoveDamage(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, s32 fixedBasePower, bool32 isCrit, bool32 randomFactor, bool32 updateFlags);
@ -174,44 +174,44 @@ s32 CalculateMoveDamageAndEffectiveness(u16 move, u8 battlerAtk, u8 battlerDef,
uq4_12_t CalcTypeEffectivenessMultiplier(u16 move, u8 moveType, u8 battlerAtk, u8 battlerDef, bool32 recordAbilities);
uq4_12_t CalcPartyMonTypeEffectivenessMultiplier(u16 move, u16 speciesDef, u16 abilityDef);
uq4_12_t GetTypeModifier(u8 atkType, u8 defType);
s32 GetStealthHazardDamage(u8 hazardType, u8 battlerId);
s32 GetStealthHazardDamage(u8 hazardType, u8 battler);
s32 GetStealthHazardDamageByTypesAndHP(u8 hazardType, u8 type1, u8 type2, u32 maxHp);
bool32 CanMegaEvolve(u8 battlerId);
bool32 IsBattlerMegaEvolved(u8 battlerId);
bool32 IsBattlerPrimalReverted(u8 battlerId);
u16 GetBattleFormChangeTargetSpecies(u8 battlerId, u16 method);
bool32 TryBattleFormChange(u8 battlerId, u16 method);
bool32 CanMegaEvolve(u8 battler);
bool32 IsBattlerMegaEvolved(u8 battler);
bool32 IsBattlerPrimalReverted(u8 battler);
u16 GetBattleFormChangeTargetSpecies(u8 battler, u16 method);
bool32 TryBattleFormChange(u8 battler, u16 method);
bool32 DoBattlersShareType(u32 battler1, u32 battler2);
bool32 CanBattlerGetOrLoseItem(u8 battlerId, u16 itemId);
u32 GetIllusionMonSpecies(u32 battlerId);
struct Pokemon *GetIllusionMonPtr(u32 battlerId);
void ClearIllusionMon(u32 battlerId);
bool32 SetIllusionMon(struct Pokemon *mon, u32 battlerId);
bool8 ShouldGetStatBadgeBoost(u16 flagId, u8 battlerId);
bool32 CanBattlerGetOrLoseItem(u8 battler, u16 itemId);
u32 GetIllusionMonSpecies(u32 battler);
struct Pokemon *GetIllusionMonPtr(u32 battler);
void ClearIllusionMon(u32 battler);
bool32 SetIllusionMon(struct Pokemon *mon, u32 battler);
bool8 ShouldGetStatBadgeBoost(u16 flagId, u8 battler);
u8 GetBattleMoveSplit(u32 moveId);
bool32 CanFling(u8 battlerId);
bool32 CanFling(u8 battler);
bool32 IsTelekinesisBannedSpecies(u16 species);
bool32 IsHealBlockPreventingMove(u32 battler, u32 move);
bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId);
bool32 IsPartnerMonFromSameTrainer(u8 battlerId);
u8 GetSplitBasedOnStats(u8 battlerId);
bool32 HasEnoughHpToEatBerry(u32 battler, u32 hpFraction, u32 itemId);
bool32 IsPartnerMonFromSameTrainer(u8 battler);
u8 GetSplitBasedOnStats(u8 battler);
bool32 TestSheerForceFlag(u8 battler, u16 move);
void TryRestoreHeldItems(void);
bool32 CanStealItem(u8 battlerStealing, u8 battlerItem, u16 item);
void TrySaveExchangedItem(u8 battlerId, u16 stolenItem);
bool32 IsPartnerMonFromSameTrainer(u8 battlerId);
void TrySaveExchangedItem(u8 battler, u16 stolenItem);
bool32 IsPartnerMonFromSameTrainer(u8 battler);
u8 TryHandleSeed(u8 battler, u32 terrainFlag, u8 statId, u16 itemId, bool32 execute);
bool32 IsBattlerAffectedByHazards(u8 battlerId, bool32 toxicSpikes);
bool32 IsBattlerAffectedByHazards(u8 battler, bool32 toxicSpikes);
void SortBattlersBySpeed(u8 *battlers, bool8 slowToFast);
bool32 CompareStat(u8 battlerId, u8 statId, u8 cmpTo, u8 cmpKind);
bool32 TryRoomService(u8 battlerId);
void BufferStatChange(u8 battlerId, u8 statId, u8 stringId);
bool32 CompareStat(u8 battler, u8 statId, u8 cmpTo, u8 cmpKind);
bool32 TryRoomService(u8 battler);
void BufferStatChange(u8 battler, u8 statId, u8 stringId);
bool32 BlocksPrankster(u16 move, u8 battlerPrankster, u8 battlerDef, bool32 checkTarget);
u16 GetUsedHeldItem(u8 battler);
bool32 IsBattlerWeatherAffected(u8 battlerId, u32 weatherFlags);
u32 GetBattlerMoveTargetType(u8 battlerId, u16 move);
bool32 IsBattlerWeatherAffected(u8 battler, u32 weatherFlags);
u32 GetBattlerMoveTargetType(u8 battler, u16 move);
bool32 CanTargetBattler(u8 battlerAtk, u8 battlerDef, u16 move);
bool8 IsMoveAffectedByParentalBond(u16 move, u8 battlerId);
bool8 IsMoveAffectedByParentalBond(u16 move, u8 battler);
void CopyMonLevelAndBaseStatsToBattleMon(u32 battler, struct Pokemon *mon);
void CopyMonAbilityAndTypesToBattleMon(u32 battler, struct Pokemon *mon);
void RecalcBattlerStats(u32 battler, struct Pokemon *mon);
@ -226,21 +226,21 @@ bool32 IsGastroAcidBannedAbility(u16 ability);
bool32 IsEntrainmentBannedAbilityAttacker(u16 ability);
bool32 IsEntrainmentTargetOrSimpleBeamBannedAbility(u16 ability);
bool32 CanSleep(u8 battlerId);
bool32 CanSleep(u8 battler);
bool32 CanBePoisoned(u8 battlerAttacker, u8 battlerTarget);
bool32 CanBeBurned(u8 battlerId);
bool32 CanBeParalyzed(u8 battlerId);
bool32 CanBeFrozen(u8 battlerId);
bool32 CanGetFrostbite(u8 battlerId);
bool32 CanBeConfused(u8 battlerId);
bool32 IsBattlerTerrainAffected(u8 battlerId, u32 terrainFlag);
u32 GetBattlerFriendshipScore(u8 battlerId);
u32 CountBattlerStatIncreases(u8 battlerId, bool32 countEvasionAcc);
bool32 CanBeBurned(u8 battler);
bool32 CanBeParalyzed(u8 battler);
bool32 CanBeFrozen(u8 battler);
bool32 CanGetFrostbite(u8 battler);
bool32 CanBeConfused(u8 battler);
bool32 IsBattlerTerrainAffected(u8 battler, u32 terrainFlag);
u32 GetBattlerFriendshipScore(u8 battler);
u32 CountBattlerStatIncreases(u8 battler, bool32 countEvasionAcc);
bool32 IsMyceliumMightOnField(void);
bool8 ChangeTypeBasedOnTerrain(u8 battlerId);
void RemoveConfusionStatus(u8 battlerId);
u8 GetBattlerGender(u8 battlerId);
bool8 ChangeTypeBasedOnTerrain(u8 battler);
void RemoveConfusionStatus(u8 battler);
u8 GetBattlerGender(u8 battler);
bool8 AreBattlersOfOppositeGender(u8 battler1, u8 battler2);
u32 CalcSecondaryEffectChance(u8 battlerId, u8 secondaryEffectChance);
u32 CalcSecondaryEffectChance(u8 battler, u8 secondaryEffectChance);
#endif // GUARD_BATTLE_UTIL_H

View File

@ -14,18 +14,18 @@ struct SignatureZMove
};
bool8 IsZMove(u16 move);
void QueueZMove(u8 battlerId, u16 baseMove);
bool32 IsViableZMove(u8 battlerId, u16 move);
bool32 TryChangeZIndicator(u8 battlerId, u8 moveIndex);
void QueueZMove(u8 battler, u16 baseMove);
bool32 IsViableZMove(u8 battler, u16 move);
bool32 TryChangeZIndicator(u8 battler, u8 moveIndex);
void CreateZMoveTriggerSprite(u8, bool8);
void HideZMoveTriggerSprite(void);
bool32 IsZMoveTriggerSpriteActive(void);
void DestroyZMoveTriggerSprite(void);
bool32 MoveSelectionDisplayZMove(u16 zmove);
bool32 MoveSelectionDisplayZMove(u16 zmove, u32 battler);
const u8 *GetZMoveName(u16 move);
void SetZEffect(void);
bool32 IsZMoveUsable(u8 battlerId, u16 moveIndex);
void GetUsableZMoves(u8 battlerId, u16 *moves);
bool32 IsZMoveUsable(u8 battler, u16 moveIndex);
void GetUsableZMoves(u8 battler, u16 *moves);
u16 GetZMovePower(u16 move);
#endif // GUARD_BATTLE_Z_MOVE_H

View File

@ -70,13 +70,13 @@ void PlayRecordedBattle(void (*CB2_After)(void));
u8 GetRecordedBattleFrontierFacility(void);
u8 GetRecordedBattleFronterBrainSymbol(void);
void RecordedBattle_SaveParties(void);
u8 GetActiveBattlerLinkPlayerGender(void);
u8 GetBattlerLinkPlayerGender(u32 battler);
void RecordedBattle_ClearFrontierPassFlag(void);
void RecordedBattle_SetFrontierPassFlagFromHword(u16 flags);
u8 RecordedBattle_GetFrontierPassFlag(void);
u8 GetBattleSceneInRecordedBattle(void);
u8 GetTextSpeedInRecordedBattle(void);
void RecordedBattle_CopyBattlerMoves(void);
void RecordedBattle_CopyBattlerMoves(u32 battler);
void RecordedBattle_CheckMovesetChanges(u8 mode);
u32 GetAiScriptsInRecordedBattle(void);
void RecordedBattle_SetPlaybackFinished(void);

View File

@ -184,7 +184,7 @@ void BattleAI_SetupFlags(void)
}
// sBattler_AI set in ComputeBattleAiScores
void BattleAI_SetupAIData(u8 defaultScoreMoves)
void BattleAI_SetupAIData(u8 defaultScoreMoves, u32 battler)
{
s32 i, move, dmg;
u8 moveLimitations;
@ -434,13 +434,11 @@ static u8 ChooseMoveOrAction_Singles(void)
if (AI_THINKING_STRUCT->aiAction & AI_ACTION_WATCH)
return AI_CHOICE_WATCH;
gActiveBattler = sBattler_AI;
// If can switch.
if (CountUsablePartyMons(sBattler_AI) > 0
&& !IsAbilityPreventingEscape(sBattler_AI)
&& !(gBattleMons[gActiveBattler].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION))
&& !(gStatuses3[gActiveBattler] & STATUS3_ROOTED)
&& !(gBattleMons[sBattler_AI].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION))
&& !(gStatuses3[sBattler_AI] & STATUS3_ROOTED)
&& !(gBattleTypeFlags & (BATTLE_TYPE_ARENA | BATTLE_TYPE_PALACE))
&& AI_THINKING_STRUCT->aiFlags & (AI_FLAG_CHECK_VIABILITY | AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_TRY_TO_FAINT | AI_FLAG_PREFER_BATON_PASS))
{

View File

@ -863,7 +863,7 @@ static void HandleInputChooseMove(u32 battler)
//TODO: brighten z move symbol
PlaySE(SE_SELECT);
if (!gBattleStruct->zmove.viewing)
MoveSelectionDisplayZMove(gBattleStruct->zmove.chosenZMove);
MoveSelectionDisplayZMove(gBattleStruct->zmove.chosenZMove, battler);
else
ReloadMoveNames(battler);
}
@ -1638,7 +1638,7 @@ static void MoveSelectionDisplayPpNumber(u32 battler)
if (gBattleResources->bufferA[battler][2] == TRUE) // check if we didn't want to display pp number
return;
SetPpNumbersPaletteInMoveSelection();
SetPpNumbersPaletteInMoveSelection(battler);
moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[battler][4]);
txtPtr = ConvertIntToDecimalStringN(gDisplayedStringBattle, moveInfo->currentPp[gMoveSelectionCursor[battler]], STR_CONV_MODE_RIGHT_ALIGN, 2);
*(txtPtr)++ = CHAR_SLASH;

View File

@ -404,7 +404,7 @@ static void RecordedOpponentHandleDrawTrainerPic(u32 battler)
}
else
{
trainerPicId = PlayerGenderToFrontTrainerPicId(GetActiveBattlerLinkPlayerGender());
trainerPicId = PlayerGenderToFrontTrainerPicId(GetBattlerLinkPlayerGender(battler));
}
}
else
@ -442,7 +442,7 @@ static void RecordedOpponentHandlePrintString(u32 battler)
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
stringId = (u16 *)(&gBattleResources->bufferA[battler][2]);
BufferStringBattle(*stringId);
BufferStringBattle(*stringId, battler);
if (gTestRunnerEnabled)
{

View File

@ -374,7 +374,7 @@ static void RecordedPlayerHandleDrawTrainerPic(u32 battler)
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK)
{
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
trainerPicId = GetActiveBattlerLinkPlayerGender();
trainerPicId = GetBattlerLinkPlayerGender(battler);
else
trainerPicId = gLinkPlayers[gRecordedBattleMultiplayerId].gender;
}
@ -432,7 +432,7 @@ static void RecordedPlayerHandlePrintString(u32 battler)
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
stringId = (u16 *)(&gBattleResources->bufferA[battler][2]);
BufferStringBattle(*stringId);
BufferStringBattle(*stringId, battler);
if (gTestRunnerEnabled)
{

View File

@ -670,13 +670,13 @@ static void SetBattlePartyIds(void)
}
}
static void PrepareBufferDataTransfer(u32 battlerId, u32 bufferId, u8 *data, u16 size)
static void PrepareBufferDataTransfer(u32 battler, u32 bufferId, u8 *data, u16 size)
{
s32 i;
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
PrepareBufferDataTransferLink(battlerId, bufferId, size, data);
PrepareBufferDataTransferLink(battler, bufferId, size, data);
}
else
{
@ -684,11 +684,11 @@ static void PrepareBufferDataTransfer(u32 battlerId, u32 bufferId, u8 *data, u16
{
case BUFFER_A:
for (i = 0; i < size; data++, i++)
gBattleResources->bufferA[battlerId][i] = *data;
gBattleResources->bufferA[battler][i] = *data;
break;
case BUFFER_B:
for (i = 0; i < size; data++, i++)
gBattleResources->bufferB[battlerId][i] = *data;
gBattleResources->bufferB[battler][i] = *data;
break;
}
}
@ -723,7 +723,7 @@ enum
LINK_BUFF_DATA,
};
void PrepareBufferDataTransferLink(u32 battlerId, u32 bufferId, u16 size, u8 *data)
void PrepareBufferDataTransferLink(u32 battler, u32 bufferId, u16 size, u8 *data)
{
s32 alignedSize;
s32 i;
@ -735,7 +735,7 @@ void PrepareBufferDataTransferLink(u32 battlerId, u32 bufferId, u16 size, u8 *da
gTasks[sLinkSendTaskId].data[14] = 0;
}
gLinkBattleSendBuffer[gTasks[sLinkSendTaskId].data[14] + LINK_BUFF_BUFFER_ID] = bufferId;
gLinkBattleSendBuffer[gTasks[sLinkSendTaskId].data[14] + LINK_BUFF_ACTIVE_BATTLER] = battlerId;
gLinkBattleSendBuffer[gTasks[sLinkSendTaskId].data[14] + LINK_BUFF_ACTIVE_BATTLER] = battler;
gLinkBattleSendBuffer[gTasks[sLinkSendTaskId].data[14] + LINK_BUFF_ATTACKER] = gBattlerAttacker;
gLinkBattleSendBuffer[gTasks[sLinkSendTaskId].data[14] + LINK_BUFF_TARGET] = gBattlerTarget;
gLinkBattleSendBuffer[gTasks[sLinkSendTaskId].data[14] + LINK_BUFF_SIZE_LO] = alignedSize;
@ -2562,19 +2562,19 @@ void BtlController_HandleTrainerSlide(u32 battler, u32 trainerPicId)
#undef sSpeedX
void BtlController_HandleTrainerSlideBack(u32 battlerId, s16 data0, bool32 startAnim)
void BtlController_HandleTrainerSlideBack(u32 battler, s16 data0, bool32 startAnim)
{
u32 side = GetBattlerSide(battlerId);
u32 side = GetBattlerSide(battler);
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[battlerId]]);
gSprites[gBattlerSpriteIds[battlerId]].data[0] = data0;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = (side == B_SIDE_PLAYER) ? -40 : 280;
gSprites[gBattlerSpriteIds[battlerId]].data[4] = gSprites[gBattlerSpriteIds[battlerId]].y;
gSprites[gBattlerSpriteIds[battlerId]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[battlerId]], SpriteCallbackDummy);
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[battler]]);
gSprites[gBattlerSpriteIds[battler]].data[0] = data0;
gSprites[gBattlerSpriteIds[battler]].data[2] = (side == B_SIDE_PLAYER) ? -40 : 280;
gSprites[gBattlerSpriteIds[battler]].data[4] = gSprites[gBattlerSpriteIds[battler]].y;
gSprites[gBattlerSpriteIds[battler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[battler]], SpriteCallbackDummy);
if (startAnim)
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], 1);
gBattlerControllerFuncs[battlerId] = Controller_HandleTrainerSlideBack;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], 1);
gBattlerControllerFuncs[battler] = Controller_HandleTrainerSlideBack;
}
#define sSpeedX data[1]
@ -2667,7 +2667,7 @@ void BtlController_HandlePrintString(u32 battler, bool32 updateTvData, bool32 ar
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
stringId = (u16 *)(&gBattleResources->bufferA[battler][2]);
BufferStringBattle(*stringId);
BufferStringBattle(*stringId, battler);
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MSG);
gBattlerControllerFuncs[battler] = Controller_WaitForString;
if (updateTvData)

View File

@ -764,7 +764,7 @@ static void SetAllPlayersBerryData(void)
{
s32 numPlayers;
struct BattleEnigmaBerry *src;
u8 battlerId;
u8 battler;
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{
@ -776,17 +776,17 @@ static void SetAllPlayersBerryData(void)
for (i = 0; i < numPlayers; i++)
{
src = (struct BattleEnigmaBerry *)(gBlockRecvBuffer[i] + 2);
battlerId = gLinkPlayers[i].id;
battler = gLinkPlayers[i].id;
for (j = 0; j < BERRY_NAME_LENGTH; j++)
gEnigmaBerries[battlerId].name[j] = src->name[j];
gEnigmaBerries[battlerId].name[j] = EOS;
gEnigmaBerries[battler].name[j] = src->name[j];
gEnigmaBerries[battler].name[j] = EOS;
for (j = 0; j < BERRY_ITEM_EFFECT_COUNT; j++)
gEnigmaBerries[battlerId].itemEffect[j] = src->itemEffect[j];
gEnigmaBerries[battler].itemEffect[j] = src->itemEffect[j];
gEnigmaBerries[battlerId].holdEffect = src->holdEffect;
gEnigmaBerries[battlerId].holdEffectParam = src->holdEffectParam;
gEnigmaBerries[battler].holdEffect = src->holdEffect;
gEnigmaBerries[battler].holdEffectParam = src->holdEffectParam;
}
}
else
@ -3000,7 +3000,6 @@ void BeginBattleIntro(void)
static void BattleMainCB1(void)
{
gBattleMainFunc();
for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++)
gBattlerControllerFuncs[gActiveBattler](gActiveBattler);
}
@ -4079,7 +4078,7 @@ static void HandleTurnActionSelectionState(void)
switch (gBattleCommunication[gActiveBattler])
{
case STATE_TURN_START_RECORD: // Recorded battle related action on start of every turn.
RecordedBattle_CopyBattlerMoves();
RecordedBattle_CopyBattlerMoves(gActiveBattler);
gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN;
// Do AI score computations here so we can use them in AI_TrySwitchOrUseItem
@ -4140,7 +4139,7 @@ static void HandleTurnActionSelectionState(void)
switch (gBattleResources->bufferB[gActiveBattler][1])
{
case B_ACTION_USE_MOVE:
if (AreAllMovesUnusable())
if (AreAllMovesUnusable(gActiveBattler))
{
gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT;
*(gBattleStruct->selectionScriptFinished + gActiveBattler) = FALSE;
@ -4356,7 +4355,7 @@ static void HandleTurnActionSelectionState(void)
gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN;
RecordedBattle_ClearBattlerAction(gActiveBattler, 1);
}
else if (TrySetCantSelectMoveBattleScript())
else if (TrySetCantSelectMoveBattleScript(gActiveBattler))
{
RecordedBattle_ClearBattlerAction(gActiveBattler, 1);
gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT;
@ -4598,12 +4597,12 @@ void SwapTurnOrder(u8 id1, u8 id2)
SWAP(gBattlerByTurnOrder[id1], gBattlerByTurnOrder[id2], temp);
}
u32 GetBattlerTotalSpeedStat(u8 battlerId)
u32 GetBattlerTotalSpeedStat(u8 battler)
{
u32 speed = gBattleMons[battlerId].speed;
u32 ability = GetBattlerAbility(battlerId);
u32 holdEffect = GetBattlerHoldEffect(battlerId, TRUE);
u32 highestStat = GetHighestStatId(battlerId);
u32 speed = gBattleMons[battler].speed;
u32 ability = GetBattlerAbility(battler);
u32 holdEffect = GetBattlerHoldEffect(battler, TRUE);
u32 highestStat = GetHighestStatId(battler);
// weather abilities
if (WEATHER_HAS_EFFECT)
@ -4619,11 +4618,11 @@ u32 GetBattlerTotalSpeedStat(u8 battlerId)
}
// other abilities
if (ability == ABILITY_QUICK_FEET && gBattleMons[battlerId].status1 & STATUS1_ANY)
if (ability == ABILITY_QUICK_FEET && gBattleMons[battler].status1 & STATUS1_ANY)
speed = (speed * 150) / 100;
else if (ability == ABILITY_SURGE_SURFER && gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN)
speed *= 2;
else if (ability == ABILITY_SLOW_START && gDisableStructs[battlerId].slowStartTimer != 0)
else if (ability == ABILITY_SLOW_START && gDisableStructs[battler].slowStartTimer != 0)
speed /= 2;
else if (ability == ABILITY_PROTOSYNTHESIS && gBattleWeather & B_WEATHER_SUN && highestStat == STAT_SPEED)
speed = (speed * 150) / 100;
@ -4631,13 +4630,13 @@ u32 GetBattlerTotalSpeedStat(u8 battlerId)
speed = (speed * 150) / 100;
// stat stages
speed *= gStatStageRatios[gBattleMons[battlerId].statStages[STAT_SPEED]][0];
speed /= gStatStageRatios[gBattleMons[battlerId].statStages[STAT_SPEED]][1];
speed *= gStatStageRatios[gBattleMons[battler].statStages[STAT_SPEED]][0];
speed /= gStatStageRatios[gBattleMons[battler].statStages[STAT_SPEED]][1];
// player's badge boost
if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_FRONTIER))
&& ShouldGetStatBadgeBoost(FLAG_BADGE03_GET, battlerId)
&& GetBattlerSide(battlerId) == B_SIDE_PLAYER)
&& ShouldGetStatBadgeBoost(FLAG_BADGE03_GET, battler)
&& GetBattlerSide(battler) == B_SIDE_PLAYER)
{
speed = (speed * 110) / 100;
}
@ -4649,17 +4648,17 @@ u32 GetBattlerTotalSpeedStat(u8 battlerId)
speed /= 2;
else if (holdEffect == HOLD_EFFECT_CHOICE_SCARF)
speed = (speed * 150) / 100;
else if (holdEffect == HOLD_EFFECT_QUICK_POWDER && gBattleMons[battlerId].species == SPECIES_DITTO && !(gBattleMons[battlerId].status2 & STATUS2_TRANSFORMED))
else if (holdEffect == HOLD_EFFECT_QUICK_POWDER && gBattleMons[battler].species == SPECIES_DITTO && !(gBattleMons[battler].status2 & STATUS2_TRANSFORMED))
speed *= 2;
// various effects
if (gSideStatuses[GET_BATTLER_SIDE(battlerId)] & SIDE_STATUS_TAILWIND)
if (gSideStatuses[GET_BATTLER_SIDE(battler)] & SIDE_STATUS_TAILWIND)
speed *= 2;
if (gBattleResources->flags->flags[battlerId] & RESOURCE_FLAG_UNBURDEN)
if (gBattleResources->flags->flags[battler] & RESOURCE_FLAG_UNBURDEN)
speed *= 2;
// paralysis drop
if (gBattleMons[battlerId].status1 & STATUS1_PARALYSIS && ability != ABILITY_QUICK_FEET)
if (gBattleMons[battler].status1 & STATUS1_PARALYSIS && ability != ABILITY_QUICK_FEET)
#if B_PARALYSIS_SPEED >= GEN_7
speed /= 2;
#else
@ -4669,28 +4668,28 @@ u32 GetBattlerTotalSpeedStat(u8 battlerId)
return speed;
}
s8 GetChosenMovePriority(u32 battlerId)
s8 GetChosenMovePriority(u32 battler)
{
u16 move;
gProtectStructs[battlerId].pranksterElevated = 0;
if (gProtectStructs[battlerId].noValidMoves)
gProtectStructs[battler].pranksterElevated = 0;
if (gProtectStructs[battler].noValidMoves)
move = MOVE_STRUGGLE;
else
move = gBattleMons[battlerId].moves[*(gBattleStruct->chosenMovePositions + battlerId)];
move = gBattleMons[battler].moves[*(gBattleStruct->chosenMovePositions + battler)];
return GetMovePriority(battlerId, move);
return GetMovePriority(battler, move);
}
s8 GetMovePriority(u32 battlerId, u16 move)
s8 GetMovePriority(u32 battler, u16 move)
{
s8 priority;
u16 ability = GetBattlerAbility(battlerId);
u16 ability = GetBattlerAbility(battler);
priority = gBattleMoves[move].priority;
if (ability == ABILITY_GALE_WINGS
#if B_GALE_WINGS >= GEN_7
&& BATTLER_MAX_HP(battlerId)
&& BATTLER_MAX_HP(battler)
#endif
&& gBattleMoves[move].type == TYPE_FLYING)
{
@ -4698,10 +4697,10 @@ s8 GetMovePriority(u32 battlerId, u16 move)
}
else if (ability == ABILITY_PRANKSTER && IS_MOVE_STATUS(move))
{
gProtectStructs[battlerId].pranksterElevated = 1;
gProtectStructs[battler].pranksterElevated = 1;
priority++;
}
else if (gBattleMoves[move].effect == EFFECT_GRASSY_GLIDE && gFieldStatuses & STATUS_FIELD_GRASSY_TERRAIN && IsBattlerGrounded(battlerId))
else if (gBattleMoves[move].effect == EFFECT_GRASSY_GLIDE && gFieldStatuses & STATUS_FIELD_GRASSY_TERRAIN && IsBattlerGrounded(battler))
{
priority++;
}
@ -4727,7 +4726,7 @@ s8 GetMovePriority(u32 battlerId, u16 move)
}
}
if (gProtectStructs[battlerId].quash)
if (gProtectStructs[battler].quash)
priority = -8;
return priority;
@ -4838,14 +4837,14 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves)
static void SetActionsAndBattlersTurnOrder(void)
{
s32 turnOrderId = 0;
s32 i, j;
s32 i, j, battler;
if (gBattleTypeFlags & BATTLE_TYPE_SAFARI)
{
for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++)
for (battler = 0; battler < gBattlersCount; battler++)
{
gActionsByTurnOrder[turnOrderId] = gChosenActionByBattler[gActiveBattler];
gBattlerByTurnOrder[turnOrderId] = gActiveBattler;
gActionsByTurnOrder[turnOrderId] = gChosenActionByBattler[battler];
gBattlerByTurnOrder[turnOrderId] = battler;
turnOrderId++;
}
}
@ -4853,9 +4852,9 @@ static void SetActionsAndBattlersTurnOrder(void)
{
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++)
for (battler = 0; battler < gBattlersCount; battler++)
{
if (gChosenActionByBattler[gActiveBattler] == B_ACTION_RUN)
if (gChosenActionByBattler[battler] == B_ACTION_RUN)
{
turnOrderId = 5;
break;
@ -4866,24 +4865,24 @@ static void SetActionsAndBattlersTurnOrder(void)
{
if (gChosenActionByBattler[0] == B_ACTION_RUN)
{
gActiveBattler = 0;
battler = 0;
turnOrderId = 5;
}
if (gChosenActionByBattler[2] == B_ACTION_RUN)
{
gActiveBattler = 2;
battler = 2;
turnOrderId = 5;
}
}
if (turnOrderId == 5) // One of battlers wants to run.
{
gActionsByTurnOrder[0] = gChosenActionByBattler[gActiveBattler];
gBattlerByTurnOrder[0] = gActiveBattler;
gActionsByTurnOrder[0] = gChosenActionByBattler[battler];
gBattlerByTurnOrder[0] = battler;
turnOrderId = 1;
for (i = 0; i < gBattlersCount; i++)
{
if (i != gActiveBattler)
if (i != battler)
{
gActionsByTurnOrder[turnOrderId] = gChosenActionByBattler[i];
gBattlerByTurnOrder[turnOrderId] = i;
@ -4893,25 +4892,25 @@ static void SetActionsAndBattlersTurnOrder(void)
}
else
{
for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++)
for (battler = 0; battler < gBattlersCount; battler++)
{
if (gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_ITEM
|| gChosenActionByBattler[gActiveBattler] == B_ACTION_SWITCH
|| gChosenActionByBattler[gActiveBattler] == B_ACTION_THROW_BALL)
if (gChosenActionByBattler[battler] == B_ACTION_USE_ITEM
|| gChosenActionByBattler[battler] == B_ACTION_SWITCH
|| gChosenActionByBattler[battler] == B_ACTION_THROW_BALL)
{
gActionsByTurnOrder[turnOrderId] = gChosenActionByBattler[gActiveBattler];
gBattlerByTurnOrder[turnOrderId] = gActiveBattler;
gActionsByTurnOrder[turnOrderId] = gChosenActionByBattler[battler];
gBattlerByTurnOrder[turnOrderId] = battler;
turnOrderId++;
}
}
for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++)
for (battler = 0; battler < gBattlersCount; battler++)
{
if (gChosenActionByBattler[gActiveBattler] != B_ACTION_USE_ITEM
&& gChosenActionByBattler[gActiveBattler] != B_ACTION_SWITCH
&& gChosenActionByBattler[gActiveBattler] != B_ACTION_THROW_BALL)
if (gChosenActionByBattler[battler] != B_ACTION_USE_ITEM
&& gChosenActionByBattler[battler] != B_ACTION_SWITCH
&& gChosenActionByBattler[battler] != B_ACTION_THROW_BALL)
{
gActionsByTurnOrder[turnOrderId] = gChosenActionByBattler[gActiveBattler];
gBattlerByTurnOrder[turnOrderId] = gActiveBattler;
gActionsByTurnOrder[turnOrderId] = gChosenActionByBattler[battler];
gBattlerByTurnOrder[turnOrderId] = battler;
turnOrderId++;
}
}
@ -5046,8 +5045,8 @@ static bool32 TryDoMoveEffectsBeforeMoves(void)
&& !(gProtectStructs[battlers[i]].noValidMoves))
{
gBattleStruct->focusPunchBattlers |= gBitTable[battlers[i]];
gActiveBattler = gBattlerAttacker = battlers[i];
switch (gChosenMoveByBattler[gActiveBattler])
gBattlerAttacker = battlers[i];
switch (gChosenMoveByBattler[gBattlerAttacker])
{
case MOVE_FOCUS_PUNCH:
BattleScriptExecute(BattleScript_FocusPunchSetUp);
@ -5089,44 +5088,44 @@ static void TryChangeTurnOrder(void)
static void CheckQuickClaw_CustapBerryActivation(void)
{
u32 i;
u32 i, battler;
if (!(gHitMarker & HITMARKER_RUN))
{
while (gBattleStruct->quickClawBattlerId < gBattlersCount)
{
gActiveBattler = gBattlerAttacker = gBattleStruct->quickClawBattlerId;
battler = gBattlerAttacker = gBattleStruct->quickClawBattlerId;
gBattleStruct->quickClawBattlerId++;
if (gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_MOVE
&& gChosenMoveByBattler[gActiveBattler] != MOVE_FOCUS_PUNCH // quick claw message doesn't need to activate here
&& (gProtectStructs[gActiveBattler].usedCustapBerry || gProtectStructs[gActiveBattler].quickDraw)
&& !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP)
if (gChosenActionByBattler[battler] == B_ACTION_USE_MOVE
&& gChosenMoveByBattler[battler] != MOVE_FOCUS_PUNCH // quick claw message doesn't need to activate here
&& (gProtectStructs[battler].usedCustapBerry || gProtectStructs[battler].quickDraw)
&& !(gBattleMons[battler].status1 & STATUS1_SLEEP)
&& !(gDisableStructs[gBattlerAttacker].truantCounter)
&& !(gProtectStructs[gActiveBattler].noValidMoves))
&& !(gProtectStructs[battler].noValidMoves))
{
if (gProtectStructs[gActiveBattler].usedCustapBerry)
if (gProtectStructs[battler].usedCustapBerry)
{
gProtectStructs[gActiveBattler].usedCustapBerry = FALSE;
gLastUsedItem = gBattleMons[gActiveBattler].item;
gProtectStructs[battler].usedCustapBerry = FALSE;
gLastUsedItem = gBattleMons[battler].item;
PREPARE_ITEM_BUFFER(gBattleTextBuff1, gLastUsedItem);
if (GetBattlerHoldEffect(gActiveBattler, FALSE) == HOLD_EFFECT_CUSTAP_BERRY)
if (GetBattlerHoldEffect(battler, FALSE) == HOLD_EFFECT_CUSTAP_BERRY)
{
// don't record berry since its gone now
BattleScriptExecute(BattleScript_CustapBerryActivation);
}
else
{
RecordItemEffectBattle(gActiveBattler, GetBattlerHoldEffect(gActiveBattler, FALSE));
RecordItemEffectBattle(battler, GetBattlerHoldEffect(battler, FALSE));
BattleScriptExecute(BattleScript_QuickClawActivation);
}
}
else if (gProtectStructs[gActiveBattler].quickDraw)
else if (gProtectStructs[battler].quickDraw)
{
gBattlerAbility = gActiveBattler;
gProtectStructs[gActiveBattler].quickDraw = FALSE;
gLastUsedAbility = gBattleMons[gActiveBattler].ability;
gBattlerAbility = battler;
gProtectStructs[battler].quickDraw = FALSE;
gLastUsedAbility = gBattleMons[battler].ability;
PREPARE_ABILITY_BUFFER(gBattleTextBuff1, gLastUsedAbility);
RecordAbilityBattle(gActiveBattler, gLastUsedAbility);
RecordAbilityBattle(battler, gLastUsedAbility);
BattleScriptExecute(BattleScript_QuickDrawActivation);
}
return;
@ -5179,7 +5178,7 @@ static void RunTurnActionsFunctions(void)
}
else
{
if (gBattleStruct->savedTurnActionNumber != gCurrentTurnActionNumber) // action turn has been done, clear hitmarker bits for another battlerId
if (gBattleStruct->savedTurnActionNumber != gCurrentTurnActionNumber) // action turn has been done, clear hitmarker bits for another battler
{
gHitMarker &= ~HITMARKER_NO_ATTACKSTRING;
gHitMarker &= ~HITMARKER_UNABLE_TO_USE_MOVE;
@ -5698,20 +5697,20 @@ void SetTypeBeforeUsingMove(u16 move, u8 battlerAtk)
// special to set a field's totem boost(s)
// inputs:
// var8000: battlerId
// var8000: battler
// var8001 - var8007: stat changes
void SetTotemBoost(void)
{
u8 battlerId = gSpecialVar_0x8000;
u8 battler = gSpecialVar_0x8000;
u8 i;
for (i = 0; i < (NUM_BATTLE_STATS - 1); i++)
{
if (*(&gSpecialVar_0x8001 + i))
{
gTotemBoosts[battlerId].stats |= (1 << i);
gTotemBoosts[battlerId].statChanges[i] = *(&gSpecialVar_0x8001 + i);
gTotemBoosts[battlerId].stats |= 0x80; // used as a flag for the "totem flared to life" script
gTotemBoosts[battler].stats |= (1 << i);
gTotemBoosts[battler].statChanges[i] = *(&gSpecialVar_0x8001 + i);
gTotemBoosts[battler].stats |= 0x80; // used as a flag for the "totem flared to life" script
}
}
}

View File

@ -2631,12 +2631,12 @@ static const struct BattleWindowText *const sBattleTextOnWindowsInfo[] =
static const u8 sRecordedBattleTextSpeeds[] = {8, 4, 1, 0};
void BufferStringBattle(u16 stringID)
void BufferStringBattle(u16 stringID, u32 battler)
{
s32 i;
const u8 *stringPtr = NULL;
gBattleMsgDataPtr = (struct BattleMsgData *)(&gBattleResources->bufferA[gActiveBattler][4]);
gBattleMsgDataPtr = (struct BattleMsgData *)(&gBattleResources->bufferA[battler][4]);
gLastUsedItem = gBattleMsgDataPtr->lastItem;
gLastUsedAbility = gBattleMsgDataPtr->lastAbility;
gBattleScripting.battler = gBattleMsgDataPtr->scrActive;
@ -2709,9 +2709,9 @@ void BufferStringBattle(u16 stringID)
}
break;
case STRINGID_INTROSENDOUT: // poke first send-out
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
{
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && IsValidForBattle(&gPlayerParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]]))
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && IsValidForBattle(&gPlayerParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]]))
{
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
stringPtr = sText_InGamePartnerSentOutZGoN;
@ -2729,7 +2729,7 @@ void BufferStringBattle(u16 stringID)
}
else
{
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]]))
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]]))
{
if (BATTLE_TWO_VS_ONE_OPPONENT)
stringPtr = sText_Trainer1SentOutTwoPkmn;
@ -2756,7 +2756,7 @@ void BufferStringBattle(u16 stringID)
}
break;
case STRINGID_RETURNMON: // sending poke to ball msg
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
{
if (*(&gBattleStruct->hpScale) == 0)
stringPtr = sText_PkmnThatsEnough;
@ -2845,7 +2845,7 @@ void BufferStringBattle(u16 stringID)
if (gBattleTextBuff1[0] & B_OUTCOME_LINK_BATTLE_RAN)
{
gBattleTextBuff1[0] &= ~(B_OUTCOME_LINK_BATTLE_RAN);
if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT && gBattleTextBuff1[0] != B_OUTCOME_DREW)
if (GetBattlerSide(battler) == B_SIDE_OPPONENT && gBattleTextBuff1[0] != B_OUTCOME_DREW)
gBattleTextBuff1[0] ^= (B_OUTCOME_LOST | B_OUTCOME_WON);
if (gBattleTextBuff1[0] == B_OUTCOME_LOST || gBattleTextBuff1[0] == B_OUTCOME_DREW)
@ -2857,7 +2857,7 @@ void BufferStringBattle(u16 stringID)
}
else
{
if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT && gBattleTextBuff1[0] != B_OUTCOME_DREW)
if (GetBattlerSide(battler) == B_SIDE_OPPONENT && gBattleTextBuff1[0] != B_OUTCOME_DREW)
gBattleTextBuff1[0] ^= (B_OUTCOME_LOST | B_OUTCOME_WON);
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
@ -2964,24 +2964,24 @@ static const u8 *TryGetStatusString(u8 *src)
return NULL;
}
static void GetBattlerNick(u32 battlerId, u8 *dst)
static void GetBattlerNick(u32 battler, u8 *dst)
{
struct Pokemon *mon, *illusionMon;
if (GET_BATTLER_SIDE(battlerId) == B_SIDE_PLAYER)
mon = &gPlayerParty[gBattlerPartyIndexes[battlerId]];
if (GET_BATTLER_SIDE(battler) == B_SIDE_PLAYER)
mon = &gPlayerParty[gBattlerPartyIndexes[battler]];
else
mon = &gEnemyParty[gBattlerPartyIndexes[battlerId]];
mon = &gEnemyParty[gBattlerPartyIndexes[battler]];
illusionMon = GetIllusionMonPtr(battlerId);
illusionMon = GetIllusionMonPtr(battler);
if (illusionMon != NULL)
mon = illusionMon;
GetMonData(mon, MON_DATA_NICKNAME, dst);
StringGet_Nickname(dst);
}
#define HANDLE_NICKNAME_STRING_CASE(battlerId) \
if (GetBattlerSide(battlerId) != B_SIDE_PLAYER) \
#define HANDLE_NICKNAME_STRING_CASE(battler) \
if (GetBattlerSide(battler) != B_SIDE_PLAYER) \
{ \
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) \
toCpy = sText_FoePkmnPrefix; \
@ -2994,10 +2994,10 @@ static void GetBattlerNick(u32 battlerId, u8 *dst)
toCpy++; \
} \
} \
GetBattlerNick(battlerId, text); \
GetBattlerNick(battler, text); \
toCpy = text;
static const u8 *BattleStringGetOpponentNameByTrainerId(u16 trainerId, u8 *text, u8 multiplayerId, u8 battlerId)
static const u8 *BattleStringGetOpponentNameByTrainerId(u16 trainerId, u8 *text, u8 multiplayerId, u8 battler)
{
const u8 *toCpy;
@ -3017,9 +3017,9 @@ static const u8 *BattleStringGetOpponentNameByTrainerId(u16 trainerId, u8 *text,
else if (trainerId == TRAINER_LINK_OPPONENT)
{
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
toCpy = gLinkPlayers[GetBattlerMultiplayerId(battlerId)].name;
toCpy = gLinkPlayers[GetBattlerMultiplayerId(battler)].name;
else
toCpy = gLinkPlayers[GetBattlerMultiplayerId(battlerId) & BIT_SIDE].name;
toCpy = gLinkPlayers[GetBattlerMultiplayerId(battler) & BIT_SIDE].name;
}
else if (trainerId == TRAINER_FRONTIER_BRAIN)
{
@ -3049,31 +3049,31 @@ static const u8 *BattleStringGetOpponentNameByTrainerId(u16 trainerId, u8 *text,
return toCpy;
}
static const u8 *BattleStringGetOpponentName(u8 *text, u8 multiplayerId, u8 battlerId)
static const u8 *BattleStringGetOpponentName(u8 *text, u8 multiplayerId, u8 battler)
{
const u8 *toCpy;
switch (GetBattlerPosition(battlerId))
switch (GetBattlerPosition(battler))
{
case B_POSITION_OPPONENT_LEFT:
toCpy = BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_A, text, multiplayerId, battlerId);
toCpy = BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_A, text, multiplayerId, battler);
break;
case B_POSITION_OPPONENT_RIGHT:
if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_MULTI) && !BATTLE_TWO_VS_ONE_OPPONENT)
toCpy = BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_B, text, multiplayerId, battlerId);
toCpy = BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_B, text, multiplayerId, battler);
else
toCpy = BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_A, text, multiplayerId, battlerId);
toCpy = BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_A, text, multiplayerId, battler);
break;
}
return toCpy;
}
static const u8 *BattleStringGetPlayerName(u8 *text, u8 battlerId)
static const u8 *BattleStringGetPlayerName(u8 *text, u8 battler)
{
const u8 *toCpy;
switch (GetBattlerPosition(battlerId))
switch (GetBattlerPosition(battler))
{
case B_POSITION_PLAYER_LEFT:
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED)
@ -3105,12 +3105,12 @@ static const u8 *BattleStringGetPlayerName(u8 *text, u8 battlerId)
return toCpy;
}
static const u8 *BattleStringGetTrainerName(u8 *text, u8 multiplayerId, u8 battlerId)
static const u8 *BattleStringGetTrainerName(u8 *text, u8 multiplayerId, u8 battler)
{
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
return BattleStringGetPlayerName(text, battlerId);
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
return BattleStringGetPlayerName(text, battler);
else
return BattleStringGetOpponentName(text, multiplayerId, battlerId);
return BattleStringGetOpponentName(text, multiplayerId, battler);
}
static const u8 *BattleStringGetOpponentClassByTrainerId(u16 trainerId)
@ -3248,7 +3248,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst)
GetBattlerNick(gActiveBattler, text);
toCpy = text;
break;
case B_TXT_ACTIVE_NAME2: // active battlerId name with prefix, no illusion
case B_TXT_ACTIVE_NAME2: // active battler name with prefix, no illusion
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_NICKNAME, text);
else
@ -3256,13 +3256,13 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst)
StringGet_Nickname(text);
toCpy = text;
break;
case B_TXT_EFF_NAME_WITH_PREFIX: // effect battlerId name with prefix
case B_TXT_EFF_NAME_WITH_PREFIX: // effect battler name with prefix
HANDLE_NICKNAME_STRING_CASE(gEffectBattler)
break;
case B_TXT_ACTIVE_NAME_WITH_PREFIX: // active battlerId name with prefix
case B_TXT_ACTIVE_NAME_WITH_PREFIX: // active battler name with prefix
HANDLE_NICKNAME_STRING_CASE(gActiveBattler)
break;
case B_TXT_SCR_ACTIVE_NAME_WITH_PREFIX: // scripting active battlerId name with prefix
case B_TXT_SCR_ACTIVE_NAME_WITH_PREFIX: // scripting active battler name with prefix
HANDLE_NICKNAME_STRING_CASE(gBattleScripting.battler)
break;
case B_TXT_CURRENT_MOVE: // current move name
@ -3336,7 +3336,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst)
case B_TXT_SCR_ACTIVE_ABILITY: // scripting active ability
toCpy = gAbilityNames[sBattlerAbilities[gBattleScripting.battler]];
break;
case B_TXT_EFF_ABILITY: // effect battlerId ability
case B_TXT_EFF_ABILITY: // effect battler ability
toCpy = gAbilityNames[sBattlerAbilities[gEffectBattler]];
break;
case B_TXT_TRAINER1_CLASS: // trainer class name
@ -3575,7 +3575,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst)
return dstID;
}
static void IllusionNickHack(u32 battlerId, u32 partyId, u8 *dst)
static void IllusionNickHack(u32 battler, u32 partyId, u8 *dst)
{
s32 id, i;
// we know it's gEnemyParty
@ -3583,8 +3583,8 @@ static void IllusionNickHack(u32 battlerId, u32 partyId, u8 *dst)
if (GetMonAbility(mon) == ABILITY_ILLUSION)
{
if (IsBattlerAlive(BATTLE_PARTNER(battlerId)))
partnerMon = &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)]];
if (IsBattlerAlive(BATTLE_PARTNER(battler)))
partnerMon = &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]];
else
partnerMon = mon;
@ -3888,17 +3888,17 @@ void BattlePutTextOnWindow(const u8 *text, u8 windowId)
}
}
void SetPpNumbersPaletteInMoveSelection(void)
void SetPpNumbersPaletteInMoveSelection(u32 battler)
{
struct ChooseMoveStruct *chooseMoveStruct = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]);
struct ChooseMoveStruct *chooseMoveStruct = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[battler][4]);
const u16 *palPtr = gPPTextPalette;
u8 var;
if (!gBattleStruct->zmove.viewing)
var = GetCurrentPpToMaxPpState(chooseMoveStruct->currentPp[gMoveSelectionCursor[gActiveBattler]],
chooseMoveStruct->maxPp[gMoveSelectionCursor[gActiveBattler]]);
var = GetCurrentPpToMaxPpState(chooseMoveStruct->currentPp[gMoveSelectionCursor[battler]],
chooseMoveStruct->maxPp[gMoveSelectionCursor[battler]]);
else
var = GetCurrentPpToMaxPpState(chooseMoveStruct->currentPp[gMoveSelectionCursor[gActiveBattler]], gBattleMoves[gMoveSelectionCursor[gActiveBattler]].pp);
var = GetCurrentPpToMaxPpState(chooseMoveStruct->currentPp[gMoveSelectionCursor[battler]], gBattleMoves[gMoveSelectionCursor[battler]].pp);
gPlttBufferUnfaded[BG_PLTT_ID(5) + 12] = palPtr[(var * 2) + 0];
gPlttBufferUnfaded[BG_PLTT_ID(5) + 11] = palPtr[(var * 2) + 1];
@ -4005,38 +4005,38 @@ enum
NOT_EQUAL,
};
u32 BattlerHPPercentage(u32 battlerId, u32 operation, u32 threshold)
u32 BattlerHPPercentage(u32 battler, u32 operation, u32 threshold)
{
switch (operation)
{
case LESS_THAN:
return gBattleMons[battlerId].hp < (gBattleMons[battlerId].maxHP / threshold);
return gBattleMons[battler].hp < (gBattleMons[battler].maxHP / threshold);
case EQUAL:
return gBattleMons[battlerId].hp == (gBattleMons[battlerId].maxHP / threshold);
return gBattleMons[battler].hp == (gBattleMons[battler].maxHP / threshold);
case GREATER_THAN:
return gBattleMons[battlerId].hp > (gBattleMons[battlerId].maxHP / threshold);
return gBattleMons[battler].hp > (gBattleMons[battler].maxHP / threshold);
case LESS_THAN_OR_EQUAL:
return gBattleMons[battlerId].hp <= (gBattleMons[battlerId].maxHP / threshold);
return gBattleMons[battler].hp <= (gBattleMons[battler].maxHP / threshold);
case GREATER_THAN_OR_EQUAL:
return gBattleMons[battlerId].hp >= (gBattleMons[battlerId].maxHP / threshold);
return gBattleMons[battler].hp >= (gBattleMons[battler].maxHP / threshold);
case NOT_EQUAL:
return gBattleMons[battlerId].hp != (gBattleMons[battlerId].maxHP / threshold);
return gBattleMons[battler].hp != (gBattleMons[battler].maxHP / threshold);
default:
break;
}
}
u32 ShouldDoTrainerSlide(u32 battlerId, u32 which)
u32 ShouldDoTrainerSlide(u32 battler, u32 which)
{
u32 i, firstId, lastId, trainerId, retValue = 1;
if (!(gBattleTypeFlags & BATTLE_TYPE_TRAINER) || GetBattlerSide(battlerId) != B_SIDE_OPPONENT)
if (!(gBattleTypeFlags & BATTLE_TYPE_TRAINER) || GetBattlerSide(battler) != B_SIDE_OPPONENT)
return 0;
// Two opponents support.
if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)
{
if (gBattlerPartyIndexes[battlerId] >= 3)
if (gBattlerPartyIndexes[battler] >= 3)
{
firstId = 3, lastId = PARTY_SIZE;
trainerId = gTrainerBattleOpponent_B;
@ -4060,11 +4060,11 @@ u32 ShouldDoTrainerSlide(u32 battlerId, u32 which)
&& (((gBattleTypeFlags & BATTLE_TYPE_FRONTIER) && sTrainerSlides[i].isFrontierTrainer)
|| (!(gBattleTypeFlags & BATTLE_TYPE_FRONTIER) && !sTrainerSlides[i].isFrontierTrainer)))
{
gBattleScripting.battler = battlerId;
gBattleScripting.battler = battler;
switch (which)
{
case TRAINER_SLIDE_LAST_SWITCHIN:
if (sTrainerSlides[i].msgLastSwitchIn != NULL && !CanBattlerSwitch(battlerId))
if (sTrainerSlides[i].msgLastSwitchIn != NULL && !CanBattlerSwitch(battler))
{
gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgLastSwitchIn;
return retValue;
@ -4073,7 +4073,7 @@ u32 ShouldDoTrainerSlide(u32 battlerId, u32 which)
case TRAINER_SLIDE_LAST_LOW_HP:
if (sTrainerSlides[i].msgLastLowHp != NULL
&& GetEnemyMonCount(firstId, lastId, TRUE) == 1
&& BattlerHPPercentage(battlerId, GREATER_THAN_OR_EQUAL, 4)
&& BattlerHPPercentage(battler, GREATER_THAN_OR_EQUAL, 4)
&& !gBattleStruct->trainerSlideLowHpMsgDone)
{
gBattleStruct->trainerSlideLowHpMsgDone = TRUE;
@ -4091,7 +4091,7 @@ u32 ShouldDoTrainerSlide(u32 battlerId, u32 which)
case TRAINER_SLIDE_LAST_HALF_HP:
if (sTrainerSlides[i].msgLastHalfHp != NULL
&& GetEnemyMonCount(firstId, lastId, TRUE) == GetEnemyMonCount(firstId, lastId, FALSE) - 1
&& BattlerHPPercentage(battlerId, LESS_THAN_OR_EQUAL, 2) && BattlerHPPercentage(battlerId, GREATER_THAN, 4)
&& BattlerHPPercentage(battler, LESS_THAN_OR_EQUAL, 2) && BattlerHPPercentage(battler, GREATER_THAN, 4)
&& !gBattleStruct->trainerSlideHalfHpMsgDone)
{
gBattleStruct->trainerSlideHalfHpMsgDone = TRUE;
@ -4110,7 +4110,7 @@ u32 ShouldDoTrainerSlide(u32 battlerId, u32 which)
case TRAINER_SLIDE_FIRST_SUPER_EFFECTIVE_HIT:
if (sTrainerSlides[i].msgFirstSuperEffectiveHit != NULL
&& gBattleStruct->trainerSlideFirstSuperEffectiveHitMsgState == 1
&& gBattleMons[battlerId].hp)
&& gBattleMons[battler].hp)
{
gBattleStruct->trainerSlideFirstSuperEffectiveHitMsgState = 2;
gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgFirstSuperEffectiveHit;

View File

@ -338,7 +338,7 @@ static const u16 sWhiteOutBadgeMoney[9] = { 8, 16, 24, 36, 48, 64, 80, 100, 120
static bool8 IsTwoTurnsMove(u16 move);
static void TrySetDestinyBondToHappen(void);
static u8 AttacksThisTurn(u8 battlerId, u16 move); // Note: returns 1 if it's a charging turn, otherwise 2.
static u8 AttacksThisTurn(u8 battler, u16 move); // Note: returns 1 if it's a charging turn, otherwise 2.
static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr);
static bool32 IsMonGettingExpSentOut(void);
static void InitLevelUpBanner(void);
@ -1200,12 +1200,12 @@ static const u8 sBattlePalaceNatureToFlavorTextId[NUM_NATURES] =
[NATURE_QUIRKY] = B_MSG_EAGER_FOR_MORE,
};
static bool32 NoTargetPresent(u8 battlerId, u32 move)
static bool32 NoTargetPresent(u8 battler, u32 move)
{
if (!IsBattlerAlive(gBattlerTarget))
gBattlerTarget = GetMoveTarget(move, NO_TARGET_OVERRIDE);
switch (GetBattlerMoveTargetType(battlerId, move))
switch (GetBattlerMoveTargetType(battler, move))
{
case MOVE_TARGET_SELECTED:
case MOVE_TARGET_DEPENDS:
@ -2687,23 +2687,23 @@ static void Cmd_printselectionstringfromtable(void)
}
}
u8 GetBattlerTurnOrderNum(u8 battlerId)
u8 GetBattlerTurnOrderNum(u8 battler)
{
s32 i;
for (i = 0; i < gBattlersCount; i++)
{
if (gBattlerByTurnOrder[i] == battlerId)
if (gBattlerByTurnOrder[i] == battler)
break;
}
return i;
}
static void CheckSetUnburden(u8 battlerId)
static void CheckSetUnburden(u8 battler)
{
if (GetBattlerAbility(battlerId) == ABILITY_UNBURDEN)
if (GetBattlerAbility(battler) == ABILITY_UNBURDEN)
{
gBattleResources->flags->flags[battlerId] |= RESOURCE_FLAG_UNBURDEN;
RecordAbilityBattle(battlerId, ABILITY_UNBURDEN);
gBattleResources->flags->flags[battler] |= RESOURCE_FLAG_UNBURDEN;
RecordAbilityBattle(battler, ABILITY_UNBURDEN);
}
}
@ -2781,7 +2781,7 @@ void SetMoveEffect(bool32 primary, u32 certain)
if (gBattleScripting.moveEffect & MOVE_EFFECT_AFFECTS_USER)
{
gEffectBattler = gBattlerAttacker; // battlerId that effects get applied on
gEffectBattler = gBattlerAttacker; // battler that effects get applied on
gBattleScripting.moveEffect &= ~MOVE_EFFECT_AFFECTS_USER;
affectsUser = MOVE_EFFECT_AFFECTS_USER;
gBattleScripting.battler = gBattlerTarget; // theoretically the attacker
@ -3874,11 +3874,11 @@ static void Cmd_jumpifstatus(void)
{
CMD_ARGS(u8 battler, u32 flags, const u8 *jumpInstr);
u8 battlerId = GetBattlerForBattleScript(cmd->battler);
u8 battler = GetBattlerForBattleScript(cmd->battler);
u32 flags = cmd->flags;
const u8 *jumpInstr = cmd->jumpInstr;
if (gBattleMons[battlerId].status1 & flags && gBattleMons[battlerId].hp != 0)
if (gBattleMons[battler].status1 & flags && gBattleMons[battler].hp != 0)
gBattlescriptCurrInstr = jumpInstr;
else
gBattlescriptCurrInstr = cmd->nextInstr;
@ -3888,11 +3888,11 @@ static void Cmd_jumpifstatus2(void)
{
CMD_ARGS(u8 battler, u32 flags, const u8 *jumpInstr);
u8 battlerId = GetBattlerForBattleScript(cmd->battler);
u8 battler = GetBattlerForBattleScript(cmd->battler);
u32 flags = cmd->flags;
const u8 *jumpInstr = cmd->jumpInstr;
if (gBattleMons[battlerId].status2 & flags && gBattleMons[battlerId].hp != 0)
if (gBattleMons[battler].status2 & flags && gBattleMons[battler].hp != 0)
gBattlescriptCurrInstr = jumpInstr;
else
gBattlescriptCurrInstr = cmd->nextInstr;
@ -3902,30 +3902,30 @@ static void Cmd_jumpifability(void)
{
CMD_ARGS(u8 battler, u16 ability, const u8 *jumpInstr);
u32 battlerId;
u32 battler;
bool32 hasAbility = FALSE;
u32 ability = cmd->ability;
switch (cmd->battler)
{
default:
battlerId = GetBattlerForBattleScript(cmd->battler);
if (GetBattlerAbility(battlerId) == ability)
battler = GetBattlerForBattleScript(cmd->battler);
if (GetBattlerAbility(battler) == ability)
hasAbility = TRUE;
break;
case BS_ATTACKER_SIDE:
battlerId = IsAbilityOnSide(gBattlerAttacker, ability);
if (battlerId)
battler = IsAbilityOnSide(gBattlerAttacker, ability);
if (battler)
{
battlerId--;
battler--;
hasAbility = TRUE;
}
break;
case BS_TARGET_SIDE:
battlerId = IsAbilityOnOpposingSide(gBattlerAttacker, ability);
if (battlerId)
battler = IsAbilityOnOpposingSide(gBattlerAttacker, ability);
if (battler)
{
battlerId--;
battler--;
hasAbility = TRUE;
}
break;
@ -3935,8 +3935,8 @@ static void Cmd_jumpifability(void)
{
gLastUsedAbility = ability;
gBattlescriptCurrInstr = cmd->jumpInstr;
RecordAbilityBattle(battlerId, gLastUsedAbility);
gBattlerAbility = battlerId;
RecordAbilityBattle(battler, gLastUsedAbility);
gBattlerAbility = battler;
}
else
{
@ -3967,12 +3967,12 @@ static void Cmd_jumpifstat(void)
CMD_ARGS(u8 battler, u8 comparison, u8 stat, u8 value, const u8 *jumpInstr);
bool32 ret = 0;
u8 battlerId = GetBattlerForBattleScript(cmd->battler);
u8 battler = GetBattlerForBattleScript(cmd->battler);
u8 stat = cmd->stat;
u8 value = cmd->value;
u8 comparison = cmd->comparison;
ret = CompareStat(battlerId, stat, value, comparison);
ret = CompareStat(battler, stat, value, comparison);
if (ret)
gBattlescriptCurrInstr = cmd->jumpInstr;
@ -4005,14 +4005,14 @@ static void Cmd_jumpbasedontype(void)
{
CMD_ARGS(u8 battler, u8 type, u8 jumpIfType, const u8 *jumpInstr);
u8 battlerId = GetBattlerForBattleScript(cmd->battler);
u8 battler = GetBattlerForBattleScript(cmd->battler);
u8 type = cmd->type;
const u8 *jumpInstr = cmd->jumpInstr;
// jumpiftype
if (cmd->jumpIfType)
{
if (IS_BATTLER_OF_TYPE(battlerId, type))
if (IS_BATTLER_OF_TYPE(battler, type))
gBattlescriptCurrInstr = jumpInstr;
else
gBattlescriptCurrInstr = cmd->nextInstr;
@ -4020,7 +4020,7 @@ static void Cmd_jumpbasedontype(void)
// jumpifnottype
else
{
if (!IS_BATTLER_OF_TYPE(battlerId, type))
if (!IS_BATTLER_OF_TYPE(battler, type))
gBattlescriptCurrInstr = jumpInstr;
else
gBattlescriptCurrInstr = cmd->nextInstr;
@ -4213,7 +4213,7 @@ static void Cmd_getexp(void)
i = STRINGID_EMPTYSTRING4;
}
// get exp getter battlerId
// get exp getter battler
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
if (gBattlerPartyIndexes[2] == gBattleStruct->expGetterMonId && !(gAbsentBattlerFlags & gBitTable[2]))
@ -4269,7 +4269,7 @@ static void Cmd_getexp(void)
u32 expBattler = gBattleStruct->expGetterBattlerId;
if (gBattleResources->bufferB[expBattler][0] == CONTROLLER_TWORETURNVALUES && gBattleResources->bufferB[expBattler][1] == RET_VALUE_LEVELED_UP)
{
u16 temp, battlerId = 0xFF;
u16 temp, battler = 0xFF;
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && gBattlerPartyIndexes[expBattler] == gBattleStruct->expGetterMonId)
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[expBattler]], expBattler);
@ -4284,15 +4284,15 @@ static void Cmd_getexp(void)
// update battle mon structure after level up
if (gBattlerPartyIndexes[0] == gBattleStruct->expGetterMonId && gBattleMons[0].hp)
battlerId = 0;
battler = 0;
else if (gBattlerPartyIndexes[2] == gBattleStruct->expGetterMonId && gBattleMons[2].hp && (gBattleTypeFlags & BATTLE_TYPE_DOUBLE))
battlerId = 2;
battler = 2;
if (battlerId != 0xFF)
if (battler != 0xFF)
{
CopyMonLevelAndBaseStatsToBattleMon(battlerId, &gPlayerParty[gBattleStruct->expGetterMonId]);
if (gStatuses3[battlerId] & STATUS3_POWER_TRICK)
SWAP(gBattleMons[battlerId].attack, gBattleMons[battlerId].defense, temp);
CopyMonLevelAndBaseStatsToBattleMon(battler, &gPlayerParty[gBattleStruct->expGetterMonId]);
if (gStatuses3[battler] & STATUS3_POWER_TRICK)
SWAP(gBattleMons[battler].attack, gBattleMons[battler].defense, temp);
}
gBattleScripting.getexpState = 5;
@ -6236,13 +6236,13 @@ static void Cmd_switchinanim(void)
BattleArena_InitPoints();
}
bool32 CanBattlerSwitch(u32 battlerId)
bool32 CanBattlerSwitch(u32 battler)
{
s32 i, lastMonId, battlerIn1, battlerIn2;
bool32 ret = FALSE;
struct Pokemon *party;
if (BATTLE_TWO_VS_ONE_OPPONENT && GetBattlerSide(battlerId) == B_SIDE_OPPONENT)
if (BATTLE_TWO_VS_ONE_OPPONENT && GetBattlerSide(battler) == B_SIDE_OPPONENT)
{
battlerIn1 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
battlerIn2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
@ -6261,10 +6261,10 @@ bool32 CanBattlerSwitch(u32 battlerId)
}
else if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
{
party = GetBattlerParty(battlerId);
party = GetBattlerParty(battler);
lastMonId = 0;
if (battlerId & 2)
if (battler & 2)
lastMonId = MULTI_PARTY_SIZE;
for (i = lastMonId; i < lastMonId + MULTI_PARTY_SIZE; i++)
@ -6272,7 +6272,7 @@ bool32 CanBattlerSwitch(u32 battlerId)
if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE
&& !GetMonData(&party[i], MON_DATA_IS_EGG)
&& GetMonData(&party[i], MON_DATA_HP) != 0
&& gBattlerPartyIndexes[battlerId] != i)
&& gBattlerPartyIndexes[battler] != i)
break;
}
@ -6282,19 +6282,19 @@ bool32 CanBattlerSwitch(u32 battlerId)
{
if (gBattleTypeFlags & BATTLE_TYPE_TOWER_LINK_MULTI)
{
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
{
party = gPlayerParty;
lastMonId = 0;
if (GetLinkTrainerFlankId(GetBattlerMultiplayerId(battlerId)) == TRUE)
if (GetLinkTrainerFlankId(GetBattlerMultiplayerId(battler)) == TRUE)
lastMonId = MULTI_PARTY_SIZE;
}
else
{
party = gEnemyParty;
if (battlerId == 1)
if (battler == 1)
lastMonId = 0;
else
lastMonId = MULTI_PARTY_SIZE;
@ -6302,10 +6302,10 @@ bool32 CanBattlerSwitch(u32 battlerId)
}
else
{
party = GetBattlerParty(battlerId);
party = GetBattlerParty(battler);
lastMonId = 0;
if (GetLinkTrainerFlankId(GetBattlerMultiplayerId(battlerId)) == TRUE)
if (GetLinkTrainerFlankId(GetBattlerMultiplayerId(battler)) == TRUE)
lastMonId = MULTI_PARTY_SIZE;
}
@ -6314,18 +6314,18 @@ bool32 CanBattlerSwitch(u32 battlerId)
if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE
&& !GetMonData(&party[i], MON_DATA_IS_EGG)
&& GetMonData(&party[i], MON_DATA_HP) != 0
&& gBattlerPartyIndexes[battlerId] != i)
&& gBattlerPartyIndexes[battler] != i)
break;
}
ret = (i != lastMonId + MULTI_PARTY_SIZE);
}
else if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS && GetBattlerSide(battlerId) == B_SIDE_OPPONENT)
else if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS && GetBattlerSide(battler) == B_SIDE_OPPONENT)
{
party = gEnemyParty;
lastMonId = 0;
if (battlerId == B_POSITION_OPPONENT_RIGHT)
if (battler == B_POSITION_OPPONENT_RIGHT)
lastMonId = PARTY_SIZE / 2;
for (i = lastMonId; i < lastMonId + (PARTY_SIZE / 2); i++)
@ -6333,7 +6333,7 @@ bool32 CanBattlerSwitch(u32 battlerId)
if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE
&& !GetMonData(&party[i], MON_DATA_IS_EGG)
&& GetMonData(&party[i], MON_DATA_HP) != 0
&& gBattlerPartyIndexes[battlerId] != i)
&& gBattlerPartyIndexes[battler] != i)
break;
}
@ -6341,7 +6341,7 @@ bool32 CanBattlerSwitch(u32 battlerId)
}
else
{
if (GetBattlerSide(battlerId) == B_SIDE_OPPONENT)
if (GetBattlerSide(battler) == B_SIDE_OPPONENT)
{
battlerIn1 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
@ -6761,11 +6761,11 @@ static void Cmd_switchhandleorder(void)
gBattlescriptCurrInstr = cmd->nextInstr;
}
static void SetDmgHazardsBattlescript(u8 battlerId, u8 multistringId)
static void SetDmgHazardsBattlescript(u8 battler, u8 multistringId)
{
gBattleMons[battlerId].status2 &= ~STATUS2_DESTINY_BOND;
gBattleMons[battler].status2 &= ~STATUS2_DESTINY_BOND;
gHitMarker &= ~HITMARKER_DESTINYBOND;
gBattleScripting.battler = battlerId;
gBattleScripting.battler = battler;
gBattleCommunication[MULTISTRING_CHOOSER] = multistringId;
BattleScriptPushCursor();
@ -6777,20 +6777,20 @@ static void SetDmgHazardsBattlescript(u8 battlerId, u8 multistringId)
gBattlescriptCurrInstr = BattleScript_DmgHazardsOnFaintedBattler;
}
bool32 DoSwitchInAbilitiesItems(u32 battlerId)
bool32 DoSwitchInAbilitiesItems(u32 battler)
{
return (TryPrimalReversion(battlerId)
|| AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, battlerId, 0, 0, 0)
|| (gBattleWeather & B_WEATHER_ANY && WEATHER_HAS_EFFECT && AbilityBattleEffects(ABILITYEFFECT_ON_WEATHER, battlerId, 0, 0, 0))
|| (gFieldStatuses & STATUS_FIELD_TERRAIN_ANY && AbilityBattleEffects(ABILITYEFFECT_ON_TERRAIN, battlerId, 0, 0, 0))
|| ItemBattleEffects(ITEMEFFECT_ON_SWITCH_IN, battlerId, FALSE)
return (TryPrimalReversion(battler)
|| AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, battler, 0, 0, 0)
|| (gBattleWeather & B_WEATHER_ANY && WEATHER_HAS_EFFECT && AbilityBattleEffects(ABILITYEFFECT_ON_WEATHER, battler, 0, 0, 0))
|| (gFieldStatuses & STATUS_FIELD_TERRAIN_ANY && AbilityBattleEffects(ABILITYEFFECT_ON_TERRAIN, battler, 0, 0, 0))
|| ItemBattleEffects(ITEMEFFECT_ON_SWITCH_IN, battler, FALSE)
|| AbilityBattleEffects(ABILITYEFFECT_TRACE2, 0, 0, 0, 0));
}
bool32 ShouldPostponeSwitchInAbilities(u32 battlerId)
bool32 ShouldPostponeSwitchInAbilities(u32 battler)
{
bool32 aliveOpposing1 = IsBattlerAlive(BATTLE_OPPOSITE(battlerId));
bool32 aliveOpposing2 = IsBattlerAlive(BATTLE_PARTNER(BATTLE_OPPOSITE(battlerId)));
bool32 aliveOpposing1 = IsBattlerAlive(BATTLE_OPPOSITE(battler));
bool32 aliveOpposing2 = IsBattlerAlive(BATTLE_PARTNER(BATTLE_OPPOSITE(battler)));
// No pokemon on opposing side - postpone.
if (!aliveOpposing1 && !aliveOpposing2)
return TRUE;
@ -6798,9 +6798,9 @@ bool32 ShouldPostponeSwitchInAbilities(u32 battlerId)
// Checks for double battle, so abilities like Intimidate wait until all battlers are switched-in before activating.
if (IsDoubleBattle())
{
if (aliveOpposing1 && !aliveOpposing2 && !HasNoMonsToSwitch(BATTLE_PARTNER(BATTLE_OPPOSITE(battlerId)), PARTY_SIZE, PARTY_SIZE))
if (aliveOpposing1 && !aliveOpposing2 && !HasNoMonsToSwitch(BATTLE_PARTNER(BATTLE_OPPOSITE(battler)), PARTY_SIZE, PARTY_SIZE))
return TRUE;
if (!aliveOpposing1 && aliveOpposing2 && !HasNoMonsToSwitch(BATTLE_OPPOSITE(battlerId), PARTY_SIZE, PARTY_SIZE))
if (!aliveOpposing1 && aliveOpposing2 && !HasNoMonsToSwitch(BATTLE_OPPOSITE(battler), PARTY_SIZE, PARTY_SIZE))
return TRUE;
}
@ -7584,19 +7584,19 @@ static void Cmd_setgravity(void)
}
}
static bool32 TryCheekPouch(u32 battlerId, u32 itemId)
static bool32 TryCheekPouch(u32 battler, u32 itemId)
{
if (ItemId_GetPocket(itemId) == POCKET_BERRIES
&& GetBattlerAbility(battlerId) == ABILITY_CHEEK_POUCH
&& !(gStatuses3[battlerId] & STATUS3_HEAL_BLOCK)
&& gBattleStruct->ateBerry[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]]
&& !BATTLER_MAX_HP(battlerId))
&& GetBattlerAbility(battler) == ABILITY_CHEEK_POUCH
&& !(gStatuses3[battler] & STATUS3_HEAL_BLOCK)
&& gBattleStruct->ateBerry[GetBattlerSide(battler)] & gBitTable[gBattlerPartyIndexes[battler]]
&& !BATTLER_MAX_HP(battler))
{
gBattleMoveDamage = gBattleMons[battlerId].maxHP / 3;
gBattleMoveDamage = gBattleMons[battler].maxHP / 3;
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
gBattleMoveDamage *= -1;
gBattlerAbility = battlerId;
gBattlerAbility = battler;
BattleScriptPush(gBattlescriptCurrInstr + 2);
gBattlescriptCurrInstr = BattleScript_CheekPouchActivates;
return TRUE;
@ -8183,16 +8183,16 @@ bool32 CanParalyzeType(u8 battlerAttacker, u8 battlerTarget)
return !(B_PARALYZE_ELECTRIC >= GEN_6 && IS_BATTLER_OF_TYPE(battlerTarget, TYPE_ELECTRIC));
}
bool32 CanUseLastResort(u8 battlerId)
bool32 CanUseLastResort(u8 battler)
{
u32 i;
u32 knownMovesCount = 0, usedMovesCount = 0;
for (i = 0; i < 4; i++)
{
if (gBattleMons[battlerId].moves[i] != MOVE_NONE)
if (gBattleMons[battler].moves[i] != MOVE_NONE)
knownMovesCount++;
if (i != gCurrMovePos && gDisableStructs[battlerId].usedMoves & gBitTable[i]) // Increment used move count for all moves except current Last Resort.
if (i != gCurrMovePos && gDisableStructs[battler].usedMoves & gBitTable[i]) // Increment used move count for all moves except current Last Resort.
usedMovesCount++;
}
@ -8304,13 +8304,13 @@ u32 IsAbilityStatusProtected(u32 battler)
|| IsShieldsDownProtected(battler);
}
u32 GetHighestStatId(u32 battlerId)
u32 GetHighestStatId(u32 battler)
{
u32 i, highestId = STAT_ATK, highestStat = gBattleMons[battlerId].attack;
u32 i, highestId = STAT_ATK, highestStat = gBattleMons[battler].attack;
for (i = STAT_DEF; i < NUM_STATS; i++)
{
u16 *statVal = &gBattleMons[battlerId].attack + (i - 1);
u16 *statVal = &gBattleMons[battler].attack + (i - 1);
if (*statVal > highestStat)
{
highestStat = *statVal;
@ -8320,17 +8320,17 @@ u32 GetHighestStatId(u32 battlerId)
return highestId;
}
static bool32 IsRototillerAffected(u32 battlerId)
static bool32 IsRototillerAffected(u32 battler)
{
if (!IsBattlerAlive(battlerId))
if (!IsBattlerAlive(battler))
return FALSE;
if (!IsBattlerGrounded(battlerId))
if (!IsBattlerGrounded(battler))
return FALSE; // Only grounded battlers affected
if (!IS_BATTLER_OF_TYPE(battlerId, TYPE_GRASS))
if (!IS_BATTLER_OF_TYPE(battler, TYPE_GRASS))
return FALSE; // Only grass types affected
if (gStatuses3[battlerId] & STATUS3_SEMI_INVULNERABLE)
if (gStatuses3[battler] & STATUS3_SEMI_INVULNERABLE)
return FALSE; // Rototiller doesn't affected semi-invulnerable battlers
if (BlocksPrankster(MOVE_ROTOTILLER, gBattlerAttacker, battlerId, FALSE))
if (BlocksPrankster(MOVE_ROTOTILLER, gBattlerAttacker, battler, FALSE))
return FALSE;
return TRUE;
}
@ -8387,11 +8387,11 @@ static bool32 IsAbilityAbsorbAffected(void)
return FALSE;
}
static bool32 IsTeatimeAffected(u32 battlerId)
static bool32 IsTeatimeAffected(u32 battler)
{
if (ItemId_GetPocket(gBattleMons[battlerId].item) != POCKET_BERRIES)
if (ItemId_GetPocket(gBattleMons[battler].item) != POCKET_BERRIES)
return FALSE; // Only berries
if (gStatuses3[battlerId] & STATUS3_SEMI_INVULNERABLE)
if (gStatuses3[battler] & STATUS3_SEMI_INVULNERABLE)
return FALSE; // Teatime doesn't affected semi-invulnerable battlers
return TRUE;
}
@ -8455,35 +8455,35 @@ static bool32 CourtChangeSwapSideStatuses(void)
SWAP(sideTimerPlayer->stickyWebBattlerSide, sideTimerOpp->stickyWebBattlerSide, temp);
}
static void HandleScriptMegaPrimal(u32 caseId, u32 battlerId, bool32 isMega)
static void HandleScriptMegaPrimal(u32 caseId, u32 battler, bool32 isMega)
{
struct Pokemon *party = GetBattlerParty(battlerId);
struct Pokemon *mon = &party[gBattlerPartyIndexes[battlerId]];
u32 position = GetBattlerPosition(battlerId);
u32 side = GET_BATTLER_SIDE(battlerId);
struct Pokemon *party = GetBattlerParty(battler);
struct Pokemon *mon = &party[gBattlerPartyIndexes[battler]];
u32 position = GetBattlerPosition(battler);
u32 side = GET_BATTLER_SIDE(battler);
// Change species.
if (caseId == 0)
{
if (isMega)
{
if (!TryBattleFormChange(battlerId, FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM))
TryBattleFormChange(battlerId, FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE);
if (!TryBattleFormChange(battler, FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM))
TryBattleFormChange(battler, FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE);
}
else
TryBattleFormChange(battlerId, FORM_CHANGE_BATTLE_PRIMAL_REVERSION);
TryBattleFormChange(battler, FORM_CHANGE_BATTLE_PRIMAL_REVERSION);
PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[battlerId].species);
PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[battler].species);
BtlController_EmitSetMonData(battlerId, BUFFER_A, REQUEST_SPECIES_BATTLE, gBitTable[gBattlerPartyIndexes[battlerId]], sizeof(gBattleMons[battlerId].species), &gBattleMons[battlerId].species);
MarkBattlerForControllerExec(battlerId);
BtlController_EmitSetMonData(battler, BUFFER_A, REQUEST_SPECIES_BATTLE, gBitTable[gBattlerPartyIndexes[battler]], sizeof(gBattleMons[battler].species), &gBattleMons[battler].species);
MarkBattlerForControllerExec(battler);
}
// Update healthbox and elevation and play cry.
else
{
UpdateHealthboxAttribute(gHealthboxSpriteIds[battlerId], mon, HEALTHBOX_ALL);
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], mon, HEALTHBOX_ALL);
if (side == B_SIDE_OPPONENT)
SetBattlerShadowSpriteCallback(battlerId, gBattleMons[battlerId].species);
SetBattlerShadowSpriteCallback(battler, gBattleMons[battler].species);
if (isMega)
gBattleStruct->mega.alreadyEvolved[position] = TRUE;
}
@ -10331,7 +10331,7 @@ static void Cmd_various(void)
if (cmd->fromBattler)
gLastUsedItem = gBattleMons[battler].item;
gBattleScripting.battler = gEffectBattler = gBattlerTarget = battler; // Cover all berry effect battlerId cases. e.g. ChangeStatBuffs uses target ID
gBattleScripting.battler = gEffectBattler = gBattlerTarget = battler; // Cover all berry effect battler cases. e.g. ChangeStatBuffs uses target ID
if (ItemBattleEffects(ITEMEFFECT_USE_LAST_ITEM, battler, FALSE))
return;
gBattlescriptCurrInstr = cmd->nextInstr;
@ -11274,13 +11274,13 @@ static void Cmd_setmiracleeye(void)
}
}
bool8 UproarWakeUpCheck(u8 battlerId)
bool8 UproarWakeUpCheck(u8 battler)
{
s32 i;
for (i = 0; i < gBattlersCount; i++)
{
if (!(gBattleMons[i].status2 & STATUS2_UPROAR) || GetBattlerAbility(battlerId) == ABILITY_SOUNDPROOF)
if (!(gBattleMons[i].status2 & STATUS2_UPROAR) || GetBattlerAbility(battler) == ABILITY_SOUNDPROOF)
continue;
gBattleScripting.battler = i;
@ -12940,11 +12940,11 @@ static bool8 IsTwoTurnsMove(u16 move)
}
// unused
static u8 AttacksThisTurn(u8 battlerId, u16 move) // Note: returns 1 if it's a charging turn, otherwise 2
static u8 AttacksThisTurn(u8 battler, u16 move) // Note: returns 1 if it's a charging turn, otherwise 2
{
// first argument is unused
if (gBattleMoves[move].effect == EFFECT_SOLAR_BEAM
&& IsBattlerWeatherAffected(battlerId, B_WEATHER_SUN))
&& IsBattlerWeatherAffected(battler, B_WEATHER_SUN))
return 2;
if (gBattleMoves[move].effect == EFFECT_SKULL_BASH
@ -14357,13 +14357,13 @@ static void Cmd_tryimprison(void)
}
else
{
u8 battlerId, sideAttacker;
u8 battler, sideAttacker;
sideAttacker = GetBattlerSide(gBattlerAttacker);
PressurePPLoseOnUsingImprison(gBattlerAttacker);
for (battlerId = 0; battlerId < gBattlersCount; battlerId++)
for (battler = 0; battler < gBattlersCount; battler++)
{
if (sideAttacker != GetBattlerSide(battlerId))
if (sideAttacker != GetBattlerSide(battler))
{
s32 attackerMoveId;
for (attackerMoveId = 0; attackerMoveId < MAX_MON_MOVES; attackerMoveId++)
@ -14371,7 +14371,7 @@ static void Cmd_tryimprison(void)
s32 i;
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (gBattleMons[gBattlerAttacker].moves[attackerMoveId] == gBattleMons[battlerId].moves[i]
if (gBattleMons[gBattlerAttacker].moves[attackerMoveId] == gBattleMons[battler].moves[i]
&& gBattleMons[gBattlerAttacker].moves[attackerMoveId] != MOVE_NONE)
break;
}
@ -14386,7 +14386,7 @@ static void Cmd_tryimprison(void)
}
}
}
if (battlerId == gBattlersCount) // In Generation 3 games, Imprison fails if the user doesn't share any moves with any of the foes.
if (battler == gBattlersCount) // In Generation 3 games, Imprison fails if the user doesn't share any moves with any of the foes.
gBattlescriptCurrInstr = cmd->failInstr;
}
}
@ -14873,9 +14873,9 @@ static void Cmd_tryrecycleitem(void)
}
}
bool32 CanCamouflage(u8 battlerId)
bool32 CanCamouflage(u8 battler)
{
if (IS_BATTLER_OF_TYPE(battlerId, sTerrainToType[gBattleTerrain]))
if (IS_BATTLER_OF_TYPE(battler, sTerrainToType[gBattleTerrain]))
return FALSE;
return TRUE;
}
@ -15879,7 +15879,7 @@ static const u16 sParentalBondBannedEffects[] =
EFFECT_UPROAR,
};
bool8 IsMoveAffectedByParentalBond(u16 move, u8 battlerId)
bool8 IsMoveAffectedByParentalBond(u16 move, u8 battler)
{
if (move != MOVE_NONE && move != MOVE_STRUGGLE
&& gBattleMoves[move].split != SPLIT_STATUS
@ -15894,7 +15894,7 @@ bool8 IsMoveAffectedByParentalBond(u16 move, u8 battlerId)
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
switch (GetBattlerMoveTargetType(battlerId, move))
switch (GetBattlerMoveTargetType(battler, move))
{
// Both foes are alive, spread move strikes once
case MOVE_TARGET_BOTH:
@ -16028,19 +16028,19 @@ static void TryUpdateRoundTurnOrder(void)
}
}
u8 GetFirstFaintedPartyIndex(u8 battlerId)
u8 GetFirstFaintedPartyIndex(u8 battler)
{
u32 i;
u32 start = 0;
u32 end = PARTY_SIZE;
struct Pokemon *party = GetBattlerParty(battlerId);
struct Pokemon *party = GetBattlerParty(battler);
// Check whether partner is separate trainer.
if ((GetBattlerSide(battlerId) == B_SIDE_PLAYER && gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
|| (GetBattlerSide(battlerId) == B_SIDE_OPPONENT && gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS))
if ((GetBattlerSide(battler) == B_SIDE_PLAYER && gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
|| (GetBattlerSide(battler) == B_SIDE_OPPONENT && gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS))
{
if (GetBattlerPosition(battlerId) == B_POSITION_OPPONENT_LEFT
|| GetBattlerPosition(battlerId) == B_POSITION_PLAYER_LEFT)
if (GetBattlerPosition(battler) == B_POSITION_OPPONENT_LEFT
|| GetBattlerPosition(battler) == B_POSITION_PLAYER_LEFT)
{
end = PARTY_SIZE / 2;
}
@ -16070,7 +16070,7 @@ void BS_ItemRestoreHP(void)
{
NATIVE_ARGS();
u16 healAmount;
u32 battlerId = MAX_BATTLERS_COUNT;
u32 battler = MAX_BATTLERS_COUNT;
u32 healParam = GetItemEffect(gLastUsedItem)[6];
u32 side = GetBattlerSide(gBattlerAttacker);
struct Pokemon *party = GetSideParty(side);
@ -16084,10 +16084,10 @@ void BS_ItemRestoreHP(void)
// Check if the recipient is an active battler.
if (gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[gBattlerAttacker])
battlerId = gBattlerAttacker;
battler = gBattlerAttacker;
else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE
&& gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[BATTLE_PARTNER(gBattlerAttacker)])
battlerId = BATTLE_PARTNER(gBattlerAttacker);
battler = BATTLE_PARTNER(gBattlerAttacker);
// Get amount to heal.
switch (healParam)
@ -16109,7 +16109,7 @@ void BS_ItemRestoreHP(void)
healAmount = maxHP - hp;
// Heal is applied as move damage if battler is active.
if (battlerId != MAX_BATTLERS_COUNT && hp != 0)
if (battler != MAX_BATTLERS_COUNT && hp != 0)
{
gBattleMoveDamage = -healAmount;
}
@ -16119,10 +16119,10 @@ void BS_ItemRestoreHP(void)
SetMonData(&party[gBattleStruct->itemPartyIndex[gBattlerAttacker]], MON_DATA_HP, &hp);
// Revived battlers on the field need to be brought back.
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && battlerId != MAX_BATTLERS_COUNT)
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && battler != MAX_BATTLERS_COUNT)
{
gAbsentBattlerFlags &= ~gBitTable[battlerId];
gBattleScripting.battler = battlerId;
gAbsentBattlerFlags &= ~gBitTable[battler];
gBattleScripting.battler = battler;
gBattleCommunication[MULTIUSE_STATE] = TRUE;
}
}
@ -16173,7 +16173,7 @@ void BS_ItemRestorePP(void)
NATIVE_ARGS();
const u8 *effect = GetItemEffect(gLastUsedItem);
u32 i, pp, maxPP, moveId, loopEnd;
u32 battlerId = MAX_BATTLERS_COUNT;
u32 battler = MAX_BATTLERS_COUNT;
struct Pokemon *mon = (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) ? &gPlayerParty[gBattleStruct->itemPartyIndex[gBattlerAttacker]] : &gEnemyParty[gBattleStruct->itemPartyIndex[gBattlerAttacker]];
// Check whether to apply to all moves.
@ -16190,10 +16190,10 @@ void BS_ItemRestorePP(void)
// Check if the recipient is an active battler.
if (gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[gBattlerAttacker])
battlerId = gBattlerAttacker;
battler = gBattlerAttacker;
else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE
&& gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[BATTLE_PARTNER(gBattlerAttacker)])
battlerId = BATTLE_PARTNER(gBattlerAttacker);
battler = BATTLE_PARTNER(gBattlerAttacker);
// Heal PP!
for (; i < loopEnd; i++)
@ -16209,11 +16209,11 @@ void BS_ItemRestorePP(void)
SetMonData(mon, MON_DATA_PP1 + i, &pp);
// Update battler PP if needed.
if (battlerId != MAX_BATTLERS_COUNT
&& gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[battlerId]
&& MOVE_IS_PERMANENT(battlerId, i))
if (battler != MAX_BATTLERS_COUNT
&& gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[battler]
&& MOVE_IS_PERMANENT(battler, i))
{
gBattleMons[battlerId].pp[i] = pp;
gBattleMons[battler].pp[i] = pp;
}
}
}

View File

@ -646,22 +646,23 @@ bool8 TryRunFromBattle(u8 battler)
void HandleAction_Run(void)
{
gBattlerAttacker = gBattlerByTurnOrder[gCurrentTurnActionNumber];
s32 i;
gBattlerAttacker = gBattlerByTurnOrder[gCurrentTurnActionNumber];
if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK))
{
gCurrentTurnActionNumber = gBattlersCount;
for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++)
for (i = 0; i < gBattlersCount; i++)
{
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
if (GetBattlerSide(i) == B_SIDE_PLAYER)
{
if (gChosenActionByBattler[gActiveBattler] == B_ACTION_RUN)
if (gChosenActionByBattler[i] == B_ACTION_RUN)
gBattleOutcome |= B_OUTCOME_LOST;
}
else
{
if (gChosenActionByBattler[gActiveBattler] == B_ACTION_RUN)
if (gChosenActionByBattler[i] == B_ACTION_RUN)
gBattleOutcome |= B_OUTCOME_WON;
}
}
@ -1604,86 +1605,86 @@ static bool32 IsBelchPreventingMove(u32 battler, u32 move)
return !(gBattleStruct->ateBerry[battler & BIT_SIDE] & gBitTable[gBattlerPartyIndexes[battler]]);
}
u8 TrySetCantSelectMoveBattleScript(void)
u32 TrySetCantSelectMoveBattleScript(u32 battler)
{
u32 limitations = 0;
u8 moveId = gBattleResources->bufferB[gActiveBattler][2] & ~RET_MEGA_EVOLUTION;
u32 move = gBattleMons[gActiveBattler].moves[moveId];
u32 holdEffect = GetBattlerHoldEffect(gActiveBattler, TRUE);
u16 *choicedMove = &gBattleStruct->choicedMove[gActiveBattler];
u8 moveId = gBattleResources->bufferB[battler][2] & ~RET_MEGA_EVOLUTION;
u32 move = gBattleMons[battler].moves[moveId];
u32 holdEffect = GetBattlerHoldEffect(battler, TRUE);
u16 *choicedMove = &gBattleStruct->choicedMove[battler];
if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] == MOVE_NONE && gDisableStructs[gActiveBattler].disabledMove == move && move != MOVE_NONE)
if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] == MOVE_NONE && gDisableStructs[battler].disabledMove == move && move != MOVE_NONE)
{
gBattleScripting.battler = gActiveBattler;
gBattleScripting.battler = battler;
gCurrentMove = move;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingDisabledMoveInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingDisabledMoveInPalace;
gProtectStructs[battler].palaceUnableToUseMove = TRUE;
}
else
{
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingDisabledMove;
gSelectionBattleScripts[battler] = BattleScript_SelectingDisabledMove;
limitations++;
}
}
if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] == MOVE_NONE && move == gLastMoves[gActiveBattler] && move != MOVE_STRUGGLE && (gBattleMons[gActiveBattler].status2 & STATUS2_TORMENT))
if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] == MOVE_NONE && move == gLastMoves[battler] && move != MOVE_STRUGGLE && (gBattleMons[battler].status2 & STATUS2_TORMENT))
{
CancelMultiTurnMoves(gActiveBattler);
CancelMultiTurnMoves(battler);
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingTormentedMoveInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingTormentedMoveInPalace;
gProtectStructs[battler].palaceUnableToUseMove = TRUE;
}
else
{
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingTormentedMove;
gSelectionBattleScripts[battler] = BattleScript_SelectingTormentedMove;
limitations++;
}
}
if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] == MOVE_NONE && gDisableStructs[gActiveBattler].tauntTimer != 0 && IS_MOVE_STATUS(move))
if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] == MOVE_NONE && gDisableStructs[battler].tauntTimer != 0 && IS_MOVE_STATUS(move))
{
gCurrentMove = move;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveTauntInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveTauntInPalace;
gProtectStructs[battler].palaceUnableToUseMove = TRUE;
}
else
{
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveTaunt;
gSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveTaunt;
limitations++;
}
}
if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] == MOVE_NONE && gDisableStructs[gActiveBattler].throatChopTimer != 0 && gBattleMoves[move].soundMove)
if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] == MOVE_NONE && gDisableStructs[battler].throatChopTimer != 0 && gBattleMoves[move].soundMove)
{
gCurrentMove = move;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveThroatChopInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveThroatChopInPalace;
gProtectStructs[battler].palaceUnableToUseMove = TRUE;
}
else
{
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveThroatChop;
gSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveThroatChop;
limitations++;
}
}
if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] == MOVE_NONE && GetImprisonedMovesCount(gActiveBattler, move))
if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] == MOVE_NONE && GetImprisonedMovesCount(battler, move))
{
gCurrentMove = move;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingImprisonedMoveInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingImprisonedMoveInPalace;
gProtectStructs[battler].palaceUnableToUseMove = TRUE;
}
else
{
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingImprisonedMove;
gSelectionBattleScripts[battler] = BattleScript_SelectingImprisonedMove;
limitations++;
}
}
@ -1693,118 +1694,118 @@ u8 TrySetCantSelectMoveBattleScript(void)
gCurrentMove = move;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveGravityInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveGravityInPalace;
gProtectStructs[battler].palaceUnableToUseMove = TRUE;
}
else
{
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveGravity;
gSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveGravity;
limitations++;
}
}
if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] == MOVE_NONE && IsHealBlockPreventingMove(gActiveBattler, move))
if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] == MOVE_NONE && IsHealBlockPreventingMove(battler, move))
{
gCurrentMove = move;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveHealBlockInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveHealBlockInPalace;
gProtectStructs[battler].palaceUnableToUseMove = TRUE;
}
else
{
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveHealBlock;
gSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveHealBlock;
limitations++;
}
}
if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] == MOVE_NONE && IsBelchPreventingMove(gActiveBattler, move))
if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] == MOVE_NONE && IsBelchPreventingMove(battler, move))
{
gCurrentMove = move;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedBelchInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedBelchInPalace;
gProtectStructs[battler].palaceUnableToUseMove = TRUE;
}
else
{
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedBelch;
gSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedBelch;
limitations++;
}
}
if (move == MOVE_STUFF_CHEEKS && ItemId_GetPocket(gBattleMons[gActiveBattler].item) != POCKET_BERRIES)
if (move == MOVE_STUFF_CHEEKS && ItemId_GetPocket(gBattleMons[battler].item) != POCKET_BERRIES)
{
gCurrentMove = move;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedStuffCheeksInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedStuffCheeksInPalace;
gProtectStructs[battler].palaceUnableToUseMove = TRUE;
}
else
{
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedStuffCheeks;
gSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedStuffCheeks;
limitations++;
}
}
gPotentialItemEffectBattler = gActiveBattler;
gPotentialItemEffectBattler = battler;
if (HOLD_EFFECT_CHOICE(holdEffect) && *choicedMove != MOVE_NONE && *choicedMove != MOVE_UNAVAILABLE && *choicedMove != move)
{
gCurrentMove = *choicedMove;
gLastUsedItem = gBattleMons[gActiveBattler].item;
gLastUsedItem = gBattleMons[battler].item;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveChoiceItemInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveChoiceItemInPalace;
gProtectStructs[battler].palaceUnableToUseMove = TRUE;
}
else
{
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveChoiceItem;
gSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveChoiceItem;
limitations++;
}
}
else if (holdEffect == HOLD_EFFECT_ASSAULT_VEST && IS_MOVE_STATUS(move) && move != MOVE_ME_FIRST)
{
gCurrentMove = move;
gLastUsedItem = gBattleMons[gActiveBattler].item;
gLastUsedItem = gBattleMons[battler].item;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveAssaultVestInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveAssaultVestInPalace;
gProtectStructs[battler].palaceUnableToUseMove = TRUE;
}
else
{
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveAssaultVest;
gSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveAssaultVest;
limitations++;
}
}
if ((GetBattlerAbility(gActiveBattler) == ABILITY_GORILLA_TACTICS) && *choicedMove != MOVE_NONE
if ((GetBattlerAbility(battler) == ABILITY_GORILLA_TACTICS) && *choicedMove != MOVE_NONE
&& *choicedMove != MOVE_UNAVAILABLE && *choicedMove != move)
{
gCurrentMove = *choicedMove;
gLastUsedItem = gBattleMons[gActiveBattler].item;
gLastUsedItem = gBattleMons[battler].item;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveGorillaTacticsInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveGorillaTacticsInPalace;
gProtectStructs[battler].palaceUnableToUseMove = TRUE;
}
else
{
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveGorillaTactics;
gSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveGorillaTactics;
limitations++;
}
}
if (gBattleMons[gActiveBattler].pp[moveId] == 0)
if (gBattleMons[battler].pp[moveId] == 0)
{
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
gProtectStructs[battler].palaceUnableToUseMove = TRUE;
}
else
{
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingMoveWithNoPP;
gSelectionBattleScripts[battler] = BattleScript_SelectingMoveWithNoPP;
limitations++;
}
}
@ -1813,12 +1814,12 @@ u8 TrySetCantSelectMoveBattleScript(void)
{
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedPlaceholderInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedPlaceholderInPalace;
gProtectStructs[battler].palaceUnableToUseMove = TRUE;
}
else
{
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedPlaceholder;
gSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedPlaceholder;
limitations++;
}
}
@ -1889,18 +1890,18 @@ u8 CheckMoveLimitations(u8 battler, u8 unusableMoves, u16 check)
}
#define ALL_MOVES_MASK ((1 << MAX_MON_MOVES) - 1)
bool8 AreAllMovesUnusable(void)
bool32 AreAllMovesUnusable(u32 battler)
{
u8 unusable = CheckMoveLimitations(gActiveBattler, 0, MOVE_LIMITATIONS_ALL);
u8 unusable = CheckMoveLimitations(battler, 0, MOVE_LIMITATIONS_ALL);
if (unusable == ALL_MOVES_MASK) // All moves are unusable.
{
gProtectStructs[gActiveBattler].noValidMoves = TRUE;
gSelectionBattleScripts[gActiveBattler] = BattleScript_NoMovesLeft;
gProtectStructs[battler].noValidMoves = TRUE;
gSelectionBattleScripts[battler] = BattleScript_NoMovesLeft;
}
else
{
gProtectStructs[gActiveBattler].noValidMoves = FALSE;
gProtectStructs[battler].noValidMoves = FALSE;
}
return (unusable == ALL_MOVES_MASK);
@ -2055,7 +2056,7 @@ u8 DoFieldEndTurnEffects(void)
while (gBattleStruct->turnSideTracker < 2)
{
side = gBattleStruct->turnSideTracker;
gActiveBattler = gBattlerAttacker = gSideTimers[side].reflectBattlerId;
gBattlerAttacker = gSideTimers[side].reflectBattlerId;
if (gSideStatuses[side] & SIDE_STATUS_REFLECT)
{
if (--gSideTimers[side].reflectTimer == 0)
@ -2080,7 +2081,7 @@ u8 DoFieldEndTurnEffects(void)
while (gBattleStruct->turnSideTracker < 2)
{
side = gBattleStruct->turnSideTracker;
gActiveBattler = gBattlerAttacker = gSideTimers[side].lightscreenBattlerId;
gBattlerAttacker = gSideTimers[side].lightscreenBattlerId;
if (gSideStatuses[side] & SIDE_STATUS_LIGHTSCREEN)
{
if (--gSideTimers[side].lightscreenTimer == 0)
@ -2106,7 +2107,7 @@ u8 DoFieldEndTurnEffects(void)
while (gBattleStruct->turnSideTracker < 2)
{
side = gBattleStruct->turnSideTracker;
gActiveBattler = gBattlerAttacker = gSideTimers[side].auroraVeilBattlerId;
gBattlerAttacker = gSideTimers[side].auroraVeilBattlerId;
if (gSideStatuses[side] & SIDE_STATUS_AURORA_VEIL)
{
if (--gSideTimers[side].auroraVeilTimer == 0)
@ -2132,7 +2133,7 @@ u8 DoFieldEndTurnEffects(void)
while (gBattleStruct->turnSideTracker < 2)
{
side = gBattleStruct->turnSideTracker;
gActiveBattler = gBattlerAttacker = gSideTimers[side].mistBattlerId;
gBattlerAttacker = gSideTimers[side].mistBattlerId;
if (gSideTimers[side].mistTimer != 0 && --gSideTimers[side].mistTimer == 0)
{
gSideStatuses[side] &= ~SIDE_STATUS_MIST;
@ -2155,7 +2156,7 @@ u8 DoFieldEndTurnEffects(void)
while (gBattleStruct->turnSideTracker < 2)
{
side = gBattleStruct->turnSideTracker;
gActiveBattler = gBattlerAttacker = gSideTimers[side].safeguardBattlerId;
gBattlerAttacker = gSideTimers[side].safeguardBattlerId;
if (gSideStatuses[side] & SIDE_STATUS_SAFEGUARD)
{
if (--gSideTimers[side].safeguardTimer == 0)
@ -2179,7 +2180,7 @@ u8 DoFieldEndTurnEffects(void)
while (gBattleStruct->turnSideTracker < 2)
{
side = gBattleStruct->turnSideTracker;
gActiveBattler = gBattlerAttacker = gSideTimers[side].luckyChantBattlerId;
gBattlerAttacker = gSideTimers[side].luckyChantBattlerId;
if (gSideStatuses[side] & SIDE_STATUS_LUCKY_CHANT)
{
if (--gSideTimers[side].luckyChantTimer == 0)
@ -2203,7 +2204,7 @@ u8 DoFieldEndTurnEffects(void)
while (gBattleStruct->turnSideTracker < 2)
{
side = gBattleStruct->turnSideTracker;
gActiveBattler = gBattlerAttacker = gSideTimers[side].tailwindBattlerId;
gBattlerAttacker = gSideTimers[side].tailwindBattlerId;
if (gSideStatuses[side] & SIDE_STATUS_TAILWIND)
{
if (--gSideTimers[side].tailwindTimer == 0)
@ -2226,12 +2227,12 @@ u8 DoFieldEndTurnEffects(void)
case ENDTURN_WISH:
while (gBattleStruct->turnSideTracker < gBattlersCount)
{
gActiveBattler = gBattlerByTurnOrder[gBattleStruct->turnSideTracker];
if (gWishFutureKnock.wishCounter[gActiveBattler] != 0
&& --gWishFutureKnock.wishCounter[gActiveBattler] == 0
&& gBattleMons[gActiveBattler].hp != 0)
u32 battler = gBattlerByTurnOrder[gBattleStruct->turnSideTracker];
if (gWishFutureKnock.wishCounter[battler] != 0
&& --gWishFutureKnock.wishCounter[battler] == 0
&& gBattleMons[battler].hp != 0)
{
gBattlerTarget = gActiveBattler;
gBattlerTarget = battler;
BattleScriptExecute(BattleScript_WishComesTrue);
effect++;
}
@ -3102,41 +3103,42 @@ u8 DoBattlerEndTurnEffects(void)
bool8 HandleWishPerishSongOnTurnEnd(void)
{
gHitMarker |= (HITMARKER_GRUDGE | HITMARKER_SKIP_DMG_TRACK);
u32 battler;
gHitMarker |= (HITMARKER_GRUDGE | HITMARKER_SKIP_DMG_TRACK);
switch (gBattleStruct->wishPerishSongState)
{
case 0:
while (gBattleStruct->wishPerishSongBattlerId < gBattlersCount)
{
gActiveBattler = gBattleStruct->wishPerishSongBattlerId;
if (gAbsentBattlerFlags & gBitTable[gActiveBattler])
battler = gBattleStruct->wishPerishSongBattlerId;
if (gAbsentBattlerFlags & gBitTable[battler])
{
gBattleStruct->wishPerishSongBattlerId++;
continue;
}
gBattleStruct->wishPerishSongBattlerId++;
if (gWishFutureKnock.futureSightCounter[gActiveBattler] != 0
&& --gWishFutureKnock.futureSightCounter[gActiveBattler] == 0
&& gBattleMons[gActiveBattler].hp != 0)
if (gWishFutureKnock.futureSightCounter[battler] != 0
&& --gWishFutureKnock.futureSightCounter[battler] == 0
&& gBattleMons[battler].hp != 0)
{
if (gWishFutureKnock.futureSightMove[gActiveBattler] == MOVE_FUTURE_SIGHT)
if (gWishFutureKnock.futureSightMove[battler] == MOVE_FUTURE_SIGHT)
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_FUTURE_SIGHT;
else
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_DOOM_DESIRE;
PREPARE_MOVE_BUFFER(gBattleTextBuff1, gWishFutureKnock.futureSightMove[gActiveBattler]);
PREPARE_MOVE_BUFFER(gBattleTextBuff1, gWishFutureKnock.futureSightMove[battler]);
gBattlerTarget = gActiveBattler;
gBattlerAttacker = gWishFutureKnock.futureSightAttacker[gActiveBattler];
gBattlerTarget = battler;
gBattlerAttacker = gWishFutureKnock.futureSightAttacker[battler];
gSpecialStatuses[gBattlerTarget].dmg = 0xFFFF;
gCurrentMove = gWishFutureKnock.futureSightMove[gActiveBattler];
SetTypeBeforeUsingMove(gCurrentMove, gActiveBattler);
gCurrentMove = gWishFutureKnock.futureSightMove[battler];
SetTypeBeforeUsingMove(gCurrentMove, battler);
BattleScriptExecute(BattleScript_MonTookFutureAttack);
if (gWishFutureKnock.futureSightCounter[gActiveBattler] == 0
&& gWishFutureKnock.futureSightCounter[BATTLE_PARTNER(gActiveBattler)] == 0)
if (gWishFutureKnock.futureSightCounter[battler] == 0
&& gWishFutureKnock.futureSightCounter[BATTLE_PARTNER(battler)] == 0)
{
gSideStatuses[GET_BATTLER_SIDE(gBattlerTarget)] &= ~SIDE_STATUS_FUTUREATTACK;
}
@ -3149,37 +3151,33 @@ bool8 HandleWishPerishSongOnTurnEnd(void)
case 1:
while (gBattleStruct->wishPerishSongBattlerId < gBattlersCount)
{
gActiveBattler = gBattlerAttacker = gBattlerByTurnOrder[gBattleStruct->wishPerishSongBattlerId];
if (gAbsentBattlerFlags & gBitTable[gActiveBattler])
battler = gBattlerAttacker = gBattlerByTurnOrder[gBattleStruct->wishPerishSongBattlerId];
if (gAbsentBattlerFlags & gBitTable[battler])
{
gBattleStruct->wishPerishSongBattlerId++;
continue;
}
gBattleStruct->wishPerishSongBattlerId++;
if (gStatuses3[gActiveBattler] & STATUS3_PERISH_SONG)
if (gStatuses3[battler] & STATUS3_PERISH_SONG)
{
PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 1, gDisableStructs[gActiveBattler].perishSongTimer);
if (gDisableStructs[gActiveBattler].perishSongTimer == 0)
PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 1, gDisableStructs[battler].perishSongTimer);
if (gDisableStructs[battler].perishSongTimer == 0)
{
gStatuses3[gActiveBattler] &= ~STATUS3_PERISH_SONG;
gBattleMoveDamage = gBattleMons[gActiveBattler].hp;
gStatuses3[battler] &= ~STATUS3_PERISH_SONG;
gBattleMoveDamage = gBattleMons[battler].hp;
gBattlescriptCurrInstr = BattleScript_PerishSongTakesLife;
}
else
{
gDisableStructs[gActiveBattler].perishSongTimer--;
gDisableStructs[battler].perishSongTimer--;
gBattlescriptCurrInstr = BattleScript_PerishSongCountGoesDown;
}
BattleScriptExecute(gBattlescriptCurrInstr);
return TRUE;
}
}
// Hm...
{
u8 *state = &gBattleStruct->wishPerishSongState;
*state = 2;
gBattleStruct->wishPerishSongState = 2;
gBattleStruct->wishPerishSongBattlerId = 0;
}
// fall through
case 2:
if ((gBattleTypeFlags & BATTLE_TYPE_ARENA)
@ -4889,7 +4887,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
}
break;
case ABILITY_CUD_CHEW:
if (ItemId_GetPocket(GetUsedHeldItem(battler)) == POCKET_BERRIES && gDisableStructs[gActiveBattler].cudChew == TRUE)
if (ItemId_GetPocket(GetUsedHeldItem(battler)) == POCKET_BERRIES && gDisableStructs[battler].cudChew == TRUE)
{
gLastUsedItem = gBattleStruct->usedHeldItems[battler][GetBattlerSide(battler)];
gBattleStruct->usedHeldItems[battler][GetBattlerSide(battler)] = ITEM_NONE;
@ -5530,7 +5528,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
}
else if (TryChangeBattleWeather(battler, ENUM_WEATHER_SANDSTORM, TRUE))
{
gBattleScripting.battler = gActiveBattler = battler;
gBattleScripting.battler = battler;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_SandSpitActivates;
effect++;
@ -5880,24 +5878,25 @@ 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 target1 = GetBattlerAtPosition(side);
u8 target2 = GetBattlerAtPosition(side + BIT_FLANK);
u32 chosenTarget;
u32 side = (BATTLE_OPPOSITE(GetBattlerPosition(i))) & BIT_SIDE; // side of the opposing pokemon
u32 target1 = GetBattlerAtPosition(side);
u32 target2 = GetBattlerAtPosition(side + BIT_FLANK);
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
if (!sAbilitiesNotTraced[gBattleMons[target1].ability] && gBattleMons[target1].hp != 0
&& !sAbilitiesNotTraced[gBattleMons[target2].ability] && gBattleMons[target2].hp != 0)
gActiveBattler = GetBattlerAtPosition(((Random() & 1) * 2) | side), effect++;
chosenTarget = GetBattlerAtPosition(((Random() & 1) * 2) | side), effect++;
else if (!sAbilitiesNotTraced[gBattleMons[target1].ability] && gBattleMons[target1].hp != 0)
gActiveBattler = target1, effect++;
chosenTarget = target1, effect++;
else if (!sAbilitiesNotTraced[gBattleMons[target2].ability] && gBattleMons[target2].hp != 0)
gActiveBattler = target2, effect++;
chosenTarget = target2, effect++;
}
else
{
if (!sAbilitiesNotTraced[gBattleMons[target1].ability] && gBattleMons[target1].hp != 0)
gActiveBattler = target1, effect++;
chosenTarget = target1, effect++;
}
if (effect != 0)
@ -5912,11 +5911,11 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
gBattlescriptCurrInstr = BattleScript_TraceActivates;
}
gBattleResources->flags->flags[i] &= ~RESOURCE_FLAG_TRACED;
gBattleStruct->tracedAbility[i] = gLastUsedAbility = gBattleMons[gActiveBattler].ability;
RecordAbilityBattle(gActiveBattler, gLastUsedAbility); // Record the opposing battler has this ability
gBattleStruct->tracedAbility[i] = gLastUsedAbility = gBattleMons[chosenTarget].ability;
RecordAbilityBattle(chosenTarget, gLastUsedAbility); // Record the opposing battler has this ability
battler = gBattlerAbility = gBattleScripting.battler = i;
PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gActiveBattler, gBattlerPartyIndexes[gActiveBattler])
PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, chosenTarget, gBattlerPartyIndexes[chosenTarget])
PREPARE_ABILITY_BUFFER(gBattleTextBuff2, gLastUsedAbility)
break;
}
@ -6951,7 +6950,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battler, bool8 moveTurn)
{
gBattleScripting.battler = battler;
gPotentialItemEffectBattler = battler;
gActiveBattler = gBattlerAttacker = battler;
gBattlerAttacker = battler;
BattleScriptExecute(BattleScript_WhiteHerbEnd2);
}
break;
@ -7133,7 +7132,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battler, bool8 moveTurn)
&& !(gCurrentMove == MOVE_PARTING_SHOT && CanBattlerSwitch(gBattlerAttacker))) // Does not activate if attacker used Parting Shot and can switch out
{
gProtectStructs[battler].statFell = FALSE;
gActiveBattler = gBattleScripting.battler = battler;
gBattleScripting.battler = battler;
effect = ITEM_STATS_CHANGE;
if (moveTurn)
{
@ -7246,7 +7245,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battler, bool8 moveTurn)
{
gBattleScripting.battler = battler;
gPotentialItemEffectBattler = battler;
gActiveBattler = gBattlerAttacker = battler;
gBattlerAttacker = battler;
BattleScriptExecute(BattleScript_WhiteHerbEnd2);
}
break;
@ -10100,7 +10099,7 @@ bool32 CanMegaEvolve(u8 battler)
struct Pokemon *mon;
u8 battlerPosition = GetBattlerPosition(battler);
u8 partnerPosition = GetBattlerPosition(BATTLE_PARTNER(battler));
struct MegaEvolutionData *mega = &(((struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]))->mega);
struct MegaEvolutionData *mega = &(((struct ChooseMoveStruct *)(&gBattleResources->bufferA[battler][4]))->mega);
// Check if Player has a Mega Ring
if ((GetBattlerPosition(battler) == B_POSITION_PLAYER_LEFT || (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) && GetBattlerPosition(battler) == B_POSITION_PLAYER_RIGHT))

View File

@ -48,12 +48,12 @@
static void SpriteCB_ZMoveTrigger(struct Sprite *sprite);
static u16 GetSignatureZMove(u16 move, u16 species, u16 item);
static u16 GetTypeBasedZMove(u16 move, u8 battler);
static void ZMoveSelectionDisplayPpNumber(void);
static void ZMoveSelectionDisplayPpNumber(u32 battler);
static void ZMoveSelectionDisplayPower(u16 move, u16 zMove);
static void ShowZMoveTriggerSprite(u8 battleId);
static bool32 AreStatsMaxed(u8 battlerId, u8 n);
static bool32 AreStatsMaxed(u8 battler, u8 n);
static u8 GetZMoveScore(u8 battlerAtk, u8 battlerDef, u16 baseMove, u16 zMove);
static void ZMoveSelectionDisplayMoveType(u16 zMove);
static void ZMoveSelectionDisplayMoveType(u16 zMove, u32 battler);
// Const Data
static const struct SignatureZMove sSignatureZMoves[] =
@ -146,52 +146,52 @@ bool8 IsZMove(u16 move)
return move >= FIRST_Z_MOVE && move <= LAST_Z_MOVE;
}
void QueueZMove(u8 battlerId, u16 baseMove)
void QueueZMove(u8 battler, u16 baseMove)
{
gBattleStruct->zmove.toBeUsed[battlerId] = gBattleStruct->zmove.chosenZMove;
gBattleStruct->zmove.baseMoves[battlerId] = baseMove;
gBattleStruct->zmove.toBeUsed[battler] = gBattleStruct->zmove.chosenZMove;
gBattleStruct->zmove.baseMoves[battler] = baseMove;
if (gBattleStruct->zmove.chosenZMove == MOVE_LIGHT_THAT_BURNS_THE_SKY)
gBattleStruct->zmove.splits[battlerId] = GetSplitBasedOnStats(battlerId);
gBattleStruct->zmove.splits[battler] = GetSplitBasedOnStats(battler);
else
gBattleStruct->zmove.splits[battlerId] = gBattleMoves[baseMove].split;
gBattleStruct->zmove.splits[battler] = gBattleMoves[baseMove].split;
}
bool32 IsViableZMove(u8 battlerId, u16 move)
bool32 IsViableZMove(u8 battler, u16 move)
{
struct Pokemon *mon;
u8 battlerPosition = GetBattlerPosition(battlerId);
u8 partnerPosition = GetBattlerPosition(BATTLE_PARTNER(battlerId));
u8 battlerPosition = GetBattlerPosition(battler);
u8 partnerPosition = GetBattlerPosition(BATTLE_PARTNER(battler));
u32 item;
u16 holdEffect;
u16 species;
int moveSlotIndex;
species = gBattleMons[battlerId].species;
item = gBattleMons[battlerId].item;
species = gBattleMons[battler].species;
item = gBattleMons[battler].item;
for (moveSlotIndex = 0; moveSlotIndex < MAX_MON_MOVES; moveSlotIndex++)
{
if (gBattleMons[battlerId].moves[moveSlotIndex] == move && gBattleMons[battlerId].pp[moveSlotIndex] == 0)
if (gBattleMons[battler].moves[moveSlotIndex] == move && gBattleMons[battler].pp[moveSlotIndex] == 0)
return FALSE;
}
if (gBattleStruct->zmove.used[battlerId])
if (gBattleStruct->zmove.used[battler])
return FALSE;
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 ((GetBattlerPosition(battler) == B_POSITION_PLAYER_LEFT || (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) && GetBattlerPosition(battler) == B_POSITION_PLAYER_RIGHT)) && !CheckBagHasItem(ITEM_Z_POWER_RING, 1))
return FALSE;
if (item == ITEM_ENIGMA_BERRY_E_READER)
return FALSE; // HoldEffect = gEnigmaBerries[battlerId].holdEffect;
return FALSE; // HoldEffect = gEnigmaBerries[battler].holdEffect;
else
holdEffect = ItemId_GetHoldEffect(item);
if (holdEffect == HOLD_EFFECT_Z_CRYSTAL)
{
u16 zMove = GetSignatureZMove(move, gBattleMons[battlerId].species, item);
u16 zMove = GetSignatureZMove(move, gBattleMons[battler].species, item);
if (zMove != MOVE_NONE)
{
gBattleStruct->zmove.chosenZMove = zMove; // Signature z move exists
@ -200,7 +200,7 @@ bool32 IsViableZMove(u8 battlerId, u16 move)
if (move != MOVE_NONE && zMove != MOVE_Z_STATUS && gBattleMoves[move].type == ItemId_GetSecondaryId(item))
{
gBattleStruct->zmove.chosenZMove = GetTypeBasedZMove(move, battlerId);
gBattleStruct->zmove.chosenZMove = GetTypeBasedZMove(move, battler);
return TRUE;
}
}
@ -208,34 +208,34 @@ bool32 IsViableZMove(u8 battlerId, u16 move)
return FALSE;
}
void GetUsableZMoves(u8 battlerId, u16 *moves)
void GetUsableZMoves(u8 battler, u16 *moves)
{
u32 i;
gBattleStruct->zmove.possibleZMoves[battlerId] = 0;
gBattleStruct->zmove.possibleZMoves[battler] = 0;
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (moves[i] != MOVE_NONE && IsViableZMove(battlerId, moves[i]))
gBattleStruct->zmove.possibleZMoves[battlerId] |= (1 << i);
if (moves[i] != MOVE_NONE && IsViableZMove(battler, moves[i]))
gBattleStruct->zmove.possibleZMoves[battler] |= (1 << i);
}
}
bool32 IsZMoveUsable(u8 battlerId, u16 moveIndex)
bool32 IsZMoveUsable(u8 battler, u16 moveIndex)
{
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && IsPartnerMonFromSameTrainer(battlerId) && gBattleStruct->zmove.toBeUsed[BATTLE_PARTNER(battlerId)] != MOVE_NONE)
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && IsPartnerMonFromSameTrainer(battler) && gBattleStruct->zmove.toBeUsed[BATTLE_PARTNER(battler)] != MOVE_NONE)
return FALSE; // Player's other mon has a z move queued up already
if (gBattleStruct->zmove.possibleZMoves[battlerId] & (1 << moveIndex))
if (gBattleStruct->zmove.possibleZMoves[battler] & (1 << moveIndex))
return TRUE;
return FALSE;
}
bool32 TryChangeZIndicator(u8 battlerId, u8 moveIndex)
bool32 TryChangeZIndicator(u8 battler, u8 moveIndex)
{
bool32 viableZMove = IsZMoveUsable(battlerId, moveIndex);
bool32 viableZMove = IsZMoveUsable(battler, moveIndex);
if (gBattleStruct->zmove.viable && !viableZMove)
HideZMoveTriggerSprite(); // Was a viable z move, now is not -> slide out
else if (!gBattleStruct->zmove.viable && viableZMove)
ShowZMoveTriggerSprite(battlerId); // Was not a viable z move, now is -> slide back in
ShowZMoveTriggerSprite(battler); // Was not a viable z move, now is -> slide back in
}
#define SINGLES_Z_TRIGGER_POS_X_OPTIMAL (29)
@ -251,7 +251,7 @@ bool32 TryChangeZIndicator(u8 battlerId, u8 moveIndex)
#define tBattler data[0]
#define tHide data[1]
void CreateZMoveTriggerSprite(u8 battlerId, bool8 viable)
void CreateZMoveTriggerSprite(u8 battler, bool8 viable)
{
s16 x, y;
@ -261,19 +261,19 @@ void CreateZMoveTriggerSprite(u8 battlerId, bool8 viable)
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
x = gSprites[gHealthboxSpriteIds[battlerId]].x - DOUBLES_Z_TRIGGER_POS_X_SLIDE;
y = gSprites[gHealthboxSpriteIds[battlerId]].y - DOUBLES_Z_TRIGGER_POS_Y_DIFF;
x = gSprites[gHealthboxSpriteIds[battler]].x - DOUBLES_Z_TRIGGER_POS_X_SLIDE;
y = gSprites[gHealthboxSpriteIds[battler]].y - DOUBLES_Z_TRIGGER_POS_Y_DIFF;
}
else
{
x = gSprites[gHealthboxSpriteIds[battlerId]].x - SINGLES_Z_TRIGGER_POS_X_SLIDE;
y = gSprites[gHealthboxSpriteIds[battlerId]].y - SINGLES_Z_TRIGGER_POS_Y_DIFF, 0;
x = gSprites[gHealthboxSpriteIds[battler]].x - SINGLES_Z_TRIGGER_POS_X_SLIDE;
y = gSprites[gHealthboxSpriteIds[battler]].y - SINGLES_Z_TRIGGER_POS_Y_DIFF, 0;
}
if (gBattleStruct->zmove.triggerSpriteId == 0xFF)
gBattleStruct->zmove.triggerSpriteId = CreateSprite(&sSpriteTemplate_ZMoveTrigger, x, y, 0);
gSprites[gBattleStruct->zmove.triggerSpriteId].tBattler = battlerId;
gSprites[gBattleStruct->zmove.triggerSpriteId].tBattler = battler;
gSprites[gBattleStruct->zmove.triggerSpriteId].tHide = (viable == TRUE) ? FALSE : TRUE;
}
@ -348,11 +348,11 @@ void HideZMoveTriggerSprite(void)
sprite->tHide = TRUE;
}
static void ShowZMoveTriggerSprite(u8 battlerId)
static void ShowZMoveTriggerSprite(u8 battler)
{
struct Sprite *sprite = &gSprites[gBattleStruct->zmove.triggerSpriteId];
gBattleStruct->zmove.viable = TRUE;
CreateZMoveTriggerSprite(battlerId, TRUE);
CreateZMoveTriggerSprite(battler, TRUE);
}
void DestroyZMoveTriggerSprite(void)
@ -392,11 +392,11 @@ static u16 GetTypeBasedZMove(u16 move, u8 battler)
return MOVE_BREAKNECK_BLITZ + (moveType - 1);
}
bool32 MoveSelectionDisplayZMove(u16 zmove)
bool32 MoveSelectionDisplayZMove(u16 zmove, u32 battler)
{
u32 i;
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]);
u16 move = moveInfo->moves[gMoveSelectionCursor[gActiveBattler]];
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[battler][4]);
u16 move = moveInfo->moves[gMoveSelectionCursor[battler]];
PlaySE(SE_SELECT);
gBattleStruct->zmove.viewing = TRUE;
@ -507,8 +507,8 @@ bool32 MoveSelectionDisplayZMove(u16 zmove)
}
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MOVE_NAME_1);
ZMoveSelectionDisplayPpNumber();
ZMoveSelectionDisplayMoveType(zmove);
ZMoveSelectionDisplayPpNumber(battler);
ZMoveSelectionDisplayMoveType(zmove, battler);
MoveSelectionCreateCursorAt(0, 0);
return TRUE;
}
@ -532,26 +532,26 @@ static void ZMoveSelectionDisplayPower(u16 move, u16 zMove)
}
}
static void ZMoveSelectionDisplayPpNumber(void)
static void ZMoveSelectionDisplayPpNumber(u32 battler)
{
u8 *txtPtr;
struct ChooseMoveStruct *moveInfo;
if (gBattleResources->bufferA[gActiveBattler][2] == TRUE) // Check if we didn't want to display pp number
if (gBattleResources->bufferA[battler][2] == TRUE) // Check if we didn't want to display pp number
return;
SetPpNumbersPaletteInMoveSelection();
moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]);
SetPpNumbersPaletteInMoveSelection(battler);
moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[battler][4]);
txtPtr = ConvertIntToDecimalStringN(gDisplayedStringBattle, 1, STR_CONV_MODE_RIGHT_ALIGN, 2);
*(txtPtr)++ = CHAR_SLASH;
ConvertIntToDecimalStringN(txtPtr, 1, STR_CONV_MODE_RIGHT_ALIGN, 2);
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_PP_REMAINING);
}
static void ZMoveSelectionDisplayMoveType(u16 zMove)
static void ZMoveSelectionDisplayMoveType(u16 zMove, u32 battler)
{
u8 *txtPtr;
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]);
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[battler][4]);
u8 zMoveType;
GET_MOVE_TYPE(zMove, zMoveType);
@ -683,12 +683,12 @@ void SetZEffect(void)
gBattleStruct->zmove.zStatusActive = FALSE;
}
static bool32 AreStatsMaxed(u8 battlerId, u8 n)
static bool32 AreStatsMaxed(u8 battler, u8 n)
{
u32 i;
for (i = STAT_ATK; i <= n; i++)
{
if (STAT_STAGE(battlerId, i) < MAX_STAT_STAGE)
if (STAT_STAGE(battler, i) < MAX_STAT_STAGE)
return FALSE;
}
return TRUE;

View File

@ -616,13 +616,13 @@ static void RecordedBattle_RestoreSavedParties(void)
}
}
u8 GetActiveBattlerLinkPlayerGender(void)
u8 GetBattlerLinkPlayerGender(u32 battler)
{
s32 i;
for (i = 0; i < MAX_LINK_PLAYERS; i++)
{
if (gLinkPlayers[i].id == gActiveBattler)
if (gLinkPlayers[i].id == battler)
break;
}
@ -658,11 +658,11 @@ u8 GetTextSpeedInRecordedBattle(void)
return sTextSpeed;
}
void RecordedBattle_CopyBattlerMoves(void)
void RecordedBattle_CopyBattlerMoves(u32 battler)
{
s32 i;
if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT)
if (GetBattlerSide(battler) == B_SIDE_OPPONENT)
return;
if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK))
return;
@ -670,7 +670,7 @@ void RecordedBattle_CopyBattlerMoves(void)
return;
for (i = 0; i < MAX_MON_MOVES; i++)
sPlayerMonMoves[gActiveBattler / 2][i] = gBattleMons[gActiveBattler].moves[i];
sPlayerMonMoves[battler / 2][i] = gBattleMons[battler].moves[i];
}
// This is a special battle action only used by this function