Misc battle script cleanup
This commit is contained in:
@@ -4801,7 +4801,9 @@ static void Cmd_jumpifcantswitch(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_804CF10(u8 slotId)
|
||||
// Opens the party screen to choose a new Pokémon to send out
|
||||
// slotId is the Pokémon to replace
|
||||
static void ChooseMonToSendOut(u8 slotId)
|
||||
{
|
||||
*(gBattleStruct->field_58 + gActiveBattler) = gBattlerPartyIndexes[gActiveBattler];
|
||||
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = PARTY_SIZE;
|
||||
@@ -4822,7 +4824,7 @@ static void Cmd_openpartyscreen(void)
|
||||
flags = 0;
|
||||
jumpPtr = T1_READ_PTR(gBattlescriptCurrInstr + 2);
|
||||
|
||||
if (gBattlescriptCurrInstr[1] == 5)
|
||||
if (gBattlescriptCurrInstr[1] == BS_UNK_5)
|
||||
{
|
||||
if ((gBattleTypeFlags & (BATTLE_TYPE_DOUBLE | BATTLE_TYPE_MULTI)) != BATTLE_TYPE_DOUBLE)
|
||||
{
|
||||
@@ -4830,7 +4832,7 @@ static void Cmd_openpartyscreen(void)
|
||||
{
|
||||
if (gHitMarker & HITMARKER_FAINTED(gActiveBattler))
|
||||
{
|
||||
if (HasNoMonsToSwitch(gActiveBattler, 6, 6))
|
||||
if (HasNoMonsToSwitch(gActiveBattler, PARTY_SIZE, PARTY_SIZE))
|
||||
{
|
||||
gAbsentBattlerFlags |= gBitTable[gActiveBattler];
|
||||
gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler));
|
||||
@@ -4839,7 +4841,7 @@ static void Cmd_openpartyscreen(void)
|
||||
}
|
||||
else if (!gSpecialStatuses[gActiveBattler].flag40)
|
||||
{
|
||||
sub_804CF10(PARTY_SIZE);
|
||||
ChooseMonToSendOut(PARTY_SIZE);
|
||||
gSpecialStatuses[gActiveBattler].flag40 = 1;
|
||||
}
|
||||
}
|
||||
@@ -4859,16 +4861,16 @@ static void Cmd_openpartyscreen(void)
|
||||
if (gBitTable[0] & hitmarkerFaintBits)
|
||||
{
|
||||
gActiveBattler = 0;
|
||||
if (HasNoMonsToSwitch(0, 6, 6))
|
||||
if (HasNoMonsToSwitch(0, PARTY_SIZE, PARTY_SIZE))
|
||||
{
|
||||
gAbsentBattlerFlags |= gBitTable[gActiveBattler];
|
||||
gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler));
|
||||
BtlController_EmitCmd42(0);
|
||||
BtlController_EmitCantSwitch(0);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
}
|
||||
else if (!gSpecialStatuses[gActiveBattler].flag40)
|
||||
{
|
||||
sub_804CF10(gBattleStruct->monToSwitchIntoId[2]);
|
||||
ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[2]);
|
||||
gSpecialStatuses[gActiveBattler].flag40 = 1;
|
||||
}
|
||||
else
|
||||
@@ -4881,16 +4883,16 @@ static void Cmd_openpartyscreen(void)
|
||||
if (gBitTable[2] & hitmarkerFaintBits && !(gBitTable[0] & hitmarkerFaintBits))
|
||||
{
|
||||
gActiveBattler = 2;
|
||||
if (HasNoMonsToSwitch(2, 6, 6))
|
||||
if (HasNoMonsToSwitch(2, PARTY_SIZE, PARTY_SIZE))
|
||||
{
|
||||
gAbsentBattlerFlags |= gBitTable[gActiveBattler];
|
||||
gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler));
|
||||
BtlController_EmitCmd42(0);
|
||||
BtlController_EmitCantSwitch(0);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
}
|
||||
else if (!gSpecialStatuses[gActiveBattler].flag40)
|
||||
{
|
||||
sub_804CF10(gBattleStruct->monToSwitchIntoId[0]);
|
||||
ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[0]);
|
||||
gSpecialStatuses[gActiveBattler].flag40 = 1;
|
||||
}
|
||||
else if (!(flags & 1))
|
||||
@@ -4902,16 +4904,16 @@ static void Cmd_openpartyscreen(void)
|
||||
if (gBitTable[1] & hitmarkerFaintBits)
|
||||
{
|
||||
gActiveBattler = 1;
|
||||
if (HasNoMonsToSwitch(1, 6, 6))
|
||||
if (HasNoMonsToSwitch(1, PARTY_SIZE, PARTY_SIZE))
|
||||
{
|
||||
gAbsentBattlerFlags |= gBitTable[gActiveBattler];
|
||||
gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler));
|
||||
BtlController_EmitCmd42(0);
|
||||
BtlController_EmitCantSwitch(0);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
}
|
||||
else if (!gSpecialStatuses[gActiveBattler].flag40)
|
||||
{
|
||||
sub_804CF10(gBattleStruct->monToSwitchIntoId[3]);
|
||||
ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[3]);
|
||||
gSpecialStatuses[gActiveBattler].flag40 = 1;
|
||||
}
|
||||
else
|
||||
@@ -4924,16 +4926,16 @@ static void Cmd_openpartyscreen(void)
|
||||
if (gBitTable[3] & hitmarkerFaintBits && !(gBitTable[1] & hitmarkerFaintBits))
|
||||
{
|
||||
gActiveBattler = 3;
|
||||
if (HasNoMonsToSwitch(3, 6, 6))
|
||||
if (HasNoMonsToSwitch(3, PARTY_SIZE, PARTY_SIZE))
|
||||
{
|
||||
gAbsentBattlerFlags |= gBitTable[gActiveBattler];
|
||||
gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler));
|
||||
BtlController_EmitCmd42(0);
|
||||
BtlController_EmitCantSwitch(0);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
}
|
||||
else if (!gSpecialStatuses[gActiveBattler].flag40)
|
||||
{
|
||||
sub_804CF10(gBattleStruct->monToSwitchIntoId[1]);
|
||||
ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[1]);
|
||||
gSpecialStatuses[gActiveBattler].flag40 = 1;
|
||||
}
|
||||
else if (!(flags & 2))
|
||||
@@ -4977,7 +4979,7 @@ static void Cmd_openpartyscreen(void)
|
||||
}
|
||||
gBattlescriptCurrInstr += 6;
|
||||
}
|
||||
else if (gBattlescriptCurrInstr[1] == 6)
|
||||
else if (gBattlescriptCurrInstr[1] == BS_UNK_6)
|
||||
{
|
||||
if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI))
|
||||
{
|
||||
@@ -4987,32 +4989,32 @@ static void Cmd_openpartyscreen(void)
|
||||
if (gBitTable[2] & hitmarkerFaintBits && gBitTable[0] & hitmarkerFaintBits)
|
||||
{
|
||||
gActiveBattler = 2;
|
||||
if (HasNoMonsToSwitch(2, gBattleBufferB[0][1], 6))
|
||||
if (HasNoMonsToSwitch(2, gBattleBufferB[0][1], PARTY_SIZE))
|
||||
{
|
||||
gAbsentBattlerFlags |= gBitTable[gActiveBattler];
|
||||
gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler));
|
||||
BtlController_EmitCmd42(0);
|
||||
BtlController_EmitCantSwitch(0);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
}
|
||||
else if (!gSpecialStatuses[gActiveBattler].flag40)
|
||||
{
|
||||
sub_804CF10(gBattleStruct->monToSwitchIntoId[0]);
|
||||
ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[0]);
|
||||
gSpecialStatuses[gActiveBattler].flag40 = 1;
|
||||
}
|
||||
}
|
||||
if (gBitTable[3] & hitmarkerFaintBits && hitmarkerFaintBits & gBitTable[1])
|
||||
{
|
||||
gActiveBattler = 3;
|
||||
if (HasNoMonsToSwitch(3, gBattleBufferB[1][1], 6))
|
||||
if (HasNoMonsToSwitch(3, gBattleBufferB[1][1], PARTY_SIZE))
|
||||
{
|
||||
gAbsentBattlerFlags |= gBitTable[gActiveBattler];
|
||||
gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler));
|
||||
BtlController_EmitCmd42(0);
|
||||
BtlController_EmitCantSwitch(0);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
}
|
||||
else if (!gSpecialStatuses[gActiveBattler].flag40)
|
||||
{
|
||||
sub_804CF10(gBattleStruct->monToSwitchIntoId[1]);
|
||||
ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[1]);
|
||||
gSpecialStatuses[gActiveBattler].flag40 = 1;
|
||||
}
|
||||
}
|
||||
@@ -5040,17 +5042,17 @@ static void Cmd_openpartyscreen(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gBattlescriptCurrInstr[1] & 0x80)
|
||||
if (gBattlescriptCurrInstr[1] & PARTY_SCREEN_OPTIONAL)
|
||||
hitmarkerFaintBits = PARTY_ACTION_CHOOSE_MON; // Used here as the caseId for the EmitChoose function.
|
||||
else
|
||||
hitmarkerFaintBits = PARTY_ACTION_SEND_OUT;
|
||||
|
||||
battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1] & ~(0x80));
|
||||
battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1] & ~(PARTY_SCREEN_OPTIONAL));
|
||||
if (gSpecialStatuses[battlerId].flag40)
|
||||
{
|
||||
gBattlescriptCurrInstr += 6;
|
||||
}
|
||||
else if (HasNoMonsToSwitch(battlerId, 6, 6))
|
||||
else if (HasNoMonsToSwitch(battlerId, PARTY_SIZE, PARTY_SIZE))
|
||||
{
|
||||
gActiveBattler = battlerId;
|
||||
gAbsentBattlerFlags |= gBitTable[gActiveBattler];
|
||||
@@ -6372,10 +6374,10 @@ static void Cmd_various(void)
|
||||
break;
|
||||
case VARIOUS_ARENA_JUDGMENT_STRING:
|
||||
BattleStringExpandPlaceholdersToDisplayedString(gRefereeStringsTable[gBattlescriptCurrInstr[1]]);
|
||||
BattlePutTextOnWindow(gDisplayedStringBattle, 0x16);
|
||||
BattlePutTextOnWindow(gDisplayedStringBattle, 22);
|
||||
break;
|
||||
case VARIOUS_ARENA_WAIT_STRING:
|
||||
if (IsTextPrinterActive(0x16))
|
||||
if (IsTextPrinterActive(22))
|
||||
return;
|
||||
break;
|
||||
case VARIOUS_WAIT_CRY:
|
||||
@@ -7313,7 +7315,7 @@ static void Cmd_tryconversiontypechange(void) // randomly changes user's type to
|
||||
do
|
||||
{
|
||||
|
||||
while ((moveChecked = Random() & 3) >= validMoves);
|
||||
while ((moveChecked = Random() & (MAX_MON_MOVES - 1)) >= validMoves);
|
||||
|
||||
moveType = gBattleMoves[gBattleMons[gBattlerAttacker].moves[moveChecked]].type;
|
||||
|
||||
@@ -8138,7 +8140,7 @@ static void Cmd_trychoosesleeptalkmove(void)
|
||||
|
||||
do
|
||||
{
|
||||
movePosition = Random() & 3;
|
||||
movePosition = Random() & (MAX_MON_MOVES - 1);
|
||||
} while ((gBitTable[movePosition] & unusableMovesBits));
|
||||
|
||||
gCalledMove = gBattleMons[gBattlerAttacker].moves[movePosition];
|
||||
|
||||
Reference in New Issue
Block a user