diff --git a/Data/Scripts/001_Settings.rb b/Data/Scripts/001_Settings.rb index ca984ca37..0ab4a74cb 100644 --- a/Data/Scripts/001_Settings.rb +++ b/Data/Scripts/001_Settings.rb @@ -1,6 +1,6 @@ #==============================================================================# # Pokémon Essentials # -# Version 19 # +# Version 19.1 # # https://github.com/Maruno17/pokemon-essentials # #==============================================================================# @@ -403,6 +403,6 @@ end # DO NOT EDIT THESE! module Essentials - VERSION = "19" + VERSION = "19.1" ERROR_TEXT = "" end diff --git a/Data/Scripts/001_Technical/005_PluginManager.rb b/Data/Scripts/001_Technical/005_PluginManager.rb index eb8f4b437..883c601c3 100644 --- a/Data/Scripts/001_Technical/005_PluginManager.rb +++ b/Data/Scripts/001_Technical/005_PluginManager.rb @@ -667,7 +667,7 @@ module PluginManager # collect garbage GC.start echoln ' done.' - echoln "" + echoln '' end #----------------------------------------------------------------------------- # Check if plugins need compiling @@ -705,7 +705,7 @@ module PluginManager end end end - echoln "" if !echoed_plugins.empty? + echoln '' if !echoed_plugins.empty? end #----------------------------------------------------------------------------- end diff --git a/Data/Scripts/002_Save data/003_SaveData_Conversion.rb b/Data/Scripts/002_Save data/003_SaveData_Conversion.rb index 639b7a451..f48bc35ea 100644 --- a/Data/Scripts/002_Save data/003_SaveData_Conversion.rb +++ b/Data/Scripts/002_Save data/003_SaveData_Conversion.rb @@ -201,6 +201,7 @@ module SaveData conversion.run(save_data) echoln ' done.' end + echoln '' if conversions_to_run.length > 0 save_data[:essentials_version] = Essentials::VERSION save_data[:game_version] = Settings::GAME_VERSION return true diff --git a/Data/Scripts/002_Save data/005_Game_SaveConversions.rb b/Data/Scripts/002_Save data/005_Game_SaveConversions.rb index 237741f80..896ce30e2 100644 --- a/Data/Scripts/002_Save data/005_Game_SaveConversions.rb +++ b/Data/Scripts/002_Save data/005_Game_SaveConversions.rb @@ -97,7 +97,7 @@ SaveData.register_conversion(:v19_convert_global_metadata) do end end global.phoneNumbers.each do |contact| - contact[1] = GameData::TrainerType.get(contact[1]) if contact && contact.length == 8 + contact[1] = GameData::TrainerType.get(contact[1]).id if contact && contact.length == 8 end if global.partner global.partner[0] = GameData::TrainerType.get(global.partner[0]).id @@ -137,6 +137,16 @@ SaveData.register_conversion(:v19_convert_global_metadata) do end end +SaveData.register_conversion(:v19_1_fix_phone_contacts) do + essentials_version 19.1 + display_title 'Fixing phone contacts data' + to_value :global_metadata do |global| + global.phoneNumbers.each do |contact| + contact[1] = GameData::TrainerType.get(contact[1]).id if contact && contact.length == 8 + end + end +end + SaveData.register_conversion(:v19_convert_bag) do essentials_version 19 display_title 'Converting item IDs in Bag' diff --git a/Data/Scripts/004_Game classes/001_Switches and Variables/003_Game_Variables.rb b/Data/Scripts/004_Game classes/001_Switches and Variables/003_Game_Variables.rb index 493a56f07..70d16f90e 100644 --- a/Data/Scripts/004_Game classes/001_Switches and Variables/003_Game_Variables.rb +++ b/Data/Scripts/004_Game classes/001_Switches and Variables/003_Game_Variables.rb @@ -16,7 +16,7 @@ class Game_Variables # variable_id : variable ID #----------------------------------------------------------------------------- def [](variable_id) - return @data[variable_id] if variable_id <= 5000 + return @data[variable_id] if variable_id <= 5000 && !@data[variable_id].nil? return 0 end #----------------------------------------------------------------------------- diff --git a/Data/Scripts/013_Items/001_Item_Utilities.rb b/Data/Scripts/013_Items/001_Item_Utilities.rb index 7adb7091b..fc2bf9266 100644 --- a/Data/Scripts/013_Items/001_Item_Utilities.rb +++ b/Data/Scripts/013_Items/001_Item_Utilities.rb @@ -686,7 +686,7 @@ def pbChooseItem(var = 0, *args) screen = PokemonBagScreen.new(scene,$PokemonBag) ret = screen.pbChooseItemScreen } - $game_variables[var] = ret if var > 0 + $game_variables[var] = ret || :NONE if var > 0 return ret end @@ -697,7 +697,7 @@ def pbChooseApricorn(var = 0) screen = PokemonBagScreen.new(scene,$PokemonBag) ret = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).is_apricorn? }) } - $game_variables[var] = ret if var > 0 + $game_variables[var] = ret || :NONE if var > 0 return ret end @@ -708,7 +708,7 @@ def pbChooseFossil(var = 0) screen = PokemonBagScreen.new(scene,$PokemonBag) ret = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).is_fossil? }) } - $game_variables[var] = ret if var > 0 + $game_variables[var] = ret || :NONE if var > 0 return ret end diff --git a/Data/Scripts/013_Items/004_Item_Phone.rb b/Data/Scripts/013_Items/004_Item_Phone.rb index ffbcdd9d9..5ec42d015 100644 --- a/Data/Scripts/013_Items/004_Item_Phone.rb +++ b/Data/Scripts/013_Items/004_Item_Phone.rb @@ -42,7 +42,7 @@ end def pbPhoneRegisterBattle(message,event,trainertype,trainername,maxbattles) return if !$Trainer.has_pokegear # Can't register without a Pokégear return false if !GameData::TrainerType.exists?(trainertype) - trainertype = GameData::TrainerType.get(trainertype) + trainertype = GameData::TrainerType.get(trainertype).id contact = pbFindPhoneTrainer(trainertype,trainername) return if contact && contact[0] # Existing contact and is visible message = _INTL("Let me register you.") if !message @@ -82,7 +82,6 @@ end def pbFindPhoneTrainer(tr_type, tr_name) # Ignores whether visible or not return nil if !$PokemonGlobal.phoneNumbers - tr_type = GameData::TrainerType.get(tr_type).id for num in $PokemonGlobal.phoneNumbers return num if num[1] == tr_type && num[2] == tr_name # If a match end diff --git a/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb b/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb index 19a29ddeb..9fd6231e5 100644 --- a/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb +++ b/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb @@ -694,9 +694,9 @@ module Compiler #============================================================================= def write_battle_tower_pokemon(btpokemon,filename) return if !btpokemon || !filename - species = { 0 => "" } - moves = { 0 => "" } - items = { 0 => "" } + species = {} + moves = {} + items = {} natures = {} evs = { :HP => "HP", @@ -710,20 +710,27 @@ module Compiler add_PBS_header_to_file(f) f.write("\#-------------------------------\r\n") for i in 0...btpokemon.length - Graphics.update if i%500==0 + Graphics.update if i % 500 == 0 pkmn = btpokemon[i] c1 = (species[pkmn.species]) ? species[pkmn.species] : (species[pkmn.species] = GameData::Species.get(pkmn.species).species.to_s) c2 = (items[pkmn.item]) ? items[pkmn.item] : (items[pkmn.item] = GameData::Item.get(pkmn.item).id.to_s) c3 = (natures[pkmn.nature]) ? natures[pkmn.nature] : (natures[pkmn.nature] = GameData::Nature.get(pkmn.nature).id.to_s) evlist = "" - pkmn.ev.each do |stat| - evlist += "," if evlist.length > 0 + pkmn.ev.each_with_index do |stat, i| + evlist += "," if i > 0 evlist += evs[stat] end - c4 = (moves[pkmn.move1]) ? moves[pkmn.move1] : (moves[pkmn.move1] = GameData::Move.get(pkmn.move1).id.to_s) - c5 = (moves[pkmn.move2]) ? moves[pkmn.move2] : (moves[pkmn.move2] = GameData::Move.get(pkmn.move2).id.to_s) - c6 = (moves[pkmn.move3]) ? moves[pkmn.move3] : (moves[pkmn.move3] = GameData::Move.get(pkmn.move3).id.to_s) - c7 = (moves[pkmn.move4]) ? moves[pkmn.move4] : (moves[pkmn.move4] = GameData::Move.get(pkmn.move4).id.to_s) + c4 = c5 = c6 = c7 = "" + [pkmn.move1, pkmn.move2, pkmn.move3, pkmn.move4].each_with_index do |move, i| + next if !move + text = (moves[move]) ? moves[move] : (moves[move] = GameData::Move.get(move).id.to_s) + case i + when 0 then c4 = text + when 1 then c5 = text + when 2 then c6 = text + when 3 then c7 = text + end + end f.write("#{c1};#{c2};#{c3};#{evlist};#{c4},#{c5},#{c6},#{c7}\r\n") end }