mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-27 22:03:53 +01:00
Clean up some frontier mon use in battle factory
This commit is contained in:
parent
617e411aca
commit
1c75396276
@ -39,7 +39,7 @@ static void GenerateInitialRentalMons(void);
|
|||||||
static void GetOpponentMostCommonMonType(void);
|
static void GetOpponentMostCommonMonType(void);
|
||||||
static void GetOpponentBattleStyle(void);
|
static void GetOpponentBattleStyle(void);
|
||||||
static void RestorePlayerPartyHeldItems(void);
|
static void RestorePlayerPartyHeldItems(void);
|
||||||
static u16 GetMonSetId(u8 lvlMode, u8 challengeNum, bool8 arg2);
|
static u16 GetFactoryMonId(u8 lvlMode, u8 challengeNum, bool8 arg2);
|
||||||
static u8 GetMoveBattleStyle(u16 move);
|
static u8 GetMoveBattleStyle(u16 move);
|
||||||
|
|
||||||
// Const rom data.
|
// Const rom data.
|
||||||
@ -159,24 +159,27 @@ static const u8 sFixedIVTable[][2] =
|
|||||||
{31, 31},
|
{31, 31},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const u16 sMonsToChooseFrom[][2] =
|
static const u16 sInitialRentalMonRanges[][2] =
|
||||||
{
|
{
|
||||||
{0x006e, 0x00c7},
|
// Level 50
|
||||||
{0x00a2, 0x010a},
|
{FRONTIER_MON_GRIMER, FRONTIER_MON_FURRET_1}, // 110 - 199
|
||||||
{0x010b, 0x0173},
|
{FRONTIER_MON_DELCATTY_1, FRONTIER_MON_CLOYSTER_1}, // 162 - 266
|
||||||
{0x0174, 0x01d3},
|
{FRONTIER_MON_DELCATTY_2, FRONTIER_MON_CLOYSTER_2}, // 267 - 371
|
||||||
{0x01d4, 0x0233},
|
{FRONTIER_MON_DUGTRIO_1, FRONTIER_MON_SLAKING_1}, // 372 - 467
|
||||||
{0x0234, 0x0293},
|
{FRONTIER_MON_DUGTRIO_2, FRONTIER_MON_SLAKING_2}, // 468 - 563
|
||||||
{0x0294, 0x02f3},
|
{FRONTIER_MON_DUGTRIO_3, FRONTIER_MON_SLAKING_3}, // 564 - 659
|
||||||
{0x0174, 0x0351},
|
{FRONTIER_MON_DUGTRIO_4, FRONTIER_MON_SLAKING_4}, // 660 - 755
|
||||||
{0x0174, 0x01d3},
|
{FRONTIER_MON_DUGTRIO_1, FRONTIER_MONS_HIGH_TIER}, // 372 - 849
|
||||||
{0x01d4, 0x0233},
|
|
||||||
{0x0234, 0x0293},
|
// Open level
|
||||||
{0x0294, 0x02f3},
|
{FRONTIER_MON_DUGTRIO_1, FRONTIER_MON_SLAKING_1}, // 372 - 467
|
||||||
{0x0174, 0x0371},
|
{FRONTIER_MON_DUGTRIO_2, FRONTIER_MON_SLAKING_2}, // 468 - 563
|
||||||
{0x0174, 0x0371},
|
{FRONTIER_MON_DUGTRIO_3, FRONTIER_MON_SLAKING_3}, // 564 - 659
|
||||||
{0x0174, 0x0371},
|
{FRONTIER_MON_DUGTRIO_4, FRONTIER_MON_SLAKING_4}, // 660 - 755
|
||||||
{0x0174, 0x0371},
|
{FRONTIER_MON_DUGTRIO_1, NUM_FRONTIER_MONS - 1}, // 372 - 881
|
||||||
|
{FRONTIER_MON_DUGTRIO_1, NUM_FRONTIER_MONS - 1}, // 372 - 881
|
||||||
|
{FRONTIER_MON_DUGTRIO_1, NUM_FRONTIER_MONS - 1}, // 372 - 881
|
||||||
|
{FRONTIER_MON_DUGTRIO_1, NUM_FRONTIER_MONS - 1}, // 372 - 881
|
||||||
};
|
};
|
||||||
|
|
||||||
// code
|
// code
|
||||||
@ -320,24 +323,24 @@ static void GenerateOpponentMons(void)
|
|||||||
i = 0;
|
i = 0;
|
||||||
while (i != FRONTIER_PARTY_SIZE)
|
while (i != FRONTIER_PARTY_SIZE)
|
||||||
{
|
{
|
||||||
u16 monSetId = GetMonSetId(lvlMode, challengeNum, FALSE);
|
u16 monId = GetFactoryMonId(lvlMode, challengeNum, FALSE);
|
||||||
if (gFacilityTrainerMons[monSetId].species == SPECIES_UNOWN)
|
if (gFacilityTrainerMons[monId].species == SPECIES_UNOWN)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (j = 0; j < 6; j++)
|
for (j = 0; j < 6; j++)
|
||||||
{
|
{
|
||||||
if (gFacilityTrainerMons[monSetId].species == gFacilityTrainerMons[gSaveBlock2Ptr->frontier.rentalMons[j].monId].species)
|
if (gFacilityTrainerMons[monId].species == gFacilityTrainerMons[gSaveBlock2Ptr->frontier.rentalMons[j].monId].species)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (j != 6)
|
if (j != 6)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (lvlMode == FRONTIER_LVL_50 && monSetId > FRONTIER_MONS_HIGH_TIER)
|
if (lvlMode == FRONTIER_LVL_50 && monId > FRONTIER_MONS_HIGH_TIER)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (k = firstMonId; k < firstMonId + i; k++)
|
for (k = firstMonId; k < firstMonId + i; k++)
|
||||||
{
|
{
|
||||||
if (species[k] == gFacilityTrainerMons[monSetId].species)
|
if (species[k] == gFacilityTrainerMons[monId].species)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (k != firstMonId + i)
|
if (k != firstMonId + i)
|
||||||
@ -345,15 +348,15 @@ static void GenerateOpponentMons(void)
|
|||||||
|
|
||||||
for (k = firstMonId; k < firstMonId + i; k++)
|
for (k = firstMonId; k < firstMonId + i; k++)
|
||||||
{
|
{
|
||||||
if (heldItems[k] != 0 && heldItems[k] == gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId])
|
if (heldItems[k] != 0 && heldItems[k] == gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (k != firstMonId + i)
|
if (k != firstMonId + i)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
species[i] = gFacilityTrainerMons[monSetId].species;
|
species[i] = gFacilityTrainerMons[monId].species;
|
||||||
heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId];
|
heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId];
|
||||||
gUnknown_03006298[i] = monSetId;
|
gUnknown_03006298[i] = monId;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -388,7 +391,7 @@ static void SetPlayerAndOpponentParties(void)
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
u8 bits = 0;
|
u8 bits = 0;
|
||||||
u8 monLevel;
|
u8 monLevel;
|
||||||
u16 monSetId;
|
u16 monId;
|
||||||
u16 evs;
|
u16 evs;
|
||||||
u8 ivs;
|
u8 ivs;
|
||||||
u8 friendship;
|
u8 friendship;
|
||||||
@ -412,17 +415,17 @@ static void SetPlayerAndOpponentParties(void)
|
|||||||
ZeroPlayerPartyMons();
|
ZeroPlayerPartyMons();
|
||||||
for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
|
for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
|
||||||
{
|
{
|
||||||
monSetId = gSaveBlock2Ptr->frontier.rentalMons[i].monId;
|
monId = gSaveBlock2Ptr->frontier.rentalMons[i].monId;
|
||||||
ivs = gSaveBlock2Ptr->frontier.rentalMons[i].ivs;
|
ivs = gSaveBlock2Ptr->frontier.rentalMons[i].ivs;
|
||||||
CreateMon(&gPlayerParty[i],
|
CreateMon(&gPlayerParty[i],
|
||||||
gFacilityTrainerMons[monSetId].species,
|
gFacilityTrainerMons[monId].species,
|
||||||
monLevel,
|
monLevel,
|
||||||
ivs,
|
ivs,
|
||||||
TRUE, gSaveBlock2Ptr->frontier.rentalMons[i].personality,
|
TRUE, gSaveBlock2Ptr->frontier.rentalMons[i].personality,
|
||||||
OT_ID_PLAYER_ID, 0);
|
OT_ID_PLAYER_ID, 0);
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
bits = gFacilityTrainerMons[monSetId].evSpread;
|
bits = gFacilityTrainerMons[monId].evSpread;
|
||||||
for (j = 0; j < NUM_STATS; bits >>= 1, j++)
|
for (j = 0; j < NUM_STATS; bits >>= 1, j++)
|
||||||
{
|
{
|
||||||
if (bits & 1)
|
if (bits & 1)
|
||||||
@ -433,16 +436,16 @@ static void SetPlayerAndOpponentParties(void)
|
|||||||
bits = 1;
|
bits = 1;
|
||||||
for (j = 0; j < NUM_STATS; bits <<= 1, j++)
|
for (j = 0; j < NUM_STATS; bits <<= 1, j++)
|
||||||
{
|
{
|
||||||
if (gFacilityTrainerMons[monSetId].evSpread & bits)
|
if (gFacilityTrainerMons[monId].evSpread & bits)
|
||||||
SetMonData(&gPlayerParty[i], MON_DATA_HP_EV + j, &evs);
|
SetMonData(&gPlayerParty[i], MON_DATA_HP_EV + j, &evs);
|
||||||
}
|
}
|
||||||
|
|
||||||
CalculateMonStats(&gPlayerParty[i]);
|
CalculateMonStats(&gPlayerParty[i]);
|
||||||
friendship = 0;
|
friendship = 0;
|
||||||
for (k = 0; k < MAX_MON_MOVES; k++)
|
for (k = 0; k < MAX_MON_MOVES; k++)
|
||||||
SetMonMoveAvoidReturn(&gPlayerParty[i], gFacilityTrainerMons[monSetId].moves[k], k);
|
SetMonMoveAvoidReturn(&gPlayerParty[i], gFacilityTrainerMons[monId].moves[k], k);
|
||||||
SetMonData(&gPlayerParty[i], MON_DATA_FRIENDSHIP, &friendship);
|
SetMonData(&gPlayerParty[i], MON_DATA_FRIENDSHIP, &friendship);
|
||||||
SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId]);
|
SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]);
|
||||||
SetMonData(&gPlayerParty[i], MON_DATA_ABILITY_NUM, &gSaveBlock2Ptr->frontier.rentalMons[i].abilityNum);
|
SetMonData(&gPlayerParty[i], MON_DATA_ABILITY_NUM, &gSaveBlock2Ptr->frontier.rentalMons[i].abilityNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -453,17 +456,17 @@ static void SetPlayerAndOpponentParties(void)
|
|||||||
case 2:
|
case 2:
|
||||||
for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
|
for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
|
||||||
{
|
{
|
||||||
monSetId = gSaveBlock2Ptr->frontier.rentalMons[i + 3].monId;
|
monId = gSaveBlock2Ptr->frontier.rentalMons[i + 3].monId;
|
||||||
ivs = gSaveBlock2Ptr->frontier.rentalMons[i + 3].ivs;
|
ivs = gSaveBlock2Ptr->frontier.rentalMons[i + 3].ivs;
|
||||||
CreateMon(&gEnemyParty[i],
|
CreateMon(&gEnemyParty[i],
|
||||||
gFacilityTrainerMons[monSetId].species,
|
gFacilityTrainerMons[monId].species,
|
||||||
monLevel,
|
monLevel,
|
||||||
ivs,
|
ivs,
|
||||||
TRUE, gSaveBlock2Ptr->frontier.rentalMons[i + 3].personality,
|
TRUE, gSaveBlock2Ptr->frontier.rentalMons[i + 3].personality,
|
||||||
OT_ID_PLAYER_ID, 0);
|
OT_ID_PLAYER_ID, 0);
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
bits = gFacilityTrainerMons[monSetId].evSpread;
|
bits = gFacilityTrainerMons[monId].evSpread;
|
||||||
for (j = 0; j < NUM_STATS; bits >>= 1, j++)
|
for (j = 0; j < NUM_STATS; bits >>= 1, j++)
|
||||||
{
|
{
|
||||||
if (bits & 1)
|
if (bits & 1)
|
||||||
@ -474,14 +477,14 @@ static void SetPlayerAndOpponentParties(void)
|
|||||||
bits = 1;
|
bits = 1;
|
||||||
for (j = 0; j < NUM_STATS; bits <<= 1, j++)
|
for (j = 0; j < NUM_STATS; bits <<= 1, j++)
|
||||||
{
|
{
|
||||||
if (gFacilityTrainerMons[monSetId].evSpread & bits)
|
if (gFacilityTrainerMons[monId].evSpread & bits)
|
||||||
SetMonData(&gEnemyParty[i], MON_DATA_HP_EV + j, &evs);
|
SetMonData(&gEnemyParty[i], MON_DATA_HP_EV + j, &evs);
|
||||||
}
|
}
|
||||||
|
|
||||||
CalculateMonStats(&gEnemyParty[i]);
|
CalculateMonStats(&gEnemyParty[i]);
|
||||||
for (k = 0; k < MAX_MON_MOVES; k++)
|
for (k = 0; k < MAX_MON_MOVES; k++)
|
||||||
SetMonMoveAvoidReturn(&gEnemyParty[i], gFacilityTrainerMons[monSetId].moves[k], k);
|
SetMonMoveAvoidReturn(&gEnemyParty[i], gFacilityTrainerMons[monId].moves[k], k);
|
||||||
SetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId]);
|
SetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]);
|
||||||
SetMonData(&gEnemyParty[i], MON_DATA_ABILITY_NUM, &gSaveBlock2Ptr->frontier.rentalMons[i + 3].abilityNum);
|
SetMonData(&gEnemyParty[i], MON_DATA_ABILITY_NUM, &gSaveBlock2Ptr->frontier.rentalMons[i + 3].abilityNum);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -497,8 +500,8 @@ static void GenerateInitialRentalMons(void)
|
|||||||
u8 challengeNum;
|
u8 challengeNum;
|
||||||
u8 factoryLvlMode;
|
u8 factoryLvlMode;
|
||||||
u8 factoryBattleMode;
|
u8 factoryBattleMode;
|
||||||
u8 var_40;
|
u8 rentalRank;
|
||||||
u16 monSetId;
|
u16 monId;
|
||||||
u16 currSpecies;
|
u16 currSpecies;
|
||||||
u16 species[PARTY_SIZE];
|
u16 species[PARTY_SIZE];
|
||||||
u16 monIds[PARTY_SIZE];
|
u16 monIds[PARTY_SIZE];
|
||||||
@ -530,30 +533,30 @@ static void GenerateInitialRentalMons(void)
|
|||||||
factoryLvlMode = FRONTIER_LVL_50;
|
factoryLvlMode = FRONTIER_LVL_50;
|
||||||
firstMonId = 0;
|
firstMonId = 0;
|
||||||
}
|
}
|
||||||
var_40 = GetNumPastRentalsRank(factoryBattleMode, factoryLvlMode);
|
rentalRank = GetNumPastRentalsRank(factoryBattleMode, factoryLvlMode);
|
||||||
|
|
||||||
currSpecies = SPECIES_NONE;
|
currSpecies = SPECIES_NONE;
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i != PARTY_SIZE)
|
while (i != PARTY_SIZE)
|
||||||
{
|
{
|
||||||
if (i < var_40)
|
if (i < rentalRank) // The more times the player has rented, the more initial rentals are generated from a better set of pokemon
|
||||||
monSetId = GetMonSetId(factoryLvlMode, challengeNum, TRUE);
|
monId = GetFactoryMonId(factoryLvlMode, challengeNum, TRUE);
|
||||||
else
|
else
|
||||||
monSetId = GetMonSetId(factoryLvlMode, challengeNum, FALSE);
|
monId = GetFactoryMonId(factoryLvlMode, challengeNum, FALSE);
|
||||||
|
|
||||||
if (gFacilityTrainerMons[monSetId].species == SPECIES_UNOWN)
|
if (gFacilityTrainerMons[monId].species == SPECIES_UNOWN)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Cannot have two pokemon of the same species.
|
// Cannot have two pokemon of the same species.
|
||||||
for (j = firstMonId; j < firstMonId + i; j++)
|
for (j = firstMonId; j < firstMonId + i; j++)
|
||||||
{
|
{
|
||||||
u16 monId = monIds[j];
|
u16 existingMonId = monIds[j];
|
||||||
if (monId == monSetId)
|
if (existingMonId == monId)
|
||||||
break;
|
break;
|
||||||
if (species[j] == gFacilityTrainerMons[monSetId].species)
|
if (species[j] == gFacilityTrainerMons[monId].species)
|
||||||
{
|
{
|
||||||
if (currSpecies == SPECIES_NONE)
|
if (currSpecies == SPECIES_NONE)
|
||||||
currSpecies = gFacilityTrainerMons[monSetId].species;
|
currSpecies = gFacilityTrainerMons[monId].species;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -564,9 +567,9 @@ static void GenerateInitialRentalMons(void)
|
|||||||
// Cannot have two same held items.
|
// Cannot have two same held items.
|
||||||
for (j = firstMonId; j < firstMonId + i; j++)
|
for (j = firstMonId; j < firstMonId + i; j++)
|
||||||
{
|
{
|
||||||
if (heldItems[j] != 0 && heldItems[j] == gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId])
|
if (heldItems[j] != 0 && heldItems[j] == gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId])
|
||||||
{
|
{
|
||||||
if (gFacilityTrainerMons[monSetId].species == currSpecies)
|
if (gFacilityTrainerMons[monId].species == currSpecies)
|
||||||
currSpecies = SPECIES_NONE;
|
currSpecies = SPECIES_NONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -574,10 +577,10 @@ static void GenerateInitialRentalMons(void)
|
|||||||
if (j != firstMonId + i)
|
if (j != firstMonId + i)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
gSaveBlock2Ptr->frontier.rentalMons[i].monId = monSetId;
|
gSaveBlock2Ptr->frontier.rentalMons[i].monId = monId;
|
||||||
species[i] = gFacilityTrainerMons[monSetId].species;
|
species[i] = gFacilityTrainerMons[monId].species;
|
||||||
heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId];
|
heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId];
|
||||||
monIds[i] = monSetId;
|
monIds[i] = monId;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -629,10 +632,10 @@ static void GetOpponentBattleStyle(void)
|
|||||||
|
|
||||||
for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
|
for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
|
||||||
{
|
{
|
||||||
u16 monSetId = gUnknown_03006298[i];
|
u16 monId = gUnknown_03006298[i];
|
||||||
for (j = 0; j < MAX_MON_MOVES; j++)
|
for (j = 0; j < MAX_MON_MOVES; j++)
|
||||||
{
|
{
|
||||||
u8 battleStyle = GetMoveBattleStyle(gFacilityTrainerMons[monSetId].moves[j]);
|
u8 battleStyle = GetMoveBattleStyle(gFacilityTrainerMons[monId].moves[j]);
|
||||||
stylePoints[battleStyle]++;
|
stylePoints[battleStyle]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -724,16 +727,16 @@ void FillFactoryBrainParty(void)
|
|||||||
|
|
||||||
while (i != FRONTIER_PARTY_SIZE)
|
while (i != FRONTIER_PARTY_SIZE)
|
||||||
{
|
{
|
||||||
u16 monSetId = GetMonSetId(lvlMode, challengeNum, FALSE);
|
u16 monId = GetFactoryMonId(lvlMode, challengeNum, FALSE);
|
||||||
|
|
||||||
if (gFacilityTrainerMons[monSetId].species == SPECIES_UNOWN)
|
if (gFacilityTrainerMons[monId].species == SPECIES_UNOWN)
|
||||||
continue;
|
continue;
|
||||||
if (monLevel == 50 && monSetId > FRONTIER_MONS_HIGH_TIER)
|
if (monLevel == 50 && monId > FRONTIER_MONS_HIGH_TIER)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (j = 0; j < 6; j++)
|
for (j = 0; j < 6; j++)
|
||||||
{
|
{
|
||||||
if (monSetId == gSaveBlock2Ptr->frontier.rentalMons[j].monId)
|
if (monId == gSaveBlock2Ptr->frontier.rentalMons[j].monId)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (j != 6)
|
if (j != 6)
|
||||||
@ -741,7 +744,7 @@ void FillFactoryBrainParty(void)
|
|||||||
|
|
||||||
for (k = 0; k < i; k++)
|
for (k = 0; k < i; k++)
|
||||||
{
|
{
|
||||||
if (species[k] == gFacilityTrainerMons[monSetId].species)
|
if (species[k] == gFacilityTrainerMons[monId].species)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (k != i)
|
if (k != i)
|
||||||
@ -749,35 +752,35 @@ void FillFactoryBrainParty(void)
|
|||||||
|
|
||||||
for (k = 0; k < i; k++)
|
for (k = 0; k < i; k++)
|
||||||
{
|
{
|
||||||
if (heldItems[k] != 0 && heldItems[k] == gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId])
|
if (heldItems[k] != 0 && heldItems[k] == gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (k != i)
|
if (k != i)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
species[i] = gFacilityTrainerMons[monSetId].species;
|
species[i] = gFacilityTrainerMons[monId].species;
|
||||||
heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId];
|
heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId];
|
||||||
CreateMonWithEVSpreadNatureOTID(&gEnemyParty[i],
|
CreateMonWithEVSpreadNatureOTID(&gEnemyParty[i],
|
||||||
gFacilityTrainerMons[monSetId].species,
|
gFacilityTrainerMons[monId].species,
|
||||||
monLevel,
|
monLevel,
|
||||||
gFacilityTrainerMons[monSetId].nature,
|
gFacilityTrainerMons[monId].nature,
|
||||||
fixedIV,
|
fixedIV,
|
||||||
gFacilityTrainerMons[monSetId].evSpread,
|
gFacilityTrainerMons[monId].evSpread,
|
||||||
otId);
|
otId);
|
||||||
|
|
||||||
friendship = 0;
|
friendship = 0;
|
||||||
for (k = 0; k < MAX_MON_MOVES; k++)
|
for (k = 0; k < MAX_MON_MOVES; k++)
|
||||||
SetMonMoveAvoidReturn(&gEnemyParty[i], gFacilityTrainerMons[monSetId].moves[k], k);
|
SetMonMoveAvoidReturn(&gEnemyParty[i], gFacilityTrainerMons[monId].moves[k], k);
|
||||||
SetMonData(&gEnemyParty[i], MON_DATA_FRIENDSHIP, &friendship);
|
SetMonData(&gEnemyParty[i], MON_DATA_FRIENDSHIP, &friendship);
|
||||||
SetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId]);
|
SetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static u16 GetMonSetId(u8 lvlMode, u8 challengeNum, bool8 arg2)
|
static u16 GetFactoryMonId(u8 lvlMode, u8 challengeNum, bool8 useBetterRange)
|
||||||
{
|
{
|
||||||
u16 range, monSetId;
|
u16 numMons, monId;
|
||||||
u16 adder;
|
u16 adder; // Used to skip past early mons for open level
|
||||||
|
|
||||||
if (lvlMode == FRONTIER_LVL_50)
|
if (lvlMode == FRONTIER_LVL_50)
|
||||||
adder = 0;
|
adder = 0;
|
||||||
@ -786,30 +789,31 @@ static u16 GetMonSetId(u8 lvlMode, u8 challengeNum, bool8 arg2)
|
|||||||
|
|
||||||
if (challengeNum < 7)
|
if (challengeNum < 7)
|
||||||
{
|
{
|
||||||
if (arg2)
|
if (useBetterRange)
|
||||||
{
|
{
|
||||||
range = (sMonsToChooseFrom[adder + challengeNum + 1][1] - sMonsToChooseFrom[adder + challengeNum + 1][0]) + 1;
|
numMons = (sInitialRentalMonRanges[adder + challengeNum + 1][1] - sInitialRentalMonRanges[adder + challengeNum + 1][0]) + 1;
|
||||||
monSetId = Random() % range;
|
monId = Random() % numMons;
|
||||||
monSetId += sMonsToChooseFrom[adder + challengeNum + 1][0];
|
monId += sInitialRentalMonRanges[adder + challengeNum + 1][0];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
range = (sMonsToChooseFrom[adder + challengeNum][1] - sMonsToChooseFrom[adder + challengeNum][0]) + 1;
|
numMons = (sInitialRentalMonRanges[adder + challengeNum][1] - sInitialRentalMonRanges[adder + challengeNum][0]) + 1;
|
||||||
monSetId = Random() % range;
|
monId = Random() % numMons;
|
||||||
monSetId += sMonsToChooseFrom[adder + challengeNum][0];
|
monId += sInitialRentalMonRanges[adder + challengeNum][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
u16 num = challengeNum;
|
u16 challenge = challengeNum;
|
||||||
if (num != 7)
|
if (challenge != 7)
|
||||||
num = 7;
|
challenge = 7; // why bother assigning it above at all
|
||||||
range = (sMonsToChooseFrom[adder + num][1] - sMonsToChooseFrom[adder + num][0]) + 1;
|
|
||||||
monSetId = Random() % range;
|
numMons = (sInitialRentalMonRanges[adder + challenge][1] - sInitialRentalMonRanges[adder + challenge][0]) + 1;
|
||||||
monSetId += sMonsToChooseFrom[adder + num][0];
|
monId = Random() % numMons;
|
||||||
|
monId += sInitialRentalMonRanges[adder + challenge][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
return monSetId;
|
return monId;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 GetNumPastRentalsRank(u8 battleMode, u8 lvlMode)
|
u8 GetNumPastRentalsRank(u8 battleMode, u8 lvlMode)
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
struct FactorySelecteableMon
|
struct FactorySelecteableMon
|
||||||
{
|
{
|
||||||
u16 monSetId;
|
u16 monId;
|
||||||
u16 spriteId;
|
u16 spriteId;
|
||||||
u8 selectedId; // 0 - not selected, 1 - first pokemon, 2 - second pokemon, 3 - third pokemon
|
u8 selectedId; // 0 - not selected, 1 - first pokemon, 2 - second pokemon, 3 - third pokemon
|
||||||
struct Pokemon monData;
|
struct Pokemon monData;
|
||||||
@ -168,7 +168,7 @@ static u8 sub_819BC9C(void);
|
|||||||
static u8 Select_OptionSummary(void);
|
static u8 Select_OptionSummary(void);
|
||||||
static u8 Select_OptionOthers(void);
|
static u8 Select_OptionOthers(void);
|
||||||
static u8 Select_OptionRentDeselect(void);
|
static u8 Select_OptionRentDeselect(void);
|
||||||
static bool32 Select_AreSpeciesValid(u16 monSetId);
|
static bool32 Select_AreSpeciesValid(u16 monId);
|
||||||
static void Swap_DestroyAllSprites(void);
|
static void Swap_DestroyAllSprites(void);
|
||||||
static void Swap_ShowYesNoOptions(void);
|
static void Swap_ShowYesNoOptions(void);
|
||||||
static void sub_819E8EC(void);
|
static void sub_819E8EC(void);
|
||||||
@ -1665,7 +1665,7 @@ static void CreateFrontierFactorySelectableMons(u8 firstMonId)
|
|||||||
u8 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
|
u8 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
|
||||||
u8 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
|
u8 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
|
||||||
u8 challengeNum = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode] / 7;
|
u8 challengeNum = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode] / 7;
|
||||||
u8 var_28 = 0;
|
u8 rentalRank = 0;
|
||||||
|
|
||||||
gFacilityTrainerMons = gBattleFrontierMons;
|
gFacilityTrainerMons = gBattleFrontierMons;
|
||||||
if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_50)
|
if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_50)
|
||||||
@ -1673,29 +1673,29 @@ static void CreateFrontierFactorySelectableMons(u8 firstMonId)
|
|||||||
else
|
else
|
||||||
level = 50;
|
level = 50;
|
||||||
|
|
||||||
var_28 = GetNumPastRentalsRank(battleMode, lvlMode);
|
rentalRank = GetNumPastRentalsRank(battleMode, lvlMode);
|
||||||
otId = T1_READ_32(gSaveBlock2Ptr->playerTrainerId);
|
otId = T1_READ_32(gSaveBlock2Ptr->playerTrainerId);
|
||||||
|
|
||||||
for (i = 0; i < SELECTABLE_MONS_COUNT; i++)
|
for (i = 0; i < SELECTABLE_MONS_COUNT; i++)
|
||||||
{
|
{
|
||||||
u16 monSetId = gSaveBlock2Ptr->frontier.rentalMons[i].monId;
|
u16 monId = gSaveBlock2Ptr->frontier.rentalMons[i].monId;
|
||||||
sFactorySelectScreen->mons[i + firstMonId].monSetId = monSetId;
|
sFactorySelectScreen->mons[i + firstMonId].monId = monId;
|
||||||
if (i < var_28)
|
if (i < rentalRank)
|
||||||
ivs = GetFactoryMonFixedIV(challengeNum + 1, 0);
|
ivs = GetFactoryMonFixedIV(challengeNum + 1, 0);
|
||||||
else
|
else
|
||||||
ivs = GetFactoryMonFixedIV(challengeNum, 0);
|
ivs = GetFactoryMonFixedIV(challengeNum, 0);
|
||||||
CreateMonWithEVSpreadNatureOTID(&sFactorySelectScreen->mons[i + firstMonId].monData,
|
CreateMonWithEVSpreadNatureOTID(&sFactorySelectScreen->mons[i + firstMonId].monData,
|
||||||
gFacilityTrainerMons[monSetId].species,
|
gFacilityTrainerMons[monId].species,
|
||||||
level,
|
level,
|
||||||
gFacilityTrainerMons[monSetId].nature,
|
gFacilityTrainerMons[monId].nature,
|
||||||
ivs,
|
ivs,
|
||||||
gFacilityTrainerMons[monSetId].evSpread,
|
gFacilityTrainerMons[monId].evSpread,
|
||||||
otId);
|
otId);
|
||||||
happiness = 0;
|
happiness = 0;
|
||||||
for (j = 0; j < MAX_MON_MOVES; j++)
|
for (j = 0; j < MAX_MON_MOVES; j++)
|
||||||
SetMonMoveAvoidReturn(&sFactorySelectScreen->mons[i + firstMonId].monData, gFacilityTrainerMons[monSetId].moves[j], j);
|
SetMonMoveAvoidReturn(&sFactorySelectScreen->mons[i + firstMonId].monData, gFacilityTrainerMons[monId].moves[j], j);
|
||||||
SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_FRIENDSHIP, &happiness);
|
SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_FRIENDSHIP, &happiness);
|
||||||
SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId]);
|
SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1712,20 +1712,20 @@ static void CreateTentFactorySelectableMons(u8 firstMonId)
|
|||||||
|
|
||||||
for (i = 0; i < SELECTABLE_MONS_COUNT; i++)
|
for (i = 0; i < SELECTABLE_MONS_COUNT; i++)
|
||||||
{
|
{
|
||||||
u16 monSetId = gSaveBlock2Ptr->frontier.rentalMons[i].monId;
|
u16 monId = gSaveBlock2Ptr->frontier.rentalMons[i].monId;
|
||||||
sFactorySelectScreen->mons[i + firstMonId].monSetId = monSetId;
|
sFactorySelectScreen->mons[i + firstMonId].monId = monId;
|
||||||
CreateMonWithEVSpreadNatureOTID(&sFactorySelectScreen->mons[i + firstMonId].monData,
|
CreateMonWithEVSpreadNatureOTID(&sFactorySelectScreen->mons[i + firstMonId].monData,
|
||||||
gFacilityTrainerMons[monSetId].species,
|
gFacilityTrainerMons[monId].species,
|
||||||
level,
|
level,
|
||||||
gFacilityTrainerMons[monSetId].nature,
|
gFacilityTrainerMons[monId].nature,
|
||||||
ivs,
|
ivs,
|
||||||
gFacilityTrainerMons[monSetId].evSpread,
|
gFacilityTrainerMons[monId].evSpread,
|
||||||
otId);
|
otId);
|
||||||
happiness = 0;
|
happiness = 0;
|
||||||
for (j = 0; j < MAX_MON_MOVES; j++)
|
for (j = 0; j < MAX_MON_MOVES; j++)
|
||||||
SetMonMoveAvoidReturn(&sFactorySelectScreen->mons[i + firstMonId].monData, gFacilityTrainerMons[monSetId].moves[j], j);
|
SetMonMoveAvoidReturn(&sFactorySelectScreen->mons[i + firstMonId].monData, gFacilityTrainerMons[monId].moves[j], j);
|
||||||
SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_FRIENDSHIP, &happiness);
|
SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_FRIENDSHIP, &happiness);
|
||||||
SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monSetId].itemTableId]);
|
SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1740,7 +1740,7 @@ static void Select_CopyMonsToPlayerParty(void)
|
|||||||
if (sFactorySelectScreen->mons[j].selectedId == i + 1)
|
if (sFactorySelectScreen->mons[j].selectedId == i + 1)
|
||||||
{
|
{
|
||||||
gPlayerParty[i] = sFactorySelectScreen->mons[j].monData;
|
gPlayerParty[i] = sFactorySelectScreen->mons[j].monData;
|
||||||
gSaveBlock2Ptr->frontier.rentalMons[i].monId = sFactorySelectScreen->mons[j].monSetId;
|
gSaveBlock2Ptr->frontier.rentalMons[i].monId = sFactorySelectScreen->mons[j].monId;
|
||||||
gSaveBlock2Ptr->frontier.rentalMons[i].personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY, NULL);
|
gSaveBlock2Ptr->frontier.rentalMons[i].personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY, NULL);
|
||||||
gSaveBlock2Ptr->frontier.rentalMons[i].abilityNum = GetBoxMonData(&gPlayerParty[i].box, MON_DATA_ABILITY_NUM, NULL);
|
gSaveBlock2Ptr->frontier.rentalMons[i].abilityNum = GetBoxMonData(&gPlayerParty[i].box, MON_DATA_ABILITY_NUM, NULL);
|
||||||
gSaveBlock2Ptr->frontier.rentalMons[i].ivs = GetBoxMonData(&gPlayerParty[i].box, MON_DATA_ATK_IV, NULL);
|
gSaveBlock2Ptr->frontier.rentalMons[i].ivs = GetBoxMonData(&gPlayerParty[i].box, MON_DATA_ATK_IV, NULL);
|
||||||
@ -1871,8 +1871,8 @@ static u8 Select_RunMenuOptionFunc(void)
|
|||||||
static u8 Select_OptionRentDeselect(void)
|
static u8 Select_OptionRentDeselect(void)
|
||||||
{
|
{
|
||||||
u8 selectedId = sFactorySelectScreen->mons[sFactorySelectScreen->cursorPos].selectedId;
|
u8 selectedId = sFactorySelectScreen->mons[sFactorySelectScreen->cursorPos].selectedId;
|
||||||
u16 monSetId = sFactorySelectScreen->mons[sFactorySelectScreen->cursorPos].monSetId;
|
u16 monId = sFactorySelectScreen->mons[sFactorySelectScreen->cursorPos].monId;
|
||||||
if (selectedId == 0 && !Select_AreSpeciesValid(monSetId))
|
if (selectedId == 0 && !Select_AreSpeciesValid(monId))
|
||||||
{
|
{
|
||||||
Select_PrintCantSelectSameMon();
|
Select_PrintCantSelectSameMon();
|
||||||
sub_819B958(3);
|
sub_819B958(3);
|
||||||
@ -2160,10 +2160,10 @@ static void Select_SetWinRegs(s16 mWin0H, s16 nWin0H, s16 mWin0V, s16 nWin0V)
|
|||||||
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_CLR | WINOUT_WIN01_OBJ);
|
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_CLR | WINOUT_WIN01_OBJ);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool32 Select_AreSpeciesValid(u16 monSetId)
|
static bool32 Select_AreSpeciesValid(u16 monId)
|
||||||
{
|
{
|
||||||
u8 i, j;
|
u8 i, j;
|
||||||
u32 species = gFacilityTrainerMons[monSetId].species;
|
u32 species = gFacilityTrainerMons[monId].species;
|
||||||
u8 selectState = sFactorySelectScreen->selectingMonsState;
|
u8 selectState = sFactorySelectScreen->selectingMonsState;
|
||||||
|
|
||||||
for (i = 1; i < selectState; i++)
|
for (i = 1; i < selectState; i++)
|
||||||
@ -2172,7 +2172,7 @@ static bool32 Select_AreSpeciesValid(u16 monSetId)
|
|||||||
{
|
{
|
||||||
if (sFactorySelectScreen->mons[j].selectedId == i)
|
if (sFactorySelectScreen->mons[j].selectedId == i)
|
||||||
{
|
{
|
||||||
if (gFacilityTrainerMons[sFactorySelectScreen->mons[j].monSetId].species == species)
|
if (gFacilityTrainerMons[sFactorySelectScreen->mons[j].monId].species == species)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user