Created and implemented GameData::Species

This commit is contained in:
Maruno17
2020-12-24 21:25:16 +00:00
parent 1ffeddc41c
commit ad21fc92cb
91 changed files with 6733 additions and 7963 deletions

View File

@@ -2,18 +2,11 @@
# Data caches.
#===============================================================================
class PokemonTemp
attr_accessor :metadata
attr_accessor :townMapData
attr_accessor :encountersData
attr_accessor :phoneData
attr_accessor :regionalDexes
attr_accessor :speciesData
attr_accessor :speciesEggMoves
attr_accessor :speciesMetrics
attr_accessor :speciesMovesets
attr_accessor :speciesTMData
attr_accessor :speciesShadowMovesets
attr_accessor :pokemonFormToSpecies
attr_accessor :trainersData
attr_accessor :moveToAnim
attr_accessor :battleAnims
@@ -21,18 +14,11 @@ end
def pbClearData
if $PokemonTemp
$PokemonTemp.metadata = nil
$PokemonTemp.townMapData = nil
$PokemonTemp.encountersData = nil
$PokemonTemp.phoneData = nil
$PokemonTemp.regionalDexes = nil
$PokemonTemp.speciesData = nil
$PokemonTemp.speciesEggMoves = nil
$PokemonTemp.speciesMetrics = nil
$PokemonTemp.speciesMovesets = nil
$PokemonTemp.speciesTMData = nil
$PokemonTemp.speciesShadowMovesets = nil
$PokemonTemp.pokemonFormToSpecies = nil
$PokemonTemp.trainersData = nil
$PokemonTemp.moveToAnim = nil
$PokemonTemp.battleAnims = nil
@@ -95,96 +81,6 @@ def pbLoadRegionalDexes
return $PokemonTemp.regionalDexes
end
#===============================================================================
# Methods to get Pokémon species data.
#===============================================================================
def pbLoadSpeciesData
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
if !$PokemonTemp.speciesData
$PokemonTemp.speciesData = load_data("Data/species.dat") || []
end
return $PokemonTemp.speciesData
end
def pbGetSpeciesData(species, form = 0, species_data_type = -1)
species = getID(PBSpecies, species)
s = pbGetFSpeciesFromForm(species, form)
species_data = pbLoadSpeciesData
if species_data_type < 0
return species_data[s] || []
end
return species_data[s][species_data_type] if species_data[s] && species_data[s][species_data_type]
case species_data_type
when SpeciesData::TYPE2
return nil
when SpeciesData::BASE_STATS
return [1, 1, 1, 1, 1, 1]
when SpeciesData::EFFORT_POINTS
return [0, 0, 0, 0, 0, 0]
when SpeciesData::STEPS_TO_HATCH, SpeciesData::HEIGHT, SpeciesData::WEIGHT
return 1
end
return 0
end
#===============================================================================
# Methods to get egg moves data.
#===============================================================================
def pbLoadEggMovesData
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
if !$PokemonTemp.speciesEggMoves
$PokemonTemp.speciesEggMoves = load_data("Data/species_eggmoves.dat") || []
end
return $PokemonTemp.speciesEggMoves
end
def pbGetSpeciesEggMoves(species, form = 0)
species = getID(PBSpecies, species)
s = pbGetFSpeciesFromForm(species, form)
egg_moves_data = pbLoadEggMovesData
return egg_moves_data[s] || []
end
#===============================================================================
# Method to get Pokémon species metrics (sprite positioning) data.
#===============================================================================
def pbLoadSpeciesMetrics
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
if !$PokemonTemp.speciesMetrics
$PokemonTemp.speciesMetrics = load_data("Data/species_metrics.dat") || []
end
return $PokemonTemp.speciesMetrics
end
#===============================================================================
# Methods to get Pokémon moveset data.
#===============================================================================
def pbLoadMovesetsData
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
if !$PokemonTemp.speciesMovesets
$PokemonTemp.speciesMovesets = load_data("Data/species_movesets.dat") || []
end
return $PokemonTemp.speciesMovesets
end
def pbGetSpeciesMoveset(species, form = 0)
species = getID(PBSpecies, species)
s = pbGetFSpeciesFromForm(species, form)
movesets_data = pbLoadMovesetsData
return movesets_data[s] || []
end
#===============================================================================
# Method to get TM/Move Tutor compatibility data.
#===============================================================================
def pbLoadSpeciesTMData
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
if !$PokemonTemp.speciesTMData
$PokemonTemp.speciesTMData = load_data("Data/tm.dat") || {}
end
return $PokemonTemp.speciesTMData
end
#===============================================================================
# Method to get Shadow Pokémon moveset data.
#===============================================================================
@@ -196,17 +92,6 @@ def pbLoadShadowMovesets
return $PokemonTemp.speciesShadowMovesets
end
#===============================================================================
# Method to get array that converts species + form to and from fSpecies values.
#===============================================================================
def pbLoadFormToSpecies
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
if !$PokemonTemp.pokemonFormToSpecies
$PokemonTemp.pokemonFormToSpecies = load_data("Data/form2species.dat")
end
return $PokemonTemp.pokemonFormToSpecies
end
#===============================================================================
# Methods to get data about individual trainers.
#===============================================================================

