Commented out support for ID numbers in Pokémon filenames, added class GameData::EggGroup

This commit is contained in:
Maruno17
2021-02-06 21:30:19 +00:00
parent e9ed260277
commit 033434807d
30 changed files with 180 additions and 70 deletions

View File

@@ -92,7 +92,7 @@ module GameData
"WildItemCommon" => [0, "e", :Item],
"WildItemUncommon" => [0, "e", :Item],
"WildItemRare" => [0, "e", :Item],
"Compatibility" => [0, "*e", :PBEggGroups],
"Compatibility" => [0, "*e", :EggGroup],
"StepsToHatch" => [0, "v"],
"Height" => [0, "f"],
"Weight" => [0, "f"],
@@ -153,7 +153,7 @@ module GameData
@wild_item_common = hash[:wild_item_common]
@wild_item_uncommon = hash[:wild_item_uncommon]
@wild_item_rare = hash[:wild_item_rare]
@egg_groups = hash[:egg_groups] || [PBEggGroups::Undiscovered]
@egg_groups = hash[:egg_groups] || [:Undiscovered]
@hatch_steps = hash[:hatch_steps] || 1
@incense = hash[:incense]
@evolutions = hash[:evolutions] || []

View File

@@ -2,8 +2,8 @@ module GameData
class Species
def self.check_graphic_file(path, species, form = 0, gender = 0, shiny = false, shadow = false, subfolder = "")
try_subfolder = sprintf("%s/", subfolder)
species_data = self.get_species_form(species, form)
species_id = sprintf("%03d", (species_data) ? self.get(species_data.species).id_number : 0)
# species_data = self.get_species_form(species, form)
# species_id = sprintf("%03d", (species_data) ? self.get(species_data.species).id_number : 0)
try_species = species
try_form = (form > 0) ? sprintf("_%d", form) : ""
try_gender = (gender == 1) ? "_female" : ""
@@ -28,13 +28,14 @@ module GameData
end
end
# Look for a graphic matching this combination's parameters
for j in 0...2 # Try using the species' ID symbol and then its ID number
next if !try_species || (try_species == "000" && j == 1)
try_species_text = (j == 0) ? try_species : species_id
# for j in 0...2 # Try using the species' ID symbol and then its ID number
# next if !try_species || (try_species == "000" && j == 1)
# try_species_text = (j == 0) ? try_species : species_id
try_species_text = try_species
ret = pbResolveBitmap(sprintf("%s%s%s%s%s%s", path, try_subfolder,
try_species_text, try_form, try_gender, try_shadow))
return ret if ret
end
# end
end
return nil
end
@@ -42,16 +43,17 @@ module GameData
def self.check_egg_graphic_file(path, species, form, suffix = "")
species_data = self.get_species_form(species, form)
return nil if species_data.nil?
species_id = self.get(species_data.species).id_number
# species_id = self.get(species_data.species).id_number
if form > 0
ret = pbResolveBitmap(sprintf("%s%s_%d%s", path, species_data.species, form, suffix))
return ret if ret
ret = pbResolveBitmap(sprintf("%s%03d_%d%s", path, species_id, form, suffix))
return ret if ret
# ret = pbResolveBitmap(sprintf("%s%03d_%d%s", path, species_id, form, suffix))
# return ret if ret
end
ret = pbResolveBitmap(sprintf("%s%s%s", path, species_data.species, suffix))
return ret if ret
return pbResolveBitmap(sprintf("%s%03d%s", path, species_id, suffix))
return ret
# return ret if ret
# return pbResolveBitmap(sprintf("%s%03d%s", path, species_id, suffix))
end
def self.front_sprite_filename(species, form = 0, gender = 0, shiny = false, shadow = false)
@@ -148,16 +150,17 @@ module GameData
def self.footprint_filename(species, form = 0)
species_data = self.get_species_form(species, form)
return nil if species_data.nil?
species_id = self.get(species_data.species).id_number
# species_id = self.get(species_data.species).id_number
if form > 0
ret = pbResolveBitmap(sprintf("Graphics/Pokemon/Footprints/%s_%d", species_data.species, form))
return ret if ret
ret = pbResolveBitmap(sprintf("Graphics/Pokemon/Footprints/%03d_%d", species_id, form))
return ret if ret
# ret = pbResolveBitmap(sprintf("Graphics/Pokemon/Footprints/%03d_%d", species_id, form))
# return ret if ret
end
ret = pbResolveBitmap(sprintf("Graphics/Pokemon/Footprints/%s", species_data.species))
return ret if ret
return pbResolveBitmap(sprintf("Graphics/Pokemon/Footprints/%03d", species_id))
return ret
# return ret if ret
# return pbResolveBitmap(sprintf("Graphics/Pokemon/Footprints/%03d", species_id))
end
#===========================================================================
@@ -165,18 +168,18 @@ module GameData
def self.shadow_filename(species, form = 0)
species_data = self.get_species_form(species, form)
return nil if species_data.nil?
species_id = self.get(species_data.species).id_number
# species_id = self.get(species_data.species).id_number
# Look for species-specific shadow graphic
if form > 0
ret = pbResolveBitmap(sprintf("Graphics/Pokemon/Shadow/%s_%d", species_data.species, form))
return ret if ret
ret = pbResolveBitmap(sprintf("Graphics/Pokemon/Shadow/%03d_%d", species_id, form))
return ret if ret
# ret = pbResolveBitmap(sprintf("Graphics/Pokemon/Shadow/%03d_%d", species_id, form))
# return ret if ret
end
ret = pbResolveBitmap(sprintf("Graphics/Pokemon/Shadow/%s", species_data.species))
return ret if ret
ret = pbResolveBitmap(sprintf("Graphics/Pokemon/Shadow/%03d", species_id))
return ret if ret
# ret = pbResolveBitmap(sprintf("Graphics/Pokemon/Shadow/%03d", species_id))
# return ret if ret
# Use general shadow graphic
return pbResolveBitmap(sprintf("Graphics/Pokemon/Shadow/%d", species_data.shadow_size))
end
@@ -196,16 +199,16 @@ module GameData
def self.check_cry_file(species, form)
species_data = self.get_species_form(species, form)
return nil if species_data.nil?
species_id = self.get(species_data.species).id_number
# species_id = self.get(species_data.species).id_number
if form > 0
ret = sprintf("Cries/%s_%d", species_data.species, form)
return ret if pbResolveAudioSE(ret)
ret = sprintf("Cries/%03d_%d", species_id, form)
return ret if pbResolveAudioSE(ret)
# ret = sprintf("Cries/%03d_%d", species_id, form)
# return ret if pbResolveAudioSE(ret)
end
ret = sprintf("Cries/%s", species_data.species)
return ret if pbResolveAudioSE(ret)
ret = sprintf("Cries/%03d", species_id)
# return ret if pbResolveAudioSE(ret)
# ret = sprintf("Cries/%03d", species_id)
return (pbResolveAudioSE(ret)) ? ret : nil
end

