=begin
                              Thomas Edison VX
Version: 0.1
Author: BulletXt (bulletxt@gmail.com)
Date: 12/06/2009
Script based upon Kylock's (http://www.rpgmakervx.net/index.php?showtopic=2432)
Description:
 To make an event glow, put a Comment inside event with one of the following
 light modes. When importing this script to a new project, be sure to copy
 Graphics/Pictures/le.png to your project.
 
Light Modes:
  
 GROUND - Medium steady white light.
 GROUND2 - Medium white light with slight flicker.
 GROUND3 - Small steady red light.
 GROUND4 - Medium steady green light.
 GROUND5 - Medium steady blu light.
 FIRE - Large red light with a slight flicker.
 LIGHT - Small steady white light.
 LIGHT2 - X-Large steady white light.
 LIGHT3 - Small white light with slight flicker.
 TORCH - X-Large red light with a heavy flicker.
 TORCH2 - X-Large red light with a sleight flicker.
 TORCH3 - Large white light with a slight flicker.
You can make a specific light type turn off/on by turning
one of the following switches id ON/off. By default, the switches are off so
the lights will show. Of course, turning all switches to ON will make all
light types go off.
=end
#id switch that if ON turns off FIRE mode lights
#applies only to light mode: FIRE
FIRE = 87
#id switch that if ON turns off LIGHT mode lights
#applies to light mode: LIGHT, LIGHT2, LIGHT3
LIGHT = 86
#id switch that if ON turns off GROUND mode lights
#applies to light mode: GROUND, GROUND2, GROUND3, GROUND4, GROUND5
GROUND = 85
#id switch that if ON turns off TORCH mode lights
#applies to light mode: TORCH, TORCH2, TORCH3
TORCH = 84
# this value can be true or false. If true, it enables compatibility with
# KGC_DayNight script. When it's night, lights will automatically go on, when
# morning comes back lights will go off. If you set this to true, be sure to
# place this script below KGC_DayNight script in the Scripting Editor of VX.
ENABLE_KGC_DAY_NIGHT_SCRIPT = true
=begin
This value must be exactly the same of "PHASE_VARIABLE" setting in KGC_DayNight
script. By default the script sets it to 11.
To make the event light go on/off with DayNight system, set the event page
to be triggered with this variable id and set it to be 1 or above.
=end
KGC_DAY_NIGHT_SCRIPT_VARIABLE = 11
=begin
Tips and tricks:
  You can't make a single specific light inside event go on/off if 
  a condition applies, for example if a switch is ON.
  For the moment, you can achieve this by doing
  a script call immediatley after you make the condition apply.
  If for example the light event must go on if switch 100 is ON, after you turn
  on the switch do this call script:
  $scene = Scene_Map.new
  
  Be aware that doing this call script will make game freeze
  for 30 milliseconds.
