Added compiler schema letter "m" which makes the value a symbol, refactored many PBS file compilers, removed support for old PBS formats/properties

This commit is contained in:
Maruno17
2022-11-16 22:03:12 +00:00
parent bbe654028c
commit 5d439de87d
18 changed files with 887 additions and 1193 deletions

View File

@@ -14,15 +14,15 @@ module GameData
DATA_FILENAME = "types.dat" DATA_FILENAME = "types.dat"
SCHEMA = { SCHEMA = {
"Name" => [0, "s"], "SectionName" => [:id, "m"],
"InternalName" => [0, "s"], "Name" => [:real_name, "s"],
"IsSpecialType" => [0, "b"], "IsSpecialType" => [:special_type, "b"],
"IsPseudoType" => [0, "b"], "IsPseudoType" => [:pseudo_type, "b"],
"Flags" => [0, "*s"], "Flags" => [:flags, "*s"],
"Weaknesses" => [0, "*s"], "Weaknesses" => [:weaknesses, "*m"],
"Resistances" => [0, "*s"], "Resistances" => [:resistances, "*m"],
"Immunities" => [0, "*s"], "Immunities" => [:immunities, "*m"],
"IconPosition" => [0, "u"] "IconPosition" => [:icon_position, "u"]
} }
extend ClassMethodsSymbols extend ClassMethodsSymbols
@@ -30,7 +30,7 @@ module GameData
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name] || "Unnamed" @real_name = hash[:real_name] || "Unnamed"
@special_type = hash[:special_type] || false @special_type = hash[:special_type] || false
@pseudo_type = hash[:pseudo_type] || false @pseudo_type = hash[:pseudo_type] || false
@flags = hash[:flags] || [] @flags = hash[:flags] || []

View File

@@ -12,16 +12,17 @@ module GameData
include InstanceMethods include InstanceMethods
SCHEMA = { SCHEMA = {
"Name" => [:name, "s"], "SectionName" => [:id, "m"],
"Description" => [:description, "q"], "Name" => [:real_name, "s"],
"Flags" => [:flags, "*s"] "Description" => [:real_description, "q"],
"Flags" => [:flags, "*s"]
} }
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name] || "Unnamed" @real_name = hash[:real_name] || "Unnamed"
@real_description = hash[:description] || "???" @real_description = hash[:real_description] || "???"
@flags = hash[:flags] || [] @flags = hash[:flags] || []
end end
# @return [String] the translated name of this ability # @return [String] the translated name of this ability

View File

@@ -19,21 +19,19 @@ module GameData
DATA_FILENAME = "moves.dat" DATA_FILENAME = "moves.dat"
SCHEMA = { SCHEMA = {
"Name" => [:name, "s"], "SectionName" => [:id, "m"],
"Type" => [:type, "e", :Type], "Name" => [:real_name, "s"],
"Category" => [:category, "e", ["Physical", "Special", "Status"]], "Type" => [:type, "e", :Type],
"Power" => [:base_damage, "u"], "Category" => [:category, "e", ["Physical", "Special", "Status"]],
"Accuracy" => [:accuracy, "u"], "Power" => [:base_damage, "u"],
"TotalPP" => [:total_pp, "u"], "Accuracy" => [:accuracy, "u"],
"Target" => [:target, "e", :Target], "TotalPP" => [:total_pp, "u"],
"Priority" => [:priority, "i"], "Target" => [:target, "e", :Target],
"FunctionCode" => [:function_code, "s"], "Priority" => [:priority, "i"],
"Flags" => [:flags, "*s"], "FunctionCode" => [:function_code, "s"],
"EffectChance" => [:effect_chance, "u"], "Flags" => [:flags, "*s"],
"Description" => [:description, "q"], "EffectChance" => [:effect_chance, "u"],
# All properties below here are old names for some properties above. "Description" => [:real_description, "q"]
# They will be removed in v21.
"BaseDamage" => [:base_damage, "u"]
} }
extend ClassMethodsSymbols extend ClassMethodsSymbols
@@ -42,19 +40,19 @@ module GameData
def initialize(hash) def initialize(hash)
convert_move_data(hash) convert_move_data(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name] || "Unnamed" @real_name = hash[:real_name] || "Unnamed"
@type = hash[:type] || :NONE @type = hash[:type] || :NONE
@category = hash[:category] || 2 @category = hash[:category] || 2
@base_damage = hash[:base_damage] || 0 @base_damage = hash[:base_damage] || 0
@accuracy = hash[:accuracy] || 100 @accuracy = hash[:accuracy] || 100
@total_pp = hash[:total_pp] || 5 @total_pp = hash[:total_pp] || 5
@target = hash[:target] || :None @target = hash[:target] || :None
@priority = hash[:priority] || 0 @priority = hash[:priority] || 0
@function_code = hash[:function_code] || "None" @function_code = hash[:function_code] || "None"
@flags = hash[:flags] || [] @flags = hash[:flags] || []
@flags = [@flags] if !@flags.is_a?(Array) @flags = [@flags] if !@flags.is_a?(Array)
@effect_chance = hash[:effect_chance] || 0 @effect_chance = hash[:effect_chance] || 0
@real_description = hash[:description] || "???" @real_description = hash[:real_description] || "???"
end end
# @return [String] the translated name of this move # @return [String] the translated name of this move

