Added PBS file pokemon_metrics.txt, for all Pokémon sprite positionings

This commit is contained in:
Maruno17
2021-10-23 20:30:09 +01:00
parent ca680c9feb
commit 10a1fc4430
34 changed files with 16729 additions and 20062 deletions

View File

@@ -230,6 +230,7 @@ module GameData
Item.load
BerryPlant.load
Species.load
SpeciesMetrics.load
Ribbon.load
Encounter.load
TrainerType.load

View File

@@ -40,13 +40,6 @@ module GameData
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"
@@ -190,13 +183,6 @@ module GameData
@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
@@ -235,25 +221,13 @@ module GameData
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
metrics_data = GameData::SpeciesMetrics.get_species_form(@species, @form)
metrics_data.apply_metrics_to_sprite(sprite, index, shadow)
end
def shows_shadow?
return true
# return @front_sprite_altitude > 0
metrics_data = GameData::SpeciesMetrics.get_species_form(@species, @form)
return metrics_data.shows_shadow?
end
def get_evolutions(exclude_invalid = false)

View File

@@ -158,7 +158,8 @@ module GameData
ret = pbResolveBitmap(sprintf("Graphics/Pokemon/Shadow/%s", species_data.species))
return ret if ret
# Use general shadow graphic
return pbResolveBitmap(sprintf("Graphics/Pokemon/Shadow/%d", species_data.shadow_size))
metrics_data = GameData::SpeciesMetrics.get_species_form(species_data.species, form)
return pbResolveBitmap(sprintf("Graphics/Pokemon/Shadow/%d", metrics_data.shadow_size))
end
def self.shadow_bitmap(species, form = 0)

View File

@@ -0,0 +1,89 @@
module GameData
class SpeciesMetrics
attr_reader :id
attr_reader :species
attr_reader :form
attr_accessor :back_sprite
attr_accessor :front_sprite
attr_accessor :front_sprite_altitude
attr_accessor :shadow_x
attr_accessor :shadow_size
DATA = {}
DATA_FILENAME = "species_metrics.dat"
SCHEMA = {
"BackSprite" => [0, "ii"],
"FrontSprite" => [0, "ii"],
"FrontSpriteAltitude" => [0, "i"],
"ShadowX" => [0, "i"],
"ShadowSize" => [0, "u"]
}
extend ClassMethodsSymbols
include InstanceMethods
# @param species [Symbol, String]
# @param form [Integer]
# @return [self, nil]
def self.get_species_form(species, form)
return nil if !species || !form
validate species => [Symbol, String]
validate form => Integer
raise _INTL("Undefined species {1}.", species) if !GameData::Species.exists?(species)
species = species.to_sym if species.is_a?(String)
if form > 0
trial = sprintf("%s_%d", species, form).to_sym
if !DATA.has_key?(trial)
self.register({:id => species}) if !DATA[species]
self.register({
:id => trial,
:species => species,
:form => form,
:back_sprite => DATA[species].back_sprite.clone,
:front_sprite => DATA[species].front_sprite.clone,
:front_sprite_altitude => DATA[species].front_sprite_altitude,
:shadow_x => DATA[species].shadow_x,
:shadow_size => DATA[species].shadow_size
})
end
return DATA[trial]
end
self.register({:id => species}) if !DATA[species]
return DATA[species]
end
def initialize(hash)
@id = hash[:id]
@species = hash[:species] || @id
@form = hash[:form] || 0
@back_sprite = hash[:back_sprite] || [0, 0]
@front_sprite = hash[:front_sprite] || [0, 0]
@front_sprite_altitude = hash[:front_sprite_altitude] || 0
@shadow_x = hash[:shadow_x] || 0
@shadow_size = hash[:shadow_size] || 2
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[0] * 2
sprite.y += @back_sprite[1] * 2
else # Foe Pokémon
sprite.x += @front_sprite[0] * 2
sprite.y += @front_sprite[1] * 2
sprite.y -= @front_sprite_altitude * 2
end
end
end
def shows_shadow?
return true
# return @front_sprite_altitude > 0
end
end
end

View File

