Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Light Circles Script v1.2

Light Circles Script v1.2c


Introduction
This script is for RMXP.
It creates light circles for hero and events.

Features

  • create circles just with script
  • have flickering effect now
  • different light radius for each event
  • support moving events



Code:
 

#=begin

#==============================================================================

#==============================================================================

#==============================================================================

#Light Circle Script v1.2C updated(09-07-2011)

#==============================================================================

#==============================================================================

#==============================================================================

class Scene_Save < Scene_File

     

  alias alias_write_save_data write_save_data

     

  def write_save_data(file)

    alias_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_Map

  def spriteset

    return @spriteset

  end

end

#==============================================================================

#==============================================================================

#==============================================================================

class Scene_Title

  

  alias alias_main main

#--------------------------------------------------------------------------

# * change initial sensitivity here

#--------------------------------------------------------------------------   

  def main

    $light_switch=1

    $sensitivity_2=[]

    $sensitivity_2[0]=100

    $light_level=[]

    for i in 0..255

      $light_level[i]=Tone.new(-i,-i,-i)

      end

    $flick=0

    alias_main

  end

#--------------------------------------------------------------------------

# * change initial sensitivity here

#--------------------------------------------------------------------------  

end

#==============================================================================

#==============================================================================

#==============================================================================

# ** Spriteset_Map

#------------------------------------------------------------------------------

#   This class brings together map screen sprites, tilemaps, etc.

#   It's used within the Scene_Map class.

#==============================================================================

#==============================================================================

#==============================================================================

class Spriteset_Map

  attr_accessor :tone

  attr_accessor :light_limit

  attr_accessor :x_limit

  attr_accessor :y_limit

   

  alias alias_update update

  alias alias_initialize initialize

  alias alias_dispose dispose

#--------------------------------------------------------------------------

# * Object Initialization

#--------------------------------------------------------------------------

  def initialize

#--------------------------------------------------------------------------

# * change initial setting

#--------------------------------------------------------------------------      

    @tone=40

    @light_limit=15

    @x_limit=10

    @y_limit=7

#--------------------------------------------------------------------------

# * change initial setting

#-------------------------------------------------------------------------- 

    @opacity=[]

    @random=[]

    @r_value=[]

    @x_x=[]

    @y_y=[]

    @xx=[]

    @yy=[]

    @event_rx=[]

    @event_ry=[]

    @event_coor_x=[]

    @event_coor_y=[]

    @sensitivity=[]

    @viewport=[]

    @viewport[0]=[]

    @viewport[1]=[]

    @viewport[2]=[]

    @viewport[3]=[]

    @viewport[4]=[]

    @d=6

    @frame=3

    @event_frame_x_highlimit=[]

    @event_frame_y_highlimit=[]

    @event_frame_x_lowlimit=[]

    @event_frame_y_lowlimit=[]

    @count_rate=0

    @compare1=(Time.now).sec

    @ccc=0

    @ccc2=0

    #@player_coor_x = 0

    #@player_coor_y = 0

    #@player_coor_x = @player_coor_x.to_f

    #@player_coor_y = @player_coor_y.to_f

    get_event_data

#------------------------------------

@opacity[99]=[]

    for @y in 0..15

            @opacity[@y]=[]

            @opacity[@y][99]=0

      @viewport[0][@y]=[]

      @viewport[1][@y]=[]

      @viewport[2][@y]=[]

      @viewport[3][@y]=[]

      @viewport[4][@y]=[]

      for @x in 0..20

        @opacity[99][@x]=0

        @viewport[0][@y][@x] = Viewport.new(@x*32-16, @y*32-16, 32, 32)

        @viewport[0][@y][@x].tone = Tone.new(-255, -255, -255, 0)

        @viewport[0][@y][@x].z = 199

        @viewport[1][@y][@x] = Viewport.new(@x*32-16+@d, @y*32-16+@d, 32, 32)

        @viewport[1][@y][@x].tone = Tone.new(-255, -255, -255, 0)

        @viewport[1][@y][@x].z = 199

        @viewport[2][@y][@x] = Viewport.new(@x*32-16+@d*2, @y*32-16+@d*2, 32, 32)

        @viewport[2][@y][@x].tone = Tone.new(-255, -255, -255, 0)

        @viewport[2][@y][@x].z = 199

        @viewport[3][@y][@x] = Viewport.new(@x*32-16-@d, @y*32-16-@d, 32, 32)

        @viewport[3][@y][@x].tone = Tone.new(-255, -255, -255, 0)

        @viewport[3][@y][@x].z = 199

        @viewport[4][@y][@x] = Viewport.new(@x*32-16-@d*2, @y*32-16-@d*2, 32, 32)

        @viewport[4][@y][@x].tone = Tone.new(-255, -255, -255, 0)

        @viewport[4][@y][@x].z = 199

        @opacity[@y][@x]=-@tone

      end

    end

        @opacity[99][99]=0

    

    alias_initialize

 

  end