################################################################################
=end
$bulletxt_day_check = 0
class Spriteset_Map
	
  alias bulletxt_spriteset_map_initalize initialize
	def initialize
		@light_effects = []
		initialize_lights
		bulletxt_spriteset_map_initalize
		update
	end
  alias bulletxt_spriteset_map_dispose dispose
	def dispose
		bulletxt_spriteset_map_dispose
		for effect in @light_effects
			effect.light.dispose
		end
		@light_effects = []
	end
	
  alias bulletxt_spriteset_map_update update
	def update
		bulletxt_spriteset_map_update
    check_day_night if ENABLE_KGC_DAY_NIGHT_SCRIPT
		update_light_effects
    
	end
  
  def check_day_night
    #if night
   if $bulletxt_day_check == 0 
    if $game_variables[KGC_DAY_NIGHT_SCRIPT_VARIABLE] == 1
      $scene = Scene_Map.new
      $bulletxt_day_check = 1
  
    end
    
  else
    #if morning
    if $game_variables[KGC_DAY_NIGHT_SCRIPT_VARIABLE] == 3
      $game_variables[KGC_DAY_NIGHT_SCRIPT_VARIABLE] = -1
      $scene = Scene_Map.new
      $bulletxt_day_check = 0
    end
  end
  
    
    
  end
  
  
	def initialize_lights
		for event in $game_map.events.values
			next if event.list == nil
				for i in 0...event.list.size
					if event.list[i].code == 108 and event.list[i].parameters == ["FIRE"]
						type = "FIRE"
						light_effects = Light_Effect.new(event,type)
						light_effects.light.zoom_x = 300 / 100.0
						light_effects.light.zoom_y = 300 / 100.0
						light_effects.light.opacity = 100
						@light_effects.push(light_effects)
					end
          
					if event.list[i].code == 108 and event.list[i].parameters == ["LIGHT"]
						type = "LIGHT"
						light_effects = Light_Effect.new(event,type)
						light_effects.light.zoom_x = 1
						light_effects.light.zoom_y = 1
						light_effects.light.opacity = 150
						@light_effects.push(light_effects)
					end
					if event.list[i].code == 108 and event.list[i].parameters == ["LIGHT2"]
						type = "LIGHT2"
						light_effects = Light_Effect.new(event,type)
						light_effects.light.zoom_x = 6
						light_effects.light.zoom_y = 6
						light_effects.light.opacity = 150
						@light_effects.push(light_effects)
					end
					if event.list[i].code == 108 and event.list[i].parameters == ["LIGHT3"]
						type = "LIGHT3"
						light_effects = Light_Effect.new(event,type)
						light_effects.light.zoom_x = 1
						light_effects.light.zoom_y = 1
						light_effects.light.opacity = 150
						@light_effects.push(light_effects)
					end
          
					if event.list[i].code == 108 and event.list[i].parameters == ["TORCH"]
						type = "TORCH"
						light_effects = Light_Effect.new(event,type)
						light_effects.light.zoom_x = 6
						light_effects.light.zoom_y = 6
						light_effects.light.opacity = 150
						@light_effects.push(light_effects)
					end
					if event.list[i].code == 108 and event.list[i].parameters == ["TORCH2"]
						type = "TORCH2"
						light_effects = Light_Effect.new(event,type)
						light_effects.light.zoom_x = 6
						light_effects.light.zoom_y = 6
						light_effects.light.opacity = 150
						@light_effects.push(light_effects)
					end
					if event.list[i].code == 108 and event.list[i].parameters == ["TORCH3"]
						type = "TORCH3"
						light_effects = Light_Effect.new(event,type)
						light_effects.light.zoom_x = 300 / 100.0
						light_effects.light.zoom_y = 300 / 100.0
						light_effects.light.opacity = 100
						@light_effects.push(light_effects)
					end
          
					if event.list[i].code == 108 and event.list[i].parameters == ["GROUND"]
						type = "GROUND"
						light_effects = Light_Effect.new(event,type)
						light_effects.light.zoom_x = 2
						light_effects.light.zoom_y = 2
						light_effects.light.opacity = 100
						@light_effects.push(light_effects)
					end
					if event.list[i].code == 108 and event.list[i].parameters == ["GROUND2"]
						type = "GROUND2"
						light_effects = Light_Effect.new(event,type)
						light_effects.light.zoom_x = 2
						light_effects.light.zoom_y = 2
						light_effects.light.opacity = 100
						@light_effects.push(light_effects)
					end
					if event.list[i].code == 108 and event.list[i].parameters == ["GROUND3"]
						type = "GROUND3"
						light_effects = Light_Effect.new(event,type)
						light_effects.light.zoom_x = 2
						light_effects.light.zoom_y = 2
						light_effects.light.opacity = 100
						@light_effects.push(light_effects)
					end
					if event.list[i].code == 108 and event.list[i].parameters == ["GROUND4"]
						type = "GROUND4"
						light_effects = Light_Effect.new(event,type)
						light_effects.light.zoom_x = 2
						light_effects.light.zoom_y = 2
						light_effects.light.opacity = 100
						@light_effects.push(light_effects)
					end
					if event.list[i].code == 108 and event.list[i].parameters == ["GROUND5"]
						type = "GROUND5"
						light_effects = Light_Effect.new(event,type)
						light_effects.light.zoom_x = 2
						light_effects.light.zoom_y = 2
						light_effects.light.opacity = 100
						@light_effects.push(light_effects)
					end
				end
			end
			
	for effect in @light_effects
		case effect.type
		
		when "FIRE"
			effect.light.x = (effect.event.real_x - 600 - $game_map.display_x) / 8 + rand(6) - 3
			effect.light.y = (effect.event.real_y - 600 - $game_map.display_y) / 8 + rand(6) - 3
			effect.light.tone = Tone.new(255,-100,-255, 0)
			effect.light.blend_type = 1
		when "LIGHT"
			effect.light.x = (-0.25 / 2 * $game_map.display_x) + (effect.event.x * 32) - 15
			effect.light.y = (-0.25 / 2 * $game_map.display_y) + (effect.event.y * 32) - 15
			effect.light.blend_type = 1
		when "LIGHT2"
			effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
			effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
			effect.light.blend_type = 1
		when "LIGHT3"
			effect.light.x = (-0.25 / 2 * $game_map.display_x) + (effect.event.x * 32) - 15
			effect.light.y = (-0.25 / 2 * $game_map.display_y) + (effect.event.y * 32) - 15
			effect.light.blend_type = 1
		when "TORCH"
			effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
			effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
			effect.light.tone = Tone.new(255,-100,-255, 0)
			effect.light.blend_type = 1
		when "TORCH2"
			effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
			effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
			effect.light.tone = Tone.new(255,-100,-255, 0)
			effect.light.blend_type = 1
		when "TORCH3"
			effect.light.x = (effect.event.real_x - 600 - $game_map.display_x) / 8 + rand(6) - 3
			effect.light.y = (effect.event.real_y - 600 - $game_map.display_y) / 8 + rand(6) - 3
			effect.light.blend_type = 1
      
		when "GROUND"
			effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
			effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
			effect.light.blend_type = 1
		when "GROUND2"
			effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
			effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
			effect.light.blend_type = 1
		when "GROUND3"
			effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
			effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
			effect.light.tone = Tone.new(255,-255,-255, 255)
			effect.light.blend_type = 1
		when "GROUND4"
			effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
			effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
			effect.light.tone = Tone.new(-255,255,-255, 100)
			effect.light.blend_type = 1
		when "GROUND5"
			effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
			effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
			effect.light.tone = Tone.new(-255,255,255, 100)
			effect.light.blend_type = 1
		end
	end
