mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Added PBS file pokemon_metrics.txt, for all Pokémon sprite positionings
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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
|
||||
#=============================================================================
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user