#--------------------------------------------------------------------------

# * Object Initialization

#--------------------------------------------------------------------------  

#--------------------------------------------------------------------------

# * Dispose

#--------------------------------------------------------------------------

  def dispose

    alias_dispose

    for @y in 0..15

      for @x in 0..20

        for i in 0..4

          @viewport[i][@y][@x].dispose

        end

      end

    end

 

  end

#--------------------------------------------------------------------------

# * Dispose

#--------------------------------------------------------------------------

#--------------------------------------------------------------------------

# * Light Map

#--------------------------------------------------------------------------

def light_map(light_value,event_id, x , y)

  

 

  if x==nil or y==nil

    return

  end

 

  

 

#=begin  

  xn1= x-1 <0 ? 99 : x-1

  xn2= x-2 <0 ? 99 : x-2

  xn3= x-3 <0 ? 99 : x-3

  xn4= x-4 <0 ? 99 : x-4

  xn5= x-5 <0 ? 99 : x-5

  xn6= x-6 <0 ? 99 : x-6

  xn7= x-7 <0 ? 99 : x-7

  xn8= x-8 <0 ? 99 : x-8

  xn9= x-9 <0 ? 99 : x-9

  xn10= x-10 <0 ? 99 : x-10

  

  xp1= x+1 >20 ? 99 : x+1

  xp2= x+2 >20 ? 99 : x+2

  xp3= x+3 >20 ? 99 : x+3

  xp4= x+4 >20 ? 99 : x+4

  xp5= x+5 >20 ? 99 : x+5

  xp6= x+6 >20 ? 99 : x+6

  xp7= x+7 >20 ? 99 : x+7

  xp8= x+8 >20 ? 99 : x+8

  xp9= x+9 >20 ? 99 : x+9

  xp10= x+10 >20 ? 99 : x+10

  

  yn1= y-1 <0 ? 99 : y-1

  yn2= y-2 <0 ? 99 : y-2

  yn3= y-3 <0 ? 99 : y-3

  yn4= y-4 <0 ? 99 : y-4

  yn5= y-5 <0 ? 99 : y-5

  yn6= y-6 <0 ? 99 : y-6

  yn7= y-7 <0 ? 99 : y-7

  yn8= y-8 <0 ? 99 : y-8

  yn9= y-9 <0 ? 99 : y-9

  yn10= y-10 <0 ? 99 : y-10

  

  yp1= y+1 >15 ? 99 : y+1

  yp2= y+2 >15 ? 99 : y+2

  yp3= y+3 >15 ? 99 : y+3

  yp4= y+4 >15 ? 99 : y+4

  yp5= y+5 >15 ? 99 : y+5

  yp6= y+6 >15 ? 99 : y+6

  yp7= y+7 >15 ? 99 : y+7

  yp8= y+8 >15 ? 99 : y+8

  yp9= y+9 >15 ? 99 : y+9

  yp10= y+10 >15 ? 99 : y+10

  

  sen_e_d=@sensitivity[event_id]

  s0=sen_e_d/(5)

  s0a=sen_e_d/(6)

s1=sen_e_d/(7)

s1a=sen_e_d/(9)

    s2=sen_e_d/(10)

    s3=sen_e_d/(13)

    s3a=sen_e_d/(14)

    s4=sen_e_d/(15) 

    s5=sen_e_d/(18) 

    s5a=sen_e_d/(21) 

    s6=sen_e_d/(22)

    s6a=sen_e_d/(23)

    s7=sen_e_d/(25)

    

    

    

    

