• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
Modifying Egg Generation

v19 Modifying Egg Generation N/A

This resource pertains to version 19 of Pokémon Essentials.
Pokémon Essentials Version
v19.1 ➖
The daycare is useful for competitive breeding- but all the Pokémon are almost always identical to the mother! How boring! Let's come up with some ways to let players get creative with breeding!




This tutorial is currently for v19, but I'll get around to showing how this works in v18! (It's very similar, though, just some calls being changed)

First things first, let's take a look at what's already there in Essentials! We're going to head to Overworld_DayCare and find this section:

Ruby:
Expand Collapse Copy
  # Determine the egg's species
  babyspecies = GameData::Species.get(babyspecies).get_baby_species(true, mother.item_id, father.item_id)
  case babyspecies
  when :MANAPHY
    babyspecies = :PHIONE if GameData::Species.exists?(:PHIONE)
  when :NIDORANfE, :NIDORANmA
    if GameData::Species.exists?(:NIDORANfE) && GameData::Species.exists?(:NIDORANmA)
      babyspecies = [:NIDORANfE, :NIDORANmA][rand(2)]
    end
  when :VOLBEAT, :ILLUMISE
    if GameData::Species.exists?(:VOLBEAT) && GameData::Species.exists?(:ILLUMISE)
      babyspecies = [:VOLBEAT, :ILLUMISE][rand(2)]
    end
  end
It might seem like a lot, but when we break it down, we'll see it's actually pretty easy to work through!

  • babyspecies = GameData::Species.get(babyspecies).get_bably_species(true, mother.item_id, father.item_id) just generates the baby's species! It looks at the mother and father's species, what items they're holding, etc, and then returns the symbol for the baby's species!
  • case babyspecies is to start what's basically just a series of if conditionals, but it makes things a little easier! Instead of writing something like:
Ruby:
Expand Collapse Copy
if babyspecies == :MANAPHY
#(code)
elsif babyspecies == :VOLBEAT || babyspecies == :ILLUMISE
#(code)
end
We can just do it as
Ruby:
Expand Collapse Copy
case babyspecies

when :MANAPHY
#code
when :VOLBEART,:ILLUMISE
#code
end

  • when :MANAPHY is our check for if the baby would be a Manaphy when generated. And if this is true, then it goes to this next line-
  • babyspecies = :PHIONE if GameData::Species.exists?:PHIONE) , which sets the baby to be a Phione instead! if GameData::Species.exists?:PHIONE) is a check to make sure that there's actually a Phione species defined in the game, so we don't run into any errors
  • when :NIDORANfE, :NIDORANmA- this is a check that looks for both Nidoran species
  • if GameData::Species.exists?(:NIDORANfE) && GameData::Species.exists?(:NIDORANmA) - this double-checks to make sure both species have been defined
  • babyspecies = [:NIDORANfE, :NIDORANmA][rand(2)] - this randomly selects a species from the array, and sets the baby to it!

There's more we can do, of course, but that's all that there is in Essentials! Let's go over how to add in some new cases!

Manaphione babies
Have you seen RacieBeep's sprite recreations for the beta legendary beasts? They're adorable! So, let's say that I really want to include them in my game, and I want to make it where breeding Suicune with Ditto gives me a Sui. (You could just copy+paste the Manaphy section and change the species, but I'm going to go step-by-step just for clarity's sake lol)

The first steps will actually be in the pokemon.txt file, though- right now, Suicune is in the Undefined group, so I can't get any eggs! I can just change it to whatever I want, and since it's still genderless, it'll only be able to breed with Ditto!

Now onto the script:
  • Start with the check for the egg species- when: SUICUNE , because we'll be adding this in the case babyspecies section
  • We want to make sure Sui exists in the code, so we'll do if GameData::Species.exists?(:SUI).
  • And now we just change the species with babyspecies = :SUI
  • Normally, we'd add an "end" to close out the earlier if when we checked if Sui exists in the code. But, since this check is small and moving it wouldn't affect our ability to read it, we can just as easily move it to be part of the same line, if we put the conditional afterthe command, like so:
    • babyspecies = :SUI if GameData::Species.exists?(:SUI)


It should look like this!
Ruby:
Expand Collapse Copy
  when :SUICUNE
    babyspecies = :SUI if GameData::Species.exists?(:SUI)

Eggs that might hatch into counterparts
Let's add some code that will give Miltank a chance to lay Tauros eggs, or vice versa! (Again, you could do this by literally just copy+pasting the code for Illumise/Volbeat and changing the names, but I'm gonna go step-by-step for the example)

  • We want this to take effect if the baby would be a Miltank or a Tauros, so we start with when :MILTANK, :TAUROS
  • As a safety measure, we'll make sure both species exist- if GameData::Species.exists?(:MILTANK) && GameData::Species.exists?(:TAUROS)
  • Now we set the babyspecies to pick randomly out of an array that lists the species- babyspecies = [:MILTANK, :TAUROS][rand(2)]
  • And one last end to close out our earlier if!