View File

@@ -0,0 +1,109 @@
module GameData
class EggGroup
attr_reader :id
attr_reader :real_name
DATA = {}
extend ClassMethods
include InstanceMethods
def register(hash)
self::DATA[hash[:id]] = self.new(hash)
end
# Yields all data in alphabetical order.
def each
keys = self::DATA.keys.sort { |a, b| self::DATA[a].real_name <=> self::DATA[b].real_name }
keys.each { |key| yield self::DATA[key] }
end
def self.load; end
def self.save; end
def initialize(hash)
@id = hash[:id]
@real_name = hash[:name] || "Unnamed"
end
# @return [String] the translated name of this egg group
def name
return _INTL(@real_name)
end
end
end
GameData::EggGroup.register({
:id => :Undiscovered,
:name => _INTL("Undiscovered")
})
GameData::EggGroup.register({
:id => :Monster,
:name => _INTL("Monster")
})
GameData::EggGroup.register({
:id => :Water1,
:name => _INTL("Water 1")
})
GameData::EggGroup.register({
:id => :Bug,
:name => _INTL("Bug")
})
GameData::EggGroup.register({
:id => :Flying,
:name => _INTL("Flying")
})
GameData::EggGroup.register({
:id => :Field,
:name => _INTL("Field")
})
GameData::EggGroup.register({
:id => :Fairy,
:name => _INTL("Fairy")
})
GameData::EggGroup.register({
:id => :Grass,
:name => _INTL("Grass")
})
GameData::EggGroup.register({
:id => :Humanlike,
:name => _INTL("Humanlike")
})
GameData::EggGroup.register({
:id => :Water3,
:name => _INTL("Water 3")
})
GameData::EggGroup.register({
:id => :Mineral,
:name => _INTL("Mineral")
})
GameData::EggGroup.register({
:id => :Amorphous,
:name => _INTL("Amorphous")
})
GameData::EggGroup.register({
:id => :Water2,
:name => _INTL("Water 2")
})
GameData::EggGroup.register({
:id => :Ditto,
:name => _INTL("Ditto")
})
GameData::EggGroup.register({
:id => :Dragon,
:name => _INTL("Dragon")
})