end
def update_light_effects
################################################################################
  
  # handle FIRE
  if $game_switches[FIRE]
    for effect in @light_effects
      next if effect.type != "FIRE" 
      effect.light.visible = false
    end
  else
    for effect in @light_effects
     next if effect.type != "FIRE" 
      effect.light.visible = true
    end
  end
  # handle LIGHT
  if $game_switches[LIGHT]
    for effect in @light_effects
      next if effect.type != "LIGHT" && effect.type != "LIGHT2" && effect.type != "LIGHT3"
      effect.light.visible = false
    end
  else
    for effect in @light_effects
      next if effect.type != "LIGHT" && effect.type != "LIGHT2" && effect.type != "LIGHT3"
      effect.light.visible = true
    end
  end
  # handle GROUND
  if $game_switches[GROUND]
    for effect in @light_effects
      next if effect.type != "GROUND" && effect.type != "GROUND2" && effect.type != "GROUND3" && effect.type != "GROUND4" && effect.type != "GROUND5" 
      effect.light.visible = false
    end
  else
    for effect in @light_effects
      next if effect.type != "GROUND" && effect.type != "GROUND2" && effect.type != "GROUND3" && effect.type != "GROUND4" && effect.type != "GROUND5" 
      effect.light.visible = true
    end
  end
  # handle TORCH
  if $game_switches[TORCH]
    for effect in @light_effects
      next if effect.type != "TORCH" && effect.type != "TORCH2" && effect.type != "TORCH3"
      effect.light.visible = false
    end
  else
    for effect in @light_effects
      next if effect.type != "TORCH" && effect.type != "TORCH2" && effect.type != "TORCH3"
      effect.light.visible = true
    end
  end
################################################################################
	for effect in @light_effects
		case effect.type
	when "FIRE"
			effect.light.x = (effect.event.real_x - 600 - $game_map.display_x) / 8 + rand(6) - 3
			effect.light.y = (effect.event.real_y - 600 - $game_map.display_y) / 8 + rand(6) - 3
			effect.light.opacity = rand(10) + 90
      
	when "LIGHT"
			effect.light.x = (-0.25 / 2 * $game_map.display_x) + (effect.event.x * 32) - 15
			effect.light.y = (-0.25 / 2 * $game_map.display_y) + (effect.event.y * 32) - 15
	when "LIGHT2"
			effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
			effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
	when "LIGHT3"
			effect.light.x = (-0.25 / 2 * $game_map.display_x) + (effect.event.x * 32) - 15
			effect.light.y = (-0.25 / 2 * $game_map.display_y) + (effect.event.y * 32) - 15
			effect.light.opacity = rand(10) + 90
      
	when "TORCH"
			effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20 + rand(20) - 10
			effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8 + rand(20) - 10
			effect.light.opacity = rand(30) + 70
	when "TORCH2"
			effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
			effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
			effect.light.opacity = rand(10) + 90
	when "TORCH3"
			effect.light.x = (effect.event.real_x - 600 - $game_map.display_x) / 8 + rand(6) - 3
			effect.light.y = (effect.event.real_y - 600 - $game_map.display_y) / 8 + rand(6) - 3
			effect.light.opacity = rand(10) + 90
      
	when "GROUND"
			effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
			effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
	when "GROUND2"
			effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
			effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
			effect.light.opacity = rand(10) + 90
	when "GROUND3"
			effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
			effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
	when "GROUND4"
			effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
			effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
	when "GROUND5"
			effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
			effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
		end
	end
  #close def
	end
#close class	
end
class Light_Effect
	attr_accessor :light
	attr_accessor :event
	attr_accessor :type
	
	def initialize(event, type)
		@light = Sprite.new
		@light.bitmap = Cache.picture("le.png")
		@light.visible = true
		@light.z = 1000
		@event = event
		@type = type
	end
