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