Renamed trainers.txt property Ability to AbilityIndex, and added the property Ability which accepts an ability ID (and an index number for backwards compatibility)

This commit is contained in:
Maruno17
2021-05-13 22:34:46 +01:00
parent 8384adeb22
commit 2e1a7646ed
6 changed files with 84 additions and 65 deletions

View File

@@ -13,23 +13,24 @@ module GameData
DATA_FILENAME = "trainers.dat"
SCHEMA = {
"Items" => [:items, "*e", :Item],
"LoseText" => [:lose_text, "s"],
"Pokemon" => [:pokemon, "ev", :Species], # Species, level
"Form" => [:form, "u"],
"Name" => [:name, "s"],
"Moves" => [:moves, "*e", :Move],
"Ability" => [:ability_flag, "u"],
"Item" => [:item, "e", :Item],
"Gender" => [:gender, "e", { "M" => 0, "m" => 0, "Male" => 0, "male" => 0, "0" => 0,
"F" => 1, "f" => 1, "Female" => 1, "female" => 1, "1" => 1 }],
"Nature" => [:nature, "e", :Nature],
"IV" => [:iv, "uUUUUU"],
"EV" => [:ev, "uUUUUU"],
"Happiness" => [:happiness, "u"],
"Shiny" => [:shininess, "b"],
"Shadow" => [:shadowness, "b"],
"Ball" => [:poke_ball, "s"],
"Items" => [:items, "*e", :Item],
"LoseText" => [:lose_text, "s"],
"Pokemon" => [:pokemon, "ev", :Species], # Species, level
"Form" => [:form, "u"],
"Name" => [:name, "s"],
"Moves" => [:moves, "*e", :Move],
"Ability" => [:ability, "s"],
"AbilityIndex" => [:ability_index, "u"],
"Item" => [:item, "e", :Item],
"Gender" => [:gender, "e", { "M" => 0, "m" => 0, "Male" => 0, "male" => 0, "0" => 0,
"F" => 1, "f" => 1, "Female" => 1, "female" => 1, "1" => 1 }],
"Nature" => [:nature, "e", :Nature],
"IV" => [:iv, "uUUUUU"],
"EV" => [:ev, "uUUUUU"],
"Happiness" => [:happiness, "u"],
"Shiny" => [:shininess, "b"],
"Shadow" => [:shadowness, "b"],
"Ball" => [:poke_ball, "s"],
}
extend ClassMethods
@@ -127,7 +128,8 @@ module GameData
else
pkmn.reset_moves
end
pkmn.ability_index = pkmn_data[:ability_flag]
pkmn.ability_index = pkmn_data[:ability_index]
pkmn.ability = pkmn_data[:ability]
pkmn.gender = pkmn_data[:gender] || ((trainer.male?) ? 0 : 1)
pkmn.shiny = (pkmn_data[:shininess]) ? true : false
if pkmn_data[:nature]

View File