end
------------------------------------------------------------------------------------
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
#_/    ◆              Day-to-Night Phases - KGC_DayNight                ◆ VX ◆
#_/    ◇                   Last update : 2008/03/08                          ◇
#_/    ◆                  Translated by Mr. Anonymous                        ◆
#_/-----------------------------------------------------------------------------
#_/  This script adds the concept of Day-to-Night phase shifting to your game.
#_/   Events that only occur during certain phase shifts, such as night, can
#_/   be created as well.
#_/=============================================================================
#_/  Note: The event command "Tint Screen" doesn't function normally while this 
#_/   script is running a phase shift. To use the Tint Screen function properly,
#_/   please refer to the directions.
#_/=============================================================================
#_/ Installation: Insert above Main.
#_/-----------------------------------------------------------------------------
#_/  Terminology: Phase refers to the current state of the day, such as "Noon".
#_/                         ◆ Instructions For Usage ◆
#_/  
#_/                           ◆ Stop Day-to-Night ◆
#_/  When [DN_STOP] is inserted into a Map's name (after its given name), the
#_/  Day-to-Night change stops, the timer does not stop however, and if a phase
#_/  is currently active, such as "Night", the tint remains on the map.
#_/  
#_/                 ◆ Stop Day-to-Night and Time, Cancel Phase ◆
#_/  
#_/  When [DN_VOID] is inserted into a Map's name (after its given name), the
#_/  Day-to-Night change stops, the timer is effectively frozen, and if a phase
#_/  is currently active, such as "Night", the tint is reverted back to normal.
#_/  
#_/                       ◆ Phase-Specific Encounters ◆
#_/  
#_/  When [DN Phase#](Where Phase# refers to the phase. 0 = Noon, 1 = Evening,
#_/   2 = Night, 3 = Morning) is inserted into a specified Troop's "Notes" box 
#_/   in the Troops tab of the database, the specified Troop will only appear
#_/   under those conditions.
#_/  
#_/                         ◆ Event Script Functions ◆
#_/  The following commands are available using the "Script" item in events.
#_/  
#_/  * stop_daynight
#_/     Day to Night change is stopped.
#_/  
#_/  * start_daynight
#_/     Day to Night change is started.
#_/  
#_/  * get_daynight_name 
#_/     Name of present phase is acquired. This function only works in other
#_/      scripts.
#_/  
#_/  * get_daynight_week (variable_id)
#_/     Appoints the day of the week to the given variable.
#_/  
#_/  * get_daynight_week_name
#_/     Name of the present day is aquired. This function only works in other
#_/      scripts.
#_/  
#_/  * change_daynight_phase(phase, duration, pass_days)
#_/     Changes the current phase to a new one. Handy for Inns and the like.
#_/     Example: change_daynight_phase (3, 1, 1)
#_/       This would make one day pass, change the phase to morning, with a
#_/       duration of one frame. Duration must be set to a minimum of 1.
#_/  
#_/   * transit_daynight_phase(duration)
#_/      Forces the phase to change at the very moment you call this.
#_/       This appears to be bugged. No matter how I've called it, I get errors.
#_/  
#_/   * set_daynight_default(duration)
#_/      Forces the tint of the current phase to reset to the initial phase.
#_/  
#_/   * restore_daynight_phase(duration)
#_/      Forces the tint of the current phase to reset to its normal tint.
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
#==============================================================================#
#                              ★ Customization ★                               #
#==============================================================================#
module KGC
 module DayNight
  #                      ◆ Day to Night Switch Method ◆
  #  0. Time Lapse  1.Time passes with number of steps  2.Real Time
  METHOD = 1
  #                           ◆ Phase Variable ◆
  # The present phase (of day and night) is stored here.
  PHASE_VARIABLE = 11
  
  #                     ◆ Passing Days Storage Variable ◆
  #  The passing days is stored here.
  PASS_DAYS_VARIABLE = 12
  #                         ◆ Stop On Event Toggle ◆ 
  #  Stops the Day/Night Timer when an event is run by player.
  STOP_ON_EVENT = false
  
  #                         ◆ Phases During Combat ◆
  #  true = Only the battleback is tinted.
  #  false = Battleback and enemies are tinted.
  TONE_BACK_ONLY_IN_BATTLE = true
  #                       ◆ Setting Individual Phases ◆
  #  Each phase makes use of the Tint Screen function. The format as follows:
  #   ["Name", the color tone(Tint), time switch],
  #
  #  [Name]
  #    Name of Phase
  #    *The name holds no significance.
  #  [Tint]
  #    The color tone of the entire screen.
  #    Please don't alter this if you don't grasp color tints.
  #  [Time Shift]
  #    The amount of steps taken until the next phase shift occurs.
  #    The following set up is for step-time change. (METHOD = 1) 
  PHASE = [
    ["Noon",   Tone.new(   0,    0,   0), 300],     # Phase 0
    ["Evening", Tone.new( -32,  -96, -96), 100],    # Phase 1
    ["Night",   Tone.new(-128, -128, -32), 250],    # Phase 2
    ["Morning",   Tone.new( -48,  -48, -16), 100],  # Phase 3
  ] 
  #                          ◆ Real Time Setup ◆
  # Replace the values in the about phase set-up if you wish to use real-time.
  #  ["Noon",   Tone.new(  0,   0,   0), 16],     #Phase0 (16 o'clock [4:00PM])
  #  ["Evening", Tone.new(  0, -96, -96), 20],    #Phase1 (20 o'clock [8:00PM])
  #  ["Night",   Tone.new(-96, -96, -64),  6],    #Phase2 (6 o'clock [6:00AM])
  #  ["Morning",   Tone.new(-48, -48, -16), 10],  #Phase3 (10 o'clock [10:00AM])
  #                            ◆ Day Change ◆
  #  The day changes on the value set here.
  #   0.Day  1.Evening  2.Night  3.Morning
  PASS_DAY_PHASE = 3
  #                        ◆ Fade Time (by frame) ◆
  #  The amount of frames it takes to fade into the next phase.
  PHASE_DURATION = 60
  #                        ◆ Day of the Week Names ◆
  #  This shouldn't be hard to figure out, I hope.
  #  When using the Real-Time method (= 2), this must be seven days.
  #  Values of these are 0, 1, 2, 3, 4, 5, 6
  WEEK_NAME = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
 end