View File

@@ -9,27 +9,28 @@ module GameData
attr_reader :real_description attr_reader :real_description
attr_reader :field_use attr_reader :field_use
attr_reader :battle_use attr_reader :battle_use
attr_reader :consumable
attr_reader :flags attr_reader :flags
attr_reader :consumable
attr_reader :move attr_reader :move
DATA = {} DATA = {}
DATA_FILENAME = "items.dat" DATA_FILENAME = "items.dat"
SCHEMA = { SCHEMA = {
"Name" => [:name, "s"], "SectionName" => [:id, "m"],
"NamePlural" => [:name_plural, "s"], "Name" => [:real_name, "s"],
"Pocket" => [:pocket, "v"], "NamePlural" => [:real_name_plural, "s"],
"Price" => [:price, "u"], "Pocket" => [:pocket, "v"],
"SellPrice" => [:sell_price, "u"], "Price" => [:price, "u"],
"Description" => [:description, "q"], "SellPrice" => [:sell_price, "u"],
"FieldUse" => [:field_use, "e", { "OnPokemon" => 1, "Direct" => 2, "TM" => 3, "Description" => [:real_description, "q"],
"HM" => 4, "TR" => 5 }], "FieldUse" => [:field_use, "e", { "OnPokemon" => 1, "Direct" => 2, "TM" => 3,
"BattleUse" => [:battle_use, "e", { "OnPokemon" => 1, "OnMove" => 2, "OnBattler" => 3, "HM" => 4, "TR" => 5 }],
"OnFoe" => 4, "Direct" => 5 }], "BattleUse" => [:battle_use, "e", { "OnPokemon" => 1, "OnMove" => 2, "OnBattler" => 3,
"Consumable" => [:consumable, "b"], "OnFoe" => 4, "Direct" => 5 }],
"Flags" => [:flags, "*s"], "Flags" => [:flags, "*s"],
"Move" => [:move, "e", :Move] "Consumable" => [:consumable, "b"],
"Move" => [:move, "e", :Move]
} }
extend ClassMethodsSymbols extend ClassMethodsSymbols
@@ -82,15 +83,15 @@ module GameData
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name] || "Unnamed" @real_name = hash[:real_name] || "Unnamed"
@real_name_plural = hash[:name_plural] || "Unnamed" @real_name_plural = hash[:real_name_plural] || "Unnamed"
@pocket = hash[:pocket] || 1 @pocket = hash[:pocket] || 1
@price = hash[:price] || 0 @price = hash[:price] || 0
@sell_price = hash[:sell_price] || (@price / 2) @sell_price = hash[:sell_price] || (@price / 2)
@real_description = hash[:description] || "???" @real_description = hash[:real_description] || "???"
@field_use = hash[:field_use] || 0 @field_use = hash[:field_use] || 0
@battle_use = hash[:battle_use] || 0 @battle_use = hash[:battle_use] || 0
@flags = hash[:flags] || [] @flags = hash[:flags] || []
@consumable = hash[:consumable] @consumable = hash[:consumable]
@consumable = !is_important? if @consumable.nil? @consumable = !is_important? if @consumable.nil?
@move = hash[:move] @move = hash[:move]

View File

@@ -9,6 +9,7 @@ module GameData
DATA_FILENAME = "berry_plants.dat" DATA_FILENAME = "berry_plants.dat"
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "m"],
"HoursPerStage" => [:hours_per_stage, "v"], "HoursPerStage" => [:hours_per_stage, "v"],
"DryingPerHour" => [:drying_per_hour, "u"], "DryingPerHour" => [:drying_per_hour, "u"],
"Yield" => [:yield, "uv"] "Yield" => [:yield, "uv"]

View File

