# =============================================================================
# TheoAllen - 记忆事件位置
# Version : 1.0
# Contact : [url]www.rpgmakerid.com[/url] (or) [url]http://theolized.blogspot.com[/url]
# (This script documentation is written in informal indonesian language)
# =============================================================================
($imported ||= {})[:Theo_MemorizeEvent] = true
# =============================================================================
# CHANGE LOGS:
# -----------------------------------------------------------------------------
# 2013.06.18 - Finished script
# =============================================================================
=begin
介绍 :
本脚本可以在玩家进入下一张地图时,记忆事件的位置。玩家从其他地图回到该地图时
事件会出现在之前的相同位置上。
使用方法 :
将本脚本放在插件脚本和基础模块之下,Main之上
事件名以此标志作为开头: <memorize>
则该事件的位置可以被记忆。
使用条款 :
署名脚本作者, TheoAllen. 你可以自由编辑此脚本,只要你不声明你是脚本的原作者
如果你想用此脚本于商业游戏,请和我共享收益.别忘了给我一份免费的游戏拷贝.
=end
# =============================================================================
# 无设定
# =============================================================================
module THEO
module MAP
module REGEXP
MEMORIZE = /<(?:MEMORIZE|memorize)>(.*)/
end
end
end
Point = Struct.new(:x,:y)
class Event_Memorizer
def initialize
@data = {}
end
def [](key)
if @data[key].nil?
event = $game_map.events[key[1]]
@data[key] = Point.new(event.x,event.y)
end
return @data[key]
end
def []=(key,value)
@data[key] = value
end
end
class Game_System
attr_accessor :event_pos
alias pre_evmemorize_init initialize
def initialize
pre_evmemorize_init
init_event_memorizer
end
def init_event_memorizer
@event_pos = Event_Memorizer.new
end
end
class Game_Event < Game_Character
def name
@event.name
end
end
class Scene_Map < Scene_Base
include THEO::MAP
alias pre_evmemorize_transfer pre_transfer
def pre_transfer
pre_evmemorize_transfer
save_events_location
end
def save_events_location
$game_map.events.each do |id,event|
case event.name
when REGEXP::MEMORIZE
$game_system.event_pos[[$game_map.map_id,id]]=Point.new(event.x,event.y)
end
end
end
end
class Game_Map
include THEO::MAP
alias pre_setup_evmemorize setup
def setup(map_id)
pre_setup_evmemorize(map_id)
load_events_location
end
def load_events_location
events.each do |id,event|
case event.name
when REGEXP::MEMORIZE
point = $game_system.event_pos[[map_id,id]]
event.moveto(point.x,point.y)
end
end
end
end