end
#------------------------------------------------------------------------------#
$imported = {} if $imported == nil
$imported["DayNight"] = true
if $data_mapinfos == nil
  $data_mapinfos = load_data("Data/MapInfos.rvdata")
end
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #
#  Unless you know what you're doing, it's best not to alter anything beyond  #
#  this point, as this only affects the tags used for the Map name.           #
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #
module KGC::DayNight
  METHOD_TIME  = 0  # Time Lapse
  METHOD_STEP  = 1  # Time passes with number of steps
  METHOD_RTIME = 2  # Real Time
  
#  Whatever word(s) in the following lines are what are used to determine 
#  what is searched for in the Map Name or the "Notes" section of the database.
  # Regular Expression Defined
  module Regexp
    # Base MapInfo Module
    module MapInfo
      # Day/Night Stop tag string
      DAYNIGHT_STOP = /\[DN_STOP\]/i
      # Day/Night Void tag string
      DAYNIGHT_VOID = /\[DN_VOID\]/i
    end
    # Base Troop Module
    module Troop
      # Appearance Phase tag string
      APPEAR_PHASE = /\[DN((?:[ ]*[\-]?\d+(?:[ ]*,)?)+)\]/i
    end
  end
  #--------------------------------------------------------------------------
  # ○ 敵グループ出現判定
  #     troop : 判定対象の敵グループ
  #     phase : 判定するフェーズ
  #--------------------------------------------------------------------------
  def self.troop_appear?(troop, phase = $game_system.daynight_phase)
    # 出現判定
    unless troop.appear_daynight_phase.empty?
      return false unless troop.appear_daynight_phase.include?(phase)
    end
    # 非出現判定
    unless troop.nonappear_daynight_phase.empty?
      return false if troop.nonappear_daynight_phase.include?(phase)
    end
    return true
  end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# □ KGC::Commands
#==============================================================================
module KGC::Commands
  module_function
  #--------------------------------------------------------------------------
  # ○ 昼夜切り替えを停止
  #--------------------------------------------------------------------------
  def stop_daynight
    $game_system.daynight_change_enabled = false
  end
  #--------------------------------------------------------------------------
  # ○ 昼夜切り替えを起動
  #--------------------------------------------------------------------------
  def start_daynight
    $game_system.daynight_change_enabled = true
  end
  #--------------------------------------------------------------------------
  # ○ Preset Phase is aquired.
  #--------------------------------------------------------------------------
  def get_daynight_name
    return KGC::DayNight::PHASE[get_daynight_phase][0]
  end
  #--------------------------------------------------------------------------
  # ○ Obtain DayNight Week and store it in a variable.
  #     variable_id : Variable ID
  #--------------------------------------------------------------------------
  def get_daynight_week(variable_id = 0)
    if KGC::DayNight::METHOD == KGC::DayNight::METHOD_RTIME
      week = Time.now.wday
    else
      days = $game_variables[KGC::DayNight::PASS_DAYS_VARIABLE]
      week = (days % KGC::DayNight::WEEK_NAME.size)
    end
    if variable_id > 0
      $game_variables[variable_id] = week
    end
   return week
  end
  #--------------------------------------------------------------------------
  # ○ Present Day of the Week is aquired.
  #--------------------------------------------------------------------------
  def get_daynight_week_name
    return KGC::DayNight::WEEK_NAME[get_daynight_week]
  end
  #--------------------------------------------------------------------------
  # ○ Phase Shift
  #     phase     : Phase
  #     duration  : Shift Time(In Frames)
  #     pass_days : Passing Days  (When argument is omitted: 0)
  #--------------------------------------------------------------------------
  def change_daynight_phase(phase,
      duration = KGC::DayNight::PHASE_DURATION,
      pass_days = 0)
    $game_temp.manual_daynight_duration = duration
    $game_system.daynight_counter = 0
    $game_system.daynight_phase = phase
    $game_variables[KGC::DayNight::PASS_DAYS_VARIABLE] += pass_days
    $game_map.need_refresh = true
  end
  #--------------------------------------------------------------------------
  # ○ Transit Daynight Phase
  #     duration : Shift Time(In Frames)
  #--------------------------------------------------------------------------
  def transit_daynight_phase(duration = KGC::DayNight::PHASE_DURATION)
    $game_screen.transit_daynight_phase(duration)
    $game_map.need_refresh = true
  end
  #--------------------------------------------------------------------------
  # ○ デフォルトの色調に戻す
  #     duration : 切り替え時間(フレーム)
  #--------------------------------------------------------------------------
  def set_daynight_default(duration = KGC::DayNight::PHASE_DURATION)
    $game_screen.set_daynight_default(duration)
    $game_map.need_refresh = true
  end
  #--------------------------------------------------------------------------
  # ○ 現在のフェーズを復元
  #     duration : 切り替え時間(フレーム)
  #--------------------------------------------------------------------------
  def restore_daynight_phase(duration = KGC::DayNight::PHASE_DURATION)
    $game_screen.restore_daynight_phase(duration)
    $game_map.need_refresh = true
  end