#=begin    

  if light_value>0 && x>=0 && y>=0 && x<=20 && y<=15

    

    

    @opacity[yp4][xn1] +=s6

    @opacity[yp4][xn2] +=s7

    @opacity[yp3][xn1] +=s4

    @opacity[yp3][xn2] +=s5

    @opacity[yp3][xn3] +=s6a

    @opacity[yp2][xn1] +=s2

    @opacity[yp2][xn2] +=s3

    @opacity[yp2][xn3] +=s5

    @opacity[yp2][xn4] +=s7

    @opacity[yp1][xn1] +=s1

    @opacity[yp1][xn2] +=s2

    @opacity[yp1][xn3] +=s4

    @opacity[yp1][xn4] +=s6

    

    @opacity[yn4][xn1] +=s6 

    @opacity[yn4][xn2] +=s7 

    @opacity[yn3][xn1] +=s4 

    @opacity[yn3][xn2] +=s5 

    @opacity[yn3][xn3] +=s6a 

    @opacity[yn2][xn1] +=s2 

    @opacity[yn2][xn2] +=s3

    @opacity[yn2][xn3] +=s5

    @opacity[yn2][xn4] +=s7 

    @opacity[yn1][xn1] +=s1 

    @opacity[yn1][xn2] +=s2 

    @opacity[yn1][xn3] +=s4

    @opacity[yn1][xn4] +=s6 

    

    @opacity[yn4][xp1] +=s6 

    @opacity[yn4][xp2] +=s7 

    @opacity[yn3][xp1] +=s4 

    @opacity[yn3][xp2] +=s5 

    @opacity[yn3][xp3] +=s6a 

    @opacity[yn2][xp1] +=s2 

    @opacity[yn2][xp2] +=s3 

    @opacity[yn2][xp3] +=s5

    @opacity[yn2][xp4] +=s7 

    @opacity[yn1][xp1] +=s1 

    @opacity[yn1][xp2] +=s2 

    @opacity[yn1][xp3] +=s4

    @opacity[yn1][xp4] +=s6 

    

    @opacity[yp4][xp1] +=s6 

    @opacity[yp4][xp2] +=s7 

    @opacity[yp3][xp1] +=s4 

    @opacity[yp3][xp2] +=s5 

    @opacity[yp3][xp3] +=s6a 

    @opacity[yp2][xp1] +=s2 

    @opacity[yp2][xp2] +=s3 

    @opacity[yp2][xp3] +=s5

    @opacity[yp2][xp4] +=s7 

    @opacity[yp1][xp1] +=s1 

    @opacity[yp1][xp2] +=s2 

    @opacity[yp1][xp3] +=s4

    @opacity[yp1][xp4] +=s6 

    

    

      @opacity[y][x] +=s0 

    

    @opacity[yp4][x] +=s5a 

    @opacity[yp3][x] +=s3a 

    @opacity[yp2][x] +=s1a 

    @opacity[yp1][x] +=s0a 

    @opacity[yn4][x] +=s5a 

    @opacity[yn3][x] +=s3a 

    @opacity[yn2][x] +=s1a 

    @opacity[yn1][x] +=s0a 

    

    @opacity[y][xp4] +=s5a 

    @opacity[y][xp3] +=s3a 

    @opacity[y][xp2] +=s1a 

    @opacity[y][xp1] +=s0a 

    @opacity[y][xn4] +=s5a 

    @opacity[y][xn3] +=s3a 

    @opacity[y][xn2] +=s1a 

    @opacity[y][xn1] +=s0a 

    end