View File

@@ -1,19 +0,0 @@
module PBEggGroups
Undiscovered = 0 # NoEggs, None, NA
Monster = 1
Water1 = 2
Bug = 3
Flying = 4
Field = 5 # Ground
Fairy = 6
Grass = 7 # Plant
Humanlike = 8 # Humanoid, Humanshape, Human
Water3 = 9
Mineral = 10
Amorphous = 11 # Indeterminate
Water2 = 12
Ditto = 13
Dragon = 14
def self.maxValue; 14; end
end

View File

@@ -105,7 +105,7 @@ end
# Check compatibility of Pokémon in the Day Care.
#===============================================================================
def pbIsDitto?(pkmn)
return pkmn.species_data.egg_groups.include?(PBEggGroups::Ditto)
return pkmn.species_data.egg_groups.include?(:Ditto)
end
def pbDayCareCompatibleGender(pkmn1, pkmn2)
@@ -127,12 +127,12 @@ def pbDayCareGetCompat
# 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?(PBEggGroups::Undiscovered) ||
egg_groups2.include?(PBEggGroups::Undiscovered)
return 0 if egg_groups1.include?(:Undiscovered) ||
egg_groups2.include?(:Undiscovered)
# Pokémon that don't share an egg group (and neither is in the Ditto group)
# cannot breed
return 0 if !egg_groups1.include?(PBEggGroups::Ditto) &&
!egg_groups2.include?(PBEggGroups::Ditto) &&
return 0 if !egg_groups1.include?(:Ditto) &&
!egg_groups2.include?(:Ditto) &&
(egg_groups1 & egg_groups2).length == 0
# Pokémon with incompatible genders cannot breed
return 0 if !pbDayCareCompatibleGender(pkmn1, pkmn2)

View File

@@ -151,7 +151,7 @@ end
class NonlegendaryRestriction
def isValid?(pkmn)
return true if !pkmn.genderless?
return false if pkmn.species_data.egg_groups.include?(PBEggGroups::Undiscovered)
return false if pkmn.species_data.egg_groups.include?(:Undiscovered)
return true
end
end

View File

@@ -296,8 +296,8 @@ def pbHasEgg?(species)
compatSpecies = (evoSpecies && evoSpecies[0]) ? evoSpecies[0][2] : species
species_data = GameData::Species.try_get(compatSpecies)
compat = species_data.egg_groups
return false if compat.include?(PBEggGroups::Undiscovered)
return false if compat.include?(PBEggGroups::Ditto)
return false if compat.include?(:Undiscovered)
return false if compat.include?(:Ditto)
baby = EvolutionHelper.baby_species(species)
return true if species == baby # Is a basic species
baby = EvolutionHelper.baby_species(species, true)

View File