end
class Game_Interpreter
  include KGC::Commands
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ RPG::MapInfo
#==============================================================================
class RPG::MapInfo
  #--------------------------------------------------------------------------
  # ● マップ名取得
  #--------------------------------------------------------------------------
  def name
    return @name.gsub(/\[.*\]/) { "" }
  end
  #--------------------------------------------------------------------------
  # ○ オリジナルマップ名取得
  #--------------------------------------------------------------------------
  def original_name
    return @name
  end
  #--------------------------------------------------------------------------
  # ○ 昼夜切り替え停止
  #--------------------------------------------------------------------------
  def daynight_stop
    return @name =~ KGC::DayNight::Regexp::MapInfo::DAYNIGHT_STOP
  end
  #--------------------------------------------------------------------------
  # ○ 昼夜エフェクト無効
  #--------------------------------------------------------------------------
  def daynight_void
    return @name =~ KGC::DayNight::Regexp::MapInfo::DAYNIGHT_VOID
  end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ RPG::Area
#==============================================================================
unless $@
class RPG::Area
  #--------------------------------------------------------------------------
  # ○ エンカウントリストの取得
  #--------------------------------------------------------------------------
  alias encounter_list_KGC_DayNight encounter_list
  def encounter_list
    list = encounter_list_KGC_DayNight.clone
    # 出現条件判定
    list.each_index { |i|
      list[i] = nil unless KGC::DayNight.troop_appear?($data_troops[list[i]])
    }
    return list.compact
  end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ RPG::Troop
