Refactored phone/rematches code, added Phone.rematches_enabled/Phone.rematch_variant/map metadata flag "NoPhoneSignal", changed event layout, trainer contacts can use Common Events for their calls, etc.

This commit is contained in:
Maruno17
2022-08-13 16:52:42 +01:00
parent c79b970d6b
commit aa9b1a9e23
9 changed files with 851 additions and 412 deletions

View File

@@ -348,3 +348,35 @@ SaveData.register_conversion(:v20_convert_pokemon_markings) do
end
end
end
#===============================================================================
SaveData.register_conversion(:v21_replace_phone_data) do
essentials_version 21
display_title "Updating Phone data format"
to_value :global_metadata do |global|
if !global.phone
global.instance_eval do
@phone = Phone.new
@phoneTime = nil # Don't bother using this
if @phoneNumbers
@phoneNumbers.each do |contact|
if contact.length > 4
# Trainer
# TODO: Is there any way to ensure the versions count is accurate?
Phone.add_silent(contact[6], contact[7], contact[1], contact[2], 0, [contact[5], 3].max)
new_contact = Phone.get(contact[1], contact[2], 0)
new_contact.visible = contact[0]
new_contact.version = contact[5]
new_contact.rematch_flag = [contact[4] - 1, 0].max
else
# Non-trainer
Phone.add_silent(contact[3], contact[2], contact[1])
end
end
@phoneNumbers = nil
end
end
end
end
end