Added conversion to fix incorrect phone contacts data, fixed being unable to call people, fixed crash when writing a Battle Facility PBS file

This commit is contained in:
Maruno17
2021-05-07 21:09:22 +01:00
parent 5618607afa
commit 43eddaa5da
8 changed files with 38 additions and 21 deletions

View File

@@ -1,6 +1,6 @@
#==============================================================================# #==============================================================================#
# Pokémon Essentials # # Pokémon Essentials #
# Version 19 # # Version 19.1 #
# https://github.com/Maruno17/pokemon-essentials # # https://github.com/Maruno17/pokemon-essentials #
#==============================================================================# #==============================================================================#
@@ -403,6 +403,6 @@ end
# DO NOT EDIT THESE! # DO NOT EDIT THESE!
module Essentials module Essentials
VERSION = "19" VERSION = "19.1"
ERROR_TEXT = "" ERROR_TEXT = ""
end end

View File

@@ -667,7 +667,7 @@ module PluginManager
# collect garbage # collect garbage
GC.start GC.start
echoln ' done.' echoln ' done.'
echoln "" echoln ''
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Check if plugins need compiling # Check if plugins need compiling
@@ -705,7 +705,7 @@ module PluginManager
end end
end end
end end
echoln "" if !echoed_plugins.empty? echoln '' if !echoed_plugins.empty?
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
end end

View File

@@ -201,6 +201,7 @@ module SaveData
conversion.run(save_data) conversion.run(save_data)
echoln ' done.' echoln ' done.'
end end
echoln '' if conversions_to_run.length > 0
save_data[:essentials_version] = Essentials::VERSION save_data[:essentials_version] = Essentials::VERSION
save_data[:game_version] = Settings::GAME_VERSION save_data[:game_version] = Settings::GAME_VERSION
return true return true

View File

@@ -97,7 +97,7 @@ SaveData.register_conversion(:v19_convert_global_metadata) do
end end
end end
global.phoneNumbers.each do |contact| 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 end
if global.partner if global.partner
global.partner[0] = GameData::TrainerType.get(global.partner[0]).id global.partner[0] = GameData::TrainerType.get(global.partner[0]).id
@@ -137,6 +137,16 @@ SaveData.register_conversion(:v19_convert_global_metadata) do
end end
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 SaveData.register_conversion(:v19_convert_bag) do
essentials_version 19 essentials_version 19
display_title 'Converting item IDs in Bag' display_title 'Converting item IDs in Bag'

View File

@@ -16,7 +16,7 @@ class Game_Variables
# variable_id : variable ID # variable_id : variable ID
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
def [](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 return 0
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------

View File

@@ -686,7 +686,7 @@ def pbChooseItem(var = 0, *args)
screen = PokemonBagScreen.new(scene,$PokemonBag) screen = PokemonBagScreen.new(scene,$PokemonBag)
ret = screen.pbChooseItemScreen ret = screen.pbChooseItemScreen
} }
$game_variables[var] = ret if var > 0 $game_variables[var] = ret || :NONE if var > 0
return ret return ret
end end
@@ -697,7 +697,7 @@ def pbChooseApricorn(var = 0)
screen = PokemonBagScreen.new(scene,$PokemonBag) screen = PokemonBagScreen.new(scene,$PokemonBag)
ret = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).is_apricorn? }) 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 return ret
end end
@@ -708,7 +708,7 @@ def pbChooseFossil(var = 0)
screen = PokemonBagScreen.new(scene,$PokemonBag) screen = PokemonBagScreen.new(scene,$PokemonBag)
ret = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).is_fossil? }) 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 return ret
end end

View File

@@ -42,7 +42,7 @@ end
def pbPhoneRegisterBattle(message,event,trainertype,trainername,maxbattles) def pbPhoneRegisterBattle(message,event,trainertype,trainername,maxbattles)
return if !$Trainer.has_pokegear # Can't register without a Pokégear return if !$Trainer.has_pokegear # Can't register without a Pokégear
return false if !GameData::TrainerType.exists?(trainertype) return false if !GameData::TrainerType.exists?(trainertype)
trainertype = GameData::TrainerType.get(trainertype) trainertype = GameData::TrainerType.get(trainertype).id
contact = pbFindPhoneTrainer(trainertype,trainername) contact = pbFindPhoneTrainer(trainertype,trainername)
return if contact && contact[0] # Existing contact and is visible return if contact && contact[0] # Existing contact and is visible
message = _INTL("Let me register you.") if !message message = _INTL("Let me register you.") if !message
@@ -82,7 +82,6 @@ end
def pbFindPhoneTrainer(tr_type, tr_name) # Ignores whether visible or not def pbFindPhoneTrainer(tr_type, tr_name) # Ignores whether visible or not
return nil if !$PokemonGlobal.phoneNumbers return nil if !$PokemonGlobal.phoneNumbers
tr_type = GameData::TrainerType.get(tr_type).id
for num in $PokemonGlobal.phoneNumbers for num in $PokemonGlobal.phoneNumbers
return num if num[1] == tr_type && num[2] == tr_name # If a match return num if num[1] == tr_type && num[2] == tr_name # If a match
end end

View File

@@ -694,9 +694,9 @@ module Compiler
#============================================================================= #=============================================================================
def write_battle_tower_pokemon(btpokemon,filename) def write_battle_tower_pokemon(btpokemon,filename)
return if !btpokemon || !filename return if !btpokemon || !filename
species = { 0 => "" } species = {}
moves = { 0 => "" } moves = {}
items = { 0 => "" } items = {}
natures = {} natures = {}
evs = { evs = {
:HP => "HP", :HP => "HP",
@@ -710,20 +710,27 @@ module Compiler
add_PBS_header_to_file(f) add_PBS_header_to_file(f)
f.write("\#-------------------------------\r\n") f.write("\#-------------------------------\r\n")
for i in 0...btpokemon.length for i in 0...btpokemon.length
Graphics.update if i%500==0 Graphics.update if i % 500 == 0
pkmn = btpokemon[i] pkmn = btpokemon[i]
c1 = (species[pkmn.species]) ? species[pkmn.species] : (species[pkmn.species] = GameData::Species.get(pkmn.species).species.to_s) 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) 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) c3 = (natures[pkmn.nature]) ? natures[pkmn.nature] : (natures[pkmn.nature] = GameData::Nature.get(pkmn.nature).id.to_s)
evlist = "" evlist = ""
pkmn.ev.each do |stat| pkmn.ev.each_with_index do |stat, i|
evlist += "," if evlist.length > 0 evlist += "," if i > 0
evlist += evs[stat] evlist += evs[stat]
end end
c4 = (moves[pkmn.move1]) ? moves[pkmn.move1] : (moves[pkmn.move1] = GameData::Move.get(pkmn.move1).id.to_s) c4 = c5 = c6 = c7 = ""
c5 = (moves[pkmn.move2]) ? moves[pkmn.move2] : (moves[pkmn.move2] = GameData::Move.get(pkmn.move2).id.to_s) [pkmn.move1, pkmn.move2, pkmn.move3, pkmn.move4].each_with_index do |move, i|
c6 = (moves[pkmn.move3]) ? moves[pkmn.move3] : (moves[pkmn.move3] = GameData::Move.get(pkmn.move3).id.to_s) next if !move
c7 = (moves[pkmn.move4]) ? moves[pkmn.move4] : (moves[pkmn.move4] = GameData::Move.get(pkmn.move4).id.to_s) 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") f.write("#{c1};#{c2};#{c3};#{evlist};#{c4},#{c5},#{c6},#{c7}\r\n")
end end
} }