Factory done
This commit is contained in:
@@ -4,13 +4,14 @@
|
||||
#include "battle.h"
|
||||
#include "battle_setup.h"
|
||||
#include "recorded_battle.h"
|
||||
#include "constants/species.h"
|
||||
#include "constants/abilities.h"
|
||||
#include "random.h"
|
||||
#include "item.h"
|
||||
#include "util.h"
|
||||
#include "battle_factory.h"
|
||||
#include "constants/species.h"
|
||||
#include "constants/abilities.h"
|
||||
#include "constants/battle_move_effects.h"
|
||||
#include "constants/moves.h"
|
||||
#include "util.h"
|
||||
#include "constants/battle_ai.h"
|
||||
|
||||
#define AI_ACTION_DONE 0x0001
|
||||
@@ -44,8 +45,6 @@ AI scripts.
|
||||
|
||||
extern const u8 *const gBattleAI_ScriptsTable[];
|
||||
|
||||
extern u32 GetAiScriptsInBattleFactory();
|
||||
|
||||
static u8 ChooseMoveOrAction_Singles(void);
|
||||
static u8 ChooseMoveOrAction_Doubles(void);
|
||||
static void RecordLastUsedMoveByTarget(void);
|
||||
|
||||
@@ -9,18 +9,62 @@
|
||||
#include "bg.h"
|
||||
#include "sound.h"
|
||||
#include "m4a.h"
|
||||
#include "util.h"
|
||||
#include "battle_setup.h"
|
||||
#include "overworld.h"
|
||||
#include "frontier_util.h"
|
||||
#include "random.h"
|
||||
#include "item.h"
|
||||
#include "battle_tower.h"
|
||||
#include "constants/songs.h"
|
||||
#include "constants/battle_string_ids.h"
|
||||
#include "constants/battle_frontier.h"
|
||||
|
||||
extern u16 gBattle_WIN0H;
|
||||
extern u16 gBattle_WIN0V;
|
||||
|
||||
extern void (* const gUnknown_08611F84[])(void);
|
||||
extern const struct CompressedSpriteSheet gUnknown_08611F74[];
|
||||
extern const u32 gUnknown_08D854E8[];
|
||||
extern const u16 gUnknown_08D855E8[];
|
||||
extern const struct SpriteTemplate gUnknown_08611F5C;
|
||||
extern const s8 gBattleArenaMoveMindRatings[];
|
||||
|
||||
// This file's functions.
|
||||
void sub_81A5558(u8 x, u8 y, u8 arg2, u8 battler);
|
||||
static void sub_81A58B4(void);
|
||||
static void sub_81A5964(void);
|
||||
static void sub_81A59FC(void);
|
||||
static void sub_81A5AC4(void);
|
||||
static void sub_81A5B08(void);
|
||||
static void sub_81A5B88(void);
|
||||
static void sub_81A5BE0(void);
|
||||
static void sub_81A5558(u8 x, u8 y, u8 arg2, u8 battler);
|
||||
|
||||
// Const rom data.
|
||||
static const struct CompressedSpriteSheet gUnknown_08611F74[] =
|
||||
{
|
||||
{gUnknown_08D854E8, 0x200, 0x3E8},
|
||||
{0}
|
||||
};
|
||||
|
||||
static void (* const gUnknown_08611F84[])(void) =
|
||||
{
|
||||
sub_81A58B4,
|
||||
sub_81A5964,
|
||||
sub_81A59FC,
|
||||
sub_81A5AC4,
|
||||
sub_81A5B08,
|
||||
sub_81A5B88,
|
||||
sub_81A5BE0,
|
||||
};
|
||||
|
||||
static const u16 gUnknown_08611FA0[6] =
|
||||
{
|
||||
0x003f, 0x0040, 0x0041, 0x0043, 0x0042, 0x0046
|
||||
};
|
||||
|
||||
static const u16 gUnknown_08611FAC[9] =
|
||||
{
|
||||
0x00b3, 0x00b4, 0x00b7, 0x00c8, 0x00b9, 0x00bb, 0x00c4, 0x00c6, 0x00ba
|
||||
};
|
||||
|
||||
// code
|
||||
void CallBattleArenaFunction(void)
|
||||
@@ -153,7 +197,7 @@ u8 sub_81A5258(u8 *state)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void sub_81A5558(u8 x, u8 y, u8 arg2, u8 battler)
|
||||
static void sub_81A5558(u8 x, u8 y, u8 arg2, u8 battler)
|
||||
{
|
||||
s32 animNum = 0;
|
||||
s32 r6 = 0;
|
||||
@@ -222,3 +266,243 @@ void sub_81A56B4(void)
|
||||
ptr3[0] = gBattleMons[0].hp;
|
||||
ptr3[1] = gBattleMons[1].hp;
|
||||
}
|
||||
|
||||
void sub_81A56E8(u8 battler)
|
||||
{
|
||||
s8 *ptr1 = gBattleStruct->field_298;
|
||||
|
||||
ptr1[battler] += gBattleArenaMoveMindRatings[gCurrentMove];
|
||||
}
|
||||
|
||||
void sub_81A5718(u8 battler)
|
||||
{
|
||||
s8 *ptr2 = gBattleStruct->field_29A;
|
||||
|
||||
if (gHitMarker & HITMARKER_OBEYS)
|
||||
{
|
||||
u8 *ptr4 = &gBattleStruct->field_2A2;
|
||||
if (*ptr4 & gBitTable[battler])
|
||||
{
|
||||
*ptr4 &= ~(gBitTable[battler]);
|
||||
ptr2[battler] -= 2;
|
||||
}
|
||||
else if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
|
||||
{
|
||||
if (!(gMoveResultFlags & MOVE_RESULT_MISSED) || gBattleCommunication[6] != 1)
|
||||
ptr2[battler] -= 2;
|
||||
}
|
||||
else if (gMoveResultFlags & MOVE_RESULT_SUPER_EFFECTIVE && gMoveResultFlags & MOVE_RESULT_NOT_VERY_EFFECTIVE)
|
||||
{
|
||||
ptr2[battler] += 1;
|
||||
}
|
||||
else if (gMoveResultFlags & MOVE_RESULT_SUPER_EFFECTIVE)
|
||||
{
|
||||
ptr2[battler] += 2;
|
||||
}
|
||||
else if (gMoveResultFlags & MOVE_RESULT_NOT_VERY_EFFECTIVE)
|
||||
{
|
||||
ptr2[battler] -= 1;
|
||||
}
|
||||
else if (!gProtectStructs[battler].protected)
|
||||
{
|
||||
ptr2[battler] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_81A57E4(u8 battler, u16 stringId)
|
||||
{
|
||||
s8 *ptr2 = gBattleStruct->field_29A;
|
||||
|
||||
switch (stringId)
|
||||
{
|
||||
case STRINGID_PKMNSXMADEYUSELESS:
|
||||
case STRINGID_PKMNSXMADEITINEFFECTIVE:
|
||||
case STRINGID_PKMNSXPREVENTSFLINCHING:
|
||||
case STRINGID_PKMNSXBLOCKSY2:
|
||||
case STRINGID_PKMNSXPREVENTSYLOSS:
|
||||
case STRINGID_PKMNSXMADEYINEFFECTIVE:
|
||||
case STRINGID_PKMNSXPREVENTSBURNS:
|
||||
case STRINGID_PKMNSXBLOCKSY:
|
||||
case STRINGID_PKMNPROTECTEDBY:
|
||||
case STRINGID_PKMNPREVENTSUSAGE:
|
||||
case STRINGID_PKMNRESTOREDHPUSING:
|
||||
case STRINGID_PKMNPREVENTSPARALYSISWITH:
|
||||
case STRINGID_PKMNPREVENTSROMANCEWITH:
|
||||
case STRINGID_PKMNPREVENTSPOISONINGWITH:
|
||||
case STRINGID_PKMNPREVENTSCONFUSIONWITH:
|
||||
case STRINGID_PKMNRAISEDFIREPOWERWITH:
|
||||
case STRINGID_PKMNANCHORSITSELFWITH:
|
||||
case STRINGID_PKMNPREVENTSSTATLOSSWITH:
|
||||
case STRINGID_PKMNSTAYEDAWAKEUSING:
|
||||
ptr2[battler] -= 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_81A586C(u8 battler)
|
||||
{
|
||||
u16 *ptr3 = gBattleStruct->field_29C;
|
||||
|
||||
ptr3[battler] = gBattleMons[battler].hp;
|
||||
if (ptr3[BATTLE_OPPOSITE(battler)] > gBattleMons[BATTLE_OPPOSITE(battler)].hp)
|
||||
ptr3[BATTLE_OPPOSITE(battler)] = gBattleMons[BATTLE_OPPOSITE(battler)].hp;
|
||||
}
|
||||
|
||||
static void sub_81A58B4(void)
|
||||
{
|
||||
bool32 isCurrent;
|
||||
u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
|
||||
|
||||
gSaveBlock2Ptr->frontier.field_CA8 = 0;
|
||||
gSaveBlock2Ptr->frontier.curChallengeBattleNum = 0;
|
||||
gSaveBlock2Ptr->frontier.field_CA9_a = 0;
|
||||
gSaveBlock2Ptr->frontier.field_CA9_b = 0;
|
||||
if (lvlMode != FRONTIER_LVL_50)
|
||||
isCurrent = gSaveBlock2Ptr->frontier.field_CDC & 0x80;
|
||||
else
|
||||
isCurrent = gSaveBlock2Ptr->frontier.field_CDC & 0x40;
|
||||
|
||||
if (!isCurrent)
|
||||
gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode] = 0;
|
||||
|
||||
saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1);
|
||||
gTrainerBattleOpponent_A = 0;
|
||||
}
|
||||
|
||||
static void sub_81A5964(void)
|
||||
{
|
||||
u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
|
||||
|
||||
switch (gSpecialVar_0x8005)
|
||||
{
|
||||
case 0:
|
||||
gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_DD8;
|
||||
break;
|
||||
case 1:
|
||||
gSpecialVar_Result = gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode];
|
||||
break;
|
||||
case 2:
|
||||
if (lvlMode != FRONTIER_LVL_50)
|
||||
gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_CDC & 0x80;
|
||||
else
|
||||
gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_CDC & 0x40;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_81A59FC(void)
|
||||
{
|
||||
u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
|
||||
|
||||
switch (gSpecialVar_0x8005)
|
||||
{
|
||||
case 0:
|
||||
gSaveBlock2Ptr->frontier.field_DD8 = gSpecialVar_0x8006;
|
||||
break;
|
||||
case 1:
|
||||
gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode] = gSpecialVar_0x8006;
|
||||
break;
|
||||
case 2:
|
||||
if (lvlMode != FRONTIER_LVL_50)
|
||||
{
|
||||
if (gSpecialVar_0x8006)
|
||||
gSaveBlock2Ptr->frontier.field_CDC |= 0x80;
|
||||
else
|
||||
gSaveBlock2Ptr->frontier.field_CDC &= ~(0x80);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gSpecialVar_0x8006)
|
||||
gSaveBlock2Ptr->frontier.field_CDC |= 0x40;
|
||||
else
|
||||
gSaveBlock2Ptr->frontier.field_CDC &= ~(0x40);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_81A5AC4(void)
|
||||
{
|
||||
gSaveBlock2Ptr->frontier.field_CA8 = gSpecialVar_0x8005;
|
||||
VarSet(VAR_TEMP_0, 0);
|
||||
gSaveBlock2Ptr->frontier.field_CA9_a = 1;
|
||||
sub_81A4C30();
|
||||
}
|
||||
|
||||
static void sub_81A5B08(void)
|
||||
{
|
||||
u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
|
||||
|
||||
if (gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode] > 41)
|
||||
gSaveBlock2Ptr->frontier.field_DD8 = gUnknown_08611FAC[Random() % ARRAY_COUNT(gUnknown_08611FAC)];
|
||||
else
|
||||
gSaveBlock2Ptr->frontier.field_DD8 = gUnknown_08611FA0[Random() % ARRAY_COUNT(gUnknown_08611FA0)];
|
||||
}
|
||||
|
||||
static void sub_81A5B88(void)
|
||||
{
|
||||
if (AddBagItem(gSaveBlock2Ptr->frontier.field_DD8, 1) == TRUE)
|
||||
{
|
||||
CopyItemName(gSaveBlock2Ptr->frontier.field_DD8, gStringVar1);
|
||||
gSaveBlock2Ptr->frontier.field_DD8 = 0;
|
||||
gSpecialVar_Result = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gSpecialVar_Result = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_81A5BE0(void)
|
||||
{
|
||||
GetFrontierTrainerName(gStringVar1, gTrainerBattleOpponent_A);
|
||||
}
|
||||
|
||||
void sub_81A5BF8(void)
|
||||
{
|
||||
u8 width = 27;
|
||||
u8 palNum = 7;
|
||||
|
||||
FillBgTilemapBufferRect(0, 0, 254, 14, 1, 6, palNum);
|
||||
FillBgTilemapBufferRect(0, 0, 32, 14, 1, 6, palNum);
|
||||
FillBgTilemapBufferRect(0, 0x31, 0, 14, 1, 1, palNum);
|
||||
FillBgTilemapBufferRect(0, 0x33, 1, 14, 1, 1, palNum);
|
||||
FillBgTilemapBufferRect(0, 0x34, 2, 14, width, 1, palNum);
|
||||
width++;
|
||||
FillBgTilemapBufferRect(0, 0x35, 28, 14, 1, 1, palNum);
|
||||
FillBgTilemapBufferRect(0, 0x36, 29, 14, 1, 1, palNum);
|
||||
FillBgTilemapBufferRect(0, 0x37, 0, 15, 1, 5, palNum);
|
||||
FillBgTilemapBufferRect(0, 0x39, 1, 15, width, 5, palNum);
|
||||
FillBgTilemapBufferRect(0, 0x3A, 29, 15, 1, 5, palNum);
|
||||
FillBgTilemapBufferRect(0, 0x831, 0, 19, 1, 1, palNum);
|
||||
FillBgTilemapBufferRect(0, 0x833, 1, 19, 1, 1, palNum);
|
||||
FillBgTilemapBufferRect(0, 0x834, 2, 19, width - 2, 1, palNum);
|
||||
FillBgTilemapBufferRect(0, 0x835, 28, 19, 1, 1, palNum);
|
||||
FillBgTilemapBufferRect(0, 0x836, 29, 19, 1, 1, palNum);
|
||||
}
|
||||
|
||||
void sub_81A5D44(void)
|
||||
{
|
||||
u8 width;
|
||||
u8 height;
|
||||
u8 palNum = 0;
|
||||
|
||||
FillBgTilemapBufferRect(0, 3, 0, 14, 1, 1, palNum);
|
||||
height = 4;
|
||||
FillBgTilemapBufferRect(0, 4, 1, 14, 1, 1, palNum);
|
||||
width = 27;
|
||||
FillBgTilemapBufferRect(0, 5, 2, 14, width, 1, palNum);
|
||||
FillBgTilemapBufferRect(0, 6, 28, 14, 1, 1, palNum);
|
||||
FillBgTilemapBufferRect(0, 7, 29, 14, 1, 1, palNum);
|
||||
FillBgTilemapBufferRect(0, 8, 0, 15, 1, height, palNum);
|
||||
FillBgTilemapBufferRect(0, 9, 1, 15, 1, height, palNum);
|
||||
FillBgTilemapBufferRect(0, 0xA, 2, 15, width, height, palNum);
|
||||
FillBgTilemapBufferRect(0, 0xB, 28, 15, 1, height, palNum);
|
||||
FillBgTilemapBufferRect(0, 0xC, 29, 15, 1, height, palNum);
|
||||
FillBgTilemapBufferRect(0, 0xD, 0, 19, 1, 1, palNum);
|
||||
FillBgTilemapBufferRect(0, 0xE, 1, 19, 1, 1, palNum);
|
||||
FillBgTilemapBufferRect(0, 0xF, 2, 19, width, 1, palNum);
|
||||
FillBgTilemapBufferRect(0, 0x10, 28, 19, 1, 1, palNum);
|
||||
FillBgTilemapBufferRect(0, 0x11, 29, 19, 1, 1, palNum);
|
||||
}
|
||||
|
||||
@@ -2555,7 +2555,7 @@ static void InitDomeTrainers(void)
|
||||
s32 species[3];
|
||||
s32 monTypesBits, monTypesCount;
|
||||
s32 trainerId;
|
||||
s32 monTournamentId;
|
||||
s32 monSetId;
|
||||
u16 *statSums;
|
||||
s32 *statValues;
|
||||
u8 ivs = 0;
|
||||
@@ -2618,20 +2618,20 @@ static void InitDomeTrainers(void)
|
||||
// Make sure the mon is valid.
|
||||
do
|
||||
{
|
||||
monTournamentId = RandomizeFacilityTrainerMonId(trainerId);
|
||||
monSetId = RandomizeFacilityTrainerMonSet(trainerId);
|
||||
for (k = 0; k < j; k++)
|
||||
{
|
||||
s32 checkingMonId = gSaveBlock2Ptr->frontier.domeMonIds[i][k];
|
||||
if (checkingMonId == monTournamentId
|
||||
|| species[0] == gFacilityTrainerMons[monTournamentId].species
|
||||
|| species[1] == gFacilityTrainerMons[monTournamentId].species
|
||||
|| gFacilityTrainerMons[checkingMonId].itemTableId == gFacilityTrainerMons[monTournamentId].itemTableId)
|
||||
s32 checkingMonSetId = gSaveBlock2Ptr->frontier.domeMonIds[i][k];
|
||||
if (checkingMonSetId == monSetId
|
||||
|| species[0] == gFacilityTrainerMons[monSetId].species
|
||||
|| species[1] == gFacilityTrainerMons[monSetId].species
|
||||
|| gFacilityTrainerMons[checkingMonSetId].itemTableId == gFacilityTrainerMons[monSetId].itemTableId)
|
||||
break;
|
||||
}
|
||||
} while (k != j);
|
||||
|
||||
gSaveBlock2Ptr->frontier.domeMonIds[i][j] = monTournamentId;
|
||||
species[j] = gFacilityTrainerMons[monTournamentId].species;
|
||||
gSaveBlock2Ptr->frontier.domeMonIds[i][j] = monSetId;
|
||||
species[j] = gFacilityTrainerMons[monSetId].species;
|
||||
}
|
||||
|
||||
gSaveBlock2Ptr->frontier.domeTrainers[i].isEliminated = 0;
|
||||
@@ -2828,7 +2828,7 @@ static void CreateDomeMon(u8 monPartyId, u16 tournamentTrainerId, u8 tournamentM
|
||||
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 = SetFacilityPtrsGetLevel();
|
||||
CreateMonWithEVSpreadPersonalityOTID(&gEnemyParty[monPartyId],
|
||||
CreateMonWithEVSpreadNatureOTID(&gEnemyParty[monPartyId],
|
||||
gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[tournamentTrainerId][tournamentMonId]].species,
|
||||
level,
|
||||
gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[tournamentTrainerId][tournamentMonId]].nature,
|
||||
@@ -6143,7 +6143,7 @@ static void sub_8194F58(void)
|
||||
s32 species[3];
|
||||
s32 monTypesBits;
|
||||
s32 trainerId;
|
||||
s32 monTournamentId;
|
||||
s32 monSetId;
|
||||
u8 lvlMode;
|
||||
u16 *statSums;
|
||||
s32 *statValues;
|
||||
@@ -6190,20 +6190,20 @@ static void sub_8194F58(void)
|
||||
// Make sure the mon is valid.
|
||||
do
|
||||
{
|
||||
monTournamentId = RandomizeFacilityTrainerMonId(trainerId);
|
||||
monSetId = RandomizeFacilityTrainerMonSet(trainerId);
|
||||
for (k = 0; k < j; k++)
|
||||
{
|
||||
s32 checkingMonId = gSaveBlock2Ptr->frontier.domeMonIds[i][k];
|
||||
if (checkingMonId == monTournamentId
|
||||
|| species[0] == gFacilityTrainerMons[monTournamentId].species
|
||||
|| species[1] == gFacilityTrainerMons[monTournamentId].species
|
||||
|| gFacilityTrainerMons[checkingMonId].itemTableId == gFacilityTrainerMons[monTournamentId].itemTableId)
|
||||
if (checkingMonId == monSetId
|
||||
|| species[0] == gFacilityTrainerMons[monSetId].species
|
||||
|| species[1] == gFacilityTrainerMons[monSetId].species
|
||||
|| gFacilityTrainerMons[checkingMonId].itemTableId == gFacilityTrainerMons[monSetId].itemTableId)
|
||||
break;
|
||||
}
|
||||
} while (k != j);
|
||||
|
||||
gSaveBlock2Ptr->frontier.domeMonIds[i][j] = monTournamentId;
|
||||
species[j] = gFacilityTrainerMons[monTournamentId].species;
|
||||
gSaveBlock2Ptr->frontier.domeMonIds[i][j] = monSetId;
|
||||
species[j] = gFacilityTrainerMons[monSetId].species;
|
||||
}
|
||||
gSaveBlock2Ptr->frontier.domeTrainers[i].isEliminated = 0;
|
||||
gSaveBlock2Ptr->frontier.domeTrainers[i].eliminatedAt = 0;
|
||||
|
||||
4627
src/battle_factory.c
4627
src/battle_factory.c
File diff suppressed because it is too large
Load Diff
4111
src/battle_factory_screen.c
Normal file
4111
src/battle_factory_screen.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@
|
||||
#include "battle_tower.h"
|
||||
#include "random.h"
|
||||
#include "item.h"
|
||||
#include "battle_factory.h"
|
||||
#include "battle_factory_screen.h"
|
||||
#include "frontier_util.h"
|
||||
#include "constants/items.h"
|
||||
#include "constants/region_map_sections.h"
|
||||
@@ -280,17 +280,17 @@ bool8 sub_81B9E94(void)
|
||||
&& ((gMapHeader.mapLayoutId == 385) | (gMapHeader.mapLayoutId == 386)));
|
||||
}
|
||||
|
||||
// This function was written very...oddly.
|
||||
#ifdef NONMATCHING
|
||||
static void sub_81B9EC0(void)
|
||||
{
|
||||
s32 i, j;
|
||||
u16 currMonId = 0, currSpecies = 0;
|
||||
u8 firstMonId;
|
||||
u16 monSetId;
|
||||
u16 currSpecies;
|
||||
u16 species[PARTY_SIZE];
|
||||
u16 monIds[PARTY_SIZE];
|
||||
u16 heldItems[PARTY_SIZE];
|
||||
s32 zero = 0;
|
||||
|
||||
firstMonId = 0;
|
||||
gFacilityTrainers = gSlateportBattleTentTrainers;
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
@@ -300,250 +300,56 @@ static void sub_81B9EC0(void)
|
||||
}
|
||||
gFacilityTrainerMons = gSlateportBattleTentMons;
|
||||
currSpecies = 0;
|
||||
for (i = 0; i != PARTY_SIZE;)
|
||||
i = 0;
|
||||
while (i != PARTY_SIZE)
|
||||
{
|
||||
// Cannot have two pokemon of the same species.
|
||||
currMonId = Random() % 70;
|
||||
for (j = zero; j < i + zero; j++)
|
||||
monSetId = Random() % 70;
|
||||
for (j = firstMonId; j < firstMonId + i; j++)
|
||||
{
|
||||
if (monIds[j] == currMonId)
|
||||
u16 monId = monIds[j];
|
||||
if (monIds[j] == monSetId)
|
||||
break;
|
||||
if (species[j] == gFacilityTrainerMons[currMonId].species)
|
||||
if (species[j] == gFacilityTrainerMons[monSetId].species)
|
||||
{
|
||||
if (currSpecies == 0)
|
||||
currSpecies = gFacilityTrainerMons[currMonId].species;
|
||||
currSpecies = gFacilityTrainerMons[monSetId].species;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j != i + zero)
|
||||
if (j != i + firstMonId)
|
||||
continue;
|
||||
|
||||
// Cannot have two same held items.
|
||||
for (j = zero; j < i + zero; j++)
|
||||
for (j = firstMonId; j < i + firstMonId; j++)
|
||||
{
|
||||
if (heldItems[j] == 0)
|
||||
continue;
|
||||
if (heldItems[j] == gBattleFrontierHeldItems[gFacilityTrainerMons[currMonId].itemTableId])
|
||||
if (heldItems[j] != 0 && heldItems[j] == gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId])
|
||||
{
|
||||
if (gFacilityTrainerMons[currMonId].species == currSpecies)
|
||||
if (gFacilityTrainerMons[monSetId].species == currSpecies)
|
||||
currSpecies = 0;
|
||||
else
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j != i + zero)
|
||||
if (j != i + firstMonId)
|
||||
continue;
|
||||
|
||||
gSaveBlock2Ptr->frontier.field_E70[i].monId = currMonId;
|
||||
species[i] = gFacilityTrainerMons[currMonId].species;
|
||||
heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[currMonId].itemTableId];
|
||||
monIds[i] = currMonId;
|
||||
gSaveBlock2Ptr->frontier.field_E70[i].monId = monSetId;
|
||||
species[i] = gFacilityTrainerMons[monSetId].species;
|
||||
heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId];
|
||||
monIds[i] = monSetId;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
#else
|
||||
NAKED
|
||||
static void sub_81B9EC0(void)
|
||||
{
|
||||
asm_unified("\n\
|
||||
push {r4-r7,lr}\n\
|
||||
mov r7, r10\n\
|
||||
mov r6, r9\n\
|
||||
mov r5, r8\n\
|
||||
push {r5-r7}\n\
|
||||
sub sp, 0x3C\n\
|
||||
ldr r1, =gFacilityTrainers\n\
|
||||
ldr r0, =gSlateportBattleTentTrainers\n\
|
||||
str r0, [r1]\n\
|
||||
add r0, sp, 0xC\n\
|
||||
mov r9, r0\n\
|
||||
mov r1, sp\n\
|
||||
adds r1, 0x18\n\
|
||||
str r1, [sp, 0x2C]\n\
|
||||
ldr r5, =gFacilityTrainerMons\n\
|
||||
ldr r4, =gSlateportBattleTentMons\n\
|
||||
movs r2, 0\n\
|
||||
adds r3, r1, 0\n\
|
||||
mov r1, r9\n\
|
||||
mov r0, sp\n\
|
||||
movs r6, 0x5\n\
|
||||
mov r8, r6\n\
|
||||
_081B9EEC:\n\
|
||||
strh r2, [r0]\n\
|
||||
strh r2, [r1]\n\
|
||||
strh r2, [r3]\n\
|
||||
adds r3, 0x2\n\
|
||||
adds r1, 0x2\n\
|
||||
adds r0, 0x2\n\
|
||||
movs r7, 0x1\n\
|
||||
negs r7, r7\n\
|
||||
add r8, r7\n\
|
||||
mov r6, r8\n\
|
||||
cmp r6, 0\n\
|
||||
bge _081B9EEC\n\
|
||||
str r4, [r5]\n\
|
||||
movs r7, 0\n\
|
||||
mov r10, r7\n\
|
||||
movs r0, 0\n\
|
||||
mov r8, r0\n\
|
||||
ldr r1, [sp, 0x2C]\n\
|
||||
str r1, [sp, 0x30]\n\
|
||||
mov r2, sp\n\
|
||||
str r2, [sp, 0x34]\n\
|
||||
lsls r6, r0, 1\n\
|
||||
str r6, [sp, 0x24]\n\
|
||||
add r6, r9\n\
|
||||
str r6, [sp, 0x28]\n\
|
||||
_081B9F1E:\n\
|
||||
bl Random\n\
|
||||
lsls r0, 16\n\
|
||||
lsrs r0, 16\n\
|
||||
movs r1, 0x46\n\
|
||||
bl __umodsi3\n\
|
||||
lsls r0, 16\n\
|
||||
lsrs r5, r0, 16\n\
|
||||
movs r2, 0\n\
|
||||
mov r7, r8\n\
|
||||
adds r6, r2, r7\n\
|
||||
cmp r2, r6\n\
|
||||
bge _081B9F7C\n\
|
||||
ldr r1, [sp, 0x28]\n\
|
||||
ldrh r0, [r1]\n\
|
||||
cmp r0, r5\n\
|
||||
beq _081B9F7C\n\
|
||||
ldr r0, =gFacilityTrainerMons\n\
|
||||
ldr r1, [r0]\n\
|
||||
lsls r0, r5, 4\n\
|
||||
adds r4, r0, r1\n\
|
||||
ldrh r7, [r4]\n\
|
||||
mov r12, r7\n\
|
||||
lsls r3, r2, 1\n\
|
||||
ldr r1, [sp, 0x24]\n\
|
||||
add r1, sp\n\
|
||||
str r6, [sp, 0x38]\n\
|
||||
_081B9F56:\n\
|
||||
ldrh r0, [r1]\n\
|
||||
cmp r0, r12\n\
|
||||
bne _081B9F66\n\
|
||||
mov r0, r10\n\
|
||||
cmp r0, 0\n\
|
||||
bne _081B9F7C\n\
|
||||
ldrh r7, [r4]\n\
|
||||
mov r10, r7\n\
|
||||
_081B9F66:\n\
|
||||
adds r3, 0x2\n\
|
||||
adds r1, 0x2\n\
|
||||
adds r2, 0x1\n\
|
||||
ldr r0, [sp, 0x38]\n\
|
||||
cmp r2, r0\n\
|
||||
bge _081B9F7C\n\
|
||||
mov r7, r9\n\
|
||||
adds r0, r7, r3\n\
|
||||
ldrh r0, [r0]\n\
|
||||
cmp r0, r5\n\
|
||||
bne _081B9F56\n\
|
||||
_081B9F7C:\n\
|
||||
cmp r2, r6\n\
|
||||
bne _081BA01C\n\
|
||||
movs r2, 0\n\
|
||||
cmp r2, r6\n\
|
||||
bge _081B9FD4\n\
|
||||
ldr r0, =gBattleFrontierHeldItems\n\
|
||||
mov r12, r0\n\
|
||||
ldr r7, =gFacilityTrainerMons\n\
|
||||
ldr r1, [sp, 0x24]\n\
|
||||
ldr r0, [sp, 0x2C]\n\
|
||||
adds r4, r1, r0\n\
|
||||
_081B9F92:\n\
|
||||
ldrh r3, [r4]\n\
|
||||
cmp r3, 0\n\
|
||||
beq _081B9FCC\n\
|
||||
ldr r1, [r7]\n\
|
||||
lsls r0, r5, 4\n\
|
||||
adds r1, r0, r1\n\
|
||||
ldrb r0, [r1, 0xA]\n\
|
||||
lsls r0, 1\n\
|
||||
add r0, r12\n\
|
||||
ldrh r0, [r0]\n\
|
||||
cmp r3, r0\n\
|
||||
bne _081B9FCC\n\
|
||||
ldrh r0, [r1]\n\
|
||||
cmp r0, r10\n\
|
||||
bne _081B9FD4\n\
|
||||
movs r1, 0\n\
|
||||
mov r10, r1\n\
|
||||
b _081B9FD4\n\
|
||||
.pool\n\
|
||||
_081B9FCC:\n\
|
||||
adds r4, 0x2\n\
|
||||
adds r2, 0x1\n\
|
||||
cmp r2, r6\n\
|
||||
blt _081B9F92\n\
|
||||
_081B9FD4:\n\
|
||||
cmp r2, r6\n\
|
||||
bne _081BA01C\n\
|
||||
ldr r0, =gSaveBlock2Ptr\n\
|
||||
ldr r1, [r0]\n\
|
||||
mov r2, r8\n\
|
||||
lsls r3, r2, 1\n\
|
||||
adds r0, r3, r2\n\
|
||||
lsls r0, 2\n\
|
||||
adds r1, r0\n\
|
||||
movs r6, 0xE7\n\
|
||||
lsls r6, 4\n\
|
||||
adds r1, r6\n\
|
||||
strh r5, [r1]\n\
|
||||
ldr r0, =gFacilityTrainerMons\n\
|
||||
ldr r0, [r0]\n\
|
||||
lsls r1, r5, 4\n\
|
||||
adds r1, r0\n\
|
||||
ldrh r0, [r1]\n\
|
||||
ldr r7, [sp, 0x34]\n\
|
||||
strh r0, [r7]\n\
|
||||
ldr r2, =gBattleFrontierHeldItems\n\
|
||||
ldrb r0, [r1, 0xA]\n\
|
||||
lsls r0, 1\n\
|
||||
adds r0, r2\n\
|
||||
ldrh r0, [r0]\n\
|
||||
ldr r1, [sp, 0x30]\n\
|
||||
strh r0, [r1]\n\
|
||||
add r3, r9\n\
|
||||
strh r5, [r3]\n\
|
||||
adds r1, 0x2\n\
|
||||
str r1, [sp, 0x30]\n\
|
||||
adds r2, r7, 0\n\
|
||||
adds r2, 0x2\n\
|
||||
str r2, [sp, 0x34]\n\
|
||||
movs r6, 0x1\n\
|
||||
add r8, r6\n\
|
||||
_081BA01C:\n\
|
||||
mov r7, r8\n\
|
||||
cmp r7, 0x6\n\
|
||||
beq _081BA024\n\
|
||||
b _081B9F1E\n\
|
||||
_081BA024:\n\
|
||||
add sp, 0x3C\n\
|
||||
pop {r3-r5}\n\
|
||||
mov r8, r3\n\
|
||||
mov r9, r4\n\
|
||||
mov r10, r5\n\
|
||||
pop {r4-r7}\n\
|
||||
pop {r0}\n\
|
||||
bx r0\n\
|
||||
.pool\n\
|
||||
");
|
||||
}
|
||||
#endif // NONMATCHING
|
||||
|
||||
static void sub_81BA040(void)
|
||||
{
|
||||
u16 trainerId;
|
||||
s32 i, j, k;
|
||||
register const u16 *monSetsPool asm("r9"); // Fix me. Compiler insists on moving that variable into stack.
|
||||
register const u16 *monSets asm("r9"); // Fix me. Compiler insists on moving that variable into stack.
|
||||
u16 species[3];
|
||||
u16 heldItems[3];
|
||||
s32 monPoolCount = 0;
|
||||
s32 setsCount = 0;
|
||||
|
||||
gFacilityTrainers = gSlateportBattleTentTrainers;
|
||||
gFacilityTrainerMons = gSlateportBattleTentMons;
|
||||
@@ -561,21 +367,21 @@ static void sub_81BA040(void)
|
||||
} while (i != gSaveBlock2Ptr->frontier.curChallengeBattleNum);
|
||||
|
||||
gTrainerBattleOpponent_A = trainerId;
|
||||
while (gFacilityTrainers[gTrainerBattleOpponent_A].bfMonPool[monPoolCount] != 0xFFFF)
|
||||
monPoolCount++;
|
||||
if (monPoolCount > 8)
|
||||
while (gFacilityTrainers[gTrainerBattleOpponent_A].monSets[setsCount] != 0xFFFF)
|
||||
setsCount++;
|
||||
if (setsCount > 8)
|
||||
break;
|
||||
monPoolCount = 0;
|
||||
setsCount = 0;
|
||||
}
|
||||
|
||||
if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < 2)
|
||||
gSaveBlock2Ptr->frontier.field_CB4[gSaveBlock2Ptr->frontier.curChallengeBattleNum] = gTrainerBattleOpponent_A;
|
||||
|
||||
monSetsPool = gFacilityTrainers[gTrainerBattleOpponent_A].bfMonPool;
|
||||
monSets = gFacilityTrainers[gTrainerBattleOpponent_A].monSets;
|
||||
i = 0;
|
||||
while (i != 3)
|
||||
{
|
||||
sRandMonSetId = monSetsPool[Random() % monPoolCount];
|
||||
sRandMonSetId = monSets[Random() % setsCount];
|
||||
for (j = 0; j < 6; j++)
|
||||
{
|
||||
if (gFacilityTrainerMons[sRandMonSetId].species == gFacilityTrainerMons[gSaveBlock2Ptr->frontier.field_E70[j].monId].species)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "link.h"
|
||||
#include "field_message_box.h"
|
||||
#include "tv.h"
|
||||
#include "battle_factory.h"
|
||||
#include "constants/battle_frontier.h"
|
||||
#include "constants/trainers.h"
|
||||
#include "constants/event_objects.h"
|
||||
@@ -29,19 +30,16 @@
|
||||
|
||||
extern u16 gUnknown_03006298[];
|
||||
|
||||
extern void sub_81A6CD0(void);
|
||||
extern void sub_81A4C30(void);
|
||||
extern u8 sub_81A6CA8(u8, u8);
|
||||
extern void SetMonMoveAvoidReturn(struct Pokemon *mon, u16 move, u8 moveSlot);
|
||||
|
||||
extern const u8 *const *const gUnknown_085DD690[];
|
||||
extern const u16 gBattleFrontierHeldItems[];
|
||||
extern const u8 sRubyFacilityClassToEmerald[82][2];
|
||||
extern const u16 gUnknown_085DFA46[];
|
||||
extern const struct FacilityMon gBattleFrontierMons[];
|
||||
extern const struct FacilityMon gSlateportBattleTentMons[];
|
||||
extern const struct FacilityMon gVerdanturfBattleTentMons[];
|
||||
extern const struct FacilityMon gFallarborBattleTentMons[];
|
||||
extern const struct FacilityMon gBattleFrontierMons[];
|
||||
extern const struct BattleFrontierTrainer gBattleFrontierTrainers[];
|
||||
extern const struct BattleFrontierTrainer gSlateportBattleTentTrainers[];
|
||||
extern const struct BattleFrontierTrainer gVerdanturfBattleTentTrainers[];
|
||||
@@ -983,14 +981,14 @@ static void FillTrainerParty(u16 trainerId, u8 firstMonId, u8 monCount)
|
||||
u8 level = SetFacilityPtrsGetLevel();
|
||||
u8 fixedIV = 0;
|
||||
u8 bfMonCount;
|
||||
const u16 *bfMonPool = NULL;
|
||||
const u16 *monSets = NULL;
|
||||
u32 otID = 0;
|
||||
|
||||
if (trainerId < TRAINER_RECORD_MIXING_FRIEND)
|
||||
{
|
||||
// Normal battle frontier trainer.
|
||||
fixedIV = GetFrontierTrainerFixedIvs(trainerId);
|
||||
bfMonPool = gFacilityTrainers[gTrainerBattleOpponent_A].bfMonPool;
|
||||
monSets = gFacilityTrainers[gTrainerBattleOpponent_A].monSets;
|
||||
}
|
||||
else if (trainerId == TRAINER_EREADER)
|
||||
{
|
||||
@@ -1028,20 +1026,20 @@ static void FillTrainerParty(u16 trainerId, u8 firstMonId, u8 monCount)
|
||||
// Attempt to fill the trainer's party with random Pokemon until 3 have been
|
||||
// successfully chosen. The trainer's party may not have duplicate pokemon species
|
||||
// or duplicate held items.
|
||||
for (bfMonCount = 0; bfMonPool[bfMonCount] != 0xFFFF; bfMonCount++)
|
||||
for (bfMonCount = 0; monSets[bfMonCount] != 0xFFFF; bfMonCount++)
|
||||
;
|
||||
i = 0;
|
||||
otID = Random32();
|
||||
while (i != monCount)
|
||||
{
|
||||
u16 monPoolId = bfMonPool[Random() % bfMonCount];
|
||||
if ((level == 50 || level == 20) && monPoolId > 849)
|
||||
u16 monSetId = monSets[Random() % bfMonCount];
|
||||
if ((level == 50 || level == 20) && monSetId > 849)
|
||||
continue;
|
||||
|
||||
// Ensure this pokemon species isn't a duplicate.
|
||||
for (j = 0; j < i + firstMonId; j++)
|
||||
{
|
||||
if (GetMonData(&gEnemyParty[j], MON_DATA_SPECIES, NULL) == gFacilityTrainerMons[monPoolId].species)
|
||||
if (GetMonData(&gEnemyParty[j], MON_DATA_SPECIES, NULL) == gFacilityTrainerMons[monSetId].species)
|
||||
break;
|
||||
}
|
||||
if (j != i + firstMonId)
|
||||
@@ -1051,7 +1049,7 @@ static void FillTrainerParty(u16 trainerId, u8 firstMonId, u8 monCount)
|
||||
for (j = 0; j < i + firstMonId; j++)
|
||||
{
|
||||
if (GetMonData(&gEnemyParty[j], MON_DATA_HELD_ITEM, NULL) != 0
|
||||
&& GetMonData(&gEnemyParty[j], MON_DATA_HELD_ITEM, NULL) == gBattleFrontierHeldItems[gFacilityTrainerMons[monPoolId].itemTableId])
|
||||
&& GetMonData(&gEnemyParty[j], MON_DATA_HELD_ITEM, NULL) == gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId])
|
||||
break;
|
||||
}
|
||||
if (j != i + firstMonId)
|
||||
@@ -1061,34 +1059,34 @@ static void FillTrainerParty(u16 trainerId, u8 firstMonId, u8 monCount)
|
||||
// because the species and held items were already checked directly above.
|
||||
for (j = 0; j < i; j++)
|
||||
{
|
||||
if (chosenMonIndices[j] == monPoolId)
|
||||
if (chosenMonIndices[j] == monSetId)
|
||||
break;
|
||||
}
|
||||
if (j != i)
|
||||
continue;
|
||||
|
||||
chosenMonIndices[i] = monPoolId;
|
||||
chosenMonIndices[i] = monSetId;
|
||||
|
||||
// Place the chosen pokemon into the trainer's party.
|
||||
CreateMonWithEVSpreadPersonalityOTID(&gEnemyParty[i + firstMonId],
|
||||
gFacilityTrainerMons[monPoolId].species,
|
||||
CreateMonWithEVSpreadNatureOTID(&gEnemyParty[i + firstMonId],
|
||||
gFacilityTrainerMons[monSetId].species,
|
||||
level,
|
||||
gFacilityTrainerMons[monPoolId].nature,
|
||||
gFacilityTrainerMons[monSetId].nature,
|
||||
fixedIV,
|
||||
gFacilityTrainerMons[monPoolId].evSpread,
|
||||
gFacilityTrainerMons[monSetId].evSpread,
|
||||
otID);
|
||||
|
||||
friendship = 255;
|
||||
// Give the chosen pokemon its specified moves.
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
SetMonMoveSlot(&gEnemyParty[i + firstMonId], gFacilityTrainerMons[monPoolId].moves[j], j);
|
||||
if (gFacilityTrainerMons[monPoolId].moves[j] == MOVE_FRUSTRATION)
|
||||
SetMonMoveSlot(&gEnemyParty[i + firstMonId], gFacilityTrainerMons[monSetId].moves[j], j);
|
||||
if (gFacilityTrainerMons[monSetId].moves[j] == MOVE_FRUSTRATION)
|
||||
friendship = 0; // Frustration is more powerful the lower the pokemon's friendship is.
|
||||
}
|
||||
|
||||
SetMonData(&gEnemyParty[i + firstMonId], MON_DATA_FRIENDSHIP, &friendship);
|
||||
SetMonData(&gEnemyParty[i + firstMonId], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monPoolId].itemTableId]);
|
||||
SetMonData(&gEnemyParty[i + firstMonId], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId]);
|
||||
|
||||
// The pokemon was successfully added to the trainer's party, so it's safe to move on to
|
||||
// the next party slot.
|
||||
@@ -1129,27 +1127,27 @@ static void Unused_CreateApprenticeMons(u16 trainerId, u8 firstMonId)
|
||||
}
|
||||
}
|
||||
|
||||
u16 RandomizeFacilityTrainerMonId(u16 trainerId)
|
||||
u16 RandomizeFacilityTrainerMonSet(u16 trainerId)
|
||||
{
|
||||
u8 level = SetFacilityPtrsGetLevel();
|
||||
const u16 *bfMonPool = gFacilityTrainers[trainerId].bfMonPool;
|
||||
const u16 *monSets = gFacilityTrainers[trainerId].monSets;
|
||||
u8 bfMonCount = 0;
|
||||
u32 monPoolId = bfMonPool[bfMonCount];
|
||||
u32 monSetId = monSets[bfMonCount];
|
||||
|
||||
while (monPoolId != 0xFFFF)
|
||||
while (monSetId != 0xFFFF)
|
||||
{
|
||||
bfMonCount++;
|
||||
monPoolId = bfMonPool[bfMonCount];
|
||||
if (monPoolId == 0xFFFF)
|
||||
monSetId = monSets[bfMonCount];
|
||||
if (monSetId == 0xFFFF)
|
||||
break;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
monPoolId = bfMonPool[Random() % bfMonCount];
|
||||
} while((level == 50 || level == 20) && monPoolId > 849);
|
||||
monSetId = monSets[Random() % bfMonCount];
|
||||
} while((level == 50 || level == 20) && monSetId > 849);
|
||||
|
||||
return monPoolId;
|
||||
return monSetId;
|
||||
}
|
||||
|
||||
static void FillFactoryTrainerParty(void)
|
||||
@@ -1175,9 +1173,9 @@ static void FillFactoryFrontierTrainerParty(u16 trainerId, u8 firstMonId)
|
||||
u8 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
|
||||
u8 challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][0] / 7;
|
||||
if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < 6)
|
||||
fixedIV = sub_81A6CA8(challengeNum, 0);
|
||||
fixedIV = GetFactoryMonFixedIV(challengeNum, 0);
|
||||
else
|
||||
fixedIV = sub_81A6CA8(challengeNum, 1);
|
||||
fixedIV = GetFactoryMonFixedIV(challengeNum, 1);
|
||||
}
|
||||
else if (trainerId == TRAINER_EREADER)
|
||||
{
|
||||
@@ -1187,7 +1185,7 @@ static void FillFactoryFrontierTrainerParty(u16 trainerId, u8 firstMonId)
|
||||
}
|
||||
else if (trainerId == TRAINER_FRONTIER_BRAIN)
|
||||
{
|
||||
sub_81A6CD0();
|
||||
FillFactoryBrainParty();
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -1195,26 +1193,25 @@ static void FillFactoryFrontierTrainerParty(u16 trainerId, u8 firstMonId)
|
||||
fixedIV = 31;
|
||||
}
|
||||
|
||||
|
||||
level = SetFacilityPtrsGetLevel();
|
||||
otID = T1_READ_32(gSaveBlock2Ptr->playerTrainerId);
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
u16 poolId = gUnknown_03006298[i];
|
||||
CreateMonWithEVSpreadPersonalityOTID(&gEnemyParty[firstMonId + i],
|
||||
gFacilityTrainerMons[poolId].species,
|
||||
u16 monSetId = gUnknown_03006298[i];
|
||||
CreateMonWithEVSpreadNatureOTID(&gEnemyParty[firstMonId + i],
|
||||
gFacilityTrainerMons[monSetId].species,
|
||||
level,
|
||||
gFacilityTrainerMons[poolId].nature,
|
||||
gFacilityTrainerMons[monSetId].nature,
|
||||
fixedIV,
|
||||
gFacilityTrainerMons[poolId].evSpread,
|
||||
gFacilityTrainerMons[monSetId].evSpread,
|
||||
otID);
|
||||
|
||||
friendship = 0;
|
||||
for (j = 0; j < 4; j++)
|
||||
SetMonMoveAvoidReturn(&gEnemyParty[firstMonId + i], gFacilityTrainerMons[poolId].moves[j], j);
|
||||
SetMonMoveAvoidReturn(&gEnemyParty[firstMonId + i], gFacilityTrainerMons[monSetId].moves[j], j);
|
||||
|
||||
SetMonData(&gEnemyParty[firstMonId + i], MON_DATA_FRIENDSHIP, &friendship);
|
||||
SetMonData(&gEnemyParty[firstMonId + i], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[poolId].itemTableId]);
|
||||
SetMonData(&gEnemyParty[firstMonId + i], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1228,25 +1225,25 @@ static void FillFactoryTentTrainerParty(u16 trainerId, u8 firstMonId)
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
u16 poolId = gUnknown_03006298[i];
|
||||
CreateMonWithEVSpreadPersonalityOTID(&gEnemyParty[firstMonId + i],
|
||||
gFacilityTrainerMons[poolId].species,
|
||||
u16 monSetId = gUnknown_03006298[i];
|
||||
CreateMonWithEVSpreadNatureOTID(&gEnemyParty[firstMonId + i],
|
||||
gFacilityTrainerMons[monSetId].species,
|
||||
level,
|
||||
gFacilityTrainerMons[poolId].nature,
|
||||
gFacilityTrainerMons[monSetId].nature,
|
||||
fixedIV,
|
||||
gFacilityTrainerMons[poolId].evSpread,
|
||||
gFacilityTrainerMons[monSetId].evSpread,
|
||||
otID);
|
||||
|
||||
friendship = 0;
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
SetMonMoveAvoidReturn(&gEnemyParty[firstMonId + i], gFacilityTrainerMons[poolId].moves[j], j);
|
||||
if (gFacilityTrainerMons[poolId].moves[j] == MOVE_FRUSTRATION)
|
||||
SetMonMoveAvoidReturn(&gEnemyParty[firstMonId + i], gFacilityTrainerMons[monSetId].moves[j], j);
|
||||
if (gFacilityTrainerMons[monSetId].moves[j] == MOVE_FRUSTRATION)
|
||||
friendship = 0;
|
||||
}
|
||||
|
||||
SetMonData(&gEnemyParty[firstMonId + i], MON_DATA_FRIENDSHIP, &friendship);
|
||||
SetMonData(&gEnemyParty[firstMonId + i], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[poolId].itemTableId]);
|
||||
SetMonData(&gEnemyParty[firstMonId + i], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1609,7 +1606,7 @@ static void sub_81642A0(void)
|
||||
u32 spArray[5];
|
||||
s32 r10;
|
||||
u16 trainerId;
|
||||
u16 monPoolId;
|
||||
u16 monSetId;
|
||||
u32 lvlMode, battleMode;
|
||||
s32 challengeNum;
|
||||
u32 species1, species2;
|
||||
@@ -1651,24 +1648,24 @@ static void sub_81642A0(void)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
monPoolId = RandomizeFacilityTrainerMonId(trainerId);
|
||||
if (j % 2 != 0 && gFacilityTrainerMons[gSaveBlock2Ptr->frontier.field_CB4[r10 - 1]].itemTableId == gFacilityTrainerMons[monPoolId].itemTableId)
|
||||
monSetId = RandomizeFacilityTrainerMonSet(trainerId);
|
||||
if (j % 2 != 0 && gFacilityTrainerMons[gSaveBlock2Ptr->frontier.field_CB4[r10 - 1]].itemTableId == gFacilityTrainerMons[monSetId].itemTableId)
|
||||
continue;
|
||||
|
||||
for (k = 8; k < r10; k++)
|
||||
{
|
||||
if (gFacilityTrainerMons[gSaveBlock2Ptr->frontier.field_CB4[k]].species == gFacilityTrainerMons[monPoolId].species)
|
||||
if (gFacilityTrainerMons[gSaveBlock2Ptr->frontier.field_CB4[k]].species == gFacilityTrainerMons[monSetId].species)
|
||||
break;
|
||||
if (species1 == gFacilityTrainerMons[monPoolId].species)
|
||||
if (species1 == gFacilityTrainerMons[monSetId].species)
|
||||
break;
|
||||
if (species2 == gFacilityTrainerMons[monPoolId].species)
|
||||
if (species2 == gFacilityTrainerMons[monSetId].species)
|
||||
break;
|
||||
}
|
||||
if (k == r10)
|
||||
break;
|
||||
}
|
||||
|
||||
gSaveBlock2Ptr->frontier.field_CB4[r10] = monPoolId;
|
||||
gSaveBlock2Ptr->frontier.field_CB4[r10] = monSetId;
|
||||
r10++;
|
||||
}
|
||||
}
|
||||
@@ -1749,7 +1746,7 @@ static void sub_81642A0(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_81646BC(u16 trainerId, u16 monPoolId)
|
||||
static void sub_81646BC(u16 trainerId, u16 monSetId)
|
||||
{
|
||||
u16 move = 0;
|
||||
u16 species = 0;
|
||||
@@ -1759,8 +1756,8 @@ static void sub_81646BC(u16 trainerId, u16 monPoolId)
|
||||
{
|
||||
if (trainerId < TRAINER_RECORD_MIXING_FRIEND)
|
||||
{
|
||||
move = gFacilityTrainerMons[monPoolId].moves[0];
|
||||
species = gFacilityTrainerMons[monPoolId].species;
|
||||
move = gFacilityTrainerMons[monSetId].moves[0];
|
||||
species = gFacilityTrainerMons[monSetId].species;
|
||||
}
|
||||
else if (trainerId < TRAINER_RECORD_MIXING_APPRENTICE)
|
||||
{
|
||||
@@ -1787,7 +1784,7 @@ static void sub_81646BC(u16 trainerId, u16 monPoolId)
|
||||
static void sub_8164828(void)
|
||||
{
|
||||
s32 i, j, arrId;
|
||||
s32 monPoolId;
|
||||
s32 monSetId;
|
||||
s32 level = SetFacilityPtrsGetLevel();
|
||||
u16 winStreak = GetCurrentFacilityWinStreak();
|
||||
s32 challengeNum = winStreak / 7;
|
||||
@@ -1825,12 +1822,12 @@ static void sub_8164828(void)
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
monPoolId = gSaveBlock2Ptr->frontier.field_CB4[8 + k * 2];
|
||||
sub_81646BC(trainerId, monPoolId);
|
||||
monSetId = gSaveBlock2Ptr->frontier.field_CB4[8 + k * 2];
|
||||
sub_81646BC(trainerId, monSetId);
|
||||
break;
|
||||
case 2:
|
||||
monPoolId = gSaveBlock2Ptr->frontier.field_CB4[9 + k * 2];
|
||||
sub_81646BC(trainerId, monPoolId);
|
||||
monSetId = gSaveBlock2Ptr->frontier.field_CB4[9 + k * 2];
|
||||
sub_81646BC(trainerId, monSetId);
|
||||
break;
|
||||
case 3:
|
||||
gPartnerTrainerId = trainerId;
|
||||
@@ -2280,7 +2277,7 @@ static void FillPartnerParty(u16 trainerId)
|
||||
s32 i, j;
|
||||
u32 ivs, level;
|
||||
u32 friendship;
|
||||
u16 monPoolId;
|
||||
u16 monSetId;
|
||||
u32 otID;
|
||||
u8 trainerName[PLAYER_NAME_LENGTH + 1];
|
||||
SetFacilityPtrsGetLevel();
|
||||
@@ -2321,23 +2318,23 @@ static void FillPartnerParty(u16 trainerId)
|
||||
otID = Random32();
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
monPoolId = gSaveBlock2Ptr->frontier.field_CB4[i + 18];
|
||||
CreateMonWithEVSpreadPersonalityOTID(&gPlayerParty[3 + i],
|
||||
gFacilityTrainerMons[monPoolId].species,
|
||||
monSetId = gSaveBlock2Ptr->frontier.field_CB4[i + 18];
|
||||
CreateMonWithEVSpreadNatureOTID(&gPlayerParty[3 + i],
|
||||
gFacilityTrainerMons[monSetId].species,
|
||||
level,
|
||||
gFacilityTrainerMons[monPoolId].nature,
|
||||
gFacilityTrainerMons[monSetId].nature,
|
||||
ivs,
|
||||
gFacilityTrainerMons[monPoolId].evSpread,
|
||||
gFacilityTrainerMons[monSetId].evSpread,
|
||||
otID);
|
||||
friendship = 0xFF;
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
SetMonMoveSlot(&gPlayerParty[3 + i], gFacilityTrainerMons[monPoolId].moves[j], j);
|
||||
if (gFacilityTrainerMons[monPoolId].moves[j] == MOVE_FRUSTRATION)
|
||||
SetMonMoveSlot(&gPlayerParty[3 + i], gFacilityTrainerMons[monSetId].moves[j], j);
|
||||
if (gFacilityTrainerMons[monSetId].moves[j] == MOVE_FRUSTRATION)
|
||||
friendship = 0;
|
||||
}
|
||||
SetMonData(&gPlayerParty[3 + i], MON_DATA_FRIENDSHIP, &friendship);
|
||||
SetMonData(&gPlayerParty[3 + i], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monPoolId].itemTableId]);
|
||||
SetMonData(&gPlayerParty[3 + i], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId]);
|
||||
for (j = 0; j < PLAYER_NAME_LENGTH + 1; j++)
|
||||
trainerName[j] = gFacilityTrainers[trainerId].trainerName[j];
|
||||
SetMonData(&gPlayerParty[3 + i], MON_DATA_OT_NAME, &trainerName);
|
||||
@@ -2689,19 +2686,19 @@ static void FillTentTrainerParty_(u16 trainerId, u8 firstMonId, u8 monCount)
|
||||
u8 level = SetTentPtrsGetLevel();
|
||||
u8 fixedIV = 0;
|
||||
u8 bfMonCount;
|
||||
const u16 *bfMonPool = NULL;
|
||||
const u16 *monSets = NULL;
|
||||
u32 otID = 0;
|
||||
u16 monPoolId;
|
||||
u16 monSetId;
|
||||
|
||||
bfMonPool = gFacilityTrainers[gTrainerBattleOpponent_A].bfMonPool;
|
||||
monSets = gFacilityTrainers[gTrainerBattleOpponent_A].monSets;
|
||||
|
||||
bfMonCount = 0;
|
||||
monPoolId = bfMonPool[bfMonCount];
|
||||
while (monPoolId != 0xFFFF)
|
||||
monSetId = monSets[bfMonCount];
|
||||
while (monSetId != 0xFFFF)
|
||||
{
|
||||
bfMonCount++;
|
||||
monPoolId = bfMonPool[bfMonCount];
|
||||
if (monPoolId == 0xFFFF)
|
||||
monSetId = monSets[bfMonCount];
|
||||
if (monSetId == 0xFFFF)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2709,12 +2706,12 @@ static void FillTentTrainerParty_(u16 trainerId, u8 firstMonId, u8 monCount)
|
||||
otID = Random32();
|
||||
while (i != monCount)
|
||||
{
|
||||
u16 monPoolId = bfMonPool[Random() % bfMonCount];
|
||||
u16 monSetId = monSets[Random() % bfMonCount];
|
||||
|
||||
// Ensure this pokemon species isn't a duplicate.
|
||||
for (j = 0; j < i + firstMonId; j++)
|
||||
{
|
||||
if (GetMonData(&gEnemyParty[j], MON_DATA_SPECIES, NULL) == gFacilityTrainerMons[monPoolId].species)
|
||||
if (GetMonData(&gEnemyParty[j], MON_DATA_SPECIES, NULL) == gFacilityTrainerMons[monSetId].species)
|
||||
break;
|
||||
}
|
||||
if (j != i + firstMonId)
|
||||
@@ -2724,7 +2721,7 @@ static void FillTentTrainerParty_(u16 trainerId, u8 firstMonId, u8 monCount)
|
||||
for (j = 0; j < i + firstMonId; j++)
|
||||
{
|
||||
if (GetMonData(&gEnemyParty[j], MON_DATA_HELD_ITEM, NULL) != 0
|
||||
&& GetMonData(&gEnemyParty[j], MON_DATA_HELD_ITEM, NULL) == gBattleFrontierHeldItems[gFacilityTrainerMons[monPoolId].itemTableId])
|
||||
&& GetMonData(&gEnemyParty[j], MON_DATA_HELD_ITEM, NULL) == gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId])
|
||||
break;
|
||||
}
|
||||
if (j != i + firstMonId)
|
||||
@@ -2734,34 +2731,34 @@ static void FillTentTrainerParty_(u16 trainerId, u8 firstMonId, u8 monCount)
|
||||
// because the species and held items were already checked directly above.
|
||||
for (j = 0; j < i; j++)
|
||||
{
|
||||
if (chosenMonIndices[j] == monPoolId)
|
||||
if (chosenMonIndices[j] == monSetId)
|
||||
break;
|
||||
}
|
||||
if (j != i)
|
||||
continue;
|
||||
|
||||
chosenMonIndices[i] = monPoolId;
|
||||
chosenMonIndices[i] = monSetId;
|
||||
|
||||
// Place the chosen pokemon into the trainer's party.
|
||||
CreateMonWithEVSpreadPersonalityOTID(&gEnemyParty[i + firstMonId],
|
||||
gFacilityTrainerMons[monPoolId].species,
|
||||
CreateMonWithEVSpreadNatureOTID(&gEnemyParty[i + firstMonId],
|
||||
gFacilityTrainerMons[monSetId].species,
|
||||
level,
|
||||
gFacilityTrainerMons[monPoolId].nature,
|
||||
gFacilityTrainerMons[monSetId].nature,
|
||||
fixedIV,
|
||||
gFacilityTrainerMons[monPoolId].evSpread,
|
||||
gFacilityTrainerMons[monSetId].evSpread,
|
||||
otID);
|
||||
|
||||
friendship = 255;
|
||||
// Give the chosen pokemon its specified moves.
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
SetMonMoveSlot(&gEnemyParty[i + firstMonId], gFacilityTrainerMons[monPoolId].moves[j], j);
|
||||
if (gFacilityTrainerMons[monPoolId].moves[j] == MOVE_FRUSTRATION)
|
||||
SetMonMoveSlot(&gEnemyParty[i + firstMonId], gFacilityTrainerMons[monSetId].moves[j], j);
|
||||
if (gFacilityTrainerMons[monSetId].moves[j] == MOVE_FRUSTRATION)
|
||||
friendship = 0; // Frustration is more powerful the lower the pokemon's friendship is.
|
||||
}
|
||||
|
||||
SetMonData(&gEnemyParty[i + firstMonId], MON_DATA_FRIENDSHIP, &friendship);
|
||||
SetMonData(&gEnemyParty[i + firstMonId], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monPoolId].itemTableId]);
|
||||
SetMonData(&gEnemyParty[i + firstMonId], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId]);
|
||||
|
||||
// The pokemon was successfully added to the trainer's party, so it's safe to move on to
|
||||
// the next party slot.
|
||||
|
||||
@@ -336,7 +336,8 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][3] =
|
||||
},
|
||||
[FRONTIER_FACILITY_FACTORY] =
|
||||
{
|
||||
// Silver Symbol.
|
||||
// Because Factory's pokemon are random, this facility's Brain also uses random pokemon.
|
||||
// What is interesting, this team is actually the one Steven uses in the multi tag battle alongside the player.
|
||||
{
|
||||
{
|
||||
.species = SPECIES_METANG,
|
||||
@@ -363,7 +364,6 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][3] =
|
||||
.moves = {MOVE_THUNDERBOLT, MOVE_PROTECT, MOVE_SOLAR_BEAM, MOVE_DRAGON_CLAW},
|
||||
},
|
||||
},
|
||||
// Gold Symbol.
|
||||
{
|
||||
{
|
||||
.species = SPECIES_METANG,
|
||||
|
||||
@@ -2904,7 +2904,7 @@ void CreateApprenticeMon(struct Pokemon *mon, const struct Apprentice *src, u8 m
|
||||
CalculateMonStats(mon);
|
||||
}
|
||||
|
||||
void CreateMonWithEVSpreadPersonalityOTID(struct Pokemon *mon, u16 species, u8 level, u8 nature, u8 fixedIV, u8 evSpread, u32 otId)
|
||||
void CreateMonWithEVSpreadNatureOTID(struct Pokemon *mon, u16 species, u8 level, u8 nature, u8 fixedIV, u8 evSpread, u32 otId)
|
||||
{
|
||||
s32 i;
|
||||
s32 statCount = 0;
|
||||
|
||||
Reference in New Issue
Block a user