View File

@@ -125,5 +125,7 @@ module GameData
MapMetadata.load
Move.load
TrainerType.load
Type.load
Species.load
end
end

View File

@@ -115,8 +115,8 @@ module GameData
def can_hold?; return !is_important?; end
def unlosable?(species, ability)
return false if isConst?(species, PBSpecies, :ARCEUS) && ability != :MULTITYPE
return false if isConst?(species, PBSpecies, :SILVALLY) && ability != :RKSSYSTEM
return false if species == :ARCEUS && ability != :MULTITYPE
return false if species == :SILVALLY && ability != :RKSSYSTEM
combos = {
:ARCEUS => [:FISTPLATE, :FIGHTINIUMZ,
:SKYPLATE, :FLYINIUMZ,
@@ -157,11 +157,7 @@ module GameData
:KYOGRE => [:BLUEORB],
:GROUDON => [:REDORB]
}
combos.each do |comboSpecies, items|
next if !isConst?(species, PBSpecies, comboSpecies)
return items.include?(@id)
end
return false
return combos[species] && combos[species].include?(@id)
end
end
end

View File

@@ -0,0 +1,339 @@
module GameData
class Species
attr_reader :id
attr_reader :id_number
attr_reader :species
attr_reader :form
attr_reader :real_name
attr_reader :real_form_name
attr_reader :real_category
attr_reader :real_pokedex_entry
attr_reader :pokedex_form
attr_reader :type1
attr_reader :type2
attr_reader :base_stats
attr_reader :evs
attr_reader :base_exp
attr_reader :growth_rate
attr_reader :gender_rate
attr_reader :catch_rate
attr_reader :happiness
attr_reader :moves
attr_reader :tutor_moves
attr_reader :egg_moves
attr_reader :abilities
attr_reader :hidden_abilities
attr_reader :wild_item_common
attr_reader :wild_item_uncommon
attr_reader :wild_item_rare
attr_reader :egg_groups
attr_reader :hatch_steps
attr_reader :incense
attr_reader :evolutions
attr_reader :height
attr_reader :weight
attr_reader :color
attr_reader :shape
attr_reader :habitat
attr_reader :generation
attr_reader :mega_stone
attr_reader :mega_move
attr_reader :unmega_form
attr_reader :mega_message
attr_accessor :back_sprite_x
attr_accessor :back_sprite_y
attr_accessor :front_sprite_x
attr_accessor :front_sprite_y
attr_accessor :front_sprite_altitude
attr_accessor :shadow_x
attr_accessor :shadow_size
DATA = {}
DATA_FILENAME = "species.dat"
extend ClassMethods
include InstanceMethods
# @param species [Symbol, self, String, Integer]
# @param form [Integer]
# @return [self, nil]
def self.get_species_form(species, form)
return nil if !species || !form
validate species => [Symbol, self, String, Integer]
validate form => Integer
# if other.is_a?(Integer)
# p "Please switch to symbols, thanks."
# end
species = species.species if species.is_a?(self)
species = DATA[species].species if species.is_a?(Integer)
species = species.to_sym if species.is_a?(String)
trial = sprintf("%s_%d", species, form).to_sym
species_form = (DATA[trial].nil?) ? species : trial
return (DATA.has_key?(species_form)) ? DATA[species_form] : nil
end
# TODO: Needs tidying up.
def self.schema(compiling_forms = false)
ret = {
"FormName" => [0, "q"],
"Kind" => [0, "s"],
"Pokedex" => [0, "q"],
"Type1" => [0, "e", :Type],
"Type2" => [0, "e", :Type],
"BaseStats" => [0, "vvvvvv"],
"EffortPoints" => [0, "uuuuuu"],
"BaseEXP" => [0, "v"],
"Rareness" => [0, "u"],
"Happiness" => [0, "u"],
"Moves" => [0, "*ue", nil, :Move],
"TutorMoves" => [0, "*e", :Move],
"EggMoves" => [0, "*e", :Move],
"Abilities" => [0, "*e", :Ability],
"HiddenAbility" => [0, "*e", :Ability],
"WildItemCommon" => [0, "e", :Item],
"WildItemUncommon" => [0, "e", :Item],
"WildItemRare" => [0, "e", :Item],
"Compatibility" => [0, "*e", :PBEggGroups],
"StepsToHatch" => [0, "v"],
"Height" => [0, "f"],
"Weight" => [0, "f"],
"Color" => [0, "e", :PBColors],
"Shape" => [0, "u"],
"Habitat" => [0, "e", :PBHabitats],
"Generation" => [0, "i"],
"BattlerPlayerX" => [0, "i"],
"BattlerPlayerY" => [0, "i"],
"BattlerEnemyX" => [0, "i"],
"BattlerEnemyY" => [0, "i"],
"BattlerAltitude" => [0, "i"],
"BattlerShadowX" => [0, "i"],
"BattlerShadowSize" => [0, "u"]
}
if compiling_forms
ret["PokedexForm"] = [0, "u"]
ret["Evolutions"] = [0, "*ees", :Species, :PBEvolution, nil]
ret["MegaStone"] = [0, "e", :Item]
ret["MegaMove"] = [0, "e", :Move]
ret["UnmegaForm"] = [0, "u"]
ret["MegaMessage"] = [0, "u"]
else
ret["InternalName"] = [0, "n"]
ret["Name"] = [0, "s"]
ret["GrowthRate"] = [0, "e", :PBGrowthRates]
ret["GenderRate"] = [0, "e", :PBGenderRates]
ret["Incense"] = [0, "e", :Item]
ret["Evolutions"] = [0, "*ses", nil, :PBEvolution, nil]
end
return ret
end
def initialize(hash)
@id = hash[:id]
@id_number = hash[:id_number] || -1
@species = hash[:species] || @id
@form = hash[:form] || 0
@real_name = hash[:name] || "Unnamed"
@real_form_name = hash[:form_name]
@real_category = hash[:category] || "???"
@real_pokedex_entry = hash[:pokedex_entry] || "???"
@pokedex_form = hash[:pokedex_form] || @form
@type1 = hash[:type1] || :NORMAL
@type2 = hash[:type2] || @type1
@base_stats = hash[:base_stats] || [1, 1, 1, 1, 1, 1]
@evs = hash[:evs] || [0, 0, 0, 0, 0, 0]
@base_exp = hash[:base_exp] || 100
@growth_rate = hash[:growth_rate] || PBGrowthRates::Medium
@gender_rate = hash[:gender_rate] || PBGenderRates::Female50Percent
@catch_rate = hash[:catch_rate] || 255
@happiness = hash[:happiness] || 70
@moves = hash[:moves] || []
@tutor_moves = hash[:tutor_moves] || []
@egg_moves = hash[:egg_moves] || []
@abilities = hash[:abilities] || []
@hidden_abilities = hash[:hidden_abilities] || []
@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]
@hatch_steps = hash[:hatch_steps] || 1
@incense = hash[:incense]
@evolutions = hash[:evolutions] || []
@height = hash[:height] || 1
@weight = hash[:weight] || 1
@color = hash[:color] || PBColors::Red
@shape = hash[:shape] || 1
@habitat = hash[:habitat] || PBHabitats::None
@generation = hash[:generation] || 0
@mega_stone = hash[:mega_stone]
@mega_move = hash[:mega_move]
@unmega_form = hash[:unmega_form] || 0
@mega_message = hash[:mega_message] || 0
@back_sprite_x = hash[:back_sprite_x] || 0
@back_sprite_y = hash[:back_sprite_y] || 0
@front_sprite_x = hash[:front_sprite_x] || 0
@front_sprite_y = hash[:front_sprite_y] || 0
@front_sprite_altitude = hash[:front_sprite_altitude] || 0
@shadow_x = hash[:shadow_x] || 0
@shadow_size = hash[:shadow_size] || 2
end
# @return [String] the translated name of this species
def name
return pbGetMessage(MessageTypes::Species, @id_number)
end
# @return [String] the translated name of this form of this species
def form_name
return pbGetMessage(MessageTypes::FormNames, @id_number)
end
# @return [String] the translated Pokédex category of this species
def category
return pbGetMessage(MessageTypes::Kinds, @id_number)
end
# @return [String] the translated Pokédex entry of this species
def pokedex_entry
return pbGetMessage(MessageTypes::Entries, @id_number)
end
end
def apply_metrics_to_sprite(sprite, index, shadow = false)
if shadow
if (index & 1) == 1 # Foe Pokémon
sprite.x += @shadow_x * 2
end
else
if (index & 1) == 0 # Player's Pokémon
sprite.x += @back_sprite_x * 2
sprite.y += @back_sprite_y * 2
else # Foe Pokémon
sprite.x += @front_sprite_x * 2
sprite.y += @front_sprite_y * 2
sprite.y -= @front_sprite_altitude * 2
end
end
end
def shows_shadow?
return true
# return @front_sprite_altitude > 0
end
end
#===============================================================================
# Deprecated methods
#===============================================================================
module SpeciesData
TYPE1 = 0
TYPE2 = 1
BASE_STATS = 2
GENDER_RATE = 3
GROWTH_RATE = 4
BASE_EXP = 5
EFFORT_POINTS = 6
RARENESS = 7
HAPPINESS = 8
ABILITIES = 9
HIDDEN_ABILITY = 10
COMPATIBILITY = 11
STEPS_TO_HATCH = 12
HEIGHT = 13
WEIGHT = 14
COLOR = 15
SHAPE = 16
HABITAT = 17
WILD_ITEM_COMMON = 18
WILD_ITEM_UNCOMMON = 19
WILD_ITEM_RARE = 20
INCENSE = 21
POKEDEX_FORM = 22 # For alternate forms
MEGA_STONE = 23 # For alternate forms
MEGA_MOVE = 24 # For alternate forms
UNMEGA_FORM = 25 # For alternate forms
MEGA_MESSAGE = 26 # For alternate forms
METRIC_PLAYER_X = 27
METRIC_PLAYER_Y = 28
METRIC_ENEMY_X = 29
METRIC_ENEMY_Y = 30
METRIC_ALTITUDE = 31
METRIC_SHADOW_X = 32
METRIC_SHADOW_SIZE = 33
end
#===============================================================================
# Methods to get Pokémon species data.
#===============================================================================
def pbGetSpeciesData(species, form = 0, species_data_type = -1)
Deprecation.warn_method('pbGetSpeciesData', 'v20', 'GameData::Species.get_species_form(species, form).something')
ret = GameData::Species.get_species_form(species, form)
return ret if species_data_type == -1
case species_data_type
when SpeciesData::TYPE1 then return ret.type1
when SpeciesData::TYPE2 then return ret.type2
when SpeciesData::BASE_STATS then return ret.base_stats
when SpeciesData::GENDER_RATE then return ret.gender_rate
when SpeciesData::GROWTH_RATE then return ret.growth_rate
when SpeciesData::BASE_EXP then return ret.base_exp
when SpeciesData::EFFORT_POINTS then return ret.evs
when SpeciesData::RARENESS then return ret.catch_rate
when SpeciesData::HAPPINESS then return ret.happiness
when SpeciesData::ABILITIES then return ret.abilities
when SpeciesData::HIDDEN_ABILITY then return ret.hidden_abilities
when SpeciesData::COMPATIBILITY then return ret.egg_groups
when SpeciesData::STEPS_TO_HATCH then return ret.hatch_steps
when SpeciesData::HEIGHT then return ret.height
when SpeciesData::WEIGHT then return ret.weight
when SpeciesData::COLOR then return ret.color
when SpeciesData::SHAPE then return ret.shape
when SpeciesData::HABITAT then return ret.habitat
when SpeciesData::WILD_ITEM_COMMON then return ret.wild_item_common
when SpeciesData::WILD_ITEM_UNCOMMON then return ret.wild_item_uncommon
when SpeciesData::WILD_ITEM_RARE then return ret.wild_item_rare
when SpeciesData::INCENSE then return ret.incense
when SpeciesData::POKEDEX_FORM then return ret.pokedex_form
when SpeciesData::MEGA_STONE then return ret.mega_stone
when SpeciesData::MEGA_MOVE then return ret.mega_move
when SpeciesData::UNMEGA_FORM then return ret.unmega_form
when SpeciesData::MEGA_MESSAGE then return ret.mega_message
when SpeciesData::METRIC_PLAYER_X then return ret.back_sprite_x
when SpeciesData::METRIC_PLAYER_Y then return ret.back_sprite_y
when SpeciesData::METRIC_ENEMY_X then return ret.front_sprite_x
when SpeciesData::METRIC_ENEMY_Y then return ret.front_sprite_y
when SpeciesData::METRIC_ALTITUDE then return ret.front_sprite_altitude
when SpeciesData::METRIC_SHADOW_X then return ret.shadow_x
when SpeciesData::METRIC_SHADOW_SIZE then return ret.shadow_size
end
return 0
end
#===============================================================================
# Methods to get Pokémon moves data.
#===============================================================================
def pbGetSpeciesEggMoves(species, form = 0)
Deprecation.warn_method('pbGetSpeciesEggMoves', 'v20', 'GameData::Species.get_species_form(species, form).egg_moves')
return GameData::Species.get_species_form(species, form).egg_moves
end
def pbGetSpeciesMoveset(species, form = 0)
Deprecation.warn_method('pbGetSpeciesMoveset', 'v20', 'GameData::Species.get_species_form(species, form).moves')
return GameData::Species.get_species_form(species, form).moves
end
def pbGetEvolutionData(species)
Deprecation.warn_method('pbGetEvolutionData', 'v20', 'GameData::Species.get(species).evolutions')
return GameData::Species.get(species).evolutions
end
#===============================================================================
# Method to get Pokémon species metrics (sprite positioning) data.
#===============================================================================
def pbApplyBattlerMetricsToSprite(sprite, index, species_data, shadow = false, metrics = nil)
Deprecation.warn_method('pbApplyBattlerMetricsToSprite', 'v20', 'GameData::Species.get(species).apply_metrics_to_sprite')
GameData::Species.get(species).apply_metrics_to_sprite(sprite, index, shadow)
end
def showShadow?(species)
Deprecation.warn_method('showShadow?', 'v20', 'GameData::Species.get(species).shows_shadow?')
return GameData::Species.get(species).shows_shadow?
end

