mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Rewrote and standardised several PBS writer methods
This commit is contained in:
@@ -8,6 +8,34 @@ module Compiler
|
||||
file.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
|
||||
end
|
||||
|
||||
def write_PBS_file_generic(game_data, path)
|
||||
write_pbs_file_message_start(path)
|
||||
schema = game_data::SCHEMA
|
||||
File.open(path, "wb") { |f|
|
||||
add_PBS_header_to_file(f)
|
||||
# Write each element in turn
|
||||
game_data.each do |element|
|
||||
f.write("\#-------------------------------\r\n")
|
||||
if schema["SectionName"]
|
||||
f.write("[")
|
||||
pbWriteCsvRecord(element.get_property_for_PBS("SectionName"), f, schema["SectionName"])
|
||||
f.write("]\r\n")
|
||||
else
|
||||
f.write("[#{element.id}]\r\n")
|
||||
end
|
||||
schema.each_key do |key|
|
||||
next if key == "SectionName"
|
||||
val = element.get_property_for_PBS(key)
|
||||
next if val.nil?
|
||||
f.write(sprintf("%s = ", key))
|
||||
pbWriteCsvRecord(val, f, schema[key])
|
||||
f.write("\r\n")
|
||||
end
|
||||
end
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Save Town Map data to PBS file
|
||||
#=============================================================================
|
||||
@@ -131,126 +159,35 @@ module Compiler
|
||||
# Save type data to PBS file
|
||||
#=============================================================================
|
||||
def write_types(path = "PBS/types.txt")
|
||||
write_pbs_file_message_start(path)
|
||||
File.open(path, "wb") { |f|
|
||||
add_PBS_header_to_file(f)
|
||||
# Write each type in turn
|
||||
GameData::Type.each do |type|
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write("[#{type.id}]\r\n")
|
||||
f.write("Name = #{type.real_name}\r\n")
|
||||
f.write("IconPosition = #{type.icon_position}\r\n")
|
||||
f.write("IsSpecialType = true\r\n") if type.special?
|
||||
f.write("IsPseudoType = true\r\n") if type.pseudo_type
|
||||
f.write(sprintf("Flags = %s\r\n", type.flags.join(","))) if type.flags.length > 0
|
||||
f.write("Weaknesses = #{type.weaknesses.join(',')}\r\n") if type.weaknesses.length > 0
|
||||
f.write("Resistances = #{type.resistances.join(',')}\r\n") if type.resistances.length > 0
|
||||
f.write("Immunities = #{type.immunities.join(',')}\r\n") if type.immunities.length > 0
|
||||
end
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
write_PBS_file_generic(GameData::Type, path)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Save ability data to PBS file
|
||||
#=============================================================================
|
||||
def write_abilities(path = "PBS/abilities.txt")
|
||||
write_pbs_file_message_start(path)
|
||||
File.open(path, "wb") { |f|
|
||||
add_PBS_header_to_file(f)
|
||||
# Write each ability in turn
|
||||
GameData::Ability.each do |ability|
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write("[#{ability.id}]\r\n")
|
||||
f.write("Name = #{ability.real_name}\r\n")
|
||||
f.write("Description = #{ability.real_description}\r\n")
|
||||
f.write(sprintf("Flags = %s\r\n", ability.flags.join(","))) if ability.flags.length > 0
|
||||
end
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
write_PBS_file_generic(GameData::Ability, path)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Save move data to PBS file
|
||||
#=============================================================================
|
||||
def write_moves(path = "PBS/moves.txt")
|
||||
write_pbs_file_message_start(path)
|
||||
File.open(path, "wb") { |f|
|
||||
idx = 0
|
||||
add_PBS_header_to_file(f)
|
||||
# Write each move in turn
|
||||
GameData::Move.each do |move|
|
||||
echo "." if idx % 50 == 0
|
||||
idx += 1
|
||||
Graphics.update if idx % 250 == 0
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write("[#{move.id}]\r\n")
|
||||
f.write("Name = #{move.real_name}\r\n")
|
||||
f.write("Type = #{move.type}\r\n")
|
||||
category = GameData::Move::SCHEMA["Category"][2][move.category]
|
||||
f.write("Category = #{category}\r\n")
|
||||
f.write("Power = #{move.base_damage}\r\n") if move.base_damage > 0
|
||||
f.write("Accuracy = #{move.accuracy}\r\n")
|
||||
f.write("TotalPP = #{move.total_pp}\r\n")
|
||||
f.write("Target = #{move.target}\r\n")
|
||||
f.write("Priority = #{move.priority}\r\n") if move.priority != 0
|
||||
f.write("FunctionCode = #{move.function_code}\r\n")
|
||||
f.write("Flags = #{move.flags.join(',')}\r\n") if move.flags.length > 0
|
||||
f.write("EffectChance = #{move.effect_chance}\r\n") if move.effect_chance > 0
|
||||
f.write("Description = #{move.real_description}\r\n")
|
||||
end
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
write_PBS_file_generic(GameData::Move, path)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Save item data to PBS file
|
||||
#=============================================================================
|
||||
def write_items(path = "PBS/items.txt")
|
||||
write_pbs_file_message_start(path)
|
||||
File.open(path, "wb") { |f|
|
||||
idx = 0
|
||||
add_PBS_header_to_file(f)
|
||||
GameData::Item.each do |item|
|
||||
echo "." if idx % 50 == 0
|
||||
idx += 1
|
||||
Graphics.update if idx % 250 == 0
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write(sprintf("[%s]\r\n", item.id))
|
||||
f.write(sprintf("Name = %s\r\n", item.real_name))
|
||||
f.write(sprintf("NamePlural = %s\r\n", item.real_name_plural))
|
||||
f.write(sprintf("Pocket = %d\r\n", item.pocket))
|
||||
f.write(sprintf("Price = %d\r\n", item.price))
|
||||
f.write(sprintf("SellPrice = %d\r\n", item.sell_price)) if item.sell_price != item.price / 2
|
||||
field_use = GameData::Item::SCHEMA["FieldUse"][2].key(item.field_use)
|
||||
f.write(sprintf("FieldUse = %s\r\n", field_use)) if field_use
|
||||
battle_use = GameData::Item::SCHEMA["BattleUse"][2].key(item.battle_use)
|
||||
f.write(sprintf("BattleUse = %s\r\n", battle_use)) if battle_use
|
||||
f.write(sprintf("Consumable = false\r\n")) if !item.is_important? && !item.consumable
|
||||
f.write(sprintf("Flags = %s\r\n", item.flags.join(","))) if item.flags.length > 0
|
||||
f.write(sprintf("Move = %s\r\n", item.move)) if item.move
|
||||
f.write(sprintf("Description = %s\r\n", item.real_description))
|
||||
end
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
write_PBS_file_generic(GameData::Item, path)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Save berry plant data to PBS file
|
||||
#=============================================================================
|
||||
def write_berry_plants(path = "PBS/berry_plants.txt")
|
||||
write_pbs_file_message_start(path)
|
||||
File.open(path, "wb") { |f|
|
||||
add_PBS_header_to_file(f)
|
||||
GameData::BerryPlant.each do |bp|
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write(sprintf("[%s]\r\n", bp.id))
|
||||
f.write(sprintf("HoursPerStage = %d\r\n", bp.hours_per_stage))
|
||||
f.write(sprintf("DryingPerHour = %d\r\n", bp.drying_per_hour))
|
||||
f.write(sprintf("Yield = %s\r\n", bp.yield.join(",")))
|
||||
end
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
write_PBS_file_generic(GameData::BerryPlant, path)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
@@ -258,85 +195,25 @@ module Compiler
|
||||
#=============================================================================
|
||||
def write_pokemon(path = "PBS/pokemon.txt")
|
||||
write_pbs_file_message_start(path)
|
||||
schema = GameData::Species.schema
|
||||
File.open(path, "wb") { |f|
|
||||
idx = 0
|
||||
add_PBS_header_to_file(f)
|
||||
GameData::Species.each_species do |species|
|
||||
echo "." if idx % 50 == 0
|
||||
idx += 1
|
||||
Graphics.update if idx % 250 == 0
|
||||
# Write each element in turn
|
||||
GameData::Species.each_species do |element|
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write(sprintf("[%s]\r\n", species.id))
|
||||
f.write(sprintf("Name = %s\r\n", species.real_name))
|
||||
f.write(sprintf("Types = %s\r\n", species.types.uniq.compact.join(",")))
|
||||
stats_array = []
|
||||
evs_array = []
|
||||
GameData::Stat.each_main do |s|
|
||||
next if s.pbs_order < 0
|
||||
stats_array[s.pbs_order] = species.base_stats[s.id]
|
||||
evs_array.concat([s.id.to_s, species.evs[s.id]]) if species.evs[s.id] > 0
|
||||
if schema["SectionName"]
|
||||
f.write("[")
|
||||
pbWriteCsvRecord(element.get_property_for_PBS("SectionName"), f, schema["SectionName"])
|
||||
f.write("]\r\n")
|
||||
else
|
||||
f.write("[#{element.id}]\r\n")
|
||||
end
|
||||
f.write(sprintf("BaseStats = %s\r\n", stats_array.join(",")))
|
||||
f.write(sprintf("GenderRatio = %s\r\n", species.gender_ratio))
|
||||
f.write(sprintf("GrowthRate = %s\r\n", species.growth_rate))
|
||||
f.write(sprintf("BaseExp = %d\r\n", species.base_exp))
|
||||
f.write(sprintf("EVs = %s\r\n", evs_array.join(",")))
|
||||
f.write(sprintf("CatchRate = %d\r\n", species.catch_rate))
|
||||
f.write(sprintf("Happiness = %d\r\n", species.happiness))
|
||||
if species.abilities.length > 0
|
||||
f.write(sprintf("Abilities = %s\r\n", species.abilities.join(",")))
|
||||
end
|
||||
if species.hidden_abilities.length > 0
|
||||
f.write(sprintf("HiddenAbilities = %s\r\n", species.hidden_abilities.join(",")))
|
||||
end
|
||||
if species.moves.length > 0
|
||||
f.write(sprintf("Moves = %s\r\n", species.moves.join(",")))
|
||||
end
|
||||
if species.tutor_moves.length > 0
|
||||
f.write(sprintf("TutorMoves = %s\r\n", species.tutor_moves.join(",")))
|
||||
end
|
||||
if species.egg_moves.length > 0
|
||||
f.write(sprintf("EggMoves = %s\r\n", species.egg_moves.join(",")))
|
||||
end
|
||||
if species.egg_groups.length > 0
|
||||
f.write(sprintf("EggGroups = %s\r\n", species.egg_groups.join(",")))
|
||||
end
|
||||
f.write(sprintf("HatchSteps = %d\r\n", species.hatch_steps))
|
||||
f.write(sprintf("Incense = %s\r\n", species.incense)) if species.incense
|
||||
if species.offspring.length > 0
|
||||
f.write(sprintf("Offspring = %s\r\n", species.offspring.join(",")))
|
||||
end
|
||||
f.write(sprintf("Height = %.1f\r\n", species.height / 10.0))
|
||||
f.write(sprintf("Weight = %.1f\r\n", species.weight / 10.0))
|
||||
f.write(sprintf("Color = %s\r\n", species.color))
|
||||
f.write(sprintf("Shape = %s\r\n", species.shape))
|
||||
f.write(sprintf("Habitat = %s\r\n", species.habitat)) if species.habitat != :None
|
||||
f.write(sprintf("Category = %s\r\n", species.real_category))
|
||||
f.write(sprintf("Pokedex = %s\r\n", species.real_pokedex_entry))
|
||||
f.write(sprintf("FormName = %s\r\n", species.real_form_name)) if species.real_form_name && !species.real_form_name.empty?
|
||||
f.write(sprintf("Generation = %d\r\n", species.generation)) if species.generation != 0
|
||||
f.write(sprintf("Flags = %s\r\n", species.flags.join(","))) if species.flags.length > 0
|
||||
f.write(sprintf("WildItemCommon = %s\r\n", species.wild_item_common.join(","))) if species.wild_item_common.length > 0
|
||||
f.write(sprintf("WildItemUncommon = %s\r\n", species.wild_item_uncommon.join(","))) if species.wild_item_uncommon.length > 0
|
||||
f.write(sprintf("WildItemRare = %s\r\n", species.wild_item_rare.join(","))) if species.wild_item_rare.length > 0
|
||||
if species.evolutions.any? { |evo| !evo[3] }
|
||||
f.write("Evolutions = ")
|
||||
need_comma = false
|
||||
species.evolutions.each do |evo|
|
||||
next if evo[3] # Skip prevolution entries
|
||||
f.write(",") if need_comma
|
||||
need_comma = true
|
||||
evo_type_data = GameData::Evolution.get(evo[1])
|
||||
param_type = evo_type_data.parameter
|
||||
f.write(sprintf("%s,%s,", evo[0], evo_type_data.id.to_s))
|
||||
if !param_type.nil?
|
||||
if param_type.is_a?(Symbol) && !GameData.const_defined?(param_type)
|
||||
f.write(getConstantName(param_type, evo[2]))
|
||||
else
|
||||
f.write(evo[2].to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
schema.each_key do |key|
|
||||
next if key == "SectionName"
|
||||
val = element.get_property_for_PBS(key)
|
||||
next if val.nil?
|
||||
f.write(sprintf("%s = ", key))
|
||||
pbWriteCsvRecord(val, f, schema[key])
|
||||
f.write("\r\n")
|
||||
end
|
||||
end
|
||||
@@ -349,96 +226,26 @@ module Compiler
|
||||
#=============================================================================
|
||||
def write_pokemon_forms(path = "PBS/pokemon_forms.txt")
|
||||
write_pbs_file_message_start(path)
|
||||
schema = GameData::Species.schema(true)
|
||||
File.open(path, "wb") { |f|
|
||||
idx = 0
|
||||
add_PBS_header_to_file(f)
|
||||
GameData::Species.each do |species|
|
||||
echo "." if idx % 50 == 0
|
||||
idx += 1
|
||||
Graphics.update if idx % 250 == 0
|
||||
next if species.form == 0
|
||||
base_species = GameData::Species.get(species.species)
|
||||
# Write each element in turn
|
||||
GameData::Species.each do |element|
|
||||
next if element.form == 0
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write(sprintf("[%s,%d]\r\n", species.species, species.form))
|
||||
f.write(sprintf("FormName = %s\r\n", species.real_form_name)) if species.real_form_name && !species.real_form_name.empty?
|
||||
f.write(sprintf("PokedexForm = %d\r\n", species.pokedex_form)) if species.pokedex_form != species.form
|
||||
f.write(sprintf("MegaStone = %s\r\n", species.mega_stone)) if species.mega_stone
|
||||
f.write(sprintf("MegaMove = %s\r\n", species.mega_move)) if species.mega_move
|
||||
f.write(sprintf("UnmegaForm = %d\r\n", species.unmega_form)) if species.unmega_form != 0
|
||||
f.write(sprintf("MegaMessage = %d\r\n", species.mega_message)) if species.mega_message != 0
|
||||
if species.types.uniq.compact != base_species.types.uniq.compact
|
||||
f.write(sprintf("Types = %s\r\n", species.types.uniq.compact.join(",")))
|
||||
if schema["SectionName"]
|
||||
f.write("[")
|
||||
pbWriteCsvRecord(element.get_property_for_PBS("SectionName", true), f, schema["SectionName"])
|
||||
f.write("]\r\n")
|
||||
else
|
||||
f.write("[#{element.id}]\r\n")
|
||||
end
|
||||
stats_array = []
|
||||
evs_array = []
|
||||
GameData::Stat.each_main do |s|
|
||||
next if s.pbs_order < 0
|
||||
stats_array[s.pbs_order] = species.base_stats[s.id]
|
||||
evs_array.concat([s.id.to_s, species.evs[s.id]]) if species.evs[s.id] > 0
|
||||
end
|
||||
f.write(sprintf("BaseStats = %s\r\n", stats_array.join(","))) if species.base_stats != base_species.base_stats
|
||||
f.write(sprintf("BaseExp = %d\r\n", species.base_exp)) if species.base_exp != base_species.base_exp
|
||||
f.write(sprintf("EVs = %s\r\n", evs_array.join(","))) if species.evs != base_species.evs
|
||||
f.write(sprintf("CatchRate = %d\r\n", species.catch_rate)) if species.catch_rate != base_species.catch_rate
|
||||
f.write(sprintf("Happiness = %d\r\n", species.happiness)) if species.happiness != base_species.happiness
|
||||
if species.abilities.length > 0 && species.abilities != base_species.abilities
|
||||
f.write(sprintf("Abilities = %s\r\n", species.abilities.join(",")))
|
||||
end
|
||||
if species.hidden_abilities.length > 0 && species.hidden_abilities != base_species.hidden_abilities
|
||||
f.write(sprintf("HiddenAbilities = %s\r\n", species.hidden_abilities.join(",")))
|
||||
end
|
||||
if species.moves.length > 0 && species.moves != base_species.moves
|
||||
f.write(sprintf("Moves = %s\r\n", species.moves.join(",")))
|
||||
end
|
||||
if species.tutor_moves.length > 0 && species.tutor_moves != base_species.tutor_moves
|
||||
f.write(sprintf("TutorMoves = %s\r\n", species.tutor_moves.join(",")))
|
||||
end
|
||||
if species.egg_moves.length > 0 && species.egg_moves != base_species.egg_moves
|
||||
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(sprintf("EggGroups = %s\r\n", species.egg_groups.join(",")))
|
||||
end
|
||||
f.write(sprintf("HatchSteps = %d\r\n", species.hatch_steps)) if species.hatch_steps != base_species.hatch_steps
|
||||
if species.offspring.length > 0 && species.offspring != base_species.offspring
|
||||
f.write(sprintf("Offspring = %s\r\n", species.offspring.join(",")))
|
||||
end
|
||||
f.write(sprintf("Height = %.1f\r\n", species.height / 10.0)) if species.height != base_species.height
|
||||
f.write(sprintf("Weight = %.1f\r\n", species.weight / 10.0)) if species.weight != base_species.weight
|
||||
f.write(sprintf("Color = %s\r\n", species.color)) if species.color != base_species.color
|
||||
f.write(sprintf("Shape = %s\r\n", species.shape)) if species.shape != base_species.shape
|
||||
if species.habitat != :None && species.habitat != base_species.habitat
|
||||
f.write(sprintf("Habitat = %s\r\n", species.habitat))
|
||||
end
|
||||
f.write(sprintf("Category = %s\r\n", species.real_category)) if species.real_category != base_species.real_category
|
||||
f.write(sprintf("Pokedex = %s\r\n", species.real_pokedex_entry)) if species.real_pokedex_entry != base_species.real_pokedex_entry
|
||||
f.write(sprintf("Generation = %d\r\n", species.generation)) if species.generation != base_species.generation
|
||||
f.write(sprintf("Flags = %s\r\n", species.flags.join(","))) if species.flags.length > 0 && species.flags != base_species.flags
|
||||
if species.wild_item_common != base_species.wild_item_common ||
|
||||
species.wild_item_uncommon != base_species.wild_item_uncommon ||
|
||||
species.wild_item_rare != base_species.wild_item_rare
|
||||
f.write(sprintf("WildItemCommon = %s\r\n", species.wild_item_common.join(","))) if species.wild_item_common.length > 0
|
||||
f.write(sprintf("WildItemUncommon = %s\r\n", species.wild_item_uncommon.join(","))) if species.wild_item_uncommon.length > 0
|
||||
f.write(sprintf("WildItemRare = %s\r\n", species.wild_item_rare.join(","))) if species.wild_item_rare.length > 0
|
||||
end
|
||||
if species.evolutions != base_species.evolutions && species.evolutions.any? { |evo| !evo[3] }
|
||||
f.write("Evolutions = ")
|
||||
need_comma = false
|
||||
species.evolutions.each do |evo|
|
||||
next if evo[3] # Skip prevolution entries
|
||||
f.write(",") if need_comma
|
||||
need_comma = true
|
||||
evo_type_data = GameData::Evolution.get(evo[1])
|
||||
param_type = evo_type_data.parameter
|
||||
f.write(sprintf("%s,%s,", evo[0], evo_type_data.id.to_s))
|
||||
if !param_type.nil?
|
||||
if param_type.is_a?(Symbol) && !GameData.const_defined?(param_type)
|
||||
f.write(getConstantName(param_type, evo[2]))
|
||||
else
|
||||
f.write(evo[2].to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
schema.each_key do |key|
|
||||
next if key == "SectionName"
|
||||
val = element.get_property_for_PBS(key, true)
|
||||
next if val.nil?
|
||||
f.write(sprintf("%s = ", key))
|
||||
pbWriteCsvRecord(val, f, schema[key])
|
||||
f.write("\r\n")
|
||||
end
|
||||
end
|
||||
@@ -451,48 +258,39 @@ module Compiler
|
||||
#=============================================================================
|
||||
def write_pokemon_metrics(path = "PBS/pokemon_metrics.txt")
|
||||
write_pbs_file_message_start(path)
|
||||
# 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
|
||||
schema = GameData::SpeciesMetrics::SCHEMA
|
||||
File.open(path, "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 % 250 == 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
|
||||
# Write each element in turn
|
||||
GameData::SpeciesMetrics.each do |element|
|
||||
if element.form > 0
|
||||
base_element = GameData::SpeciesMetrics.get(element.species)
|
||||
next if element.back_sprite == base_element.back_sprite &&
|
||||
element.front_sprite == base_element.front_sprite &&
|
||||
element.front_sprite_altitude == base_element.front_sprite_altitude &&
|
||||
element.shadow_x == base_element.shadow_x &&
|
||||
element.shadow_size == base_element.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
|
||||
next if element.back_sprite == [0, 0] && element.front_sprite == [0, 0] &&
|
||||
element.front_sprite_altitude == 0 &&
|
||||
element.shadow_x == 0 && element.shadow_size == 2
|
||||
end
|
||||
f.write("\#-------------------------------\r\n")
|
||||
if species.form > 0
|
||||
f.write(sprintf("[%s,%d]\r\n", species.species, species.form))
|
||||
if schema["SectionName"]
|
||||
f.write("[")
|
||||
pbWriteCsvRecord(element.get_property_for_PBS("SectionName"), f, schema["SectionName"])
|
||||
f.write("]\r\n")
|
||||
else
|
||||
f.write(sprintf("[%s]\r\n", species.species))
|
||||
f.write("[#{element.id}]\r\n")
|
||||
end
|
||||
schema.each_key do |key|
|
||||
next if key == "SectionName"
|
||||
val = element.get_property_for_PBS(key)
|
||||
next if val.nil?
|
||||
f.write(sprintf("%s = ", key))
|
||||
pbWriteCsvRecord(val, f, schema[key])
|
||||
f.write("\r\n")
|
||||
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
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
@@ -502,21 +300,7 @@ module Compiler
|
||||
# Save Shadow Pokémon data to PBS file
|
||||
#=============================================================================
|
||||
def write_shadow_pokemon(path = "PBS/shadow_pokemon.txt")
|
||||
write_pbs_file_message_start(path)
|
||||
File.open(path, "wb") { |f|
|
||||
idx = 0
|
||||
add_PBS_header_to_file(f)
|
||||
GameData::ShadowPokemon.each do |shadow|
|
||||
echo "." if idx % 150 == 0
|
||||
idx += 1
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write(sprintf("[%s]\r\n", shadow.id))
|
||||
f.write(sprintf("GaugeSize = %d\r\n", shadow.gauge_size))
|
||||
f.write(sprintf("Moves = %s\r\n", shadow.moves.join(","))) if shadow.moves.length > 0
|
||||
f.write(sprintf("Flags = %s\r\n", shadow.flags.join(","))) if shadow.flags.length > 0
|
||||
end
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
write_PBS_file_generic(GameData::ShadowPokemon, path)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
@@ -555,20 +339,7 @@ module Compiler
|
||||
# Save ability data to PBS file
|
||||
#=============================================================================
|
||||
def write_ribbons(path = "PBS/ribbons.txt")
|
||||
write_pbs_file_message_start(path)
|
||||
File.open(path, "wb") { |f|
|
||||
add_PBS_header_to_file(f)
|
||||
# Write each ability in turn
|
||||
GameData::Ribbon.each do |ribbon|
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write("[#{ribbon.id}]\r\n")
|
||||
f.write("Name = #{ribbon.real_name}\r\n")
|
||||
f.write("IconPosition = #{ribbon.icon_position}\r\n")
|
||||
f.write("Description = #{ribbon.real_description}\r\n")
|
||||
f.write(sprintf("Flags = %s\r\n", ribbon.flags.join(","))) if ribbon.flags.length > 0
|
||||
end
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
write_PBS_file_generic(GameData::Ribbon, path)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
@@ -615,24 +386,7 @@ module Compiler
|
||||
# Save trainer type data to PBS file
|
||||
#=============================================================================
|
||||
def write_trainer_types(path = "PBS/trainer_types.txt")
|
||||
write_pbs_file_message_start(path)
|
||||
File.open(path, "wb") { |f|
|
||||
add_PBS_header_to_file(f)
|
||||
GameData::TrainerType.each do |t|
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write(sprintf("[%s]\r\n", t.id))
|
||||
f.write(sprintf("Name = %s\r\n", t.real_name))
|
||||
gender = GameData::TrainerType::SCHEMA["Gender"][2].key(t.gender)
|
||||
f.write(sprintf("Gender = %s\r\n", gender))
|
||||
f.write(sprintf("BaseMoney = %d\r\n", t.base_money))
|
||||
f.write(sprintf("SkillLevel = %d\r\n", t.skill_level)) if t.skill_level != t.base_money
|
||||
f.write(sprintf("Flags = %s\r\n", t.flags.join(","))) if t.flags.length > 0
|
||||
f.write(sprintf("IntroBGM = %s\r\n", t.intro_BGM)) if !nil_or_empty?(t.intro_BGM)
|
||||
f.write(sprintf("BattleBGM = %s\r\n", t.battle_BGM)) if !nil_or_empty?(t.battle_BGM)
|
||||
f.write(sprintf("VictoryBGM = %s\r\n", t.victory_BGM)) if !nil_or_empty?(t.victory_BGM)
|
||||
end
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
write_PBS_file_generic(GameData::TrainerType, path)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
@@ -805,31 +559,31 @@ module Compiler
|
||||
#=============================================================================
|
||||
def write_metadata(path = "PBS/metadata.txt")
|
||||
write_pbs_file_message_start(path)
|
||||
global_schema = GameData::Metadata::SCHEMA
|
||||
player_schema = GameData::PlayerMetadata::SCHEMA
|
||||
File.open(path, "wb") { |f|
|
||||
add_PBS_header_to_file(f)
|
||||
# Write metadata
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write("[0]\r\n")
|
||||
metadata = GameData::Metadata.get
|
||||
schema = GameData::Metadata::SCHEMA
|
||||
schema.keys.each do |key|
|
||||
record = metadata.property_from_string(key)
|
||||
next if record.nil? || (record.is_a?(Array) && record.empty?)
|
||||
f.write(sprintf("%s = ", key))
|
||||
pbWriteCsvRecord(record, f, schema[key])
|
||||
f.write("\r\n")
|
||||
end
|
||||
# Write player metadata
|
||||
schema = GameData::PlayerMetadata::SCHEMA
|
||||
GameData::PlayerMetadata.each do |player_data|
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write(sprintf("[%d]\r\n", player_data.id))
|
||||
schema.keys.each do |key|
|
||||
record = player_data.property_from_string(key)
|
||||
next if record.nil? || (record.is_a?(Array) && record.empty?)
|
||||
f.write(sprintf("%s = ", key))
|
||||
pbWriteCsvRecord(record, f, schema[key])
|
||||
f.write("\r\n")
|
||||
# Write each element in turn
|
||||
[GameData::Metadata, GameData::PlayerMetadata].each do |game_data|
|
||||
schema = global_schema if game_data == GameData::Metadata
|
||||
schema = player_schema if game_data == GameData::PlayerMetadata
|
||||
game_data.each do |element|
|
||||
f.write("\#-------------------------------\r\n")
|
||||
if schema["SectionName"]
|
||||
f.write("[")
|
||||
pbWriteCsvRecord(element.get_property_for_PBS("SectionName"), f, schema["SectionName"])
|
||||
f.write("]\r\n")
|
||||
else
|
||||
f.write("[#{element.id}]\r\n")
|
||||
end
|
||||
schema.each_key do |key|
|
||||
next if key == "SectionName"
|
||||
val = element.get_property_for_PBS(key)
|
||||
next if val.nil?
|
||||
f.write(sprintf("%s = ", key))
|
||||
pbWriteCsvRecord(val, f, schema[key])
|
||||
f.write("\r\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
@@ -846,23 +600,21 @@ module Compiler
|
||||
File.open(path, "wb") { |f|
|
||||
idx = 0
|
||||
add_PBS_header_to_file(f)
|
||||
GameData::MapMetadata.each do |map_data|
|
||||
GameData::MapMetadata.each do |element|
|
||||
echo "." if idx % 50 == 0
|
||||
idx += 1
|
||||
Graphics.update if idx % 250 == 0
|
||||
f.write("\#-------------------------------\r\n")
|
||||
map_name = (map_infos && map_infos[map_data.id]) ? map_infos[map_data.id].name : nil
|
||||
if map_name
|
||||
f.write(sprintf("[%03d] # %s\r\n", map_data.id, map_name))
|
||||
f.write("Name = #{map_name}\r\n") if nil_or_empty?(map_data.real_name)
|
||||
else
|
||||
f.write(sprintf("[%03d]\r\n", map_data.id))
|
||||
end
|
||||
schema.keys.each do |key|
|
||||
record = map_data.property_from_string(key)
|
||||
next if record.nil? || (record.is_a?(Array) && record.empty?)
|
||||
map_name = (map_infos && map_infos[element.id]) ? map_infos[element.id].name : nil
|
||||
f.write(sprintf("[%03d]", element.id))
|
||||
f.write(sprintf(" # %s", map_name)) if map_name
|
||||
f.write("\r\n")
|
||||
schema.each_key do |key|
|
||||
next if key == "SectionName"
|
||||
val = element.get_property_for_PBS(key)
|
||||
next if val.nil?
|
||||
f.write(sprintf("%s = ", key))
|
||||
pbWriteCsvRecord(record, f, schema[key])
|
||||
pbWriteCsvRecord(val, f, schema[key])
|
||||
f.write("\r\n")
|
||||
end
|
||||
end
|
||||
@@ -926,33 +678,7 @@ module Compiler
|
||||
# Save dungeon parameters to PBS file
|
||||
#=============================================================================
|
||||
def write_dungeon_parameters(path = "PBS/dungeon_parameters.txt")
|
||||
write_pbs_file_message_start(path)
|
||||
schema = GameData::DungeonParameters::SCHEMA
|
||||
keys = schema.keys
|
||||
# Write file
|
||||
File.open(path, "wb") { |f|
|
||||
idx = 0
|
||||
add_PBS_header_to_file(f)
|
||||
GameData::DungeonParameters.each do |parameters_data|
|
||||
echo "." if idx % 50 == 0
|
||||
idx += 1
|
||||
Graphics.update if idx % 250 == 0
|
||||
f.write("\#-------------------------------\r\n")
|
||||
if parameters_data.version > 0
|
||||
f.write(sprintf("[%s,%d]\r\n", parameters_data.area, parameters_data.version))
|
||||
else
|
||||
f.write(sprintf("[%s]\r\n", parameters_data.area))
|
||||
end
|
||||
keys.each do |key|
|
||||
value = parameters_data.property_from_string(key)
|
||||
next if !value || (value.is_a?(Array) && value.length == 0)
|
||||
f.write(sprintf("%s = ", key))
|
||||
pbWriteCsvRecord(value, f, schema[key])
|
||||
f.write("\r\n")
|
||||
end
|
||||
end
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
write_PBS_file_generic(GameData::DungeonParameters, path)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
|
||||
Reference in New Issue
Block a user