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:
@@ -219,6 +219,15 @@ module GameData
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def get_property_for_PBS(key)
|
||||
ret = nil
|
||||
if self.class::SCHEMA.include?(key)
|
||||
ret = self.send(self.class::SCHEMA[key][0])
|
||||
ret = nil if ret == false || (ret.is_a?(Array) && ret.length == 0)
|
||||
end
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
|
||||
@@ -2,13 +2,13 @@ module GameData
|
||||
class Type
|
||||
attr_reader :id
|
||||
attr_reader :real_name
|
||||
attr_reader :icon_position # Where this type's icon is within types.png
|
||||
attr_reader :special_type
|
||||
attr_reader :pseudo_type
|
||||
attr_reader :flags
|
||||
attr_reader :weaknesses
|
||||
attr_reader :resistances
|
||||
attr_reader :immunities
|
||||
attr_reader :icon_position # Where this type's icon is within types.png
|
||||
attr_reader :flags
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "types.dat"
|
||||
@@ -16,13 +16,13 @@ module GameData
|
||||
SCHEMA = {
|
||||
"SectionName" => [:id, "m"],
|
||||
"Name" => [:real_name, "s"],
|
||||
"IconPosition" => [:icon_position, "u"],
|
||||
"IsSpecialType" => [:special_type, "b"],
|
||||
"IsPseudoType" => [:pseudo_type, "b"],
|
||||
"Flags" => [:flags, "*s"],
|
||||
"Weaknesses" => [:weaknesses, "*m"],
|
||||
"Resistances" => [:resistances, "*m"],
|
||||
"Immunities" => [:immunities, "*m"],
|
||||
"IconPosition" => [:icon_position, "u"]
|
||||
"Flags" => [:flags, "*s"]
|
||||
}
|
||||
|
||||
extend ClassMethodsSymbols
|
||||
@@ -31,16 +31,16 @@ module GameData
|
||||
def initialize(hash)
|
||||
@id = hash[:id]
|
||||
@real_name = hash[:real_name] || "Unnamed"
|
||||
@icon_position = hash[:icon_position] || 0
|
||||
@special_type = hash[:special_type] || false
|
||||
@pseudo_type = hash[:pseudo_type] || false
|
||||
@flags = hash[:flags] || []
|
||||
@weaknesses = hash[:weaknesses] || []
|
||||
@weaknesses = [@weaknesses] if !@weaknesses.is_a?(Array)
|
||||
@resistances = hash[:resistances] || []
|
||||
@resistances = [@resistances] if !@resistances.is_a?(Array)
|
||||
@immunities = hash[:immunities] || []
|
||||
@immunities = [@immunities] if !@immunities.is_a?(Array)
|
||||
@icon_position = hash[:icon_position] || 0
|
||||
@flags = hash[:flags] || []
|
||||
end
|
||||
|
||||
# @return [String] the translated name of this item
|
||||
|
||||
@@ -811,5 +811,12 @@ module GameData
|
||||
data[:function_code] = new_code
|
||||
return data
|
||||
end
|
||||
|
||||
alias __orig__get_property_for_PBS get_property_for_PBS
|
||||
def get_property_for_PBS(key)
|
||||
ret = __orig__get_property_for_PBS(key)
|
||||
ret = nil if ["Power", "Priority", "EffectChance"].include?(key) && ret == 0
|
||||
return ret
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,12 +6,12 @@ module GameData
|
||||
attr_reader :pocket
|
||||
attr_reader :price
|
||||
attr_reader :sell_price
|
||||
attr_reader :real_description
|
||||
attr_reader :field_use
|
||||
attr_reader :battle_use
|
||||
attr_reader :flags
|
||||
attr_reader :consumable
|
||||
attr_reader :move
|
||||
attr_reader :real_description
|
||||
|
||||
DATA = {}
|
||||
DATA_FILENAME = "items.dat"
|
||||
@@ -23,14 +23,14 @@ module GameData
|
||||
"Pocket" => [:pocket, "v"],
|
||||
"Price" => [:price, "u"],
|
||||
"SellPrice" => [:sell_price, "u"],
|
||||
"Description" => [:real_description, "q"],
|
||||
"FieldUse" => [:field_use, "e", { "OnPokemon" => 1, "Direct" => 2, "TM" => 3,
|
||||
"HM" => 4, "TR" => 5 }],
|
||||
"BattleUse" => [:battle_use, "e", { "OnPokemon" => 1, "OnMove" => 2, "OnBattler" => 3,
|
||||
"OnFoe" => 4, "Direct" => 5 }],
|
||||
"Flags" => [:flags, "*s"],
|
||||
"Consumable" => [:consumable, "b"],
|
||||
"Move" => [:move, "e", :Move]
|
||||
"Move" => [:move, "e", :Move],
|
||||
"Description" => [:real_description, "q"]
|
||||
}
|
||||
|
||||
extend ClassMethodsSymbols
|
||||
@@ -88,13 +88,13 @@ module GameData
|
||||
@pocket = hash[:pocket] || 1
|
||||
@price = hash[:price] || 0
|
||||
@sell_price = hash[:sell_price] || (@price / 2)
|
||||
@real_description = hash[:real_description] || "???"
|
||||
@field_use = hash[:field_use] || 0
|
||||
@battle_use = hash[:battle_use] || 0
|
||||
@flags = hash[:flags] || []
|
||||
@consumable = hash[:consumable]
|
||||
@consumable = !is_important? if @consumable.nil?
|
||||
@move = hash[:move]
|
||||
@real_description = hash[:real_description] || "???"
|
||||
end
|
||||
|
||||
# @return [String] the translated name of this item
|
||||
@@ -192,5 +192,20 @@ module GameData
|
||||
}
|
||||
return combos[species]&.include?(@id)
|
||||
end
|
||||
|
||||
alias __orig__get_property_for_PBS get_property_for_PBS
|
||||
def get_property_for_PBS(key)
|
||||
ret = __orig__get_property_for_PBS(key)
|
||||
case key
|
||||
when "SellPrice"
|
||||
ret = nil if ret == @price / 2
|
||||
when "FieldUse", "BattleUse"
|
||||
ret = nil if ret == 0
|
||||
when "Consumable"
|
||||
ret = @consumable
|
||||
ret = nil if ret || is_important? # Only return false, only for non-important items
|
||||
end
|
||||
return ret
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -72,51 +72,60 @@ module GameData
|
||||
end
|
||||
|
||||
def self.schema(compiling_forms = false)
|
||||
ret = {
|
||||
"FormName" => [:real_form_name, "q"],
|
||||
"Category" => [:real_category, "s"],
|
||||
"Pokedex" => [:real_pokedex_entry, "q"],
|
||||
"Types" => [:types, "eE", :Type, :Type],
|
||||
"BaseStats" => [:base_stats, "vvvvvv"],
|
||||
"EVs" => [:evs, "*ev", :Stat],
|
||||
"BaseExp" => [:base_exp, "v"],
|
||||
"CatchRate" => [:catch_rate, "u"],
|
||||
"Happiness" => [:happiness, "u"],
|
||||
"Moves" => [:moves, "*ue", nil, :Move],
|
||||
"TutorMoves" => [:tutor_moves, "*e", :Move],
|
||||
"EggMoves" => [:egg_moves, "*e", :Move],
|
||||
"Abilities" => [:abilities, "*e", :Ability],
|
||||
"HiddenAbilities" => [:hidden_abilities, "*e", :Ability],
|
||||
"WildItemCommon" => [:wild_item_common, "*e", :Item],
|
||||
"WildItemUncommon" => [:wild_item_uncommon, "*e", :Item],
|
||||
"WildItemRare" => [:wild_item_rare, "*e", :Item],
|
||||
"EggGroups" => [:egg_groups, "*e", :EggGroup],
|
||||
"HatchSteps" => [:hatch_steps, "v"],
|
||||
"Height" => [:height, "f"],
|
||||
"Weight" => [:weight, "f"],
|
||||
"Color" => [:color, "e", :BodyColor],
|
||||
"Shape" => [:shape, "e", :BodyShape],
|
||||
"Habitat" => [:habitat, "e", :Habitat],
|
||||
"Generation" => [:generation, "i"],
|
||||
"Flags" => [:flags, "*s"]
|
||||
}
|
||||
ret = {}
|
||||
if compiling_forms
|
||||
ret["SectionName"] = [:id, "ev", :Species]
|
||||
ret["PokedexForm"] = [:pokedex_form, "u"]
|
||||
ret["Offspring"] = [:offspring, "*e", :Species]
|
||||
ret["Evolutions"] = [:evolutions, "*ees", :Species, :Evolution, nil]
|
||||
ret["MegaStone"] = [:mega_stone, "e", :Item]
|
||||
ret["MegaMove"] = [:mega_move, "e", :Move]
|
||||
ret["UnmegaForm"] = [:unmega_form, "u"]
|
||||
ret["MegaMessage"] = [:mega_message, "u"]
|
||||
ret["SectionName"] = [:id, "ev", :Species]
|
||||
else
|
||||
ret["SectionName"] = [:id, "m"]
|
||||
ret["Name"] = [:real_name, "s"]
|
||||
ret["GrowthRate"] = [:growth_rate, "e", :GrowthRate]
|
||||
ret["GenderRatio"] = [:gender_ratio, "e", :GenderRatio]
|
||||
ret["Incense"] = [:incense, "e", :Item]
|
||||
ret["Offspring"] = [:offspring, "*s"]
|
||||
ret["Evolutions"] = [:evolutions, "*ses", nil, :Evolution, nil]
|
||||
ret["SectionName"] = [:id, "m"]
|
||||
ret["Name"] = [:real_name, "s"]
|
||||
end
|
||||
ret["FormName"] = [:real_form_name, "q"]
|
||||
if compiling_forms
|
||||
ret["PokedexForm"] = [:pokedex_form, "u"]
|
||||
ret["MegaStone"] = [:mega_stone, "e", :Item]
|
||||
ret["MegaMove"] = [:mega_move, "e", :Move]
|
||||
ret["UnmegaForm"] = [:unmega_form, "u"]
|
||||
ret["MegaMessage"] = [:mega_message, "u"]
|
||||
end
|
||||
ret["Types"] = [:types, "eE", :Type, :Type]
|
||||
ret["BaseStats"] = [:base_stats, "vvvvvv"]
|
||||
if !compiling_forms
|
||||
ret["GenderRatio"] = [:gender_ratio, "e", :GenderRatio]
|
||||
ret["GrowthRate"] = [:growth_rate, "e", :GrowthRate]
|
||||
end
|
||||
ret["BaseExp"] = [:base_exp, "v"]
|
||||
ret["EVs"] = [:evs, "*ev", :Stat]
|
||||
ret["CatchRate"] = [:catch_rate, "u"]
|
||||
ret["Happiness"] = [:happiness, "u"]
|
||||
ret["Abilities"] = [:abilities, "*e", :Ability]
|
||||
ret["HiddenAbilities"] = [:hidden_abilities, "*e", :Ability]
|
||||
ret["Moves"] = [:moves, "*ue", nil, :Move]
|
||||
ret["TutorMoves"] = [:tutor_moves, "*e", :Move]
|
||||
ret["EggMoves"] = [:egg_moves, "*e", :Move]
|
||||
ret["EggGroups"] = [:egg_groups, "*e", :EggGroup]
|
||||
ret["HatchSteps"] = [:hatch_steps, "v"]
|
||||
if compiling_forms
|
||||
ret["Offspring"] = [:offspring, "*e", :Species]
|
||||
else
|
||||
ret["Incense"] = [:incense, "e", :Item]
|
||||
ret["Offspring"] = [:offspring, "*s"]
|
||||
end
|
||||
ret["Height"] = [:height, "f"]
|
||||
ret["Weight"] = [:weight, "f"]
|
||||
ret["Color"] = [:color, "e", :BodyColor]
|
||||
ret["Shape"] = [:shape, "e", :BodyShape]
|
||||
ret["Habitat"] = [:habitat, "e", :Habitat]
|
||||
ret["Category"] = [:real_category, "s"]
|
||||
ret["Pokedex"] = [:real_pokedex_entry, "q"]
|
||||
ret["Generation"] = [:generation, "i"]
|
||||
ret["Flags"] = [:flags, "*s"]
|
||||
ret["WildItemCommon"] = [:wild_item_common, "*e", :Item]
|
||||
ret["WildItemUncommon"] = [:wild_item_uncommon, "*e", :Item]
|
||||
ret["WildItemRare"] = [:wild_item_rare, "*e", :Item]
|
||||
if compiling_forms
|
||||
ret["Evolutions"] = [:evolutions, "*ees", :Species, :Evolution, nil]
|
||||
else
|
||||
ret["Evolutions"] = [:evolutions, "*ses", nil, :Evolution, nil]
|
||||
end
|
||||
return ret
|
||||
end
|
||||
@@ -332,5 +341,66 @@ module GameData
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
alias __orig__get_property_for_PBS get_property_for_PBS
|
||||
def get_property_for_PBS(key, writing_form = false)
|
||||
ret = nil
|
||||
if self.class.schema(writing_form).include?(key)
|
||||
ret = self.send(self.class.schema(writing_form)[key][0])
|
||||
ret = nil if ret == false || (ret.is_a?(Array) && ret.length == 0)
|
||||
end
|
||||
case key
|
||||
when "SectionName"
|
||||
ret = [@species, @form] if writing_form
|
||||
when "FormName"
|
||||
ret = nil if nil_or_empty?(ret)
|
||||
when "PokedexForm"
|
||||
ret = nil if ret == @form
|
||||
when "UnmegaForm", "MegaMessage", "Generation"
|
||||
ret = nil if ret == 0
|
||||
when "BaseStats"
|
||||
new_ret = []
|
||||
GameData::Stat.each_main do |s|
|
||||
new_ret[s.pbs_order] = ret[s.id] if s.pbs_order >= 0
|
||||
end
|
||||
ret = new_ret
|
||||
when "EVs"
|
||||
new_ret = []
|
||||
GameData::Stat.each_main do |s|
|
||||
new_ret.push([s.id, ret[s.id]]) if ret[s.id] > 0 && s.pbs_order >= 0
|
||||
end
|
||||
ret = new_ret
|
||||
when "Height", "Weight"
|
||||
ret = ret.to_f / 10
|
||||
when "Habitat"
|
||||
ret = nil if ret == :None
|
||||
when "Evolutions"
|
||||
if ret
|
||||
ret = ret.select { |evo| !evo[3] } # Remove prevolutions
|
||||
ret.each do |evo|
|
||||
param_type = GameData::Evolution.get(evo[1]).parameter
|
||||
if !param_type.nil?
|
||||
if param_type.is_a?(Symbol) && !GameData.const_defined?(param_type)
|
||||
evo[2] = getConstantName(param_type, evo[2])
|
||||
else
|
||||
evo[2] = evo[2].to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
ret.each_with_index { |evo, i| ret[i] = evo[0, 3] }
|
||||
ret = nil if ret.length == 0
|
||||
end
|
||||
end
|
||||
if writing_form && !ret.nil?
|
||||
base_form = GameData::Species.get(@species)
|
||||
if !["WildItemCommon", "WildItemUncommon", "WildItemRare"].include?(key) ||
|
||||
(base_form.wild_item_common == @wild_item_common &&
|
||||
base_form.wild_item_uncommon == @wild_item_uncommon &&
|
||||
base_form.wild_item_rare == @wild_item_rare)
|
||||
ret = nil if base_form.get_property_for_PBS(key) == ret
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -84,5 +84,17 @@ module GameData
|
||||
return true
|
||||
# return @front_sprite_altitude > 0
|
||||
end
|
||||
|
||||
alias __orig__get_property_for_PBS get_property_for_PBS
|
||||
def get_property_for_PBS(key)
|
||||
ret = __orig__get_property_for_PBS(key)
|
||||
case key
|
||||
when "SectionName"
|
||||
ret = [@species, (@form > 0) ? @form : nil]
|
||||
when "FrontSpriteAltitude"
|
||||
ret = nil if ret == 0
|
||||
end
|
||||
return ret
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -103,5 +103,12 @@ module GameData
|
||||
def has_flag?(flag)
|
||||
return @flags.any? { |f| f.downcase == flag.downcase }
|
||||
end
|
||||
|
||||
alias __orig__get_property_for_PBS get_property_for_PBS
|
||||
def get_property_for_PBS(key)
|
||||
ret = __orig__get_property_for_PBS(key)
|
||||
ret = nil if key == "SkillLevel" && ret == @base_money
|
||||
return ret
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -37,8 +37,8 @@ module GameData
|
||||
"MaxRoomSize" => [:max_room_size, "vv"],
|
||||
"CorridorWidth" => [:corridor_width, "v"],
|
||||
"ShiftCorridors" => [:random_corridor_shift, "b"],
|
||||
"NodeLayout" => [:node_layout, "s"],
|
||||
"RoomLayout" => [:room_layout, "s"],
|
||||
"NodeLayout" => [:node_layout, "m"],
|
||||
"RoomLayout" => [:room_layout, "m"],
|
||||
"RoomChance" => [:room_chance, "v"],
|
||||
"ExtraConnections" => [:extra_connections_count, "u"],
|
||||
"FloorPatches" => [:floor_patches, "vvu"],
|
||||
@@ -78,8 +78,8 @@ module GameData
|
||||
@room_max_height = (hash[:max_room_size]) ? hash[:max_room_size][1] : @cell_height - 1
|
||||
@corridor_width = hash[:corridor_width] || 2
|
||||
@random_corridor_shift = hash[:random_corridor_shift]
|
||||
@node_layout = hash[:node_layout]&.downcase&.to_sym || :full
|
||||
@room_layout = hash[:room_layout]&.downcase&.to_sym || :full
|
||||
@node_layout = hash[:node_layout] || :full
|
||||
@room_layout = hash[:room_layout] || :full
|
||||
@room_chance = hash[:room_chance] || 70
|
||||
@extra_connections_count = hash[:extra_connections_count] || 2
|
||||
@floor_patch_radius = (hash[:floor_patches]) ? hash[:floor_patches][0] : 3
|
||||
@@ -115,25 +115,19 @@ module GameData
|
||||
return width, height
|
||||
end
|
||||
|
||||
def property_from_string(str)
|
||||
case str
|
||||
alias __orig__get_property_for_PBS get_property_for_PBS
|
||||
def get_property_for_PBS(key)
|
||||
case key
|
||||
when "SectionName" then return [@area, (@version > 0) ? @version : nil]
|
||||
when "DungeonSize" then return [@cell_count_x, @cell_count_y]
|
||||
when "CellSize" then return [@cell_width, @cell_height]
|
||||
when "MinRoomSize" then return [@room_min_width, @room_min_height]
|
||||
when "MaxRoomSize" then return [@room_max_width, @room_max_height]
|
||||
when "CorridorWidth" then return @corridor_width
|
||||
when "ShiftCorridors" then return @random_corridor_shift
|
||||
when "NodeLayout" then return @node_layout
|
||||
when "RoomLayout" then return @room_layout
|
||||
when "RoomChance" then return @room_chance
|
||||
when "ExtraConnections" then return @extra_connections_count
|
||||
when "FloorPatches" then return [@floor_patch_radius, @floor_patch_chance, @floor_patch_smooth_rate]
|
||||
when "FloorDecorations" then return [@floor_decoration_density, @floor_decoration_large_density]
|
||||
when "VoidDecorations" then return [@void_decoration_density, @void_decoration_large_density]
|
||||
when "RNGSeed" then return @rng_seed
|
||||
when "Flags" then return @flags
|
||||
end
|
||||
return nil
|
||||
return __orig__get_property_for_PBS(key)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user