@@ -73,70 +73,50 @@ module GameData
def self.schema(compiling_forms = false) def self.schema(compiling_forms = false)
ret = { ret = {
"FormName" => [0, "q"], "FormName" => [:real_form_name, "q"],
"Category" => [0, "s"], "Category" => [:real_category, "s"],
"Pokedex" => [0, "q"], "Pokedex" => [:real_pokedex_entry, "q"],
"Types" => [0, "eE", :Type, :Type], "Types" => [:types, "eE", :Type, :Type],
"BaseStats" => [0, "vvvvvv"], "BaseStats" => [:base_stats, "vvvvvv"],
"EVs" => [0, "*ev", :Stat], "EVs" => [:evs, "*ev", :Stat],
"BaseExp" => [0, "v"], "BaseExp" => [:base_exp, "v"],
"CatchRate" => [0, "u"], "CatchRate" => [:catch_rate, "u"],
"Happiness" => [0, "u"], "Happiness" => [:happiness, "u"],
"Moves" => [0, "*ue", nil, :Move], "Moves" => [:moves, "*ue", nil, :Move],
"TutorMoves" => [0, "*e", :Move], "TutorMoves" => [:tutor_moves, "*e", :Move],
"EggMoves" => [0, "*e", :Move], "EggMoves" => [:egg_moves, "*e", :Move],
"Abilities" => [0, "*e", :Ability], "Abilities" => [:abilities, "*e", :Ability],
"HiddenAbilities" => [0, "*e", :Ability], "HiddenAbilities" => [:hidden_abilities, "*e", :Ability],
"WildItemCommon" => [0, "*e", :Item], "WildItemCommon" => [:wild_item_common, "*e", :Item],
"WildItemUncommon" => [0, "*e", :Item], "WildItemUncommon" => [:wild_item_uncommon, "*e", :Item],
"WildItemRare" => [0, "*e", :Item], "WildItemRare" => [:wild_item_rare, "*e", :Item],
"EggGroups" => [0, "*e", :EggGroup], "EggGroups" => [:egg_groups, "*e", :EggGroup],
"HatchSteps" => [0, "v"], "HatchSteps" => [:hatch_steps, "v"],
"Height" => [0, "f"], "Height" => [:height, "f"],
"Weight" => [0, "f"], "Weight" => [:weight, "f"],
"Color" => [0, "e", :BodyColor], "Color" => [:color, "e", :BodyColor],
"Shape" => [0, "e", :BodyShape], "Shape" => [:shape, "e", :BodyShape],
"Habitat" => [0, "e", :Habitat], "Habitat" => [:habitat, "e", :Habitat],
"Generation" => [0, "i"], "Generation" => [:generation, "i"],
"Flags" => [0, "*s"], "Flags" => [:flags, "*s"]
"BattlerPlayerX" => [0, "i"],
"BattlerPlayerY" => [0, "i"],
"BattlerEnemyX" => [0, "i"],
"BattlerEnemyY" => [0, "i"],
"BattlerAltitude" => [0, "i"],
"BattlerShadowX" => [0, "i"],
"BattlerShadowSize" => [0, "u"],
# All properties below here are old names for some properties above.
# They will be removed in v21.
"Type1" => [0, "e", :Type],
"Type2" => [0, "e", :Type],
"Rareness" => [0, "u"],
"Compatibility" => [0, "*e", :EggGroup],
"Kind" => [0, "s"],
"BaseEXP" => [0, "v"],
"EffortPoints" => [0, "*ev", :Stat],
"HiddenAbility" => [0, "*e", :Ability],
"StepsToHatch" => [0, "v"]
} }
if compiling_forms if compiling_forms
ret["PokedexForm"] = [0, "u"] ret["SectionName"] = [:id, "ev", :Species]
ret["Offspring"] = [0, "*e", :Species] ret["PokedexForm"] = [:pokedex_form, "u"]
ret["Evolutions"] = [0, "*ees", :Species, :Evolution, nil] ret["Offspring"] = [:offspring, "*e", :Species]
ret["MegaStone"] = [0, "e", :Item] ret["Evolutions"] = [:evolutions, "*ees", :Species, :Evolution, nil]
ret["MegaMove"] = [0, "e", :Move] ret["MegaStone"] = [:mega_stone, "e", :Item]
ret["UnmegaForm"] = [0, "u"] ret["MegaMove"] = [:mega_move, "e", :Move]
ret["MegaMessage"] = [0, "u"] ret["UnmegaForm"] = [:unmega_form, "u"]
ret["MegaMessage"] = [:mega_message, "u"]
else else
ret["InternalName"] = [0, "n"] ret["SectionName"] = [:id, "m"]
ret["Name"] = [0, "s"] ret["Name"] = [:real_name, "s"]
ret["GrowthRate"] = [0, "e", :GrowthRate] ret["GrowthRate"] = [:growth_rate, "e", :GrowthRate]
ret["GenderRatio"] = [0, "e", :GenderRatio] ret["GenderRatio"] = [:gender_ratio, "e", :GenderRatio]
ret["Incense"] = [0, "e", :Item] ret["Incense"] = [:incense, "e", :Item]
ret["Offspring"] = [0, "*s"] ret["Offspring"] = [:offspring, "*s"]
ret["Evolutions"] = [0, "*ses", nil, :Evolution, nil] ret["Evolutions"] = [:evolutions, "*ses", nil, :Evolution, nil]
# All properties below here are old names for some properties above.
# They will be removed in v21.
ret["GenderRate"] = [0, "e", :GenderRatio]
end end
return ret return ret
end end
@@ -145,10 +125,10 @@ module GameData
@id = hash[:id] @id = hash[:id]
@species = hash[:species] || @id @species = hash[:species] || @id
@form = hash[:form] || 0 @form = hash[:form] || 0
@real_name = hash[:name] || "Unnamed" @real_name = hash[:real_name] || "Unnamed"
@real_form_name = hash[:form_name] @real_form_name = hash[:real_form_name]
@real_category = hash[:category] || "???" @real_category = hash[:real_category] || "???"
@real_pokedex_entry = hash[:pokedex_entry] || "???" @real_pokedex_entry = hash[:real_pokedex_entry] || "???"
@pokedex_form = hash[:pokedex_form] || @form @pokedex_form = hash[:pokedex_form] || @form
@types = hash[:types] || [:NORMAL] @types = hash[:types] || [:NORMAL]
@base_stats = hash[:base_stats] || {} @base_stats = hash[:base_stats] || {}