#=end  

  

    if light_value>60  && x>=0 && y>=0 && x<=20 && y<=15 

      s8=sen_e_d/(30)

    s9=sen_e_d/(31)

    s10=sen_e_d/(34)

    s11=sen_e_d/(37)

    s12=sen_e_d/(39)

    s13=sen_e_d/(41)

    s14=sen_e_d/(42) 

    s15=sen_e_d/(45)

    s16=sen_e_d/(46) 

    s17=sen_e_d/(50)

      @opacity[yp6][xn2] +=s15 

      @opacity[yp6][xn1] +=s14 

      @opacity[yp6][x] +=s13 

      @opacity[yp6][xp2] +=s15 

      @opacity[yp6][xp1] +=s14 

      

      @opacity[yn6][xn2] +=s15 

      @opacity[yn6][xn1] +=s14 

      @opacity[yn6][x] +=s13 

      @opacity[yn6][xp2] +=s15 

      @opacity[yn6][xp1] +=s14 

      

      @opacity[yp5][xn4] +=s16 

      @opacity[yp5][xn3] +=s12 

      @opacity[yp5][xn2] +=s10 

      @opacity[yp5][xn1] +=s9 

      @opacity[yp5][x] +=s8 

      @opacity[yp5][xp4] +=s16 

      @opacity[yp5][xp3] +=s12 

      @opacity[yp5][xp2] +=s10 

      @opacity[yp5][xp1] +=s9 

      

      @opacity[yn5][xn4] +=s16 

      @opacity[yn5][xn3] +=s12 

      @opacity[yn5][xn2] +=s10 

      @opacity[yn5][xn1] +=s9 

      @opacity[yn5][x] +=s8 

      @opacity[yn5][xp4] +=s16 

      @opacity[yn5][xp3] +=s12 

      @opacity[yn5][xp2] +=s10 

      @opacity[yn5][xp1] +=s9 

      

      

      @opacity[yp3][xn6] +=s17 

      @opacity[yp2][xn6] +=s15 

      @opacity[yp1][xn6] +=s14 

      @opacity[y][xn6] +=s13 

      @opacity[yn3][xn6] +=s17 

      @opacity[yn2][xn6] +=s15 

      @opacity[yn1][xn6] +=s14

      

      @opacity[yp3][xp6] +=s17 

      @opacity[yp2][xp6] +=s15 

      @opacity[yp1][xp6] +=s14 

      @opacity[y][xp6] +=s13 

      @opacity[yn3][xp6] +=s17 

      @opacity[yn2][xp6] +=s15 

      @opacity[yn1][xp6] +=s14

      

      @opacity[yp4][xn5] +=s16 

      @opacity[yp3][xn5] +=s12 

      @opacity[yp2][xn5] +=s10 

      @opacity[yp1][xn5] +=s9 

      @opacity[y][xn5] +=s8 

      @opacity[yn4][xn5] +=s16 

      @opacity[yn3][xn5] +=s12 

      @opacity[yn2][xn5] +=s10 

      @opacity[yn1][xn5] +=s9 

      

       @opacity[yp4][xp5] +=s16 

      @opacity[yp3][xp5] +=s12 

      @opacity[yp2][xp5] +=s10 

      @opacity[yp1][xp5] +=s9 

      @opacity[y][xp5] +=s8 

      @opacity[yn4][xp5] +=s16 

      @opacity[yn3][xp5] +=s12 

      @opacity[yn2][xp5] +=s10 

      @opacity[yn1][xp5] +=s9 

      

      @opacity[yp4][xn4] +=s11

      @opacity[yp4][xn3] +=s8

      @opacity[yp3][xn4] +=s8

      

      @opacity[yp4][xp4] +=s11

      @opacity[yp4][xp3] +=s8

      @opacity[yp3][xp4] +=s8

      

      @opacity[yn4][xn4] +=s11

      @opacity[yn4][xn3] +=s8

      @opacity[yn3][xn4] +=s8

      

      @opacity[yn4][xp4] +=s11

      @opacity[yn4][xp3] +=s8

      @opacity[yn3][xp4] +=s8

      

      end

   

      

    if light_value>100  && x>=0 && y>=0 && x<=20 && y<=15

      s17a=sen_e_d/(54)

    s18=sen_e_d/(55)

    s19=sen_e_d/(56)

    s20=sen_e_d/(57)

    s21=sen_e_d/(58)

    s22=sen_e_d/(63)

    s23=sen_e_d/(69)

    s24=sen_e_d/(70)

    s25=sen_e_d/(73)

    s26=sen_e_d/(77)

    s27=sen_e_d/(78)

    s28=sen_e_d/(79)

      

       @opacity[yp8][x] +=s23

       @opacity[yp7][x] +=s17a

       @opacity[yn8][x] +=s23

       @opacity[yn7][x] +=s17a

       @opacity[y][xp8] +=s23

       @opacity[y][xp7] +=s17a

       @opacity[y][xn8] +=s23

       @opacity[y][xn7] +=s17a

       

      @opacity[yp8][xn3] +=s27

      @opacity[yp8][xn2] +=s25

      @opacity[yp8][xn1] +=s24

      @opacity[yp7][xn5] +=s28

      @opacity[yp7][xn4] +=s24

      @opacity[yp7][xn3] +=s22

      @opacity[yp7][xn2] +=s21

      @opacity[yp7][xn1] +=s18

      @opacity[yp6][xn6] +=s26

      @opacity[yp6][xn5] +=s19

      @opacity[yp6][xn4] +=s20

      @opacity[yp6][xn3] +=s17

      @opacity[yp5][xn7] +=s28

      @opacity[yp5][xn6] +=s19

      @opacity[yp5][xn5] +=s18

      @opacity[yp4][xn7] +=s24

      @opacity[yp4][xn6] +=s20

      @opacity[yp3][xn8] +=s27

      @opacity[yp3][xn7] +=s22

      @opacity[yp2][xn8] +=s25

      @opacity[yp2][xn7] +=s21

      @opacity[yp1][xn8] +=s24

      @opacity[yp1][xn7] +=s18

      

      @opacity[yn8][xn3] +=s27

      @opacity[yn8][xn2] +=s25

      @opacity[yn8][xn1] +=s24

      @opacity[yn7][xn5] +=s28

      @opacity[yn7][xn4] +=s24

      @opacity[yn7][xn3] +=s22

      @opacity[yn7][xn2] +=s21

      @opacity[yn7][xn1] +=s18

      @opacity[yn6][xn6] +=s26

      @opacity[yn6][xn5] +=s19

      @opacity[yn6][xn4] +=s20

      @opacity[yn6][xn3] +=s17

      @opacity[yn5][xn7] +=s28

      @opacity[yn5][xn6] +=s19

      @opacity[yn5][xn5] +=s18

      @opacity[yn4][xn7] +=s24

      @opacity[yn4][xn6] +=s20

      @opacity[yn3][xn8] +=s27

      @opacity[yn3][xn7] +=s22

      @opacity[yn2][xn8] +=s25

      @opacity[yn2][xn7] +=s21

      @opacity[yn1][xn8] +=s24

      @opacity[yn1][xn7] +=s18

      

      @opacity[yn8][xp3] +=s27

      @opacity[yn8][xp2] +=s25

      @opacity[yn8][xp1] +=s24

      @opacity[yn7][xp5] +=s28

      @opacity[yn7][xp4] +=s24

      @opacity[yn7][xp3] +=s22

      @opacity[yn7][xp2] +=s21

      @opacity[yn7][xp1] +=s18

      @opacity[yn6][xp6] +=s26

      @opacity[yn6][xp5] +=s19

      @opacity[yn6][xp4] +=s20

      @opacity[yn6][xp3] +=s17

      @opacity[yn5][xp7] +=s28

      @opacity[yn5][xp6] +=s19

      @opacity[yn5][xp5] +=s18

      @opacity[yn4][xp7] +=s24

      @opacity[yn4][xp6] +=s20

      @opacity[yn3][xp8] +=s27

      @opacity[yn3][xp7] +=s22

      @opacity[yn2][xp8] +=s25

      @opacity[yn2][xp7] +=s21

      @opacity[yn1][xp8] +=s24

      @opacity[yn1][xp7] +=s18

      

      @opacity[yp8][xp3] +=s27

      @opacity[yp8][xp2] +=s25

      @opacity[yp8][xp1] +=s24

      @opacity[yp7][xp5] +=s28

      @opacity[yp7][xp4] +=s24

      @opacity[yp7][xp3] +=s22

      @opacity[yp7][xp2] +=s21

      @opacity[yp7][xp1] +=s18

      @opacity[yp6][xp6] +=s26

      @opacity[yp6][xp5] +=s19

      @opacity[yp6][xp4] +=s20

      @opacity[yp6][xp3] +=s17

      @opacity[yp5][xp7] +=s28

      @opacity[yp5][xp6] +=s19

      @opacity[yp5][xp5] +=s18

      @opacity[yp4][xp7] +=s24

      @opacity[yp4][xp6] +=s20

      @opacity[yp3][xp8] +=s27

      @opacity[yp3][xp7] +=s22

      @opacity[yp2][xp8] +=s25

      @opacity[yp2][xp7] +=s21

      @opacity[yp1][xp8] +=s24

      @opacity[yp1][xp7] +=s18

      end

    

      if light_value>130  && x>=0 && y>=0 && x<=20 && y<=15

         s29=sen_e_d/(85)

         s30=sen_e_d/(86)

         s31=sen_e_d/(87)

         s32=sen_e_d/(90)

         s33=sen_e_d/(94)

         s34=sen_e_d/(95)

         s35=sen_e_d/(102)

         s36=sen_e_d/(103)

         s37=sen_e_d/(105)

         s38=sen_e_d/(106)

         s39=sen_e_d/(109)

         s40=sen_e_d/(111)

         s41=sen_e_d/(114)

         s42=sen_e_d/(118)

         s43=sen_e_d/(121)

         s44=sen_e_d/(122)

         

         

        @opacity[yp10][xn1] +=s38

        @opacity[yp10][xn2] +=s39

        @opacity[yp10][xn3] +=s41

        @opacity[yp9][xn1] +=s31

        @opacity[yp9][xn2] +=s32

        @opacity[yp9][xn3] +=s34

        @opacity[yp9][xn4] +=s35

        @opacity[yp9][xn5] +=s40

        @opacity[yp8][xn4] +=s29

        @opacity[yp8][xn5] +=s33

        @opacity[yp8][xn6] +=s37

        @opacity[yp8][xn7] +=s42

        @opacity[yp7][xn6] +=s32

        @opacity[yp7][xn7] +=s36

        @opacity[yp7][xn8] +=s42

        @opacity[yp6][xn7] +=s32

        @opacity[yp6][xn8] +=s37

        @opacity[yp6][xn9] +=s44

        @opacity[yp5][xn8] +=s33

        @opacity[yp5][xn9] +=s40

        @opacity[yp4][xn8] +=s29

        @opacity[yp4][xn9] +=s35

        @opacity[yp4][xn10] +=s43

        @opacity[yp3][xn9] +=s34

        @opacity[yp3][xn10] +=s41

        @opacity[yp2][xn9] +=s32

        @opacity[yp2][xn10] +=s39

        @opacity[yp1][xn9] +=s31

        @opacity[yp1][xn10] +=s38

        

        @opacity[yn10][xn1] +=s38

        @opacity[yn10][xn2] +=s39

        @opacity[yn10][xn3] +=s41

        @opacity[yn9][xn1] +=s31

        @opacity[yn9][xn2] +=s32

        @opacity[yn9][xn3] +=s34

        @opacity[yn9][xn4] +=s35

        @opacity[yn9][xn5] +=s40

        @opacity[yn8][xn4] +=s29

        @opacity[yn8][xn5] +=s33

        @opacity[yn8][xn6] +=s37

        @opacity[yn8][xn7] +=s42

        @opacity[yn7][xn6] +=s32

        @opacity[yn7][xn7] +=s36

        @opacity[yn7][xn8] +=s42

        @opacity[yn6][xn7] +=s32

        @opacity[yn6][xn8] +=s37

        @opacity[yn6][xn9] +=s44

        @opacity[yn5][xn8] +=s33

        @opacity[yn5][xn9] +=s40

        @opacity[yn4][xn8] +=s29

        @opacity[yn4][xn9] +=s35

        @opacity[yn4][xn10] +=s43

        @opacity[yn3][xn9] +=s34

        @opacity[yn3][xn10] +=s41

        @opacity[yn2][xn9] +=s32

        @opacity[yn2][xn10] +=s39

        @opacity[yn1][xn9] +=s31

        @opacity[yn1][xn10] +=s38

        

        @opacity[yn10][xp1] +=s38

        @opacity[yn10][xp2] +=s39

        @opacity[yn10][xp3] +=s41

        @opacity[yn9][xp1] +=s31

        @opacity[yn9][xp2] +=s32

        @opacity[yn9][xp3] +=s34

        @opacity[yn9][xp4] +=s35

        @opacity[yn9][xp5] +=s40

        @opacity[yn8][xp4] +=s29

        @opacity[yn8][xp5] +=s33

        @opacity[yn8][xp6] +=s37

        @opacity[yn8][xp7] +=s42

        @opacity[yn7][xp6] +=s32

        @opacity[yn7][xp7] +=s36

        @opacity[yn7][xp8] +=s42

        @opacity[yn6][xp7] +=s32

        @opacity[yn6][xp8] +=s37

        @opacity[yn6][xp9] +=s44

        @opacity[yn5][xp8] +=s33

        @opacity[yn5][xp9] +=s40

        @opacity[yn4][xp8] +=s29

        @opacity[yn4][xp9] +=s35

        @opacity[yn4][xp10] +=s43

        @opacity[yn3][xp9] +=s34

        @opacity[yn3][xp10] +=s41

        @opacity[yn2][xp9] +=s32

        @opacity[yn2][xp10] +=s39

        @opacity[yn1][xp9] +=s31

        @opacity[yn1][xp10] +=s38

        

        @opacity[yp10][xp1] +=s38

        @opacity[yp10][xp2] +=s39

        @opacity[yp10][xp3] +=s41

        @opacity[yp9][xp1] +=s31

        @opacity[yp9][xp2] +=s32

        @opacity[yp9][xp3] +=s34

        @opacity[yp9][xp4] +=s35

        @opacity[yp9][xp5] +=s40

        @opacity[yp8][xp4] +=s29

        @opacity[yp8][xp5] +=s33

        @opacity[yp8][xp6] +=s37

        @opacity[yp8][xp7] +=s42

        @opacity[yp7][xp6] +=s32

        @opacity[yp7][xp7] +=s36

        @opacity[yp7][xp8] +=s42

        @opacity[yp6][xp7] +=s32

        @opacity[yp6][xp8] +=s37

        @opacity[yp6][xp9] +=s44

        @opacity[yp5][xp8] +=s33

        @opacity[yp5][xp9] +=s40

        @opacity[yp4][xp8] +=s29

        @opacity[yp4][xp9] +=s35

        @opacity[yp4][xp10] +=s43

        @opacity[yp3][xp9] +=s34

        @opacity[yp3][xp10] +=s41

        @opacity[yp2][xp9] +=s32

        @opacity[yp2][xp10] +=s39

        @opacity[yp1][xp9] +=s31

        @opacity[yp1][xp10] +=s38

        

        @opacity[y][xn9] +=s30

        @opacity[y][xn10] +=s37

        @opacity[y][xp9] +=s30

        @opacity[y][xp10] +=s37

        @opacity[yn9][x] +=s30

        @opacity[yn10][x] +=s37

        @opacity[yp9][x] +=s30

        @opacity[yp10][x] +=s37

        end

      

      