@@ -645,7 +645,8 @@ module TrainerPokemonProperty
oldsetting.push((initsetting[:moves]) ? initsetting[:moves][i] : nil)
end
oldsetting.concat([
initsetting[:ability_flag],
initsetting[:ability],
initsetting[:ability_index],
initsetting[:item],
initsetting[:nature],
initsetting[:iv],
@@ -655,43 +656,46 @@ module TrainerPokemonProperty
])
max_level = GameData::GrowthRate.max_level
pkmn_properties = [
[_INTL("Species"), SpeciesProperty, _INTL("Species of the Pokémon.")],
[_INTL("Level"), NonzeroLimitProperty.new(max_level), _INTL("Level of the Pokémon (1-{1}).", max_level)],
[_INTL("Name"), StringProperty, _INTL("Name of the Pokémon.")],
[_INTL("Form"), LimitProperty2.new(999), _INTL("Form of the Pokémon.")],
[_INTL("Gender"), GenderProperty, _INTL("Gender of the Pokémon.")],
[_INTL("Shiny"), BooleanProperty2, _INTL("If set to true, the Pokémon is a different-colored Pokémon.")],
[_INTL("Shadow"), BooleanProperty2, _INTL("If set to true, the Pokémon is a Shadow Pokémon.")]
[_INTL("Species"), SpeciesProperty, _INTL("Species of the Pokémon.")],
[_INTL("Level"), NonzeroLimitProperty.new(max_level), _INTL("Level of the Pokémon (1-{1}).", max_level)],
[_INTL("Name"), StringProperty, _INTL("Name of the Pokémon.")],
[_INTL("Form"), LimitProperty2.new(999), _INTL("Form of the Pokémon.")],
[_INTL("Gender"), GenderProperty, _INTL("Gender of the Pokémon.")],
[_INTL("Shiny"), BooleanProperty2, _INTL("If set to true, the Pokémon is a different-colored Pokémon.")],
[_INTL("Shadow"), BooleanProperty2, _INTL("If set to true, the Pokémon is a Shadow Pokémon.")]
]
Pokemon::MAX_MOVES.times do |i|
pkmn_properties.push([_INTL("Move {1}", i + 1), MovePropertyForSpecies.new(oldsetting), _INTL("A move known by the Pokémon. Leave all moves blank (use Z key to delete) for a wild moveset.")])
pkmn_properties.push([_INTL("Move {1}", i + 1),
MovePropertyForSpecies.new(oldsetting), _INTL("A move known by the Pokémon. Leave all moves blank (use Z key to delete) for a wild moveset.")])
end
pkmn_properties.concat([
[_INTL("Ability"), LimitProperty2.new(99), _INTL("Ability flag. 0=first ability, 1=second ability, 2-5=hidden ability.")],
[_INTL("Held item"), ItemProperty, _INTL("Item held by the Pokémon.")],
[_INTL("Nature"), GameDataProperty.new(:Nature), _INTL("Nature of the Pokémon.")],
[_INTL("IVs"), IVsProperty.new(Pokemon::IV_STAT_LIMIT), _INTL("Individual values for each of the Pokémon's stats.")],
[_INTL("EVs"), EVsProperty.new(Pokemon::EV_STAT_LIMIT), _INTL("Effort values for each of the Pokémon's stats.")],
[_INTL("Happiness"), LimitProperty2.new(255), _INTL("Happiness of the Pokémon (0-255).")],
[_INTL("Poké Ball"), BallProperty.new(oldsetting), _INTL("The kind of Poké Ball the Pokémon is kept in.")]
[_INTL("Ability"), AbilityProperty, _INTL("Ability of the Pokémon. Overrides the ability index.")],
[_INTL("Ability index"), LimitProperty2.new(99), _INTL("Ability index. 0=first ability, 1=second ability, 2+=hidden ability.")],
[_INTL("Held item"), ItemProperty, _INTL("Item held by the Pokémon.")],
[_INTL("Nature"), GameDataProperty.new(:Nature), _INTL("Nature of the Pokémon.")],
[_INTL("IVs"), IVsProperty.new(Pokemon::IV_STAT_LIMIT), _INTL("Individual values for each of the Pokémon's stats.")],
[_INTL("EVs"), EVsProperty.new(Pokemon::EV_STAT_LIMIT), _INTL("Effort values for each of the Pokémon's stats.")],
[_INTL("Happiness"), LimitProperty2.new(255), _INTL("Happiness of the Pokémon (0-255).")],
[_INTL("Poké Ball"), BallProperty.new(oldsetting), _INTL("The kind of Poké Ball the Pokémon is kept in.")]
])
pbPropertyList(settingname, oldsetting, pkmn_properties, false)
return nil if !oldsetting[0] # Species is nil
ret = {
:species => oldsetting[0],
:level => oldsetting[1],
:name => oldsetting[2],
:form => oldsetting[3],
:gender => oldsetting[4],
:shininess => oldsetting[5],
:shadowness => oldsetting[6],
:ability_flag => oldsetting[7 + Pokemon::MAX_MOVES],
:item => oldsetting[8 + Pokemon::MAX_MOVES],
:nature => oldsetting[9 + Pokemon::MAX_MOVES],
:iv => oldsetting[10 + Pokemon::MAX_MOVES],
:ev => oldsetting[11 + Pokemon::MAX_MOVES],
:happiness => oldsetting[12 + Pokemon::MAX_MOVES],
:poke_ball => oldsetting[13 + Pokemon::MAX_MOVES],
:species => oldsetting[0],
:level => oldsetting[1],
:name => oldsetting[2],
:form => oldsetting[3],
:gender => oldsetting[4],
:shininess => oldsetting[5],
:shadowness => oldsetting[6],
:ability => oldsetting[7 + Pokemon::MAX_MOVES],
:ability_index => oldsetting[8 + Pokemon::MAX_MOVES],
:item => oldsetting[9 + Pokemon::MAX_MOVES],
:nature => oldsetting[10 + Pokemon::MAX_MOVES],
:iv => oldsetting[11 + Pokemon::MAX_MOVES],
:ev => oldsetting[12 + Pokemon::MAX_MOVES],
:happiness => oldsetting[13 + Pokemon::MAX_MOVES],
:poke_ball => oldsetting[14 + Pokemon::MAX_MOVES],
}
moves = []
Pokemon::MAX_MOVES.times do |i|

