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); u8 ComputeBattleAiScores(u8 battler);
void BattleAI_SetupItems(void); void BattleAI_SetupItems(void);
void BattleAI_SetupFlags(void); void BattleAI_SetupFlags(void);
void BattleAI_SetupAIData(u8 defaultScoreMoves); void BattleAI_SetupAIData(u8 defaultScoreMoves, u32 battler);
u8 BattleAI_ChooseMoveOrAction(void); u8 BattleAI_ChooseMoveOrAction(void);
void Ai_InitPartyStruct(void); void Ai_InitPartyStruct(void);
void Ai_UpdateSwitchInData(u32 battler); void Ai_UpdateSwitchInData(u32 battler);

View File

@ -239,13 +239,13 @@ enum
TRAINER_SLIDE_BEFORE_FIRST_TURN, TRAINER_SLIDE_BEFORE_FIRST_TURN,
}; };
void BufferStringBattle(u16 stringID); void BufferStringBattle(u16 stringID, u32 battler);
u32 BattleStringExpandPlaceholdersToDisplayedString(const u8 *src); u32 BattleStringExpandPlaceholdersToDisplayedString(const u8 *src);
u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst); u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst);
void BattlePutTextOnWindow(const u8 *text, u8 windowId); void BattlePutTextOnWindow(const u8 *text, u8 windowId);
void SetPpNumbersPaletteInMoveSelection(void); void SetPpNumbersPaletteInMoveSelection(u32 battler);
u8 GetCurrentPpToMaxPpState(u8 currentPp, u8 maxPp); 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); void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst);
extern struct BattleMsgData *gBattleMsgDataPtr; extern struct BattleMsgData *gBattleMsgDataPtr;

View File

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

View File

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

View File

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

View File

@ -184,7 +184,7 @@ void BattleAI_SetupFlags(void)
} }
// sBattler_AI set in ComputeBattleAiScores // sBattler_AI set in ComputeBattleAiScores
void BattleAI_SetupAIData(u8 defaultScoreMoves) void BattleAI_SetupAIData(u8 defaultScoreMoves, u32 battler)
{ {
s32 i, move, dmg; s32 i, move, dmg;
u8 moveLimitations; u8 moveLimitations;
@ -434,13 +434,11 @@ static u8 ChooseMoveOrAction_Singles(void)
if (AI_THINKING_STRUCT->aiAction & AI_ACTION_WATCH) if (AI_THINKING_STRUCT->aiAction & AI_ACTION_WATCH)
return AI_CHOICE_WATCH; return AI_CHOICE_WATCH;
gActiveBattler = sBattler_AI;
// If can switch. // If can switch.
if (CountUsablePartyMons(sBattler_AI) > 0 if (CountUsablePartyMons(sBattler_AI) > 0
&& !IsAbilityPreventingEscape(sBattler_AI) && !IsAbilityPreventingEscape(sBattler_AI)
&& !(gBattleMons[gActiveBattler].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION)) && !(gBattleMons[sBattler_AI].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION))
&& !(gStatuses3[gActiveBattler] & STATUS3_ROOTED) && !(gStatuses3[sBattler_AI] & STATUS3_ROOTED)
&& !(gBattleTypeFlags & (BATTLE_TYPE_ARENA | BATTLE_TYPE_PALACE)) && !(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)) && 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 //TODO: brighten z move symbol
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
if (!gBattleStruct->zmove.viewing) if (!gBattleStruct->zmove.viewing)
MoveSelectionDisplayZMove(gBattleStruct->zmove.chosenZMove); MoveSelectionDisplayZMove(gBattleStruct->zmove.chosenZMove, battler);
else else
ReloadMoveNames(battler); 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 if (gBattleResources->bufferA[battler][2] == TRUE) // check if we didn't want to display pp number
return; return;
SetPpNumbersPaletteInMoveSelection(); SetPpNumbersPaletteInMoveSelection(battler);
moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[battler][4]); moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[battler][4]);
txtPtr = ConvertIntToDecimalStringN(gDisplayedStringBattle, moveInfo->currentPp[gMoveSelectionCursor[battler]], STR_CONV_MODE_RIGHT_ALIGN, 2); txtPtr = ConvertIntToDecimalStringN(gDisplayedStringBattle, moveInfo->currentPp[gMoveSelectionCursor[battler]], STR_CONV_MODE_RIGHT_ALIGN, 2);
*(txtPtr)++ = CHAR_SLASH; *(txtPtr)++ = CHAR_SLASH;

View File

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

View File

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

View File

@ -764,7 +764,7 @@ static void SetAllPlayersBerryData(void)
{ {
s32 numPlayers; s32 numPlayers;
struct BattleEnigmaBerry *src; struct BattleEnigmaBerry *src;
u8 battlerId; u8 battler;
if (gBattleTypeFlags & BATTLE_TYPE_MULTI) if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{ {
@ -776,17 +776,17 @@ static void SetAllPlayersBerryData(void)
for (i = 0; i < numPlayers; i++) for (i = 0; i < numPlayers; i++)
{ {
src = (struct BattleEnigmaBerry *)(gBlockRecvBuffer[i] + 2); src = (struct BattleEnigmaBerry *)(gBlockRecvBuffer[i] + 2);
battlerId = gLinkPlayers[i].id; battler = gLinkPlayers[i].id;
for (j = 0; j < BERRY_NAME_LENGTH; j++) for (j = 0; j < BERRY_NAME_LENGTH; j++)
gEnigmaBerries[battlerId].name[j] = src->name[j]; gEnigmaBerries[battler].name[j] = src->name[j];
gEnigmaBerries[battlerId].name[j] = EOS; gEnigmaBerries[battler].name[j] = EOS;
for (j = 0; j < BERRY_ITEM_EFFECT_COUNT; j++) 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[battler].holdEffect = src->holdEffect;
gEnigmaBerries[battlerId].holdEffectParam = src->holdEffectParam; gEnigmaBerries[battler].holdEffectParam = src->holdEffectParam;
} }
} }
else else
@ -3000,7 +3000,6 @@ void BeginBattleIntro(void)
static void BattleMainCB1(void) static void BattleMainCB1(void)
{ {
gBattleMainFunc(); gBattleMainFunc();
for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++)
gBattlerControllerFuncs[gActiveBattler](gActiveBattler); gBattlerControllerFuncs[gActiveBattler](gActiveBattler);
} }
@ -4079,7 +4078,7 @@ static void HandleTurnActionSelectionState(void)
switch (gBattleCommunication[gActiveBattler]) switch (gBattleCommunication[gActiveBattler])
{ {
case STATE_TURN_START_RECORD: // Recorded battle related action on start of every turn. 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; gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN;
// Do AI score computations here so we can use them in AI_TrySwitchOrUseItem // 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]) switch (gBattleResources->bufferB[gActiveBattler][1])
{ {
case B_ACTION_USE_MOVE: case B_ACTION_USE_MOVE:
if (AreAllMovesUnusable()) if (AreAllMovesUnusable(gActiveBattler))
{ {
gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT; gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT;
*(gBattleStruct->selectionScriptFinished + gActiveBattler) = FALSE; *(gBattleStruct->selectionScriptFinished + gActiveBattler) = FALSE;
@ -4356,7 +4355,7 @@ static void HandleTurnActionSelectionState(void)
gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN; gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN;
RecordedBattle_ClearBattlerAction(gActiveBattler, 1); RecordedBattle_ClearBattlerAction(gActiveBattler, 1);
} }
else if (TrySetCantSelectMoveBattleScript()) else if (TrySetCantSelectMoveBattleScript(gActiveBattler))
{ {
RecordedBattle_ClearBattlerAction(gActiveBattler, 1); RecordedBattle_ClearBattlerAction(gActiveBattler, 1);
gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT; gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT;
@ -4598,12 +4597,12 @@ void SwapTurnOrder(u8 id1, u8 id2)
SWAP(gBattlerByTurnOrder[id1], gBattlerByTurnOrder[id2], temp); SWAP(gBattlerByTurnOrder[id1], gBattlerByTurnOrder[id2], temp);
} }
u32 GetBattlerTotalSpeedStat(u8 battlerId) u32 GetBattlerTotalSpeedStat(u8 battler)
{ {
u32 speed = gBattleMons[battlerId].speed; u32 speed = gBattleMons[battler].speed;
u32 ability = GetBattlerAbility(battlerId); u32 ability = GetBattlerAbility(battler);
u32 holdEffect = GetBattlerHoldEffect(battlerId, TRUE); u32 holdEffect = GetBattlerHoldEffect(battler, TRUE);
u32 highestStat = GetHighestStatId(battlerId); u32 highestStat = GetHighestStatId(battler);
// weather abilities // weather abilities
if (WEATHER_HAS_EFFECT) if (WEATHER_HAS_EFFECT)
@ -4619,11 +4618,11 @@ u32 GetBattlerTotalSpeedStat(u8 battlerId)
} }
// other abilities // 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; speed = (speed * 150) / 100;
else if (ability == ABILITY_SURGE_SURFER && gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN) else if (ability == ABILITY_SURGE_SURFER && gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN)
speed *= 2; speed *= 2;
else if (ability == ABILITY_SLOW_START && gDisableStructs[battlerId].slowStartTimer != 0) else if (ability == ABILITY_SLOW_START && gDisableStructs[battler].slowStartTimer != 0)
speed /= 2; speed /= 2;
else if (ability == ABILITY_PROTOSYNTHESIS && gBattleWeather & B_WEATHER_SUN && highestStat == STAT_SPEED) else if (ability == ABILITY_PROTOSYNTHESIS && gBattleWeather & B_WEATHER_SUN && highestStat == STAT_SPEED)
speed = (speed * 150) / 100; speed = (speed * 150) / 100;
@ -4631,13 +4630,13 @@ u32 GetBattlerTotalSpeedStat(u8 battlerId)
speed = (speed * 150) / 100; speed = (speed * 150) / 100;
// stat stages // stat stages
speed *= gStatStageRatios[gBattleMons[battlerId].statStages[STAT_SPEED]][0]; speed *= gStatStageRatios[gBattleMons[battler].statStages[STAT_SPEED]][0];
speed /= gStatStageRatios[gBattleMons[battlerId].statStages[STAT_SPEED]][1]; speed /= gStatStageRatios[gBattleMons[battler].statStages[STAT_SPEED]][1];
// player's badge boost // player's badge boost
if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_FRONTIER)) if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_FRONTIER))
&& ShouldGetStatBadgeBoost(FLAG_BADGE03_GET, battlerId) && ShouldGetStatBadgeBoost(FLAG_BADGE03_GET, battler)
&& GetBattlerSide(battlerId) == B_SIDE_PLAYER) && GetBattlerSide(battler) == B_SIDE_PLAYER)
{ {
speed = (speed * 110) / 100; speed = (speed * 110) / 100;
} }
@ -4649,17 +4648,17 @@ u32 GetBattlerTotalSpeedStat(u8 battlerId)
speed /= 2; speed /= 2;
else if (holdEffect == HOLD_EFFECT_CHOICE_SCARF) else if (holdEffect == HOLD_EFFECT_CHOICE_SCARF)
speed = (speed * 150) / 100; 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; speed *= 2;
// various effects // various effects
if (gSideStatuses[GET_BATTLER_SIDE(battlerId)] & SIDE_STATUS_TAILWIND) if (gSideStatuses[GET_BATTLER_SIDE(battler)] & SIDE_STATUS_TAILWIND)
speed *= 2; speed *= 2;
if (gBattleResources->flags->flags[battlerId] & RESOURCE_FLAG_UNBURDEN) if (gBattleResources->flags->flags[battler] & RESOURCE_FLAG_UNBURDEN)
speed *= 2; speed *= 2;
// paralysis drop // 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 #if B_PARALYSIS_SPEED >= GEN_7
speed /= 2; speed /= 2;
#else #else
@ -4669,28 +4668,28 @@ u32 GetBattlerTotalSpeedStat(u8 battlerId)
return speed; return speed;
} }
s8 GetChosenMovePriority(u32 battlerId) s8 GetChosenMovePriority(u32 battler)
{ {
u16 move; u16 move;
gProtectStructs[battlerId].pranksterElevated = 0; gProtectStructs[battler].pranksterElevated = 0;
if (gProtectStructs[battlerId].noValidMoves) if (gProtectStructs[battler].noValidMoves)
move = MOVE_STRUGGLE; move = MOVE_STRUGGLE;
else 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; s8 priority;
u16 ability = GetBattlerAbility(battlerId); u16 ability = GetBattlerAbility(battler);
priority = gBattleMoves[move].priority; priority = gBattleMoves[move].priority;
if (ability == ABILITY_GALE_WINGS if (ability == ABILITY_GALE_WINGS
#if B_GALE_WINGS >= GEN_7 #if B_GALE_WINGS >= GEN_7
&& BATTLER_MAX_HP(battlerId) && BATTLER_MAX_HP(battler)
#endif #endif
&& gBattleMoves[move].type == TYPE_FLYING) && gBattleMoves[move].type == TYPE_FLYING)
{ {
@ -4698,10 +4697,10 @@ s8 GetMovePriority(u32 battlerId, u16 move)
} }
else if (ability == ABILITY_PRANKSTER && IS_MOVE_STATUS(move)) else if (ability == ABILITY_PRANKSTER && IS_MOVE_STATUS(move))
{ {
gProtectStructs[battlerId].pranksterElevated = 1; gProtectStructs[battler].pranksterElevated = 1;
priority++; 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++; priority++;
} }
@ -4727,7 +4726,7 @@ s8 GetMovePriority(u32 battlerId, u16 move)
} }
} }
if (gProtectStructs[battlerId].quash) if (gProtectStructs[battler].quash)
priority = -8; priority = -8;
return priority; return priority;
@ -4838,14 +4837,14 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves)
static void SetActionsAndBattlersTurnOrder(void) static void SetActionsAndBattlersTurnOrder(void)
{ {
s32 turnOrderId = 0; s32 turnOrderId = 0;
s32 i, j; s32 i, j, battler;
if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) if (gBattleTypeFlags & BATTLE_TYPE_SAFARI)
{ {
for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) for (battler = 0; battler < gBattlersCount; battler++)
{ {
gActionsByTurnOrder[turnOrderId] = gChosenActionByBattler[gActiveBattler]; gActionsByTurnOrder[turnOrderId] = gChosenActionByBattler[battler];
gBattlerByTurnOrder[turnOrderId] = gActiveBattler; gBattlerByTurnOrder[turnOrderId] = battler;
turnOrderId++; turnOrderId++;
} }
} }
@ -4853,9 +4852,9 @@ static void SetActionsAndBattlersTurnOrder(void)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_LINK) 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; turnOrderId = 5;
break; break;
@ -4866,24 +4865,24 @@ static void SetActionsAndBattlersTurnOrder(void)
{ {
if (gChosenActionByBattler[0] == B_ACTION_RUN) if (gChosenActionByBattler[0] == B_ACTION_RUN)
{ {
gActiveBattler = 0; battler = 0;
turnOrderId = 5; turnOrderId = 5;
} }
if (gChosenActionByBattler[2] == B_ACTION_RUN) if (gChosenActionByBattler[2] == B_ACTION_RUN)
{ {
gActiveBattler = 2; battler = 2;
turnOrderId = 5; turnOrderId = 5;
} }
} }
if (turnOrderId == 5) // One of battlers wants to run. if (turnOrderId == 5) // One of battlers wants to run.
{ {
gActionsByTurnOrder[0] = gChosenActionByBattler[gActiveBattler]; gActionsByTurnOrder[0] = gChosenActionByBattler[battler];
gBattlerByTurnOrder[0] = gActiveBattler; gBattlerByTurnOrder[0] = battler;
turnOrderId = 1; turnOrderId = 1;
for (i = 0; i < gBattlersCount; i++) for (i = 0; i < gBattlersCount; i++)
{ {
if (i != gActiveBattler) if (i != battler)
{ {
gActionsByTurnOrder[turnOrderId] = gChosenActionByBattler[i]; gActionsByTurnOrder[turnOrderId] = gChosenActionByBattler[i];
gBattlerByTurnOrder[turnOrderId] = i; gBattlerByTurnOrder[turnOrderId] = i;
@ -4893,25 +4892,25 @@ static void SetActionsAndBattlersTurnOrder(void)
} }
else else
{ {
for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) for (battler = 0; battler < gBattlersCount; battler++)
{ {
if (gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_ITEM if (gChosenActionByBattler[battler] == B_ACTION_USE_ITEM
|| gChosenActionByBattler[gActiveBattler] == B_ACTION_SWITCH || gChosenActionByBattler[battler] == B_ACTION_SWITCH
|| gChosenActionByBattler[gActiveBattler] == B_ACTION_THROW_BALL) || gChosenActionByBattler[battler] == B_ACTION_THROW_BALL)
{ {
gActionsByTurnOrder[turnOrderId] = gChosenActionByBattler[gActiveBattler]; gActionsByTurnOrder[turnOrderId] = gChosenActionByBattler[battler];
gBattlerByTurnOrder[turnOrderId] = gActiveBattler; gBattlerByTurnOrder[turnOrderId] = battler;
turnOrderId++; turnOrderId++;
} }
} }
for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) for (battler = 0; battler < gBattlersCount; battler++)
{ {
if (gChosenActionByBattler[gActiveBattler] != B_ACTION_USE_ITEM if (gChosenActionByBattler[battler] != B_ACTION_USE_ITEM
&& gChosenActionByBattler[gActiveBattler] != B_ACTION_SWITCH && gChosenActionByBattler[battler] != B_ACTION_SWITCH
&& gChosenActionByBattler[gActiveBattler] != B_ACTION_THROW_BALL) && gChosenActionByBattler[battler] != B_ACTION_THROW_BALL)
{ {
gActionsByTurnOrder[turnOrderId] = gChosenActionByBattler[gActiveBattler]; gActionsByTurnOrder[turnOrderId] = gChosenActionByBattler[battler];
gBattlerByTurnOrder[turnOrderId] = gActiveBattler; gBattlerByTurnOrder[turnOrderId] = battler;
turnOrderId++; turnOrderId++;
} }
} }
@ -5046,8 +5045,8 @@ static bool32 TryDoMoveEffectsBeforeMoves(void)
&& !(gProtectStructs[battlers[i]].noValidMoves)) && !(gProtectStructs[battlers[i]].noValidMoves))
{ {
gBattleStruct->focusPunchBattlers |= gBitTable[battlers[i]]; gBattleStruct->focusPunchBattlers |= gBitTable[battlers[i]];
gActiveBattler = gBattlerAttacker = battlers[i]; gBattlerAttacker = battlers[i];
switch (gChosenMoveByBattler[gActiveBattler]) switch (gChosenMoveByBattler[gBattlerAttacker])
{ {
case MOVE_FOCUS_PUNCH: case MOVE_FOCUS_PUNCH:
BattleScriptExecute(BattleScript_FocusPunchSetUp); BattleScriptExecute(BattleScript_FocusPunchSetUp);
@ -5089,44 +5088,44 @@ static void TryChangeTurnOrder(void)
static void CheckQuickClaw_CustapBerryActivation(void) static void CheckQuickClaw_CustapBerryActivation(void)
{ {
u32 i; u32 i, battler;
if (!(gHitMarker & HITMARKER_RUN)) if (!(gHitMarker & HITMARKER_RUN))
{ {
while (gBattleStruct->quickClawBattlerId < gBattlersCount) while (gBattleStruct->quickClawBattlerId < gBattlersCount)
{ {
gActiveBattler = gBattlerAttacker = gBattleStruct->quickClawBattlerId; battler = gBattlerAttacker = gBattleStruct->quickClawBattlerId;
gBattleStruct->quickClawBattlerId++; gBattleStruct->quickClawBattlerId++;
if (gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_MOVE if (gChosenActionByBattler[battler] == B_ACTION_USE_MOVE
&& gChosenMoveByBattler[gActiveBattler] != MOVE_FOCUS_PUNCH // quick claw message doesn't need to activate here && gChosenMoveByBattler[battler] != MOVE_FOCUS_PUNCH // quick claw message doesn't need to activate here
&& (gProtectStructs[gActiveBattler].usedCustapBerry || gProtectStructs[gActiveBattler].quickDraw) && (gProtectStructs[battler].usedCustapBerry || gProtectStructs[battler].quickDraw)
&& !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP) && !(gBattleMons[battler].status1 & STATUS1_SLEEP)
&& !(gDisableStructs[gBattlerAttacker].truantCounter) && !(gDisableStructs[gBattlerAttacker].truantCounter)
&& !(gProtectStructs[gActiveBattler].noValidMoves)) && !(gProtectStructs[battler].noValidMoves))
{ {
if (gProtectStructs[gActiveBattler].usedCustapBerry) if (gProtectStructs[battler].usedCustapBerry)
{ {
gProtectStructs[gActiveBattler].usedCustapBerry = FALSE; gProtectStructs[battler].usedCustapBerry = FALSE;
gLastUsedItem = gBattleMons[gActiveBattler].item; gLastUsedItem = gBattleMons[battler].item;
PREPARE_ITEM_BUFFER(gBattleTextBuff1, gLastUsedItem); 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 // don't record berry since its gone now
BattleScriptExecute(BattleScript_CustapBerryActivation); BattleScriptExecute(BattleScript_CustapBerryActivation);
} }
else else
{ {
RecordItemEffectBattle(gActiveBattler, GetBattlerHoldEffect(gActiveBattler, FALSE)); RecordItemEffectBattle(battler, GetBattlerHoldEffect(battler, FALSE));
BattleScriptExecute(BattleScript_QuickClawActivation); BattleScriptExecute(BattleScript_QuickClawActivation);
} }
} }
else if (gProtectStructs[gActiveBattler].quickDraw) else if (gProtectStructs[battler].quickDraw)
{ {
gBattlerAbility = gActiveBattler; gBattlerAbility = battler;
gProtectStructs[gActiveBattler].quickDraw = FALSE; gProtectStructs[battler].quickDraw = FALSE;
gLastUsedAbility = gBattleMons[gActiveBattler].ability; gLastUsedAbility = gBattleMons[battler].ability;
PREPARE_ABILITY_BUFFER(gBattleTextBuff1, gLastUsedAbility); PREPARE_ABILITY_BUFFER(gBattleTextBuff1, gLastUsedAbility);
RecordAbilityBattle(gActiveBattler, gLastUsedAbility); RecordAbilityBattle(battler, gLastUsedAbility);
BattleScriptExecute(BattleScript_QuickDrawActivation); BattleScriptExecute(BattleScript_QuickDrawActivation);
} }
return; return;
@ -5179,7 +5178,7 @@ static void RunTurnActionsFunctions(void)
} }
else 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_NO_ATTACKSTRING;
gHitMarker &= ~HITMARKER_UNABLE_TO_USE_MOVE; 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) // special to set a field's totem boost(s)
// inputs: // inputs:
// var8000: battlerId // var8000: battler
// var8001 - var8007: stat changes // var8001 - var8007: stat changes
void SetTotemBoost(void) void SetTotemBoost(void)
{ {
u8 battlerId = gSpecialVar_0x8000; u8 battler = gSpecialVar_0x8000;
u8 i; u8 i;
for (i = 0; i < (NUM_BATTLE_STATS - 1); i++) for (i = 0; i < (NUM_BATTLE_STATS - 1); i++)
{ {
if (*(&gSpecialVar_0x8001 + i)) if (*(&gSpecialVar_0x8001 + i))
{ {
gTotemBoosts[battlerId].stats |= (1 << i); gTotemBoosts[battler].stats |= (1 << i);
gTotemBoosts[battlerId].statChanges[i] = *(&gSpecialVar_0x8001 + i); gTotemBoosts[battler].statChanges[i] = *(&gSpecialVar_0x8001 + i);
gTotemBoosts[battlerId].stats |= 0x80; // used as a flag for the "totem flared to life" script 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}; static const u8 sRecordedBattleTextSpeeds[] = {8, 4, 1, 0};
void BufferStringBattle(u16 stringID) void BufferStringBattle(u16 stringID, u32 battler)
{ {
s32 i; s32 i;
const u8 *stringPtr = NULL; const u8 *stringPtr = NULL;
gBattleMsgDataPtr = (struct BattleMsgData *)(&gBattleResources->bufferA[gActiveBattler][4]); gBattleMsgDataPtr = (struct BattleMsgData *)(&gBattleResources->bufferA[battler][4]);
gLastUsedItem = gBattleMsgDataPtr->lastItem; gLastUsedItem = gBattleMsgDataPtr->lastItem;
gLastUsedAbility = gBattleMsgDataPtr->lastAbility; gLastUsedAbility = gBattleMsgDataPtr->lastAbility;
gBattleScripting.battler = gBattleMsgDataPtr->scrActive; gBattleScripting.battler = gBattleMsgDataPtr->scrActive;
@ -2709,9 +2709,9 @@ void BufferStringBattle(u16 stringID)
} }
break; break;
case STRINGID_INTROSENDOUT: // poke first send-out 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) if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
stringPtr = sText_InGamePartnerSentOutZGoN; stringPtr = sText_InGamePartnerSentOutZGoN;
@ -2729,7 +2729,7 @@ void BufferStringBattle(u16 stringID)
} }
else 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) if (BATTLE_TWO_VS_ONE_OPPONENT)
stringPtr = sText_Trainer1SentOutTwoPkmn; stringPtr = sText_Trainer1SentOutTwoPkmn;
@ -2756,7 +2756,7 @@ void BufferStringBattle(u16 stringID)
} }
break; break;
case STRINGID_RETURNMON: // sending poke to ball msg case STRINGID_RETURNMON: // sending poke to ball msg
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) if (GetBattlerSide(battler) == B_SIDE_PLAYER)
{ {
if (*(&gBattleStruct->hpScale) == 0) if (*(&gBattleStruct->hpScale) == 0)
stringPtr = sText_PkmnThatsEnough; stringPtr = sText_PkmnThatsEnough;
@ -2845,7 +2845,7 @@ void BufferStringBattle(u16 stringID)
if (gBattleTextBuff1[0] & B_OUTCOME_LINK_BATTLE_RAN) if (gBattleTextBuff1[0] & B_OUTCOME_LINK_BATTLE_RAN)
{ {
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); gBattleTextBuff1[0] ^= (B_OUTCOME_LOST | B_OUTCOME_WON);
if (gBattleTextBuff1[0] == B_OUTCOME_LOST || gBattleTextBuff1[0] == B_OUTCOME_DREW) if (gBattleTextBuff1[0] == B_OUTCOME_LOST || gBattleTextBuff1[0] == B_OUTCOME_DREW)
@ -2857,7 +2857,7 @@ void BufferStringBattle(u16 stringID)
} }
else 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); gBattleTextBuff1[0] ^= (B_OUTCOME_LOST | B_OUTCOME_WON);
if (gBattleTypeFlags & BATTLE_TYPE_MULTI) if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
@ -2964,24 +2964,24 @@ static const u8 *TryGetStatusString(u8 *src)
return NULL; return NULL;
} }
static void GetBattlerNick(u32 battlerId, u8 *dst) static void GetBattlerNick(u32 battler, u8 *dst)
{ {
struct Pokemon *mon, *illusionMon; struct Pokemon *mon, *illusionMon;
if (GET_BATTLER_SIDE(battlerId) == B_SIDE_PLAYER) if (GET_BATTLER_SIDE(battler) == B_SIDE_PLAYER)
mon = &gPlayerParty[gBattlerPartyIndexes[battlerId]]; mon = &gPlayerParty[gBattlerPartyIndexes[battler]];
else else
mon = &gEnemyParty[gBattlerPartyIndexes[battlerId]]; mon = &gEnemyParty[gBattlerPartyIndexes[battler]];
illusionMon = GetIllusionMonPtr(battlerId); illusionMon = GetIllusionMonPtr(battler);
if (illusionMon != NULL) if (illusionMon != NULL)
mon = illusionMon; mon = illusionMon;
GetMonData(mon, MON_DATA_NICKNAME, dst); GetMonData(mon, MON_DATA_NICKNAME, dst);
StringGet_Nickname(dst); StringGet_Nickname(dst);
} }
#define HANDLE_NICKNAME_STRING_CASE(battlerId) \ #define HANDLE_NICKNAME_STRING_CASE(battler) \
if (GetBattlerSide(battlerId) != B_SIDE_PLAYER) \ if (GetBattlerSide(battler) != B_SIDE_PLAYER) \
{ \ { \
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) \ if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) \
toCpy = sText_FoePkmnPrefix; \ toCpy = sText_FoePkmnPrefix; \
@ -2994,10 +2994,10 @@ static void GetBattlerNick(u32 battlerId, u8 *dst)
toCpy++; \ toCpy++; \
} \ } \
} \ } \
GetBattlerNick(battlerId, text); \ GetBattlerNick(battler, text); \
toCpy = 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; const u8 *toCpy;
@ -3017,9 +3017,9 @@ static const u8 *BattleStringGetOpponentNameByTrainerId(u16 trainerId, u8 *text,
else if (trainerId == TRAINER_LINK_OPPONENT) else if (trainerId == TRAINER_LINK_OPPONENT)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_MULTI) if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
toCpy = gLinkPlayers[GetBattlerMultiplayerId(battlerId)].name; toCpy = gLinkPlayers[GetBattlerMultiplayerId(battler)].name;
else else
toCpy = gLinkPlayers[GetBattlerMultiplayerId(battlerId) & BIT_SIDE].name; toCpy = gLinkPlayers[GetBattlerMultiplayerId(battler) & BIT_SIDE].name;
} }
else if (trainerId == TRAINER_FRONTIER_BRAIN) else if (trainerId == TRAINER_FRONTIER_BRAIN)
{ {
@ -3049,31 +3049,31 @@ static const u8 *BattleStringGetOpponentNameByTrainerId(u16 trainerId, u8 *text,
return toCpy; 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; const u8 *toCpy;
switch (GetBattlerPosition(battlerId)) switch (GetBattlerPosition(battler))
{ {
case B_POSITION_OPPONENT_LEFT: case B_POSITION_OPPONENT_LEFT:
toCpy = BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_A, text, multiplayerId, battlerId); toCpy = BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_A, text, multiplayerId, battler);
break; break;
case B_POSITION_OPPONENT_RIGHT: case B_POSITION_OPPONENT_RIGHT:
if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_MULTI) && !BATTLE_TWO_VS_ONE_OPPONENT) 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 else
toCpy = BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_A, text, multiplayerId, battlerId); toCpy = BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_A, text, multiplayerId, battler);
break; break;
} }
return toCpy; return toCpy;
} }
static const u8 *BattleStringGetPlayerName(u8 *text, u8 battlerId) static const u8 *BattleStringGetPlayerName(u8 *text, u8 battler)
{ {
const u8 *toCpy; const u8 *toCpy;
switch (GetBattlerPosition(battlerId)) switch (GetBattlerPosition(battler))
{ {
case B_POSITION_PLAYER_LEFT: case B_POSITION_PLAYER_LEFT:
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) if (gBattleTypeFlags & BATTLE_TYPE_RECORDED)
@ -3105,12 +3105,12 @@ static const u8 *BattleStringGetPlayerName(u8 *text, u8 battlerId)
return toCpy; 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) if (GetBattlerSide(battler) == B_SIDE_PLAYER)
return BattleStringGetPlayerName(text, battlerId); return BattleStringGetPlayerName(text, battler);
else else
return BattleStringGetOpponentName(text, multiplayerId, battlerId); return BattleStringGetOpponentName(text, multiplayerId, battler);
} }
static const u8 *BattleStringGetOpponentClassByTrainerId(u16 trainerId) static const u8 *BattleStringGetOpponentClassByTrainerId(u16 trainerId)
@ -3248,7 +3248,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst)
GetBattlerNick(gActiveBattler, text); GetBattlerNick(gActiveBattler, text);
toCpy = text; toCpy = text;
break; 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) if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_NICKNAME, text); GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_NICKNAME, text);
else else
@ -3256,13 +3256,13 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst)
StringGet_Nickname(text); StringGet_Nickname(text);
toCpy = text; toCpy = text;
break; 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) HANDLE_NICKNAME_STRING_CASE(gEffectBattler)
break; 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) HANDLE_NICKNAME_STRING_CASE(gActiveBattler)
break; 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) HANDLE_NICKNAME_STRING_CASE(gBattleScripting.battler)
break; break;
case B_TXT_CURRENT_MOVE: // current move name 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 case B_TXT_SCR_ACTIVE_ABILITY: // scripting active ability
toCpy = gAbilityNames[sBattlerAbilities[gBattleScripting.battler]]; toCpy = gAbilityNames[sBattlerAbilities[gBattleScripting.battler]];
break; break;
case B_TXT_EFF_ABILITY: // effect battlerId ability case B_TXT_EFF_ABILITY: // effect battler ability
toCpy = gAbilityNames[sBattlerAbilities[gEffectBattler]]; toCpy = gAbilityNames[sBattlerAbilities[gEffectBattler]];
break; break;
case B_TXT_TRAINER1_CLASS: // trainer class name case B_TXT_TRAINER1_CLASS: // trainer class name
@ -3575,7 +3575,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst)
return dstID; return dstID;
} }
static void IllusionNickHack(u32 battlerId, u32 partyId, u8 *dst) static void IllusionNickHack(u32 battler, u32 partyId, u8 *dst)
{ {
s32 id, i; s32 id, i;
// we know it's gEnemyParty // we know it's gEnemyParty
@ -3583,8 +3583,8 @@ static void IllusionNickHack(u32 battlerId, u32 partyId, u8 *dst)
if (GetMonAbility(mon) == ABILITY_ILLUSION) if (GetMonAbility(mon) == ABILITY_ILLUSION)
{ {
if (IsBattlerAlive(BATTLE_PARTNER(battlerId))) if (IsBattlerAlive(BATTLE_PARTNER(battler)))
partnerMon = &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)]]; partnerMon = &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]];
else else
partnerMon = mon; 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; const u16 *palPtr = gPPTextPalette;
u8 var; u8 var;
if (!gBattleStruct->zmove.viewing) if (!gBattleStruct->zmove.viewing)
var = GetCurrentPpToMaxPpState(chooseMoveStruct->currentPp[gMoveSelectionCursor[gActiveBattler]], var = GetCurrentPpToMaxPpState(chooseMoveStruct->currentPp[gMoveSelectionCursor[battler]],
chooseMoveStruct->maxPp[gMoveSelectionCursor[gActiveBattler]]); chooseMoveStruct->maxPp[gMoveSelectionCursor[battler]]);
else 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) + 12] = palPtr[(var * 2) + 0];
gPlttBufferUnfaded[BG_PLTT_ID(5) + 11] = palPtr[(var * 2) + 1]; gPlttBufferUnfaded[BG_PLTT_ID(5) + 11] = palPtr[(var * 2) + 1];
@ -4005,38 +4005,38 @@ enum
NOT_EQUAL, NOT_EQUAL,
}; };
u32 BattlerHPPercentage(u32 battlerId, u32 operation, u32 threshold) u32 BattlerHPPercentage(u32 battler, u32 operation, u32 threshold)
{ {
switch (operation) switch (operation)
{ {
case LESS_THAN: case LESS_THAN:
return gBattleMons[battlerId].hp < (gBattleMons[battlerId].maxHP / threshold); return gBattleMons[battler].hp < (gBattleMons[battler].maxHP / threshold);
case EQUAL: case EQUAL:
return gBattleMons[battlerId].hp == (gBattleMons[battlerId].maxHP / threshold); return gBattleMons[battler].hp == (gBattleMons[battler].maxHP / threshold);
case GREATER_THAN: case GREATER_THAN:
return gBattleMons[battlerId].hp > (gBattleMons[battlerId].maxHP / threshold); return gBattleMons[battler].hp > (gBattleMons[battler].maxHP / threshold);
case LESS_THAN_OR_EQUAL: 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: case GREATER_THAN_OR_EQUAL:
return gBattleMons[battlerId].hp >= (gBattleMons[battlerId].maxHP / threshold); return gBattleMons[battler].hp >= (gBattleMons[battler].maxHP / threshold);
case NOT_EQUAL: case NOT_EQUAL:
return gBattleMons[battlerId].hp != (gBattleMons[battlerId].maxHP / threshold); return gBattleMons[battler].hp != (gBattleMons[battler].maxHP / threshold);
default: default:
break; break;
} }
} }
u32 ShouldDoTrainerSlide(u32 battlerId, u32 which) u32 ShouldDoTrainerSlide(u32 battler, u32 which)
{ {
u32 i, firstId, lastId, trainerId, retValue = 1; 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; return 0;
// Two opponents support. // Two opponents support.
if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)
{ {
if (gBattlerPartyIndexes[battlerId] >= 3) if (gBattlerPartyIndexes[battler] >= 3)
{ {
firstId = 3, lastId = PARTY_SIZE; firstId = 3, lastId = PARTY_SIZE;
trainerId = gTrainerBattleOpponent_B; 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)
|| (!(gBattleTypeFlags & BATTLE_TYPE_FRONTIER) && !sTrainerSlides[i].isFrontierTrainer))) || (!(gBattleTypeFlags & BATTLE_TYPE_FRONTIER) && !sTrainerSlides[i].isFrontierTrainer)))
{ {
gBattleScripting.battler = battlerId; gBattleScripting.battler = battler;
switch (which) switch (which)
{ {
case TRAINER_SLIDE_LAST_SWITCHIN: case TRAINER_SLIDE_LAST_SWITCHIN:
if (sTrainerSlides[i].msgLastSwitchIn != NULL && !CanBattlerSwitch(battlerId)) if (sTrainerSlides[i].msgLastSwitchIn != NULL && !CanBattlerSwitch(battler))
{ {
gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgLastSwitchIn; gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgLastSwitchIn;
return retValue; return retValue;
@ -4073,7 +4073,7 @@ u32 ShouldDoTrainerSlide(u32 battlerId, u32 which)
case TRAINER_SLIDE_LAST_LOW_HP: case TRAINER_SLIDE_LAST_LOW_HP:
if (sTrainerSlides[i].msgLastLowHp != NULL if (sTrainerSlides[i].msgLastLowHp != NULL
&& GetEnemyMonCount(firstId, lastId, TRUE) == 1 && GetEnemyMonCount(firstId, lastId, TRUE) == 1
&& BattlerHPPercentage(battlerId, GREATER_THAN_OR_EQUAL, 4) && BattlerHPPercentage(battler, GREATER_THAN_OR_EQUAL, 4)
&& !gBattleStruct->trainerSlideLowHpMsgDone) && !gBattleStruct->trainerSlideLowHpMsgDone)
{ {
gBattleStruct->trainerSlideLowHpMsgDone = TRUE; gBattleStruct->trainerSlideLowHpMsgDone = TRUE;
@ -4091,7 +4091,7 @@ u32 ShouldDoTrainerSlide(u32 battlerId, u32 which)
case TRAINER_SLIDE_LAST_HALF_HP: case TRAINER_SLIDE_LAST_HALF_HP:
if (sTrainerSlides[i].msgLastHalfHp != NULL if (sTrainerSlides[i].msgLastHalfHp != NULL
&& GetEnemyMonCount(firstId, lastId, TRUE) == GetEnemyMonCount(firstId, lastId, FALSE) - 1 && 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)
{ {
gBattleStruct->trainerSlideHalfHpMsgDone = TRUE; gBattleStruct->trainerSlideHalfHpMsgDone = TRUE;
@ -4110,7 +4110,7 @@ u32 ShouldDoTrainerSlide(u32 battlerId, u32 which)
case TRAINER_SLIDE_FIRST_SUPER_EFFECTIVE_HIT: case TRAINER_SLIDE_FIRST_SUPER_EFFECTIVE_HIT:
if (sTrainerSlides[i].msgFirstSuperEffectiveHit != NULL if (sTrainerSlides[i].msgFirstSuperEffectiveHit != NULL
&& gBattleStruct->trainerSlideFirstSuperEffectiveHitMsgState == 1 && gBattleStruct->trainerSlideFirstSuperEffectiveHitMsgState == 1
&& gBattleMons[battlerId].hp) && gBattleMons[battler].hp)
{ {
gBattleStruct->trainerSlideFirstSuperEffectiveHitMsgState = 2; gBattleStruct->trainerSlideFirstSuperEffectiveHitMsgState = 2;
gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgFirstSuperEffectiveHit; 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 bool8 IsTwoTurnsMove(u16 move);
static void TrySetDestinyBondToHappen(void); 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 u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr);
static bool32 IsMonGettingExpSentOut(void); static bool32 IsMonGettingExpSentOut(void);
static void InitLevelUpBanner(void); static void InitLevelUpBanner(void);
@ -1200,12 +1200,12 @@ static const u8 sBattlePalaceNatureToFlavorTextId[NUM_NATURES] =
[NATURE_QUIRKY] = B_MSG_EAGER_FOR_MORE, [NATURE_QUIRKY] = B_MSG_EAGER_FOR_MORE,
}; };
static bool32 NoTargetPresent(u8 battlerId, u32 move) static bool32 NoTargetPresent(u8 battler, u32 move)
{ {
if (!IsBattlerAlive(gBattlerTarget)) if (!IsBattlerAlive(gBattlerTarget))
gBattlerTarget = GetMoveTarget(move, NO_TARGET_OVERRIDE); gBattlerTarget = GetMoveTarget(move, NO_TARGET_OVERRIDE);
switch (GetBattlerMoveTargetType(battlerId, move)) switch (GetBattlerMoveTargetType(battler, move))
{ {
case MOVE_TARGET_SELECTED: case MOVE_TARGET_SELECTED:
case MOVE_TARGET_DEPENDS: case MOVE_TARGET_DEPENDS:
@ -2687,23 +2687,23 @@ static void Cmd_printselectionstringfromtable(void)
} }
} }
u8 GetBattlerTurnOrderNum(u8 battlerId) u8 GetBattlerTurnOrderNum(u8 battler)
{ {
s32 i; s32 i;
for (i = 0; i < gBattlersCount; i++) for (i = 0; i < gBattlersCount; i++)
{ {
if (gBattlerByTurnOrder[i] == battlerId) if (gBattlerByTurnOrder[i] == battler)
break; break;
} }
return i; 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; gBattleResources->flags->flags[battler] |= RESOURCE_FLAG_UNBURDEN;
RecordAbilityBattle(battlerId, ABILITY_UNBURDEN); RecordAbilityBattle(battler, ABILITY_UNBURDEN);
} }
} }
@ -2781,7 +2781,7 @@ void SetMoveEffect(bool32 primary, u32 certain)
if (gBattleScripting.moveEffect & MOVE_EFFECT_AFFECTS_USER) 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; gBattleScripting.moveEffect &= ~MOVE_EFFECT_AFFECTS_USER;
affectsUser = MOVE_EFFECT_AFFECTS_USER; affectsUser = MOVE_EFFECT_AFFECTS_USER;
gBattleScripting.battler = gBattlerTarget; // theoretically the attacker gBattleScripting.battler = gBattlerTarget; // theoretically the attacker
@ -3874,11 +3874,11 @@ static void Cmd_jumpifstatus(void)
{ {
CMD_ARGS(u8 battler, u32 flags, const u8 *jumpInstr); CMD_ARGS(u8 battler, u32 flags, const u8 *jumpInstr);
u8 battlerId = GetBattlerForBattleScript(cmd->battler); u8 battler = GetBattlerForBattleScript(cmd->battler);
u32 flags = cmd->flags; u32 flags = cmd->flags;
const u8 *jumpInstr = cmd->jumpInstr; 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; gBattlescriptCurrInstr = jumpInstr;
else else
gBattlescriptCurrInstr = cmd->nextInstr; gBattlescriptCurrInstr = cmd->nextInstr;
@ -3888,11 +3888,11 @@ static void Cmd_jumpifstatus2(void)
{ {
CMD_ARGS(u8 battler, u32 flags, const u8 *jumpInstr); CMD_ARGS(u8 battler, u32 flags, const u8 *jumpInstr);
u8 battlerId = GetBattlerForBattleScript(cmd->battler); u8 battler = GetBattlerForBattleScript(cmd->battler);
u32 flags = cmd->flags; u32 flags = cmd->flags;
const u8 *jumpInstr = cmd->jumpInstr; 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; gBattlescriptCurrInstr = jumpInstr;
else else
gBattlescriptCurrInstr = cmd->nextInstr; gBattlescriptCurrInstr = cmd->nextInstr;
@ -3902,30 +3902,30 @@ static void Cmd_jumpifability(void)
{ {
CMD_ARGS(u8 battler, u16 ability, const u8 *jumpInstr); CMD_ARGS(u8 battler, u16 ability, const u8 *jumpInstr);
u32 battlerId; u32 battler;
bool32 hasAbility = FALSE; bool32 hasAbility = FALSE;
u32 ability = cmd->ability; u32 ability = cmd->ability;
switch (cmd->battler) switch (cmd->battler)
{ {
default: default:
battlerId = GetBattlerForBattleScript(cmd->battler); battler = GetBattlerForBattleScript(cmd->battler);
if (GetBattlerAbility(battlerId) == ability) if (GetBattlerAbility(battler) == ability)
hasAbility = TRUE; hasAbility = TRUE;
break; break;
case BS_ATTACKER_SIDE: case BS_ATTACKER_SIDE:
battlerId = IsAbilityOnSide(gBattlerAttacker, ability); battler = IsAbilityOnSide(gBattlerAttacker, ability);
if (battlerId) if (battler)
{ {
battlerId--; battler--;
hasAbility = TRUE; hasAbility = TRUE;
} }
break; break;
case BS_TARGET_SIDE: case BS_TARGET_SIDE:
battlerId = IsAbilityOnOpposingSide(gBattlerAttacker, ability); battler = IsAbilityOnOpposingSide(gBattlerAttacker, ability);
if (battlerId) if (battler)
{ {
battlerId--; battler--;
hasAbility = TRUE; hasAbility = TRUE;
} }
break; break;
@ -3935,8 +3935,8 @@ static void Cmd_jumpifability(void)
{ {
gLastUsedAbility = ability; gLastUsedAbility = ability;
gBattlescriptCurrInstr = cmd->jumpInstr; gBattlescriptCurrInstr = cmd->jumpInstr;
RecordAbilityBattle(battlerId, gLastUsedAbility); RecordAbilityBattle(battler, gLastUsedAbility);
gBattlerAbility = battlerId; gBattlerAbility = battler;
} }
else else
{ {
@ -3967,12 +3967,12 @@ static void Cmd_jumpifstat(void)
CMD_ARGS(u8 battler, u8 comparison, u8 stat, u8 value, const u8 *jumpInstr); CMD_ARGS(u8 battler, u8 comparison, u8 stat, u8 value, const u8 *jumpInstr);
bool32 ret = 0; bool32 ret = 0;
u8 battlerId = GetBattlerForBattleScript(cmd->battler); u8 battler = GetBattlerForBattleScript(cmd->battler);
u8 stat = cmd->stat; u8 stat = cmd->stat;
u8 value = cmd->value; u8 value = cmd->value;
u8 comparison = cmd->comparison; u8 comparison = cmd->comparison;
ret = CompareStat(battlerId, stat, value, comparison); ret = CompareStat(battler, stat, value, comparison);
if (ret) if (ret)
gBattlescriptCurrInstr = cmd->jumpInstr; gBattlescriptCurrInstr = cmd->jumpInstr;
@ -4005,14 +4005,14 @@ static void Cmd_jumpbasedontype(void)
{ {
CMD_ARGS(u8 battler, u8 type, u8 jumpIfType, const u8 *jumpInstr); 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; u8 type = cmd->type;
const u8 *jumpInstr = cmd->jumpInstr; const u8 *jumpInstr = cmd->jumpInstr;
// jumpiftype // jumpiftype
if (cmd->jumpIfType) if (cmd->jumpIfType)
{ {
if (IS_BATTLER_OF_TYPE(battlerId, type)) if (IS_BATTLER_OF_TYPE(battler, type))
gBattlescriptCurrInstr = jumpInstr; gBattlescriptCurrInstr = jumpInstr;
else else
gBattlescriptCurrInstr = cmd->nextInstr; gBattlescriptCurrInstr = cmd->nextInstr;
@ -4020,7 +4020,7 @@ static void Cmd_jumpbasedontype(void)
// jumpifnottype // jumpifnottype
else else
{ {
if (!IS_BATTLER_OF_TYPE(battlerId, type)) if (!IS_BATTLER_OF_TYPE(battler, type))
gBattlescriptCurrInstr = jumpInstr; gBattlescriptCurrInstr = jumpInstr;
else else
gBattlescriptCurrInstr = cmd->nextInstr; gBattlescriptCurrInstr = cmd->nextInstr;
@ -4213,7 +4213,7 @@ static void Cmd_getexp(void)
i = STRINGID_EMPTYSTRING4; i = STRINGID_EMPTYSTRING4;
} }
// get exp getter battlerId // get exp getter battler
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{ {
if (gBattlerPartyIndexes[2] == gBattleStruct->expGetterMonId && !(gAbsentBattlerFlags & gBitTable[2])) if (gBattlerPartyIndexes[2] == gBattleStruct->expGetterMonId && !(gAbsentBattlerFlags & gBitTable[2]))
@ -4269,7 +4269,7 @@ static void Cmd_getexp(void)
u32 expBattler = gBattleStruct->expGetterBattlerId; u32 expBattler = gBattleStruct->expGetterBattlerId;
if (gBattleResources->bufferB[expBattler][0] == CONTROLLER_TWORETURNVALUES && gBattleResources->bufferB[expBattler][1] == RET_VALUE_LEVELED_UP) 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) if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && gBattlerPartyIndexes[expBattler] == gBattleStruct->expGetterMonId)
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[expBattler]], expBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[expBattler]], expBattler);
@ -4284,15 +4284,15 @@ static void Cmd_getexp(void)
// update battle mon structure after level up // update battle mon structure after level up
if (gBattlerPartyIndexes[0] == gBattleStruct->expGetterMonId && gBattleMons[0].hp) 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)) 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]); CopyMonLevelAndBaseStatsToBattleMon(battler, &gPlayerParty[gBattleStruct->expGetterMonId]);
if (gStatuses3[battlerId] & STATUS3_POWER_TRICK) if (gStatuses3[battler] & STATUS3_POWER_TRICK)
SWAP(gBattleMons[battlerId].attack, gBattleMons[battlerId].defense, temp); SWAP(gBattleMons[battler].attack, gBattleMons[battler].defense, temp);
} }
gBattleScripting.getexpState = 5; gBattleScripting.getexpState = 5;
@ -6236,13 +6236,13 @@ static void Cmd_switchinanim(void)
BattleArena_InitPoints(); BattleArena_InitPoints();
} }
bool32 CanBattlerSwitch(u32 battlerId) bool32 CanBattlerSwitch(u32 battler)
{ {
s32 i, lastMonId, battlerIn1, battlerIn2; s32 i, lastMonId, battlerIn1, battlerIn2;
bool32 ret = FALSE; bool32 ret = FALSE;
struct Pokemon *party; 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); battlerIn1 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
battlerIn2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); battlerIn2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
@ -6261,10 +6261,10 @@ bool32 CanBattlerSwitch(u32 battlerId)
} }
else if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) else if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
{ {
party = GetBattlerParty(battlerId); party = GetBattlerParty(battler);
lastMonId = 0; lastMonId = 0;
if (battlerId & 2) if (battler & 2)
lastMonId = MULTI_PARTY_SIZE; lastMonId = MULTI_PARTY_SIZE;
for (i = lastMonId; i < lastMonId + MULTI_PARTY_SIZE; i++) 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 if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE
&& !GetMonData(&party[i], MON_DATA_IS_EGG) && !GetMonData(&party[i], MON_DATA_IS_EGG)
&& GetMonData(&party[i], MON_DATA_HP) != 0 && GetMonData(&party[i], MON_DATA_HP) != 0
&& gBattlerPartyIndexes[battlerId] != i) && gBattlerPartyIndexes[battler] != i)
break; break;
} }
@ -6282,19 +6282,19 @@ bool32 CanBattlerSwitch(u32 battlerId)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_TOWER_LINK_MULTI) if (gBattleTypeFlags & BATTLE_TYPE_TOWER_LINK_MULTI)
{ {
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER) if (GetBattlerSide(battler) == B_SIDE_PLAYER)
{ {
party = gPlayerParty; party = gPlayerParty;
lastMonId = 0; lastMonId = 0;
if (GetLinkTrainerFlankId(GetBattlerMultiplayerId(battlerId)) == TRUE) if (GetLinkTrainerFlankId(GetBattlerMultiplayerId(battler)) == TRUE)
lastMonId = MULTI_PARTY_SIZE; lastMonId = MULTI_PARTY_SIZE;
} }
else else
{ {
party = gEnemyParty; party = gEnemyParty;
if (battlerId == 1) if (battler == 1)
lastMonId = 0; lastMonId = 0;
else else
lastMonId = MULTI_PARTY_SIZE; lastMonId = MULTI_PARTY_SIZE;
@ -6302,10 +6302,10 @@ bool32 CanBattlerSwitch(u32 battlerId)
} }
else else
{ {
party = GetBattlerParty(battlerId); party = GetBattlerParty(battler);
lastMonId = 0; lastMonId = 0;
if (GetLinkTrainerFlankId(GetBattlerMultiplayerId(battlerId)) == TRUE) if (GetLinkTrainerFlankId(GetBattlerMultiplayerId(battler)) == TRUE)
lastMonId = MULTI_PARTY_SIZE; lastMonId = MULTI_PARTY_SIZE;
} }
@ -6314,18 +6314,18 @@ bool32 CanBattlerSwitch(u32 battlerId)
if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE
&& !GetMonData(&party[i], MON_DATA_IS_EGG) && !GetMonData(&party[i], MON_DATA_IS_EGG)
&& GetMonData(&party[i], MON_DATA_HP) != 0 && GetMonData(&party[i], MON_DATA_HP) != 0
&& gBattlerPartyIndexes[battlerId] != i) && gBattlerPartyIndexes[battler] != i)
break; break;
} }
ret = (i != lastMonId + MULTI_PARTY_SIZE); 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; party = gEnemyParty;
lastMonId = 0; lastMonId = 0;
if (battlerId == B_POSITION_OPPONENT_RIGHT) if (battler == B_POSITION_OPPONENT_RIGHT)
lastMonId = PARTY_SIZE / 2; lastMonId = PARTY_SIZE / 2;
for (i = lastMonId; i < lastMonId + (PARTY_SIZE / 2); i++) 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 if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE
&& !GetMonData(&party[i], MON_DATA_IS_EGG) && !GetMonData(&party[i], MON_DATA_IS_EGG)
&& GetMonData(&party[i], MON_DATA_HP) != 0 && GetMonData(&party[i], MON_DATA_HP) != 0
&& gBattlerPartyIndexes[battlerId] != i) && gBattlerPartyIndexes[battler] != i)
break; break;
} }
@ -6341,7 +6341,7 @@ bool32 CanBattlerSwitch(u32 battlerId)
} }
else else
{ {
if (GetBattlerSide(battlerId) == B_SIDE_OPPONENT) if (GetBattlerSide(battler) == B_SIDE_OPPONENT)
{ {
battlerIn1 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); battlerIn1 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
@ -6761,11 +6761,11 @@ static void Cmd_switchhandleorder(void)
gBattlescriptCurrInstr = cmd->nextInstr; 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; gHitMarker &= ~HITMARKER_DESTINYBOND;
gBattleScripting.battler = battlerId; gBattleScripting.battler = battler;
gBattleCommunication[MULTISTRING_CHOOSER] = multistringId; gBattleCommunication[MULTISTRING_CHOOSER] = multistringId;
BattleScriptPushCursor(); BattleScriptPushCursor();
@ -6777,20 +6777,20 @@ static void SetDmgHazardsBattlescript(u8 battlerId, u8 multistringId)
gBattlescriptCurrInstr = BattleScript_DmgHazardsOnFaintedBattler; gBattlescriptCurrInstr = BattleScript_DmgHazardsOnFaintedBattler;
} }
bool32 DoSwitchInAbilitiesItems(u32 battlerId) bool32 DoSwitchInAbilitiesItems(u32 battler)
{ {
return (TryPrimalReversion(battlerId) return (TryPrimalReversion(battler)
|| AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, battlerId, 0, 0, 0) || AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, battler, 0, 0, 0)
|| (gBattleWeather & B_WEATHER_ANY && WEATHER_HAS_EFFECT && AbilityBattleEffects(ABILITYEFFECT_ON_WEATHER, battlerId, 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, battlerId, 0, 0, 0)) || (gFieldStatuses & STATUS_FIELD_TERRAIN_ANY && AbilityBattleEffects(ABILITYEFFECT_ON_TERRAIN, battler, 0, 0, 0))
|| ItemBattleEffects(ITEMEFFECT_ON_SWITCH_IN, battlerId, FALSE) || ItemBattleEffects(ITEMEFFECT_ON_SWITCH_IN, battler, FALSE)
|| AbilityBattleEffects(ABILITYEFFECT_TRACE2, 0, 0, 0, 0)); || AbilityBattleEffects(ABILITYEFFECT_TRACE2, 0, 0, 0, 0));
} }
bool32 ShouldPostponeSwitchInAbilities(u32 battlerId) bool32 ShouldPostponeSwitchInAbilities(u32 battler)
{ {
bool32 aliveOpposing1 = IsBattlerAlive(BATTLE_OPPOSITE(battlerId)); bool32 aliveOpposing1 = IsBattlerAlive(BATTLE_OPPOSITE(battler));
bool32 aliveOpposing2 = IsBattlerAlive(BATTLE_PARTNER(BATTLE_OPPOSITE(battlerId))); bool32 aliveOpposing2 = IsBattlerAlive(BATTLE_PARTNER(BATTLE_OPPOSITE(battler)));
// No pokemon on opposing side - postpone. // No pokemon on opposing side - postpone.
if (!aliveOpposing1 && !aliveOpposing2) if (!aliveOpposing1 && !aliveOpposing2)
return TRUE; 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. // Checks for double battle, so abilities like Intimidate wait until all battlers are switched-in before activating.
if (IsDoubleBattle()) 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; 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; 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 if (ItemId_GetPocket(itemId) == POCKET_BERRIES
&& GetBattlerAbility(battlerId) == ABILITY_CHEEK_POUCH && GetBattlerAbility(battler) == ABILITY_CHEEK_POUCH
&& !(gStatuses3[battlerId] & STATUS3_HEAL_BLOCK) && !(gStatuses3[battler] & STATUS3_HEAL_BLOCK)
&& gBattleStruct->ateBerry[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]] && gBattleStruct->ateBerry[GetBattlerSide(battler)] & gBitTable[gBattlerPartyIndexes[battler]]
&& !BATTLER_MAX_HP(battlerId)) && !BATTLER_MAX_HP(battler))
{ {
gBattleMoveDamage = gBattleMons[battlerId].maxHP / 3; gBattleMoveDamage = gBattleMons[battler].maxHP / 3;
if (gBattleMoveDamage == 0) if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1; gBattleMoveDamage = 1;
gBattleMoveDamage *= -1; gBattleMoveDamage *= -1;
gBattlerAbility = battlerId; gBattlerAbility = battler;
BattleScriptPush(gBattlescriptCurrInstr + 2); BattleScriptPush(gBattlescriptCurrInstr + 2);
gBattlescriptCurrInstr = BattleScript_CheekPouchActivates; gBattlescriptCurrInstr = BattleScript_CheekPouchActivates;
return TRUE; 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)); return !(B_PARALYZE_ELECTRIC >= GEN_6 && IS_BATTLER_OF_TYPE(battlerTarget, TYPE_ELECTRIC));
} }
bool32 CanUseLastResort(u8 battlerId) bool32 CanUseLastResort(u8 battler)
{ {
u32 i; u32 i;
u32 knownMovesCount = 0, usedMovesCount = 0; u32 knownMovesCount = 0, usedMovesCount = 0;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (gBattleMons[battlerId].moves[i] != MOVE_NONE) if (gBattleMons[battler].moves[i] != MOVE_NONE)
knownMovesCount++; 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++; usedMovesCount++;
} }
@ -8304,13 +8304,13 @@ u32 IsAbilityStatusProtected(u32 battler)
|| IsShieldsDownProtected(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++) 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) if (*statVal > highestStat)
{ {
highestStat = *statVal; highestStat = *statVal;
@ -8320,17 +8320,17 @@ u32 GetHighestStatId(u32 battlerId)
return highestId; return highestId;
} }
static bool32 IsRototillerAffected(u32 battlerId) static bool32 IsRototillerAffected(u32 battler)
{ {
if (!IsBattlerAlive(battlerId)) if (!IsBattlerAlive(battler))
return FALSE; return FALSE;
if (!IsBattlerGrounded(battlerId)) if (!IsBattlerGrounded(battler))
return FALSE; // Only grounded battlers affected 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 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 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 FALSE;
return TRUE; return TRUE;
} }
@ -8387,11 +8387,11 @@ static bool32 IsAbilityAbsorbAffected(void)
return FALSE; 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 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 FALSE; // Teatime doesn't affected semi-invulnerable battlers
return TRUE; return TRUE;
} }
@ -8455,35 +8455,35 @@ static bool32 CourtChangeSwapSideStatuses(void)
SWAP(sideTimerPlayer->stickyWebBattlerSide, sideTimerOpp->stickyWebBattlerSide, temp); 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 *party = GetBattlerParty(battler);
struct Pokemon *mon = &party[gBattlerPartyIndexes[battlerId]]; struct Pokemon *mon = &party[gBattlerPartyIndexes[battler]];
u32 position = GetBattlerPosition(battlerId); u32 position = GetBattlerPosition(battler);
u32 side = GET_BATTLER_SIDE(battlerId); u32 side = GET_BATTLER_SIDE(battler);
// Change species. // Change species.
if (caseId == 0) if (caseId == 0)
{ {
if (isMega) if (isMega)
{ {
if (!TryBattleFormChange(battlerId, FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM)) if (!TryBattleFormChange(battler, FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM))
TryBattleFormChange(battlerId, FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE); TryBattleFormChange(battler, FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE);
} }
else 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); BtlController_EmitSetMonData(battler, BUFFER_A, REQUEST_SPECIES_BATTLE, gBitTable[gBattlerPartyIndexes[battler]], sizeof(gBattleMons[battler].species), &gBattleMons[battler].species);
MarkBattlerForControllerExec(battlerId); MarkBattlerForControllerExec(battler);
} }
// Update healthbox and elevation and play cry. // Update healthbox and elevation and play cry.
else else
{ {
UpdateHealthboxAttribute(gHealthboxSpriteIds[battlerId], mon, HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], mon, HEALTHBOX_ALL);
if (side == B_SIDE_OPPONENT) if (side == B_SIDE_OPPONENT)
SetBattlerShadowSpriteCallback(battlerId, gBattleMons[battlerId].species); SetBattlerShadowSpriteCallback(battler, gBattleMons[battler].species);
if (isMega) if (isMega)
gBattleStruct->mega.alreadyEvolved[position] = TRUE; gBattleStruct->mega.alreadyEvolved[position] = TRUE;
} }
@ -10331,7 +10331,7 @@ static void Cmd_various(void)
if (cmd->fromBattler) if (cmd->fromBattler)
gLastUsedItem = gBattleMons[battler].item; 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)) if (ItemBattleEffects(ITEMEFFECT_USE_LAST_ITEM, battler, FALSE))
return; return;
gBattlescriptCurrInstr = cmd->nextInstr; gBattlescriptCurrInstr = cmd->nextInstr;
@ -11274,13 +11274,13 @@ static void Cmd_setmiracleeye(void)
} }
} }
bool8 UproarWakeUpCheck(u8 battlerId) bool8 UproarWakeUpCheck(u8 battler)
{ {
s32 i; s32 i;
for (i = 0; i < gBattlersCount; 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; continue;
gBattleScripting.battler = i; gBattleScripting.battler = i;
@ -12940,11 +12940,11 @@ static bool8 IsTwoTurnsMove(u16 move)
} }
// unused // 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 // first argument is unused
if (gBattleMoves[move].effect == EFFECT_SOLAR_BEAM if (gBattleMoves[move].effect == EFFECT_SOLAR_BEAM
&& IsBattlerWeatherAffected(battlerId, B_WEATHER_SUN)) && IsBattlerWeatherAffected(battler, B_WEATHER_SUN))
return 2; return 2;
if (gBattleMoves[move].effect == EFFECT_SKULL_BASH if (gBattleMoves[move].effect == EFFECT_SKULL_BASH
@ -14357,13 +14357,13 @@ static void Cmd_tryimprison(void)
} }
else else
{ {
u8 battlerId, sideAttacker; u8 battler, sideAttacker;
sideAttacker = GetBattlerSide(gBattlerAttacker); sideAttacker = GetBattlerSide(gBattlerAttacker);
PressurePPLoseOnUsingImprison(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; s32 attackerMoveId;
for (attackerMoveId = 0; attackerMoveId < MAX_MON_MOVES; attackerMoveId++) for (attackerMoveId = 0; attackerMoveId < MAX_MON_MOVES; attackerMoveId++)
@ -14371,7 +14371,7 @@ static void Cmd_tryimprison(void)
s32 i; s32 i;
for (i = 0; i < MAX_MON_MOVES; 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) && gBattleMons[gBattlerAttacker].moves[attackerMoveId] != MOVE_NONE)
break; 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; 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 FALSE;
return TRUE; return TRUE;
} }
@ -15879,7 +15879,7 @@ static const u16 sParentalBondBannedEffects[] =
EFFECT_UPROAR, EFFECT_UPROAR,
}; };
bool8 IsMoveAffectedByParentalBond(u16 move, u8 battlerId) bool8 IsMoveAffectedByParentalBond(u16 move, u8 battler)
{ {
if (move != MOVE_NONE && move != MOVE_STRUGGLE if (move != MOVE_NONE && move != MOVE_STRUGGLE
&& gBattleMoves[move].split != SPLIT_STATUS && gBattleMoves[move].split != SPLIT_STATUS
@ -15894,7 +15894,7 @@ bool8 IsMoveAffectedByParentalBond(u16 move, u8 battlerId)
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{ {
switch (GetBattlerMoveTargetType(battlerId, move)) switch (GetBattlerMoveTargetType(battler, move))
{ {
// Both foes are alive, spread move strikes once // Both foes are alive, spread move strikes once
case MOVE_TARGET_BOTH: case MOVE_TARGET_BOTH:
@ -16028,19 +16028,19 @@ static void TryUpdateRoundTurnOrder(void)
} }
} }
u8 GetFirstFaintedPartyIndex(u8 battlerId) u8 GetFirstFaintedPartyIndex(u8 battler)
{ {
u32 i; u32 i;
u32 start = 0; u32 start = 0;
u32 end = PARTY_SIZE; u32 end = PARTY_SIZE;
struct Pokemon *party = GetBattlerParty(battlerId); struct Pokemon *party = GetBattlerParty(battler);
// Check whether partner is separate trainer. // Check whether partner is separate trainer.
if ((GetBattlerSide(battlerId) == B_SIDE_PLAYER && gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) if ((GetBattlerSide(battler) == B_SIDE_PLAYER && gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
|| (GetBattlerSide(battlerId) == B_SIDE_OPPONENT && gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)) || (GetBattlerSide(battler) == B_SIDE_OPPONENT && gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS))
{ {
if (GetBattlerPosition(battlerId) == B_POSITION_OPPONENT_LEFT if (GetBattlerPosition(battler) == B_POSITION_OPPONENT_LEFT
|| GetBattlerPosition(battlerId) == B_POSITION_PLAYER_LEFT) || GetBattlerPosition(battler) == B_POSITION_PLAYER_LEFT)
{ {
end = PARTY_SIZE / 2; end = PARTY_SIZE / 2;
} }
@ -16070,7 +16070,7 @@ void BS_ItemRestoreHP(void)
{ {
NATIVE_ARGS(); NATIVE_ARGS();
u16 healAmount; u16 healAmount;
u32 battlerId = MAX_BATTLERS_COUNT; u32 battler = MAX_BATTLERS_COUNT;
u32 healParam = GetItemEffect(gLastUsedItem)[6]; u32 healParam = GetItemEffect(gLastUsedItem)[6];
u32 side = GetBattlerSide(gBattlerAttacker); u32 side = GetBattlerSide(gBattlerAttacker);
struct Pokemon *party = GetSideParty(side); struct Pokemon *party = GetSideParty(side);
@ -16084,10 +16084,10 @@ void BS_ItemRestoreHP(void)
// Check if the recipient is an active battler. // Check if the recipient is an active battler.
if (gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[gBattlerAttacker]) if (gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[gBattlerAttacker])
battlerId = gBattlerAttacker; battler = gBattlerAttacker;
else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE
&& gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[BATTLE_PARTNER(gBattlerAttacker)]) && gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[BATTLE_PARTNER(gBattlerAttacker)])
battlerId = BATTLE_PARTNER(gBattlerAttacker); battler = BATTLE_PARTNER(gBattlerAttacker);
// Get amount to heal. // Get amount to heal.
switch (healParam) switch (healParam)
@ -16109,7 +16109,7 @@ void BS_ItemRestoreHP(void)
healAmount = maxHP - hp; healAmount = maxHP - hp;
// Heal is applied as move damage if battler is active. // 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; gBattleMoveDamage = -healAmount;
} }
@ -16119,10 +16119,10 @@ void BS_ItemRestoreHP(void)
SetMonData(&party[gBattleStruct->itemPartyIndex[gBattlerAttacker]], MON_DATA_HP, &hp); SetMonData(&party[gBattleStruct->itemPartyIndex[gBattlerAttacker]], MON_DATA_HP, &hp);
// Revived battlers on the field need to be brought back. // 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]; gAbsentBattlerFlags &= ~gBitTable[battler];
gBattleScripting.battler = battlerId; gBattleScripting.battler = battler;
gBattleCommunication[MULTIUSE_STATE] = TRUE; gBattleCommunication[MULTIUSE_STATE] = TRUE;
} }
} }
@ -16173,7 +16173,7 @@ void BS_ItemRestorePP(void)
NATIVE_ARGS(); NATIVE_ARGS();
const u8 *effect = GetItemEffect(gLastUsedItem); const u8 *effect = GetItemEffect(gLastUsedItem);
u32 i, pp, maxPP, moveId, loopEnd; 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]]; struct Pokemon *mon = (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) ? &gPlayerParty[gBattleStruct->itemPartyIndex[gBattlerAttacker]] : &gEnemyParty[gBattleStruct->itemPartyIndex[gBattlerAttacker]];
// Check whether to apply to all moves. // Check whether to apply to all moves.
@ -16190,10 +16190,10 @@ void BS_ItemRestorePP(void)
// Check if the recipient is an active battler. // Check if the recipient is an active battler.
if (gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[gBattlerAttacker]) if (gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[gBattlerAttacker])
battlerId = gBattlerAttacker; battler = gBattlerAttacker;
else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE
&& gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[BATTLE_PARTNER(gBattlerAttacker)]) && gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[BATTLE_PARTNER(gBattlerAttacker)])
battlerId = BATTLE_PARTNER(gBattlerAttacker); battler = BATTLE_PARTNER(gBattlerAttacker);
// Heal PP! // Heal PP!
for (; i < loopEnd; i++) for (; i < loopEnd; i++)
@ -16209,11 +16209,11 @@ void BS_ItemRestorePP(void)
SetMonData(mon, MON_DATA_PP1 + i, &pp); SetMonData(mon, MON_DATA_PP1 + i, &pp);
// Update battler PP if needed. // Update battler PP if needed.
if (battlerId != MAX_BATTLERS_COUNT if (battler != MAX_BATTLERS_COUNT
&& gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[battlerId] && gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[battler]
&& MOVE_IS_PERMANENT(battlerId, i)) && 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) void HandleAction_Run(void)
{ {
gBattlerAttacker = gBattlerByTurnOrder[gCurrentTurnActionNumber]; s32 i;
gBattlerAttacker = gBattlerByTurnOrder[gCurrentTurnActionNumber];
if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK)) if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK))
{ {
gCurrentTurnActionNumber = gBattlersCount; 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; gBattleOutcome |= B_OUTCOME_LOST;
} }
else else
{ {
if (gChosenActionByBattler[gActiveBattler] == B_ACTION_RUN) if (gChosenActionByBattler[i] == B_ACTION_RUN)
gBattleOutcome |= B_OUTCOME_WON; gBattleOutcome |= B_OUTCOME_WON;
} }
} }
@ -1604,86 +1605,86 @@ static bool32 IsBelchPreventingMove(u32 battler, u32 move)
return !(gBattleStruct->ateBerry[battler & BIT_SIDE] & gBitTable[gBattlerPartyIndexes[battler]]); return !(gBattleStruct->ateBerry[battler & BIT_SIDE] & gBitTable[gBattlerPartyIndexes[battler]]);
} }
u8 TrySetCantSelectMoveBattleScript(void) u32 TrySetCantSelectMoveBattleScript(u32 battler)
{ {
u32 limitations = 0; u32 limitations = 0;
u8 moveId = gBattleResources->bufferB[gActiveBattler][2] & ~RET_MEGA_EVOLUTION; u8 moveId = gBattleResources->bufferB[battler][2] & ~RET_MEGA_EVOLUTION;
u32 move = gBattleMons[gActiveBattler].moves[moveId]; u32 move = gBattleMons[battler].moves[moveId];
u32 holdEffect = GetBattlerHoldEffect(gActiveBattler, TRUE); u32 holdEffect = GetBattlerHoldEffect(battler, TRUE);
u16 *choicedMove = &gBattleStruct->choicedMove[gActiveBattler]; 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; gCurrentMove = move;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingDisabledMoveInPalace; gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingDisabledMoveInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; gProtectStructs[battler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingDisabledMove; gSelectionBattleScripts[battler] = BattleScript_SelectingDisabledMove;
limitations++; 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) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingTormentedMoveInPalace; gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingTormentedMoveInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; gProtectStructs[battler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingTormentedMove; gSelectionBattleScripts[battler] = BattleScript_SelectingTormentedMove;
limitations++; 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; gCurrentMove = move;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveTauntInPalace; gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveTauntInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; gProtectStructs[battler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveTaunt; gSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveTaunt;
limitations++; 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; gCurrentMove = move;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveThroatChopInPalace; gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveThroatChopInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; gProtectStructs[battler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveThroatChop; gSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveThroatChop;
limitations++; limitations++;
} }
} }
if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] == MOVE_NONE && GetImprisonedMovesCount(gActiveBattler, move)) if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] == MOVE_NONE && GetImprisonedMovesCount(battler, move))
{ {
gCurrentMove = move; gCurrentMove = move;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingImprisonedMoveInPalace; gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingImprisonedMoveInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; gProtectStructs[battler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingImprisonedMove; gSelectionBattleScripts[battler] = BattleScript_SelectingImprisonedMove;
limitations++; limitations++;
} }
} }
@ -1693,118 +1694,118 @@ u8 TrySetCantSelectMoveBattleScript(void)
gCurrentMove = move; gCurrentMove = move;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveGravityInPalace; gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveGravityInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; gProtectStructs[battler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveGravity; gSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveGravity;
limitations++; limitations++;
} }
} }
if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] == MOVE_NONE && IsHealBlockPreventingMove(gActiveBattler, move)) if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] == MOVE_NONE && IsHealBlockPreventingMove(battler, move))
{ {
gCurrentMove = move; gCurrentMove = move;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveHealBlockInPalace; gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveHealBlockInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; gProtectStructs[battler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveHealBlock; gSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveHealBlock;
limitations++; limitations++;
} }
} }
if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] == MOVE_NONE && IsBelchPreventingMove(gActiveBattler, move)) if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] == MOVE_NONE && IsBelchPreventingMove(battler, move))
{ {
gCurrentMove = move; gCurrentMove = move;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedBelchInPalace; gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedBelchInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; gProtectStructs[battler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedBelch; gSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedBelch;
limitations++; 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; gCurrentMove = move;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedStuffCheeksInPalace; gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedStuffCheeksInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; gProtectStructs[battler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedStuffCheeks; gSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedStuffCheeks;
limitations++; limitations++;
} }
} }
gPotentialItemEffectBattler = gActiveBattler; gPotentialItemEffectBattler = battler;
if (HOLD_EFFECT_CHOICE(holdEffect) && *choicedMove != MOVE_NONE && *choicedMove != MOVE_UNAVAILABLE && *choicedMove != move) if (HOLD_EFFECT_CHOICE(holdEffect) && *choicedMove != MOVE_NONE && *choicedMove != MOVE_UNAVAILABLE && *choicedMove != move)
{ {
gCurrentMove = *choicedMove; gCurrentMove = *choicedMove;
gLastUsedItem = gBattleMons[gActiveBattler].item; gLastUsedItem = gBattleMons[battler].item;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveChoiceItemInPalace; gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveChoiceItemInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; gProtectStructs[battler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveChoiceItem; gSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveChoiceItem;
limitations++; limitations++;
} }
} }
else if (holdEffect == HOLD_EFFECT_ASSAULT_VEST && IS_MOVE_STATUS(move) && move != MOVE_ME_FIRST) else if (holdEffect == HOLD_EFFECT_ASSAULT_VEST && IS_MOVE_STATUS(move) && move != MOVE_ME_FIRST)
{ {
gCurrentMove = move; gCurrentMove = move;
gLastUsedItem = gBattleMons[gActiveBattler].item; gLastUsedItem = gBattleMons[battler].item;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveAssaultVestInPalace; gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveAssaultVestInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; gProtectStructs[battler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveAssaultVest; gSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveAssaultVest;
limitations++; limitations++;
} }
} }
if ((GetBattlerAbility(gActiveBattler) == ABILITY_GORILLA_TACTICS) && *choicedMove != MOVE_NONE if ((GetBattlerAbility(battler) == ABILITY_GORILLA_TACTICS) && *choicedMove != MOVE_NONE
&& *choicedMove != MOVE_UNAVAILABLE && *choicedMove != move) && *choicedMove != MOVE_UNAVAILABLE && *choicedMove != move)
{ {
gCurrentMove = *choicedMove; gCurrentMove = *choicedMove;
gLastUsedItem = gBattleMons[gActiveBattler].item; gLastUsedItem = gBattleMons[battler].item;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveGorillaTacticsInPalace; gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveGorillaTacticsInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; gProtectStructs[battler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveGorillaTactics; gSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedMoveGorillaTactics;
limitations++; limitations++;
} }
} }
if (gBattleMons[gActiveBattler].pp[moveId] == 0) if (gBattleMons[battler].pp[moveId] == 0)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; gProtectStructs[battler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingMoveWithNoPP; gSelectionBattleScripts[battler] = BattleScript_SelectingMoveWithNoPP;
limitations++; limitations++;
} }
} }
@ -1813,12 +1814,12 @@ u8 TrySetCantSelectMoveBattleScript(void)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedPlaceholderInPalace; gPalaceSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedPlaceholderInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; gProtectStructs[battler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedPlaceholder; gSelectionBattleScripts[battler] = BattleScript_SelectingNotAllowedPlaceholder;
limitations++; limitations++;
} }
} }
@ -1889,18 +1890,18 @@ u8 CheckMoveLimitations(u8 battler, u8 unusableMoves, u16 check)
} }
#define ALL_MOVES_MASK ((1 << MAX_MON_MOVES) - 1) #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. if (unusable == ALL_MOVES_MASK) // All moves are unusable.
{ {
gProtectStructs[gActiveBattler].noValidMoves = TRUE; gProtectStructs[battler].noValidMoves = TRUE;
gSelectionBattleScripts[gActiveBattler] = BattleScript_NoMovesLeft; gSelectionBattleScripts[battler] = BattleScript_NoMovesLeft;
} }
else else
{ {
gProtectStructs[gActiveBattler].noValidMoves = FALSE; gProtectStructs[battler].noValidMoves = FALSE;
} }
return (unusable == ALL_MOVES_MASK); return (unusable == ALL_MOVES_MASK);
@ -2055,7 +2056,7 @@ u8 DoFieldEndTurnEffects(void)
while (gBattleStruct->turnSideTracker < 2) while (gBattleStruct->turnSideTracker < 2)
{ {
side = gBattleStruct->turnSideTracker; side = gBattleStruct->turnSideTracker;
gActiveBattler = gBattlerAttacker = gSideTimers[side].reflectBattlerId; gBattlerAttacker = gSideTimers[side].reflectBattlerId;
if (gSideStatuses[side] & SIDE_STATUS_REFLECT) if (gSideStatuses[side] & SIDE_STATUS_REFLECT)
{ {
if (--gSideTimers[side].reflectTimer == 0) if (--gSideTimers[side].reflectTimer == 0)
@ -2080,7 +2081,7 @@ u8 DoFieldEndTurnEffects(void)
while (gBattleStruct->turnSideTracker < 2) while (gBattleStruct->turnSideTracker < 2)
{ {
side = gBattleStruct->turnSideTracker; side = gBattleStruct->turnSideTracker;
gActiveBattler = gBattlerAttacker = gSideTimers[side].lightscreenBattlerId; gBattlerAttacker = gSideTimers[side].lightscreenBattlerId;
if (gSideStatuses[side] & SIDE_STATUS_LIGHTSCREEN) if (gSideStatuses[side] & SIDE_STATUS_LIGHTSCREEN)
{ {
if (--gSideTimers[side].lightscreenTimer == 0) if (--gSideTimers[side].lightscreenTimer == 0)
@ -2106,7 +2107,7 @@ u8 DoFieldEndTurnEffects(void)
while (gBattleStruct->turnSideTracker < 2) while (gBattleStruct->turnSideTracker < 2)
{ {
side = gBattleStruct->turnSideTracker; side = gBattleStruct->turnSideTracker;
gActiveBattler = gBattlerAttacker = gSideTimers[side].auroraVeilBattlerId; gBattlerAttacker = gSideTimers[side].auroraVeilBattlerId;
if (gSideStatuses[side] & SIDE_STATUS_AURORA_VEIL) if (gSideStatuses[side] & SIDE_STATUS_AURORA_VEIL)
{ {
if (--gSideTimers[side].auroraVeilTimer == 0) if (--gSideTimers[side].auroraVeilTimer == 0)
@ -2132,7 +2133,7 @@ u8 DoFieldEndTurnEffects(void)
while (gBattleStruct->turnSideTracker < 2) while (gBattleStruct->turnSideTracker < 2)
{ {
side = gBattleStruct->turnSideTracker; side = gBattleStruct->turnSideTracker;
gActiveBattler = gBattlerAttacker = gSideTimers[side].mistBattlerId; gBattlerAttacker = gSideTimers[side].mistBattlerId;
if (gSideTimers[side].mistTimer != 0 && --gSideTimers[side].mistTimer == 0) if (gSideTimers[side].mistTimer != 0 && --gSideTimers[side].mistTimer == 0)
{ {
gSideStatuses[side] &= ~SIDE_STATUS_MIST; gSideStatuses[side] &= ~SIDE_STATUS_MIST;
@ -2155,7 +2156,7 @@ u8 DoFieldEndTurnEffects(void)
while (gBattleStruct->turnSideTracker < 2) while (gBattleStruct->turnSideTracker < 2)
{ {
side = gBattleStruct->turnSideTracker; side = gBattleStruct->turnSideTracker;
gActiveBattler = gBattlerAttacker = gSideTimers[side].safeguardBattlerId; gBattlerAttacker = gSideTimers[side].safeguardBattlerId;
if (gSideStatuses[side] & SIDE_STATUS_SAFEGUARD) if (gSideStatuses[side] & SIDE_STATUS_SAFEGUARD)
{ {
if (--gSideTimers[side].safeguardTimer == 0) if (--gSideTimers[side].safeguardTimer == 0)
@ -2179,7 +2180,7 @@ u8 DoFieldEndTurnEffects(void)
while (gBattleStruct->turnSideTracker < 2) while (gBattleStruct->turnSideTracker < 2)
{ {
side = gBattleStruct->turnSideTracker; side = gBattleStruct->turnSideTracker;
gActiveBattler = gBattlerAttacker = gSideTimers[side].luckyChantBattlerId; gBattlerAttacker = gSideTimers[side].luckyChantBattlerId;
if (gSideStatuses[side] & SIDE_STATUS_LUCKY_CHANT) if (gSideStatuses[side] & SIDE_STATUS_LUCKY_CHANT)
{ {
if (--gSideTimers[side].luckyChantTimer == 0) if (--gSideTimers[side].luckyChantTimer == 0)
@ -2203,7 +2204,7 @@ u8 DoFieldEndTurnEffects(void)
while (gBattleStruct->turnSideTracker < 2) while (gBattleStruct->turnSideTracker < 2)
{ {
side = gBattleStruct->turnSideTracker; side = gBattleStruct->turnSideTracker;
gActiveBattler = gBattlerAttacker = gSideTimers[side].tailwindBattlerId; gBattlerAttacker = gSideTimers[side].tailwindBattlerId;
if (gSideStatuses[side] & SIDE_STATUS_TAILWIND) if (gSideStatuses[side] & SIDE_STATUS_TAILWIND)
{ {
if (--gSideTimers[side].tailwindTimer == 0) if (--gSideTimers[side].tailwindTimer == 0)
@ -2226,12 +2227,12 @@ u8 DoFieldEndTurnEffects(void)
case ENDTURN_WISH: case ENDTURN_WISH:
while (gBattleStruct->turnSideTracker < gBattlersCount) while (gBattleStruct->turnSideTracker < gBattlersCount)
{ {
gActiveBattler = gBattlerByTurnOrder[gBattleStruct->turnSideTracker]; u32 battler = gBattlerByTurnOrder[gBattleStruct->turnSideTracker];
if (gWishFutureKnock.wishCounter[gActiveBattler] != 0 if (gWishFutureKnock.wishCounter[battler] != 0
&& --gWishFutureKnock.wishCounter[gActiveBattler] == 0 && --gWishFutureKnock.wishCounter[battler] == 0
&& gBattleMons[gActiveBattler].hp != 0) && gBattleMons[battler].hp != 0)
{ {
gBattlerTarget = gActiveBattler; gBattlerTarget = battler;
BattleScriptExecute(BattleScript_WishComesTrue); BattleScriptExecute(BattleScript_WishComesTrue);
effect++; effect++;
} }
@ -3102,41 +3103,42 @@ u8 DoBattlerEndTurnEffects(void)
bool8 HandleWishPerishSongOnTurnEnd(void) bool8 HandleWishPerishSongOnTurnEnd(void)
{ {
gHitMarker |= (HITMARKER_GRUDGE | HITMARKER_SKIP_DMG_TRACK); u32 battler;
gHitMarker |= (HITMARKER_GRUDGE | HITMARKER_SKIP_DMG_TRACK);
switch (gBattleStruct->wishPerishSongState) switch (gBattleStruct->wishPerishSongState)
{ {
case 0: case 0:
while (gBattleStruct->wishPerishSongBattlerId < gBattlersCount) while (gBattleStruct->wishPerishSongBattlerId < gBattlersCount)
{ {
gActiveBattler = gBattleStruct->wishPerishSongBattlerId; battler = gBattleStruct->wishPerishSongBattlerId;
if (gAbsentBattlerFlags & gBitTable[gActiveBattler]) if (gAbsentBattlerFlags & gBitTable[battler])
{ {
gBattleStruct->wishPerishSongBattlerId++; gBattleStruct->wishPerishSongBattlerId++;
continue; continue;
} }
gBattleStruct->wishPerishSongBattlerId++; gBattleStruct->wishPerishSongBattlerId++;
if (gWishFutureKnock.futureSightCounter[gActiveBattler] != 0 if (gWishFutureKnock.futureSightCounter[battler] != 0
&& --gWishFutureKnock.futureSightCounter[gActiveBattler] == 0 && --gWishFutureKnock.futureSightCounter[battler] == 0
&& gBattleMons[gActiveBattler].hp != 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; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_FUTURE_SIGHT;
else else
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_DOOM_DESIRE; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_DOOM_DESIRE;
PREPARE_MOVE_BUFFER(gBattleTextBuff1, gWishFutureKnock.futureSightMove[gActiveBattler]); PREPARE_MOVE_BUFFER(gBattleTextBuff1, gWishFutureKnock.futureSightMove[battler]);
gBattlerTarget = gActiveBattler; gBattlerTarget = battler;
gBattlerAttacker = gWishFutureKnock.futureSightAttacker[gActiveBattler]; gBattlerAttacker = gWishFutureKnock.futureSightAttacker[battler];
gSpecialStatuses[gBattlerTarget].dmg = 0xFFFF; gSpecialStatuses[gBattlerTarget].dmg = 0xFFFF;
gCurrentMove = gWishFutureKnock.futureSightMove[gActiveBattler]; gCurrentMove = gWishFutureKnock.futureSightMove[battler];
SetTypeBeforeUsingMove(gCurrentMove, gActiveBattler); SetTypeBeforeUsingMove(gCurrentMove, battler);
BattleScriptExecute(BattleScript_MonTookFutureAttack); BattleScriptExecute(BattleScript_MonTookFutureAttack);
if (gWishFutureKnock.futureSightCounter[gActiveBattler] == 0 if (gWishFutureKnock.futureSightCounter[battler] == 0
&& gWishFutureKnock.futureSightCounter[BATTLE_PARTNER(gActiveBattler)] == 0) && gWishFutureKnock.futureSightCounter[BATTLE_PARTNER(battler)] == 0)
{ {
gSideStatuses[GET_BATTLER_SIDE(gBattlerTarget)] &= ~SIDE_STATUS_FUTUREATTACK; gSideStatuses[GET_BATTLER_SIDE(gBattlerTarget)] &= ~SIDE_STATUS_FUTUREATTACK;
} }
@ -3149,37 +3151,33 @@ bool8 HandleWishPerishSongOnTurnEnd(void)
case 1: case 1:
while (gBattleStruct->wishPerishSongBattlerId < gBattlersCount) while (gBattleStruct->wishPerishSongBattlerId < gBattlersCount)
{ {
gActiveBattler = gBattlerAttacker = gBattlerByTurnOrder[gBattleStruct->wishPerishSongBattlerId]; battler = gBattlerAttacker = gBattlerByTurnOrder[gBattleStruct->wishPerishSongBattlerId];
if (gAbsentBattlerFlags & gBitTable[gActiveBattler]) if (gAbsentBattlerFlags & gBitTable[battler])
{ {
gBattleStruct->wishPerishSongBattlerId++; gBattleStruct->wishPerishSongBattlerId++;
continue; continue;
} }
gBattleStruct->wishPerishSongBattlerId++; gBattleStruct->wishPerishSongBattlerId++;
if (gStatuses3[gActiveBattler] & STATUS3_PERISH_SONG) if (gStatuses3[battler] & STATUS3_PERISH_SONG)
{ {
PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 1, gDisableStructs[gActiveBattler].perishSongTimer); PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 1, gDisableStructs[battler].perishSongTimer);
if (gDisableStructs[gActiveBattler].perishSongTimer == 0) if (gDisableStructs[battler].perishSongTimer == 0)
{ {
gStatuses3[gActiveBattler] &= ~STATUS3_PERISH_SONG; gStatuses3[battler] &= ~STATUS3_PERISH_SONG;
gBattleMoveDamage = gBattleMons[gActiveBattler].hp; gBattleMoveDamage = gBattleMons[battler].hp;
gBattlescriptCurrInstr = BattleScript_PerishSongTakesLife; gBattlescriptCurrInstr = BattleScript_PerishSongTakesLife;
} }
else else
{ {
gDisableStructs[gActiveBattler].perishSongTimer--; gDisableStructs[battler].perishSongTimer--;
gBattlescriptCurrInstr = BattleScript_PerishSongCountGoesDown; gBattlescriptCurrInstr = BattleScript_PerishSongCountGoesDown;
} }
BattleScriptExecute(gBattlescriptCurrInstr); BattleScriptExecute(gBattlescriptCurrInstr);
return TRUE; return TRUE;
} }
} }
// Hm... gBattleStruct->wishPerishSongState = 2;
{
u8 *state = &gBattleStruct->wishPerishSongState;
*state = 2;
gBattleStruct->wishPerishSongBattlerId = 0; gBattleStruct->wishPerishSongBattlerId = 0;
}
// fall through // fall through
case 2: case 2:
if ((gBattleTypeFlags & BATTLE_TYPE_ARENA) if ((gBattleTypeFlags & BATTLE_TYPE_ARENA)
@ -4889,7 +4887,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
} }
break; break;
case ABILITY_CUD_CHEW: 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)]; gLastUsedItem = gBattleStruct->usedHeldItems[battler][GetBattlerSide(battler)];
gBattleStruct->usedHeldItems[battler][GetBattlerSide(battler)] = ITEM_NONE; 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)) else if (TryChangeBattleWeather(battler, ENUM_WEATHER_SANDSTORM, TRUE))
{ {
gBattleScripting.battler = gActiveBattler = battler; gBattleScripting.battler = battler;
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_SandSpitActivates; gBattlescriptCurrInstr = BattleScript_SandSpitActivates;
effect++; 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)) 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 u32 chosenTarget;
u8 target1 = GetBattlerAtPosition(side); u32 side = (BATTLE_OPPOSITE(GetBattlerPosition(i))) & BIT_SIDE; // side of the opposing pokemon
u8 target2 = GetBattlerAtPosition(side + BIT_FLANK); u32 target1 = GetBattlerAtPosition(side);
u32 target2 = GetBattlerAtPosition(side + BIT_FLANK);
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{ {
if (!sAbilitiesNotTraced[gBattleMons[target1].ability] && gBattleMons[target1].hp != 0 if (!sAbilitiesNotTraced[gBattleMons[target1].ability] && gBattleMons[target1].hp != 0
&& !sAbilitiesNotTraced[gBattleMons[target2].ability] && gBattleMons[target2].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) 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) else if (!sAbilitiesNotTraced[gBattleMons[target2].ability] && gBattleMons[target2].hp != 0)
gActiveBattler = target2, effect++; chosenTarget = target2, effect++;
} }
else else
{ {
if (!sAbilitiesNotTraced[gBattleMons[target1].ability] && gBattleMons[target1].hp != 0) if (!sAbilitiesNotTraced[gBattleMons[target1].ability] && gBattleMons[target1].hp != 0)
gActiveBattler = target1, effect++; chosenTarget = target1, effect++;
} }
if (effect != 0) if (effect != 0)
@ -5912,11 +5911,11 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
gBattlescriptCurrInstr = BattleScript_TraceActivates; gBattlescriptCurrInstr = BattleScript_TraceActivates;
} }
gBattleResources->flags->flags[i] &= ~RESOURCE_FLAG_TRACED; gBattleResources->flags->flags[i] &= ~RESOURCE_FLAG_TRACED;
gBattleStruct->tracedAbility[i] = gLastUsedAbility = gBattleMons[gActiveBattler].ability; gBattleStruct->tracedAbility[i] = gLastUsedAbility = gBattleMons[chosenTarget].ability;
RecordAbilityBattle(gActiveBattler, gLastUsedAbility); // Record the opposing battler has this ability RecordAbilityBattle(chosenTarget, gLastUsedAbility); // Record the opposing battler has this ability
battler = gBattlerAbility = gBattleScripting.battler = i; 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) PREPARE_ABILITY_BUFFER(gBattleTextBuff2, gLastUsedAbility)
break; break;
} }
@ -6951,7 +6950,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battler, bool8 moveTurn)
{ {
gBattleScripting.battler = battler; gBattleScripting.battler = battler;
gPotentialItemEffectBattler = battler; gPotentialItemEffectBattler = battler;
gActiveBattler = gBattlerAttacker = battler; gBattlerAttacker = battler;
BattleScriptExecute(BattleScript_WhiteHerbEnd2); BattleScriptExecute(BattleScript_WhiteHerbEnd2);
} }
break; 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 && !(gCurrentMove == MOVE_PARTING_SHOT && CanBattlerSwitch(gBattlerAttacker))) // Does not activate if attacker used Parting Shot and can switch out
{ {
gProtectStructs[battler].statFell = FALSE; gProtectStructs[battler].statFell = FALSE;
gActiveBattler = gBattleScripting.battler = battler; gBattleScripting.battler = battler;
effect = ITEM_STATS_CHANGE; effect = ITEM_STATS_CHANGE;
if (moveTurn) if (moveTurn)
{ {
@ -7246,7 +7245,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battler, bool8 moveTurn)
{ {
gBattleScripting.battler = battler; gBattleScripting.battler = battler;
gPotentialItemEffectBattler = battler; gPotentialItemEffectBattler = battler;
gActiveBattler = gBattlerAttacker = battler; gBattlerAttacker = battler;
BattleScriptExecute(BattleScript_WhiteHerbEnd2); BattleScriptExecute(BattleScript_WhiteHerbEnd2);
} }
break; break;
@ -10100,7 +10099,7 @@ bool32 CanMegaEvolve(u8 battler)
struct Pokemon *mon; struct Pokemon *mon;
u8 battlerPosition = GetBattlerPosition(battler); u8 battlerPosition = GetBattlerPosition(battler);
u8 partnerPosition = GetBattlerPosition(BATTLE_PARTNER(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 // Check if Player has a Mega Ring
if ((GetBattlerPosition(battler) == B_POSITION_PLAYER_LEFT || (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) && GetBattlerPosition(battler) == B_POSITION_PLAYER_RIGHT)) 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 void SpriteCB_ZMoveTrigger(struct Sprite *sprite);
static u16 GetSignatureZMove(u16 move, u16 species, u16 item); static u16 GetSignatureZMove(u16 move, u16 species, u16 item);
static u16 GetTypeBasedZMove(u16 move, u8 battler); 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 ZMoveSelectionDisplayPower(u16 move, u16 zMove);
static void ShowZMoveTriggerSprite(u8 battleId); 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 u8 GetZMoveScore(u8 battlerAtk, u8 battlerDef, u16 baseMove, u16 zMove);
static void ZMoveSelectionDisplayMoveType(u16 zMove); static void ZMoveSelectionDisplayMoveType(u16 zMove, u32 battler);
// Const Data // Const Data
static const struct SignatureZMove sSignatureZMoves[] = static const struct SignatureZMove sSignatureZMoves[] =
@ -146,52 +146,52 @@ bool8 IsZMove(u16 move)
return move >= FIRST_Z_MOVE && move <= LAST_Z_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.toBeUsed[battler] = gBattleStruct->zmove.chosenZMove;
gBattleStruct->zmove.baseMoves[battlerId] = baseMove; gBattleStruct->zmove.baseMoves[battler] = baseMove;
if (gBattleStruct->zmove.chosenZMove == MOVE_LIGHT_THAT_BURNS_THE_SKY) if (gBattleStruct->zmove.chosenZMove == MOVE_LIGHT_THAT_BURNS_THE_SKY)
gBattleStruct->zmove.splits[battlerId] = GetSplitBasedOnStats(battlerId); gBattleStruct->zmove.splits[battler] = GetSplitBasedOnStats(battler);
else 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; struct Pokemon *mon;
u8 battlerPosition = GetBattlerPosition(battlerId); u8 battlerPosition = GetBattlerPosition(battler);
u8 partnerPosition = GetBattlerPosition(BATTLE_PARTNER(battlerId)); u8 partnerPosition = GetBattlerPosition(BATTLE_PARTNER(battler));
u32 item; u32 item;
u16 holdEffect; u16 holdEffect;
u16 species; u16 species;
int moveSlotIndex; int moveSlotIndex;
species = gBattleMons[battlerId].species; species = gBattleMons[battler].species;
item = gBattleMons[battlerId].item; item = gBattleMons[battler].item;
for (moveSlotIndex = 0; moveSlotIndex < MAX_MON_MOVES; moveSlotIndex++) 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; return FALSE;
} }
if (gBattleStruct->zmove.used[battlerId]) if (gBattleStruct->zmove.used[battler])
return FALSE; return FALSE;
if (gBattleTypeFlags & (BATTLE_TYPE_SAFARI | BATTLE_TYPE_WALLY_TUTORIAL | BATTLE_TYPE_FRONTIER)) if (gBattleTypeFlags & (BATTLE_TYPE_SAFARI | BATTLE_TYPE_WALLY_TUTORIAL | BATTLE_TYPE_FRONTIER))
return FALSE; 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; return FALSE;
if (item == ITEM_ENIGMA_BERRY_E_READER) if (item == ITEM_ENIGMA_BERRY_E_READER)
return FALSE; // HoldEffect = gEnigmaBerries[battlerId].holdEffect; return FALSE; // HoldEffect = gEnigmaBerries[battler].holdEffect;
else else
holdEffect = ItemId_GetHoldEffect(item); holdEffect = ItemId_GetHoldEffect(item);
if (holdEffect == HOLD_EFFECT_Z_CRYSTAL) 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) if (zMove != MOVE_NONE)
{ {
gBattleStruct->zmove.chosenZMove = zMove; // Signature z move exists 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)) 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; return TRUE;
} }
} }
@ -208,34 +208,34 @@ bool32 IsViableZMove(u8 battlerId, u16 move)
return FALSE; return FALSE;
} }
void GetUsableZMoves(u8 battlerId, u16 *moves) void GetUsableZMoves(u8 battler, u16 *moves)
{ {
u32 i; u32 i;
gBattleStruct->zmove.possibleZMoves[battlerId] = 0; gBattleStruct->zmove.possibleZMoves[battler] = 0;
for (i = 0; i < MAX_MON_MOVES; i++) for (i = 0; i < MAX_MON_MOVES; i++)
{ {
if (moves[i] != MOVE_NONE && IsViableZMove(battlerId, moves[i])) if (moves[i] != MOVE_NONE && IsViableZMove(battler, moves[i]))
gBattleStruct->zmove.possibleZMoves[battlerId] |= (1 << 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 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 TRUE;
return FALSE; 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) if (gBattleStruct->zmove.viable && !viableZMove)
HideZMoveTriggerSprite(); // Was a viable z move, now is not -> slide out HideZMoveTriggerSprite(); // Was a viable z move, now is not -> slide out
else if (!gBattleStruct->zmove.viable && viableZMove) 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) #define SINGLES_Z_TRIGGER_POS_X_OPTIMAL (29)
@ -251,7 +251,7 @@ bool32 TryChangeZIndicator(u8 battlerId, u8 moveIndex)
#define tBattler data[0] #define tBattler data[0]
#define tHide data[1] #define tHide data[1]
void CreateZMoveTriggerSprite(u8 battlerId, bool8 viable) void CreateZMoveTriggerSprite(u8 battler, bool8 viable)
{ {
s16 x, y; s16 x, y;
@ -261,19 +261,19 @@ void CreateZMoveTriggerSprite(u8 battlerId, bool8 viable)
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{ {
x = gSprites[gHealthboxSpriteIds[battlerId]].x - DOUBLES_Z_TRIGGER_POS_X_SLIDE; x = gSprites[gHealthboxSpriteIds[battler]].x - DOUBLES_Z_TRIGGER_POS_X_SLIDE;
y = gSprites[gHealthboxSpriteIds[battlerId]].y - DOUBLES_Z_TRIGGER_POS_Y_DIFF; y = gSprites[gHealthboxSpriteIds[battler]].y - DOUBLES_Z_TRIGGER_POS_Y_DIFF;
} }
else else
{ {
x = gSprites[gHealthboxSpriteIds[battlerId]].x - SINGLES_Z_TRIGGER_POS_X_SLIDE; x = gSprites[gHealthboxSpriteIds[battler]].x - SINGLES_Z_TRIGGER_POS_X_SLIDE;
y = gSprites[gHealthboxSpriteIds[battlerId]].y - SINGLES_Z_TRIGGER_POS_Y_DIFF, 0; y = gSprites[gHealthboxSpriteIds[battler]].y - SINGLES_Z_TRIGGER_POS_Y_DIFF, 0;
} }
if (gBattleStruct->zmove.triggerSpriteId == 0xFF) if (gBattleStruct->zmove.triggerSpriteId == 0xFF)
gBattleStruct->zmove.triggerSpriteId = CreateSprite(&sSpriteTemplate_ZMoveTrigger, x, y, 0); 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; gSprites[gBattleStruct->zmove.triggerSpriteId].tHide = (viable == TRUE) ? FALSE : TRUE;
} }
@ -348,11 +348,11 @@ void HideZMoveTriggerSprite(void)
sprite->tHide = TRUE; sprite->tHide = TRUE;
} }
static void ShowZMoveTriggerSprite(u8 battlerId) static void ShowZMoveTriggerSprite(u8 battler)
{ {
struct Sprite *sprite = &gSprites[gBattleStruct->zmove.triggerSpriteId]; struct Sprite *sprite = &gSprites[gBattleStruct->zmove.triggerSpriteId];
gBattleStruct->zmove.viable = TRUE; gBattleStruct->zmove.viable = TRUE;
CreateZMoveTriggerSprite(battlerId, TRUE); CreateZMoveTriggerSprite(battler, TRUE);
} }
void DestroyZMoveTriggerSprite(void) void DestroyZMoveTriggerSprite(void)
@ -392,11 +392,11 @@ static u16 GetTypeBasedZMove(u16 move, u8 battler)
return MOVE_BREAKNECK_BLITZ + (moveType - 1); return MOVE_BREAKNECK_BLITZ + (moveType - 1);
} }
bool32 MoveSelectionDisplayZMove(u16 zmove) bool32 MoveSelectionDisplayZMove(u16 zmove, u32 battler)
{ {
u32 i; u32 i;
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]); struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[battler][4]);
u16 move = moveInfo->moves[gMoveSelectionCursor[gActiveBattler]]; u16 move = moveInfo->moves[gMoveSelectionCursor[battler]];
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
gBattleStruct->zmove.viewing = TRUE; gBattleStruct->zmove.viewing = TRUE;
@ -507,8 +507,8 @@ bool32 MoveSelectionDisplayZMove(u16 zmove)
} }
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MOVE_NAME_1); BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MOVE_NAME_1);
ZMoveSelectionDisplayPpNumber(); ZMoveSelectionDisplayPpNumber(battler);
ZMoveSelectionDisplayMoveType(zmove); ZMoveSelectionDisplayMoveType(zmove, battler);
MoveSelectionCreateCursorAt(0, 0); MoveSelectionCreateCursorAt(0, 0);
return TRUE; return TRUE;
} }
@ -532,26 +532,26 @@ static void ZMoveSelectionDisplayPower(u16 move, u16 zMove)
} }
} }
static void ZMoveSelectionDisplayPpNumber(void) static void ZMoveSelectionDisplayPpNumber(u32 battler)
{ {
u8 *txtPtr; u8 *txtPtr;
struct ChooseMoveStruct *moveInfo; 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; return;
SetPpNumbersPaletteInMoveSelection(); SetPpNumbersPaletteInMoveSelection(battler);
moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]); moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[battler][4]);
txtPtr = ConvertIntToDecimalStringN(gDisplayedStringBattle, 1, STR_CONV_MODE_RIGHT_ALIGN, 2); txtPtr = ConvertIntToDecimalStringN(gDisplayedStringBattle, 1, STR_CONV_MODE_RIGHT_ALIGN, 2);
*(txtPtr)++ = CHAR_SLASH; *(txtPtr)++ = CHAR_SLASH;
ConvertIntToDecimalStringN(txtPtr, 1, STR_CONV_MODE_RIGHT_ALIGN, 2); ConvertIntToDecimalStringN(txtPtr, 1, STR_CONV_MODE_RIGHT_ALIGN, 2);
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_PP_REMAINING); BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_PP_REMAINING);
} }
static void ZMoveSelectionDisplayMoveType(u16 zMove) static void ZMoveSelectionDisplayMoveType(u16 zMove, u32 battler)
{ {
u8 *txtPtr; u8 *txtPtr;
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]); struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[battler][4]);
u8 zMoveType; u8 zMoveType;
GET_MOVE_TYPE(zMove, zMoveType); GET_MOVE_TYPE(zMove, zMoveType);
@ -683,12 +683,12 @@ void SetZEffect(void)
gBattleStruct->zmove.zStatusActive = FALSE; gBattleStruct->zmove.zStatusActive = FALSE;
} }
static bool32 AreStatsMaxed(u8 battlerId, u8 n) static bool32 AreStatsMaxed(u8 battler, u8 n)
{ {
u32 i; u32 i;
for (i = STAT_ATK; i <= n; 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 FALSE;
} }
return TRUE; return TRUE;

View File

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