mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
Convert vanilla trainer data to only use the full custom trainer mon struct (#3114)
This commit is contained in:
commit
5b885a4ddb
@ -72,7 +72,7 @@ bool32 IsWildMonSmart(void);
|
||||
u8 CreateNPCTrainerPartyFromTrainer(struct Pokemon *party, const struct Trainer *trainer, bool32 firstTrainer, u32 battleTypeFlags);
|
||||
void ModifyPersonalityForNature(u32 *personality, u32 newNature);
|
||||
u32 GeneratePersonalityForGender(u32 gender, u32 species);
|
||||
void CustomTrainerPartyAssignMoves(struct Pokemon *mon, const struct TrainerMonCustomized *partyEntry);
|
||||
void CustomTrainerPartyAssignMoves(struct Pokemon *mon, const struct TrainerMon *partyEntry);
|
||||
|
||||
extern struct MultiPartnerMenuPokemon gMultiPartnerParty[MULTI_PARTY_SIZE];
|
||||
|
||||
|
@ -371,13 +371,6 @@
|
||||
|
||||
#define F_TRAINER_FEMALE (1 << 7)
|
||||
|
||||
// All trainer parties specify the IV, level, and species for each Pokémon in the
|
||||
// party. Some trainer parties also specify held items and custom moves for each
|
||||
// Pokémon.
|
||||
#define F_TRAINER_PARTY_CUSTOM_MOVESET (1 << 0)
|
||||
#define F_TRAINER_PARTY_HELD_ITEM (1 << 1)
|
||||
#define F_TRAINER_PARTY_EVERYTHING_CUSTOMIZED (1 << 3)
|
||||
|
||||
// Trainer party defines
|
||||
#define TRAINER_MON_MALE 1
|
||||
#define TRAINER_MON_FEMALE 2
|
||||
|
@ -35,7 +35,7 @@ struct MonCoords
|
||||
#define TRAINER_PARTY_EVS(hp, atk, def, speed, spatk, spdef) ((const u8[6]){hp,atk,def,spatk,spdef,speed})
|
||||
#define TRAINER_PARTY_NATURE(nature) (nature+1)
|
||||
|
||||
struct TrainerMonCustomized
|
||||
struct TrainerMon
|
||||
{
|
||||
const u8 *nickname;
|
||||
const u8 *ev;
|
||||
@ -52,64 +52,19 @@ struct TrainerMonCustomized
|
||||
bool8 isShiny : 1;
|
||||
};
|
||||
|
||||
struct TrainerMonNoItemDefaultMoves
|
||||
{
|
||||
u16 iv;
|
||||
u8 lvl;
|
||||
u16 species;
|
||||
};
|
||||
|
||||
struct TrainerMonItemDefaultMoves
|
||||
{
|
||||
u16 iv;
|
||||
u8 lvl;
|
||||
u16 species;
|
||||
u16 heldItem;
|
||||
};
|
||||
|
||||
struct TrainerMonNoItemCustomMoves
|
||||
{
|
||||
u16 iv;
|
||||
u8 lvl;
|
||||
u16 species;
|
||||
u16 moves[MAX_MON_MOVES];
|
||||
};
|
||||
|
||||
struct TrainerMonItemCustomMoves
|
||||
{
|
||||
u16 iv;
|
||||
u8 lvl;
|
||||
u16 species;
|
||||
u16 heldItem;
|
||||
u16 moves[MAX_MON_MOVES];
|
||||
};
|
||||
|
||||
#define NO_ITEM_DEFAULT_MOVES(party) { .NoItemDefaultMoves = party }, .partySize = ARRAY_COUNT(party), .partyFlags = 0
|
||||
#define NO_ITEM_CUSTOM_MOVES(party) { .NoItemCustomMoves = party }, .partySize = ARRAY_COUNT(party), .partyFlags = F_TRAINER_PARTY_CUSTOM_MOVESET
|
||||
#define ITEM_DEFAULT_MOVES(party) { .ItemDefaultMoves = party }, .partySize = ARRAY_COUNT(party), .partyFlags = F_TRAINER_PARTY_HELD_ITEM
|
||||
#define ITEM_CUSTOM_MOVES(party) { .ItemCustomMoves = party }, .partySize = ARRAY_COUNT(party), .partyFlags = F_TRAINER_PARTY_CUSTOM_MOVESET | F_TRAINER_PARTY_HELD_ITEM
|
||||
#define EVERYTHING_CUSTOMIZED(party) { .EverythingCustomized = party}, .partySize = ARRAY_COUNT(party), .partyFlags = F_TRAINER_PARTY_EVERYTHING_CUSTOMIZED
|
||||
|
||||
union TrainerMonPtr
|
||||
{
|
||||
const struct TrainerMonNoItemDefaultMoves *NoItemDefaultMoves;
|
||||
const struct TrainerMonNoItemCustomMoves *NoItemCustomMoves;
|
||||
const struct TrainerMonItemDefaultMoves *ItemDefaultMoves;
|
||||
const struct TrainerMonItemCustomMoves *ItemCustomMoves;
|
||||
const struct TrainerMonCustomized *EverythingCustomized;
|
||||
};
|
||||
#define TRAINER_PARTY(partyArray) partyArray, .partySize = ARRAY_COUNT(partyArray)
|
||||
|
||||
struct Trainer
|
||||
{
|
||||
/*0x00*/ u32 aiFlags;
|
||||
/*0x04*/ union TrainerMonPtr party;
|
||||
/*0x04*/ const struct TrainerMon *party;
|
||||
/*0x08*/ u16 items[MAX_TRAINER_ITEMS];
|
||||
/*0x10*/ u8 trainerClass;
|
||||
/*0x11*/ u8 encounterMusic_gender; // last bit is gender
|
||||
/*0x12*/ u8 trainerPic;
|
||||
/*0x13*/ u8 trainerName[TRAINER_NAME_LENGTH + 1];
|
||||
/*0x1E*/ bool8 doubleBattle:1;
|
||||
u8 partyFlags:7;
|
||||
u8 padding:7;
|
||||
/*0x1F*/ u8 partySize;
|
||||
};
|
||||
|
||||
|
@ -1902,33 +1902,8 @@ static u32 Crc32B (const u8 *data, u32 size)
|
||||
|
||||
static u32 GeneratePartyHash(const struct Trainer *trainer, u32 i)
|
||||
{
|
||||
const u8 *buffer;
|
||||
u32 n;
|
||||
if (trainer->partyFlags == 0)
|
||||
{
|
||||
buffer = (const u8 *) &trainer->party.NoItemDefaultMoves[i];
|
||||
n = sizeof(*trainer->party.NoItemDefaultMoves);
|
||||
}
|
||||
else if (trainer->partyFlags == F_TRAINER_PARTY_CUSTOM_MOVESET)
|
||||
{
|
||||
buffer = (const u8 *) &trainer->party.NoItemCustomMoves[i];
|
||||
n = sizeof(*trainer->party.NoItemCustomMoves);
|
||||
}
|
||||
else if (trainer->partyFlags == F_TRAINER_PARTY_HELD_ITEM)
|
||||
{
|
||||
buffer = (const u8 *) &trainer->party.ItemDefaultMoves[i];
|
||||
n = sizeof(*trainer->party.ItemDefaultMoves);
|
||||
}
|
||||
else if (trainer->partyFlags == (F_TRAINER_PARTY_HELD_ITEM | F_TRAINER_PARTY_CUSTOM_MOVESET))
|
||||
{
|
||||
buffer = (const u8 *) &trainer->party.ItemCustomMoves[i];
|
||||
n = sizeof(*trainer->party.ItemCustomMoves);
|
||||
}
|
||||
else if (trainer->partyFlags == F_TRAINER_PARTY_EVERYTHING_CUSTOMIZED)
|
||||
{
|
||||
buffer = (const u8 *) &trainer->party.EverythingCustomized[i];
|
||||
n = sizeof(*trainer->party.EverythingCustomized);
|
||||
}
|
||||
const u8 *buffer = (const u8 *) &trainer->party[i];
|
||||
u32 n = sizeof(*trainer->party);
|
||||
return Crc32B(buffer, n);
|
||||
}
|
||||
|
||||
@ -1954,7 +1929,7 @@ u32 GeneratePersonalityForGender(u32 gender, u32 species)
|
||||
return speciesInfo->genderRatio / 2;
|
||||
}
|
||||
|
||||
void CustomTrainerPartyAssignMoves(struct Pokemon *mon, const struct TrainerMonCustomized *partyEntry)
|
||||
void CustomTrainerPartyAssignMoves(struct Pokemon *mon, const struct TrainerMon *partyEntry)
|
||||
{
|
||||
bool32 noMoveSet = TRUE;
|
||||
u32 j;
|
||||
@ -2006,6 +1981,10 @@ u8 CreateNPCTrainerPartyFromTrainer(struct Pokemon *party, const struct Trainer
|
||||
{
|
||||
s32 ball = -1;
|
||||
u32 personalityHash = GeneratePartyHash(trainer, i);
|
||||
const struct TrainerMon *partyData = trainer->party;
|
||||
u32 otIdType = OT_ID_RANDOM_NO_SHINY;
|
||||
u32 fixedOtId = 0;
|
||||
|
||||
if (trainer->doubleBattle == TRUE)
|
||||
personalityValue = 0x80;
|
||||
else if (trainer->encounterMusic_gender & F_TRAINER_FEMALE)
|
||||
@ -2014,107 +1993,54 @@ u8 CreateNPCTrainerPartyFromTrainer(struct Pokemon *party, const struct Trainer
|
||||
personalityValue = 0x88; // Use personality more likely to result in a male Pokémon
|
||||
|
||||
personalityValue += personalityHash << 8;
|
||||
switch (trainer->partyFlags)
|
||||
if (partyData[i].gender == TRAINER_MON_MALE)
|
||||
personalityValue = (personalityValue & 0xFFFFFF00) | GeneratePersonalityForGender(MON_MALE, partyData[i].species);
|
||||
else if (partyData[i].gender == TRAINER_MON_FEMALE)
|
||||
personalityValue = (personalityValue & 0xFFFFFF00) | GeneratePersonalityForGender(MON_FEMALE, partyData[i].species);
|
||||
if (partyData[i].nature != 0)
|
||||
ModifyPersonalityForNature(&personalityValue, partyData[i].nature - 1);
|
||||
if (partyData[i].isShiny)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
const struct TrainerMonNoItemDefaultMoves *partyData = trainer->party.NoItemDefaultMoves;
|
||||
fixedIV = partyData[i].iv * MAX_PER_STAT_IVS / 255;
|
||||
CreateMon(&party[i], partyData[i].species, partyData[i].lvl, fixedIV, TRUE, personalityValue, OT_ID_RANDOM_NO_SHINY, 0);
|
||||
break;
|
||||
otIdType = OT_ID_PRESET;
|
||||
fixedOtId = HIHALF(personalityValue) ^ LOHALF(personalityValue);
|
||||
}
|
||||
case F_TRAINER_PARTY_CUSTOM_MOVESET:
|
||||
{
|
||||
const struct TrainerMonNoItemCustomMoves *partyData = trainer->party.NoItemCustomMoves;
|
||||
fixedIV = partyData[i].iv * MAX_PER_STAT_IVS / 255;
|
||||
CreateMon(&party[i], partyData[i].species, partyData[i].lvl, fixedIV, TRUE, personalityValue, OT_ID_RANDOM_NO_SHINY, 0);
|
||||
CreateMon(&party[i], partyData[i].species, partyData[i].lvl, 0, TRUE, personalityValue, otIdType, fixedOtId);
|
||||
SetMonData(&party[i], MON_DATA_HELD_ITEM, &partyData[i].heldItem);
|
||||
|
||||
for (j = 0; j < MAX_MON_MOVES; j++)
|
||||
{
|
||||
SetMonData(&party[i], MON_DATA_MOVE1 + j, &partyData[i].moves[j]);
|
||||
SetMonData(&party[i], MON_DATA_PP1 + j, &gBattleMoves[partyData[i].moves[j]].pp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case F_TRAINER_PARTY_HELD_ITEM:
|
||||
CustomTrainerPartyAssignMoves(&party[i], &partyData[i]);
|
||||
SetMonData(&party[i], MON_DATA_IVS, &(partyData[i].iv));
|
||||
if (partyData[i].ev != NULL)
|
||||
{
|
||||
const struct TrainerMonItemDefaultMoves *partyData = trainer->party.ItemDefaultMoves;
|
||||
fixedIV = partyData[i].iv * MAX_PER_STAT_IVS / 255;
|
||||
CreateMon(&party[i], partyData[i].species, partyData[i].lvl, fixedIV, TRUE, personalityValue, OT_ID_RANDOM_NO_SHINY, 0);
|
||||
|
||||
SetMonData(&party[i], MON_DATA_HELD_ITEM, &partyData[i].heldItem);
|
||||
break;
|
||||
SetMonData(&party[i], MON_DATA_HP_EV, &(partyData[i].ev[0]));
|
||||
SetMonData(&party[i], MON_DATA_ATK_EV, &(partyData[i].ev[1]));
|
||||
SetMonData(&party[i], MON_DATA_DEF_EV, &(partyData[i].ev[2]));
|
||||
SetMonData(&party[i], MON_DATA_SPATK_EV, &(partyData[i].ev[3]));
|
||||
SetMonData(&party[i], MON_DATA_SPDEF_EV, &(partyData[i].ev[4]));
|
||||
SetMonData(&party[i], MON_DATA_SPEED_EV, &(partyData[i].ev[5]));
|
||||
}
|
||||
case F_TRAINER_PARTY_CUSTOM_MOVESET | F_TRAINER_PARTY_HELD_ITEM:
|
||||
if (partyData[i].ability != ABILITY_NONE)
|
||||
{
|
||||
const struct TrainerMonItemCustomMoves *partyData = trainer->party.ItemCustomMoves;
|
||||
fixedIV = partyData[i].iv * MAX_PER_STAT_IVS / 255;
|
||||
CreateMon(&party[i], partyData[i].species, partyData[i].lvl, fixedIV, TRUE, personalityValue, OT_ID_RANDOM_NO_SHINY, 0);
|
||||
|
||||
SetMonData(&party[i], MON_DATA_HELD_ITEM, &partyData[i].heldItem);
|
||||
|
||||
for (j = 0; j < MAX_MON_MOVES; j++)
|
||||
const struct SpeciesInfo *speciesInfo = &gSpeciesInfo[partyData[i].species];
|
||||
u32 maxAbilities = ARRAY_COUNT(speciesInfo->abilities);
|
||||
for (j = 0; j < maxAbilities; ++j)
|
||||
{
|
||||
SetMonData(&party[i], MON_DATA_MOVE1 + j, &partyData[i].moves[j]);
|
||||
SetMonData(&party[i], MON_DATA_PP1 + j, &gBattleMoves[partyData[i].moves[j]].pp);
|
||||
if (speciesInfo->abilities[j] == partyData[i].ability)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
if (j < maxAbilities)
|
||||
SetMonData(&party[i], MON_DATA_ABILITY_NUM, &j);
|
||||
}
|
||||
case F_TRAINER_PARTY_EVERYTHING_CUSTOMIZED:
|
||||
SetMonData(&party[i], MON_DATA_FRIENDSHIP, &(partyData[i].friendship));
|
||||
if (partyData[i].ball != ITEM_NONE)
|
||||
{
|
||||
const struct TrainerMonCustomized *partyData = trainer->party.EverythingCustomized;
|
||||
u32 otIdType = OT_ID_RANDOM_NO_SHINY;
|
||||
u32 fixedOtId = 0;
|
||||
if (partyData[i].gender == TRAINER_MON_MALE)
|
||||
personalityValue = (personalityValue & 0xFFFFFF00) | GeneratePersonalityForGender(MON_MALE, partyData[i].species);
|
||||
else if (partyData[i].gender == TRAINER_MON_FEMALE)
|
||||
personalityValue = (personalityValue & 0xFFFFFF00) | GeneratePersonalityForGender(MON_FEMALE, partyData[i].species);
|
||||
if (partyData[i].nature != 0)
|
||||
ModifyPersonalityForNature(&personalityValue, partyData[i].nature - 1);
|
||||
if (partyData[i].isShiny)
|
||||
{
|
||||
otIdType = OT_ID_PRESET;
|
||||
fixedOtId = HIHALF(personalityValue) ^ LOHALF(personalityValue);
|
||||
}
|
||||
CreateMon(&party[i], partyData[i].species, partyData[i].lvl, 0, TRUE, personalityValue, otIdType, fixedOtId);
|
||||
SetMonData(&party[i], MON_DATA_HELD_ITEM, &partyData[i].heldItem);
|
||||
|
||||
CustomTrainerPartyAssignMoves(&party[i], &partyData[i]);
|
||||
SetMonData(&party[i], MON_DATA_IVS, &(partyData[i].iv));
|
||||
if (partyData[i].ev != NULL)
|
||||
{
|
||||
SetMonData(&party[i], MON_DATA_HP_EV, &(partyData[i].ev[0]));
|
||||
SetMonData(&party[i], MON_DATA_ATK_EV, &(partyData[i].ev[1]));
|
||||
SetMonData(&party[i], MON_DATA_DEF_EV, &(partyData[i].ev[2]));
|
||||
SetMonData(&party[i], MON_DATA_SPATK_EV, &(partyData[i].ev[3]));
|
||||
SetMonData(&party[i], MON_DATA_SPDEF_EV, &(partyData[i].ev[4]));
|
||||
SetMonData(&party[i], MON_DATA_SPEED_EV, &(partyData[i].ev[5]));
|
||||
}
|
||||
if (partyData[i].ability != ABILITY_NONE)
|
||||
{
|
||||
const struct SpeciesInfo *speciesInfo = &gSpeciesInfo[partyData[i].species];
|
||||
u32 maxAbilities = ARRAY_COUNT(speciesInfo->abilities);
|
||||
for (j = 0; j < maxAbilities; ++j)
|
||||
{
|
||||
if (speciesInfo->abilities[j] == partyData[i].ability)
|
||||
break;
|
||||
}
|
||||
if (j < maxAbilities)
|
||||
SetMonData(&party[i], MON_DATA_ABILITY_NUM, &j);
|
||||
}
|
||||
SetMonData(&party[i], MON_DATA_FRIENDSHIP, &(partyData[i].friendship));
|
||||
if (partyData[i].ball != ITEM_NONE)
|
||||
{
|
||||
ball = partyData[i].ball;
|
||||
SetMonData(&party[i], MON_DATA_POKEBALL, &ball);
|
||||
}
|
||||
if (partyData[i].nickname != NULL)
|
||||
{
|
||||
SetMonData(&party[i], MON_DATA_NICKNAME, partyData[i].nickname);
|
||||
}
|
||||
CalculateMonStats(&party[i]);
|
||||
ball = partyData[i].ball;
|
||||
SetMonData(&party[i], MON_DATA_POKEBALL, &ball);
|
||||
}
|
||||
if (partyData[i].nickname != NULL)
|
||||
{
|
||||
SetMonData(&party[i], MON_DATA_NICKNAME, partyData[i].nickname);
|
||||
}
|
||||
CalculateMonStats(&party[i]);
|
||||
|
||||
#if B_TRAINER_CLASS_POKE_BALLS >= GEN_7
|
||||
if (ball == -1)
|
||||
|
@ -7376,39 +7376,8 @@ static u32 GetTrainerMoneyToGive(u16 trainerId)
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (gTrainers[trainerId].partyFlags)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
const struct TrainerMonNoItemDefaultMoves *party = gTrainers[trainerId].party.NoItemDefaultMoves;
|
||||
lastMonLevel = party[gTrainers[trainerId].partySize - 1].lvl;
|
||||
}
|
||||
break;
|
||||
case F_TRAINER_PARTY_CUSTOM_MOVESET:
|
||||
{
|
||||
const struct TrainerMonNoItemCustomMoves *party = gTrainers[trainerId].party.NoItemCustomMoves;
|
||||
lastMonLevel = party[gTrainers[trainerId].partySize - 1].lvl;
|
||||
}
|
||||
break;
|
||||
case F_TRAINER_PARTY_HELD_ITEM:
|
||||
{
|
||||
const struct TrainerMonItemDefaultMoves *party = gTrainers[trainerId].party.ItemDefaultMoves;
|
||||
lastMonLevel = party[gTrainers[trainerId].partySize - 1].lvl;
|
||||
}
|
||||
break;
|
||||
case F_TRAINER_PARTY_CUSTOM_MOVESET | F_TRAINER_PARTY_HELD_ITEM:
|
||||
{
|
||||
const struct TrainerMonItemCustomMoves *party = gTrainers[trainerId].party.ItemCustomMoves;
|
||||
lastMonLevel = party[gTrainers[trainerId].partySize - 1].lvl;
|
||||
}
|
||||
break;
|
||||
case F_TRAINER_PARTY_EVERYTHING_CUSTOMIZED:
|
||||
{
|
||||
const struct TrainerMonCustomized *party = gTrainers[trainerId].party.EverythingCustomized;
|
||||
lastMonLevel = party[gTrainers[trainerId].partySize - 1].lvl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
const struct TrainerMon *party = gTrainers[trainerId].party;
|
||||
lastMonLevel = party[gTrainers[trainerId].partySize - 1].lvl;
|
||||
|
||||
for (; gTrainerMoneyTable[i].classId != 0xFF; i++)
|
||||
{
|
||||
|
@ -812,55 +812,16 @@ static u8 GetSumOfEnemyPartyLevel(u16 opponentId, u8 numMons)
|
||||
u8 i;
|
||||
u8 sum;
|
||||
u32 count = numMons;
|
||||
const struct TrainerMon *party;
|
||||
|
||||
if (gTrainers[opponentId].partySize < count)
|
||||
count = gTrainers[opponentId].partySize;
|
||||
|
||||
sum = 0;
|
||||
|
||||
switch (gTrainers[opponentId].partyFlags)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
const struct TrainerMonNoItemDefaultMoves *party;
|
||||
party = gTrainers[opponentId].party.NoItemDefaultMoves;
|
||||
for (i = 0; i < count; i++)
|
||||
sum += party[i].lvl;
|
||||
}
|
||||
break;
|
||||
case F_TRAINER_PARTY_CUSTOM_MOVESET:
|
||||
{
|
||||
const struct TrainerMonNoItemCustomMoves *party;
|
||||
party = gTrainers[opponentId].party.NoItemCustomMoves;
|
||||
for (i = 0; i < count; i++)
|
||||
sum += party[i].lvl;
|
||||
}
|
||||
break;
|
||||
case F_TRAINER_PARTY_HELD_ITEM:
|
||||
{
|
||||
const struct TrainerMonItemDefaultMoves *party;
|
||||
party = gTrainers[opponentId].party.ItemDefaultMoves;
|
||||
for (i = 0; i < count; i++)
|
||||
sum += party[i].lvl;
|
||||
}
|
||||
break;
|
||||
case F_TRAINER_PARTY_CUSTOM_MOVESET | F_TRAINER_PARTY_HELD_ITEM:
|
||||
{
|
||||
const struct TrainerMonItemCustomMoves *party;
|
||||
party = gTrainers[opponentId].party.ItemCustomMoves;
|
||||
for (i = 0; i < count; i++)
|
||||
sum += party[i].lvl;
|
||||
}
|
||||
break;
|
||||
case F_TRAINER_PARTY_EVERYTHING_CUSTOMIZED:
|
||||
{
|
||||
const struct TrainerMonCustomized *party;
|
||||
party = gTrainers[opponentId].party.EverythingCustomized;
|
||||
for (i = 0; i < count; i++)
|
||||
sum += party[i].lvl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
party = gTrainers[opponentId].party;
|
||||
for (i = 0; i < count; i++)
|
||||
sum += party[i].lvl;
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
@ -3049,113 +3049,62 @@ static void FillPartnerParty(u16 trainerId)
|
||||
|
||||
for (i = 0; i < 3 && i < gTrainers[trainerId - TRAINER_CUSTOM_PARTNER].partySize; i++)
|
||||
{
|
||||
const struct TrainerMon *partyData = gTrainers[trainerId - TRAINER_CUSTOM_PARTNER].party;
|
||||
u32 otIdType = OT_ID_RANDOM_NO_SHINY;
|
||||
do
|
||||
{
|
||||
j = Random32();
|
||||
} while (IsShinyOtIdPersonality(otID, j));
|
||||
|
||||
switch (gTrainers[trainerId - TRAINER_CUSTOM_PARTNER].partyFlags)
|
||||
if (partyData[i].gender == TRAINER_MON_MALE)
|
||||
j = (j & 0xFFFFFF00) | GeneratePersonalityForGender(MON_MALE, partyData[i].species);
|
||||
else if (partyData[i].gender == TRAINER_MON_FEMALE)
|
||||
j = (j & 0xFFFFFF00) | GeneratePersonalityForGender(MON_FEMALE, partyData[i].species);
|
||||
if (partyData[i].nature != 0)
|
||||
ModifyPersonalityForNature(&j, partyData[i].nature - 1);
|
||||
if (partyData[i].isShiny)
|
||||
{
|
||||
case 0:
|
||||
otIdType = OT_ID_PRESET;
|
||||
otID = HIHALF(j) ^ LOHALF(j);
|
||||
}
|
||||
|
||||
CreateMon(&gPlayerParty[i + 3], partyData[i].species, partyData[i].lvl, 0, TRUE, j, otIdType, otID);
|
||||
SetMonData(&gPlayerParty[i + 3], MON_DATA_HELD_ITEM, &partyData[i].heldItem);
|
||||
CustomTrainerPartyAssignMoves(&gPlayerParty[i+3], &partyData[i]);
|
||||
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_IVS, &(partyData[i].iv));
|
||||
if (partyData[i].ev != NULL)
|
||||
{
|
||||
const struct TrainerMonNoItemDefaultMoves *partyData = gTrainers[trainerId - TRAINER_CUSTOM_PARTNER].party.NoItemDefaultMoves;
|
||||
|
||||
CreateMon(&gPlayerParty[i + 3], partyData[i].species, partyData[i].lvl, partyData[i].iv * 31 / 255, TRUE, j, TRUE, otID);
|
||||
break;
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_HP_EV, &(partyData[i].ev[0]));
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_ATK_EV, &(partyData[i].ev[1]));
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_DEF_EV, &(partyData[i].ev[2]));
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_SPATK_EV, &(partyData[i].ev[3]));
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_SPDEF_EV, &(partyData[i].ev[4]));
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_SPEED_EV, &(partyData[i].ev[5]));
|
||||
}
|
||||
case F_TRAINER_PARTY_CUSTOM_MOVESET:
|
||||
if (partyData[i].ability != ABILITY_NONE)
|
||||
{
|
||||
const struct TrainerMonNoItemCustomMoves *partyData = gTrainers[trainerId - TRAINER_CUSTOM_PARTNER].party.NoItemCustomMoves;
|
||||
|
||||
CreateMon(&gPlayerParty[i + 3], partyData[i].species, partyData[i].lvl, partyData[i].iv * 31 / 255, TRUE, j, TRUE, otID);
|
||||
|
||||
for (j = 0; j < 4; j++)
|
||||
const struct SpeciesInfo *speciesInfo = &gSpeciesInfo[partyData[i].species];
|
||||
u32 maxAbilities = ARRAY_COUNT(speciesInfo->abilities);
|
||||
for (j = 0; j < maxAbilities; ++j)
|
||||
{
|
||||
SetMonData(&gPlayerParty[i + 3], MON_DATA_MOVE1 + j, &partyData[i].moves[j]);
|
||||
SetMonData(&gPlayerParty[i + 3], MON_DATA_PP1 + j, &gBattleMoves[partyData[i].moves[j]].pp);
|
||||
if (speciesInfo->abilities[j] == partyData[i].ability)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
if (j < maxAbilities)
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_ABILITY_NUM, &j);
|
||||
}
|
||||
case F_TRAINER_PARTY_HELD_ITEM:
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_FRIENDSHIP, &(partyData[i].friendship));
|
||||
if (partyData[i].ball != ITEM_NONE)
|
||||
{
|
||||
const struct TrainerMonItemDefaultMoves *partyData = gTrainers[trainerId - TRAINER_CUSTOM_PARTNER].party.ItemDefaultMoves;
|
||||
|
||||
CreateMon(&gPlayerParty[i + 3], partyData[i].species, partyData[i].lvl, partyData[i].iv * 31 / 255, TRUE, j, TRUE, otID);
|
||||
|
||||
SetMonData(&gPlayerParty[i + 3], MON_DATA_HELD_ITEM, &partyData[i].heldItem);
|
||||
break;
|
||||
ball = partyData[i].ball;
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_POKEBALL, &ball);
|
||||
}
|
||||
case F_TRAINER_PARTY_CUSTOM_MOVESET | F_TRAINER_PARTY_HELD_ITEM:
|
||||
if (partyData[i].nickname != NULL)
|
||||
{
|
||||
const struct TrainerMonItemCustomMoves *partyData = gTrainers[trainerId - TRAINER_CUSTOM_PARTNER].party.ItemCustomMoves;
|
||||
|
||||
CreateMon(&gPlayerParty[i + 3], partyData[i].species, partyData[i].lvl, partyData[i].iv * 31 / 255, TRUE, j, TRUE, otID);
|
||||
|
||||
SetMonData(&gPlayerParty[i + 3], MON_DATA_HELD_ITEM, &partyData[i].heldItem);
|
||||
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
SetMonData(&gPlayerParty[i + 3], MON_DATA_MOVE1 + j, &partyData[i].moves[j]);
|
||||
SetMonData(&gPlayerParty[i + 3], MON_DATA_PP1 + j, &gBattleMoves[partyData[i].moves[j]].pp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case F_TRAINER_PARTY_EVERYTHING_CUSTOMIZED:
|
||||
{
|
||||
const struct TrainerMonCustomized *partyData = gTrainers[trainerId - TRAINER_CUSTOM_PARTNER].party.EverythingCustomized;
|
||||
u32 otIdType = OT_ID_RANDOM_NO_SHINY;
|
||||
|
||||
if (partyData[i].gender == TRAINER_MON_MALE)
|
||||
j = (j & 0xFFFFFF00) | GeneratePersonalityForGender(MON_MALE, partyData[i].species);
|
||||
else if (partyData[i].gender == TRAINER_MON_FEMALE)
|
||||
j = (j & 0xFFFFFF00) | GeneratePersonalityForGender(MON_FEMALE, partyData[i].species);
|
||||
if (partyData[i].nature != 0)
|
||||
ModifyPersonalityForNature(&j, partyData[i].nature - 1);
|
||||
if (partyData[i].isShiny)
|
||||
{
|
||||
otIdType = OT_ID_PRESET;
|
||||
otID = HIHALF(j) ^ LOHALF(j);
|
||||
}
|
||||
|
||||
CreateMon(&gPlayerParty[i + 3], partyData[i].species, partyData[i].lvl, 0, TRUE, j, otIdType, otID);
|
||||
SetMonData(&gPlayerParty[i + 3], MON_DATA_HELD_ITEM, &partyData[i].heldItem);
|
||||
CustomTrainerPartyAssignMoves(&gPlayerParty[i+3], &partyData[i]);
|
||||
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_IVS, &(partyData[i].iv));
|
||||
if (partyData[i].ev != NULL)
|
||||
{
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_HP_EV, &(partyData[i].ev[0]));
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_ATK_EV, &(partyData[i].ev[1]));
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_DEF_EV, &(partyData[i].ev[2]));
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_SPATK_EV, &(partyData[i].ev[3]));
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_SPDEF_EV, &(partyData[i].ev[4]));
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_SPEED_EV, &(partyData[i].ev[5]));
|
||||
}
|
||||
if (partyData[i].ability != ABILITY_NONE)
|
||||
{
|
||||
const struct SpeciesInfo *speciesInfo = &gSpeciesInfo[partyData[i].species];
|
||||
u32 maxAbilities = ARRAY_COUNT(speciesInfo->abilities);
|
||||
for (j = 0; j < maxAbilities; ++j)
|
||||
{
|
||||
if (speciesInfo->abilities[j] == partyData[i].ability)
|
||||
break;
|
||||
}
|
||||
if (j < maxAbilities)
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_ABILITY_NUM, &j);
|
||||
}
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_FRIENDSHIP, &(partyData[i].friendship));
|
||||
if (partyData[i].ball != ITEM_NONE)
|
||||
{
|
||||
ball = partyData[i].ball;
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_POKEBALL, &ball);
|
||||
}
|
||||
if (partyData[i].nickname != NULL)
|
||||
{
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_NICKNAME, partyData[i].nickname);
|
||||
}
|
||||
CalculateMonStats(&gPlayerParty[i+3]);
|
||||
}
|
||||
SetMonData(&gPlayerParty[i+3], MON_DATA_NICKNAME, partyData[i].nickname);
|
||||
}
|
||||
CalculateMonStats(&gPlayerParty[i+3]);
|
||||
|
||||
StringCopy(trainerName, gTrainers[trainerId - TRAINER_CUSTOM_PARTNER].trainerName);
|
||||
SetMonData(&gPlayerParty[i + 3], MON_DATA_OT_NAME, trainerName);
|
||||
|
File diff suppressed because it is too large
Load Diff
1711
src/data/trainers.h
1711
src/data/trainers.h
File diff suppressed because it is too large
Load Diff
@ -1789,33 +1789,14 @@ static void PopulateSpeciesFromTrainerLocation(int matchCallId, u8 *destStr)
|
||||
static void PopulateSpeciesFromTrainerParty(int matchCallId, u8 *destStr)
|
||||
{
|
||||
u16 trainerId;
|
||||
union TrainerMonPtr party;
|
||||
const struct TrainerMon *party;
|
||||
u8 monId;
|
||||
const u8 *speciesName;
|
||||
|
||||
trainerId = GetLastBeatenRematchTrainerId(sMatchCallTrainers[matchCallId].trainerId);
|
||||
party = gTrainers[trainerId].party;
|
||||
monId = Random() % gTrainers[trainerId].partySize;
|
||||
|
||||
switch (gTrainers[trainerId].partyFlags)
|
||||
{
|
||||
case 0:
|
||||
default:
|
||||
speciesName = GetSpeciesName(party.NoItemDefaultMoves[monId].species);
|
||||
break;
|
||||
case F_TRAINER_PARTY_CUSTOM_MOVESET:
|
||||
speciesName = GetSpeciesName(party.NoItemCustomMoves[monId].species);
|
||||
break;
|
||||
case F_TRAINER_PARTY_HELD_ITEM:
|
||||
speciesName = GetSpeciesName(party.ItemDefaultMoves[monId].species);
|
||||
break;
|
||||
case F_TRAINER_PARTY_CUSTOM_MOVESET | F_TRAINER_PARTY_HELD_ITEM:
|
||||
speciesName = GetSpeciesName(party.ItemCustomMoves[monId].species);
|
||||
break;
|
||||
case F_TRAINER_PARTY_EVERYTHING_CUSTOMIZED:
|
||||
speciesName = GetSpeciesName(party.EverythingCustomized[monId].species);
|
||||
break;
|
||||
}
|
||||
speciesName = GetSpeciesName(party[monId].species);
|
||||
|
||||
StringCopy(destStr, speciesName);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "constants/battle.h"
|
||||
|
||||
|
||||
static const struct TrainerMonCustomized sTestParty1[] =
|
||||
static const struct TrainerMon sTestParty1[] =
|
||||
{
|
||||
{
|
||||
.species = SPECIES_WOBBUFFET,
|
||||
@ -35,28 +35,10 @@ static const struct TrainerMonCustomized sTestParty1[] =
|
||||
},
|
||||
};
|
||||
|
||||
static const struct TrainerMonNoItemDefaultMoves sTestParty2[] =
|
||||
{
|
||||
{
|
||||
.species = SPECIES_WOBBUFFET,
|
||||
.lvl = 5,
|
||||
},
|
||||
{
|
||||
.species = SPECIES_WOBBUFFET,
|
||||
.lvl = 6,
|
||||
}
|
||||
};
|
||||
|
||||
static const struct Trainer sTestTrainer1 =
|
||||
{
|
||||
.trainerName = _("Test1"),
|
||||
.party = EVERYTHING_CUSTOMIZED(sTestParty1),
|
||||
};
|
||||
|
||||
static const struct Trainer sTestTrainer2 =
|
||||
{
|
||||
.trainerName = _("Test2"),
|
||||
.party = NO_ITEM_DEFAULT_MOVES(sTestParty2),
|
||||
.party = TRAINER_PARTY(sTestParty1),
|
||||
};
|
||||
|
||||
TEST("CreateNPCTrainerPartyForTrainer generates customized Pokémon")
|
||||
@ -134,7 +116,7 @@ TEST("CreateNPCTrainerPartyForTrainer generates customized Pokémon")
|
||||
TEST("CreateNPCTrainerPartyForTrainer generates different personalities for different mons")
|
||||
{
|
||||
struct Pokemon *testParty = Alloc(6 * sizeof(struct Pokemon));
|
||||
CreateNPCTrainerPartyFromTrainer(testParty, &sTestTrainer2, TRUE, BATTLE_TYPE_TRAINER);
|
||||
CreateNPCTrainerPartyFromTrainer(testParty, &sTestTrainer1, TRUE, BATTLE_TYPE_TRAINER);
|
||||
EXPECT(testParty[0].box.personality != testParty[1].box.personality);
|
||||
Free(testParty);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user