Generalised form inheritance, making use of species flags

This commit is contained in:
Maruno17
2021-09-02 21:05:53 +01:00
parent 86cbcad382
commit cef3d08917
11 changed files with 266 additions and 21 deletions

View File

@@ -223,6 +223,13 @@ module GameData
return GameData::GenderRatio.get(@gender_ratio).single_gendered?
end
def base_form
@flags.each do |flag|
return $~[1].to_i if flag[/^DefaultForm(\d+)$/i]
end
return @form
end
def has_flag?(flag)
return @flags.any? { |f| f.downcase == flag.downcase }
end

View File

@@ -192,23 +192,18 @@ def pbDayCareGenerateEgg
pid = rand(65536)
pid |= (rand(65536)<<16)
egg.personalID = pid
# Inheriting form
if [:BURMY, :SHELLOS, :BASCULIN, :FLABEBE, :PUMPKABOO, :ORICORIO, :ROCKRUFF, :MINIOR].include?(babyspecies)
parent = (ditto0 || (!pkmn0.female? && ditto1)) ? father : mother
newForm = parent.form
newForm = 0 if parent.isSpecies?(:MOTHIM)
egg.form = newForm
# Inherit form from mother
parent = (ditto0 || (!pkmn0.female? && ditto1)) ? father : mother
if parent.species_data.has_flag?("InheritFormFromMother")
egg.form = parent.form
end
# Inheriting regional form
if [:RATTATA, :SANDSHREW, :VULPIX, :DIGLETT, :MEOWTH, :GEODUDE, :GRIMER,
:PONYTA, :SLOWPOKE, :FARFETCHD, :MRMIME, :ARTICUNO, :ZAPDOS, :MOLTRES,
:CORSOLA, :ZIGZAGOON, :DARUMAKA, :YAMASK, :STUNFISK].include?(babyspecies)
if mother.form > 0
egg.form = mother.form if mother.hasItem?(:EVERSTONE)
elsif father.form > 0 &&
father.species_data.get_baby_species(true, mother.item_id, father.item_id) == babyspecies
egg.form = father.form if father.hasItem?(:EVERSTONE)
end
# Inherit form from parent holding an Ever Stone
[mother, father].each do |parent|
next if !parent.species_data.get_baby_species(true, mother.item_id, father.item_id) == babyspecies
next if !parent.species_data.has_flag?("InheritFormWithEverStone")
next if !parent.hasItem?(:EVERSTONE)
egg.form = parent.form
break
end
# Inheriting Moves
moves = []

View File

@@ -1114,7 +1114,7 @@ class Pokemon
def initialize(species, level, owner = $Trainer, withMoves = true, recheck_form = true)
species_data = GameData::Species.get(species)
@species = species_data.species
@form = species_data.form
@form = species_data.base_form
@forced_form = nil
@time_form_set = nil
self.level = level