mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
Manually port daycare expansion to modern standards
This commit is contained in:
parent
32dcea0cdb
commit
b53c913558
@ -12,6 +12,11 @@
|
||||
#define P_INCENSE_BREEDING GEN_LATEST // Since Gen 9, cross-generation Baby Pokémon don't require Incense being held by the parents to be obtained via breeding.
|
||||
#define P_EGG_HATCH_LEVEL GEN_LATEST // Since Gen 4, Pokémon will hatch from eggs at level 1 instead of 5.
|
||||
#define P_BALL_INHERITING GEN_LATEST // Since Gen 6, Eggs from the Daycare will inherit the Poké Ball from their mother. From Gen 7 onwards, the father can pass it down as well, as long as it's of the same species as the mother.
|
||||
#define P_TM_INHERITANCE GEN_LATEST // Since Gen 6, the father no longer passes down TMs to the baby.
|
||||
#define P_MOTHER_EGG_MOVE_INHERITANCE GEN_LATEST // Since Gen 6, the mother can also pass down Egg Moves.
|
||||
#define P_NATURE_INHERITANCE GEN_LATEST // In Gen 3, Everstone grants Ditto and mothers a 50% chance to pass on Nature. Since Gen 4, anyone can pass on nature. Since Gen 5, the chance is 100%.
|
||||
#define P_ABILITY_INHERITANCE GEN_LATEST // TODO: In B2W2, a female Pokémon has an 80% chance of passing down their ability if bred with a male. Since Gen 6, the chance is 80% for normal ability and 60% for Hidden Ability, and anyone can pass down their abilities if bred with Ditto. NOTE: BW's effect: 60% chance to pass down HA and random for normal ability has been omitted.
|
||||
#define P_EGG_MOVE_TRANSFER GEN_LATEST // TODO: Starting in Gen 8, if two Pokémon of the same species are together in the Daycare, one knows an Egg Move, and the other has an empty slot, the other Pokémon will receive the Egg Move in the empty slot.
|
||||
|
||||
// Species-specific settings
|
||||
#define P_SHEDINJA_BALL GEN_LATEST // Since Gen 4, Shedinja requires a Poké Ball for its evolution. In Gen 3, Shedinja inherits Nincada's Ball.
|
||||
|
108
src/daycare.c
108
src/daycare.c
@ -21,11 +21,14 @@
|
||||
#include "overworld.h"
|
||||
#include "item.h"
|
||||
#include "constants/items.h"
|
||||
#include "constants/hold_effects.h"
|
||||
#include "constants/moves.h"
|
||||
#include "constants/region_map_sections.h"
|
||||
|
||||
extern const struct Evolution gEvolutionTable[][EVOS_PER_MON];
|
||||
|
||||
#define IS_DITTO(species) (gBaseStats[species].eggGroup1 == EGG_GROUP_DITTO || gBaseStats[species].eggGroup2 == EGG_GROUP_DITTO)
|
||||
|
||||
static void ClearDaycareMonMail(struct DaycareMail *mail);
|
||||
static void SetInitialEggData(struct Pokemon *mon, u16 species, struct DayCare *daycare);
|
||||
static u8 GetDaycareCompatibilityScore(struct DayCare *daycare);
|
||||
@ -425,43 +428,29 @@ static u16 GetEggSpecies(u16 species)
|
||||
|
||||
static s32 GetParentToInheritNature(struct DayCare *daycare)
|
||||
{
|
||||
u32 species[DAYCARE_MON_COUNT];
|
||||
s32 i;
|
||||
s32 dittoCount;
|
||||
s32 parent = -1;
|
||||
u32 i;
|
||||
u8 numWithEverstone = 0;
|
||||
s32 slot = -1;
|
||||
|
||||
// search for female gender
|
||||
for (i = 0; i < DAYCARE_MON_COUNT; i++)
|
||||
{
|
||||
if (GetBoxMonGender(&daycare->mons[i].mon) == MON_FEMALE)
|
||||
parent = i;
|
||||
if (ItemId_GetHoldEffect(GetBoxMonData(&daycare->mons[i].mon, MON_DATA_HELD_ITEM)) == HOLD_EFFECT_PREVENT_EVOLVE
|
||||
#if P_NATURE_INHERITANCE == GEN_3
|
||||
&& (GetBoxMonGender(&daycare->mons[i].mon) == MON_FEMALE || IS_DITTO(GetBoxMonData(&daycare->mons[i].mon, MON_DATA_SPECIES)))
|
||||
#endif
|
||||
) {
|
||||
slot = i;
|
||||
numWithEverstone++;
|
||||
}
|
||||
}
|
||||
|
||||
// search for ditto
|
||||
for (dittoCount = 0, i = 0; i < DAYCARE_MON_COUNT; i++)
|
||||
{
|
||||
species[i] = GetBoxMonData(&daycare->mons[i].mon, MON_DATA_SPECIES);
|
||||
if (species[i] == SPECIES_DITTO)
|
||||
dittoCount++, parent = i;
|
||||
}
|
||||
|
||||
// coin flip on ...two Dittos
|
||||
if (dittoCount == DAYCARE_MON_COUNT)
|
||||
{
|
||||
if (Random() >= USHRT_MAX / 2)
|
||||
parent = 0;
|
||||
else
|
||||
parent = 1;
|
||||
}
|
||||
|
||||
// Don't inherit nature if not holding Everstone
|
||||
if (GetBoxMonData(&daycare->mons[parent].mon, MON_DATA_HELD_ITEM) != ITEM_EVERSTONE
|
||||
|| Random() >= USHRT_MAX / 2)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return parent;
|
||||
if (numWithEverstone >= DAYCARE_MON_COUNT)
|
||||
return Random() & 1;
|
||||
#if P_NATURE_INHERITANCE > GEN_4
|
||||
return slot;
|
||||
#else
|
||||
return Random() & 1 ? slot : -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _TriggerPendingDaycareEgg(struct DayCare *daycare)
|
||||
@ -541,7 +530,7 @@ static void InheritIVs(struct Pokemon *egg, struct DayCare *daycare)
|
||||
{
|
||||
u16 motherItem = GetBoxMonData(&daycare->mons[0].mon, MON_DATA_HELD_ITEM);
|
||||
u16 fatherItem = GetBoxMonData(&daycare->mons[1].mon, MON_DATA_HELD_ITEM);
|
||||
u8 i;
|
||||
u8 i, start;
|
||||
u8 selectedIvs[5];
|
||||
u8 availableIVs[NUM_STATS];
|
||||
u8 whichParents[5];
|
||||
@ -557,8 +546,33 @@ static void InheritIVs(struct Pokemon *egg, struct DayCare *daycare)
|
||||
availableIVs[i] = i;
|
||||
}
|
||||
|
||||
start = 0;
|
||||
if (ItemId_GetHoldEffect(motherItem) == HOLD_EFFECT_POWER_ITEM &&
|
||||
ItemId_GetHoldEffect(fatherItem) == HOLD_EFFECT_POWER_ITEM)
|
||||
{
|
||||
whichParents[0] = Random() % DAYCARE_MON_COUNT;
|
||||
selectedIvs[0] = ItemId_GetSecondaryId(
|
||||
GetBoxMonData(&daycare->mons[whichParents[0]].mon, MON_DATA_HELD_ITEM));
|
||||
RemoveIVIndexFromList(availableIVs, selectedIvs[0]);
|
||||
start++;
|
||||
}
|
||||
else if (ItemId_GetHoldEffect(motherItem) == HOLD_EFFECT_POWER_ITEM)
|
||||
{
|
||||
whichParents[0] = 0;
|
||||
selectedIvs[0] = ItemId_GetSecondaryId(motherItem);
|
||||
RemoveIVIndexFromList(availableIVs, selectedIvs[0]);
|
||||
start++;
|
||||
}
|
||||
else if (ItemId_GetHoldEffect(fatherItem) == HOLD_EFFECT_POWER_ITEM)
|
||||
{
|
||||
whichParents[0] = 1;
|
||||
selectedIvs[0] = ItemId_GetSecondaryId(fatherItem);
|
||||
RemoveIVIndexFromList(availableIVs, selectedIvs[0]);
|
||||
start++;
|
||||
}
|
||||
|
||||
// Select which IVs that will be inherited.
|
||||
for (i = 0; i < howManyIVs; i++)
|
||||
for (i = start; i < howManyIVs; i++)
|
||||
{
|
||||
// Randomly pick an IV from the available list and stop from being chosen again.
|
||||
// BUG: Instead of removing the IV that was just picked, this
|
||||
@ -577,7 +591,7 @@ static void InheritIVs(struct Pokemon *egg, struct DayCare *daycare)
|
||||
}
|
||||
|
||||
// Determine which parent each of the selected IVs should inherit from.
|
||||
for (i = 0; i < howManyIVs; i++)
|
||||
for (i = start; i < howManyIVs; i++)
|
||||
{
|
||||
whichParents[i] = Random() % DAYCARE_MON_COUNT;
|
||||
}
|
||||
@ -703,6 +717,28 @@ static void BuildEggMoveset(struct Pokemon *egg, struct BoxPokemon *father, stru
|
||||
|
||||
numEggMoves = GetEggMoves(egg, sHatchedEggEggMoves);
|
||||
|
||||
#if P_MOTHER_EGG_MOVE_INHERITANCE >= GEN_6
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
if (sHatchedEggMotherMoves[i] != MOVE_NONE)
|
||||
{
|
||||
for (j = 0; j < numEggMoves; j++)
|
||||
{
|
||||
if (sHatchedEggMotherMoves[i] == sHatchedEggEggMoves[j])
|
||||
{
|
||||
if (GiveMoveToMon(egg, sHatchedEggMotherMoves[i]) == MON_HAS_MAX_MOVES)
|
||||
DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggMotherMoves[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
if (sHatchedEggFatherMoves[i] != MOVE_NONE)
|
||||
@ -722,6 +758,7 @@ static void BuildEggMoveset(struct Pokemon *egg, struct BoxPokemon *father, stru
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if P_TM_INHERITANCE < GEN_6
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
if (sHatchedEggFatherMoves[i] != MOVE_NONE)
|
||||
@ -737,6 +774,7 @@ static void BuildEggMoveset(struct Pokemon *egg, struct BoxPokemon *father, stru
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
if (sHatchedEggFatherMoves[i] == MOVE_NONE)
|
||||
|
Loading…
Reference in New Issue
Block a user