Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #__END__
- ##
- # This script was made under the assumptions for the map transfers
- # - No scripted map transfers
- # - Only exists in a map event (no common events)
- # - Direction appointments only
- #
- # Do not expect an accurate picture if these properties are not fulfilled
- #
- ##
- # Copyright (c) 2017 Zeriab
- #
- # This software is provided 'as-is', without any express or implied
- # warranty. In no event will the authors be held liable for any damages
- # arising from the use of this software.
- #
- # Permission is granted to anyone to use this software for any purpose,
- # including commercial applications, and to alter it and redistribute it
- # freely, subject to the following restrictions:
- #
- # 1. The origin of this software must not be misrepresented; you must not
- # claim that you wrote the original software. If you use this software
- # in a product, an acknowledgement in the product documentation would be
- # appreciated but is not required.
- # 2. Altered source versions must be plainly marked as such, and must not be
- # misrepresented as being the original software.
- # 3. This notice may not be removed or altered from any source distribution.
- #
- def update_sprite
- if @sprite.nil?
- @sprite = Sprite.new
- @sprite.bitmap = Bitmap.new(640, 120)
- end
- current = $current
- unless current == $last
- $last = current
- @sprite.bitmap.clear
- unless current.nil?
- @sprite.bitmap.draw_text(8,4,600,32,$last.map)
- @sprite.bitmap.draw_text(8,40,600,32,$last.event)
- end
- end
- end
- ##
- # A separate thread that will run and make sure the Graphics.update is updated
- # every now and then.
- #
- Thread.new {
- loop do
- # Lets the thread sleep for a while to minimize CPU usage
- sleep 0.1
- # Update the sprite
- update_sprite
- # Update the graphics
- Graphics.update
- end
- }
- Current = Struct.new(:map, :event)
- $current = nil
- Map = Struct.new(:name, :map_id, :events)
- Event = Struct.new(:name, :event_id, :pages)
- Page = Struct.new(:number, :list)
- ListElement = Struct.new(:message, :type)
- ######
- ######
- class Map
- def write_to_stream(io)
- io.print "\r\n########################################"
- io.print "\r\n# Map #{map_id} ~ #{name} (#{events.size} events)\r\n"
- io.print "########################################\r\n"
- for event in events
- event.write_to_stream(io)
- end
- end
- end
- class Event
- def write_to_stream(io)
- io.print "\r\n-= Event #{event_id} - #{name} =-\r\n"
- for page in pages
- page.write_to_stream(io)
- end
- end
- end
- class Page
- def write_to_stream(io)
- io.print "Page #{number}:\r\n"
- for element in list
- element.write_to_stream(io)
- io.print "\r\n"
- end
- end
- end
- class ListElement
- def write_to_stream(io)
- io.print message
- end
- end
- $map = Hash.new {|h, k| h[k] = []}
- ######
- def process_list(list)
- # Go through the event commands in the list
- rlist = [] # resulting list
- command_index = 0
- while command_index < list.size
- command = list[command_index]
- if command.code == 201 && command.parameters[0] != nil
- param = command.parameters
- if $origin.nil? || $origin == 0
- p 'Only supports transfers in map events atm.'
- exit
- end
- $map[$origin] << param[1]
- message = "Transfer to map #{param[1]} on (#{param[2]}, #{param[3]})"
- if param[0] != 0
- $variable_based = true
- message = "Variable based transfer to map var(#{param[1]}) on (var(#{param[2]}), var(#{param[3]}))"
- end
- rlist << ListElement.new(message, 'text')
- end
- command_index += 1
- end
- return rlist
- end
- ######
- class CommonEvent < Struct.new(:name, :event_id, :list)
- def write_to_stream(io)
- io.print "\r\n-= Common Event #{event_id} - #{name} =-\r\n"
- for element in list
- element.write_to_stream(io)
- io.print "\r\n"
- end
- end
- end
- common_events = load_data('Data/CommonEvents.rxdata')
- ces = []
- for ce in common_events.compact
- # Look at which event is currently processing
- cur = Current.new("Processing common events...",
- "Common event #{ce.id} - #{ce.name}")
- $current = cur
- # Process the list
- $origin = 0
- list = process_list(ce.list)
- unless list.empty?
- # Create struct
- current_ce = CommonEvent.new(ce.name, ce.id, list)
- ces << current_ce
- end
- end
- ######
- ######
- class Troop < Event
- def write_to_stream(io)
- io.print "\r\n-= Troop #{event_id} - #{name} =-\r\n"
- for page in pages
- page.write_to_stream(io)
- end
- end
- end
- troops = load_data('Data\Troops.rxdata')
- battle_events = []
- for event in troops.compact
- # Look at which event is currently processing
- cur = Current.new("Processing battle events...",
- "Troop " + event.id.to_s + " - " + event.name)
- $current = cur
- # Create the event struct
- current_event = Troop.new(event.name, event.id, [])
- # Create pages
- event.pages.each_with_index do |page, page_index|
- list = process_list(page.list)
- unless list.empty?
- current_page = Page.new(page_index+1, list)
- current_event.pages << current_page
- end
- end
- # Let's disregard useless events
- battle_events << current_event unless current_event.pages.empty?
- end
- ######
- ######
- infos = load_data('Data\MapInfos.rxdata')
- p infos[235]
- exit
- map_map = {}
- maps = []
- for map_id, map_info in infos.sort
- map_map[map_id] = map_info
- $origin = map_id
- # Create map struct
- current_map = Map.new(map_info.name, map_id, [])
- maps << current_map
- map = load_data(sprintf("Data/Map%03d.rxdata", map_id))
- # Create event structs
- for event_id, event in map.events.sort
- # Look at which event is currently processing
- cur = Current.new("Map " + map_id.to_s + " - " + map_info.name,
- "Event " + event_id.to_s + " - " + event.name)
- $current = cur
- # Create the event struct
- current_event = Event.new(event.name, event_id, [])
- # Create pages
- event.pages.each_with_index do |page, page_index|
- list = process_list(page.list)
- unless list.empty?
- current_page = Page.new(page_index+1, list)
- # Let's disregard useless pages
- current_event.pages << current_page
- end
- end
- # Let's disregard useless events
- current_map.events << current_event unless current_event.pages.empty?
- end
- end
- # Update status info
- cur = Current.new("All maps have been processed",
- "Writing to a text file")
- $current = cur
- File.open('Transfers_Map.txt', 'wb') {|f|
- f.print "THIS FILE CONTAINS THE DIALOGUE EXTRACTED FROM THE MAPS\r\n\r\n"
- for map in maps
- map.write_to_stream(f)
- end
- }
- File.open('Transfers_Common.txt', 'wb') {|f|
- f.print "THIS FILE CONTAINS THE DIALOGUE EXTRACTED FROM THE COMMON EVENTS\r\n\r\n"
- for ce in ces
- ce.write_to_stream(f)
- end
- }
- File.open('Transfers_Battle.txt', 'wb') {|f|
- f.print "THIS FILE CONTAINS THE DIALOGUE EXTRACTED FROM THE BATTLE EVENTS\r\n\r\n"
- for be in battle_events
- be.write_to_stream(f)
- end
- }
- $data_system = load_data("Data/System.rxdata")
- start_map_id = $data_system.start_map_id
- marked = {}
- marked[start_map_id] = true
- pending = [start_map_id]
- until pending.empty?
- map_id = pending.pop
- for new_id in $map[map_id]
- unless marked[new_id]
- marked[new_id] = true
- pending << new_id
- end
- end
- end
- reachable = (marked.keys).sort
- unreachable = ($map.keys - marked.keys).sort
- not_editable = (marked.keys - $map.keys).sort
- File.open('Transfers.txt', 'wb') {|f|
- f.print "THIS FILE CONTAINS INFORMATION ABOUT REACHABLE MAPS THROUGH TRANSFERS\r\n\r\n"
- f.print "Reachable through map transfer events (#{reachable.size} maps)\r\n"
- for map_id in reachable
- f.print "Map " + map_id.to_s + " - " + map_map[map_id].name + "\r\n"
- end
- f.print "\r\nUnreachable through map transfer events (#{unreachable.size} maps)\r\n"
- for map_id in unreachable
- f.print "Map " + map_id.to_s + " - " + map_map[map_id].name + "\r\n"
- end
- f.print "\r\Not editable in the map editor yet reachable through map transfer events (#{not_editable.size} maps)\r\n"
- for map_id in not_editable
- f.print "Map " + map_id.to_s + " - " + map_map[map_id].name + "\r\n"
- end
- }
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement