Merge pull request #370 from DizzyEggg/battle_tower
Decompile Battle Tower
This commit is contained in:
+41
-47
@@ -57,18 +57,12 @@ struct UnkStruct_860DD10
|
||||
|
||||
extern void sub_81B8558(void);
|
||||
extern u32 sub_81A39C4(void);
|
||||
extern u16 sub_8162548(u8, u8);
|
||||
extern u16 RandomizeFacilityTrainerMonId(u16);
|
||||
extern u8 GetFacilityEnemyMonLevel(void);
|
||||
extern u16 sub_81A5060(u8 monId, u8 moveSlotId);
|
||||
extern u8 sub_81A50F0(u8, u8);
|
||||
extern u8 sub_81A50B0(u8);
|
||||
extern void sub_8162614(u16, u8);
|
||||
extern void sub_81A4C30(void);
|
||||
extern bool8 sub_81A3610(void);
|
||||
extern u16 sub_81A4FF0(u8);
|
||||
extern u8 GetFrontierTrainerFrontSpriteId(u16);
|
||||
extern u8 GetFrontierOpponentClass(u16);
|
||||
extern void ReducePlayerPartyToThree(void);
|
||||
|
||||
extern u8 gUnknown_0203CEF8[];
|
||||
@@ -2410,7 +2404,7 @@ static void sub_818E9CC(void)
|
||||
u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
|
||||
|
||||
gSaveBlock2Ptr->frontier.field_CA8 = 0;
|
||||
gSaveBlock2Ptr->frontier.field_CB2 = 0;
|
||||
gSaveBlock2Ptr->frontier.curChallengeBattleNum = 0;
|
||||
gSaveBlock2Ptr->frontier.field_CA9_a = 0;
|
||||
gSaveBlock2Ptr->frontier.field_CA9_b = 0;
|
||||
if (!(gSaveBlock2Ptr->frontier.field_CDC & gUnknown_0860D0EC[battleMode][lvlMode]))
|
||||
@@ -2581,13 +2575,13 @@ static void InitDomeTrainers(void)
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
gSaveBlock2Ptr->frontier.domeMonId[0][i] = GetMonData(&gPlayerParty[gSaveBlock2Ptr->frontier.field_CAA[i] - 1], MON_DATA_SPECIES, NULL);
|
||||
gSaveBlock2Ptr->frontier.domeMonId[0][i] = GetMonData(&gPlayerParty[gSaveBlock2Ptr->frontier.selectedPartyMons[i] - 1], MON_DATA_SPECIES, NULL);
|
||||
for (j = 0; j < 4; j++)
|
||||
gSaveBlock2Ptr->frontier.field_EFC[i].moves[j] = GetMonData(&gPlayerParty[gSaveBlock2Ptr->frontier.field_CAA[i] - 1], MON_DATA_MOVE1 + j, NULL);
|
||||
gSaveBlock2Ptr->frontier.field_EFC[i].moves[j] = GetMonData(&gPlayerParty[gSaveBlock2Ptr->frontier.selectedPartyMons[i] - 1], MON_DATA_MOVE1 + j, NULL);
|
||||
for (j = 0; j < 6; j++)
|
||||
gSaveBlock2Ptr->frontier.field_EFC[i].evs[j] = GetMonData(&gPlayerParty[gSaveBlock2Ptr->frontier.field_CAA[i] - 1], MON_DATA_HP_EV + j, NULL);
|
||||
gSaveBlock2Ptr->frontier.field_EFC[i].evs[j] = GetMonData(&gPlayerParty[gSaveBlock2Ptr->frontier.selectedPartyMons[i] - 1], MON_DATA_HP_EV + j, NULL);
|
||||
|
||||
gSaveBlock2Ptr->frontier.field_EFC[i].nature = GetNature(&gPlayerParty[gSaveBlock2Ptr->frontier.field_CAA[i] - 1]);
|
||||
gSaveBlock2Ptr->frontier.field_EFC[i].nature = GetNature(&gPlayerParty[gSaveBlock2Ptr->frontier.selectedPartyMons[i] - 1]);
|
||||
}
|
||||
|
||||
for (i = 1; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
|
||||
@@ -2649,7 +2643,7 @@ static void InitDomeTrainers(void)
|
||||
statSums[0] = 0;
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
trainerId = gSaveBlock2Ptr->frontier.field_CAA[i] - 1; // Great variable choice, gamefreak.
|
||||
trainerId = gSaveBlock2Ptr->frontier.selectedPartyMons[i] - 1; // Great variable choice, gamefreak.
|
||||
statSums[0] += GetMonData(&gPlayerParty[trainerId], MON_DATA_ATK, NULL);
|
||||
statSums[0] += GetMonData(&gPlayerParty[trainerId], MON_DATA_DEF, NULL);
|
||||
statSums[0] += GetMonData(&gPlayerParty[trainerId], MON_DATA_SPATK, NULL);
|
||||
@@ -2667,7 +2661,7 @@ static void InitDomeTrainers(void)
|
||||
monTypesBits >>= 1;
|
||||
}
|
||||
|
||||
monLevel = GetFacilityEnemyMonLevel();
|
||||
monLevel = SetFacilityPtrsGetLevel();
|
||||
statSums[0] += (monTypesCount * monLevel) / 20;
|
||||
|
||||
for (i = 1; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
|
||||
@@ -2810,12 +2804,12 @@ static void SwapDomeTrainers(s32 id1, s32 id2, u16 *statsArray)
|
||||
|
||||
static void sub_818F9B0(void)
|
||||
{
|
||||
StringCopy(gStringVar1, gRoundsStringTable[gSaveBlock2Ptr->frontier.field_CB2]);
|
||||
StringCopy(gStringVar1, gRoundsStringTable[gSaveBlock2Ptr->frontier.curChallengeBattleNum]);
|
||||
}
|
||||
|
||||
static void sub_818F9E0(void)
|
||||
{
|
||||
StringCopy(gStringVar1, gRoundsStringTable[gSaveBlock2Ptr->frontier.field_CB2]);
|
||||
StringCopy(gStringVar1, gRoundsStringTable[gSaveBlock2Ptr->frontier.curChallengeBattleNum]);
|
||||
CopyDomeTrainerName(gStringVar2, gTrainerBattleOpponent_A);
|
||||
}
|
||||
|
||||
@@ -2833,7 +2827,7 @@ static void CreateDomeMon(u8 monPartyId, u16 tournamentTrainerId, u8 tournamentM
|
||||
s32 i;
|
||||
u8 happiness = 0xFF;
|
||||
u8 fixedIv = GetDomeTrainerMonIvs(tournamentTrainerId); // BUG: Should be using trainerId instead of tournamentTrainerId. As a result, all Pokemon have ivs of 3.
|
||||
u8 level = GetFacilityEnemyMonLevel();
|
||||
u8 level = SetFacilityPtrsGetLevel();
|
||||
CreateMonWithEVSpreadPersonalityOTID(&gEnemyParty[monPartyId],
|
||||
gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonId[tournamentTrainerId][tournamentMonId]].species,
|
||||
level,
|
||||
@@ -3466,12 +3460,12 @@ static void sub_8190298(void)
|
||||
|
||||
static u16 TrainerIdOfPlayerOpponent(void)
|
||||
{
|
||||
return gSaveBlock2Ptr->frontier.domeTrainers[TournamentIdOfOpponent(gSaveBlock2Ptr->frontier.field_CB2, TRAINER_PLAYER)].trainerId;
|
||||
return gSaveBlock2Ptr->frontier.domeTrainers[TournamentIdOfOpponent(gSaveBlock2Ptr->frontier.curChallengeBattleNum, TRAINER_PLAYER)].trainerId;
|
||||
}
|
||||
|
||||
static void sub_81902E4(void)
|
||||
{
|
||||
sub_8162614(gTrainerBattleOpponent_A, 0);
|
||||
SetBattleFacilityTrainerGfxId(gTrainerBattleOpponent_A, 0);
|
||||
}
|
||||
|
||||
static void sub_81902F8(void)
|
||||
@@ -3805,7 +3799,7 @@ static void sub_8190B40(struct Sprite *sprite)
|
||||
s32 taskId1 = sprite->data[0];
|
||||
s32 arrId = gTasks[gTasks[taskId1].data[4]].data[1];
|
||||
s32 tournmanetTrainerId = gUnknown_0860D080[arrId];
|
||||
s32 r12 = gSaveBlock2Ptr->frontier.field_CB2;
|
||||
s32 roundId = gSaveBlock2Ptr->frontier.curChallengeBattleNum;
|
||||
|
||||
if (gTasks[taskId1].data[3] == 1)
|
||||
{
|
||||
@@ -3817,7 +3811,7 @@ static void sub_8190B40(struct Sprite *sprite)
|
||||
sprite->invisible = FALSE;
|
||||
}
|
||||
else if (!gSaveBlock2Ptr->frontier.domeTrainers[tournmanetTrainerId].isEliminated
|
||||
&& sBattleDomeStruct->unk_10 - 1 < r12)
|
||||
&& sBattleDomeStruct->unk_10 - 1 < roundId)
|
||||
{
|
||||
sprite->invisible = FALSE;
|
||||
}
|
||||
@@ -4621,7 +4615,7 @@ static u8 sub_819221C(u8 taskId)
|
||||
s32 taskId2 = gTasks[taskId].data[4];
|
||||
s32 r5 = gTasks[taskId2].data[1];
|
||||
u8 r10 = gUnknown_0860D080[r5];
|
||||
u16 roundId = gSaveBlock2Ptr->frontier.field_CB2;
|
||||
u16 roundId = gSaveBlock2Ptr->frontier.curChallengeBattleNum;
|
||||
|
||||
if (gMain.newKeys & (A_BUTTON | B_BUTTON))
|
||||
retVal = 9;
|
||||
@@ -5373,7 +5367,7 @@ static void sub_81938E0(void)
|
||||
|
||||
sub_8194D48();
|
||||
gSaveBlock2Ptr->frontier.lvlMode = gSaveBlock2Ptr->frontier.field_D0A - 1;
|
||||
gSaveBlock2Ptr->frontier.field_CB2 = 3;
|
||||
gSaveBlock2Ptr->frontier.curChallengeBattleNum = 3;
|
||||
taskId = CreateTask(sub_8194220, 0);
|
||||
gTasks[taskId].data[0] = 0;
|
||||
gTasks[taskId].data[1] = 0;
|
||||
@@ -5475,7 +5469,7 @@ static u8 sub_8193BDC(u8 taskId)
|
||||
u8 retVal = 1;
|
||||
s32 arrId = 4;
|
||||
s32 spriteId = gTasks[taskId].data[1];
|
||||
s32 roundId = gSaveBlock2Ptr->frontier.field_CB2;
|
||||
s32 roundId = gSaveBlock2Ptr->frontier.curChallengeBattleNum;
|
||||
|
||||
if (gMain.newKeys == B_BUTTON || (gMain.newKeys & A_BUTTON && spriteId == 31))
|
||||
{
|
||||
@@ -5536,19 +5530,19 @@ static void sub_8193D7C(void)
|
||||
if (gSpecialVar_0x8005 == 1)
|
||||
{
|
||||
gSaveBlock2Ptr->frontier.domeTrainers[TrainerIdToTournamentId(gTrainerBattleOpponent_A)].isEliminated = 1;
|
||||
gSaveBlock2Ptr->frontier.domeTrainers[TrainerIdToTournamentId(gTrainerBattleOpponent_A)].eliminatedAt = gSaveBlock2Ptr->frontier.field_CB2;
|
||||
gSaveBlock2Ptr->frontier.domeTrainers[TrainerIdToTournamentId(gTrainerBattleOpponent_A)].eliminatedAt = gSaveBlock2Ptr->frontier.curChallengeBattleNum;
|
||||
gSaveBlock2Ptr->frontier.field_EC0[TrainerIdToTournamentId(gTrainerBattleOpponent_A)] = gBattleResults.lastUsedMovePlayer;
|
||||
if (gSaveBlock2Ptr->frontier.field_CB2 < DOME_FINAL)
|
||||
DecideRoundWinners(gSaveBlock2Ptr->frontier.field_CB2);
|
||||
if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < DOME_FINAL)
|
||||
DecideRoundWinners(gSaveBlock2Ptr->frontier.curChallengeBattleNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
gSaveBlock2Ptr->frontier.domeTrainers[TrainerIdToTournamentId(TRAINER_PLAYER)].isEliminated = 1;
|
||||
gSaveBlock2Ptr->frontier.domeTrainers[TrainerIdToTournamentId(TRAINER_PLAYER)].eliminatedAt = gSaveBlock2Ptr->frontier.field_CB2;
|
||||
gSaveBlock2Ptr->frontier.domeTrainers[TrainerIdToTournamentId(TRAINER_PLAYER)].eliminatedAt = gSaveBlock2Ptr->frontier.curChallengeBattleNum;
|
||||
gSaveBlock2Ptr->frontier.field_EC0[TrainerIdToTournamentId(TRAINER_PLAYER)] = gBattleResults.lastUsedMoveOpponent;
|
||||
if (gBattleOutcome == B_OUTCOME_FORFEITED || gSpecialVar_0x8005 == 9)
|
||||
gSaveBlock2Ptr->frontier.domeTrainers[TrainerIdToTournamentId(TRAINER_PLAYER)].unk3 = 1;
|
||||
for (i = gSaveBlock2Ptr->frontier.field_CB2; i < DOME_ROUNDS_COUNT; i++)
|
||||
for (i = gSaveBlock2Ptr->frontier.curChallengeBattleNum; i < DOME_ROUNDS_COUNT; i++)
|
||||
DecideRoundWinners(i);
|
||||
}
|
||||
}
|
||||
@@ -5561,7 +5555,7 @@ static u16 GetWinningMove(s32 winnerTournamentId, s32 loserTournamentId, u8 roun
|
||||
u16 bestScore = 0;
|
||||
u16 bestId = 0;
|
||||
s32 movePower = 0;
|
||||
GetFacilityEnemyMonLevel(); // Unused return variable.
|
||||
SetFacilityPtrsGetLevel();
|
||||
|
||||
// Calc move points of all 4 moves for all 3 pokemon hitting all 3 target mons.
|
||||
for (i = 0; i < 3; i++)
|
||||
@@ -5761,7 +5755,7 @@ static void sub_8194220(u8 taskId)
|
||||
AddTextPrinter(&textPrinter, 0, NULL);
|
||||
for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
|
||||
{
|
||||
s32 var, var2;
|
||||
s32 roundId, var2;
|
||||
|
||||
CopyDomeTrainerName(gDisplayedStringBattle, gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId);
|
||||
if (r10 == 1)
|
||||
@@ -5774,9 +5768,9 @@ static void sub_8194220(u8 taskId)
|
||||
sub_81948EC(i, var2);
|
||||
}
|
||||
}
|
||||
else if (gSaveBlock2Ptr->frontier.field_CB2 != DOME_ROUND2)
|
||||
else if (gSaveBlock2Ptr->frontier.curChallengeBattleNum != DOME_ROUND2)
|
||||
{
|
||||
sub_81948EC(i, gSaveBlock2Ptr->frontier.field_CB2 - 2);
|
||||
sub_81948EC(i, gSaveBlock2Ptr->frontier.curChallengeBattleNum - 2);
|
||||
}
|
||||
}
|
||||
else if (r10 == 0)
|
||||
@@ -5789,23 +5783,23 @@ static void sub_8194220(u8 taskId)
|
||||
sub_81948EC(i, var2);
|
||||
}
|
||||
}
|
||||
else if (gSaveBlock2Ptr->frontier.field_CB2 != DOME_ROUND1)
|
||||
else if (gSaveBlock2Ptr->frontier.curChallengeBattleNum != DOME_ROUND1)
|
||||
{
|
||||
if (gTasks[taskId].data[4])
|
||||
var2 = gSaveBlock2Ptr->frontier.field_CB2;
|
||||
var2 = gSaveBlock2Ptr->frontier.curChallengeBattleNum;
|
||||
else
|
||||
var2 = gSaveBlock2Ptr->frontier.field_CB2 - 1;
|
||||
var2 = gSaveBlock2Ptr->frontier.curChallengeBattleNum - 1;
|
||||
sub_81948EC(i, var2);
|
||||
}
|
||||
}
|
||||
|
||||
if (gTasks[taskId].data[4])
|
||||
var = gSaveBlock2Ptr->frontier.field_CB2;
|
||||
roundId = gSaveBlock2Ptr->frontier.curChallengeBattleNum;
|
||||
else
|
||||
var = gSaveBlock2Ptr->frontier.field_CB2 - 1;
|
||||
roundId = gSaveBlock2Ptr->frontier.curChallengeBattleNum - 1;
|
||||
|
||||
if ( ((r10 == 1 && gSaveBlock2Ptr->frontier.domeTrainers[i].eliminatedAt < gSaveBlock2Ptr->frontier.field_CB2 - 1)
|
||||
|| (r10 == 0 && gSaveBlock2Ptr->frontier.domeTrainers[i].eliminatedAt <= var))
|
||||
if ( ((r10 == 1 && gSaveBlock2Ptr->frontier.domeTrainers[i].eliminatedAt < gSaveBlock2Ptr->frontier.curChallengeBattleNum - 1)
|
||||
|| (r10 == 0 && gSaveBlock2Ptr->frontier.domeTrainers[i].eliminatedAt <= roundId))
|
||||
&& gSaveBlock2Ptr->frontier.domeTrainers[i].isEliminated)
|
||||
{
|
||||
if (gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId == TRAINER_PLAYER)
|
||||
@@ -5930,7 +5924,7 @@ static void sub_8194950(u8 taskId)
|
||||
for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
|
||||
{
|
||||
CopyDomeTrainerName(gDisplayedStringBattle, gSaveBlock2Ptr->frontier.domeTrainers[i].trainerId);
|
||||
if (gSaveBlock2Ptr->frontier.domeTrainers[i].eliminatedAt == gSaveBlock2Ptr->frontier.field_CB2 - 1
|
||||
if (gSaveBlock2Ptr->frontier.domeTrainers[i].eliminatedAt == gSaveBlock2Ptr->frontier.curChallengeBattleNum - 1
|
||||
&& gSaveBlock2Ptr->frontier.domeTrainers[i].isEliminated)
|
||||
{
|
||||
if (gUnknown_0860D3F1[i][0] == 0)
|
||||
@@ -5945,8 +5939,8 @@ static void sub_8194950(u8 taskId)
|
||||
}
|
||||
if (!gSaveBlock2Ptr->frontier.domeTrainers[i].isEliminated)
|
||||
{
|
||||
s32 var = gSaveBlock2Ptr->frontier.field_CB2 - 1;
|
||||
sub_81948EC(i, var);
|
||||
s32 roundId = gSaveBlock2Ptr->frontier.curChallengeBattleNum - 1;
|
||||
sub_81948EC(i, roundId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6084,7 +6078,7 @@ static void sub_8194D68(void)
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
s32 playerMonId = gSaveBlock2Ptr->frontier.field_CAA[gUnknown_0203CEF8[i] - 1] - 1;
|
||||
s32 playerMonId = gSaveBlock2Ptr->frontier.selectedPartyMons[gUnknown_0203CEF8[i] - 1] - 1;
|
||||
s32 count;
|
||||
|
||||
for (moveSlot = 0; moveSlot < 4; moveSlot++)
|
||||
@@ -6110,7 +6104,7 @@ static void sub_8194E44(void)
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
s32 playerMonId = gSaveBlock2Ptr->frontier.field_CAA[gUnknown_0203CEF8[i] - 1] - 1;
|
||||
s32 playerMonId = gSaveBlock2Ptr->frontier.selectedPartyMons[gUnknown_0203CEF8[i] - 1] - 1;
|
||||
u16 item = GetMonData(&gSaveBlock1Ptr->playerParty[playerMonId], MON_DATA_HELD_ITEM, NULL);
|
||||
SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &item);
|
||||
}
|
||||
@@ -6425,7 +6419,7 @@ static void DecideRoundWinners(u8 roundId)
|
||||
static void CopyDomeTrainerName(u8 *dst, u16 trainerId)
|
||||
{
|
||||
s32 i = 0;
|
||||
GetFacilityEnemyMonLevel(); // Unused return value.
|
||||
SetFacilityPtrsGetLevel();
|
||||
|
||||
if (trainerId == TRAINER_FRONTIER_BRAIN)
|
||||
{
|
||||
@@ -6440,7 +6434,7 @@ static void CopyDomeTrainerName(u8 *dst, u16 trainerId)
|
||||
}
|
||||
else if (trainerId < 300)
|
||||
{
|
||||
for (i = 0; i < FRONTIER_TRAINER_NAME_LENGTH; i++)
|
||||
for (i = 0; i < PLAYER_NAME_LENGTH; i++)
|
||||
dst[i] = gFacilityTrainers[trainerId].trainerName[i];
|
||||
}
|
||||
dst[i] = EOS;
|
||||
@@ -6461,7 +6455,7 @@ static void CopyDomeBrainTrainerName(u8 *dst)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < FRONTIER_TRAINER_NAME_LENGTH; i++)
|
||||
for (i = 0; i < PLAYER_NAME_LENGTH; i++)
|
||||
dst[i] = gTrainers[TRAINER_TUCKER].trainerName[i];
|
||||
dst[i] = EOS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user