View File

@@ -13,11 +13,12 @@ module GameData
DATA_FILENAME = "species_metrics.dat" DATA_FILENAME = "species_metrics.dat"
SCHEMA = { SCHEMA = {
"BackSprite" => [0, "ii"], "SectionName" => [:id, "eV", :Species],
"FrontSprite" => [0, "ii"], "BackSprite" => [:back_sprite, "ii"],
"FrontSpriteAltitude" => [0, "i"], "FrontSprite" => [:front_sprite, "ii"],
"ShadowX" => [0, "i"], "FrontSpriteAltitude" => [:front_sprite_altitude, "i"],
"ShadowSize" => [0, "u"] "ShadowX" => [:shadow_x, "i"],
"ShadowSize" => [:shadow_size, "u"]
} }
extend ClassMethodsSymbols extend ClassMethodsSymbols

View File

@@ -9,9 +9,10 @@ module GameData
DATA_FILENAME = "shadow_pokemon.dat" DATA_FILENAME = "shadow_pokemon.dat"
SCHEMA = { SCHEMA = {
"GaugeSize" => [:gauge_size, "v"], "SectionName" => [:id, "e", :Species],
"Moves" => [:moves, "*s"], # Not enumerated when compiled "GaugeSize" => [:gauge_size, "v"],
"Flags" => [:flags, "*s"] "Moves" => [:moves, "*m"], # Not enumerated when compiled
"Flags" => [:flags, "*s"]
} }
HEART_GAUGE_SIZE = 4000 # Default gauge size HEART_GAUGE_SIZE = 4000 # Default gauge size
@@ -20,8 +21,8 @@ module GameData
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@moves = hash[:moves] || []
@gauge_size = hash[:gauge_size] || HEART_GAUGE_SIZE @gauge_size = hash[:gauge_size] || HEART_GAUGE_SIZE
@moves = hash[:moves] || []
@flags = hash[:flags] || [] @flags = hash[:flags] || []
end end

View File

@@ -10,10 +10,11 @@ module GameData
DATA_FILENAME = "ribbons.dat" DATA_FILENAME = "ribbons.dat"
SCHEMA = { SCHEMA = {
"Name" => [:name, "s"], "SectionName" => [:id, "m"],
"IconPosition" => [:icon_position, "u"], "Name" => [:real_name, "s"],
"Description" => [:description, "q"], "IconPosition" => [:icon_position, "u"],
"Flags" => [:flags, "*s"] "Description" => [:real_description, "q"],
"Flags" => [:flags, "*s"]
} }
extend ClassMethodsSymbols extend ClassMethodsSymbols
@@ -21,10 +22,10 @@ module GameData
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name] || "Unnamed" @real_name = hash[:real_name] || "Unnamed"
@icon_position = hash[:icon_position] || 0 @icon_position = hash[:icon_position] || 0
@real_description = hash[:description] || "???" @real_description = hash[:real_description] || "???"
@flags = hash[:flags] || [] @flags = hash[:flags] || []
end end
# @return [String] the translated name of this ribbon # @return [String] the translated name of this ribbon

View File