#=end    

  end

#--------------------------------------------------------------------------

# * Light Map

#--------------------------------------------------------------------------

 

#--------------------------------------------------------------------------

# * Event Data Setup(get information from events)

#--------------------------------------------------------------------------

  def get_event_data

    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]=rand(event.list[2].parameters.to_s .to_i+1)

          end

          break if i== @light_limit

          i+=1

        end

         

      end

    end

  end

  

#--------------------------------------------------------------------------

# * Event Data Setup(get information from events)

#-------------------------------------------------------------------------- 

    #--------------------------------------------------------------------------

    # * Get Frame Rate

    #--------------------------------------------------------------------------

    def get_frame_rate

t = Time.now

@compare1 != t.sec ? (  @compare1 , count_on = t.sec , true ) : nil

count_on ? (count_on,frame_rate,@count_rate=false,@count_rate,0) : @count_rate+=1

   frame_rate

  end

    #--------------------------------------------------------------------------

    # * Get Frame Rate

    #--------------------------------------------------------------------------

#--------------------------------------------------------------------------

# * Frame Update (perform algorithms that calculate opacity of each coordinations)

#--------------------------------------------------------------------------

  def update

  frame_rate=get_frame_rate

  @frame_rate=@frame_rate==nil ? 0 : (frame_rate == nil ? @frame_rate : frame_rate )

  @frame= @frame_rate>37 ? 2 :(@frame_rate<36 ? 4 :(3))

 

    if @ccc2%@frame==0

   if @ccc==0  

      if $light_switch==1