View File

@@ -0,0 +1,341 @@
module GameData
class Species
def self.check_graphic_file(path, species, form = 0, gender = 0, shiny = false, shadow = false, back = false)
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) ? "f" : ""
try_shiny = (shiny) ? "s" : ""
try_shadow = (shadow) ? "_shadow" : ""
try_back = (back) ? "b" : ""
factors = []
factors.push([4, try_shadow, ""]) if shadow
factors.push([2, try_gender, ""]) if gender == 1
factors.push([3, try_shiny, ""]) if shiny
factors.push([1, try_form, ""]) if form > 0
factors.push([0, try_species, "000"])
# Go through each combination of parameters in turn to find an existing sprite
for i in 0...2 ** factors.length
# Set try_ parameters for this combination
factors.each_with_index do |factor, index|
value = ((i / (2 ** index)) % 2 == 0) ? factor[1] : factor[2]
case factor[0]
when 0 then try_species = value
when 1 then try_form = value
when 2 then try_gender = value
when 3 then try_shiny = value
when 4 then try_shadow = value
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
ret = pbResolveBitmap(sprintf("%s%s%s%s%s%s%s", path,
try_species_text, try_gender, try_shiny, try_back, try_form, try_shadow))
return ret if ret
end
end
return nil
end
def self.check_egg_graphic_file(path, 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
if form > 0
ret = pbResolveBitmap(sprintf("%s%segg_%d", path, species_data.species, form))
return ret if ret
ret = pbResolveBitmap(sprintf("%s%03degg_%d", path, species_id, form))
return ret if ret
end
ret = pbResolveBitmap(sprintf("%s%segg", path, species_data.species))
return ret if ret
return pbResolveBitmap(sprintf("%s%03degg", path, species_id))
end
def self.front_sprite_filename(species, form = 0, gender = 0, shiny = false, shadow = false)
return self.check_graphic_file("Graphics/Battlers/", species, form, gender, shiny, shadow)
end
def self.back_sprite_filename(species, form = 0, gender = 0, shiny = false, shadow = false)
return self.check_graphic_file("Graphics/Battlers/", species, form, gender, shiny, shadow, true)
end
def self.egg_sprite_filename(species, form)
ret = self.check_egg_graphic_file("Graphics/Battlers/", species, form)
return (ret) ? ret : pbResolveBitmap("Graphics/Battlers/egg")
end
def self.sprite_filename(species, form = 0, gender = 0, shiny = false, shadow = false, back = false, egg = false)
return self.egg_sprite_filename(species, form) if egg
return self.back_sprite_filename(species, form, gender, shiny, shadow) if back
return self.front_sprite_filename(species, form, gender, shiny, shadow)
end
def self.front_sprite_bitmap(species, form = 0, gender = 0, shiny = false, shadow = false)
filename = self.front_sprite_filename(species, form, gender, shiny, shadow)
return (filename) ? AnimatedBitmap.new(filename) : nil
end
def self.back_sprite_bitmap(species, form = 0, gender = 0, shiny = false, shadow = false)
filename = self.back_sprite_filename(species, form, gender, shiny, shadow)
return (filename) ? AnimatedBitmap.new(filename) : nil
end
def self.egg_sprite_bitmap(species, form = 0)
filename = self.egg_sprite_filename(species, form)
return (filename) ? AnimatedBitmap.new(filename) : nil
end
def self.sprite_bitmap(species, form = 0, gender = 0, shiny = false, shadow = false, back = false, egg = false)
return self.egg_sprite_bitmap(species, form) if egg
return self.back_sprite_bitmap(species, form, gender, shiny, shadow) if back
return self.front_sprite_bitmap(species, form, gender, shiny, shadow)
end
def self.sprite_bitmap_from_pokemon(pkmn, back = false, species = nil)
species = pkmn.species if !species
species = GameData::Species.get(species).species # Just to be sure it's a symbol
return self.egg_sprite_bitmap(species, pkmn.form) if pkmn.egg?
if back
ret = self.back_sprite_bitmap(species, pkmn.form, pkmn.gender, pkmn.shiny?, pkmn.shadowPokemon?)
else
ret = self.front_sprite_bitmap(species, pkmn.form, pkmn.gender, pkmn.shiny?, pkmn.shadowPokemon?)
end
alter_bitmap_function = MultipleForms.getFunction(species, "alterBitmap")
if ret && alter_bitmap_function
new_ret = ret.copy
ret.dispose
new_ret.each { |bitmap| alter_bitmap_function.call(pkmn, bitmap) }
ret = new_ret
end
return ret
end
#===========================================================================
def self.egg_icon_filename(species, form)
ret = self.check_egg_graphic_file("Graphics/Icons/icon", species, form)
return (ret) ? ret : pbResolveBitmap("Graphics/Icons/iconEgg")
end
def self.icon_filename(species, form = 0, gender = 0, shiny = false, shadow = false, egg = false)
return self.egg_icon_filename(species, form) if egg
return self.check_graphic_file("Graphics/Icons/icon", species, form, gender, shiny, shadow)
end
def self.icon_filename_from_pokemon(pkmn)
return self.icon_filename(pkmn.species, pkmn.form, pkmn.gender, pkmn.shiny?, pkmn.shadowPokemon?, pkmn.egg?)
end
def self.egg_icon_bitmap(species, form)
filename = self.egg_icon_filename(species, form)
return (filename) ? AnimatedBitmap.new(filename).deanimate : nil
end
def self.icon_bitmap(species, form = 0, gender = 0, shiny = false, shadow = false)
filename = self.icon_filename(species, form, gender,shiny, shadow)
return (filename) ? AnimatedBitmap.new(filename).deanimate : nil
end
def self.icon_bitmap_from_pokemon(pkmn)
return self.icon_bitmap(pkmn.species, pkmn.form, pkmn.gender, pkmn.shiny?, pkmn.shadowPokemon?, pkmn.egg?)
end
#===========================================================================
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
if form > 0
ret = pbResolveBitmap(sprintf("Graphics/Icons/Footprints/footprint%s_%d", species_data.species, form))
return ret if ret
ret = pbResolveBitmap(sprintf("Graphics/Icons/Footprints/footprint%03d_%d", species_id, form))
return ret if ret
end
ret = pbResolveBitmap(sprintf("Graphics/Icons/Footprints/footprint%s", species_data.species))
return ret if ret
return pbResolveBitmap(sprintf("Graphics/Icons/Footprints/footprint%03d", species_id))
end
#===========================================================================
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
# Look for species-specific shadow graphic
if form > 0
ret = pbResolveBitmap(sprintf("Graphics/Battlers/%s_%d_battleshadow", species_data.species, form))
return ret if ret
ret = pbResolveBitmap(sprintf("Graphics/Battlers/%03d_%d_battleshadow", species_id, form))
return ret if ret
end
ret = pbResolveBitmap(sprintf("Graphics/Battlers/%s_battleshadow", species_data.species))
return ret if ret
ret = pbResolveBitmap(sprintf("Graphics/Battlers/%03d_battleshadow", species_id))
return ret if ret
# Use general shadow graphic
return pbResolveBitmap(sprintf("Graphics/Pictures/Battle/battler_shadow_%d", species_data.shadow_size))
end
def self.shadow_bitmap(species, form = 0)
filename = self.shadow_filename(species, form)
return (filename) ? AnimatedBitmap.new(filename) : nil
end
def self.shadow_bitmap_from_pokemon(pkmn)
filename = self.shadow_filename(pkmn.species, pkmn.form)
return (filename) ? AnimatedBitmap.new(filename) : nil
end
#===========================================================================
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
if form > 0
ret = sprintf("Cries/%sCry_%d", species_data.species, form)
return ret if pbResolveAudioSE(ret)
ret = sprintf("Cries/%03dCry_%d", species_id, form)
return ret if pbResolveAudioSE(ret)
end
ret = sprintf("Cries/%sCry", species_data.species)
return ret if pbResolveAudioSE(ret)
ret = sprintf("Cries/%03dCry", species_id)
return (pbResolveAudioSE(ret)) ? ret : nil
end
def self.cry_filename(species, form = 0)
return self.check_cry_file(species, form)
end
def self.cry_filename_from_pokemon(pkmn)
return self.check_cry_file(pkmn.species, pkmn.form)
end
def self.play_cry_from_species(species, form = 0, volume = 90, pitch = 100)
filename = self.cry_filename(species, form)
return if !filename
pbSEPlay(RPG::AudioFile.new(filename, volume, pitch)) rescue nil
end
def self.play_cry_from_pokemon(pkmn, volume = 90, pitch = nil)
return if !pkmn || pkmn.egg?
if pkmn.respond_to?("chatter") && pkmn.chatter
pkmn.chatter.play
return
end
filename = self.cry_filename_from_pokemon(pkmn)
return if !filename
pitch ||= 75 + (pkmn.hp * 25 / pkmn.totalhp)
pbSEPlay(RPG::AudioFile.new(filename, volume, pitch)) rescue nil
end
def self.play_cry(pkmn, volume = 90, pitch = nil)
if pkmn.is_a?(Pokemon)
self.play_cry_from_pokemon(pkmn, volume, pitch)
else
self.play_cry_from_species(pkmn, nil, volume, pitch)
end
end
def self.cry_length(species, form = 0, pitch = 100)
return 0 if !species || pitch <= 0
pitch = pitch.to_f / 100
ret = 0.0
if species.is_a?(Pokemon)
if !species.egg?
if species.respond_to?("chatter") && species.chatter
ret = species.chatter.time
pitch = 1.0
else
filename = pbResolveAudioSE(GameData::Species.cry_filename_from_pokemon(species))
ret = getPlayTime(filename) if filename
end
end
else
filename = pbResolveAudioSE(GameData::Species.cry_filename(species, form))
ret = getPlayTime(filename) if filename
end
ret /= pitch # Sound played at a lower pitch lasts longer
return (ret * Graphics.frame_rate).ceil + 4 # 4 provides a buffer between sounds
end
end
end
#===============================================================================
# Deprecated
#===============================================================================
def pbLoadSpeciesBitmap(species, gender = 0, form = 0, shiny = false, shadow = false, back = false , egg = false)
Deprecation.warn_method('pbLoadSpeciesBitmap', 'v20', 'GameData::Species.sprite_bitmap(species, form, gender, shiny, shadow, back, egg)')
return GameData::Species.sprite_bitmap(species, form, gender, shiny, shadow, back, egg)
end
def pbLoadPokemonBitmap(pkmn, back = false)
Deprecation.warn_method('pbLoadPokemonBitmap', 'v20', 'GameData::Species.sprite_bitmap_from_pokemon(pkmn)')
return GameData::Species.sprite_bitmap_from_pokemon(pkmn, back)
end
def pbLoadPokemonBitmapSpecies(pkmn, species, back = false)
Deprecation.warn_method('pbLoadPokemonBitmapSpecies', 'v20', 'GameData::Species.sprite_bitmap_from_pokemon(pkmn, back, species)')
return GameData::Species.sprite_bitmap_from_pokemon(pkmn, back, species)
end
def pbPokemonIconFile(pkmn)
Deprecation.warn_method('pbPokemonIconFile', 'v20', 'GameData::Species.icon_filename_from_pokemon(pkmn)')
return GameData::Species.icon_filename_from_pokemon(pkmn)
end
def pbLoadPokemonIcon(pkmn)
Deprecation.warn_method('pbLoadPokemonIcon', 'v20', 'GameData::Species.icon_bitmap_from_pokemon(pkmn)')
return GameData::Species.icon_bitmap_from_pokemon(pkmn)
end
def pbPokemonFootprintFile(species, form = 0)
Deprecation.warn_method('pbPokemonFootprintFile', 'v20', 'GameData::Species.footprint_filename(species, form)')
return GameData::Species.footprint_filename(species, form)
end
def pbCheckPokemonShadowBitmapFiles(species, form = 0)
Deprecation.warn_method('pbCheckPokemonShadowBitmapFiles', 'v20', 'GameData::Species.shadow_filename(species, form)')
return GameData::Species.shadow_filename(species, form)
end
def pbLoadPokemonShadowBitmap(pkmn)
Deprecation.warn_method('pbLoadPokemonShadowBitmap', 'v20', 'GameData::Species.shadow_bitmap_from_pokemon(pkmn)')
return GameData::Species.shadow_bitmap_from_pokemon(pkmn)
end
def pbCryFile(species, form = 0)
if species.is_a?(Pokemon)
Deprecation.warn_method('pbCryFile', 'v20', 'GameData::Species.cry_filename_from_pokemon(pkmn)')
return GameData::Species.cry_filename_from_pokemon(species)
end
Deprecation.warn_method('pbCryFile', 'v20', 'GameData::Species.cry_filename(species, form)')
return GameData::Species.cry_filename(species, form)
end
def pbPlayCry(pkmn, volume = 90, pitch = nil)
Deprecation.warn_method('pbPlayCry', 'v20', 'GameData::Species.play_cry(pkmn)')
GameData::Species.play_cry(pkmn, volume, pitch)
end
def pbPlayCrySpecies(species, form = 0, volume = 90, pitch = nil)
Deprecation.warn_method('pbPlayCrySpecies', 'v20', 'GameData::Species.play_cry_from_species(species, form)')
GameData::Species.play_cry_from_species(species, form, volume, pitch)
end
def pbPlayCryPokemon(pkmn, volume = 90, pitch = nil)
Deprecation.warn_method('pbPlayCryPokemon', 'v20', 'GameData::Species.play_cry_from_pokemon(pkmn)')
GameData::Species.play_cry_from_pokemon(pkmn, volume, pitch)
end
def pbCryFrameLength(species, form = 0, pitch = 100)
Deprecation.warn_method('pbCryFrameLength', 'v20', 'GameData::Species.cry_length(species, form)')
return GameData::Species.cry_length(species, form, pitch)
end

View File

@@ -1,133 +0,0 @@
#===============================================================================
# Phone data
#===============================================================================
class PhoneDatabase
attr_accessor :generics
attr_accessor :greetings
attr_accessor :greetingsMorning
attr_accessor :greetingsEvening
attr_accessor :bodies1
attr_accessor :bodies2
attr_accessor :battleRequests
attr_accessor :trainers
def initialize
@generics = []
@greetings = []
@greetingsMorning = []
@greetingsEvening = []
@bodies1 = []
@bodies2 = []
@battleRequests = []
@trainers = []
end
end
module PhoneMsgType
Generic = 0
Greeting = 1
Body = 2
BattleRequest = 3
end
#===============================================================================
# Pokémon data
#===============================================================================
module SpeciesData
TYPE1 = 0
TYPE2 = 1
BASE_STATS = 2
GENDER_RATE = 3
GROWTH_RATE = 4
BASE_EXP = 5
EFFORT_POINTS = 6
RARENESS = 7
HAPPINESS = 8
ABILITIES = 9
HIDDEN_ABILITY = 10
COMPATIBILITY = 11
STEPS_TO_HATCH = 12
HEIGHT = 13
WEIGHT = 14
COLOR = 15
SHAPE = 16
HABITAT = 17
WILD_ITEM_COMMON = 18
WILD_ITEM_UNCOMMON = 19
WILD_ITEM_RARE = 20
INCENSE = 21
POKEDEX_FORM = 22 # For alternate forms
MEGA_STONE = 23 # For alternate forms
MEGA_MOVE = 24 # For alternate forms
UNMEGA_FORM = 25 # For alternate forms
MEGA_MESSAGE = 26 # For alternate forms
METRIC_PLAYER_X = 0
METRIC_PLAYER_Y = 1
METRIC_ENEMY_X = 2
METRIC_ENEMY_Y = 3
METRIC_ALTITUDE = 4
METRIC_SHADOW_X = 5
METRIC_SHADOW_SIZE = 6
def self.requiredValues(compilingForms = false)
ret = {
"Type1" => [TYPE1, "e", :Type],
"BaseStats" => [BASE_STATS, "vvvvvv"],
"BaseEXP" => [BASE_EXP, "v"],
"EffortPoints" => [EFFORT_POINTS, "uuuuuu"],
"Rareness" => [RARENESS, "u"],
"Happiness" => [HAPPINESS, "u"],
"Compatibility" => [COMPATIBILITY, "eE", :PBEggGroups, :PBEggGroups],
"StepsToHatch" => [STEPS_TO_HATCH, "v"],
"Height" => [HEIGHT, "f"],
"Weight" => [WEIGHT, "f"],
"Color" => [COLOR, "e", :PBColors],
"Shape" => [SHAPE, "u"],
"Moves" => [0, "*ue", nil, :Move],
"Kind" => [0, "s"],
"Pokedex" => [0, "q"]
}
if !compilingForms
ret["GenderRate"] = [GENDER_RATE, "e", :PBGenderRates]
ret["GrowthRate"] = [GROWTH_RATE, "e", :PBGrowthRates]
ret["Name"] = [0, "s"]
ret["InternalName"] = [0, "n"]
end
return ret
end
def self.optionalValues(compilingForms = false)
ret = {
"Type2" => [TYPE2, "e", :Type],
"Abilities" => [ABILITIES, "eE", :Ability, :Ability],
"HiddenAbility" => [HIDDEN_ABILITY, "eEEE", :Ability, :Ability,
:Ability, :Ability],
"Habitat" => [HABITAT, "e", :PBHabitats],
"WildItemCommon" => [WILD_ITEM_COMMON, "e", :Item],
"WildItemUncommon" => [WILD_ITEM_UNCOMMON, "e", :Item],
"WildItemRare" => [WILD_ITEM_RARE, "e", :Item],
"BattlerPlayerX" => [METRIC_PLAYER_X, "i"],
"BattlerPlayerY" => [METRIC_PLAYER_Y, "i"],
"BattlerEnemyX" => [METRIC_ENEMY_X, "i"],
"BattlerEnemyY" => [METRIC_ENEMY_Y, "i"],
"BattlerAltitude" => [METRIC_ALTITUDE, "i"],
"BattlerShadowX" => [METRIC_SHADOW_X, "i"],
"BattlerShadowSize" => [METRIC_SHADOW_SIZE, "u"],
"EggMoves" => [0, "*e", :Move],
"FormName" => [0, "q"],
"Evolutions" => [0, "*ses", nil, :PBEvolution, nil]
}
if compilingForms
ret["PokedexForm"] = [POKEDEX_FORM, "u"]
ret["MegaStone"] = [MEGA_STONE, "e", :Item]
ret["MegaMove"] = [MEGA_MOVE, "e", :Move]
ret["UnmegaForm"] = [UNMEGA_FORM, "u"]
ret["MegaMessage"] = [MEGA_MESSAGE, "u"]
else
ret["Incense"] = [INCENSE, "e", :Item]
ret["RegionalNumbers"] = [0, "*u"]
end
return ret
end
end

View File

@@ -0,0 +1,31 @@
#===============================================================================
# Phone data
#===============================================================================
class PhoneDatabase
attr_accessor :generics
attr_accessor :greetings
attr_accessor :greetingsMorning
attr_accessor :greetingsEvening
attr_accessor :bodies1
attr_accessor :bodies2
attr_accessor :battleRequests
attr_accessor :trainers
def initialize
@generics = []
@greetings = []
@greetingsMorning = []
@greetingsEvening = []
@bodies1 = []
@bodies2 = []
@battleRequests = []
@trainers = []
end
end
module PhoneMsgType
Generic = 0
Greeting = 1
Body = 2
BattleRequest = 3
end

View File

@@ -1,8 +1,8 @@
module PBGrowthRates
Medium = MediumFast = 0
MediumFast = Medium = 0
Erratic = 1
Fluctuating = 2
Parabolic = MediumSlow = 3
MediumSlow = Parabolic = 3
Fast = 4
Slow = 5