mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 19:47:35 +01:00
Modify "FillPartnerParty" to work with "Everything Customized" (#2889)
This commit is contained in:
commit
1094861667
@ -70,6 +70,8 @@ void SpecialStatusesClear(void);
|
|||||||
void SetTypeBeforeUsingMove(u16 move, u8 battlerAtk);
|
void SetTypeBeforeUsingMove(u16 move, u8 battlerAtk);
|
||||||
bool32 IsWildMonSmart(void);
|
bool32 IsWildMonSmart(void);
|
||||||
u8 CreateNPCTrainerPartyFromTrainer(struct Pokemon *party, const struct Trainer *trainer, bool32 firstTrainer, u32 battleTypeFlags);
|
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);
|
||||||
|
|
||||||
extern struct MultiPartnerMenuPokemon gMultiPartnerParty[MULTI_PARTY_SIZE];
|
extern struct MultiPartnerMenuPokemon gMultiPartnerParty[MULTI_PARTY_SIZE];
|
||||||
|
|
||||||
|
@ -120,8 +120,6 @@ static void SpriteCB_UnusedBattleInit_Main(struct Sprite *sprite);
|
|||||||
static void TrySpecialEvolution(void);
|
static void TrySpecialEvolution(void);
|
||||||
static u32 Crc32B (const u8 *data, u32 size);
|
static u32 Crc32B (const u8 *data, u32 size);
|
||||||
static u32 GeneratePartyHash(const struct Trainer *trainer, u32 i);
|
static u32 GeneratePartyHash(const struct Trainer *trainer, u32 i);
|
||||||
static void ModifyPersonalityForNature(u32 *personality, u32 newNature);
|
|
||||||
static u32 GeneratePersonalityForGender(u32 gender, u32 species);
|
|
||||||
|
|
||||||
EWRAM_DATA u16 gBattle_BG0_X = 0;
|
EWRAM_DATA u16 gBattle_BG0_X = 0;
|
||||||
EWRAM_DATA u16 gBattle_BG0_Y = 0;
|
EWRAM_DATA u16 gBattle_BG0_Y = 0;
|
||||||
@ -1925,7 +1923,7 @@ static u32 GeneratePartyHash(const struct Trainer *trainer, u32 i)
|
|||||||
return Crc32B(buffer, n);
|
return Crc32B(buffer, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ModifyPersonalityForNature(u32 *personality, u32 newNature)
|
void ModifyPersonalityForNature(u32 *personality, u32 newNature)
|
||||||
{
|
{
|
||||||
u32 nature = GetNatureFromPersonality(*personality);
|
u32 nature = GetNatureFromPersonality(*personality);
|
||||||
s32 diff = abs(nature - newNature);
|
s32 diff = abs(nature - newNature);
|
||||||
@ -1938,7 +1936,7 @@ static void ModifyPersonalityForNature(u32 *personality, u32 newNature)
|
|||||||
*personality -= (diff * sign);
|
*personality -= (diff * sign);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 GeneratePersonalityForGender(u32 gender, u32 species)
|
u32 GeneratePersonalityForGender(u32 gender, u32 species)
|
||||||
{
|
{
|
||||||
const struct SpeciesInfo *speciesInfo = &gSpeciesInfo[species];
|
const struct SpeciesInfo *speciesInfo = &gSpeciesInfo[species];
|
||||||
if (gender == MON_MALE)
|
if (gender == MON_MALE)
|
||||||
|
@ -3103,25 +3103,38 @@ static void FillPartnerParty(u16 trainerId)
|
|||||||
case F_TRAINER_PARTY_EVERYTHING_CUSTOMIZED:
|
case F_TRAINER_PARTY_EVERYTHING_CUSTOMIZED:
|
||||||
{
|
{
|
||||||
const struct TrainerMonCustomized *partyData = gTrainers[trainerId - TRAINER_CUSTOM_PARTNER].party.EverythingCustomized;
|
const struct TrainerMonCustomized *partyData = gTrainers[trainerId - TRAINER_CUSTOM_PARTNER].party.EverythingCustomized;
|
||||||
|
u32 otIdType = OT_ID_RANDOM_NO_SHINY;
|
||||||
|
|
||||||
CreateMon(&gPlayerParty[i], partyData[i].species, partyData[i].lvl, 0, TRUE, j, TRUE, otID);
|
if (partyData[i].gender == TRAINER_MON_MALE)
|
||||||
SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &partyData[i].heldItem);
|
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);
|
||||||
|
|
||||||
// TODO: Figure out a default strategy when moves are not set, to generate a good moveset
|
// TODO: Figure out a default strategy when moves are not set, to generate a good moveset
|
||||||
for (j = 0; j < MAX_MON_MOVES; ++j)
|
for (j = 0; j < MAX_MON_MOVES; ++j)
|
||||||
{
|
{
|
||||||
SetMonData(&gPlayerParty[i], MON_DATA_MOVE1 + j, &partyData[i].moves[j]);
|
SetMonData(&gPlayerParty[i+3], MON_DATA_MOVE1 + j, &partyData[i].moves[j]);
|
||||||
SetMonData(&gPlayerParty[i], MON_DATA_PP1 + j, &gBattleMoves[partyData[i].moves[j]].pp);
|
SetMonData(&gPlayerParty[i+3], MON_DATA_PP1 + j, &gBattleMoves[partyData[i].moves[j]].pp);
|
||||||
}
|
}
|
||||||
SetMonData(&gPlayerParty[i], MON_DATA_IVS, &(partyData[i].iv));
|
SetMonData(&gPlayerParty[i+3], MON_DATA_IVS, &(partyData[i].iv));
|
||||||
if (partyData[i].ev != NULL)
|
if (partyData[i].ev != NULL)
|
||||||
{
|
{
|
||||||
SetMonData(&gPlayerParty[i], MON_DATA_HP_EV, &(partyData[i].ev[0]));
|
SetMonData(&gPlayerParty[i+3], MON_DATA_HP_EV, &(partyData[i].ev[0]));
|
||||||
SetMonData(&gPlayerParty[i], MON_DATA_ATK_EV, &(partyData[i].ev[1]));
|
SetMonData(&gPlayerParty[i+3], MON_DATA_ATK_EV, &(partyData[i].ev[1]));
|
||||||
SetMonData(&gPlayerParty[i], MON_DATA_DEF_EV, &(partyData[i].ev[2]));
|
SetMonData(&gPlayerParty[i+3], MON_DATA_DEF_EV, &(partyData[i].ev[2]));
|
||||||
SetMonData(&gPlayerParty[i], MON_DATA_SPATK_EV, &(partyData[i].ev[3]));
|
SetMonData(&gPlayerParty[i+3], MON_DATA_SPATK_EV, &(partyData[i].ev[3]));
|
||||||
SetMonData(&gPlayerParty[i], MON_DATA_SPDEF_EV, &(partyData[i].ev[4]));
|
SetMonData(&gPlayerParty[i+3], MON_DATA_SPDEF_EV, &(partyData[i].ev[4]));
|
||||||
SetMonData(&gPlayerParty[i], MON_DATA_SPEED_EV, &(partyData[i].ev[5]));
|
SetMonData(&gPlayerParty[i+3], MON_DATA_SPEED_EV, &(partyData[i].ev[5]));
|
||||||
}
|
}
|
||||||
if (partyData[i].ability != ABILITY_NONE)
|
if (partyData[i].ability != ABILITY_NONE)
|
||||||
{
|
{
|
||||||
@ -3133,19 +3146,19 @@ static void FillPartnerParty(u16 trainerId)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (j < maxAbilities)
|
if (j < maxAbilities)
|
||||||
SetMonData(&gPlayerParty[i], MON_DATA_ABILITY_NUM, &j);
|
SetMonData(&gPlayerParty[i+3], MON_DATA_ABILITY_NUM, &j);
|
||||||
}
|
}
|
||||||
SetMonData(&gPlayerParty[i], MON_DATA_FRIENDSHIP, &(partyData[i].friendship));
|
SetMonData(&gPlayerParty[i+3], MON_DATA_FRIENDSHIP, &(partyData[i].friendship));
|
||||||
if (partyData[i].ball != ITEM_NONE)
|
if (partyData[i].ball != ITEM_NONE)
|
||||||
{
|
{
|
||||||
ball = partyData[i].ball;
|
ball = partyData[i].ball;
|
||||||
SetMonData(&gPlayerParty[i], MON_DATA_POKEBALL, &ball);
|
SetMonData(&gPlayerParty[i+3], MON_DATA_POKEBALL, &ball);
|
||||||
}
|
}
|
||||||
if (partyData[i].nickname != NULL)
|
if (partyData[i].nickname != NULL)
|
||||||
{
|
{
|
||||||
SetMonData(&gPlayerParty[i], MON_DATA_NICKNAME, partyData[i].nickname);
|
SetMonData(&gPlayerParty[i+3], MON_DATA_NICKNAME, partyData[i].nickname);
|
||||||
}
|
}
|
||||||
CalculateMonStats(&gPlayerParty[i]);
|
CalculateMonStats(&gPlayerParty[i+3]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user