#------------------

 get_event_data

#------------------

 

 

        @random[0]=rand($flick+1)

        @player_coor_x= (($game_player.real_x-$game_map.display_x)/4+16)/32.to_i

        @player_coor_y= (($game_player.real_y-$game_map.display_y)/4+16)/32.to_i

        @sensitivity[0]=$sensitivity_2[0]+@random[0]

    

      i=1

      loop do

          break if @xx[i]==nil 

          @event_coor_x[i]=(((@xx[i]-$game_map.display_x/4)+16)/32).to_i

          @event_coor_y[i]=(((@yy[i]-$game_map.display_y/4)+16)/32).to_i

          @sensitivity[i]=$sensitivity_2[i]+@r_value[i]

          i+=1

        end

 

 

#-------------------

@event_seq=1

 

for @y in 0..15

  for @x in 0..20

@opacity[@y][@x]=-@tone

   end

  end

light_map(@sensitivity[0],0,@player_coor_x,@player_coor_y)

 

 

 

loop do

  break if @xx[@event_seq]==nil  

  if (@player_coor_x-@event_coor_x[@event_seq]).abs<@x_limit && (@player_coor_y-@event_coor_y[@event_seq]).abs<@y_limit

#++++++

 

light_map(@sensitivity[@event_seq],@event_seq,@event_coor_x[@event_seq],@event_coor_y[@event_seq])

 

 end

