#==============================================================================
#==============================================================================
#Light Circle Script updated(19-7-2009)
#==============================================================================
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc.
# It's used within the Scene_Map class.
#==============================================================================
class Scene_Save < Scene_File
alias t_write_save_data write_save_data
def write_save_data(file)
t_write_save_data(file)
Marshal.dump($sensitivity,file)
Marshal.dump($sensitivity_2,file)
Marshal.dump($light_switch,file)
Marshal.dump($flick,file)
end
end
#==============================================================================
class Scene_Load < Scene_File
alias t_read_save_data read_save_data
def read_save_data(file)
t_read_save_data(file)
$sensitivity = Marshal.load(file)
$sensitivity_2 = Marshal.load(file)
$light_switch = Marshal.load(file)
$flick = Marshal.load(file)
end
end
#==============================================================================
class Game_Player< Game_Character
def change_sensitivity(value,type)
case type
when "sensitivity"
$sensitivity=value
when "sensitivity_2"
$sensitivity_2[0]=value
end
end
end
#==============================================================================
class Scene_Title
#------------------------------------------------------------------------#change initial sensitivity
alias t_main main
def main
$light_switch=1
$sensitivity=1
$sensitivity_2=[]
$sensitivity_2[0]=1
$flick=0
t_main
end
end
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
#-------------------------------------------------------------------change initial setting
@tone=75
@limit=0.2
@light_limit=7
@x_limit=640
@y_limit=480
#---------------------------------------------------------------------------
@random=[]
@r_value=[]
@black=[]
@x_x=[]
@y_y=[]
@xx=[]
@yy=[]
black_once
i=0
loop do
@black[i]=-@tone
break if i=10
i+=1
end
@viewport1 = Viewport.new(0, 0, 640, 480)
@viewport2 = Viewport.new(0, 0, 640, 480)
@viewport3 = Viewport.new(0, 0, 640, 480)
@viewport4=[]
@viewport5=[]
@viewport8=[]
#------------------------------------
@y=0
loop do
@x=0
loop do
@viewport4[@y*21+@x] = Viewport.new(@x*32-16, @y*32-16, 32, 32)
@viewport4[@y*21+@x].tone = Tone.new(-255, -255, -255, 0)
@viewport4[@y*21+@x].z = 199
@viewport5[@y*21+@x] = Viewport.new(@x*32-27, @y*32-27, 32, 32)
@viewport5[@y*21+@x].tone = Tone.new(-255, -255, -255, 0)
@viewport5[@y*21+@x].z = 199
@viewport8[@y*21+@x] = Viewport.new(@x*32-5, @y*32-5, 32, 32)
@viewport8[@y*21+@x].tone = Tone.new(-255, -255, -255, 0)
@viewport8[@y*21+@x].z = 199
break if @x==20
@x+=1
end
break if @y==15
@y+=1
end
#------------------------------------
@viewport2.z = 200
@viewport3.z = 5000
# Make tilemap
@tilemap = Tilemap.new(@viewport1)
@tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
for i in 0..6
autotile_name = $game_map.autotile_names[i]
@tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
end
@tilemap.map_data = $game_map.data
@tilemap.priorities = $game_map.priorities
# Make panorama plane
@panorama = Plane.new(@viewport1)
@panorama.z = -1000
# Make fog plane
@fog = Plane.new(@viewport1)
@fog.z = 3000
# Make character sprites
@character_sprites = []
for i in $game_map.events.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
@character_sprites.push(sprite)
end
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
# Make weather
@weather = RPG::Weather.new(@viewport1)
# Make picture sprites
@picture_sprites = []
for i in 1..100
@picture_sprites.push(Sprite_Picture.new(@viewport2,
$game_screen.pictures[i]))
end
# Make timer sprite
@timer_sprite = Sprite_Timer.new
# Frame update
update
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
# Dispose of tilemap
@tilemap.tileset.dispose
for i in 0..6
@tilemap.autotiles[i].dispose
end
@tilemap.dispose
# Dispose of panorama plane
@panorama.dispose
# Dispose of fog plane
@fog.dispose
# Dispose of character sprites
for sprite in @character_sprites
sprite.dispose
end
# Dispose of weather
@weather.dispose
# Dispose of picture sprites
for sprite in @picture_sprites
sprite.dispose
end
# Dispose of timer sprite
@timer_sprite.dispose
# Dispose of viewports
@viewport1.dispose
@viewport2.dispose
@viewport3.dispose
@y=0
loop do
@x=0
loop do
@viewport4[@y*21+@x].dispose
@viewport5[@y*21+@x].dispose
@viewport8[@y*21+@x].dispose
break if @x==20
@x+=1
end
break if @y==15
@y+=1
end
end
#--------------------------------------------------------------------------
# * call character sprite
#--------------------------------------------------------------------------
def character_sprites(id)
return @character_sprites[id]
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def black_once
for event in $game_map.events.values
if event.list && event.list[0].code == 108
i=1
loop do
if event.list[0].parameters.to_s == i.to_s
@xx[i]=event.x*32
@yy[i]=event.y*32
$sensitivity_2[i]=event.list[1].parameters.to_s .to_i
@r_value[i]=event.list[2].parameters.to_s .to_i
end
break if i== @light_limit
i+=1
end
end
end
end
#-------------------------------------------------------------------------
def find_black
@x_x[0] = (@x)*32-($game_player.x*32-$game_map.display_x/4)-16
@y_y[0] = (@y)*32-($game_player.y*32-$game_map.display_y/4) -16
x2=(@x_x[0])*(@x_x[0])
y2=(@y_y[0])*(@y_y[0])
@black[0] =(($sensitivity+$sensitivity_2[0]+@random[0])*60)/((x2+y2)*0.0005+5)#($sensitivity+$sensitivity_2[0])/(Math.sqrt(x2+y2))
i=1
loop do
if @xx[i]==nil
break
end
@x_x[i]=@x*32-(@xx[i]-$game_map.display_x/4)-16
@y_y[i]=@y*32-(@yy[i]-$game_map.display_y/4)-16
if !((@xx[i] - $game_player.x*32) > @x_limit || (@xx[i] - $game_player.x*32) <-@x_limit || (@yy[i] - $game_player.y*32) > @y_limit || (@yy[i] - $game_player.y*32) <-@y_limit )
@black[i] =(($sensitivity+$sensitivity_2[i]+@random[i])*60)/((@x_x[i]*@x_x[i]+@y_y[i]*@y_y[i])*0.0005+5)#($sensitivity+$sensitivity_2[i])/(Math.sqrt(@x_x[i]*@x_x[i]+@y_y[i]*@y_y[i]))
@black[0]+=@black[i]
end
break if i==@light_limit
i+=1
end
@black[0]=@black[0]-@tone
end
#------------------------------------------------------------------------------
def update
# If panorama is different from current one
if @panorama_name != $game_map.panorama_name or
@panorama_hue != $game_map.panorama_hue
@panorama_name = $game_map.panorama_name
@panorama_hue = $game_map.panorama_hue
if @panorama.bitmap != nil
@panorama.bitmap.dispose
@panorama.bitmap = nil
end
if @panorama_name != ""
@panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
end
Graphics.frame_reset
end
# If fog is different than current fog
if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
@fog_name = $game_map.fog_name
@fog_hue = $game_map.fog_hue
if @fog.bitmap != nil
@fog.bitmap.dispose
@fog.bitmap = nil
end
if @fog_name != ""
@fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
end
Graphics.frame_reset
end
# Update tilemap
@tilemap.ox = $game_map.display_x / 4
@tilemap.oy = $game_map.display_y / 4
@tilemap.update
# Update panorama plane
@panorama.ox = $game_map.display_x / 8
@panorama.oy = $game_map.display_y / 8
# Update fog plane
@fog.zoom_x = $game_map.fog_zoom / 100.0
@fog.zoom_y = $game_map.fog_zoom / 100.0
@fog.opacity = $game_map.fog_opacity
@fog.blend_type = $game_map.fog_blend_type
@fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
@fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
@fog.tone = $game_map.fog_tone
# Update character sprites
for sprite in @character_sprites
sprite.update
end
# Update weather graphic
@weather.type = $game_screen.weather_type
@weather.max = $game_screen.weather_max
@weather.ox = $game_map.display_x / 4
@weather.oy = $game_map.display_y / 4
@weather.update
# Update picture sprites
for sprite in @picture_sprites
sprite.update
end
# Update timer sprite
@timer_sprite.update
# Set screen color tone and shake position
@viewport1.tone = $game_screen.tone
@viewport1.ox = $game_screen.shake
# Set screen flash color
@viewport3.color = $game_screen.flash_color
# Update viewports
@viewport1.update
@viewport3.update
if Graphics.frame_count % (6) == 0
if $light_switch==1
@random[0]=rand($flick+1)
i=1
loop do
@r_value[i]=0 if @r_value[i]==nil
@random[i]=rand(@r_value[i]+1)
break if i==@light_limit
i+=1
end
@y=0
loop do
@x=0
loop do
find_black
@black[0]=0 if @black[0]>0
@black[0]=-@tone if @black[0]<-@tone
@viewport4[@y*21+@x].tone =Tone.new(@black[0], @black[0], @black[0], 0)
@viewport5[@y*21+@x].tone=@viewport4[[@y-1,0].max*21+[@x-1,0].max].tone
@viewport8[@y*21+@x].tone=@viewport4[[@y+1,15].min*21+[@x+1,20].min].tone
break if @x==20
@x+=1
end
break if @y==15
@y+=1
end
@on=nil
else
if @on==nil
@y=0
loop do
@x=0
loop do
@viewport4[@y*21+@x].tone =Tone.new(0,0,0, 0)
@viewport5[@y*21+@x].tone=Tone.new(0,0,0, 0)
@viewport8[@y*21+@x].tone=Tone.new(0,0,0, 0)
break if @x==20
@x+=1
end
break if @y==15
@y+=1
end
@on=true
end
end
end
#---------------------------------------------------------------------
#
end
end