@@ -14,17 +14,18 @@ module GameData
DATA_FILENAME = "trainer_types.dat" DATA_FILENAME = "trainer_types.dat"
SCHEMA = { SCHEMA = {
"Name" => [:name, "s"], "SectionName" => [:id, "m"],
"Gender" => [:gender, "e", { "Male" => 0, "male" => 0, "M" => 0, "m" => 0, "0" => 0, "Name" => [:real_name, "s"],
"Female" => 1, "female" => 1, "F" => 1, "f" => 1, "1" => 1, "Gender" => [:gender, "e", { "Male" => 0, "male" => 0, "M" => 0, "m" => 0, "0" => 0,
"Unknown" => 2, "unknown" => 2, "Other" => 2, "other" => 2, "Female" => 1, "female" => 1, "F" => 1, "f" => 1, "1" => 1,
"Mixed" => 2, "mixed" => 2, "X" => 2, "x" => 2, "2" => 2 }], "Unknown" => 2, "unknown" => 2, "Other" => 2, "other" => 2,
"BaseMoney" => [:base_money, "u"], "Mixed" => 2, "mixed" => 2, "X" => 2, "x" => 2, "2" => 2 }],
"SkillLevel" => [:skill_level, "u"], "BaseMoney" => [:base_money, "u"],
"Flags" => [:flags, "*s"], "SkillLevel" => [:skill_level, "u"],
"IntroBGM" => [:intro_BGM, "s"], "Flags" => [:flags, "*s"],
"BattleBGM" => [:battle_BGM, "s"], "IntroBGM" => [:intro_BGM, "s"],
"VictoryBGM" => [:victory_BGM, "s"] "BattleBGM" => [:battle_BGM, "s"],
"VictoryBGM" => [:victory_BGM, "s"]
} }
extend ClassMethodsSymbols extend ClassMethodsSymbols
@@ -81,7 +82,7 @@ module GameData
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name] || "Unnamed" @real_name = hash[:real_name] || "Unnamed"
@gender = hash[:gender] || 2 @gender = hash[:gender] || 2
@base_money = hash[:base_money] || 30 @base_money = hash[:base_money] || 30
@skill_level = hash[:skill_level] || @base_money @skill_level = hash[:skill_level] || @base_money

View File

@@ -17,17 +17,18 @@ module GameData
DATA_FILENAME = "metadata.dat" DATA_FILENAME = "metadata.dat"
SCHEMA = { SCHEMA = {
"StartMoney" => [1, "u"], "SectionName" => [:id, "u"],
"StartItemStorage" => [2, "*e", :Item], "StartMoney" => [:start_money, "u"],
"Home" => [3, "vuuu"], "StartItemStorage" => [:start_item_storage, "*e", :Item],
"StorageCreator" => [4, "s"], "Home" => [:home, "vuuu"],
"WildBattleBGM" => [5, "s"], "StorageCreator" => [:real_storage_creator, "s"],
"TrainerBattleBGM" => [6, "s"], "WildBattleBGM" => [:wild_battle_BGM, "s"],
"WildVictoryBGM" => [7, "s"], "TrainerBattleBGM" => [:trainer_battle_BGM, "s"],
"TrainerVictoryBGM" => [8, "s"], "WildVictoryBGM" => [:wild_victory_BGM, "s"],
"WildCaptureME" => [9, "s"], "TrainerVictoryBGM" => [:trainer_victory_BGM, "s"],
"SurfBGM" => [10, "s"], "WildCaptureME" => [:wild_capture_ME, "s"],
"BicycleBGM" => [11, "s"] "SurfBGM" => [:surf_BGM, "s"],
"BicycleBGM" => [:bicycle_BGM, "s"]
} }
extend ClassMethodsIDNumbers extend ClassMethodsIDNumbers
@@ -55,10 +56,10 @@ module GameData
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@start_money = hash[:start_money] || 3000 @start_money = hash[:start_money] || 3000
@start_item_storage = hash[:start_item_storage] || [] @start_item_storage = hash[:start_item_storage] || []
@home = hash[:home] @home = hash[:home]
@real_storage_creator = hash[:storage_creator] @real_storage_creator = hash[:real_storage_creator]
@wild_battle_BGM = hash[:wild_battle_BGM] @wild_battle_BGM = hash[:wild_battle_BGM]
@trainer_battle_BGM = hash[:trainer_battle_BGM] @trainer_battle_BGM = hash[:trainer_battle_BGM]
@wild_victory_BGM = hash[:wild_victory_BGM] @wild_victory_BGM = hash[:wild_victory_BGM]

View File

