Converted Shadow Pokémon PBS file to a section-based format, improved Shadow Pokémon mechanics

This commit is contained in:
Maruno17
2021-11-21 00:44:41 +00:00
parent 048a18b415
commit b445f26a88
25 changed files with 761 additions and 204 deletions

View File

@@ -729,7 +729,7 @@ module Compiler
compile_pokemon # Depends on Move, Item, Type, Ability
compile_pokemon_forms # Depends on Species, Move, Item, Type, Ability
compile_pokemon_metrics # Depends on Species
compile_shadow_movesets # Depends on Species, Move
compile_shadow_pokemon # Depends on Species
compile_regional_dexes # Depends on Species
compile_ribbons # No dependencies
compile_encounters # Depends on Species
@@ -768,7 +768,7 @@ module Compiler
"player_metadata.dat",
"regional_dexes.dat",
"ribbons.dat",
"shadow_movesets.dat",
"shadow_pokemon.dat",
"species.dat",
"species_metrics.dat",
"town_map.dat",
@@ -793,7 +793,7 @@ module Compiler
"pokemon_metrics.txt",
"regional_dexes.txt",
"ribbons.txt",
"shadow_movesets.txt",
"shadow_pokemon.txt",
"town_map.txt",
"trainer_types.txt",
"trainers.txt",

View File

@@ -368,8 +368,8 @@ module Compiler
flags.push("CanMirrorMove") if line[12][/e/]
flags.push("ThawsUser") if line[12][/g/]
flags.push("HighCriticalHitRate") if line[12][/h/]
flags.push("Bite") if line[12][/i/]
flags.push("Punch") if line[12][/j/]
flags.push("Biting") if line[12][/i/]
flags.push("Punching") if line[12][/j/]
flags.push("Sound") if line[12][/k/]
flags.push("Powder") if line[12][/l/]
flags.push("Pulse") if line[12][/m/]
@@ -969,33 +969,68 @@ module Compiler
end
#=============================================================================
# Compile Shadow movesets
# Compile Shadow Pokémon data
#=============================================================================
def compile_shadow_movesets(path = "PBS/shadow_movesets.txt")
def compile_shadow_pokemon(path = "PBS/shadow_pokemon.txt")
compile_pbs_file_message_start(path)
sections = {}
if safeExists?(path)
idx = 0
pbCompilerEachCommentedLine(path) { |line, _line_no|
if line[/^\s*(\w+)\s*=\s*(.*)$/]
echo "." if idx % 50 == 0
idx += 1
Graphics.update if idx % 250 == 0
GameData::ShadowPokemon::DATA.clear
schema = GameData::ShadowPokemon::SCHEMA
shadow_hash = nil
old_format = nil
# Read each line of shadow_pokemon.txt at a time and compile it into a
# Shadow Pokémon's data
idx = 0
pbCompilerEachPreppedLine(path) { |line, line_no|
echo "." if idx % 250 == 0
idx += 1
if line[/^\s*\[\s*(.+)\s*\]\s*$/] # New section [species_id]
old_format = false if old_format.nil?
if old_format
raise _INTL("Can't mix old and new formats.\r\n{1}", FileLineData.linereport)
end
# Add previous Shadow Pokémon's data to records
GameData::ShadowPokemon.register(shadow_hash) if shadow_hash
# Parse species ID
species_id = $~[1].to_sym
if GameData::ShadowPokemon.exists?(species_id)
raise _INTL("Shadow Pokémon data for species '{1}' is defined twice.\r\n{2}", species_id, FileLineData.linereport)
end
# Construct Shadow Pokémon hash
shadow_hash = {
:id => species_id
}
elsif line[/^\s*(\w+)\s*=\s*(.*)\s*$/] # XXX=YYY lines
old_format = true if old_format.nil?
if old_format
key = $1
value = $2
value = value.split(",")
species = parseSpecies(key)
moves = []
for i in 0...[Pokemon::MAX_MOVES, value.length].min
move = parseMove(value[i], true)
moves.push(move) if move
end
moves.compact!
sections[species] = moves if moves.length > 0
value.each { |val| val.strip! }
value.delete_if { |val| nil_or_empty?(val) }
# Construct Shadow Pokémon hash
shadow_hash = {
:id => species,
:moves => value
}
# Add Shadow Pokémons data to records
GameData::ShadowPokemon.register(shadow_hash)
shadow_hash = nil
else
# Parse property and value
property_name = $~[1]
line_schema = schema[property_name]
next if !line_schema
property_value = pbGetCsvRecord($~[2], line_no, line_schema)
# Record XXX=YYY setting
shadow_hash[line_schema[0]] = property_value
end
}
end
save_data(sections, "Data/shadow_movesets.dat")
end
}
# Add last item's data to records
GameData::ShadowPokemon.register(shadow_hash) if shadow_hash
# Save all data
GameData::ShadowPokemon.save
process_pbs_file_message_end
end

View File

@@ -513,21 +513,21 @@ module Compiler
end
#=============================================================================
# Save Shadow movesets to PBS file
# Save Shadow Pokémon data to PBS file
#=============================================================================
def write_shadow_movesets(path = "PBS/shadow_movesets.txt")
def write_shadow_pokemon(path = "PBS/shadow_pokemon.txt")
write_pbs_file_message_start(path)
shadow_movesets = pbLoadShadowMovesets
File.open(path, "wb") { |f|
idx = 0
add_PBS_header_to_file(f)
f.write("\#-------------------------------\r\n")
GameData::Species.each do |species_data|
GameData::ShadowPokemon.each do |shadow|
echo "." if idx % 150 == 0
idx += 1
moveset = shadow_movesets[species_data.id]
next if !moveset || moveset.length == 0
f.write(sprintf("%s = %s\r\n", species_data.id, moveset.join(",")))
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
@@ -901,7 +901,7 @@ module Compiler
write_pokemon
write_pokemon_forms
write_pokemon_metrics
write_shadow_movesets
write_shadow_pokemon
write_regional_dexes
write_ribbons
write_encounters