#++++++  

  @event_seq+=1

end

 

#++++++

 

for @y in 0..15

  for @x in 0..20

       @light_level_indicator=-[[@opacity[@y][@x],0].min,-@tone].max

        @viewport[0][@y][@x].tone=$light_level[@light_level_indicator]#between 0 and -@tone

  end

end

#++++++

#--------------------

    @on != nil ? @on=nil : nil

      else

#-------------------        

        if @on==nil

 

          for @y in 0..15

            for @x in 0..20

              a=Tone.new(0,0,0, 0)

                 for i in 0..4

                @viewport[i][@y][@x].tone =a

              end

            end

          end

          @on=true

        end

#-------------------        

      end

    else

              for @y in 0..15

         for @x in 0..20

              @viewport[@ccc][@y][@x].tone=@viewport[@ccc-1][@y][@x].tone

          end

        end

#-------------------

end

@ccc+=1

@ccc==5 ? @ccc=0 : nil

    end

@ccc2+=1

@ccc2==@frame ?     @ccc2=0  : nil

 

 

    alias_update 

  end

#--------------------------------------------------------------------------

# * Frame Update (perform algorithms that calculate opacity of each coordinations)

#--------------------------------------------------------------------------

end

#==============================================================================

#==============================================================================

#==============================================================================

#=end

 

 