@@ -9,15 +9,16 @@ module GameData
DATA_FILENAME = "player_metadata.dat" DATA_FILENAME = "player_metadata.dat"
SCHEMA = { SCHEMA = {
"TrainerType" => [1, "e", :TrainerType], "SectionName" => [:id, "u"],
"WalkCharset" => [2, "s"], "TrainerType" => [:trainer_type, "e", :TrainerType],
"RunCharset" => [3, "s"], "WalkCharset" => [:walk_charset, "s"],
"CycleCharset" => [4, "s"], "RunCharset" => [:run_charset, "s"],
"SurfCharset" => [5, "s"], "CycleCharset" => [:cycle_charset, "s"],
"DiveCharset" => [6, "s"], "SurfCharset" => [:surf_charset, "s"],
"FishCharset" => [7, "s"], "DiveCharset" => [:dive_charset, "s"],
"SurfFishCharset" => [8, "s"], "FishCharset" => [:fish_charset, "s"],
"Home" => [9, "vuuu"] "SurfFishCharset" => [:surf_fish_charset, "s"],
"Home" => [:home, "vuuu"]
} }
extend ClassMethodsIDNumbers extend ClassMethodsIDNumbers

View File

@@ -28,28 +28,29 @@ module GameData
DATA_FILENAME = "map_metadata.dat" DATA_FILENAME = "map_metadata.dat"
SCHEMA = { SCHEMA = {
"Name" => [1, "s"], "SectionName" => [:id, "u"],
"Outdoor" => [2, "b"], "Name" => [:real_name, "s"],
"ShowArea" => [3, "b"], "Outdoor" => [:outdoor_map, "b"],
"Bicycle" => [4, "b"], "ShowArea" => [:announce_location, "b"],
"BicycleAlways" => [5, "b"], "Bicycle" => [:can_bicycle, "b"],
"HealingSpot" => [6, "vuu"], "BicycleAlways" => [:always_bicycle, "b"],
"Weather" => [7, "eu", :Weather], "HealingSpot" => [:teleport_destination, "vuu"],
"MapPosition" => [8, "uuu"], "Weather" => [:weather, "eu", :Weather],
"DiveMap" => [9, "v"], "MapPosition" => [:town_map_position, "uuu"],
"DarkMap" => [10, "b"], "DiveMap" => [:dive_map_id, "v"],
"SafariMap" => [11, "b"], "DarkMap" => [:dark_map, "b"],
"SnapEdges" => [12, "b"], "SafariMap" => [:safari_map, "b"],
"Dungeon" => [13, "b"], "SnapEdges" => [:snap_edges, "b"],
"BattleBack" => [14, "s"], "Dungeon" => [:random_dungeon, "b"],
"WildBattleBGM" => [15, "s"], "BattleBack" => [:battle_background, "s"],
"TrainerBattleBGM" => [16, "s"], "WildBattleBGM" => [:wild_battle_BGM, "s"],
"WildVictoryBGM" => [17, "s"], "TrainerBattleBGM" => [:trainer_battle_BGM, "s"],
"TrainerVictoryBGM" => [18, "s"], "WildVictoryBGM" => [:wild_victory_BGM, "s"],
"WildCaptureME" => [19, "s"], "TrainerVictoryBGM" => [:trainer_victory_BGM, "s"],
"MapSize" => [20, "us"], "WildCaptureME" => [:wild_capture_ME, "s"],
"Environment" => [21, "e", :Environment], "MapSize" => [:town_map_size, "us"],
"Flags" => [22, "*s"] "Environment" => [:battle_environment, "e", :Environment],
"Flags" => [:flags, "*s"]
} }
extend ClassMethodsIDNumbers extend ClassMethodsIDNumbers
@@ -84,7 +85,7 @@ module GameData
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name] @real_name = hash[:real_name]
@outdoor_map = hash[:outdoor_map] @outdoor_map = hash[:outdoor_map]
@announce_location = hash[:announce_location] @announce_location = hash[:announce_location]
@can_bicycle = hash[:can_bicycle] @can_bicycle = hash[:can_bicycle]

View File

