#===============================================================================
# Legendary Breeding - Forming eggs with Arceus
#===============================================================================
# Arceus cannot be bred with other species. However, Arceus can create eggs
# through its own power if it is holding the appropriate item. If so, calling
# the "pbArceusEggSpawn" script in an event will allow it to form an egg.
#
# Egg Creation:
#
# Dialga, Palkia, Giratina
# -Inherits Arceus's ball type. (Not if Master/Cherish Balls)
# -Inherits Arceus's nature 50% of the time.
# -80% chance to inherit each of Arceus's IV's.
# -Egg source text displays as "A Divine Force."
# -Arceus's held item is transferred to the egg.
#
# Arceus
# -Inherits Arceus's ball type. (Not if Master/Cherish Balls)
# -Inherits Arceus's nature 100% of the time.
# -Ignores IV inheritence, and instead always hatches with all 31 IV's.
# -Egg source text displays as "A Divine Force."
# -Arceus's held item is consumed.
#
# Type: Null
# -Inherits Arceus's ball type. (Not if Master/Cherish Balls)
# -Inherits Arceus's nature 100% of the time.
# -Inherits each of Arceus's IV's 100% of the time.
# -Egg source text displays as "A Corrupted Force."
# -Arceus's held item is consumed.
#===============================================================================
def pbChooseArceus(variableNumber,nameVarNumber)
pbChoosePokemon(variableNumber,nameVarNumber,proc { |pkmn| pkmn.isSpecies?(:ARCEUS) })
end
def pbArceusEggSpawn
if Kernel.pbConfirmMessage(_INTL("Would you like a Pokémon to form an egg?"))
if $Trainer.party.length>=6
Kernel.pbMessage(_INTL("There isn't enough space to carry an egg!"))
else
Kernel.pbMessage(_INTL("Please select a Pokémon."))
pbChooseArceus(1,3)
poke=pbGetPokemon(1)
if poke.isSpecies?(:ARCEUS)
if poke.egg?
Kernel.pbMessage(_INTL("That Pokémon must be hatched before it can form an egg."))
elsif (poke.isShadow? rescue false)
Kernel.pbMessage(_INTL("{1} must be purified before it can form an egg.",poke.name))
# Creates a Dialga egg
elsif poke.hasItem?(:ADAMANTORB)
Kernel.pbMessage(_INTL("{1} is radiating a mysterious energy...",poke.name))
if Kernel.pbConfirmMessage(_INTL("Should {1} create an egg?",poke.name))
pbHiddenMoveAnimation(poke)
pbGenerateEgg(:DIALGA,_I("A Divine Force."))
pkmn=$Trainer.lastParty
pkmn.setItem(:ADAMANTORB)
if poke.poke_ball != 4 && poke.poke_ball != 15
pkmn.poke_ball = poke.poke_ball
end
pkmn.nature = poke.nature if rand(10)<5
pkmn.iv[0]=poke.iv[0] if rand(10)<8
pkmn.iv[1]=poke.iv[1] if rand(10)<8
pkmn.iv[2]=poke.iv[2] if rand(10)<8
pkmn.iv[3]=poke.iv[3] if rand(10)<8
pkmn.iv[4]=poke.iv[4] if rand(10)<8
pkmn.iv[5]=poke.iv[5] if rand(10)<8
pbWait(1)
pbMEPlay("Pkmn get")
Kernel.pbMessage(_INTL("{1} formed an egg!",poke.name))
pbWait(5)
Kernel.pbMessage(_INTL("{1}'s {2} fused with the egg!",
poke.name,poke.item.name))
poke.item = nil
else
Kernel.pbMessage(_INTL("You decided not to form an egg."))
end
# Creates a Palkia egg
elsif poke.hasItem?(:LUSTROUSORB)
Kernel.pbMessage(_INTL("{1} is radiating a mysterious energy...",poke.name))
if Kernel.pbConfirmMessage(_INTL("Should {1} create an egg?",poke.name))
pbHiddenMoveAnimation(poke)
pbGenerateEgg(:PALKIA,_I("A Divine Force."))
pkmn=$Trainer.lastParty
pkmn.setItem(:LUSTROUSORB)
if poke.poke_ball != 4 && poke.poke_ball != 15
pkmn.poke_ball = poke.poke_ball
end
pkmn.nature = poke.nature if rand(10)<5
pkmn.iv[0]=poke.iv[0] if rand(10)<8
pkmn.iv[1]=poke.iv[1] if rand(10)<8
pkmn.iv[2]=poke.iv[2] if rand(10)<8
pkmn.iv[3]=poke.iv[3] if rand(10)<8
pkmn.iv[4]=poke.iv[4] if rand(10)<8
pkmn.iv[5]=poke.iv[5] if rand(10)<8
pbWait(1)
pbMEPlay("Pkmn get")
Kernel.pbMessage(_INTL("{1} formed an egg!",poke.name))
pbWait(5)
Kernel.pbMessage(_INTL("{1}'s {2} fused with the egg!",
poke.name,poke.item.name))
poke.item = nil
else
Kernel.pbMessage(_INTL("You decided not to form an egg."))
end
# Creates a Giratina egg
elsif poke.hasItem?(:GRISEOUSORB)
Kernel.pbMessage(_INTL("{1} is radiating a mysterious energy...",poke.name))
if Kernel.pbConfirmMessage(_INTL("Should {1} create an egg?",poke.name))
pbHiddenMoveAnimation(poke)
pbGenerateEgg(:GIRATINA,_I("A Divine Force."))
pkmn=$Trainer.lastParty
pkmn.setItem(:GRISEOUSORB)
if poke.poke_ball != 4 && poke.poke_ball != 15
pkmn.poke_ball = poke.poke_ball
end
pkmn.nature = poke.nature if rand(10)<5
pkmn.iv[0]=poke.iv[0] if rand(10)<8
pkmn.iv[1]=poke.iv[1] if rand(10)<8
pkmn.iv[2]=poke.iv[2] if rand(10)<8
pkmn.iv[3]=poke.iv[3] if rand(10)<8
pkmn.iv[4]=poke.iv[4] if rand(10)<8
pkmn.iv[5]=poke.iv[5] if rand(10)<8
pbWait(1)
pbMEPlay("Pkmn get")
Kernel.pbMessage(_INTL("{1} formed an egg!",poke.name))
pbWait(5)
Kernel.pbMessage(_INTL("{1}'s {2} fused with the egg!",
poke.name,poke.item.name))
poke.item = nil
else
Kernel.pbMessage(_INTL("You decided not to form an egg."))
end
# Creates an Arceus egg
elsif poke.hasItem?(:DIVINEPLATE)
Kernel.pbMessage(_INTL("{1} is radiating a mysterious energy...",poke.name))
if Kernel.pbConfirmMessage(_INTL("Should {1} create an egg?",poke.name))
pbHiddenMoveAnimation(poke)
pbGenerateEgg(:ARCEUS,_I("A Divine Force."))
pkmn=$Trainer.lastParty
if poke.poke_ball != 4 && poke.poke_ball != 15
pkmn.poke_ball = poke.poke_ball
end
pkmn.nature = poke.nature
pkmn.iv[0]=31
pkmn.iv[1]=31
pkmn.iv[2]=31
pkmn.iv[3]=31
pkmn.iv[4]=31
pkmn.iv[5]=31
pbWait(1)
pbMEPlay("Pkmn get")
Kernel.pbMessage(_INTL("{1} formed an egg!",poke.name))
pbWait(5)
Kernel.pbMessage(_INTL("{1}'s {2} shattered!",
poke.name,poke.item.name))
poke.item = nil
else
Kernel.pbMessage(_INTL("You decided not to form an egg."))
end
# Creates a Type: Null egg
elsif poke.hasItem?(:FALSEPLATE)
Kernel.pbMessage(_INTL("{1} is radiating a mysterious energy...",poke.name))
if Kernel.pbConfirmMessage(_INTL("Should {1} create an egg?",poke.name))
pbHiddenMoveAnimation(poke)
pbGenerateEgg(:TYPENULL,_I("A Corrupted Force."))
pkmn=$Trainer.lastParty
if poke.poke_ball != 4 && poke.poke_ball != 15
pkmn.poke_ball = poke.poke_ball
end
pkmn.nature = poke.nature
pkmn.iv[0]=poke.iv[0]
pkmn.iv[1]=poke.iv[1]
pkmn.iv[2]=poke.iv[2]
pkmn.iv[3]=poke.iv[3]
pkmn.iv[4]=poke.iv[4]
pkmn.iv[5]=poke.iv[5]
pbWait(1)
pbMEPlay("Pkmn get")
Kernel.pbMessage(_INTL("{1} formed an egg!",poke.name))
pbWait(5)
Kernel.pbMessage(_INTL("{1}'s {2} shattered!",
poke.name,poke.item.name))
poke.item = nil
else
Kernel.pbMessage(_INTL("You decided not to form an egg."))
end
else
Kernel.pbMessage(_INTL("{1} isn't holding the correct item to form an egg.",poke.name))
end
elsif $game_variables[1]<0
Kernel.pbMessage(_INTL("You decided not to form an egg."))
elsif !poke.isSpecies?(:ARCEUS)
Kernel.pbMessage(_INTL("That Pokémon isn't capable of forming an egg."))
end
end
$game_variables[1]=-1
end
end
#===============================================================================
# Legendary Breeding - Mew
#===============================================================================
# Defines Mew as a parent so that it may be used similarly to Ditto.
#===============================================================================
def pbIsMew?(pokemon)
egg_groups = pokemon.species_data.egg_groups
return egg_groups.include?(:Ancestor)
end
#===============================================================================
def pbcheckDittoCompat(pkmn1,pkmn2)
egg_groups1 = pkmn1.species_data.egg_groups
egg_groups2 = pkmn2.species_data.egg_groups
if egg_groups1.include?(:Skycrest) || egg_groups2.include?(:Skycrest) ||
egg_groups1.include?(:Bestial) || egg_groups2.include?(:Bestial) ||
egg_groups1.include?(:Titan) || egg_groups2.include?(:Titan) ||
egg_groups1.include?(:Overlord) || egg_groups2.include?(:Overlord) ||
egg_groups1.include?(:Nebulous) || egg_groups2.include?(:Nebulous) ||
egg_groups1.include?(:Enchanted) || egg_groups2.include?(:Enchanted) ||
egg_groups1.include?(:Ancestor) || egg_groups2.include?(:Ancestor) ||
egg_groups1.include?(:Ultra) || egg_groups2.include?(:Ultra)
return false
else
return true
end
end
def pbSortaDitto(pkmn1,pkmn2)
egg_groups1 = pkmn1.species_data.egg_groups
egg_groups2 = pkmn2.species_data.egg_groups
if egg_groups1.include?(:Ditto) || egg_groups2.include?(:Ditto)
return true
elsif egg_groups1.include?(:Ancestor) || egg_groups2.include?(:Ancestor)
return true
end
end
def pbDayCareGetCompat
return 0 if pbDayCareDeposited != 2
pkmn1 = $PokemonGlobal.daycare[0][0]
pkmn2 = $PokemonGlobal.daycare[1][0]
# Shadow Pokémon cannot breed
return 0 if pkmn1.shadowPokemon? || pkmn2.shadowPokemon?
# Certain forms of Legendary Pokemon cannot breed
return 0 if pkmn1.isSpecies?(:TORNADUS) && pkmn1.form != 1
return 0 if pkmn2.isSpecies?(:TORNADUS) && pkmn2.form != 1
return 0 if pkmn1.isSpecies?(:THUNDURUS) && pkmn1.form != 1
return 0 if pkmn2.isSpecies?(:THUNDURUS) && pkmn2.form != 1
return 0 if pkmn1.isSpecies?(:LANDORUS) && pkmn1.form != 1
return 0 if pkmn2.isSpecies?(:LANDORUS) && pkmn2.form != 1
return 0 if pkmn1.isSpecies?(:KYUREM) && pkmn1.form != 0
return 0 if pkmn2.isSpecies?(:KYUREM) && pkmn2.form != 0
return 0 if pkmn1.isSpecies?(:ZYGARDE) && pkmn1.form != 0
return 0 if pkmn2.isSpecies?(:ZYGARDE) && pkmn2.form != 0
return 0 if pkmn1.isSpecies?(:NECROZMA) && pkmn1.form != 0
return 0 if pkmn2.isSpecies?(:NECROZMA) && pkmn2.form != 0
# Pokémon in the Undiscovered egg group cannot breed
egg_groups1 = pkmn1.species_data.egg_groups
egg_groups2 = pkmn2.species_data.egg_groups
return 0 if egg_groups1.include?(:Undiscovered) ||
egg_groups2.include?(:Undiscovered)
# Ditto can't breed with Legendaries
return 0 if egg_groups1.include?(:Ditto) && !pbcheckDittoCompat(pkmn1,pkmn2)
return 0 if egg_groups2.include?(:Ditto) && !pbcheckDittoCompat(pkmn1,pkmn2)
# Pokémon that don't share an egg group (and neither is in the Ditto group)
# cannot breed
return 0 if !pbSortaDitto(pkmn1,pkmn2) &&
(egg_groups1 & egg_groups2).length == 0
# Mew cannot breed with Ditto or Ultra Beasts
return 0 if egg_groups1.include?(:Ancestor) && egg_groups2.include?(:Ultra)
return 0 if egg_groups1.include?(:Ultra) && egg_groups2.include?(:Ancestor)
# Pokémon with incompatible genders cannot breed
return 0 if !pbDayCareCompatibleGender(pkmn1, pkmn2)
# Pokémon can breed; calculate a compatibility factor
ret = 1
ret += 1 if pkmn1.species == pkmn2.species
ret += 1 if pkmn1.owner.id != pkmn2.owner.id
return ret
end
def pbDayCareGenerateEgg
return if pbDayCareDeposited != 2
raise _INTL("Can't store the egg.") if $Trainer.party_full?
pkmn0 = $PokemonGlobal.daycare[0][0]
pkmn1 = $PokemonGlobal.daycare[1][0]
mother = nil
father = nil
babyspecies = nil
ditto0 = pbIsDitto?(pkmn0)
ditto1 = pbIsDitto?(pkmn1)
#=============================================================================
# Legendary Breeding - Egg Species
#=============================================================================
# Egg is always partner's species when breeding with Ditto or Mew.
#=============================================================================
mew0=pbIsMew?(pkmn0)
mew1=pbIsMew?(pkmn1)
if pkmn0.female? || ditto0 || mew0
mother = pkmn0
father = pkmn1
babyspecies = (ditto0 || mew0) ? father.species : mother.species
else
mother = pkmn1
father = pkmn0
babyspecies = (ditto1 || mew1) ? father.species : mother.species
end
# Determine the egg's species
babyspecies = GameData::Species.get(babyspecies).get_baby_species(true, mother.item_id, father.item_id)
case babyspecies
#=============================================================================
# Legendary Breeding - Baby Species
#=============================================================================
# Gets different species for legendary offsping under certain conditions.
#=============================================================================
# Latias can produce Latias or Latios eggs.
when :LATIOS, :LATIAS
if GameData::Species.exists?(:LATIOS) && GameData::Species.exists?(:LATIAS)
babyspecies = [:LATIOS, :LATIAS][rand(2)]
end
# Manaphy produces Phione eggs unless mother is holding Mystic Water.
when :MANAPHY
if mother.item == :MYSTICWATER || father.item == :MYSTICWATER
babyspecies = :MANAPHY if GameData::Species.exists?(:MANAPHY)
else
babyspecies = :PHIONE if GameData::Species.exists?(:PHIONE)
end
# Mew can produce Mewtwo eggs while holding Berserk Gene.
when :MEW
if mother.item == :BERSERKGENE || father.item == :BERSERKGENE
babyspecies = :MEWTWO
elsif mother.isSpecies?(:MEW) && father.isSpecies?(:MEW)
babyspecies = :MEW
end
# Regigigas can produce other Regi's eggs depending on held item.
when :REGIGIGAS
if mother.item == :HARDSTONE || father.item == :HARDSTONE
babyspecies = :REGIROCK
elsif mother.item == :NEVERMELTICE || father.item == :NEVERMELTICE
babyspecies = :REGICE
elsif mother.item == :IRONBALL || father.item == :IRONBALL
babyspecies = :REGISTEEL
elsif mother.item == :LIGHTBALL || father.item == :LIGHTBALL
babyspecies = :REGIELEKI
elsif mother.item == :DRAGONFANG || father.item == :DRAGONFANG
babyspecies = :REGIDRAGO
end
#=============================================================================
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
# Generate egg
egg = Pokemon.new(babyspecies, Settings::EGG_LEVEL)
# Randomise personal ID
pid = rand(65536)
pid |= (rand(65536)<<16)
egg.personalID = pid
# Inheriting form
if [:BURMY, :SHELLOS, :BASCULIN, :FLABEBE, :PUMPKABOO, :ORICORIO, :ROCKRUFF, :MINIOR].include?(babyspecies)
newForm = mother.form
newForm = 0 if mother.isSpecies?(:MOTHIM)
egg.form = newForm
end
# Inheriting Alolan / Galarian form
if [:RATTATA, :SANDSHREW, :VULPIX, :DIGLETT,
:MEOWTH, :GEODUDE, :GRIMER, :PONYTA,
:SLOWPOKE, :FARFETCHD, :MRMIME, :CORSOLA,
:ZIGZAGOON, :DARUMAKA, :YAMASK, :STUNFISK].include?(babyspecies)
if mother.form == 1
egg.form = 1 if mother.hasItem?(:EVERSTONE)
elsif father.species_data.get_baby_species(true, mother.item_id, father.item_id) == babyspecies
egg.form = 1 if father.form == 1 && father.hasItem?(:EVERSTONE)
end
if mother.form == 2
egg.form = 2 if mother.hasItem?(:EVERSTONE)
elsif pbGetBabySpecies(father.species,mother.item,father.item)==babyspecies
egg.form = 2 if father.form == 2 && father.hasItem?(:EVERSTONE)
end
end
# Inheriting Moves
moves = []
othermoves = []
movefather = father
movemother = mother
if pbIsDitto?(movefather) && !mother.female?
movefather = mother
movemother = father
end
# Initial Moves
initialmoves = egg.getMoveList
for k in initialmoves
if k[0] <= Settings::EGG_LEVEL
moves.push(k[1])
elsif mother.hasMove?(k[1]) && father.hasMove?(k[1])
othermoves.push(k[1])
end
end
# Inheriting Natural Moves
for move in othermoves
moves.push(move)
end
# Inheriting Machine Moves
if Settings::BREEDING_CAN_INHERIT_MACHINE_MOVES
GameData::Item.each do |i|
atk = i.move
next if !atk
next if !egg.compatible_with_move?(atk)
next if !movefather.hasMove?(atk)
moves.push(atk)
end
end
# Inheriting Egg Moves
babyEggMoves = egg.species_data.egg_moves
if movefather.male?
babyEggMoves.each { |m| moves.push(m) if movefather.hasMove?(m) }
end
if Settings::BREEDING_CAN_INHERIT_EGG_MOVES_FROM_MOTHER
babyEggMoves.each { |m| moves.push(m) if movemother.hasMove?(m) }
end
# Volt Tackle
lightball = false
if (father.isSpecies?(:PIKACHU) || father.isSpecies?(:RAICHU)) &&
father.hasItem?(:LIGHTBALL)
lightball = true
end
if (mother.isSpecies?(:PIKACHU) || mother.isSpecies?(:RAICHU)) &&
mother.hasItem?(:LIGHTBALL)
lightball = true
end
if lightball && babyspecies == :PICHU && GameData::Move.exists?(:VOLTTACKLE)
moves.push(:VOLTTACKLE)
end
moves = moves.reverse
moves |= [] # remove duplicates
moves = moves.reverse
# Assembling move list
first_move_index = moves.length - Pokemon::MAX_MOVES
first_move_index = 0 if first_move_index < 0
finalmoves = []
for i in first_move_index...moves.length
finalmoves.push(Pokemon::Move.new(moves[i]))
end
# Inheriting Individual Values
ivs = {}
GameData::Stat.each_main { |s| ivs[s.id] = rand(Pokemon::IV_STAT_LIMIT + 1) }
ivinherit = []
for i in 0...2
parent = [mother,father][i]
ivinherit[i] = :HP if parent.hasItem?(:POWERWEIGHT)
ivinherit[i] = :ATTACK if parent.hasItem?(:POWERBRACER)
ivinherit[i] = :DEFENSE if parent.hasItem?(:POWERBELT)
ivinherit[i] = :SPECIAL_ATTACK if parent.hasItem?(:POWERLENS)
ivinherit[i] = :SPECIAL_DEFENSE if parent.hasItem?(:POWERBAND)
ivinherit[i] = :SPEED if parent.hasItem?(:POWERANKLET)
end
num = 0
r = rand(2)
2.times do
if ivinherit[r]!=nil
parent = [mother,father][r]
ivs[ivinherit[r]] = parent.iv[ivinherit[r]]
num += 1
break
end
r = (r+1)%2
end
limit = (mother.hasItem?(:DESTINYKNOT) || father.hasItem?(:DESTINYKNOT)) ? 5 : 3
loop do
freestats = []
GameData::Stat.each_main { |s| freestats.push(s.id) if !ivinherit.include?(s.id) }
break if freestats.length==0
r = freestats[rand(freestats.length)]
parent = [mother,father][rand(2)]
ivs[r] = parent.iv[r]
ivinherit.push(r)
num += 1
break if num>=limit
end
# Inheriting nature
new_natures = []
new_natures.push(mother.nature) if mother.hasItem?(:EVERSTONE)
new_natures.push(father.nature) if father.hasItem?(:EVERSTONE)
if new_natures.length > 0
new_nature = (new_natures.length == 1) ? new_natures[0] : new_natures[rand(new_natures.length)]
egg.nature = new_nature
end
# 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?
# This was causing a crash when generating the egg on my end.
# No idea if it's because of an incompatibility with my other plugins.
# genwildpoke.shiny = nil
egg.shiny = nil
egg.personalID = rand(2**16) | rand(2**16) << 16
end
end
# Inheriting ability from the mother
if !ditto0 || !ditto1 || !mew0 || !mew1
parent = (ditto0 || mew0) ? father : mother # The non-Ditto
if parent.hasHiddenAbility?
egg.ability_index = parent.ability_index if rand(100) < 60
elsif !ditto0 && !ditto1 && !mew0 && !mew1
if rand(100) < 80
egg.ability_index = mother.ability_index
else
egg.ability_index = (mother.ability_index + 1) % 2
end
end
end
# Inheriting Poké Ball from the mother (or father if it's same species as mother)
if !ditto0 || !ditto1 || !mew0 || !mew1
possible_balls = []
if mother.species == father.species
possible_balls.push(mother.poke_ball)
possible_balls.push(father.poke_ball)
else
possible_balls.push(pkmn0.poke_ball) if pkmn0.female? || ditto1
possible_balls.push(pkmn1.poke_ball) if pkmn1.female? || ditto0
possible_balls.push(pkmn0.poke_ball) if pkmn0.female? || mew1
possible_balls.push(pkmn1.poke_ball) if pkmn1.female? || mew0
end
possible_balls.delete(:MASTERBALL) # Can't inherit this Ball
possible_balls.delete(:CHERISHBALL) # Can't inherit this Ball
if possible_balls.length > 0
egg.poke_ball = possible_balls[0]
egg.poke_ball = possible_balls[rand(possible_balls.length)] if possible_balls.length > 1
end
end
# Set all stats
egg.happiness = 120
egg.iv = ivs
egg.moves = finalmoves
egg.calc_stats
egg.obtain_text = _INTL("Day-Care Couple")
egg.name = _INTL("Egg")
egg.steps_to_hatch = egg.species_data.hatch_steps
egg.givePokerus if rand(65536) < Settings::POKERUS_CHANCE
# Add egg to party
$Trainer.party[$Trainer.party.length] = egg
end