It'll look like this!
Ruby:
Expand Collapse Copy
  when :MILTANK, :TAUROS
    if GameData::Species.exists?(:MILTANK) && GameData::Species.exists?(:TAUROS)
      babyspecies = [:MILTANK, :TAUROS][rand(2)]
    end


Broodmother
Note- I'm going to use the Fakemon from Uranium for this example, because I don't want to have to come up with new Fakemon names just for a tutorial lol.

In Pokémon Uranium, Seikamater is the mother of all insects in the region, and lays all of their eggs! We never get to see this breeding practice in action, though... so let's code it now!

  • We want this to take effect when the baby is another Seikamater, so we start with when :SEIKAMATER
  • As a safety measure, we'll make sure all the offspring species exist- if GameData::Species.exists?(:SMORE) && GameData::Species.exists?(:TRICWE) && GameData::Species.exists?(:SPONEE) && GameData::Species.exists?(:CUBBUG)
  • Now I want my baby to pick from the array- but since it's four species, I have to remember to use rand(4) instead of rand(2) like our earlier examples. babyspecies = [:SMORE,:TRICWE, :SPONEE,:CUBBUG][rand(4)]
  • And one last end for my earlier if!
It should look like this!
Ruby:
Expand Collapse Copy
  when :SEIKAMATER
    if GameData::Species.exists?(:SMORE) && GameData::Species.exists?(:TRICWE) && GameData::Species.exists?(:SPONEE) && GameData::Species.exists?(:CUBBUG)
      babyspecies = [:SMORE,:TRICWE, :SPONEE,:CUBBUG][rand(4)]
    end

Invasive Species
Mimikyu is just so, so desperate for that sweet Pikachu love. It's even begun to sneak its eggs into the Day Care in hopes of fooling trainers! Now, this doesn't happen all the time- I'd say maybe 1 in 10, at most. So how should we set it up?
  • First, the check for the species. I'm going to check if it's either Pikachu or Pichu, just to stay consistent with the lore. That'll mean I write when :PIKACHU,:PICHU
  • Next, double-checking that Mimikyu exists- if GameData::Species.exists?(:MIMIKYU)
  • Now we're going to add a random chance element! rand(100) will generate a random integer between 0 and 99. I said earlier that I wanted this to be about a 1/10 chance, so I'll tell the game to only do this if the number is less than 10 - if rand(100)<10
  • I could just nestle this conditional underneath my Mimikyu conditional, but it'll be easier for me to combine them with &&, so I don't have to worry about an extra "end". I'll write it as if GameData::Species.exists?(:MIMIKYU) && rand(100)<10
  • babyspecies = :MIMIKYU to make the baby a Mimikyu
  • And one final end to close it out!

It should look like this!
Ruby:
Expand Collapse Copy
  when :PIKACHU,:PICHU
    if GameData::Species.exists?(:MIMIKYU) && rand(100)<10
      babyspecies = :MIMIKYU
    end

Invasive species change regardless of parents
Ooh, freaky- no matter what Pokémon I put in the Day Care, 1/4 of my eggs comes back as this strange, invasive species...

This is going to be a little different from our past examples! Since this setup doesn't care about the baby's initial species at all, we're actually going to work outside of it. We'll put this code under the last end of that case babyspecies, so we should be writing our new code just above # Generate egg.

Using what we know about rand(), this should be a cinch!

Ruby:
Expand Collapse Copy
if rand(100)<25
babyspecies = :INVADER  if GameData::Species.exists?(:INVADER)
end

Cross-breeding species
Well, I'm having a lot of fun, but nothing here really rewards the player for breeding two unique species together! Let's say that I have a new Fakemon that's a crossbreed of Plusle and Minun; a Neutrun, if you will. I want this Pokémon to hatch from any pairing of a Plusle and Minun together, but I still want a Plusle and Plusle to give a Plusle, or a Minun and Minun to give a minun.

While this does need to check the parent's species, the baby's species isn't relevant, so like the last example, we'll be writing our code outside of the case babyspecies section!

Next, we're going to be making use of the .include?() command! This is really useful- you use it with an array, and it returns true if the array contains whatever's inside your parenthesis!

So, we'll start off simple- we want to check if the mother is a Plusle or Minun. Luckily, we're still working in pbDayCareGenerateEgg, which got the mother's species earlier, so all we need to do is write the check!

Ruby:
Expand Collapse Copy
if [:PLUSLE, :MINUN].include?(mother.species)
Now, I believe that .include? just returns true if there's any matches, so we want the check for the father's species to be separate, to make sure that both the mother and father are Plusle/Minun, and not just one of them. So we add another check for the father-

Ruby:
Expand Collapse Copy
if [:PLUSLE, :MINUN].include?(mother.species) && [:PLUSLE, :MINUN].include?(father.species)
But one last thing! I want to make sure that the mother and father aren't the same species, so I'll make sure that !mother.species==father.species

Ruby:
Expand Collapse Copy
if [:PLUSLE, :MINUN].include?(mother.species) && [:PLUSLE, :MINUN].include?(father.species) && !mother.species==father.species

And now we'll just carry on as usual!

