Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###############################################################################
- # Event Location Saver
- # By: Ixfuru
- # August 18, 2013
- ################################################################################
- #
- # This script saves the location of an event and holds this place even after
- # transfers to different maps. To use the script, utilize the following
- # script calls:
- #
- # To save the position of an event, use:
- #-------------------------------------------------------------------------------
- # $game_map.save_ev_loc(event_id, x, y)
- #
- # event_id: the event you wish to lock into a position
- # x: the x position where you want the event to stay
- # y: the y position where you want the event to stay
- #-------------------------------------------------------------------------------
- #
- # To free a locked event, use:
- #-------------------------------------------------------------------------------
- # $game_map.free_ev_loc(event_id)
- #
- # event_id: the id of the event you wish to free from its saved position
- #-------------------------------------------------------------------------------
- ################################################################################
- # Give credit to Ixfuru
- ################################################################################
- ################################################################################
- # CLASS GAME EVENT
- ################################################################################
- class Game_Event < Game_Character
- #-----------------------------------------------------------------------------
- # Move to Saved Location
- #-----------------------------------------------------------------------------
- def moveto_saved_location
- loc = $game_map.evlocsaves[@map_id][@id]
- moveto(loc[0], loc[1])
- end
- end
- ################################################################################
- # CLASS GAME MAP
- ################################################################################
- class Game_Map
- attr_accessor :evlocsaves
- #-----------------------------------------------------------------------------
- # Initialize (Aliased)
- #-----------------------------------------------------------------------------
- alias ixgmapinit initialize unless $@
- def initialize
- ixgmapinit
- @evlocsaves = {}
- end
- alias ixgmapsetup setup unless $@
- def setup(map_id)
- ixgmapsetup(map_id)
- @events.each_key { |event|
- if @evlocsaves.has_key?(map_id) && @evlocsaves[map_id].has_key?(event)
- $game_map.events[event].moveto_saved_location
- end
- }
- end
- #-----------------------------------------------------------------------------
- # Save Ev Loc (Save Event Location)
- # event_id: id of the event you wish to save
- # x: map x corresponding to where you want the event to be
- # y: map y corresponding to where you want the event to be
- #------------------------------------------------------------------------------
- def save_ev_loc(event_id, x, y)
- @evlocsaves[@map_id] = Hash[event_id, [x, y]]
- end
- #-----------------------------------------------------------------------------
- # Free Ev Loc
- # called to free the event from its saved location
- # event_id: the id of the event you wish to free
- #-----------------------------------------------------------------------------
- def free_ev_loc(event_id)
- if @evlocsaves[@map_id].has_key?(event_id)
- @evlocsaves[@map_id].delete(event_id)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment