=begin #=============================================================================== Title: Global Event Tracker Author: Hime Date: Jul 24, 2013 -------------------------------------------------------------------------------- ** Change log Jul 24, 2013 - Initial release -------------------------------------------------------------------------------- ** Terms of Use * Free to use in non-commercial projects * Contact me for commercial use * No real support. The script is provided as-is * Will do bug fixes, but no compatibility patches * Features may be requested but no guarantees, especially if it is non-trivial * Credits to Hime Works in your project * Preserve this header -------------------------------------------------------------------------------- ** Description This script uniquely tracks events throughout the game. It introduces the concept of an Event Unique Identifier, or simply an event's uid. The uid is composed of two pieces of information -the event's ID -the map the event was initially created The information is stored in an array and then hashed, forming the uid for the event. The uid is stored with the Game_Event and assumes there is a one-to-one correspondence between a Game_Event and its contained RPG::Event. All events are then stored in a global hash which you can look up if you need to. Note that any scripts that duplicate events without properly assigning new event ID's may not be compatible with this script. -------------------------------------------------------------------------------- ** Installation Place this script below Materials and above Main -------------------------------------------------------------------------------- ** Usage This is a utility script for developers. #=============================================================================== =end $imported = {} if $imported.nil? $imported["TH_GlobalEventTracker"] = true #=============================================================================== # ** Rest of script #=============================================================================== module DataManager class << self alias :th_event_tracker_make_save_contents :make_save_contents alias :th_event_tracker_extract_save_contents :extract_save_contents alias :th_event_tracker_create_game_objects :create_game_objects end def self.create_game_objects th_event_tracker_create_game_objects $game_events = {} end def self.make_save_contents contents = th_event_tracker_make_save_contents contents[:events] = $game_events contents end def self.extract_save_contents(contents) th_event_tracker_extract_save_contents $game_events = contents[:events] end end class Game_Event < Game_Character attr_reader :uid alias :th_event_locations_initialize :initialize def initialize(map_id, event) setup_uid(map_id, event) if @uid.nil? th_event_locations_initialize(map_id, event) end #----------------------------------------------------------------------------- # Assign this event its uid. #----------------------------------------------------------------------------- def setup_uid(map_id, event) @uid = [map_id, event.id].hash $game_events[uid] = self end end