mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-25 03:04:15 +01:00
start removing gActiveBattler in controller emitters
This commit is contained in:
parent
326fb2605a
commit
156aa59f18
@ -352,6 +352,7 @@ struct BattleResources
|
||||
struct BattleHistory *battleHistory;
|
||||
u8 bufferA[MAX_BATTLERS_COUNT][0x200];
|
||||
u8 bufferB[MAX_BATTLERS_COUNT][0x200];
|
||||
u8 transferBuffer[0x100];
|
||||
};
|
||||
|
||||
#define AI_THINKING_STRUCT ((struct AI_ThinkingStruct *)(gBattleResources->ai))
|
||||
|
@ -2,8 +2,8 @@
|
||||
#define GUARD_BATTLE_AI_SWITCH_ITEMS_H
|
||||
|
||||
void GetAIPartyIndexes(u32 battlerId, s32 *firstId, s32 *lastId);
|
||||
void AI_TrySwitchOrUseItem(void);
|
||||
u8 GetMostSuitableMonToSwitchInto(void);
|
||||
bool32 ShouldSwitch(void);
|
||||
void AI_TrySwitchOrUseItem(u32 battler);
|
||||
u8 GetMostSuitableMonToSwitchInto(u32 battler);
|
||||
bool32 ShouldSwitch(u32 battler);
|
||||
|
||||
#endif // GUARD_BATTLE_AI_SWITCH_ITEMS_H
|
||||
|
@ -207,52 +207,52 @@ void SetUpBattleVarsAndBirchZigzagoon(void);
|
||||
void InitBattleControllers(void);
|
||||
bool32 IsValidForBattle(struct Pokemon *mon);
|
||||
void TryReceiveLinkBattleData(void);
|
||||
void PrepareBufferDataTransferLink(u8 bufferId, u16 size, u8 *data);
|
||||
void PrepareBufferDataTransferLink(u32 battler, u32 bufferId, u16 size, u8 *data);
|
||||
|
||||
// emitters
|
||||
void BtlController_EmitGetMonData(u8 bufferId, u8 requestId, u8 monToCheck);
|
||||
void BtlController_EmitSetMonData(u8 bufferId, u8 requestId, u8 monToCheck, u8 bytes, void *data);
|
||||
void BtlController_EmitLoadMonSprite(u8 bufferId);
|
||||
void BtlController_EmitSwitchInAnim(u8 bufferId, u8 partyId, bool8 dontClearSubstituteBit);
|
||||
void BtlController_EmitReturnMonToBall(u8 bufferId, bool8 skipAnim);
|
||||
void BtlController_EmitDrawTrainerPic(u8 bufferId);
|
||||
void BtlController_EmitTrainerSlide(u8 bufferId);
|
||||
void BtlController_EmitTrainerSlideBack(u8 bufferId);
|
||||
void BtlController_EmitFaintAnimation(u8 bufferId);
|
||||
void BtlController_EmitBallThrowAnim(u8 bufferId, u8 caseId);
|
||||
void BtlController_EmitMoveAnimation(u8 bufferId, u16 move, u8 turnOfMove, u16 movePower, s32 dmg, u8 friendship, struct DisableStruct *disableStructPtr, u8 multihit);
|
||||
void BtlController_EmitPrintString(u8 bufferId, u16 stringId);
|
||||
void BtlController_EmitPrintSelectionString(u8 bufferId, u16 stringId);
|
||||
void BtlController_EmitChooseAction(u8 bufferId, u8 action, u16 itemId);
|
||||
void BtlController_EmitYesNoBox(u8 bufferId);
|
||||
void BtlController_EmitChooseMove(u8 bufferId, bool8 isDoubleBattle, bool8 NoPpNumber, struct ChooseMoveStruct *movePpData);
|
||||
void BtlController_EmitChooseItem(u8 bufferId, u8 *battlePartyOrder);
|
||||
void BtlController_EmitChoosePokemon(u8 bufferId, u8 caseId, u8 slotId, u16 abilityId, u8 *data);
|
||||
void BtlController_EmitHealthBarUpdate(u8 bufferId, u16 hpValue);
|
||||
void BtlController_EmitExpUpdate(u8 bufferId, u8 partyId, s32 expPoints);
|
||||
void BtlController_EmitStatusIconUpdate(u8 bufferId, u32 status1, u32 status2);
|
||||
void BtlController_EmitStatusAnimation(u8 bufferId, bool8 status2, u32 status);
|
||||
void BtlController_EmitDataTransfer(u8 bufferId, u16 size, void *data);
|
||||
void BtlController_EmitTwoReturnValues(u8 bufferId, u8 ret8, u32 ret32);
|
||||
void BtlController_EmitChosenMonReturnValue(u8 bufferId, u8 partyId, u8 *battlePartyOrder);
|
||||
void BtlController_EmitOneReturnValue(u8 bufferId, u16 ret);
|
||||
void BtlController_EmitOneReturnValue_Duplicate(u8 bufferId, u16 ret);
|
||||
void BtlController_EmitHitAnimation(u8 bufferId);
|
||||
void BtlController_EmitCantSwitch(u8 bufferId);
|
||||
void BtlController_EmitPlaySE(u8 bufferId, u16 songId);
|
||||
void BtlController_EmitPlayFanfareOrBGM(u8 bufferId, u16 songId, bool8 playBGM);
|
||||
void BtlController_EmitFaintingCry(u8 bufferId);
|
||||
void BtlController_EmitIntroSlide(u8 bufferId, u8 terrainId);
|
||||
void BtlController_EmitIntroTrainerBallThrow(u8 bufferId);
|
||||
void BtlController_EmitDrawPartyStatusSummary(u8 bufferId, struct HpAndStatus* hpAndStatus, u8 flags);
|
||||
void BtlController_EmitHidePartyStatusSummary(u8 bufferId);
|
||||
void BtlController_EmitEndBounceEffect(u8 bufferId);
|
||||
void BtlController_EmitSpriteInvisibility(u8 bufferId, bool8 isInvisible);
|
||||
void BtlController_EmitBattleAnimation(u8 bufferId, u8 animationId, u16 argument);
|
||||
void BtlController_EmitLinkStandbyMsg(u8 bufferId, u8 mode, bool32 record);
|
||||
void BtlController_EmitResetActionMoveSelection(u8 bufferId, u8 caseId);
|
||||
void BtlController_EmitEndLinkBattle(u8 bufferId, u8 battleOutcome);
|
||||
void BtlController_EmitDebugMenu(u8 bufferId);
|
||||
void BtlController_EmitGetMonData(u32 battler, u32 bufferId, u8 requestId, u8 monToCheck);
|
||||
void BtlController_EmitSetMonData(u32 battler, u32 bufferId, u8 requestId, u8 monToCheck, u8 bytes, void *data);
|
||||
void BtlController_EmitLoadMonSprite(u32 battler, u32 bufferId);
|
||||
void BtlController_EmitSwitchInAnim(u32 battler, u32 bufferId, u8 partyId, bool8 dontClearSubstituteBit);
|
||||
void BtlController_EmitReturnMonToBall(u32 battler, u32 bufferId, bool8 skipAnim);
|
||||
void BtlController_EmitDrawTrainerPic(u32 battler, u32 bufferId);
|
||||
void BtlController_EmitTrainerSlide(u32 battler, u32 bufferId);
|
||||
void BtlController_EmitTrainerSlideBack(u32 battler, u32 bufferId);
|
||||
void BtlController_EmitFaintAnimation(u32 battler, u32 bufferId);
|
||||
void BtlController_EmitBallThrowAnim(u32 battler, u32 bufferId, u8 caseId);
|
||||
void BtlController_EmitMoveAnimation(u32 battler, u32 bufferId, u16 move, u8 turnOfMove, u16 movePower, s32 dmg, u8 friendship, struct DisableStruct *disableStructPtr, u8 multihit);
|
||||
void BtlController_EmitPrintString(u32 battler, u32 bufferId, u16 stringId);
|
||||
void BtlController_EmitPrintSelectionString(u32 battler, u32 bufferId, u16 stringId);
|
||||
void BtlController_EmitChooseAction(u32 battler, u32 bufferId, u8 action, u16 itemId);
|
||||
void BtlController_EmitYesNoBox(u32 battler, u32 bufferId);
|
||||
void BtlController_EmitChooseMove(u32 battler, u32 bufferId, bool8 isDoubleBattle, bool8 NoPpNumber, struct ChooseMoveStruct *movePpData);
|
||||
void BtlController_EmitChooseItem(u32 battler, u32 bufferId, u8 *battlePartyOrder);
|
||||
void BtlController_EmitChoosePokemon(u32 battler, u32 bufferId, u8 caseId, u8 slotId, u16 abilityId, u8 *data);
|
||||
void BtlController_EmitHealthBarUpdate(u32 battler, u32 bufferId, u16 hpValue);
|
||||
void BtlController_EmitExpUpdate(u32 battler, u32 bufferId, u8 partyId, s32 expPoints);
|
||||
void BtlController_EmitStatusIconUpdate(u32 battler, u32 bufferId, u32 status1, u32 status2);
|
||||
void BtlController_EmitStatusAnimation(u32 battler, u32 bufferId, bool8 status2, u32 status);
|
||||
void BtlController_EmitDataTransfer(u32 battler, u32 bufferId, u16 size, void *data);
|
||||
void BtlController_EmitTwoReturnValues(u32 battler, u32 bufferId, u8 ret8, u32 ret32);
|
||||
void BtlController_EmitChosenMonReturnValue(u32 battler, u32 bufferId, u8 partyId, u8 *battlePartyOrder);
|
||||
void BtlController_EmitOneReturnValue(u32 battler, u32 bufferId, u16 ret);
|
||||
void BtlController_EmitOneReturnValue_Duplicate(u32 battler, u32 bufferId, u16 ret);
|
||||
void BtlController_EmitHitAnimation(u32 battler, u32 bufferId);
|
||||
void BtlController_EmitCantSwitch(u32 battler, u32 bufferId);
|
||||
void BtlController_EmitPlaySE(u32 battler, u32 bufferId, u16 songId);
|
||||
void BtlController_EmitPlayFanfareOrBGM(u32 battler, u32 bufferId, u16 songId, bool8 playBGM);
|
||||
void BtlController_EmitFaintingCry(u32 battler, u32 bufferId);
|
||||
void BtlController_EmitIntroSlide(u32 battler, u32 bufferId, u8 terrainId);
|
||||
void BtlController_EmitIntroTrainerBallThrow(u32 battler, u32 bufferId);
|
||||
void BtlController_EmitDrawPartyStatusSummary(u32 battler, u32 bufferId, struct HpAndStatus* hpAndStatus, u8 flags);
|
||||
void BtlController_EmitHidePartyStatusSummary(u32 battler, u32 bufferId);
|
||||
void BtlController_EmitEndBounceEffect(u32 battler, u32 bufferId);
|
||||
void BtlController_EmitSpriteInvisibility(u32 battler, u32 bufferId, bool8 isInvisible);
|
||||
void BtlController_EmitBattleAnimation(u32 battler, u32 bufferId, u8 animationId, u16 argument);
|
||||
void BtlController_EmitLinkStandbyMsg(u32 battler, u32 bufferId, u8 mode, bool32 record);
|
||||
void BtlController_EmitResetActionMoveSelection(u32 battler, u32 bufferId, u8 caseId);
|
||||
void BtlController_EmitEndLinkBattle(u32 battler, u32 bufferId, u8 battleOutcome);
|
||||
void BtlController_EmitDebugMenu(u32 battler, u32 bufferId);
|
||||
|
||||
void BattleControllerComplete(u32 battler); // Can be used for all the controllers.
|
||||
void BtlController_Empty(u32 battler); // Empty command, does nothing, only completes the execution.
|
||||
|
@ -48,7 +48,7 @@ extern const struct SpriteTemplate gBallSpriteTemplates[];
|
||||
#define POKEBALL_PLAYER_SENDOUT 0xFF
|
||||
#define POKEBALL_OPPONENT_SENDOUT 0xFE
|
||||
|
||||
u8 DoPokeballSendOutAnimation(s16 pan, u8 kindOfThrow);
|
||||
u8 DoPokeballSendOutAnimation(u32 battler, s16 pan, u8 kindOfThrow);
|
||||
void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 monPalNum, u8 x, u8 y, u8 oamPriority, u8 subpriority, u8 delay, u32 fadePalettes, u16 species);
|
||||
u8 CreateTradePokeballSprite(u8 monSpriteId, u8 monPalNum, u8 x, u8 y, u8 oamPriority, u8 subPriority, u8 delay, u32 fadePalettes);
|
||||
void StartHealthboxSlideIn(u8 battler);
|
||||
|
@ -455,7 +455,7 @@ static u8 ChooseMoveOrAction_Singles(void)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == MAX_MON_MOVES && GetMostSuitableMonToSwitchInto() != PARTY_SIZE)
|
||||
if (i == MAX_MON_MOVES && GetMostSuitableMonToSwitchInto(sBattler_AI) != PARTY_SIZE)
|
||||
{
|
||||
AI_THINKING_STRUCT->switchMon = TRUE;
|
||||
return AI_CHOICE_SWITCH;
|
||||
@ -469,7 +469,7 @@ static u8 ChooseMoveOrAction_Singles(void)
|
||||
&& gDisableStructs[sBattler_AI].truantCounter
|
||||
&& gBattleMons[sBattler_AI].hp >= gBattleMons[sBattler_AI].maxHP / 2)
|
||||
{
|
||||
if (GetMostSuitableMonToSwitchInto() != PARTY_SIZE)
|
||||
if (GetMostSuitableMonToSwitchInto(sBattler_AI) != PARTY_SIZE)
|
||||
{
|
||||
AI_THINKING_STRUCT->switchMon = TRUE;
|
||||
return AI_CHOICE_SWITCH;
|
||||
@ -3727,7 +3727,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
|
||||
}
|
||||
break;
|
||||
case EFFECT_BATON_PASS:
|
||||
if (ShouldSwitch() && (gBattleMons[battlerAtk].status2 & STATUS2_SUBSTITUTE
|
||||
if (ShouldSwitch(battlerAtk) && (gBattleMons[battlerAtk].status2 & STATUS2_SUBSTITUTE
|
||||
|| (gStatuses3[battlerAtk] & (STATUS3_ROOTED | STATUS3_AQUA_RING | STATUS3_MAGNET_RISE | STATUS3_POWER_TRICK))
|
||||
|| AnyStatIsRaised(battlerAtk)))
|
||||
score += 5;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2557,7 +2557,7 @@ bool32 ShouldPivot(u8 battlerAtk, u8 battlerDef, u16 defAbility, u16 move, u8 mo
|
||||
u8 battlerToSwitch;
|
||||
|
||||
gActiveBattler = battlerAtk;
|
||||
shouldSwitch = ShouldSwitch();
|
||||
shouldSwitch = ShouldSwitch(battlerAtk);
|
||||
battlerToSwitch = *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler);
|
||||
gActiveBattler = backupBattler;
|
||||
|
||||
|
@ -370,7 +370,7 @@ static void LinkOpponentBufferExecCompleted(u32 battler)
|
||||
{
|
||||
u8 playerId = GetMultiplayerId();
|
||||
|
||||
PrepareBufferDataTransferLink(2, 4, &playerId);
|
||||
PrepareBufferDataTransferLink(battler, 2, 4, &playerId);
|
||||
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
}
|
||||
else
|
||||
|
@ -196,7 +196,7 @@ static void LinkPartnerBufferExecCompleted(u32 battler)
|
||||
{
|
||||
u8 playerId = GetMultiplayerId();
|
||||
|
||||
PrepareBufferDataTransferLink(2, 4, &playerId);
|
||||
PrepareBufferDataTransferLink(battler, 2, 4, &playerId);
|
||||
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
}
|
||||
else
|
||||
|
@ -387,7 +387,7 @@ static void OpponentBufferExecCompleted(u32 battler)
|
||||
{
|
||||
u8 playerId = GetMultiplayerId();
|
||||
|
||||
PrepareBufferDataTransferLink(2, 4, &playerId);
|
||||
PrepareBufferDataTransferLink(battler, 2, 4, &playerId);
|
||||
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
}
|
||||
else
|
||||
@ -511,7 +511,7 @@ static void OpponentHandlePrintString(u32 battler)
|
||||
|
||||
static void OpponentHandleChooseAction(u32 battler)
|
||||
{
|
||||
AI_TrySwitchOrUseItem();
|
||||
AI_TrySwitchOrUseItem(battler);
|
||||
OpponentBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
@ -525,7 +525,7 @@ static void OpponentHandleChooseMove(u32 battler)
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
|
||||
{
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace());
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -534,16 +534,16 @@ static void OpponentHandleChooseMove(u32 battler)
|
||||
switch (chosenMoveId)
|
||||
{
|
||||
case AI_CHOICE_WATCH:
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_WATCH_CAREFULLY, 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_SAFARI_WATCH_CAREFULLY, 0);
|
||||
break;
|
||||
case AI_CHOICE_FLEE:
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_RUN, 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_RUN, 0);
|
||||
break;
|
||||
case AI_CHOICE_SWITCH:
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, 0xFFFF);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, 0xFFFF);
|
||||
break;
|
||||
case 6:
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 15, gBattlerTarget);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 15, gBattlerTarget);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
@ -560,9 +560,9 @@ static void OpponentHandleChooseMove(u32 battler)
|
||||
if (ShouldUseZMove(battler, gBattlerTarget, chosenMove))
|
||||
QueueZMove(battler, chosenMove);
|
||||
if (CanMegaEvolve(battler)) // If opponent can mega evolve, do it.
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (RET_MEGA_EVOLUTION) | (gBattlerTarget << 8));
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (RET_MEGA_EVOLUTION) | (gBattlerTarget << 8));
|
||||
else
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8));
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -580,7 +580,7 @@ static void OpponentHandleChooseMove(u32 battler)
|
||||
} while (move == MOVE_NONE);
|
||||
|
||||
if (GetBattlerMoveTargetType(battler, move) & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER))
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (battler << 8));
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (battler << 8));
|
||||
else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
{
|
||||
do {
|
||||
@ -614,16 +614,16 @@ static void OpponentHandleChooseMove(u32 battler)
|
||||
}
|
||||
}
|
||||
if (isPartnerEnemy && CanTargetBattler(battler, target, move))
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(BATTLE_PARTNER(battler)) << 8));
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(BATTLE_PARTNER(battler)) << 8));
|
||||
else
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (target << 8));
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (target << 8));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (target << 8));
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (target << 8));
|
||||
}
|
||||
else
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) << 8));
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) << 8));
|
||||
|
||||
OpponentBufferExecCompleted(battler);
|
||||
}
|
||||
@ -631,7 +631,7 @@ static void OpponentHandleChooseMove(u32 battler)
|
||||
|
||||
static void OpponentHandleChooseItem(u32 battler)
|
||||
{
|
||||
BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[battler]);
|
||||
BtlController_EmitOneReturnValue(battler, BUFFER_B, gBattleStruct->chosenItem[battler]);
|
||||
OpponentBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
@ -648,7 +648,7 @@ static void OpponentHandleChoosePokemon(u32 battler)
|
||||
// Switching out
|
||||
else if (*(gBattleStruct->AI_monToSwitchIntoId + battler) == PARTY_SIZE)
|
||||
{
|
||||
chosenMonId = GetMostSuitableMonToSwitchInto();
|
||||
chosenMonId = GetMostSuitableMonToSwitchInto(battler);
|
||||
if (chosenMonId == PARTY_SIZE)
|
||||
{
|
||||
s32 battler1, battler2, firstId, lastId;
|
||||
@ -687,7 +687,7 @@ static void OpponentHandleChoosePokemon(u32 battler)
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + battler) = PARTY_SIZE;
|
||||
*(gBattleStruct->monToSwitchIntoId + battler) = chosenMonId;
|
||||
}
|
||||
BtlController_EmitChosenMonReturnValue(BUFFER_B, chosenMonId, NULL);
|
||||
BtlController_EmitChosenMonReturnValue(battler, BUFFER_B, chosenMonId, NULL);
|
||||
OpponentBufferExecCompleted(battler);
|
||||
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ static void PlayerBufferExecCompleted(u32 battler)
|
||||
{
|
||||
u8 playerId = GetMultiplayerId();
|
||||
|
||||
PrepareBufferDataTransferLink(2, 4, &playerId);
|
||||
PrepareBufferDataTransferLink(battler, 2, 4, &playerId);
|
||||
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
}
|
||||
else
|
||||
@ -303,7 +303,7 @@ static void HandleInputChooseAction(u32 battler)
|
||||
PlaySE(SE_SELECT);
|
||||
ArrowsChangeColorLastBallCycle(FALSE);
|
||||
TryHideLastUsedBall();
|
||||
BtlController_EmitTwoReturnValues(1, B_ACTION_THROW_BALL, 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_THROW_BALL, 0);
|
||||
PlayerBufferExecCompleted(battler);
|
||||
}
|
||||
return;
|
||||
@ -318,16 +318,16 @@ static void HandleInputChooseAction(u32 battler)
|
||||
switch (gActionSelectionCursor[battler])
|
||||
{
|
||||
case 0: // Top left
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_MOVE, 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_USE_MOVE, 0);
|
||||
break;
|
||||
case 1: // Top right
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_ITEM, 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_USE_ITEM, 0);
|
||||
break;
|
||||
case 2: // Bottom left
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SWITCH, 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_SWITCH, 0);
|
||||
break;
|
||||
case 3: // Bottom right
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_RUN, 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_RUN, 0);
|
||||
break;
|
||||
}
|
||||
PlayerBufferExecCompleted(battler);
|
||||
@ -385,7 +385,7 @@ static void HandleInputChooseAction(u32 battler)
|
||||
AddBagItem(itemId, 1);
|
||||
}
|
||||
PlaySE(SE_SELECT);
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_CANCEL_PARTNER, 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_CANCEL_PARTNER, 0);
|
||||
PlayerBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
@ -396,7 +396,7 @@ static void HandleInputChooseAction(u32 battler)
|
||||
#if DEBUG_BATTLE_MENU == TRUE
|
||||
else if (JOY_NEW(SELECT_BUTTON))
|
||||
{
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_DEBUG, 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_DEBUG, 0);
|
||||
PlayerBufferExecCompleted(battler);
|
||||
}
|
||||
#endif
|
||||
@ -405,7 +405,7 @@ static void HandleInputChooseAction(u32 battler)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
TryHideLastUsedBall();
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_THROW_BALL, 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_THROW_BALL, 0);
|
||||
PlayerBufferExecCompleted(battler);
|
||||
}
|
||||
#endif
|
||||
@ -435,9 +435,9 @@ static void HandleInputChooseTarget(u32 battler)
|
||||
PlaySE(SE_SELECT);
|
||||
gSprites[gBattlerSpriteIds[gMultiUsePlayerCursor]].callback = SpriteCB_HideAsMoveTarget;
|
||||
if (gBattleStruct->mega.playerSelect)
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_MEGA_EVOLUTION | (gMultiUsePlayerCursor << 8));
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_MEGA_EVOLUTION | (gMultiUsePlayerCursor << 8));
|
||||
else
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[battler] | (gMultiUsePlayerCursor << 8));
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | (gMultiUsePlayerCursor << 8));
|
||||
EndBounceEffect(gMultiUsePlayerCursor, BOUNCE_HEALTHBOX);
|
||||
TryHideLastUsedBall();
|
||||
HideTriggerSprites();
|
||||
@ -593,9 +593,9 @@ static void HandleInputShowEntireFieldTargets(u32 battler)
|
||||
PlaySE(SE_SELECT);
|
||||
HideAllTargets();
|
||||
if (gBattleStruct->mega.playerSelect)
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_MEGA_EVOLUTION | (gMultiUsePlayerCursor << 8));
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_MEGA_EVOLUTION | (gMultiUsePlayerCursor << 8));
|
||||
else
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[battler] | (gMultiUsePlayerCursor << 8));
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | (gMultiUsePlayerCursor << 8));
|
||||
HideMegaTriggerSprite();
|
||||
PlayerBufferExecCompleted(battler);
|
||||
}
|
||||
@ -621,9 +621,9 @@ static void HandleInputShowTargets(u32 battler)
|
||||
PlaySE(SE_SELECT);
|
||||
HideShownTargets(battler);
|
||||
if (gBattleStruct->mega.playerSelect)
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_MEGA_EVOLUTION | (gMultiUsePlayerCursor << 8));
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_MEGA_EVOLUTION | (gMultiUsePlayerCursor << 8));
|
||||
else
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[battler] | (gMultiUsePlayerCursor << 8));
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | (gMultiUsePlayerCursor << 8));
|
||||
HideTriggerSprites();
|
||||
TryHideLastUsedBall();
|
||||
PlayerBufferExecCompleted(battler);
|
||||
@ -638,12 +638,12 @@ static void HandleInputShowTargets(u32 battler)
|
||||
}
|
||||
}
|
||||
|
||||
static void TryShowAsTarget(u32 battlerId)
|
||||
static void TryShowAsTarget(u32 battler)
|
||||
{
|
||||
if (IsBattlerAlive(battlerId))
|
||||
if (IsBattlerAlive(battler))
|
||||
{
|
||||
DoBounceEffect(battlerId, BOUNCE_HEALTHBOX, 15, 1);
|
||||
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCB_ShowAsMoveTarget;
|
||||
DoBounceEffect(battler, BOUNCE_HEALTHBOX, 15, 1);
|
||||
gSprites[gBattlerSpriteIds[battler]].callback = SpriteCB_ShowAsMoveTarget;
|
||||
}
|
||||
}
|
||||
|
||||
@ -736,9 +736,9 @@ static void HandleInputChooseMove(u32 battler)
|
||||
case 0:
|
||||
default:
|
||||
if (gBattleStruct->mega.playerSelect)
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_MEGA_EVOLUTION | (gMultiUsePlayerCursor << 8));
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_MEGA_EVOLUTION | (gMultiUsePlayerCursor << 8));
|
||||
else
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[battler] | (gMultiUsePlayerCursor << 8));
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | (gMultiUsePlayerCursor << 8));
|
||||
HideTriggerSprites();
|
||||
TryHideLastUsedBall();
|
||||
PlayerBufferExecCompleted(battler);
|
||||
@ -774,7 +774,7 @@ static void HandleInputChooseMove(u32 battler)
|
||||
{
|
||||
gBattleStruct->mega.playerSelect = FALSE;
|
||||
gBattleStruct->zmove.viable = FALSE;
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, 0xFFFF);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, 0xFFFF);
|
||||
HideTriggerSprites();
|
||||
PlayerBufferExecCompleted(battler);
|
||||
}
|
||||
@ -1382,12 +1382,11 @@ static s32 GetTaskExpValue(u8 taskId)
|
||||
|
||||
static void Task_GiveExpToMon(u8 taskId)
|
||||
{
|
||||
u32 savedActiveBattler;
|
||||
u32 monId = (u8)(gTasks[taskId].tExpTask_monId);
|
||||
u8 battlerId = gTasks[taskId].tExpTask_battler;
|
||||
u8 battler = gTasks[taskId].tExpTask_battler;
|
||||
s32 gainedExp = GetTaskExpValue(taskId);
|
||||
|
||||
if (WhichBattleCoords(battlerId) == 1 || monId != gBattlerPartyIndexes[battlerId]) // Give exp without moving the expbar.
|
||||
if (WhichBattleCoords(battler) == 1 || monId != gBattlerPartyIndexes[battler]) // Give exp without moving the expbar.
|
||||
{
|
||||
struct Pokemon *mon = &gPlayerParty[monId];
|
||||
u16 species = GetMonData(mon, MON_DATA_SPECIES);
|
||||
@ -1400,13 +1399,10 @@ static void Task_GiveExpToMon(u8 taskId)
|
||||
SetMonData(mon, MON_DATA_EXP, &nextLvlExp);
|
||||
CalculateMonStats(mon);
|
||||
gainedExp -= nextLvlExp - currExp;
|
||||
savedActiveBattler = gActiveBattler;
|
||||
gActiveBattler = battlerId;
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, RET_VALUE_LEVELED_UP, gainedExp);
|
||||
gActiveBattler = savedActiveBattler;
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, RET_VALUE_LEVELED_UP, gainedExp);
|
||||
|
||||
if (IsDoubleBattle() == TRUE
|
||||
&& (monId == gBattlerPartyIndexes[battlerId] || monId == gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)]))
|
||||
&& (monId == gBattlerPartyIndexes[battler] || monId == gBattlerPartyIndexes[BATTLE_PARTNER(battler)]))
|
||||
gTasks[taskId].func = Task_LaunchLvlUpAnim;
|
||||
else
|
||||
gTasks[taskId].func = Task_SetControllerToWaitForString;
|
||||
@ -1415,7 +1411,7 @@ static void Task_GiveExpToMon(u8 taskId)
|
||||
{
|
||||
currExp += gainedExp;
|
||||
SetMonData(mon, MON_DATA_EXP, &currExp);
|
||||
gBattlerControllerFuncs[battlerId] = Controller_WaitForString;
|
||||
gBattlerControllerFuncs[battler] = Controller_WaitForString;
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
@ -1429,7 +1425,7 @@ static void Task_PrepareToGiveExpWithExpBar(u8 taskId)
|
||||
{
|
||||
u8 monIndex = gTasks[taskId].tExpTask_monId;
|
||||
s32 gainedExp = GetTaskExpValue(taskId);
|
||||
u8 battlerId = gTasks[taskId].tExpTask_battler;
|
||||
u8 battler = gTasks[taskId].tExpTask_battler;
|
||||
struct Pokemon *mon = &gPlayerParty[monIndex];
|
||||
u8 level = GetMonData(mon, MON_DATA_LEVEL);
|
||||
u16 species = GetMonData(mon, MON_DATA_SPECIES);
|
||||
@ -1439,7 +1435,7 @@ static void Task_PrepareToGiveExpWithExpBar(u8 taskId)
|
||||
|
||||
exp -= currLvlExp;
|
||||
expToNextLvl = gExperienceTables[gSpeciesInfo[species].growthRate][level + 1] - currLvlExp;
|
||||
SetBattleBarStruct(battlerId, gHealthboxSpriteIds[battlerId], expToNextLvl, exp, -gainedExp);
|
||||
SetBattleBarStruct(battler, gHealthboxSpriteIds[battler], expToNextLvl, exp, -gainedExp);
|
||||
PlaySE(SE_EXP);
|
||||
gTasks[taskId].func = Task_GiveExpWithExpBar;
|
||||
}
|
||||
@ -1458,10 +1454,10 @@ static void Task_GiveExpWithExpBar(u8 taskId)
|
||||
{
|
||||
u8 monId = gTasks[taskId].tExpTask_monId;
|
||||
s32 gainedExp = GetTaskExpValue(taskId);
|
||||
u8 battlerId = gTasks[taskId].tExpTask_battler;
|
||||
u8 battler = gTasks[taskId].tExpTask_battler;
|
||||
|
||||
newExpPoints = MoveBattleBar(battlerId, gHealthboxSpriteIds[battlerId], EXP_BAR, 0);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battlerId]);
|
||||
newExpPoints = MoveBattleBar(battler, gHealthboxSpriteIds[battler], EXP_BAR, 0);
|
||||
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
|
||||
if (newExpPoints == -1) // The bar has been filled with given exp points.
|
||||
{
|
||||
m4aSongNumStop(SE_EXP);
|
||||
@ -1472,22 +1468,17 @@ static void Task_GiveExpWithExpBar(u8 taskId)
|
||||
|
||||
if (currExp + gainedExp >= expOnNextLvl)
|
||||
{
|
||||
u8 savedActiveBattler;
|
||||
|
||||
SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &expOnNextLvl);
|
||||
CalculateMonStats(&gPlayerParty[monId]);
|
||||
gainedExp -= expOnNextLvl - currExp;
|
||||
savedActiveBattler = gActiveBattler;
|
||||
gActiveBattler = battlerId;
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, RET_VALUE_LEVELED_UP, gainedExp);
|
||||
gActiveBattler = savedActiveBattler;
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, RET_VALUE_LEVELED_UP, gainedExp);
|
||||
gTasks[taskId].func = Task_LaunchLvlUpAnim;
|
||||
}
|
||||
else
|
||||
{
|
||||
currExp += gainedExp;
|
||||
SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &currExp);
|
||||
gBattlerControllerFuncs[battlerId] = Controller_WaitForString;
|
||||
gBattlerControllerFuncs[battler] = Controller_WaitForString;
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
@ -1496,28 +1487,28 @@ static void Task_GiveExpWithExpBar(u8 taskId)
|
||||
|
||||
static void Task_LaunchLvlUpAnim(u8 taskId)
|
||||
{
|
||||
u8 battlerId = gTasks[taskId].tExpTask_battler;
|
||||
u8 battler = gTasks[taskId].tExpTask_battler;
|
||||
u8 monIndex = gTasks[taskId].tExpTask_monId;
|
||||
|
||||
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)])
|
||||
battlerId ^= BIT_FLANK;
|
||||
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[BATTLE_PARTNER(battler)])
|
||||
battler ^= BIT_FLANK;
|
||||
|
||||
InitAndLaunchSpecialAnimation(battlerId, battlerId, battlerId, B_ANIM_LVL_UP);
|
||||
InitAndLaunchSpecialAnimation(battler, battler, battler, B_ANIM_LVL_UP);
|
||||
gTasks[taskId].func = Task_UpdateLvlInHealthbox;
|
||||
}
|
||||
|
||||
static void Task_UpdateLvlInHealthbox(u8 taskId)
|
||||
{
|
||||
u8 battlerId = gTasks[taskId].tExpTask_battler;
|
||||
u8 battler = gTasks[taskId].tExpTask_battler;
|
||||
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battlerId].specialAnimActive)
|
||||
if (!gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive)
|
||||
{
|
||||
u8 monIndex = gTasks[taskId].tExpTask_monId;
|
||||
|
||||
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)])
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(battlerId)], &gPlayerParty[monIndex], HEALTHBOX_ALL);
|
||||
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[BATTLE_PARTNER(battler)])
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(battler)], &gPlayerParty[monIndex], HEALTHBOX_ALL);
|
||||
else
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battlerId], &gPlayerParty[monIndex], HEALTHBOX_ALL);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[monIndex], HEALTHBOX_ALL);
|
||||
|
||||
gTasks[taskId].func = Task_SetControllerToWaitForString;
|
||||
}
|
||||
@ -1525,8 +1516,8 @@ static void Task_UpdateLvlInHealthbox(u8 taskId)
|
||||
|
||||
static void Task_SetControllerToWaitForString(u8 taskId)
|
||||
{
|
||||
u8 battlerId = gTasks[taskId].tExpTask_battler;
|
||||
gBattlerControllerFuncs[battlerId] = Controller_WaitForString;
|
||||
u8 battler = gTasks[taskId].tExpTask_battler;
|
||||
gBattlerControllerFuncs[battler] = Controller_WaitForString;
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
@ -1549,9 +1540,9 @@ static void WaitForMonSelection(u32 battler)
|
||||
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
|
||||
{
|
||||
if (gPartyMenuUseExitCallback == TRUE)
|
||||
BtlController_EmitChosenMonReturnValue(BUFFER_B, gSelectedMonPartyId, gBattlePartyCurrentOrder);
|
||||
BtlController_EmitChosenMonReturnValue(battler, BUFFER_B, gSelectedMonPartyId, gBattlePartyCurrentOrder);
|
||||
else
|
||||
BtlController_EmitChosenMonReturnValue(BUFFER_B, PARTY_SIZE, NULL);
|
||||
BtlController_EmitChosenMonReturnValue(battler, BUFFER_B, PARTY_SIZE, NULL);
|
||||
|
||||
if ((gBattleResources->bufferA[battler][1] & 0xF) == 1)
|
||||
PrintLinkStandbyMsg();
|
||||
@ -1575,7 +1566,7 @@ static void CompleteWhenChoseItem(u32 battler)
|
||||
{
|
||||
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
|
||||
{
|
||||
BtlController_EmitOneReturnValue(BUFFER_B, gSpecialVar_ItemId);
|
||||
BtlController_EmitOneReturnValue(battler, BUFFER_B, gSpecialVar_ItemId);
|
||||
PlayerBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
@ -1602,9 +1593,9 @@ static void PlayerHandleYesNoInput(u32 battler)
|
||||
PlaySE(SE_SELECT);
|
||||
|
||||
if (gMultiUsePlayerCursor != 0)
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 0xE, 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 0xE, 0);
|
||||
else
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 0xD, 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 0xD, 0);
|
||||
|
||||
PlayerBufferExecCompleted(battler);
|
||||
}
|
||||
@ -1936,7 +1927,7 @@ static void PlayerChooseMoveInBattlePalace(u32 battler)
|
||||
if (--*(gBattleStruct->arenaMindPoints + battler) == 0)
|
||||
{
|
||||
gBattlePalaceMoveSelectionRngValue = gRngValue;
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace());
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace());
|
||||
PlayerBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
@ -2000,7 +1991,7 @@ static void PlayerHandleChoosePokemon(u32 battler)
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_ARENA && (gBattleResources->bufferA[battler][1] & 0xF) != PARTY_ACTION_CANT_SWITCH
|
||||
&& (gBattleResources->bufferA[battler][1] & 0xF) != PARTY_ACTION_CHOOSE_FAINTED_MON)
|
||||
{
|
||||
BtlController_EmitChosenMonReturnValue(BUFFER_B, gBattlerPartyIndexes[battler] + 1, gBattlePartyCurrentOrder);
|
||||
BtlController_EmitChosenMonReturnValue(battler, BUFFER_B, gBattlerPartyIndexes[battler] + 1, gBattlePartyCurrentOrder);
|
||||
PlayerBufferExecCompleted(battler);
|
||||
}
|
||||
else
|
||||
@ -2099,25 +2090,25 @@ static void PlayerHandlePlayBGM(u32 battler)
|
||||
|
||||
static void PlayerHandleTwoReturnValues(u32 battler)
|
||||
{
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 0, 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 0, 0);
|
||||
PlayerBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void PlayerHandleChosenMonReturnValue(u32 battler)
|
||||
{
|
||||
BtlController_EmitChosenMonReturnValue(BUFFER_B, 0, NULL);
|
||||
BtlController_EmitChosenMonReturnValue(battler, BUFFER_B, 0, NULL);
|
||||
PlayerBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void PlayerHandleOneReturnValue(u32 battler)
|
||||
{
|
||||
BtlController_EmitOneReturnValue(BUFFER_B, 0);
|
||||
BtlController_EmitOneReturnValue(battler, BUFFER_B, 0);
|
||||
PlayerBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
static void PlayerHandleOneReturnValue_Duplicate(u32 battler)
|
||||
{
|
||||
BtlController_EmitOneReturnValue_Duplicate(BUFFER_B, 0);
|
||||
BtlController_EmitOneReturnValue_Duplicate(battler, BUFFER_B, 0);
|
||||
PlayerBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ static void PlayerPartnerBufferExecCompleted(u32 battler)
|
||||
{
|
||||
u8 playerId = GetMultiplayerId();
|
||||
|
||||
PrepareBufferDataTransferLink(2, 4, &playerId);
|
||||
PrepareBufferDataTransferLink(battler, 2, 4, &playerId);
|
||||
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
}
|
||||
else
|
||||
@ -340,7 +340,7 @@ static void PlayerPartnerHandlePrintString(u32 battler)
|
||||
|
||||
static void PlayerPartnerHandleChooseAction(u32 battler)
|
||||
{
|
||||
AI_TrySwitchOrUseItem();
|
||||
AI_TrySwitchOrUseItem(battler);
|
||||
PlayerPartnerBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
@ -366,9 +366,9 @@ static void PlayerPartnerHandleChooseMove(u32 battler)
|
||||
|
||||
// If partner can mega evolve, do it.
|
||||
if (CanMegaEvolve(battler))
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (RET_MEGA_EVOLUTION) | (gBattlerTarget << 8));
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (RET_MEGA_EVOLUTION) | (gBattlerTarget << 8));
|
||||
else
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8));
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8));
|
||||
|
||||
PlayerPartnerBufferExecCompleted(battler);
|
||||
}
|
||||
@ -384,7 +384,7 @@ static void PlayerPartnerHandleChoosePokemon(u32 battler)
|
||||
// Switching out
|
||||
else
|
||||
{
|
||||
chosenMonId = GetMostSuitableMonToSwitchInto();
|
||||
chosenMonId = GetMostSuitableMonToSwitchInto(battler);
|
||||
if (chosenMonId == PARTY_SIZE) // just switch to the next mon
|
||||
{
|
||||
u8 playerMonIdentity = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
|
||||
@ -402,7 +402,7 @@ static void PlayerPartnerHandleChoosePokemon(u32 battler)
|
||||
}
|
||||
*(gBattleStruct->monToSwitchIntoId + battler) = chosenMonId;
|
||||
}
|
||||
BtlController_EmitChosenMonReturnValue(BUFFER_B, chosenMonId, NULL);
|
||||
BtlController_EmitChosenMonReturnValue(battler, BUFFER_B, chosenMonId, NULL);
|
||||
PlayerPartnerBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ static void RecordedOpponentBufferExecCompleted(u32 battler)
|
||||
{
|
||||
u8 playerId = GetMultiplayerId();
|
||||
|
||||
PrepareBufferDataTransferLink(2, 4, &playerId);
|
||||
PrepareBufferDataTransferLink(battler, 2, 4, &playerId);
|
||||
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
}
|
||||
else
|
||||
@ -460,7 +460,7 @@ static void RecordedOpponentHandlePrintString(u32 battler)
|
||||
|
||||
static void RecordedOpponentHandleChooseAction(u32 battler)
|
||||
{
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, RecordedBattle_GetBattlerAction(RECORDED_ACTION_TYPE, battler), 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, RecordedBattle_GetBattlerAction(RECORDED_ACTION_TYPE, battler), 0);
|
||||
RecordedOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
@ -468,13 +468,13 @@ static void RecordedOpponentHandleChooseMove(u32 battler)
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
|
||||
{
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace());
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace());
|
||||
}
|
||||
else
|
||||
{
|
||||
u8 moveId = RecordedBattle_GetBattlerAction(RECORDED_MOVE_SLOT, battler);
|
||||
u8 target = RecordedBattle_GetBattlerAction(RECORDED_MOVE_TARGET, battler);
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, moveId | (target << 8));
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, moveId | (target << 8));
|
||||
}
|
||||
|
||||
RecordedOpponentBufferExecCompleted(battler);
|
||||
@ -487,7 +487,7 @@ static void RecordedOpponentHandleChooseItem(u32 battler)
|
||||
gBattleStruct->chosenItem[battler] = (byte1 << 8) | byte2;
|
||||
gBattleStruct->itemPartyIndex[battler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_TARGET, battler);
|
||||
gBattleStruct->itemMoveIndex[battler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_MOVE, battler);
|
||||
BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[battler]);
|
||||
BtlController_EmitOneReturnValue(battler, BUFFER_B, gBattleStruct->chosenItem[battler]);
|
||||
RecordedOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
@ -495,7 +495,7 @@ static void RecordedOpponentHandleChoosePokemon(u32 battler)
|
||||
{
|
||||
*(gBattleStruct->monToSwitchIntoId + battler) = RecordedBattle_GetBattlerAction(RECORDED_PARTY_INDEX, battler);
|
||||
gSelectedMonPartyId = gBattleStruct->monToSwitchIntoId[battler]; // Revival Blessing
|
||||
BtlController_EmitChosenMonReturnValue(BUFFER_B, *(gBattleStruct->monToSwitchIntoId + battler), NULL);
|
||||
BtlController_EmitChosenMonReturnValue(battler, BUFFER_B, *(gBattleStruct->monToSwitchIntoId + battler), NULL);
|
||||
RecordedOpponentBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
|
@ -346,7 +346,7 @@ static void RecordedPlayerBufferExecCompleted(u32 battler)
|
||||
{
|
||||
u8 playerId = GetMultiplayerId();
|
||||
|
||||
PrepareBufferDataTransferLink(2, 4, &playerId);
|
||||
PrepareBufferDataTransferLink(battler, 2, 4, &playerId);
|
||||
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
}
|
||||
else
|
||||
@ -452,7 +452,7 @@ static void ChooseActionInBattlePalace(u32 battler)
|
||||
{
|
||||
if (gBattleCommunication[4] >= gBattlersCount / 2)
|
||||
{
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, RecordedBattle_GetBattlerAction(RECORDED_BATTLE_PALACE_ACTION, battler), 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, RecordedBattle_GetBattlerAction(RECORDED_BATTLE_PALACE_ACTION, battler), 0);
|
||||
RecordedPlayerBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
@ -465,7 +465,7 @@ static void RecordedPlayerHandleChooseAction(u32 battler)
|
||||
}
|
||||
else
|
||||
{
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, RecordedBattle_GetBattlerAction(RECORDED_ACTION_TYPE, battler), 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, RecordedBattle_GetBattlerAction(RECORDED_ACTION_TYPE, battler), 0);
|
||||
RecordedPlayerBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
@ -474,13 +474,13 @@ static void RecordedPlayerHandleChooseMove(u32 battler)
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
|
||||
{
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace());
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace());
|
||||
}
|
||||
else
|
||||
{
|
||||
u8 moveId = RecordedBattle_GetBattlerAction(RECORDED_MOVE_SLOT, battler);
|
||||
u8 target = RecordedBattle_GetBattlerAction(RECORDED_MOVE_TARGET, battler);
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, moveId | (target << 8));
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, moveId | (target << 8));
|
||||
}
|
||||
|
||||
RecordedPlayerBufferExecCompleted(battler);
|
||||
@ -493,7 +493,7 @@ static void RecordedPlayerHandleChooseItem(u32 battler)
|
||||
gBattleStruct->chosenItem[battler] = (byte1 << 8) | byte2;
|
||||
gBattleStruct->itemPartyIndex[battler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_TARGET, battler);
|
||||
gBattleStruct->itemMoveIndex[battler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_MOVE, battler);
|
||||
BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[battler]);
|
||||
BtlController_EmitOneReturnValue(battler, BUFFER_B, gBattleStruct->chosenItem[battler]);
|
||||
RecordedPlayerBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
@ -501,7 +501,7 @@ static void RecordedPlayerHandleChoosePokemon(u32 battler)
|
||||
{
|
||||
*(gBattleStruct->monToSwitchIntoId + battler) = RecordedBattle_GetBattlerAction(RECORDED_PARTY_INDEX, battler);
|
||||
gSelectedMonPartyId = gBattleStruct->monToSwitchIntoId[battler]; // Revival Blessing
|
||||
BtlController_EmitChosenMonReturnValue(BUFFER_B, *(gBattleStruct->monToSwitchIntoId + battler), NULL);
|
||||
BtlController_EmitChosenMonReturnValue(battler, BUFFER_B, *(gBattleStruct->monToSwitchIntoId + battler), NULL);
|
||||
RecordedPlayerBufferExecCompleted(battler);
|
||||
}
|
||||
|
||||
|
@ -130,16 +130,16 @@ static void HandleInputChooseAction(u32 battler)
|
||||
switch (gActionSelectionCursor[battler])
|
||||
{
|
||||
case 0:
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_BALL, 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_SAFARI_BALL, 0);
|
||||
break;
|
||||
case 1:
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_POKEBLOCK, 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_SAFARI_POKEBLOCK, 0);
|
||||
break;
|
||||
case 2:
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_GO_NEAR, 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_SAFARI_GO_NEAR, 0);
|
||||
break;
|
||||
case 3:
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_RUN, 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_SAFARI_RUN, 0);
|
||||
break;
|
||||
}
|
||||
SafariBufferExecCompleted(battler);
|
||||
@ -216,7 +216,7 @@ static void CompleteWhenChosePokeblock(u32 battler)
|
||||
{
|
||||
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
|
||||
{
|
||||
BtlController_EmitOneReturnValue(BUFFER_B, gSpecialVar_ItemId);
|
||||
BtlController_EmitOneReturnValue(battler, BUFFER_B, gSpecialVar_ItemId);
|
||||
SafariBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
@ -228,7 +228,7 @@ static void SafariBufferExecCompleted(u32 battler)
|
||||
{
|
||||
u8 playerId = GetMultiplayerId();
|
||||
|
||||
PrepareBufferDataTransferLink(2, 4, &playerId);
|
||||
PrepareBufferDataTransferLink(battler, 2, 4, &playerId);
|
||||
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
}
|
||||
else
|
||||
|
@ -149,7 +149,7 @@ static void WallyHandleActions(u32 battler)
|
||||
if (--gBattleStruct->wallyWaitFrames == 0)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_MOVE, 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_USE_MOVE, 0);
|
||||
WallyBufferExecCompleted(battler);
|
||||
gBattleStruct->wallyBattleState++;
|
||||
gBattleStruct->wallyMovesState = 0;
|
||||
@ -160,7 +160,7 @@ static void WallyHandleActions(u32 battler)
|
||||
if (--gBattleStruct->wallyWaitFrames == 0)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_MOVE, 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_USE_MOVE, 0);
|
||||
WallyBufferExecCompleted(battler);
|
||||
gBattleStruct->wallyBattleState++;
|
||||
gBattleStruct->wallyMovesState = 0;
|
||||
@ -170,7 +170,7 @@ static void WallyHandleActions(u32 battler)
|
||||
case 3:
|
||||
if (--gBattleStruct->wallyWaitFrames == 0)
|
||||
{
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_WALLY_THROW, 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_WALLY_THROW, 0);
|
||||
WallyBufferExecCompleted(battler);
|
||||
gBattleStruct->wallyBattleState++;
|
||||
gBattleStruct->wallyMovesState = 0;
|
||||
@ -191,7 +191,7 @@ static void WallyHandleActions(u32 battler)
|
||||
if (--gBattleStruct->wallyWaitFrames == 0)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_ITEM, 0);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_USE_ITEM, 0);
|
||||
WallyBufferExecCompleted(battler);
|
||||
}
|
||||
break;
|
||||
@ -213,7 +213,7 @@ static void CompleteOnChosenItem(u32 battler)
|
||||
{
|
||||
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
|
||||
{
|
||||
BtlController_EmitOneReturnValue(BUFFER_B, gSpecialVar_ItemId);
|
||||
BtlController_EmitOneReturnValue(battler, BUFFER_B, gSpecialVar_ItemId);
|
||||
WallyBufferExecCompleted(battler);
|
||||
}
|
||||
}
|
||||
@ -283,7 +283,7 @@ static void WallyBufferExecCompleted(u32 battler)
|
||||
{
|
||||
u8 playerId = GetMultiplayerId();
|
||||
|
||||
PrepareBufferDataTransferLink(2, 4, &playerId);
|
||||
PrepareBufferDataTransferLink(battler, 2, 4, &playerId);
|
||||
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
|
||||
}
|
||||
else
|
||||
@ -382,7 +382,7 @@ static void WallyHandleChooseMove(u32 battler)
|
||||
if (--gBattleStruct->wallyMoveFrames == 0)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
BtlController_EmitTwoReturnValues(BUFFER_B, 10, 0x100);
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, 0x100);
|
||||
WallyBufferExecCompleted(battler);
|
||||
}
|
||||
break;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3412,14 +3412,15 @@ void FaintClearSetData(void)
|
||||
static void DoBattleIntro(void)
|
||||
{
|
||||
s32 i;
|
||||
u32 battler;
|
||||
u8 *state = &gBattleStruct->introState;
|
||||
|
||||
switch (*state)
|
||||
{
|
||||
case 0: // Get Data of all battlers.
|
||||
gActiveBattler = gBattleCommunication[1];
|
||||
BtlController_EmitGetMonData(BUFFER_A, REQUEST_ALL_BATTLE, 0);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
battler = gBattleCommunication[1];
|
||||
BtlController_EmitGetMonData(battler, BUFFER_A, REQUEST_ALL_BATTLE, 0);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
(*state)++;
|
||||
break;
|
||||
case 1: // Loop through all battlers.
|
||||
@ -3434,9 +3435,9 @@ static void DoBattleIntro(void)
|
||||
case 2: // Start graphical intro slide.
|
||||
if (!gBattleControllerExecFlags)
|
||||
{
|
||||
gActiveBattler = GetBattlerAtPosition(0);
|
||||
BtlController_EmitIntroSlide(BUFFER_A, gBattleTerrain);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
battler = GetBattlerAtPosition(0);
|
||||
BtlController_EmitIntroSlide(battler, BUFFER_A, gBattleTerrain);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
gBattleCommunication[0] = 0;
|
||||
gBattleCommunication[1] = 0;
|
||||
(*state)++;
|
||||
@ -3447,50 +3448,50 @@ static void DoBattleIntro(void)
|
||||
(*state)++;
|
||||
break;
|
||||
case 4: // Copy battler data gotten in cases 0 and 1. Draw trainer/mon sprite.
|
||||
for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++)
|
||||
for (battler = 0; battler < gBattlersCount; battler++)
|
||||
{
|
||||
if ((gBattleTypeFlags & BATTLE_TYPE_SAFARI) && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
|
||||
if ((gBattleTypeFlags & BATTLE_TYPE_SAFARI) && GetBattlerSide(battler) == B_SIDE_PLAYER)
|
||||
{
|
||||
memset(&gBattleMons[gActiveBattler], 0, sizeof(struct BattlePokemon));
|
||||
memset(&gBattleMons[battler], 0, sizeof(struct BattlePokemon));
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(&gBattleMons[gActiveBattler], &gBattleResources->bufferB[gActiveBattler][4], sizeof(struct BattlePokemon));
|
||||
gBattleMons[gActiveBattler].type1 = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0];
|
||||
gBattleMons[gActiveBattler].type2 = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1];
|
||||
gBattleMons[gActiveBattler].type3 = TYPE_MYSTERY;
|
||||
gBattleMons[gActiveBattler].ability = GetAbilityBySpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].abilityNum);
|
||||
gBattleStruct->hpOnSwitchout[GetBattlerSide(gActiveBattler)] = gBattleMons[gActiveBattler].hp;
|
||||
gBattleMons[gActiveBattler].status2 = 0;
|
||||
memcpy(&gBattleMons[battler], &gBattleResources->bufferB[battler][4], sizeof(struct BattlePokemon));
|
||||
gBattleMons[battler].type1 = gSpeciesInfo[gBattleMons[battler].species].types[0];
|
||||
gBattleMons[battler].type2 = gSpeciesInfo[gBattleMons[battler].species].types[1];
|
||||
gBattleMons[battler].type3 = TYPE_MYSTERY;
|
||||
gBattleMons[battler].ability = GetAbilityBySpecies(gBattleMons[battler].species, gBattleMons[battler].abilityNum);
|
||||
gBattleStruct->hpOnSwitchout[GetBattlerSide(battler)] = gBattleMons[battler].hp;
|
||||
gBattleMons[battler].status2 = 0;
|
||||
for (i = 0; i < NUM_BATTLE_STATS; i++)
|
||||
gBattleMons[gActiveBattler].statStages[i] = DEFAULT_STAT_STAGE;
|
||||
gBattleMons[battler].statStages[i] = DEFAULT_STAT_STAGE;
|
||||
}
|
||||
|
||||
// Draw sprite.
|
||||
switch (GetBattlerPosition(gActiveBattler))
|
||||
switch (GetBattlerPosition(battler))
|
||||
{
|
||||
case B_POSITION_PLAYER_LEFT: // player sprite
|
||||
BtlController_EmitDrawTrainerPic(BUFFER_A);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
BtlController_EmitDrawTrainerPic(battler, BUFFER_A);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
break;
|
||||
case B_POSITION_OPPONENT_LEFT:
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) // opponent 1 sprite
|
||||
{
|
||||
BtlController_EmitDrawTrainerPic(BUFFER_A);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
BtlController_EmitDrawTrainerPic(battler, BUFFER_A);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
}
|
||||
else // wild mon 1
|
||||
{
|
||||
BtlController_EmitLoadMonSprite(BUFFER_A);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
gBattleResults.lastOpponentSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES, NULL);
|
||||
BtlController_EmitLoadMonSprite(battler, BUFFER_A);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
gBattleResults.lastOpponentSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES, NULL);
|
||||
}
|
||||
break;
|
||||
case B_POSITION_PLAYER_RIGHT:
|
||||
if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_INGAME_PARTNER)) // partner sprite
|
||||
{
|
||||
BtlController_EmitDrawTrainerPic(BUFFER_A);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
BtlController_EmitDrawTrainerPic(battler, BUFFER_A);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
}
|
||||
break;
|
||||
case B_POSITION_OPPONENT_RIGHT:
|
||||
@ -3498,15 +3499,15 @@ static void DoBattleIntro(void)
|
||||
{
|
||||
if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_TWO_OPPONENTS) && !BATTLE_TWO_VS_ONE_OPPONENT) // opponent 2 if exists
|
||||
{
|
||||
BtlController_EmitDrawTrainerPic(BUFFER_A);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
BtlController_EmitDrawTrainerPic(battler, BUFFER_A);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
}
|
||||
}
|
||||
else if (IsBattlerAlive(gActiveBattler)) // wild mon 2 if alive
|
||||
else if (IsBattlerAlive(battler)) // wild mon 2 if alive
|
||||
{
|
||||
BtlController_EmitLoadMonSprite(BUFFER_A);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
gBattleResults.lastOpponentSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES, NULL);
|
||||
BtlController_EmitLoadMonSprite(battler, BUFFER_A);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
gBattleResults.lastOpponentSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES, NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -3548,9 +3549,9 @@ static void DoBattleIntro(void)
|
||||
}
|
||||
}
|
||||
|
||||
gActiveBattler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
|
||||
BtlController_EmitDrawPartyStatusSummary(BUFFER_A, hpStatus, PARTY_SUMM_SKIP_DRAW_DELAY);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
battler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
|
||||
BtlController_EmitDrawPartyStatusSummary(battler, BUFFER_A, hpStatus, PARTY_SUMM_SKIP_DRAW_DELAY);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
@ -3567,9 +3568,9 @@ static void DoBattleIntro(void)
|
||||
}
|
||||
}
|
||||
|
||||
gActiveBattler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
|
||||
BtlController_EmitDrawPartyStatusSummary(BUFFER_A, hpStatus, PARTY_SUMM_SKIP_DRAW_DELAY);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
battler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
|
||||
BtlController_EmitDrawPartyStatusSummary(battler, BUFFER_A, hpStatus, PARTY_SUMM_SKIP_DRAW_DELAY);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
|
||||
(*state)++;
|
||||
}
|
||||
@ -3615,12 +3616,12 @@ static void DoBattleIntro(void)
|
||||
break;
|
||||
case 11: // first opponent's mon send out animation
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER))
|
||||
gActiveBattler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
|
||||
battler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
|
||||
else
|
||||
gActiveBattler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
|
||||
battler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
|
||||
|
||||
BtlController_EmitIntroTrainerBallThrow(BUFFER_A);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
BtlController_EmitIntroTrainerBallThrow(battler, BUFFER_A);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
(*state)++;
|
||||
break;
|
||||
case 12: // nothing
|
||||
@ -3629,12 +3630,12 @@ static void DoBattleIntro(void)
|
||||
if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_TWO_OPPONENTS) && !BATTLE_TWO_VS_ONE_OPPONENT)
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER))
|
||||
gActiveBattler = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
|
||||
battler = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
|
||||
else
|
||||
gActiveBattler = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
|
||||
battler = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
|
||||
|
||||
BtlController_EmitIntroTrainerBallThrow(BUFFER_A);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
BtlController_EmitIntroTrainerBallThrow(battler, BUFFER_A);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
}
|
||||
#if B_FAST_INTRO == TRUE
|
||||
if (!(gBattleTypeFlags & (BATTLE_TYPE_RECORDED | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_RECORDED_IS_MASTER | BATTLE_TYPE_LINK)))
|
||||
@ -3655,21 +3656,21 @@ static void DoBattleIntro(void)
|
||||
if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI))
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER))
|
||||
gActiveBattler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
|
||||
battler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
|
||||
else
|
||||
gActiveBattler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
|
||||
battler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
|
||||
|
||||
// A hack that makes fast intro work in trainer battles too.
|
||||
#if B_FAST_INTRO == TRUE
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER
|
||||
&& !(gBattleTypeFlags & (BATTLE_TYPE_RECORDED | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_RECORDED_IS_MASTER | BATTLE_TYPE_LINK))
|
||||
&& gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_SIDE]].callback == SpriteCallbackDummy)
|
||||
&& gSprites[gHealthboxSpriteIds[battler ^ BIT_SIDE]].callback == SpriteCallbackDummy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
PrepareStringBattle(STRINGID_INTROSENDOUT, gActiveBattler);
|
||||
PrepareStringBattle(STRINGID_INTROSENDOUT, battler);
|
||||
}
|
||||
(*state)++;
|
||||
break;
|
||||
@ -3677,50 +3678,50 @@ static void DoBattleIntro(void)
|
||||
if (!(gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleControllerExecFlags))
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER))
|
||||
gActiveBattler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
|
||||
battler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
|
||||
else
|
||||
gActiveBattler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
|
||||
battler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
|
||||
|
||||
if (!IsBattlerMarkedForControllerExec(gActiveBattler))
|
||||
if (!IsBattlerMarkedForControllerExec(battler))
|
||||
(*state)++;
|
||||
}
|
||||
break;
|
||||
case 18: // player 1 send out
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER))
|
||||
gActiveBattler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
|
||||
battler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
|
||||
else
|
||||
gActiveBattler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
|
||||
battler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
|
||||
|
||||
BtlController_EmitIntroTrainerBallThrow(BUFFER_A);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
BtlController_EmitIntroTrainerBallThrow(battler, BUFFER_A);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
(*state)++;
|
||||
break;
|
||||
case 19: // player 2 send out
|
||||
if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_INGAME_PARTNER))
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER))
|
||||
gActiveBattler = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
|
||||
battler = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
|
||||
else
|
||||
gActiveBattler = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
|
||||
battler = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
|
||||
|
||||
BtlController_EmitIntroTrainerBallThrow(BUFFER_A);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
BtlController_EmitIntroTrainerBallThrow(battler, BUFFER_A);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
}
|
||||
(*state)++;
|
||||
break;
|
||||
case 20: // set dex and battle vars
|
||||
if (!gBattleControllerExecFlags)
|
||||
{
|
||||
for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++)
|
||||
for (battler = 0; battler < gBattlersCount; battler++)
|
||||
{
|
||||
if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT
|
||||
if (GetBattlerSide(battler) == B_SIDE_OPPONENT
|
||||
&& !(gBattleTypeFlags & (BATTLE_TYPE_EREADER_TRAINER
|
||||
| BATTLE_TYPE_FRONTIER
|
||||
| BATTLE_TYPE_LINK
|
||||
| BATTLE_TYPE_RECORDED_LINK
|
||||
| BATTLE_TYPE_TRAINER_HILL)))
|
||||
{
|
||||
HandleSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gActiveBattler].species), FLAG_SET_SEEN, gBattleMons[gActiveBattler].personality);
|
||||
HandleSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[battler].species), FLAG_SET_SEEN, gBattleMons[battler].personality);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4123,7 +4124,7 @@ static void HandleTurnActionSelectionState(void)
|
||||
else
|
||||
{
|
||||
gBattleStruct->itemPartyIndex[gActiveBattler] = PARTY_SIZE;
|
||||
BtlController_EmitChooseAction(BUFFER_A, gChosenActionByBattler[0], gBattleResources->bufferB[0][1] | (gBattleResources->bufferB[0][2] << 8));
|
||||
BtlController_EmitChooseAction(gActiveBattler, BUFFER_A, gChosenActionByBattler[0], gBattleResources->bufferB[0][1] | (gBattleResources->bufferB[0][2] << 8));
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
gBattleCommunication[gActiveBattler]++;
|
||||
}
|
||||
@ -4175,7 +4176,7 @@ static void HandleTurnActionSelectionState(void)
|
||||
i);
|
||||
}
|
||||
|
||||
BtlController_EmitChooseMove(BUFFER_A, (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) != 0, FALSE, &moveInfo);
|
||||
BtlController_EmitChooseMove(gActiveBattler, BUFFER_A, (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) != 0, FALSE, &moveInfo);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
}
|
||||
break;
|
||||
@ -4207,7 +4208,7 @@ static void HandleTurnActionSelectionState(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
BtlController_EmitChooseItem(BUFFER_A, gBattleStruct->battlerPartyOrders[gActiveBattler]);
|
||||
BtlController_EmitChooseItem(gActiveBattler, BUFFER_A, gBattleStruct->battlerPartyOrders[gActiveBattler]);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
}
|
||||
break;
|
||||
@ -4216,21 +4217,21 @@ static void HandleTurnActionSelectionState(void)
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_ARENA
|
||||
|| !CanBattlerEscape(gActiveBattler))
|
||||
{
|
||||
BtlController_EmitChoosePokemon(BUFFER_A, PARTY_ACTION_CANT_SWITCH, PARTY_SIZE, ABILITY_NONE, gBattleStruct->battlerPartyOrders[gActiveBattler]);
|
||||
BtlController_EmitChoosePokemon(gActiveBattler, BUFFER_A, PARTY_ACTION_CANT_SWITCH, PARTY_SIZE, ABILITY_NONE, gBattleStruct->battlerPartyOrders[gActiveBattler]);
|
||||
}
|
||||
else if (ItemId_GetHoldEffect(gBattleMons[gActiveBattler].item) != HOLD_EFFECT_SHED_SHELL
|
||||
&& (i = IsAbilityPreventingEscape(gActiveBattler))) // must be last to keep i value integrity
|
||||
{
|
||||
BtlController_EmitChoosePokemon(BUFFER_A, ((i - 1) << 4) | PARTY_ACTION_ABILITY_PREVENTS, PARTY_SIZE, gBattleMons[i - 1].ability, gBattleStruct->battlerPartyOrders[gActiveBattler]);
|
||||
BtlController_EmitChoosePokemon(gActiveBattler, BUFFER_A, ((i - 1) << 4) | PARTY_ACTION_ABILITY_PREVENTS, PARTY_SIZE, gBattleMons[i - 1].ability, gBattleStruct->battlerPartyOrders[gActiveBattler]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gActiveBattler == 2 && gChosenActionByBattler[0] == B_ACTION_SWITCH)
|
||||
BtlController_EmitChoosePokemon(BUFFER_A, PARTY_ACTION_CHOOSE_MON, *(gBattleStruct->monToSwitchIntoId + 0), ABILITY_NONE, gBattleStruct->battlerPartyOrders[gActiveBattler]);
|
||||
BtlController_EmitChoosePokemon(gActiveBattler, BUFFER_A, PARTY_ACTION_CHOOSE_MON, *(gBattleStruct->monToSwitchIntoId + 0), ABILITY_NONE, gBattleStruct->battlerPartyOrders[gActiveBattler]);
|
||||
else if (gActiveBattler == 3 && gChosenActionByBattler[1] == B_ACTION_SWITCH)
|
||||
BtlController_EmitChoosePokemon(BUFFER_A, PARTY_ACTION_CHOOSE_MON, *(gBattleStruct->monToSwitchIntoId + 1), ABILITY_NONE, gBattleStruct->battlerPartyOrders[gActiveBattler]);
|
||||
BtlController_EmitChoosePokemon(gActiveBattler, BUFFER_A, PARTY_ACTION_CHOOSE_MON, *(gBattleStruct->monToSwitchIntoId + 1), ABILITY_NONE, gBattleStruct->battlerPartyOrders[gActiveBattler]);
|
||||
else
|
||||
BtlController_EmitChoosePokemon(BUFFER_A, PARTY_ACTION_CHOOSE_MON, PARTY_SIZE, ABILITY_NONE, gBattleStruct->battlerPartyOrders[gActiveBattler]);
|
||||
BtlController_EmitChoosePokemon(gActiveBattler, BUFFER_A, PARTY_ACTION_CHOOSE_MON, PARTY_SIZE, ABILITY_NONE, gBattleStruct->battlerPartyOrders[gActiveBattler]);
|
||||
}
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
break;
|
||||
@ -4245,7 +4246,7 @@ static void HandleTurnActionSelectionState(void)
|
||||
}
|
||||
break;
|
||||
case B_ACTION_SAFARI_POKEBLOCK:
|
||||
BtlController_EmitChooseItem(BUFFER_A, gBattleStruct->battlerPartyOrders[gActiveBattler]);
|
||||
BtlController_EmitChooseItem(gActiveBattler, BUFFER_A, gBattleStruct->battlerPartyOrders[gActiveBattler]);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
break;
|
||||
case B_ACTION_CANCEL_PARTNER:
|
||||
@ -4255,7 +4256,7 @@ static void HandleTurnActionSelectionState(void)
|
||||
if (gBattleMons[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))].status2 & STATUS2_MULTIPLETURNS
|
||||
|| gBattleMons[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))].status2 & STATUS2_RECHARGE)
|
||||
{
|
||||
BtlController_EmitEndBounceEffect(BUFFER_A);
|
||||
BtlController_EmitEndBounceEffect(gActiveBattler, BUFFER_A);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
return;
|
||||
}
|
||||
@ -4286,11 +4287,11 @@ static void HandleTurnActionSelectionState(void)
|
||||
|
||||
gBattleStruct->mega.toEvolve &= ~(gBitTable[BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))]);
|
||||
gBattleStruct->zmove.toBeUsed[BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))] = MOVE_NONE;
|
||||
BtlController_EmitEndBounceEffect(BUFFER_A);
|
||||
BtlController_EmitEndBounceEffect(gActiveBattler, BUFFER_A);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
return;
|
||||
case B_ACTION_DEBUG:
|
||||
BtlController_EmitDebugMenu(BUFFER_A);
|
||||
BtlController_EmitDebugMenu(gActiveBattler, BUFFER_A);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
break;
|
||||
}
|
||||
@ -4458,11 +4459,11 @@ static void HandleTurnActionSelectionState(void)
|
||||
|| (position & BIT_FLANK) != B_FLANK_LEFT
|
||||
|| (*(&gBattleStruct->absentBattlerFlags) & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(position))]))
|
||||
{
|
||||
BtlController_EmitLinkStandbyMsg(BUFFER_A, LINK_STANDBY_MSG_STOP_BOUNCE, i);
|
||||
BtlController_EmitLinkStandbyMsg(gActiveBattler, BUFFER_A, LINK_STANDBY_MSG_STOP_BOUNCE, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
BtlController_EmitLinkStandbyMsg(BUFFER_A, LINK_STANDBY_STOP_BOUNCE_ONLY, i);
|
||||
BtlController_EmitLinkStandbyMsg(gActiveBattler, BUFFER_A, LINK_STANDBY_STOP_BOUNCE_ONLY, i);
|
||||
}
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
gBattleCommunication[gActiveBattler]++;
|
||||
|
File diff suppressed because it is too large
Load Diff
1609
src/battle_util.c
1609
src/battle_util.c
File diff suppressed because it is too large
Load Diff
@ -72,7 +72,7 @@ void FreeBattleResources(void)
|
||||
}
|
||||
}
|
||||
|
||||
void AdjustFriendshipOnBattleFaint(u8 battlerId)
|
||||
void AdjustFriendshipOnBattleFaint(u8 battler)
|
||||
{
|
||||
u8 opposingBattlerId;
|
||||
|
||||
@ -91,28 +91,28 @@ void AdjustFriendshipOnBattleFaint(u8 battlerId)
|
||||
opposingBattlerId = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
|
||||
}
|
||||
|
||||
if (gBattleMons[opposingBattlerId].level > gBattleMons[battlerId].level)
|
||||
if (gBattleMons[opposingBattlerId].level > gBattleMons[battler].level)
|
||||
{
|
||||
if (gBattleMons[opposingBattlerId].level - gBattleMons[battlerId].level > 29)
|
||||
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battlerId]], FRIENDSHIP_EVENT_FAINT_LARGE);
|
||||
if (gBattleMons[opposingBattlerId].level - gBattleMons[battler].level > 29)
|
||||
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battler]], FRIENDSHIP_EVENT_FAINT_LARGE);
|
||||
else
|
||||
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battlerId]], FRIENDSHIP_EVENT_FAINT_SMALL);
|
||||
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battler]], FRIENDSHIP_EVENT_FAINT_SMALL);
|
||||
}
|
||||
else
|
||||
{
|
||||
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battlerId]], FRIENDSHIP_EVENT_FAINT_SMALL);
|
||||
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battler]], FRIENDSHIP_EVENT_FAINT_SMALL);
|
||||
}
|
||||
}
|
||||
|
||||
void SwitchPartyOrderInGameMulti(u8 battlerId, u8 arg1)
|
||||
void SwitchPartyOrderInGameMulti(u8 battler, u8 arg1)
|
||||
{
|
||||
if (GetBattlerSide(battlerId) != B_SIDE_OPPONENT)
|
||||
if (GetBattlerSide(battler) != B_SIDE_OPPONENT)
|
||||
{
|
||||
s32 i;
|
||||
for (i = 0; i < (int)ARRAY_COUNT(gBattlePartyCurrentOrder); i++)
|
||||
gBattlePartyCurrentOrder[i] = *(0 * 3 + i + (u8 *)(gBattleStruct->battlerPartyOrders));
|
||||
|
||||
SwitchPartyMonSlots(GetPartyIdFromBattlePartyId(gBattlerPartyIndexes[battlerId]), GetPartyIdFromBattlePartyId(arg1));
|
||||
SwitchPartyMonSlots(GetPartyIdFromBattlePartyId(gBattlerPartyIndexes[battler]), GetPartyIdFromBattlePartyId(arg1));
|
||||
|
||||
for (i = 0; i < (int)ARRAY_COUNT(gBattlePartyCurrentOrder); i++)
|
||||
*(0 * 3 + i + (u8 *)(gBattleStruct->battlerPartyOrders)) = gBattlePartyCurrentOrder[i];
|
||||
@ -121,7 +121,7 @@ void SwitchPartyOrderInGameMulti(u8 battlerId, u8 arg1)
|
||||
|
||||
// Called when a Pokémon is unable to attack during a Battle Palace battle.
|
||||
// Check if it was because they are frozen/asleep, and if so try to cure the status.
|
||||
u32 BattlePalace_TryEscapeStatus(u8 battlerId)
|
||||
u32 BattlePalace_TryEscapeStatus(u8 battler)
|
||||
{
|
||||
u32 effect = 0;
|
||||
|
||||
@ -130,13 +130,13 @@ u32 BattlePalace_TryEscapeStatus(u8 battlerId)
|
||||
switch (gBattleCommunication[MULTIUSE_STATE])
|
||||
{
|
||||
case 0:
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_SLEEP)
|
||||
if (gBattleMons[battler].status1 & STATUS1_SLEEP)
|
||||
{
|
||||
if (UproarWakeUpCheck(battlerId))
|
||||
if (UproarWakeUpCheck(battler))
|
||||
{
|
||||
// Wake up from Uproar
|
||||
gBattleMons[battlerId].status1 &= ~(STATUS1_SLEEP);
|
||||
gBattleMons[battlerId].status2 &= ~(STATUS2_NIGHTMARE);
|
||||
gBattleMons[battler].status1 &= ~(STATUS1_SLEEP);
|
||||
gBattleMons[battler].status2 &= ~(STATUS2_NIGHTMARE);
|
||||
BattleScriptPushCursor();
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_WOKE_UP_UPROAR;
|
||||
gBattlescriptCurrInstr = BattleScript_MoveUsedWokeUp;
|
||||
@ -146,18 +146,18 @@ u32 BattlePalace_TryEscapeStatus(u8 battlerId)
|
||||
{
|
||||
u32 toSub;
|
||||
|
||||
if (GetBattlerAbility(battlerId) == ABILITY_EARLY_BIRD)
|
||||
if (GetBattlerAbility(battler) == ABILITY_EARLY_BIRD)
|
||||
toSub = 2;
|
||||
else
|
||||
toSub = 1;
|
||||
|
||||
// Reduce number of sleep turns
|
||||
if ((gBattleMons[battlerId].status1 & STATUS1_SLEEP) < toSub)
|
||||
gBattleMons[battlerId].status1 &= ~(STATUS1_SLEEP);
|
||||
if ((gBattleMons[battler].status1 & STATUS1_SLEEP) < toSub)
|
||||
gBattleMons[battler].status1 &= ~(STATUS1_SLEEP);
|
||||
else
|
||||
gBattleMons[battlerId].status1 -= toSub;
|
||||
gBattleMons[battler].status1 -= toSub;
|
||||
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_SLEEP)
|
||||
if (gBattleMons[battler].status1 & STATUS1_SLEEP)
|
||||
{
|
||||
// Still asleep
|
||||
gBattlescriptCurrInstr = BattleScript_MoveUsedIsAsleep;
|
||||
@ -166,7 +166,7 @@ u32 BattlePalace_TryEscapeStatus(u8 battlerId)
|
||||
else
|
||||
{
|
||||
// Wake up
|
||||
gBattleMons[battlerId].status2 &= ~(STATUS2_NIGHTMARE);
|
||||
gBattleMons[battler].status2 &= ~(STATUS2_NIGHTMARE);
|
||||
BattleScriptPushCursor();
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_WOKE_UP;
|
||||
gBattlescriptCurrInstr = BattleScript_MoveUsedWokeUp;
|
||||
@ -177,7 +177,7 @@ u32 BattlePalace_TryEscapeStatus(u8 battlerId)
|
||||
gBattleCommunication[MULTIUSE_STATE]++;
|
||||
break;
|
||||
case 1:
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_FREEZE)
|
||||
if (gBattleMons[battler].status1 & STATUS1_FREEZE)
|
||||
{
|
||||
if (Random() % 5 != 0)
|
||||
{
|
||||
@ -187,7 +187,7 @@ u32 BattlePalace_TryEscapeStatus(u8 battlerId)
|
||||
else
|
||||
{
|
||||
// Unfreeze
|
||||
gBattleMons[battlerId].status1 &= ~(STATUS1_FREEZE);
|
||||
gBattleMons[battler].status1 &= ~(STATUS1_FREEZE);
|
||||
BattleScriptPushCursor();
|
||||
gBattlescriptCurrInstr = BattleScript_MoveUsedUnfroze;
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_DEFROSTED;
|
||||
@ -204,9 +204,8 @@ u32 BattlePalace_TryEscapeStatus(u8 battlerId)
|
||||
|
||||
if (effect == 2)
|
||||
{
|
||||
gActiveBattler = battlerId;
|
||||
BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
BtlController_EmitSetMonData(battler, BUFFER_A, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[battler].status1);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
}
|
||||
|
||||
return effect;
|
||||
|
@ -527,17 +527,17 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
|
||||
#define tBattler data[3]
|
||||
#define tOpponentBattler data[4]
|
||||
|
||||
u8 DoPokeballSendOutAnimation(s16 pan, u8 kindOfThrow)
|
||||
u8 DoPokeballSendOutAnimation(u32 battler, s16 pan, u8 kindOfThrow)
|
||||
{
|
||||
u8 taskId;
|
||||
|
||||
gDoingBattleAnim = TRUE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive = TRUE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive = TRUE;
|
||||
|
||||
taskId = CreateTask(Task_DoPokeballSendOutAnim, 5);
|
||||
gTasks[taskId].tPan = pan;
|
||||
gTasks[taskId].tThrowId = kindOfThrow;
|
||||
gTasks[taskId].tBattler = gActiveBattler;
|
||||
gTasks[taskId].tBattler = battler;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user