mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
Add bugfix for Battle Factory trainer IVs
This commit is contained in:
parent
5160520639
commit
66cbe29c14
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
void CallBattleFactoryFunction(void);
|
void CallBattleFactoryFunction(void);
|
||||||
bool8 InBattleFactory(void);
|
bool8 InBattleFactory(void);
|
||||||
u8 GetFactoryMonFixedIV(u8 arg0, u8 arg1);
|
u8 GetFactoryMonFixedIV(u8 challengeNum, bool8 isLastBattle);
|
||||||
void FillFactoryBrainParty(void);
|
void FillFactoryBrainParty(void);
|
||||||
u8 GetNumPastRentalsRank(u8 battleMode, u8 lvlMode);
|
u8 GetNumPastRentalsRank(u8 battleMode, u8 lvlMode);
|
||||||
u32 GetAiScriptsInBattleFactory(void);
|
u32 GetAiScriptsInBattleFactory(void);
|
||||||
|
@ -720,17 +720,25 @@ static void RestorePlayerPartyHeldItems(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 GetFactoryMonFixedIV(u8 arg0, u8 arg1)
|
// Get the IV to use for the opponent's pokémon.
|
||||||
|
// The IVs get higher for each subsequent challenge and for
|
||||||
|
// the last trainer in each challenge. Noland is an exception
|
||||||
|
// to this, as he uses the IVs that would be used by the regular
|
||||||
|
// trainers 2 challenges ahead of the current one.
|
||||||
|
// Due to a mistake in FillFactoryFrontierTrainerParty, the
|
||||||
|
// challenge number used to determine the IVs for regular trainers
|
||||||
|
// is Battle Tower's instead of Battle Factory's.
|
||||||
|
u8 GetFactoryMonFixedIV(u8 challengeNum, bool8 isLastBattle)
|
||||||
{
|
{
|
||||||
u8 a1;
|
u8 ivSet;
|
||||||
u8 a2 = (arg1 != 0) ? 1 : 0;
|
bool8 useHigherIV = isLastBattle ? TRUE : FALSE;
|
||||||
|
|
||||||
if (arg0 > 8)
|
if (challengeNum > 8)
|
||||||
a1 = 7;
|
ivSet = 7;
|
||||||
else
|
else
|
||||||
a1 = arg0;
|
ivSet = challengeNum;
|
||||||
|
|
||||||
return sFixedIVTable[a1][a2];
|
return sFixedIVTable[ivSet][useHigherIV];
|
||||||
}
|
}
|
||||||
|
|
||||||
void FillFactoryBrainParty(void)
|
void FillFactoryBrainParty(void)
|
||||||
@ -746,7 +754,7 @@ void FillFactoryBrainParty(void)
|
|||||||
u8 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
|
u8 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
|
||||||
u8 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
|
u8 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
|
||||||
u8 challengeNum = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode] / 7;
|
u8 challengeNum = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode] / 7;
|
||||||
fixedIV = GetFactoryMonFixedIV(challengeNum + 2, 0);
|
fixedIV = GetFactoryMonFixedIV(challengeNum + 2, FALSE);
|
||||||
monLevel = SetFacilityPtrsGetLevel();
|
monLevel = SetFacilityPtrsGetLevel();
|
||||||
i = 0;
|
i = 0;
|
||||||
otId = T1_READ_32(gSaveBlock2Ptr->playerTrainerId);
|
otId = T1_READ_32(gSaveBlock2Ptr->playerTrainerId);
|
||||||
|
@ -1827,13 +1827,18 @@ static void FillFactoryFrontierTrainerParty(u16 trainerId, u8 firstMonId)
|
|||||||
|
|
||||||
if (trainerId < FRONTIER_TRAINERS_COUNT)
|
if (trainerId < FRONTIER_TRAINERS_COUNT)
|
||||||
{
|
{
|
||||||
u8 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; // Unused variable.
|
u8 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
|
||||||
u8 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
|
u8 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
|
||||||
|
// By mistake Battle Tower's Level 50 challenge number is used to determine the IVs for Battle Factory.
|
||||||
|
#ifdef BUGFIX
|
||||||
|
u8 challengeNum = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode] / 7;
|
||||||
|
#else
|
||||||
u8 challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][FRONTIER_LVL_50] / 7;
|
u8 challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][FRONTIER_LVL_50] / 7;
|
||||||
|
#endif
|
||||||
if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < 6)
|
if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < 6)
|
||||||
fixedIV = GetFactoryMonFixedIV(challengeNum, 0);
|
fixedIV = GetFactoryMonFixedIV(challengeNum, FALSE);
|
||||||
else
|
else
|
||||||
fixedIV = GetFactoryMonFixedIV(challengeNum, 1);
|
fixedIV = GetFactoryMonFixedIV(challengeNum, TRUE); // Last trainer in challenge uses higher IVs
|
||||||
}
|
}
|
||||||
else if (trainerId == TRAINER_EREADER)
|
else if (trainerId == TRAINER_EREADER)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user