Ruby:
Expand Collapse Copy
if [:PLUSLE, :MINUN].include?(mother.species) && [:PLUSLE, :MINUN].include?(father.species) && !mother.species==father.species
     babyspecies = :NEUTRUN if GameData::Species.exists?(:NEUTRUN)
end

Cross-Breed Forms
Well, Neutrun's fun, but I want to implement something like those cool Pokémon Variations that were really popular on tumblr! I'm gonna make a Rose form Bulbasaur that appears if it's fathered by a Roserade!

First thing, of course, is to define the Rose form in pokemonforms.txt. I'm going to make Rose Bulbasaur form number two, so that it can evolve into a Rose Venusaur without bumping against the Mega Venusaur slot. (Which is Venusaur-1 right now)

Now that that's done, it's time to make the code to change the form! But since this is editing the form of the Pokemon, not the species, I want to put this code after the species of the egg has been defined. Luckily, this is clearly marked with # Inheriting form!

The conditional that currently exists is for passing on forms in certain species, so I want to work outside of that, either before the if [:BURMY, :SHELLOS,... section or after its end.

I want to check for two things:
  • Is the egg going to hatch into a Bulbasaur?
  • Is the father a member of the Roselia line?
For the first part, I could check for each member of the Bulbasaur line- [:BULBASAUR,:IVYSAUR, :VENUSAUR].include?(mother.species) But it'd actually just be easier to check babyspecies! Even though babyspecies has already served its purpose in generating the egg, it's still there for us to reference in this method!

Ruby:
Expand Collapse Copy
if babyspecies == :BULBASAUR
And now we just write the check for the father- since Budew is a baby Pokémon, I can leave it off the list, so it's just

Ruby:
Expand Collapse Copy
if babyspecies == :BULBASAUR && [:ROSELIA,:ROSERADE].include?(father.species)

Now we just set the egg's form and close it out!

Ruby:
Expand Collapse Copy
if babyspecies == :BULBASAUR && [:ROSELIA,:ROSERADE].include?(father.species)
      egg.form = 2
end

Cross-breeding depending on parent's types
Turns out these Pokémon variations are really hard... I don't want to come up with a new form for every species in its egg group! What if I just did something that checks the type of the father?

I'll make a new Fire Flower form for Bulbasaur, for a Fire-type father, and set it to form 3. We can look back at the earlier code for the Rose form, which handled a lot of what we'll need for this:

Ruby:
Expand Collapse Copy
if babyspecies == :BULBASAUR && [:ROSELIA,:ROSERADE].include?(father.species)
      egg.form = 3
end
But, ugh, am I going to have to check for every Fire-type that can breed with Bulbasaur?

Nope! Because the mother and father variables have all the information about those Pokémon- so I can use a regular check for the type!
Ruby:
Expand Collapse Copy
if babyspecies == :BULBASAUR && father.hasType?(:FIRE)
      egg.form = 3
end

Shiny Parents, Shiny Offspring
I think it's unfair that shiny parents don't affect my shiny rates at all! So what can I do to change this?

The shiny section is a bit further down, and it looks like this:
Ruby:
Expand Collapse Copy
  # Masuda method and Shiny Charm
  shinyretries = 0
  shinyretries += 5 if father.owner.language != mother.owner.language
  shinyretries += 2 if GameData::Item.exists?(:SHINYCHARM) && $PokemonBag.pbHasItem?(:SHINYCHARM)
  if shinyretries>0
    shinyretries.times do
      break if egg.shiny?
      egg.personalID = rand(2**16) | rand(2**16) << 16
    end
  end
From looking at this, we can see that this doesn't create a new shiny rate, but instead gives us extra "tries" for a shiny when the game checks. That makes things easier on us! We just need to copy the formatting of the shinyretries section!

Let's add an extra 5 chances if either parent is shiny:
Ruby:
Expand Collapse Copy
  shinyretries += 5 if father.shiny? || mother.shiny?
This will add 5 extra tries if either parent is shiny, or if both of them are! If I wanted to make them stack, I'd make each a separate check, like this:

Ruby:
Expand Collapse Copy
  shinyretries += 5 if father.shiny?
  shinyretries += 5 if mother.shiny?

Glossary
I think this post would get way too long if I kept going with examples like these lol, so I'm going to create a little list of things you could check.
  • $game_variables[x] and $game_switches[x]can be used to check switches and global variables- you could make special things happen at different points in the game!
  • All attributes of the mother and father can be referenced- check the script section Pokémon for a list of checks you could run!
  • You can always get the time with pbGetTimeNow- what if you made a canine Pokémon that hatched into a werewolf on full moons? Or a star Pokemon with different zodiac forms?
  • $PokemonBag.pbHasItem?() can check if the player has a certain item in their bag!

And check out the page on Editing a Pokémon in the Essentials wiki for things you could change about the baby!
Credits
This is a tutorial, so no credits needed!
Author
TechSkylander1518
Views
3,125
First release
Last update

Ratings

5.00 star(s) 2 ratings

More resources from TechSkylander1518

Latest reviews

Great tutorial. Very in-depth and easy to understand.
TechSkylander1518
TechSkylander1518
Thank you!!
Back
Top