@@ -15,8 +15,8 @@ module GameData
DATA_FILENAME = "dungeon_tilesets.dat" DATA_FILENAME = "dungeon_tilesets.dat"
SCHEMA = { SCHEMA = {
"Autotile" => [:autotile, "us"], "Autotile" => [:autotile, "um"],
"Tile" => [:tile, "us"], "Tile" => [:tile, "um"],
"SnapToLargeGrid" => [:snap_to_large_grid, "b"], "SnapToLargeGrid" => [:snap_to_large_grid, "b"],
"LargeVoidTiles" => [:large_void_tiles, "b"], "LargeVoidTiles" => [:large_void_tiles, "b"],
"LargeWallTiles" => [:large_wall_tiles, "b"], "LargeWallTiles" => [:large_wall_tiles, "b"],
@@ -56,7 +56,7 @@ module GameData
[hash[:autotile], hash[:tile]].each_with_index do |array, i| [hash[:autotile], hash[:tile]].each_with_index do |array, i|
array.each do |tile_info| array.each do |tile_info|
next if !tile_info next if !tile_info
tile_type = tile_info[1].downcase.to_sym tile_type = tile_info[1]
if tile_type == :walls if tile_type == :walls
if @double_walls if @double_walls
if @large_wall_tiles if @large_wall_tiles

View File

@@ -30,12 +30,13 @@ module GameData
DATA_FILENAME = "dungeon_parameters.dat" DATA_FILENAME = "dungeon_parameters.dat"
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "mV"],
"DungeonSize" => [:dungeon_size, "vv"], "DungeonSize" => [:dungeon_size, "vv"],
"CellSize" => [:cell_size, "vv"], "CellSize" => [:cell_size, "vv"],
"MinRoomSize" => [:min_room_size, "vv"], "MinRoomSize" => [:min_room_size, "vv"],
"MaxRoomSize" => [:max_room_size, "vv"], "MaxRoomSize" => [:max_room_size, "vv"],
"CorridorWidth" => [:corridor_width, "v"], "CorridorWidth" => [:corridor_width, "v"],
"ShiftCorridors" => [:shift_corridors, "b"], "ShiftCorridors" => [:random_corridor_shift, "b"],
"NodeLayout" => [:node_layout, "s"], "NodeLayout" => [:node_layout, "s"],
"RoomLayout" => [:room_layout, "s"], "RoomLayout" => [:room_layout, "s"],
"RoomChance" => [:room_chance, "v"], "RoomChance" => [:room_chance, "v"],
@@ -76,7 +77,7 @@ module GameData
@room_max_width = (hash[:max_room_size]) ? hash[:max_room_size][0] : @cell_width - 1 @room_max_width = (hash[:max_room_size]) ? hash[:max_room_size][0] : @cell_width - 1
@room_max_height = (hash[:max_room_size]) ? hash[:max_room_size][1] : @cell_height - 1 @room_max_height = (hash[:max_room_size]) ? hash[:max_room_size][1] : @cell_height - 1
@corridor_width = hash[:corridor_width] || 2 @corridor_width = hash[:corridor_width] || 2
@random_corridor_shift = hash[:shift_corridors] @random_corridor_shift = hash[:random_corridor_shift]
@node_layout = hash[:node_layout]&.downcase&.to_sym || :full @node_layout = hash[:node_layout]&.downcase&.to_sym || :full
@room_layout = hash[:room_layout]&.downcase&.to_sym || :full @room_layout = hash[:room_layout]&.downcase&.to_sym || :full
@room_chance = hash[:room_chance] || 70 @room_chance = hash[:room_chance] || 70

View File

@@ -129,7 +129,10 @@ module Compiler
yield lastsection, sectionname if havesection yield lastsection, sectionname if havesection
end end
# Used for types.txt, pokemon.txt, battle_facility_lists.txt and Battle Tower trainers PBS files # Used for types.txt, abilities.txt, moves.txt, items.txt, berry_plants.txt,
# pokemon.txt, pokemon_forms.txt, pokemon_metrics.txt, shadow_pokemon.txt,
# ribbons.txt, trainer_types.txt, battle_facility_lists.txt, Battle Tower
# trainers PBS files and dungeon_parameters.txt
def pbEachFileSection(f) def pbEachFileSection(f)
pbEachFileSectionEx(f) { |section, name| pbEachFileSectionEx(f) { |section, name|
yield section, name if block_given? && name[/^.+$/] yield section, name if block_given? && name[/^.+$/]
@@ -143,14 +146,7 @@ module Compiler
} }
end end
# Used for pokemon_forms.txt # Unused
def pbEachFileSectionPokemonForms(f)
pbEachFileSectionEx(f) { |section, name|
yield section, name if block_given? && name[/^\w+[-,\s]{1}\d+$/]
}
end
# Used for phone.txt
def pbEachSection(f) def pbEachSection(f)
lineno = 1 lineno = 1
havesection = false havesection = false
@@ -193,7 +189,7 @@ module Compiler
} }
end end
# Used for many PBS files # Used for town_map.txt and Battle Tower Pokémon PBS files
def pbCompilerEachCommentedLine(filename) def pbCompilerEachCommentedLine(filename)
File.open(filename, "rb") { |f| File.open(filename, "rb") { |f|
FileLineData.file = filename FileLineData.file = filename
@@ -226,7 +222,8 @@ module Compiler
} }
end end
# Used for map_connections.txt, abilities.txt, moves.txt, regional_dexes.txt # Used for map_connections.txt, phone.txt, regional_dexes.txt, encounters.txt,
# trainers.txt and dungeon_tilesets.txt
def pbCompilerEachPreppedLine(filename) def pbCompilerEachPreppedLine(filename)
File.open(filename, "rb") { |f| File.open(filename, "rb") { |f|
FileLineData.file = filename FileLineData.file = filename
@@ -519,6 +516,21 @@ module Compiler
subrecord.push(rec) subrecord.push(rec)
rec = "" rec = ""
end end
when "m" # Symbol
field = csvfield!(rec)
if !field[/^(?![0-9])\w+$/]
raise _INTL("Field '{1}' must contain only letters, digits, and\r\nunderscores and can't begin with a number.\r\n{2}", field, FileLineData.linereport)
end
subrecord.push(field.to_sym)
when "M" # Optional symbol
field = csvfield!(rec)
if nil_or_empty?(field)
subrecord.push(nil)
elsif !field[/^(?![0-9])\w+$/]
raise _INTL("Field '{1}' must contain only letters, digits, and\r\nunderscores and can't begin with a number.\r\n{2}", field, FileLineData.linereport)
else
subrecord.push(field.to_sym)
end
when "e" # Enumerable when "e" # Enumerable
subrecord.push(csvEnumField!(rec, schema[2 + i - start], "", FileLineData.linereport)) subrecord.push(csvEnumField!(rec, schema[2 + i - start], "", FileLineData.linereport))
when "E" # Optional enumerable when "E" # Optional enumerable
@@ -548,7 +560,7 @@ module Compiler
break if repeat && nil_or_empty?(rec) break if repeat && nil_or_empty?(rec)
break unless repeat break unless repeat
end end
return (schema[1].length == 1) ? record[0] : record return (!repeat && schema[1].length == 1) ? record[0] : record
end end
#============================================================================= #=============================================================================

File diff suppressed because it is too large Load Diff

View File

@@ -812,8 +812,7 @@ module Compiler
f.write("[0]\r\n") f.write("[0]\r\n")
metadata = GameData::Metadata.get metadata = GameData::Metadata.get
schema = GameData::Metadata::SCHEMA schema = GameData::Metadata::SCHEMA
keys = schema.keys.sort { |a, b| schema[a][0] <=> schema[b][0] } schema.keys.each do |key|
keys.each do |key|
record = metadata.property_from_string(key) record = metadata.property_from_string(key)
next if record.nil? || (record.is_a?(Array) && record.empty?) next if record.nil? || (record.is_a?(Array) && record.empty?)
f.write(sprintf("%s = ", key)) f.write(sprintf("%s = ", key))
@@ -822,11 +821,10 @@ module Compiler
end end
# Write player metadata # Write player metadata
schema = GameData::PlayerMetadata::SCHEMA schema = GameData::PlayerMetadata::SCHEMA
keys = schema.keys.sort { |a, b| schema[a][0] <=> schema[b][0] }
GameData::PlayerMetadata.each do |player_data| GameData::PlayerMetadata.each do |player_data|
f.write("\#-------------------------------\r\n") f.write("\#-------------------------------\r\n")
f.write(sprintf("[%d]\r\n", player_data.id)) f.write(sprintf("[%d]\r\n", player_data.id))
keys.each do |key| schema.keys.each do |key|
record = player_data.property_from_string(key) record = player_data.property_from_string(key)
next if record.nil? || (record.is_a?(Array) && record.empty?) next if record.nil? || (record.is_a?(Array) && record.empty?)
f.write(sprintf("%s = ", key)) f.write(sprintf("%s = ", key))
@@ -845,7 +843,6 @@ module Compiler
write_pbs_file_message_start(path) write_pbs_file_message_start(path)
map_infos = pbLoadMapInfos map_infos = pbLoadMapInfos
schema = GameData::MapMetadata::SCHEMA schema = GameData::MapMetadata::SCHEMA
keys = schema.keys.sort { |a, b| schema[a][0] <=> schema[b][0] }
File.open(path, "wb") { |f| File.open(path, "wb") { |f|
idx = 0 idx = 0
add_PBS_header_to_file(f) add_PBS_header_to_file(f)
@@ -861,7 +858,7 @@ module Compiler
else else
f.write(sprintf("[%03d]\r\n", map_data.id)) f.write(sprintf("[%03d]\r\n", map_data.id))
end end
keys.each do |key| schema.keys.each do |key|
record = map_data.property_from_string(key) record = map_data.property_from_string(key)
next if record.nil? || (record.is_a?(Array) && record.empty?) next if record.nil? || (record.is_a?(Array) && record.empty?)
f.write(sprintf("%s = ", key)) f.write(sprintf("%s = ", key))