Memorize Event Positions
By Biged781
IntroFor those who do not like that the positions of their events reset when the player exits and enters a map, this script will automatically memorize their positions for you. Just drop it into the materials section and your events will always appear where they left off. You can enable and disable this behavior by turning a switch ON or OFF.
Bug Fixes / Enhancements-> Added a way to disable the effects of this script for certain events.
-> Fixed a bug that would have occurred with encrypted game files.
-> Ended reliance on the file system, greatly reduces chances of bugs (thanks wora

)
Configuration / UseJust plop it into the "Materials" sections, should be no problems. To turn the script on and off, find this part of the script:
CODE
#-----------------------------------------------------------------------
# * Set this to the switch number that you will
# use to turn this script ON or OFF.
# ---------
# Set to switch id "1" by default.
#
MOVE_EVENTS_SWITCH_ID = 1
You can modify this constant,
CODE
MOVE_EVENTS_SWITCH_ID
to equal the id of the switch that you would like to use. If this switch is ON, the events on each map will memorize their positions at all times. If you turn this switch OFF, they will return to their default positions. Note that only the maps that are loaded
after the switch is turned ON or OFF will be affected, i.e., the current map positions will be saved, but the events will not be moved.
--------------------------------To disable the effects of this script at the event level, add a comment to the event with only the text "no mem", without the quotes.

ScriptCODE
#-----------------------------------------------------------------------
# Memorize Event Positions
# BigEd781
#-----------------------------------------------------------------------
class Game_System
alias :eds_old_pre_mem_intialize :initialize
def initialize
eds_old_pre_mem_intialize
@event_pos_data = {}
end
def save_event_position_data(map_id, data)
@event_pos_data[map_id] = data
end
def get_event_position_data(map_id)
return @event_pos_data[map_id].nil? ? [] : @event_pos_data[map_id]
end
end
class Game_Event < Game_Character
def comment?(comment)
unless @list.nil?
@list.each { |line|
next if line.code != 108
return true if line.parameters[0].upcase == comment.upcase }
end
return false
end
end
class Game_Map
alias :eds_old_pre_mem_setup :setup
def setup(map_id)
save_positions if $game_switches[1]
eds_old_pre_mem_setup(map_id)
restore_positions if $game_switches[1]
end
def save_positions
return if @events.nil? || @events == { }
data = []
@events.values.each { |event| data += [[ event.id, event.x, event.y, event.direction ]] }
$game_system.save_event_position_data(@map_id, data)
end
def restore_positions
return if @events.nil? || @events == { }
$game_system.get_event_position_data(@map_id).each { |data|
event = @events[data[0]]
unless event.nil? || event.comment?('no mem')
x, y, direction = data[1], data[2], data[3]
event.moveto(x, y) unless event.pos?(x, y)
event.set_direction(direction)
end
}
end
end
Compatibilty / IssuesI don't not know of any issues currently, but this system writes out the event's locations to a file when maps are left, and reads that file back in to position the events when a map is loaded. Also, there are many edge conditions to yet be found so there will probably be some bugs. I will fix them as soon as they are posted. Compatibility with other scripts should be 100%.