class Game_Event attr_accessor :need_refresh alias petero_scriptswitches_Game_Event_initialize initialize alias petero_scriptswitches_Game_Event_update update def initialize(map_id, event) @tempSwitches={} @need_refresh=false petero_scriptswitches_Game_Event_initialize(map_id,event) end def name return @event.name end def id return @event.id end def tsOn?(c) return @tempSwitches && @tempSwitches[c]==true end def tsOff?(c) return !@tempSwitches || !@tempSwitches[c] end def setTempSwitchOn(c) @tempSwitches[c]=true refresh end def setTempSwitchOff(c) @tempSwitches[c]=false refresh end def variable return nil if !$game_eventvars return $game_eventvars[[@map_id,@event.id]] end def varAsInt return 0 if !$game_eventvars return $game_eventvars[[@map_id,@event.id]].to_i end def expired?(secs=86400) ontime=self.variable return ontime && (Time.now.to_i>ontime+secs) end def onEvent? return @map_id==$game_map.map_id && $game_player.x==self.x && $game_player.y==self.y end def isOff?(c) return !$game_self_switches[[@map_id,@event.id,c]] end def isOn?(c) return $game_self_switches[[@map_id,@event.id,c]] end def switchIsOn?(id) switchname=$data_system.switches[id] return false if !switchname if switchname[/^s\:/] return eval($~.post_match) else return $game_switches[id] end end def refresh # Initialize local variable: new_page new_page = nil # If not temporarily erased unless @erased # Check in order of large event pages for page in @event.pages.reverse # Make possible referrence for event condition with c c = page.condition # Switch 1 condition confirmation if c.switch1_valid if switchIsOn?(c.switch1_id) == false # Modification next end end # Switch 2 condition confirmation if c.switch2_valid if switchIsOn?(c.switch2_id) == false # Modification next end end # Variable condition confirmation if c.variable_valid if $game_variables[c.variable_id] < c.variable_value next end end # Self switch condition confirmation if c.self_switch_valid key = [@map_id, @event.id, c.self_switch_ch] if $game_self_switches[key] != true next end end # Set local variable: new_page new_page = page # Remove loop break end end # If event page is the same as last time if new_page == @page # End method return end # Set @page as current event page @page = new_page # Clear starting flag clear_starting # If no page fulfills conditions if @page == nil # Set each instance variable @tile_id = 0 @character_name = "" @character_hue = 0 @move_type = 0 @through = true @trigger = nil @list = nil @interpreter = nil # End method return end # Set each instance variable @tile_id = @page.graphic.tile_id @character_name = @page.graphic.character_name @character_hue = @page.graphic.character_hue if @original_direction != @page.graphic.direction @direction = @page.graphic.direction @original_direction = @direction @prelock_direction = 0 end if @original_pattern != @page.graphic.pattern @pattern = @page.graphic.pattern @original_pattern = @pattern end @opacity = @page.graphic.opacity @blend_type = @page.graphic.blend_type @move_type = @page.move_type @move_speed = @page.move_speed @move_frequency = @page.move_frequency @move_route = @page.move_route @move_route_index = 0 @move_route_forcing = false @walk_anime = @page.walk_anime @step_anime = @page.step_anime @direction_fix = @page.direction_fix @through = @page.through @always_on_top = @page.always_on_top @trigger = @page.trigger @list = @page.list @interpreter = nil # If trigger is [parallel process] if @trigger == 4 # Create parallel process interpreter @interpreter = Interpreter.new end # Auto event start determinant check_event_trigger_auto end def update if @need_refresh @need_refresh=false refresh end petero_scriptswitches_Game_Event_update end end class Interpreter def setEventTime(*arg) time=Time.now.to_i setSelfSwitch(@event_id,"A",true) $game_eventvars[[@map_id,@event_id]]=time for otherevt in arg setSelfSwitch(otherevt,"A",true) $game_eventvars[[@map_id,otherevt]]=time end end def getVariable return $game_eventvars[[@map_id,@event_id]] end def getVariableAsInt value=$game_eventvars[[@map_id,@event_id]] return value ? value.to_i : 0 end def setVariable(value) $game_eventvars[[@map_id,@event_id]]=value end def setTempSwitchOn(c) get_character(0).setTempSwitchOn(c) end def setTempSwitchOff(c) get_character(0).setTempSwitchOff(c) end def setSelfSwitch(event,swtch,value) $game_self_switches[[@map_id,event,swtch]]=value $game_map.need_refresh = true end end class Scene_Load < Scene_File alias petero_scriptswitches_Scene_Load_read_save_data read_save_data def read_save_data(file) petero_scriptswitches_Scene_Load_read_save_data(file) $game_eventvars=Marshal.load(file) end end class Scene_Save < Scene_File alias petero_scriptswitches_Scene_Save_write_save_data write_save_data def write_save_data(file) petero_scriptswitches_Scene_Save_write_save_data(file) Marshal.dump($game_eventvars,file) end end class Scene_Title alias petero_scriptswitches_Scene_Title_command_new_game command_new_game def command_new_game $game_eventvars={} petero_scriptswitches_Scene_Title_command_new_game end end