@@ -127,7 +127,7 @@ class PokemonPokedexInfo_Scene
def pbUpdateDummyPokemon
@species = @dexlist[@index][0]
@gender, @form = $player.pokedex.last_form_seen(@species)
species_data = GameData::Species.get_species_form(@species, @form)
metrics_data = GameData::SpeciesMetrics.get_species_form(@species, @form)
@sprites["infosprite"].setSpeciesBitmap(@species,@gender,@form)
if @sprites["formfront"]
@sprites["formfront"].setSpeciesBitmap(@species,@gender,@form)
@@ -135,7 +135,7 @@ class PokemonPokedexInfo_Scene
if @sprites["formback"]
@sprites["formback"].setSpeciesBitmap(@species,@gender,@form,false,false,true)
@sprites["formback"].y = 256
@sprites["formback"].y += species_data.back_sprite_y * 2
@sprites["formback"].y += metrics_data.back_sprite[1] * 2
end
if @sprites["formicon"]
@sprites["formicon"].pbSetParams(@species,@gender,@form)

View File

@@ -1030,14 +1030,7 @@ def pbPokemonEditor
[_INTL("Shape"), GameDataProperty.new(:BodyShape), _INTL("Body shape of this species.")],
[_INTL("Habitat"), GameDataProperty.new(:Habitat), _INTL("The habitat of this species.")],
[_INTL("Generation"), LimitProperty.new(99999), _INTL("The number of the generation the Pokémon debuted in.")],
[_INTL("Flags"), StringListProperty, _INTL("Words/phrases that distinguish this species from others.")],
[_INTL("BattlerPlayerX"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("BattlerPlayerY"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("BattlerEnemyX"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("BattlerEnemyY"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("BattlerAltitude"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("BattlerShadowX"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("BattlerShadowSize"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("Flags"), StringListProperty, _INTL("Words/phrases that distinguish this species from others.")]
]
pbListScreenBlock(_INTL("Pokémon species"), SpeciesLister.new(0, false)) { |button, species|
if species
@@ -1097,14 +1090,7 @@ def pbPokemonEditor
spec.shape,
spec.habitat,
spec.generation,
spec.flags.clone,
spec.back_sprite_x,
spec.back_sprite_y,
spec.front_sprite_x,
spec.front_sprite_y,
spec.front_sprite_altitude,
spec.shadow_x,
spec.shadow_size
spec.flags.clone
]
# Edit the properties
if pbPropertyList(spec.id.to_s, data, species_properties, true)
@@ -1149,14 +1135,7 @@ def pbPokemonEditor
:shape => data[34],
:habitat => data[35],
:generation => data[36],
:flags => data[37],
:back_sprite_x => data[38],
:back_sprite_y => data[39],
:front_sprite_x => data[40],
:front_sprite_y => data[41],
:front_sprite_altitude => data[42],
:shadow_x => data[43],
:shadow_size => data[44]
:flags => data[37]
}
# Add species' data to records
GameData::Species.register(species_hash)

View File

@@ -18,26 +18,26 @@ def pbAutoPositionAll
t = Time.now.to_i
Graphics.update
end
metrics = GameData::SpeciesMetrics.get_species_form(sp.species, sp.form)
bitmap1 = GameData::Species.sprite_bitmap(sp.species, sp.form, nil, nil, nil, true)
bitmap2 = GameData::Species.sprite_bitmap(sp.species, sp.form)
if bitmap1 && bitmap1.bitmap # Player's y
sp.back_sprite_x = 0
sp.back_sprite_y = (bitmap1.height - (findBottom(bitmap1.bitmap) + 1)) / 2
metrics.back_sprite[0] = 0
metrics.back_sprite[1] = (bitmap1.height - (findBottom(bitmap1.bitmap) + 1)) / 2
end
if bitmap2 && bitmap2.bitmap # Foe's y
sp.front_sprite_x = 0
sp.front_sprite_y = (bitmap2.height - (findBottom(bitmap2.bitmap) + 1)) / 2
sp.front_sprite_y += 4 # Just because
metrics.front_sprite[0] = 0
metrics.front_sprite[1] = (bitmap2.height - (findBottom(bitmap2.bitmap) + 1)) / 2
metrics.front_sprite[1] += 4 # Just because
end
sp.front_sprite_altitude = 0 # Shouldn't be used
sp.shadow_x = 0
sp.shadow_size = 2
metrics.front_sprite_altitude = 0 # Shouldn't be used
metrics.shadow_x = 0
metrics.shadow_size = 2
bitmap1.dispose if bitmap1
bitmap2.dispose if bitmap2
end
GameData::Species.save
Compiler.write_pokemon
Compiler.write_pokemon_forms
GameData::SpeciesMetrics.save
Compiler.write_pokemon_metrics
end
#===============================================================================
@@ -81,7 +81,8 @@ class SpritePositioner
@sprites["info"].viewport = @viewport
@sprites["info"].visible = false
@oldSpeciesIndex = 0
@species = nil # This can be a species_form
@species = nil # This cannot be a species_form
@form = 0
@metricsChanged = false
refresh
@starting = true
@@ -92,7 +93,7 @@ class SpritePositioner
pbSaveMetrics
@metricsChanged = false
else
GameData::Species.load # Clear all changes to metrics
GameData::SpeciesMetrics.load # Clear all changes to metrics
end
pbFadeOutAndHide(@sprites) { update }
pbDisposeSpriteHash(@sprites)
@@ -100,9 +101,8 @@ class SpritePositioner
end
def pbSaveMetrics
GameData::Species.save
Compiler.write_pokemon
Compiler.write_pokemon_forms
GameData::SpeciesMetrics.save
Compiler.write_pokemon_metrics
end
def update
@@ -116,12 +116,12 @@ class SpritePositioner
@sprites["shadow_1"].visible = false
return
end
species_data = GameData::Species.get(@species)
metrics_data = GameData::SpeciesMetrics.get_species_form(@species, @form)
for i in 0...2
pos = PokeBattle_SceneConstants.pbBattlerPosition(i, 1)
@sprites["pokemon_#{i}"].x = pos[0]
@sprites["pokemon_#{i}"].y = pos[1]
species_data.apply_metrics_to_sprite(@sprites["pokemon_#{i}"], i)
metrics_data.apply_metrics_to_sprite(@sprites["pokemon_#{i}"], i)
@sprites["pokemon_#{i}"].visible = true
if i == 1
@sprites["shadow_1"].x = pos[0]
@@ -130,52 +130,51 @@ class SpritePositioner
@sprites["shadow_1"].x -= @sprites["shadow_1"].bitmap.width / 2
@sprites["shadow_1"].y -= @sprites["shadow_1"].bitmap.height / 2
end
species_data.apply_metrics_to_sprite(@sprites["shadow_1"], i, true)
metrics_data.apply_metrics_to_sprite(@sprites["shadow_1"], i, true)
@sprites["shadow_1"].visible = true
end
end
end
def pbAutoPosition
species_data = GameData::Species.get(@species)
old_back_y = species_data.back_sprite_y
old_front_y = species_data.front_sprite_y
old_front_altitude = species_data.front_sprite_altitude
metrics_data = GameData::SpeciesMetrics.get_species_form(@species, @form)
old_back_y = metrics_data.back_sprite[1]
old_front_y = metrics_data.front_sprite[1]
old_front_altitude = metrics_data.front_sprite_altitude
bitmap1 = @sprites["pokemon_0"].bitmap
bitmap2 = @sprites["pokemon_1"].bitmap
new_back_y = (bitmap1.height - (findBottom(bitmap1) + 1)) / 2
new_front_y = (bitmap2.height - (findBottom(bitmap2) + 1)) / 2
new_front_y += 4 # Just because
if new_back_y != old_back_y || new_front_y != old_front_y || old_front_altitude != 0
species_data.back_sprite_y = new_back_y
species_data.front_sprite_y = new_front_y
species_data.front_sprite_altitude = 0
metrics_data.back_sprite[1] = new_back_y
metrics_data.front_sprite[1] = new_front_y
metrics_data.front_sprite_altitude = 0
@metricsChanged = true
refresh
end
end
def pbChangeSpecies(species)
def pbChangeSpecies(species, form)
@species = species
species_data = GameData::Species.try_get(@species)
@form = form
species_data = GameData::Species.get_species_form(@species, @form)
return if !species_data
spe = species_data.species
frm = species_data.form
@sprites["pokemon_0"].setSpeciesBitmap(spe, 0, frm, false, false, true)
@sprites["pokemon_1"].setSpeciesBitmap(spe, 0, frm)
@sprites["shadow_1"].setBitmap(GameData::Species.shadow_filename(spe, frm))
@sprites["pokemon_0"].setSpeciesBitmap(@species, 0, @form, false, false, true)
@sprites["pokemon_1"].setSpeciesBitmap(@species, 0, @form)
@sprites["shadow_1"].setBitmap(GameData::Species.shadow_filename(@species, @form))
end
def pbShadowSize
pbChangeSpecies(@species)
pbChangeSpecies(@species, @form)
refresh
species_data = GameData::Species.get(@species)
if pbResolveBitmap(sprintf("Graphics/Pokemon/Shadow/%s_%d", species_data.species, species_data.form)) ||
pbResolveBitmap(sprintf("Graphics/Pokemon/Shadow/%s", species_data.species))
metrics_data = GameData::SpeciesMetrics.get_species_form(@species, @form)
if pbResolveBitmap(sprintf("Graphics/Pokemon/Shadow/%s_%d", metrics_data.species, metrics_data.form)) ||
pbResolveBitmap(sprintf("Graphics/Pokemon/Shadow/%s", metrics_data.species))
pbMessage("This species has its own shadow sprite in Graphics/Pokemon/Shadow/. The shadow size metric cannot be edited.")
return false
end
oldval = species_data.shadow_size
oldval = metrics_data.shadow_size
cmdvals = [0]
commands = [_INTL("None")]
defindex = 0
@@ -200,17 +199,17 @@ class SpritePositioner
self.update
if cw.index != oldindex
oldindex = cw.index
species_data.shadow_size = cmdvals[cw.index]
pbChangeSpecies(@species)
metrics_data.shadow_size = cmdvals[cw.index]
pbChangeSpecies(@species, @form)
refresh
end
if Input.trigger?(Input::ACTION) # Cycle to next option
pbPlayDecisionSE
@metricsChanged = true if species_data.shadow_size != oldval
@metricsChanged = true if metrics_data.shadow_size != oldval
ret = true
break
elsif Input.trigger?(Input::BACK)
species_data.shadow_size = oldval
metrics_data.shadow_size = oldval
pbPlayCancelSE
break
elsif Input.trigger?(Input::USE)
@@ -229,19 +228,19 @@ class SpritePositioner
pbAutoPosition
return false
end
species_data = GameData::Species.get(@species)
metrics_data = GameData::SpeciesMetrics.get_species_form(@species, @form)
case param
when 0
sprite = @sprites["pokemon_0"]
xpos = species_data.back_sprite_x
ypos = species_data.back_sprite_y
xpos = metrics_data.back_sprite[0]
ypos = metrics_data.back_sprite[1]
when 1
sprite = @sprites["pokemon_1"]
xpos = species_data.front_sprite_x
ypos = species_data.front_sprite_y
xpos = metrics_data.front_sprite[0]
ypos = metrics_data.front_sprite[1]
when 3
sprite = @sprites["shadow_1"]
xpos = species_data.shadow_x
xpos = metrics_data.shadow_x
ypos = 0
end
oldxpos = xpos
@@ -261,17 +260,17 @@ class SpritePositioner
if (Input.repeat?(Input::UP) || Input.repeat?(Input::DOWN)) && param != 3
ypos += (Input.repeat?(Input::DOWN)) ? 1 : -1
case param
when 0 then species_data.back_sprite_y = ypos
when 1 then species_data.front_sprite_y = ypos
when 0 then metrics_data.back_sprite[1] = ypos
when 1 then metrics_data.front_sprite[1] = ypos
end
refresh
end
if Input.repeat?(Input::LEFT) || Input.repeat?(Input::RIGHT)
xpos += (Input.repeat?(Input::RIGHT)) ? 1 : -1
case param
when 0 then species_data.back_sprite_x = xpos
when 1 then species_data.front_sprite_x = xpos
when 3 then species_data.shadow_x = xpos
when 0 then metrics_data.back_sprite[0] = xpos
when 1 then metrics_data.front_sprite[0] = xpos
when 3 then metrics_data.shadow_x = xpos
end
refresh
end
@@ -283,13 +282,13 @@ class SpritePositioner
elsif Input.repeat?(Input::BACK)
case param
when 0
species_data.back_sprite_x = oldxpos
species_data.back_sprite_y = oldypos
metrics_data.back_sprite[0] = oldxpos
metrics_data.back_sprite[1] = oldypos
when 1
species_data.front_sprite_x = oldxpos
species_data.front_sprite_y = oldypos
metrics_data.front_sprite[0] = oldxpos
metrics_data.front_sprite[1] = oldypos
when 3
species_data.shadow_x = oldxpos
metrics_data.shadow_x = oldxpos
end
pbPlayCancelSE
refresh
@@ -305,8 +304,7 @@ class SpritePositioner
return ret
end
def pbMenu(species)
pbChangeSpecies(species)
def pbMenu
refresh
cw = Window_CommandPokemon.new([
_INTL("Set Ally Position"),
@@ -350,14 +348,14 @@ class SpritePositioner
allspecies = []
GameData::Species.each do |sp|
name = (sp.form == 0) ? sp.name : _INTL("{1} (form {2})", sp.real_name, sp.form)
allspecies.push([sp.id, sp.species, name]) if name && !name.empty?
allspecies.push([sp.id, sp.species, sp.form, name]) if name && !name.empty?
end
allspecies.sort! { |a, b| a[2] <=> b[2] }
allspecies.sort! { |a, b| a[3] <=> b[3] }
commands = []
allspecies.each { |sp| commands.push(sp[2]) }
allspecies.each { |sp| commands.push(sp[3]) }
cw.commands = commands
cw.index = @oldSpeciesIndex
ret = nil
ret = false
oldindex = -1
loop do
Graphics.update
@@ -365,17 +363,17 @@ class SpritePositioner
cw.update
if cw.index != oldindex
oldindex = cw.index
pbChangeSpecies(allspecies[cw.index][0])
pbChangeSpecies(allspecies[cw.index][1], allspecies[cw.index][2])
refresh
end
self.update
if Input.trigger?(Input::BACK)
pbChangeSpecies(nil)
pbChangeSpecies(nil, nil)
refresh
break
elsif Input.trigger?(Input::USE)
pbChangeSpecies(allspecies[cw.index][0])
ret = allspecies[cw.index][0]
pbChangeSpecies(allspecies[cw.index][1], allspecies[cw.index][2])
ret = true
break
end
end
@@ -399,7 +397,7 @@ class SpritePositionerScreen
species = @scene.pbChooseSpecies
break if !species
loop do
command = @scene.pbMenu(species)
command = @scene.pbMenu
break if command < 0
loop do
par = @scene.pbSetParameter(command)

View File

@@ -1137,6 +1137,7 @@ DebugMenuCommands.register("createpbs", {
"phone.txt",
"pokemon.txt",
"pokemon_forms.txt",
"pokemon_metrics.txt",
"regional_dexes.txt",
"ribbons.txt",
"shadow_movesets.txt",
@@ -1161,13 +1162,14 @@ DebugMenuCommands.register("createpbs", {
when 10 then Compiler.write_phone
when 11 then Compiler.write_pokemon
when 12 then Compiler.write_pokemon_forms
when 13 then Compiler.write_regional_dexes
when 14 then Compiler.write_ribbons
when 15 then Compiler.write_shadow_movesets
when 16 then Compiler.write_town_map
when 17 then Compiler.write_trainer_types
when 18 then Compiler.write_trainers
when 19 then Compiler.write_types
when 13 then Compiler.write_pokemon_metrics
when 14 then Compiler.write_regional_dexes
when 15 then Compiler.write_ribbons
when 16 then Compiler.write_shadow_movesets
when 17 then Compiler.write_town_map
when 18 then Compiler.write_trainer_types
when 19 then Compiler.write_trainers
when 20 then Compiler.write_types
else break
end
pbMessage(_INTL("File written."))

View File

@@ -724,6 +724,8 @@ module Compiler
compile_pokemon # Depends on Move, Item, Type, Ability
yield(_INTL("Compiling Pokémon forms data"))
compile_pokemon_forms # Depends on Species, Move, Item, Type, Ability
yield(_INTL("Compiling Pokémon metrics data"))
compile_pokemon_metrics # Depends on Species
yield(_INTL("Compiling shadow moveset data"))
compile_shadow_movesets # Depends on Species, Move
yield(_INTL("Compiling Regional Dexes"))
@@ -774,6 +776,7 @@ module Compiler
"ribbons.dat",
"shadow_movesets.dat",
"species.dat",
"species_metrics.dat",
"town_map.dat",
"trainer_lists.dat",
"trainer_types.dat",
@@ -793,6 +796,7 @@ module Compiler
"phone.txt",
"pokemon.txt",
"pokemon_forms.txt",
"pokemon_metrics.txt",
"regional_dexes.txt",
"ribbons.txt",
"shadow_movesets.txt",

View File

@@ -616,14 +616,7 @@ module Compiler
:shape => contents["Shape"],
:habitat => contents["Habitat"],
:generation => contents["Generation"],
:flags => contents["Flags"],
:back_sprite_x => contents["BattlerPlayerX"],
:back_sprite_y => contents["BattlerPlayerY"],
:front_sprite_x => contents["BattlerEnemyX"],
:front_sprite_y => contents["BattlerEnemyY"],
:front_sprite_altitude => contents["BattlerAltitude"],
:shadow_x => contents["BattlerShadowX"],
:shadow_size => contents["BattlerShadowSize"]
:flags => contents["Flags"]
}
# Add species' data to records
GameData::Species.register(species_hash)
@@ -631,6 +624,21 @@ module Compiler
species_form_names.push(species_hash[:form_name])
species_categories.push(species_hash[:category])
species_pokedex_entries.push(species_hash[:pokedex_entry])
# Save metrics data if defined (backwards compatibility)
if contents["BattlerPlayerX"] || contents["BattlerPlayerY"] ||
contents["BattlerEnemyX"] || contents["BattlerEnemyY"] ||
contents["BattlerAltitude"] || contents["BattlerShadowX"] ||
contents["BattlerShadowSize"]
metrics_hash = {
:id => contents["InternalName"].to_sym,
:back_sprite => [contents["BattlerPlayerX"] || 0, contents["BattlerPlayerY"] || 0],
:front_sprite => [contents["BattlerEnemyX"] || 0, contents["BattlerEnemyY"] || 0],
:front_sprite_altitude => contents["BattlerAltitude"] || 0,
:shadow_x => contents["BattlerShadowX"] || 0,
:shadow_size => contents["BattlerShadowSize"] || 2
}
GameData::SpeciesMetrics.register(metrics_hash)
end
}
}
# Enumerate all evolution species and parameters (this couldn't be done earlier)
@@ -660,6 +668,7 @@ module Compiler
end
# Save all data
GameData::Species.save
GameData::SpeciesMetrics.save
MessageTypes.setMessagesAsHash(MessageTypes::Species, species_names)
MessageTypes.setMessagesAsHash(MessageTypes::FormNames, species_form_names)
MessageTypes.setMessagesAsHash(MessageTypes::Kinds, species_categories)
@@ -688,7 +697,7 @@ module Compiler
# Split section_name into a species number and form number
split_section_name = section_name.split(/[-,\s]/)
if split_section_name.length != 2
raise _INTL("Section name {1} is invalid ({2}). Expected syntax like [XXX,Y] (XXX=species ID, Y=form number).", sectionName, path)
raise _INTL("Section name {1} is invalid ({2}). Expected syntax like [XXX,Y] (XXX=species ID, Y=form number).", section_name, path)
end
species_symbol = csvEnumField!(split_section_name[0], :Species, nil, nil)
form = csvPosInt!(split_section_name[1])
@@ -797,14 +806,7 @@ module Compiler
:mega_stone => contents["MegaStone"],
:mega_move => contents["MegaMove"],
:unmega_form => contents["UnmegaForm"],
:mega_message => contents["MegaMessage"],
:back_sprite_x => contents["BattlerPlayerX"] || base_data.back_sprite_x,
:back_sprite_y => contents["BattlerPlayerY"] || base_data.back_sprite_y,
:front_sprite_x => contents["BattlerEnemyX"] || base_data.front_sprite_x,
:front_sprite_y => contents["BattlerEnemyY"] || base_data.front_sprite_y,
:front_sprite_altitude => contents["BattlerAltitude"] || base_data.front_sprite_altitude,
:shadow_x => contents["BattlerShadowX"] || base_data.shadow_x,
:shadow_size => contents["BattlerShadowSize"] || base_data.shadow_size
:mega_message => contents["MegaMessage"]
}
# If form is single-typed, ensure it remains so if base species is dual-typed
species_hash[:type2] = contents["Type1"] if contents["Type1"] && !contents["Type2"]
@@ -820,6 +822,31 @@ module Compiler
species_form_names.push(species_hash[:form_name])
species_categories.push(species_hash[:category])
species_pokedex_entries.push(species_hash[:pokedex_entry])
# Save metrics data if defined (backwards compatibility)
if contents["BattlerPlayerX"] || contents["BattlerPlayerY"] ||
contents["BattlerEnemyX"] || contents["BattlerEnemyY"] ||
contents["BattlerAltitude"] || contents["BattlerShadowX"] ||
contents["BattlerShadowSize"]
base_metrics = GameData::SpeciesMetrics.get_species_form(species_symbol, 0)
back_x = contents["BattlerPlayerX"] || base_metrics.back_sprite[0]
back_y = contents["BattlerPlayerY"] || base_metrics.back_sprite[1]
front_x = contents["BattlerEnemyX"] || base_metrics.front_sprite[0]
front_y = contents["BattlerEnemyY"] || base_metrics.front_sprite[1]
altitude = contents["BattlerAltitude"] || base_metrics.front_sprite_altitude
shadow_x = contents["BattlerShadowX"] || base_metrics.shadow_x
shadow_size = contents["BattlerShadowSize"] || base_metrics.shadow_size
metrics_hash = {
:id => form_symbol,
:species => species_symbol,
:form => form,
:back_sprite => [back_x, back_y],
:front_sprite => [front_x, front_y],
:front_sprite_altitude => altitude,
:shadow_x => shadow_x,
:shadow_size => shadow_size
}
GameData::SpeciesMetrics.register(metrics_hash)
end
}
}
# Add prevolution "evolution" entry for all evolved forms that define their
@@ -837,6 +864,7 @@ module Compiler
end
# Save all data
GameData::Species.save
GameData::SpeciesMetrics.save
MessageTypes.addMessagesAsHash(MessageTypes::Species, species_names)
MessageTypes.addMessagesAsHash(MessageTypes::FormNames, species_form_names)
MessageTypes.addMessagesAsHash(MessageTypes::Kinds, species_categories)
@@ -844,6 +872,61 @@ module Compiler
Graphics.update
end
#=============================================================================
# Compile Pokémon metrics data
#=============================================================================
def compile_pokemon_metrics(path = "PBS/pokemon_metrics.txt")
return if !safeExists?(path)
schema = GameData::SpeciesMetrics::SCHEMA
# Read from PBS file
File.open(path, "rb") { |f|
FileLineData.file = path # For error reporting
# Read a whole section's lines at once, then run through this code.
# contents is a hash containing all the XXX=YYY lines in that section, where
# the keys are the XXX and the values are the YYY (as unprocessed strings).
pbEachFileSection(f) { |contents, section_name|
FileLineData.setSection(section_name, "header", nil) # For error reporting
# Split section_name into a species number and form number
split_section_name = section_name.split(/[-,\s]/)
if split_section_name.length == 0 || split_section_name.length > 2
raise _INTL("Section name {1} is invalid ({2}). Expected syntax like [XXX] or [XXX,Y] (XXX=species ID, Y=form number).", section_name, path)
end
species_symbol = csvEnumField!(split_section_name[0], :Species, nil, nil)
form = (split_section_name[1]) ? csvPosInt!(split_section_name[1]) : 0
# Go through schema hash of compilable data and compile this section
for key in schema.keys
# Skip empty properties (none are required)
if nil_or_empty?(contents[key])
contents[key] = nil
next
end
FileLineData.setSection(section_name, key, contents[key]) # For error reporting
# Compile value for key
value = pbGetCsvRecord(contents[key], key, schema[key])
value = nil if value.is_a?(Array) && value.length == 0
contents[key] = value
end
# Construct species hash
form_symbol = (form > 0) ? sprintf("%s_%d", species_symbol.to_s, form).to_sym : species_symbol
species_hash = {
:id => form_symbol,
:species => species_symbol,
:form => form,
:back_sprite => contents["BackSprite"],
:front_sprite => contents["FrontSprite"],
:front_sprite_altitude => contents["FrontSpriteAltitude"],
:shadow_x => contents["ShadowX"],
:shadow_size => contents["ShadowSize"]
}
# Add form's data to records
GameData::SpeciesMetrics.register(species_hash)
}
}
# Save all data
GameData::SpeciesMetrics.save
Graphics.update
end
#=============================================================================
# Compile Shadow movesets
#=============================================================================

View File

@@ -308,13 +308,6 @@ module Compiler
f.write(sprintf("WildItemCommon = %s\r\n", species.wild_item_common)) if species.wild_item_common
f.write(sprintf("WildItemUncommon = %s\r\n", species.wild_item_uncommon)) if species.wild_item_uncommon
f.write(sprintf("WildItemRare = %s\r\n", species.wild_item_rare)) if species.wild_item_rare
f.write(sprintf("BattlerPlayerX = %d\r\n", species.back_sprite_x))
f.write(sprintf("BattlerPlayerY = %d\r\n", species.back_sprite_y))
f.write(sprintf("BattlerEnemyX = %d\r\n", species.front_sprite_x))
f.write(sprintf("BattlerEnemyY = %d\r\n", species.front_sprite_y))
f.write(sprintf("BattlerAltitude = %d\r\n", species.front_sprite_altitude)) if species.front_sprite_altitude != 0
f.write(sprintf("BattlerShadowX = %d\r\n", species.shadow_x))
f.write(sprintf("BattlerShadowSize = %d\r\n", species.shadow_size))
if species.evolutions.any? { |evo| !evo[3] }
f.write("Evolutions = ")
need_comma = false
@@ -415,13 +408,6 @@ module Compiler
f.write(sprintf("WildItemUncommon = %s\r\n", species.wild_item_uncommon)) if species.wild_item_uncommon
f.write(sprintf("WildItemRare = %s\r\n", species.wild_item_rare)) if species.wild_item_rare
end
f.write(sprintf("BattlerPlayerX = %d\r\n", species.back_sprite_x)) if species.back_sprite_x != base_species.back_sprite_x
f.write(sprintf("BattlerPlayerY = %d\r\n", species.back_sprite_y)) if species.back_sprite_y != base_species.back_sprite_y
f.write(sprintf("BattlerEnemyX = %d\r\n", species.front_sprite_x)) if species.front_sprite_x != base_species.front_sprite_x
f.write(sprintf("BattlerEnemyY = %d\r\n", species.front_sprite_y)) if species.front_sprite_y != base_species.front_sprite_y
f.write(sprintf("BattlerAltitude = %d\r\n", species.front_sprite_altitude)) if species.front_sprite_altitude != base_species.front_sprite_altitude
f.write(sprintf("BattlerShadowX = %d\r\n", species.shadow_x)) if species.shadow_x != base_species.shadow_x
f.write(sprintf("BattlerShadowSize = %d\r\n", species.shadow_size)) if species.shadow_size != base_species.shadow_size
if species.evolutions != base_species.evolutions && species.evolutions.any? { |evo| !evo[3] }
f.write("Evolutions = ")
need_comma = false
@@ -447,6 +433,59 @@ module Compiler
Graphics.update
end
#=============================================================================
# Write species metrics
#=============================================================================
def write_pokemon_metrics
echo _INTL("Writing species metrics...")
# Get in species order then in form order
sort_array = []
dex_numbers = {}
i = 0
GameData::SpeciesMetrics.each do |metrics|
dex_numbers[metrics.species] = i if !dex_numbers[metrics.species]
sort_array.push([dex_numbers[metrics.species], metrics.id, metrics.species, metrics.form])
i += 1
end
sort_array.sort! { |a, b| (a[0] == b[0]) ? a[3] <=> b[3] : a[0] <=> b[0] }
# Write file
File.open("PBS/pokemon_metrics.txt", "wb") { |f|
idx = 0
add_PBS_header_to_file(f)
sort_array.each do |val|
echo "." if idx % 50 == 0
idx += 1
Graphics.update if idx % 100 == 0
species = GameData::SpeciesMetrics.get(val[1])
if species.form > 0
base_species = GameData::SpeciesMetrics.get(val[2])
next if species.back_sprite == base_species.back_sprite &&
species.front_sprite == base_species.front_sprite &&
species.front_sprite_altitude == base_species.front_sprite_altitude &&
species.shadow_x == base_species.shadow_x &&
species.shadow_size == base_species.shadow_size
else
next if species.back_sprite == [0, 0] && species.front_sprite == [0, 0] &&
species.front_sprite_altitude == 0 &&
species.shadow_x == 0 && species.shadow_size == 2
end
f.write("\#-------------------------------\r\n")
if species.form > 0
f.write(sprintf("[%s,%d]\r\n", species.species, species.form))
else
f.write(sprintf("[%s]\r\n", species.species))
end
f.write(sprintf("BackSprite = %s\r\n", species.back_sprite.join(",")))
f.write(sprintf("FrontSprite = %s\r\n", species.front_sprite.join(",")))
f.write(sprintf("FrontSpriteAltitude = %d\r\n", species.front_sprite_altitude)) if species.front_sprite_altitude != 0
f.write(sprintf("ShadowX = %d\r\n", species.shadow_x))
f.write(sprintf("ShadowSize = %d\r\n", species.shadow_size))
end
}
echoln _INTL("done")
Graphics.update
end
#=============================================================================
# Save Shadow movesets to PBS file
#=============================================================================
@@ -812,6 +851,7 @@ module Compiler
write_berry_plants
write_pokemon
write_pokemon_forms
write_pokemon_metrics
write_shadow_movesets
write_regional_dexes
write_ribbons

View File

@@ -1435,7 +1435,8 @@ module Compiler
t = Time.now.to_i
Graphics.update
trainerChecker = TrainerChecker.new
echo _INTL("Processing {1} maps...", mapData.mapinfos.keys.length)
any_changed = false
echoln _INTL("Processing {1} maps...", mapData.mapinfos.keys.length)
for id in mapData.mapinfos.keys.sort
changed = false
map = mapData.getMap(id)
@@ -1469,10 +1470,10 @@ module Compiler
end
changed = true if check_counters(map,id,mapData)
if changed
any_changed = true
mapData.saveMap(id)
mapData.saveTilesets
echoln ""
echo _INTL("Map {1}: '{2}' modified and saved.", id, mapData.mapinfos[id].name)
echoln _INTL("Map {1}: '{2}' modified and saved.", id, mapData.mapinfos[id].name)
end
end
echoln ""
@@ -1485,8 +1486,14 @@ module Compiler
if newevent
commonEvents[key] = newevent
changed = true
any_changed = true
end
end
save_data(commonEvents,"Data/CommonEvents.rxdata") if changed
echoln ""
if any_changed
echoln _INTL("!!! RMXP data was altered. Close RMXP now to ensure changes are applied. !!!")
echoln ""
end
end
end