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

View File

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

View File

@@ -574,7 +574,11 @@ class TrainerBattleLister
@sprite.bitmap.dispose if @sprite.bitmap @sprite.bitmap.dispose if @sprite.bitmap
return if index < 0 return if index < 0
begin 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 rescue
@sprite.setBitmap(nil) @sprite.setBitmap(nil)
end end

View File

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

View File

@@ -609,7 +609,8 @@ module Compiler
f.write(" Shiny = yes\r\n") if pkmn[:shininess] f.write(" Shiny = yes\r\n") if pkmn[:shininess]
f.write(" Shadow = yes\r\n") if pkmn[:shadowness] 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(" 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(" Item = %s\r\n", pkmn[:item])) if pkmn[:item]
f.write(sprintf(" Nature = %s\r\n", pkmn[:nature])) if pkmn[:nature] f.write(sprintf(" Nature = %s\r\n", pkmn[:nature])) if pkmn[:nature]
ivs_array = [] ivs_array = []

View File

@@ -11,14 +11,14 @@ LoseText = "Very good."
Pokemon = GEODUDE,12 Pokemon = GEODUDE,12
Gender = male Gender = male
Moves = DEFENSECURL,HEADSMASH,ROCKPOLISH,ROCKTHROW Moves = DEFENSECURL,HEADSMASH,ROCKPOLISH,ROCKTHROW
Ability = 0 AbilityIndex = 0
IV = 20,20,20,20,20,20 IV = 20,20,20,20,20,20
Pokemon = ONIX,14 Pokemon = ONIX,14
Name = Rocky Name = Rocky
Gender = male Gender = male
Shiny = yes Shiny = yes
Moves = HEADSMASH,ROCKTHROW,RAGE,ROCKTOMB Moves = HEADSMASH,ROCKTHROW,RAGE,ROCKTOMB
Ability = 0 AbilityIndex = 0
Item = SITRUSBERRY Item = SITRUSBERRY
IV = 20,20,20,20,20,20 IV = 20,20,20,20,20,20
Ball = HEAVYBALL Ball = HEAVYBALL