View File

@@ -574,7 +574,11 @@ class TrainerBattleLister
@sprite.bitmap.dispose if @sprite.bitmap
return if index < 0
begin
@sprite.setBitmap(GameData::TrainerType.front_sprite_filename(@ids[index][0]), 0)
if @ids[index].is_a?(Array)
@sprite.setBitmap(GameData::TrainerType.front_sprite_filename(@ids[index][0]), 0)
else
@sprite.setBitmap(nil)
end
rescue
@sprite.setBitmap(nil)
end

View File

@@ -1215,6 +1215,14 @@ module Compiler
raise _INTL("Pokémon hasn't been defined yet!\r\n{1}", FileLineData.linereport)
end
case property_name
when "Ability"
if property_value[/^\d+$/]
current_pkmn[:ability_index] = property_value.to_i
elsif !GameData::Ability.exists?(property_value.to_sym)
raise _INTL("Value {1} isn't a defined Ability.\r\n{2}", property_value, FileLineData.linereport)
else
current_pkmn[line_schema[0]] = property_value.to_sym
end
when "IV", "EV"
value_hash = {}
GameData::Stat.each_main do |s|
@@ -1319,19 +1327,19 @@ module Compiler
ivs[s.id] = line_data[12] if s.pbs_order >= 0
end
end
current_pkmn[:level] = line_data[1]
current_pkmn[:item] = line_data[2] if line_data[2]
current_pkmn[:moves] = moves if moves.length > 0
current_pkmn[:ability_flag] = line_data[7] if line_data[7]
current_pkmn[:gender] = line_data[8] if line_data[8]
current_pkmn[:form] = line_data[9] if line_data[9]
current_pkmn[:shininess] = line_data[10] if line_data[10]
current_pkmn[:nature] = line_data[11] if line_data[11]
current_pkmn[:iv] = ivs if ivs.length > 0
current_pkmn[:happiness] = line_data[13] if line_data[13]
current_pkmn[:name] = line_data[14] if line_data[14] && !line_data[14].empty?
current_pkmn[:shadowness] = line_data[15] if line_data[15]
current_pkmn[:poke_ball] = line_data[16] if line_data[16]
current_pkmn[:level] = line_data[1]
current_pkmn[:item] = line_data[2] if line_data[2]
current_pkmn[:moves] = moves if moves.length > 0
current_pkmn[:ability_index] = line_data[7] if line_data[7]
current_pkmn[:gender] = line_data[8] if line_data[8]
current_pkmn[:form] = line_data[9] if line_data[9]
current_pkmn[:shininess] = line_data[10] if line_data[10]
current_pkmn[:nature] = line_data[11] if line_data[11]
current_pkmn[:iv] = ivs if ivs.length > 0
current_pkmn[:happiness] = line_data[13] if line_data[13]
current_pkmn[:name] = line_data[14] if line_data[14] && !line_data[14].empty?
current_pkmn[:shadowness] = line_data[15] if line_data[15]
current_pkmn[:poke_ball] = line_data[16] if line_data[16]
# Check if this is the last expected Pokémon
old_format_current_line = 0 if old_format_current_line >= old_format_expected_lines
end

View File

@@ -609,7 +609,8 @@ module Compiler
f.write(" Shiny = yes\r\n") if pkmn[:shininess]
f.write(" Shadow = yes\r\n") if pkmn[:shadowness]
f.write(sprintf(" Moves = %s\r\n", pkmn[:moves].join(","))) if pkmn[:moves] && pkmn[:moves].length > 0
f.write(sprintf(" Ability = %d\r\n", pkmn[:ability_flag])) if pkmn[:ability_flag]
f.write(sprintf(" Ability = %s\r\n", pkmn[:ability])) if pkmn[:ability]
f.write(sprintf(" AbilityIndex = %d\r\n", pkmn[:ability_index])) if pkmn[:ability_index]
f.write(sprintf(" Item = %s\r\n", pkmn[:item])) if pkmn[:item]
f.write(sprintf(" Nature = %s\r\n", pkmn[:nature])) if pkmn[:nature]
ivs_array = []