Skip to content

Commit

Permalink
Use trainer partner names for id
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexOn1ine committed Dec 19, 2023
1 parent a838749 commit fe1bad6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// still has them in the ROM. This is because the developers forgot
// to define NDEBUG before release, however this has been changed as
// Ruby's actual debug build does not use the AGBPrint features.
#define NDEBUG
// #define NDEBUG

// To enable printf debugging, comment out "#define NDEBUG". This allows
// the various AGBPrint functions to be used. (See include/gba/isagbprint.h).
Expand Down
37 changes: 24 additions & 13 deletions src/battle_tower.c
Original file line number Diff line number Diff line change
Expand Up @@ -2947,7 +2947,8 @@ void TryHideBattleTowerReporter(void)

static void FillPartnerParty(u16 trainerId)
{
s32 i, j;
s32 i, j, k;
u32 firstIdPart = 0, secondIdPart = 0, thridIdPart = 0;
u32 ivs, level, personality;
u32 friendship;
u16 monId;
Expand All @@ -2964,17 +2965,30 @@ static void FillPartnerParty(u16 trainerId)
for (i = 0; i < 3 && i < gBattlePartners[trainerId - TRAINER_PARTNER(PARTNER_NONE)].partySize; i++)
{
const struct TrainerMon *partyData = gBattlePartners[trainerId - TRAINER_PARTNER(PARTNER_NONE)].party;
u32 otIdType = OT_ID_RANDOM_NO_SHINY;
const u8 *partnerName = gBattlePartners[trainerId - TRAINER_PARTNER(PARTNER_NONE)].trainerName;

if (trainerId == TRAINER_PARTNER(PARTNER_STEVEN))
for (k = 0; partnerName[k] != EOS && k < 3; k++)
{
otID = STEVEN_OTID;
otIdType = OT_ID_PRESET;
if (k == 0)
{
firstIdPart = partnerName[k];
secondIdPart = partnerName[k];
thridIdPart = partnerName[k];
}
else if (k == 1)
{
secondIdPart = partnerName[k];
thridIdPart = partnerName[k];
}
else if (k == 2)
{
thridIdPart = partnerName[k];
}
}
if (trainerId == TRAINER_PARTNER(PARTNER_STEVEN))
otID = STEVEN_OTID;
else
otID = Random32();

do
otID = ((firstIdPart % 72) * 1000) + ((secondIdPart % 23) * 10) + (thridIdPart % 37) % 65536;
{
personality = Random32();
} while (IsShinyOtIdPersonality(otID, personality));
Expand All @@ -2986,12 +3000,9 @@ static void FillPartnerParty(u16 trainerId)
if (partyData[i].nature != 0)
ModifyPersonalityForNature(&personality, partyData[i].nature - 1);
if (partyData[i].isShiny)
{
otIdType = OT_ID_PRESET;
otID = HIHALF(personality) ^ LOHALF(personality);
}
otID ^= GET_SHINY_VALUE(otID, personality) << 16;

CreateMon(&gPlayerParty[i + 3], partyData[i].species, partyData[i].lvl, 0, TRUE, personality, otIdType, otID);
CreateMon(&gPlayerParty[i + 3], partyData[i].species, partyData[i].lvl, 0, TRUE, personality, OT_ID_PRESET, otID);
SetMonData(&gPlayerParty[i + 3], MON_DATA_HELD_ITEM, &partyData[i].heldItem);
CustomTrainerPartyAssignMoves(&gPlayerParty[i + 3], &partyData[i]);

Expand Down
1 change: 1 addition & 0 deletions src/data/partner_parties.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ static const struct TrainerMon sParty_MayPartner[] = {
.nature = TRAINER_PARTY_NATURE(NATURE_TIMID),
.iv = TRAINER_PARTY_IVS(31, 31, 31, 31, 31, 31),
.moves = {MOVE_ENERGY_BALL},
.isShiny = TRUE,
},
{
.species = SPECIES_TORCHIC,
Expand Down

0 comments on commit fe1bad6

Please sign in to comment.