@@ -974,8 +974,8 @@ def pbPokemonEditor
[_INTL("WildItemCommon"), ItemProperty, _INTL("Item commonly held by wild Pokémon of this species.")],
[_INTL("WildItemUncommon"), ItemProperty, _INTL("Item uncommonly held by wild Pokémon of this species.")],
[_INTL("WildItemRare"), ItemProperty, _INTL("Item rarely held by wild Pokémon of this species.")],
[_INTL("Compat1"), EnumProperty2.new(PBEggGroups), _INTL("Compatibility group (egg group) for breeding purposes.")],
[_INTL("Compat2"), EnumProperty2.new(PBEggGroups), _INTL("Compatibility group (egg group) for breeding purposes.")],
[_INTL("Compat1"), EggGroupProperty, _INTL("Compatibility group (egg group) for breeding purposes.")],
[_INTL("Compat2"), EggGroupProperty, _INTL("Compatibility group (egg group) for breeding purposes.")],
[_INTL("StepsToHatch"), LimitProperty.new(99999), _INTL("Number of steps until an egg of this species hatches.")],
[_INTL("Incense"), ItemProperty, _INTL("Item needed to be held by a parent to produce an egg of this species.")],
[_INTL("Evolutions"), EvolutionsProperty.new, _INTL("Evolution paths of this species.")],
@@ -1067,7 +1067,7 @@ def pbPokemonEditor
data[5] = data[6] if !data[5] # Type1
data[6] = data[5] if !data[6] # Type2
egg_groups = [data[26], data[27]].uniq.compact # Egg groups
egg_groups.push(PBEggGroups::Undiscovered) if egg_groups.length == 0
egg_groups.push(:Undiscovered) if egg_groups.length == 0
abilities = [data[17], data[18]].uniq.compact # Abilities
hidden_abilities = [data[19], data[20], data[21], data[22]].uniq.compact # Hidden abilities
# Construct species hash

View File

@@ -436,6 +436,23 @@ end
module EggGroupProperty
def self.set(_settingname, oldsetting)
ret = pbChooseEggGroupList((oldsetting) ? oldsetting : nil)
return ret || oldsetting
end
def self.defaultValue
return nil
end
def self.format(value)
return (value && GameData::EggGroup.exists?(value)) ? GameData::EggGroup.get(value).real_name : "-"
end
end
class IVsProperty
def initialize(limit)
@limit = limit

View File

@@ -212,6 +212,16 @@ def pbChooseNatureList(default = nil)
return pbChooseList(commands, default, nil, -1)
end
def pbChooseEggGroupList(default = nil)
commands = []
i = 0
GameData::EggGroup.each do |g|
commands.push([i, g.name, g.id])
i += 1
end
return pbChooseList(commands, default, nil, -1)
end
def pbChooseBallList(defaultMoveID = -1)
cmdwin = pbListWindow([], 200)
commands = []

View File

@@ -295,12 +295,7 @@ module Compiler
f.write(sprintf("EggMoves = %s\r\n", species.egg_moves.join(",")))
end
if species.egg_groups.length > 0
f.write("Compatibility = ")
species.egg_groups.each_with_index do |group, i|
f.write(",") if i > 0
f.write(getConstantName(PBEggGroups, group))
end
f.write("\r\n")
f.write(sprintf("Compatibility = %s\r\n", species.egg_groups.join(",")))
end
f.write(sprintf("StepsToHatch = %d\r\n", species.hatch_steps))
f.write(sprintf("Height = %.1f\r\n", species.height / 10.0))
@@ -395,12 +390,7 @@ module Compiler
f.write(sprintf("EggMoves = %s\r\n", species.egg_moves.join(",")))
end
if species.egg_groups.length > 0 && species.egg_groups != base_species.egg_groups
f.write("Compatibility = ")
species.egg_groups.each_with_index do |group, i|
f.write(",") if i > 0
f.write(getConstantName(PBEggGroups, group))
end
f.write("\r\n")
f.write(sprintf("Compatibility = %s\r\n", species.egg_groups.join(",")))
end
f.write(sprintf("StepsToHatch = %d\r\n", species.hatch_steps)) if species.hatch_steps != base_species.hatch_steps
f.write(sprintf("Height = %.1f\r\n", species.height / 10.0)) if species.height != base_species.height