put 1st comment of number on each event to represent their id. Then, put 2nd comment of number to represent the strength of light radius of each event. Next, put the 3rd comment of number to represent the power of flickering.(Both the 3 comments can be put as what number as you want, no more limitation^^ but the 1st comment must be put according to the sequence, which mean must start with value of '1', then '2', then '3'... if you do not wish the event to flick, just set the 3rd comment value as '0' or don't create 3rd comment)

@tone represents how dark is the screen in the game, the higher value of @tone, the darker the screen.@light_limit represents the number of lights are allowed in the screen. for example, if @light_limit equals 5, the maximum light events in the screen is 5. @x_limit is where the light source being switched on or off. If the distance of x between hero and light source is more than @x_limit, the light source will be switched off. The same thing goes with @y_limit.

To set radius of single event or only hero, use $sensitivity_2[A]=value where A represents each event's id. If A equals 0, it represents hero. When $light_switch is set to 0, the script is being ignored. When $light_switch is set to 1, the script is in used. To let hero's light flick, set $flick to a value. The bigger the value $flick is, the stronger the flickering effect.

To change the darkest tone in the game, call $scene.spriteset.tone=A, where A is a number. The bigger the number, the darker the tone is.

Place this script just above Main.^^


The v1.01 version perhaps will be smoother and less lag. Comments are welcomed. Thanks^^

24-11-2010
Minor improvement is made on v1.02 which make it perhaps smoother. Some bugs fixed( picture sprite updated corrected back to number of 50). Coding is modified to provide clearer vision of the script. Thank you.


14-04-2011
v1.1 provides more effiecient coding which makes it less laggy. Moving events are now supported.
The variables '$sensitivity' is no more in used, all will just be controlled by 'sensitivity_2[A]' array.Thank you.

11-07-2011
v1.2 changes quality of light render depending on the graphic frame rate. No demo available yet, tell me if it is needed.


Demo download link(v1.1)
http://www.2shared.com/file/9Ho9UZC7/LCS_v11.html

Demo download link(v1.2)
http://www.2shared.com/file/AU1X2nyD/LCS_v12.html

FAQ



not sure to SDK



Credits and Thanks


Please give comments for this(especially to see whether it will be lag or not). TQ!!!



no need to be credited, but you are welcome to give me credits



updated photo(5-5-2009)
lightcircle8.png

smoother circle

lightcircle7.png

different light circle radius

update photo(19-7-2009)
pic2.png

pic1.png

pic3.png

light don't seem to be ignoring other anymore~

Set light circles for events
lightcircleeventsetting-1.png


Updated photo(28-8-2009)
lcspic1.png

the resolutions of the light circles are improved(7*7pixels)
 
ok, i looked at it, here is my first two thoughts:
1. people need to know what maker it is for.
2. and a screen shot is allways good(here is one for everyone)
[removed]
i know you said it is a wip so i wont over critic, i like it so far, hope it can be smoothed out more and less boxy :) good luck :)
 
deathbethecost, thanks for ur opinion.
This script is suitable for RMXP and I hv uploaded pictures for this script.
It is improved for a less boxy effect as well^^
 

regi

Sponsor

This looks like a pretty useful script. Does it work with the command "Change Screen Color Tone", or does it automatically darken the screen?

I'm not a scripter, but here are some suggestions. Try to break the limit of only 5 events; I'm sure there's a way to add more (or an infinite) number of events. Also, each light source should be able to have its own radius, so you can make lights of varying sizes. Finally, try working on smoothing it out, like death suggested. Good luck with it!
 
great script! is there something like a switch to switch this modus on and off?
because i want to use that only in caves^^

Zare
 
To Regi, thanks for ur idea. I hv modified the script so that people can set their own event limits but it will be more lag if there r more light circles on the same map.

To looseEnds, yes. You will get your hero very difficult to see things(can be totally black) once the $sensitivity is below a value and no darken area if $sensitivity is set to a high value.(I will write it on the explanation part)

To zareth, sorry I not yet make a switch for this. There is an alternative solution: you can put the $sensitivity to a high value. This makes it virtually no darken area.

I hv improved the script to a better resolution(16*16 pixels). It should b smoother than before but I scared it is a bit lag.

Guys, thanks for ur comments and continue on it. I need all these!!! haha
 
I really like your script, but i found a bug, when you use the teleport command, the light go to the left part of the map and stay there, and when you put a light on an object and teleport like before, when you return to the last place the screen is entirely white.
And another thing, the light is too quadrangular can you do something about that?

Thnx for the script!
 
To Metal_X, you are welcome and thanks for the bugs detection but can you tell me more details about it? I hv updated the script and tried to fix some bugs that you found. Hopefully it can fix the problems, if it does not work just tell me...
Of coz , I am trying my best to make it looks smoother^^(so far only managed to make it to 11*11 pixels for each light dot)
 

omen

Member

Dude, I freaking love you! My game is in a world that has no sun, making it always night time....I was having fun making all the fog effects on each map to give it the nice night time glow...but this script saves me loads of time and I like the visual look to it better then the ones I made. You will see your name in my credits for sure!
 
Cool script man, adds heaps of atmosphere.
One bug I noticed was in my menu (Stormtronics ABS with Blizz ABS Premenu commands in the Main Selection) the windows for AI Behaviour and AI triggers are dark and I can only slightly see the Actor. The same happened with another window until I made draw_map_as_background=false.
 
What a fantastic script. One thing I noticed, though is that where two light sources overlap, it is dark. It should actually be lighter where the two light sources overlap.
 
What a fantastic script. One thing I noticed, though, is that where two light sources touch, it is dark. This is where light sources would actually overlap and therefore be lighter. Kudos on a useful script.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top