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 #
# 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

View File

@@ -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

View File

@@ -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

View File

@@ -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'

View File

@@ -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
#-----------------------------------------------------------------------------

View File

@@ -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

View File

@@ -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

View File

@@ -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
}