#==============================================================================
class RPG::Troop
  #--------------------------------------------------------------------------
  # ○ Generate DayNight Cache
  #--------------------------------------------------------------------------
  def create_daynight_cache
    @__appear_daynight_phase = []
    @__nonappear_daynight_phase = []
    # 出現するフェーズ
    if @name =~ KGC::DayNight::Regexp::Troop::APPEAR_PHASE
      $1.scan(/[\-]?\d+/).each { |num|
        phase = num.to_i
        if phase < 0
          # 出現しない
          @__nonappear_daynight_phase << phase.abs
        else
          # 出現する
          @__appear_daynight_phase <<phase>= KGC::DayNight::PHASE.size
      self.daynight_phase = 0
    end
    $game_map.need_refresh = true
  end
  #--------------------------------------------------------------------------
  # ○ 現在のフェーズオブジェクトを取得
  #--------------------------------------------------------------------------
  def daynight_phase_object
    return KGC::DayNight::PHASE[daynight_phase]
  end
  #--------------------------------------------------------------------------
  # ○ 以前のフェーズオブジェクトを取得
  #--------------------------------------------------------------------------
  def previous_daynight_phase_object
    return KGC::DayNight::PHASE[daynight_phase - 1]
  end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_Screen
#==============================================================================
class Game_Screen
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader   :daynight_tone            # 昼夜の色調
  #--------------------------------------------------------------------------
  # ● クリア
  #--------------------------------------------------------------------------
  alias clear_KGC_DayNight clear
  def clear
    clear_KGC_DayNight
    clear_daynight
  end
  #--------------------------------------------------------------------------
  # ○ 昼夜切り替え用変数をクリア
  #--------------------------------------------------------------------------
  def clear_daynight
    @default_tone = Tone.new(0, 0, 0)
    # 移動判定用座標初期化
    @daynight_x = 0
    @daynight_y = 0
    # フレーム更新用カウント初期化
    @frame_count = Graphics.frame_count
    @daynight_tone_duration = 0
    apply_daynight
  end
  #--------------------------------------------------------------------------
  # ○ 昼夜の色調を適用
  #--------------------------------------------------------------------------
  def apply_daynight
    return if $game_map == nil
    # 切り替えを無効化するマップの場合
    if $game_map.daynight_void?
      if @daynight_tone_changed
        # 初期の色調に戻す
        @tone = @default_tone.clone
        @daynight_tone_changed = false
      end
      @daynight_tone = @tone.clone
      return
    end
    # フェーズがおかしければ修復
    if $game_system.daynight_phase_object == nil
      $game_system.daynight_phase = 0
    end
    # 現在の色調を適用
    @tone = $game_system.daynight_phase_object[1].clone
    @daynight_tone = @tone.clone
    # 現実時間遷移の場合
    if KGC::DayNight::METHOD == KGC::DayNight::METHOD_RTIME
      time = Time.now
      # マッチするフェーズに遷移
      KGC::DayNight::PHASE.each_with_index { |phase, i|
        if phase[2] <time>= 1
      d = @daynight_tone_duration
      target = @daynight_tone_target
      @daynight_tone.red = (@daynight_tone.red * (d - 1) + target.red) / d
      @daynight_tone.green = (@daynight_tone.green * (d - 1) + target.green) / d
      @daynight_tone.blue = (@daynight_tone.blue * (d - 1) + target.blue) / d
      @daynight_tone.gray = (@daynight_tone.gray * (d - 1) + target.gray) / d
      @daynight_tone_duration -= 1
    end
  end
  #--------------------------------------------------------------------------
  # ○ フェーズ遷移の更新
  #--------------------------------------------------------------------------
  def update_daynight_transit
    # 手動切り替えが行われた場合
    if $game_temp.manual_daynight_duration
      start_tone_change($game_system.daynight_phase_object[1],
        $game_temp.manual_daynight_duration)
      $game_temp.manual_daynight_duration = nil
      @daynight_tone_changed = true
    end
    return unless $game_system.daynight_change_enabled  # 切り替えを
    return if $game_map.daynight_stop?                  # 停止中
    if KGC::DayNight::STOP_ON_EVENT
      interpreter = ($game_temp.in_battle ? $game_troop.interpreter :
        $game_map.interpreter)
      return if interpreter.running?                    # イベント実行中
    end
    case KGC::DayNight::METHOD
    when KGC::DayNight::METHOD_TIME   # 時間
      update_daynight_pass_time
    when KGC::DayNight::METHOD_STEP   # 歩数
      update_daynight_step
    when KGC::DayNight::METHOD_RTIME  # 現実時間
      update_daynight_real_time
    end
  end
  #--------------------------------------------------------------------------
  # ○ 遷移 : 時間経過
  #--------------------------------------------------------------------------
  def update_daynight_pass_time
    # カウント増加量計算
    inc_count = Graphics.frame_count - @frame_count
    # 加算量がおかしい場合は戻る
    if inc_count >= 100
      @frame_count = Graphics.frame_count
      return
    end
    # カウント加算
    $game_system.daynight_counter += inc_count
    @frame_count = Graphics.frame_count
    # 状態遷移判定
    count = $game_system.daynight_counter / Graphics.frame_rate
    if count >= $game_system.daynight_phase_object[2]
      transit_daynight_next
    end
  end
  #--------------------------------------------------------------------------
  # ○ 遷移 : 歩数
  #--------------------------------------------------------------------------
  def update_daynight_step
    # 移動していなければ戻る
    return if @daynight_x == $game_player.x && @daynight_y == $game_player.y
    @daynight_x = $game_player.x
    @daynight_y = $game_player.y
    # カウント加算
    $game_system.daynight_counter += 1
    # 状態遷移判定
    count = $game_system.daynight_counter
    if count >= $game_system.daynight_phase_object[2]
      transit_daynight_next
    end
  end
  #--------------------------------------------------------------------------
  # ○ 遷移 : 現実時間
  #--------------------------------------------------------------------------
  def update_daynight_real_time
    time = Time.now
    # 状態遷移判定
    time1 = $game_system.daynight_phase_object[2]
    transit = (time1 <= time.hour)
    if $game_system.previous_daynight_phase_object != nil
      time2 = $game_system.previous_daynight_phase_object[2]
      if time1 < time2
        transit &= (time.hour < time2)
      end
    end
    if transit
      transit_daynight_next
    end
  end
  #--------------------------------------------------------------------------
  # ○ 次の状態へ遷移
  #     duration : 遷移時間
  #--------------------------------------------------------------------------
  def transit_daynight_next(duration = KGC::DayNight::PHASE_DURATION)
    $game_system.daynight_counter = 0
    $game_system.progress_daynight_phase
    # 日数経過判定
    if $game_system.daynight_phase == KGC::DayNight::PASS_DAY_PHASE
      $game_variables[KGC::DayNight::PASS_DAYS_VARIABLE] += 1
    end
    # 色調切り替え
    start_tone_change($game_system.daynight_phase_object[1], duration)
    @daynight_tone_changed = true
  end
  #--------------------------------------------------------------------------
  # ○ デフォルトの状態(0, 0, 0)に戻す
  #     duration : 遷移時間
  #--------------------------------------------------------------------------
  def set_daynight_default(duration)
    start_tone_change(@default_tone, duration)
  end
  #--------------------------------------------------------------------------
  # ○ 現在のフェーズを復元
  #     duration : 遷移時間
  #--------------------------------------------------------------------------
  def restore_daynight_phase(duration)
    start_tone_change($game_system.daynight_phase_object[1], duration)
    @daynight_tone_changed = true
  end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_Map
#==============================================================================
class Game_Map
  #--------------------------------------------------------------------------
  # ● セットアップ
  #     map_id : マップ ID
  #--------------------------------------------------------------------------
  alias setup_KGC_DayNight setup
  def setup(map_id)
    setup_KGC_DayNight(map_id)
    @screen.apply_daynight
  end
  #--------------------------------------------------------------------------
  # ○ 昼夜切り替えを停止するか
  #--------------------------------------------------------------------------
  def daynight_stop?
    info = $data_mapinfos[map_id]
    return false if info == nil
    return (info.daynight_stop || info.daynight_void)
  end
  #--------------------------------------------------------------------------
  # ○ 昼夜切り替えが無効か
  #--------------------------------------------------------------------------
  def daynight_void?
    info = $data_mapinfos[map_id]
    return false if info == nil
    return info.daynight_void
  end
  #--------------------------------------------------------------------------
  # ● エンカウントリストの取得
  #--------------------------------------------------------------------------
  alias encounter_list_KGC_DayNight encounter_list
  def encounter_list
    list = encounter_list_KGC_DayNight.clone
    # 出現条件判定
    list.each_index { |i|
      list[i] = nil unless KGC::DayNight.troop_appear?($data_troops[list[i]])
    }
    return list.compact
  end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Spriteset_Battle
#==============================================================================
if KGC::DayNight::TONE_BACK_ONLY_IN_BATTLE
class Spriteset_Battle
  #--------------------------------------------------------------------------
  # ● バトルバックスプライトの作成
  #--------------------------------------------------------------------------
  alias create_battleback_KGC_DayNight create_battleback
  def create_battleback
    create_battleback_KGC_DayNight
    if @battleback_sprite.wave_amp == 0
      @battleback_sprite.tone = $game_troop.screen.daynight_tone
    end
  end
  #--------------------------------------------------------------------------
  # ● バトルフロアスプライトの作成
  #--------------------------------------------------------------------------
  alias create_battlefloor_KGC_DayNight create_battlefloor
  def create_battlefloor
    create_battlefloor_KGC_DayNight
    @battlefloor_sprite.tone = $game_troop.screen.daynight_tone
  end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # ● 開始処理
  #--------------------------------------------------------------------------
  alias start_KGC_DayNight start
  def start
    $game_map.screen.clear_daynight
    start_KGC_DayNight
  end
end
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
#_/  The original untranslated version of this script can be found here:
# 
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
------------------------------------------------------------------------------------
Tyto dva dejte hned pod sebe do materials      Autorem je Kylock
#======================================================================
# ■ [RMVX] +Random Title Screen+
#------------------------------------------------------------------------------
# Version 1.0
# by Woratana [woratana@hotmail.com]
# Release Date: 07/02/2008
#
# This scrip will random title screen
#
# You can set title screen pictures to be random at line:
# Title = ["filename","filename2","filename3",...]
# title screen picture must be in folder "System"
#
# For example, Title = ["Screenfire","Title1"]
# >> Title Screen will random between pictures "Screenfire" and "Title1".
#=============================================================================
class Scene_Title < Scene_Base
  Title = Array.new
  
  # Set Title Screen Pictures for random here!
  Title = ["earth","fire","galaxy","wave","ice","sky"]
  
  def create_title_graphic
    @sprite = Sprite.new
    title_random = rand(Title.size)
    @sprite.bitmap = Cache.system(Title[title_random].to_s)
  end
end
Dejte to do materials.Obrázky nahrajte do system v adresáři hry.Místo earth,fire........dejte názvy těch souborů.Autorem je Woratana
A z jejího vychází moje upravená verze pro game over
class Scene_Gameover < Scene_Base
  GameOver = Array.new
  
  # Set GameOver Screen Pictures for random here!
  GameOver = ["zombie","zice"]
  
  def create_gameover_graphic
    @sprite = Sprite.new
    gameover_random = rand(GameOver.size)
    @sprite.bitmap = Cache.system(GameOver[gameover_random].to_s)
  end
end
Edit by legition: Lidi sakra používejte code!!
				






