-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Shifting to Pokémon Already in Battle Exits the Shift Menu
voloved edited this page Jan 13, 2023
·
1 revision
By devolov
Goal: Make selecting the Pokémon that's already out when shifting Pokémon behave the same as cancelling shifting.
Half the time when I play, I just mash A until the battle is over. I end up in a loop of the game telling me my current Pokémon is already out when doing this, so I made shifting to the current Pokémon behave like cancelling a shift request.
------------------------------- src/party_menu.c -------------------------------
index dac2b3659..a887592a0 100755
@@ -362,9 +362,9 @@ static void CB2_ReturnToPartyMenuFromReadingMail(void);
static void Task_SendMailToPCYesNo(u8);
static void Task_HandleSendMailToPCYesNoInput(u8);
static void Task_LoseMailMessageYesNo(u8);
static void Task_HandleLoseMailMessageYesNoInput(u8);
-static bool8 TrySwitchInPokemon(void);
+static u8 TrySwitchInPokemon(void);
static void Task_SpinTradeYesNo(u8);
static void Task_HandleSpinTradeYesNoInput(u8);
static void Task_CancelAfterAorBPress(u8);
static void DisplayFieldMoveExitAreaMessage(u8);
@@ -3544,14 +3544,19 @@ static void CursorCb_Cancel2(u8 taskId)
}
static void CursorCb_SendMon(u8 taskId)
{
+ u8 switchMon = TrySwitchInPokemon();
PlaySE(SE_SELECT);
PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]);
- if (TrySwitchInPokemon() == TRUE)
+ if (switchMon == 1)
{
Task_ClosePartyMenu(taskId);
}
+ else if (switchMon == 2)
+ {
+ HandleChooseMonCancel(taskId, GetCurrentPartySlotPtr());
+ }
else
{
// gStringVar4 below is the error message buffered by TrySwitchInPokemon
PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]);
@@ -5833,9 +5838,9 @@ static u8 GetPartyMenuActionsTypeInBattle(struct Pokemon *mon)
}
return ACTIONS_SUMMARY_ONLY;
}
-static bool8 TrySwitchInPokemon(void)
+static u8 TrySwitchInPokemon(void)
{
u8 slot = GetCursorSelectionMonId();
u8 newSlot;
u8 i;
@@ -5844,54 +5849,54 @@ static bool8 TrySwitchInPokemon(void)
if (IsMultiBattle() == TRUE && (slot == 1 || slot == 4 || slot == 5))
{
StringCopy(gStringVar1, GetTrainerPartnerName());
StringExpandPlaceholders(gStringVar4, gText_CantSwitchWithAlly);
- return FALSE;
+ return 0;
}
if (GetMonData(&gPlayerParty[slot], MON_DATA_HP) == 0)
{
GetMonNickname(&gPlayerParty[slot], gStringVar1);
StringExpandPlaceholders(gStringVar4, gText_PkmnHasNoEnergy);
- return FALSE;
+ return 0;
}
for (i = 0; i < gBattlersCount; i++)
{
if (GetBattlerSide(i) == B_SIDE_PLAYER && GetPartyIdFromBattleSlot(slot) == gBattlerPartyIndexes[i])
{
GetMonNickname(&gPlayerParty[slot], gStringVar1);
StringExpandPlaceholders(gStringVar4, gText_PkmnAlreadyInBattle);
- return FALSE;
+ return 2;
}
}
if (GetMonData(&gPlayerParty[slot], MON_DATA_IS_EGG))
{
StringExpandPlaceholders(gStringVar4, gText_EggCantBattle);
- return FALSE;
+ return 0;
}
if (GetPartyIdFromBattleSlot(slot) == gBattleStruct->prevSelectedPartySlot)
{
GetMonNickname(&gPlayerParty[slot], gStringVar1);
StringExpandPlaceholders(gStringVar4, gText_PkmnAlreadySelected);
- return FALSE;
+ return 0;
}
if (gPartyMenu.action == PARTY_ACTION_ABILITY_PREVENTS)
{
SetMonPreventsSwitchingString();
- return FALSE;
+ return 0;
}
if (gPartyMenu.action == PARTY_ACTION_CANT_SWITCH)
{
u8 currBattler = gBattlerInMenuId;
GetMonNickname(&gPlayerParty[GetPartyIdFromBattlePartyId(gBattlerPartyIndexes[currBattler])], gStringVar1);
StringExpandPlaceholders(gStringVar4, gText_PkmnCantSwitchOut);
- return FALSE;
+ return 0;
}
gSelectedMonPartyId = GetPartyIdFromBattleSlot(slot);
gPartyMenuUseExitCallback = TRUE;
newSlot = GetPartyIdFromBattlePartyId(gBattlerPartyIndexes[gBattlerInMenuId]);
SwitchPartyMonSlots(newSlot, slot);
SwapPartyPokemon(&gPlayerParty[newSlot], &gPlayerParty[slot]);
- return TRUE;
+ return 1;
}
void BufferBattlePartyCurrentOrder(void)
{