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



  1.  
  2. #=begin
  3. #==============================================================================
  4. #==============================================================================
  5. #==============================================================================
  6. #Light Circle Script v1.2C updated(09-07-2011)
  7. #==============================================================================
  8. #==============================================================================
  9. #==============================================================================
  10. class Scene_Save < Scene_File
  11.      
  12.   alias alias_write_save_data write_save_data
  13.      
  14.   def write_save_data(file)
  15.     alias_write_save_data(file)
  16.     Marshal.dump($sensitivity,file)
  17.     Marshal.dump($sensitivity_2,file)
  18.     Marshal.dump($light_switch,file)
  19.     Marshal.dump($flick,file)
  20.   end
  21. end
  22. #==============================================================================
  23. class Scene_Load < Scene_File
  24.   alias t_read_save_data read_save_data
  25.   def read_save_data(file)
  26.     t_read_save_data(file)
  27.     $sensitivity = Marshal.load(file)
  28.     $sensitivity_2 = Marshal.load(file)
  29.     $light_switch = Marshal.load(file)
  30.     $flick = Marshal.load(file)
  31.   end
  32. end
  33. #==============================================================================
  34. class Game_Player< Game_Character
  35.   def change_sensitivity(value,type)
  36.     case type
  37.     when "sensitivity"
  38.       $sensitivity=value
  39.     when "sensitivity_2"
  40.       $sensitivity_2[0]=value
  41.     end
  42.   end
  43. end
  44. #==============================================================================
  45. class Scene_Map
  46.   def spriteset
  47.     return @spriteset
  48.   end
  49. end
  50. #==============================================================================
  51. #==============================================================================
  52. #==============================================================================
  53. class Scene_Title
  54.  
  55.   alias alias_main main
  56. #--------------------------------------------------------------------------
  57. # * change initial sensitivity here
  58. #--------------------------------------------------------------------------  
  59.   def main
  60.     $light_switch=1
  61.     $sensitivity_2=[]
  62.     $sensitivity_2[0]=100
  63.     $light_level=[]
  64.     for i in 0..255
  65.       $light_level[i]=Tone.new(-i,-i,-i)
  66.       end
  67.     $flick=0
  68.     alias_main
  69.   end
  70. #--------------------------------------------------------------------------
  71. # * change initial sensitivity here
  72. #--------------------------------------------------------------------------  
  73. end
  74. #==============================================================================
  75. #==============================================================================
  76. #==============================================================================
  77. # ** Spriteset_Map
  78. #------------------------------------------------------------------------------
  79. #   This class brings together map screen sprites, tilemaps, etc.
  80. #   It's used within the Scene_Map class.
  81. #==============================================================================
  82. #==============================================================================
  83. #==============================================================================
  84. class Spriteset_Map
  85.   attr_accessor :tone
  86.   attr_accessor :light_limit
  87.   attr_accessor :x_limit
  88.   attr_accessor :y_limit
  89.    
  90.   alias alias_update update
  91.   alias alias_initialize initialize
  92.   alias alias_dispose dispose
  93. #--------------------------------------------------------------------------
  94. # * Object Initialization
  95. #--------------------------------------------------------------------------
  96.   def initialize
  97. #--------------------------------------------------------------------------
  98. # * change initial setting
  99. #--------------------------------------------------------------------------      
  100.     @tone=40
  101.     @light_limit=15
  102.     @x_limit=10
  103.     @y_limit=7
  104. #--------------------------------------------------------------------------
  105. # * change initial setting
  106. #--------------------------------------------------------------------------
  107.     @opacity=[]
  108.     @random=[]
  109.     @r_value=[]
  110.     @x_x=[]
  111.     @y_y=[]
  112.     @xx=[]
  113.     @yy=[]
  114.     @event_rx=[]
  115.     @event_ry=[]
  116.     @event_coor_x=[]
  117.     @event_coor_y=[]
  118.     @sensitivity=[]
  119.     @viewport=[]
  120.     @viewport[0]=[]
  121.     @viewport[1]=[]
  122.     @viewport[2]=[]
  123.     @viewport[3]=[]
  124.     @viewport[4]=[]
  125.     @d=6
  126.     @frame=3
  127.     @event_frame_x_highlimit=[]
  128.     @event_frame_y_highlimit=[]
  129.     @event_frame_x_lowlimit=[]
  130.     @event_frame_y_lowlimit=[]
  131.     @count_rate=0
  132.     @compare1=(Time.now).sec
  133.     @ccc=0
  134.     @ccc2=0
  135.     #@player_coor_x = 0
  136.     #@player_coor_y = 0
  137.     #@player_coor_x = @player_coor_x.to_f
  138.     #@player_coor_y = @player_coor_y.to_f
  139.     get_event_data
  140. #------------------------------------
  141. @opacity[99]=[]
  142.     for @y in 0..15
  143.             @opacity[@y]=[]
  144.             @opacity[@y][99]=0
  145.       @viewport[0][@y]=[]
  146.       @viewport[1][@y]=[]
  147.       @viewport[2][@y]=[]
  148.       @viewport[3][@y]=[]
  149.       @viewport[4][@y]=[]
  150.       for @x in 0..20
  151.         @opacity[99][@x]=0
  152.         @viewport[0][@y][@x] = Viewport.new(@x*32-16, @y*32-16, 32, 32)
  153.         @viewport[0][@y][@x].tone = Tone.new(-255, -255, -255, 0)
  154.         @viewport[0][@y][@x].z = 199
  155.         @viewport[1][@y][@x] = Viewport.new(@x*32-16+@d, @y*32-16+@d, 32, 32)
  156.         @viewport[1][@y][@x].tone = Tone.new(-255, -255, -255, 0)
  157.         @viewport[1][@y][@x].z = 199
  158.         @viewport[2][@y][@x] = Viewport.new(@x*32-16+@d*2, @y*32-16+@d*2, 32, 32)
  159.         @viewport[2][@y][@x].tone = Tone.new(-255, -255, -255, 0)
  160.         @viewport[2][@y][@x].z = 199
  161.         @viewport[3][@y][@x] = Viewport.new(@x*32-16-@d, @y*32-16-@d, 32, 32)
  162.         @viewport[3][@y][@x].tone = Tone.new(-255, -255, -255, 0)
  163.         @viewport[3][@y][@x].z = 199
  164.         @viewport[4][@y][@x] = Viewport.new(@x*32-16-@d*2, @y*32-16-@d*2, 32, 32)
  165.         @viewport[4][@y][@x].tone = Tone.new(-255, -255, -255, 0)
  166.         @viewport[4][@y][@x].z = 199
  167.         @opacity[@y][@x]=-@tone
  168.       end
  169.     end
  170.         @opacity[99][99]=0
  171.    
  172.     alias_initialize
  173.  
  174.   end
  175. #--------------------------------------------------------------------------
  176. # * Object Initialization
  177. #--------------------------------------------------------------------------  
  178. #--------------------------------------------------------------------------
  179. # * Dispose
  180. #--------------------------------------------------------------------------
  181.   def dispose
  182.     alias_dispose
  183.     for @y in 0..15
  184.       for @x in 0..20
  185.         for i in 0..4
  186.           @viewport[i][@y][@x].dispose
  187.         end
  188.       end
  189.     end
  190.  
  191.   end
  192. #--------------------------------------------------------------------------
  193. # * Dispose
  194. #--------------------------------------------------------------------------
  195. #--------------------------------------------------------------------------
  196. # * Light Map
  197. #--------------------------------------------------------------------------
  198. def light_map(light_value,event_id, x , y)
  199.  
  200.  
  201.   if x==nil or y==nil
  202.     return
  203.   end
  204.  
  205.  
  206.  
  207. #=begin  
  208.   xn1= x-1 <0 ? 99 : x-1
  209.   xn2= x-2 <0 ? 99 : x-2
  210.   xn3= x-3 <0 ? 99 : x-3
  211.   xn4= x-4 <0 ? 99 : x-4
  212.   xn5= x-5 <0 ? 99 : x-5
  213.   xn6= x-6 <0 ? 99 : x-6
  214.   xn7= x-7 <0 ? 99 : x-7
  215.   xn8= x-8 <0 ? 99 : x-8
  216.   xn9= x-9 <0 ? 99 : x-9
  217.   xn10= x-10 <0 ? 99 : x-10
  218.  
  219.   xp1= x+1 >20 ? 99 : x+1
  220.   xp2= x+2 >20 ? 99 : x+2
  221.   xp3= x+3 >20 ? 99 : x+3
  222.   xp4= x+4 >20 ? 99 : x+4
  223.   xp5= x+5 >20 ? 99 : x+5
  224.   xp6= x+6 >20 ? 99 : x+6
  225.   xp7= x+7 >20 ? 99 : x+7
  226.   xp8= x+8 >20 ? 99 : x+8
  227.   xp9= x+9 >20 ? 99 : x+9
  228.   xp10= x+10 >20 ? 99 : x+10
  229.  
  230.   yn1= y-1 <0 ? 99 : y-1
  231.   yn2= y-2 <0 ? 99 : y-2
  232.   yn3= y-3 <0 ? 99 : y-3
  233.   yn4= y-4 <0 ? 99 : y-4
  234.   yn5= y-5 <0 ? 99 : y-5
  235.   yn6= y-6 <0 ? 99 : y-6
  236.   yn7= y-7 <0 ? 99 : y-7
  237.   yn8= y-8 <0 ? 99 : y-8
  238.   yn9= y-9 <0 ? 99 : y-9
  239.   yn10= y-10 <0 ? 99 : y-10
  240.  
  241.   yp1= y+1 >15 ? 99 : y+1
  242.   yp2= y+2 >15 ? 99 : y+2
  243.   yp3= y+3 >15 ? 99 : y+3
  244.   yp4= y+4 >15 ? 99 : y+4
  245.   yp5= y+5 >15 ? 99 : y+5
  246.   yp6= y+6 >15 ? 99 : y+6
  247.   yp7= y+7 >15 ? 99 : y+7
  248.   yp8= y+8 >15 ? 99 : y+8
  249.   yp9= y+9 >15 ? 99 : y+9
  250.   yp10= y+10 >15 ? 99 : y+10
  251.  
  252.   sen_e_d=@sensitivity[event_id]
  253.   s0=sen_e_d/(5)
  254.   s0a=sen_e_d/(6)
  255. s1=sen_e_d/(7)
  256. s1a=sen_e_d/(9)
  257.     s2=sen_e_d/(10)
  258.     s3=sen_e_d/(13)
  259.     s3a=sen_e_d/(14)
  260.     s4=sen_e_d/(15)
  261.     s5=sen_e_d/(18)
  262.     s5a=sen_e_d/(21)
  263.     s6=sen_e_d/(22)
  264.     s6a=sen_e_d/(23)
  265.     s7=sen_e_d/(25)
  266.    
  267.    
  268.    
  269.    
  270. #=begin    
  271.   if light_value>0 && x>=0 && y>=0 && x<=20 && y<=15
  272.    
  273.    
  274.     @opacity[yp4][xn1] +=s6
  275.     @opacity[yp4][xn2] +=s7
  276.     @opacity[yp3][xn1] +=s4
  277.     @opacity[yp3][xn2] +=s5
  278.     @opacity[yp3][xn3] +=s6a
  279.     @opacity[yp2][xn1] +=s2
  280.     @opacity[yp2][xn2] +=s3
  281.     @opacity[yp2][xn3] +=s5
  282.     @opacity[yp2][xn4] +=s7
  283.     @opacity[yp1][xn1] +=s1
  284.     @opacity[yp1][xn2] +=s2
  285.     @opacity[yp1][xn3] +=s4
  286.     @opacity[yp1][xn4] +=s6
  287.    
  288.     @opacity[yn4][xn1] +=s6
  289.     @opacity[yn4][xn2] +=s7
  290.     @opacity[yn3][xn1] +=s4
  291.     @opacity[yn3][xn2] +=s5
  292.     @opacity[yn3][xn3] +=s6a
  293.     @opacity[yn2][xn1] +=s2
  294.     @opacity[yn2][xn2] +=s3
  295.     @opacity[yn2][xn3] +=s5
  296.     @opacity[yn2][xn4] +=s7
  297.     @opacity[yn1][xn1] +=s1
  298.     @opacity[yn1][xn2] +=s2
  299.     @opacity[yn1][xn3] +=s4
  300.     @opacity[yn1][xn4] +=s6
  301.    
  302.     @opacity[yn4][xp1] +=s6
  303.     @opacity[yn4][xp2] +=s7
  304.     @opacity[yn3][xp1] +=s4
  305.     @opacity[yn3][xp2] +=s5
  306.     @opacity[yn3][xp3] +=s6a
  307.     @opacity[yn2][xp1] +=s2
  308.     @opacity[yn2][xp2] +=s3
  309.     @opacity[yn2][xp3] +=s5
  310.     @opacity[yn2][xp4] +=s7
  311.     @opacity[yn1][xp1] +=s1
  312.     @opacity[yn1][xp2] +=s2
  313.     @opacity[yn1][xp3] +=s4
  314.     @opacity[yn1][xp4] +=s6
  315.    
  316.     @opacity[yp4][xp1] +=s6
  317.     @opacity[yp4][xp2] +=s7
  318.     @opacity[yp3][xp1] +=s4
  319.     @opacity[yp3][xp2] +=s5
  320.     @opacity[yp3][xp3] +=s6a
  321.     @opacity[yp2][xp1] +=s2
  322.     @opacity[yp2][xp2] +=s3
  323.     @opacity[yp2][xp3] +=s5
  324.     @opacity[yp2][xp4] +=s7
  325.     @opacity[yp1][xp1] +=s1
  326.     @opacity[yp1][xp2] +=s2
  327.     @opacity[yp1][xp3] +=s4
  328.     @opacity[yp1][xp4] +=s6
  329.    
  330.    
  331.       @opacity[y][x] +=s0
  332.    
  333.     @opacity[yp4][x] +=s5a
  334.     @opacity[yp3][x] +=s3a
  335.     @opacity[yp2][x] +=s1a
  336.     @opacity[yp1][x] +=s0a
  337.     @opacity[yn4][x] +=s5a
  338.     @opacity[yn3][x] +=s3a
  339.     @opacity[yn2][x] +=s1a
  340.     @opacity[yn1][x] +=s0a
  341.    
  342.     @opacity[y][xp4] +=s5a
  343.     @opacity[y][xp3] +=s3a
  344.     @opacity[y][xp2] +=s1a
  345.     @opacity[y][xp1] +=s0a
  346.     @opacity[y][xn4] +=s5a
  347.     @opacity[y][xn3] +=s3a
  348.     @opacity[y][xn2] +=s1a
  349.     @opacity[y][xn1] +=s0a
  350.     end
  351. #=end  
  352.  
  353.     if light_value>60  && x>=0 && y>=0 && x<=20 && y<=15
  354.       s8=sen_e_d/(30)
  355.     s9=sen_e_d/(31)
  356.     s10=sen_e_d/(34)
  357.     s11=sen_e_d/(37)
  358.     s12=sen_e_d/(39)
  359.     s13=sen_e_d/(41)
  360.     s14=sen_e_d/(42)
  361.     s15=sen_e_d/(45)
  362.     s16=sen_e_d/(46)
  363.     s17=sen_e_d/(50)
  364.       @opacity[yp6][xn2] +=s15
  365.       @opacity[yp6][xn1] +=s14
  366.       @opacity[yp6][x] +=s13
  367.       @opacity[yp6][xp2] +=s15
  368.       @opacity[yp6][xp1] +=s14
  369.      
  370.       @opacity[yn6][xn2] +=s15
  371.       @opacity[yn6][xn1] +=s14
  372.       @opacity[yn6][x] +=s13
  373.       @opacity[yn6][xp2] +=s15
  374.       @opacity[yn6][xp1] +=s14
  375.      
  376.       @opacity[yp5][xn4] +=s16
  377.       @opacity[yp5][xn3] +=s12
  378.       @opacity[yp5][xn2] +=s10
  379.       @opacity[yp5][xn1] +=s9
  380.       @opacity[yp5][x] +=s8
  381.       @opacity[yp5][xp4] +=s16
  382.       @opacity[yp5][xp3] +=s12
  383.       @opacity[yp5][xp2] +=s10
  384.       @opacity[yp5][xp1] +=s9
  385.      
  386.       @opacity[yn5][xn4] +=s16
  387.       @opacity[yn5][xn3] +=s12
  388.       @opacity[yn5][xn2] +=s10
  389.       @opacity[yn5][xn1] +=s9
  390.       @opacity[yn5][x] +=s8
  391.       @opacity[yn5][xp4] +=s16
  392.       @opacity[yn5][xp3] +=s12
  393.       @opacity[yn5][xp2] +=s10
  394.       @opacity[yn5][xp1] +=s9
  395.      
  396.      
  397.       @opacity[yp3][xn6] +=s17
  398.       @opacity[yp2][xn6] +=s15
  399.       @opacity[yp1][xn6] +=s14
  400.       @opacity[y][xn6] +=s13
  401.       @opacity[yn3][xn6] +=s17
  402.       @opacity[yn2][xn6] +=s15
  403.       @opacity[yn1][xn6] +=s14
  404.      
  405.       @opacity[yp3][xp6] +=s17
  406.       @opacity[yp2][xp6] +=s15
  407.       @opacity[yp1][xp6] +=s14
  408.       @opacity[y][xp6] +=s13
  409.       @opacity[yn3][xp6] +=s17
  410.       @opacity[yn2][xp6] +=s15
  411.       @opacity[yn1][xp6] +=s14
  412.      
  413.       @opacity[yp4][xn5] +=s16
  414.       @opacity[yp3][xn5] +=s12
  415.       @opacity[yp2][xn5] +=s10
  416.       @opacity[yp1][xn5] +=s9
  417.       @opacity[y][xn5] +=s8
  418.       @opacity[yn4][xn5] +=s16
  419.       @opacity[yn3][xn5] +=s12
  420.       @opacity[yn2][xn5] +=s10
  421.       @opacity[yn1][xn5] +=s9
  422.      
  423.        @opacity[yp4][xp5] +=s16
  424.       @opacity[yp3][xp5] +=s12
  425.       @opacity[yp2][xp5] +=s10
  426.       @opacity[yp1][xp5] +=s9
  427.       @opacity[y][xp5] +=s8
  428.       @opacity[yn4][xp5] +=s16
  429.       @opacity[yn3][xp5] +=s12
  430.       @opacity[yn2][xp5] +=s10
  431.       @opacity[yn1][xp5] +=s9
  432.      
  433.       @opacity[yp4][xn4] +=s11
  434.       @opacity[yp4][xn3] +=s8
  435.       @opacity[yp3][xn4] +=s8
  436.      
  437.       @opacity[yp4][xp4] +=s11
  438.       @opacity[yp4][xp3] +=s8
  439.       @opacity[yp3][xp4] +=s8
  440.      
  441.       @opacity[yn4][xn4] +=s11
  442.       @opacity[yn4][xn3] +=s8
  443.       @opacity[yn3][xn4] +=s8
  444.      
  445.       @opacity[yn4][xp4] +=s11
  446.       @opacity[yn4][xp3] +=s8
  447.       @opacity[yn3][xp4] +=s8
  448.      
  449.       end
  450.    
  451.      
  452.     if light_value>100  && x>=0 && y>=0 && x<=20 && y<=15
  453.       s17a=sen_e_d/(54)
  454.     s18=sen_e_d/(55)
  455.     s19=sen_e_d/(56)
  456.     s20=sen_e_d/(57)
  457.     s21=sen_e_d/(58)
  458.     s22=sen_e_d/(63)
  459.     s23=sen_e_d/(69)
  460.     s24=sen_e_d/(70)
  461.     s25=sen_e_d/(73)
  462.     s26=sen_e_d/(77)
  463.     s27=sen_e_d/(78)
  464.     s28=sen_e_d/(79)
  465.      
  466.        @opacity[yp8][x] +=s23
  467.        @opacity[yp7][x] +=s17a
  468.        @opacity[yn8][x] +=s23
  469.        @opacity[yn7][x] +=s17a
  470.        @opacity[y][xp8] +=s23
  471.        @opacity[y][xp7] +=s17a
  472.        @opacity[y][xn8] +=s23
  473.        @opacity[y][xn7] +=s17a
  474.        
  475.       @opacity[yp8][xn3] +=s27
  476.       @opacity[yp8][xn2] +=s25
  477.       @opacity[yp8][xn1] +=s24
  478.       @opacity[yp7][xn5] +=s28
  479.       @opacity[yp7][xn4] +=s24
  480.       @opacity[yp7][xn3] +=s22
  481.       @opacity[yp7][xn2] +=s21
  482.       @opacity[yp7][xn1] +=s18
  483.       @opacity[yp6][xn6] +=s26
  484.       @opacity[yp6][xn5] +=s19
  485.       @opacity[yp6][xn4] +=s20
  486.       @opacity[yp6][xn3] +=s17
  487.       @opacity[yp5][xn7] +=s28
  488.       @opacity[yp5][xn6] +=s19
  489.       @opacity[yp5][xn5] +=s18
  490.       @opacity[yp4][xn7] +=s24
  491.       @opacity[yp4][xn6] +=s20
  492.       @opacity[yp3][xn8] +=s27
  493.       @opacity[yp3][xn7] +=s22
  494.       @opacity[yp2][xn8] +=s25
  495.       @opacity[yp2][xn7] +=s21
  496.       @opacity[yp1][xn8] +=s24
  497.       @opacity[yp1][xn7] +=s18
  498.      
  499.       @opacity[yn8][xn3] +=s27
  500.       @opacity[yn8][xn2] +=s25
  501.       @opacity[yn8][xn1] +=s24
  502.       @opacity[yn7][xn5] +=s28
  503.       @opacity[yn7][xn4] +=s24
  504.       @opacity[yn7][xn3] +=s22
  505.       @opacity[yn7][xn2] +=s21
  506.       @opacity[yn7][xn1] +=s18
  507.       @opacity[yn6][xn6] +=s26
  508.       @opacity[yn6][xn5] +=s19
  509.       @opacity[yn6][xn4] +=s20
  510.       @opacity[yn6][xn3] +=s17
  511.       @opacity[yn5][xn7] +=s28
  512.       @opacity[yn5][xn6] +=s19
  513.       @opacity[yn5][xn5] +=s18
  514.       @opacity[yn4][xn7] +=s24
  515.       @opacity[yn4][xn6] +=s20
  516.       @opacity[yn3][xn8] +=s27
  517.       @opacity[yn3][xn7] +=s22
  518.       @opacity[yn2][xn8] +=s25
  519.       @opacity[yn2][xn7] +=s21
  520.       @opacity[yn1][xn8] +=s24
  521.       @opacity[yn1][xn7] +=s18
  522.      
  523.       @opacity[yn8][xp3] +=s27
  524.       @opacity[yn8][xp2] +=s25
  525.       @opacity[yn8][xp1] +=s24
  526.       @opacity[yn7][xp5] +=s28
  527.       @opacity[yn7][xp4] +=s24
  528.       @opacity[yn7][xp3] +=s22
  529.       @opacity[yn7][xp2] +=s21
  530.       @opacity[yn7][xp1] +=s18
  531.       @opacity[yn6][xp6] +=s26
  532.       @opacity[yn6][xp5] +=s19
  533.       @opacity[yn6][xp4] +=s20
  534.       @opacity[yn6][xp3] +=s17
  535.       @opacity[yn5][xp7] +=s28
  536.       @opacity[yn5][xp6] +=s19
  537.       @opacity[yn5][xp5] +=s18
  538.       @opacity[yn4][xp7] +=s24
  539.       @opacity[yn4][xp6] +=s20
  540.       @opacity[yn3][xp8] +=s27
  541.       @opacity[yn3][xp7] +=s22
  542.       @opacity[yn2][xp8] +=s25
  543.       @opacity[yn2][xp7] +=s21
  544.       @opacity[yn1][xp8] +=s24
  545.       @opacity[yn1][xp7] +=s18
  546.      
  547.       @opacity[yp8][xp3] +=s27
  548.       @opacity[yp8][xp2] +=s25
  549.       @opacity[yp8][xp1] +=s24
  550.       @opacity[yp7][xp5] +=s28
  551.       @opacity[yp7][xp4] +=s24
  552.       @opacity[yp7][xp3] +=s22
  553.       @opacity[yp7][xp2] +=s21
  554.       @opacity[yp7][xp1] +=s18
  555.       @opacity[yp6][xp6] +=s26
  556.       @opacity[yp6][xp5] +=s19
  557.       @opacity[yp6][xp4] +=s20
  558.       @opacity[yp6][xp3] +=s17
  559.       @opacity[yp5][xp7] +=s28
  560.       @opacity[yp5][xp6] +=s19
  561.       @opacity[yp5][xp5] +=s18
  562.       @opacity[yp4][xp7] +=s24
  563.       @opacity[yp4][xp6] +=s20
  564.       @opacity[yp3][xp8] +=s27
  565.       @opacity[yp3][xp7] +=s22
  566.       @opacity[yp2][xp8] +=s25
  567.       @opacity[yp2][xp7] +=s21
  568.       @opacity[yp1][xp8] +=s24
  569.       @opacity[yp1][xp7] +=s18
  570.       end
  571.    
  572.       if light_value>130  && x>=0 && y>=0 && x<=20 && y<=15
  573.          s29=sen_e_d/(85)
  574.          s30=sen_e_d/(86)
  575.          s31=sen_e_d/(87)
  576.          s32=sen_e_d/(90)
  577.          s33=sen_e_d/(94)
  578.          s34=sen_e_d/(95)
  579.          s35=sen_e_d/(102)
  580.          s36=sen_e_d/(103)
  581.          s37=sen_e_d/(105)
  582.          s38=sen_e_d/(106)
  583.          s39=sen_e_d/(109)
  584.          s40=sen_e_d/(111)
  585.          s41=sen_e_d/(114)
  586.          s42=sen_e_d/(118)
  587.          s43=sen_e_d/(121)
  588.          s44=sen_e_d/(122)
  589.          
  590.          
  591.         @opacity[yp10][xn1] +=s38
  592.         @opacity[yp10][xn2] +=s39
  593.         @opacity[yp10][xn3] +=s41
  594.         @opacity[yp9][xn1] +=s31
  595.         @opacity[yp9][xn2] +=s32
  596.         @opacity[yp9][xn3] +=s34
  597.         @opacity[yp9][xn4] +=s35
  598.         @opacity[yp9][xn5] +=s40
  599.         @opacity[yp8][xn4] +=s29
  600.         @opacity[yp8][xn5] +=s33
  601.         @opacity[yp8][xn6] +=s37
  602.         @opacity[yp8][xn7] +=s42
  603.         @opacity[yp7][xn6] +=s32
  604.         @opacity[yp7][xn7] +=s36
  605.         @opacity[yp7][xn8] +=s42
  606.         @opacity[yp6][xn7] +=s32
  607.         @opacity[yp6][xn8] +=s37
  608.         @opacity[yp6][xn9] +=s44
  609.         @opacity[yp5][xn8] +=s33
  610.         @opacity[yp5][xn9] +=s40
  611.         @opacity[yp4][xn8] +=s29
  612.         @opacity[yp4][xn9] +=s35
  613.         @opacity[yp4][xn10] +=s43
  614.         @opacity[yp3][xn9] +=s34
  615.         @opacity[yp3][xn10] +=s41
  616.         @opacity[yp2][xn9] +=s32
  617.         @opacity[yp2][xn10] +=s39
  618.         @opacity[yp1][xn9] +=s31
  619.         @opacity[yp1][xn10] +=s38
  620.        
  621.         @opacity[yn10][xn1] +=s38
  622.         @opacity[yn10][xn2] +=s39
  623.         @opacity[yn10][xn3] +=s41
  624.         @opacity[yn9][xn1] +=s31
  625.         @opacity[yn9][xn2] +=s32
  626.         @opacity[yn9][xn3] +=s34
  627.         @opacity[yn9][xn4] +=s35
  628.         @opacity[yn9][xn5] +=s40
  629.         @opacity[yn8][xn4] +=s29
  630.         @opacity[yn8][xn5] +=s33
  631.         @opacity[yn8][xn6] +=s37
  632.         @opacity[yn8][xn7] +=s42
  633.         @opacity[yn7][xn6] +=s32
  634.         @opacity[yn7][xn7] +=s36
  635.         @opacity[yn7][xn8] +=s42
  636.         @opacity[yn6][xn7] +=s32
  637.         @opacity[yn6][xn8] +=s37
  638.         @opacity[yn6][xn9] +=s44
  639.         @opacity[yn5][xn8] +=s33
  640.         @opacity[yn5][xn9] +=s40
  641.         @opacity[yn4][xn8] +=s29
  642.         @opacity[yn4][xn9] +=s35
  643.         @opacity[yn4][xn10] +=s43
  644.         @opacity[yn3][xn9] +=s34
  645.         @opacity[yn3][xn10] +=s41
  646.         @opacity[yn2][xn9] +=s32
  647.         @opacity[yn2][xn10] +=s39
  648.         @opacity[yn1][xn9] +=s31
  649.         @opacity[yn1][xn10] +=s38
  650.        
  651.         @opacity[yn10][xp1] +=s38
  652.         @opacity[yn10][xp2] +=s39
  653.         @opacity[yn10][xp3] +=s41
  654.         @opacity[yn9][xp1] +=s31
  655.         @opacity[yn9][xp2] +=s32
  656.         @opacity[yn9][xp3] +=s34
  657.         @opacity[yn9][xp4] +=s35
  658.         @opacity[yn9][xp5] +=s40
  659.         @opacity[yn8][xp4] +=s29
  660.         @opacity[yn8][xp5] +=s33
  661.         @opacity[yn8][xp6] +=s37
  662.         @opacity[yn8][xp7] +=s42
  663.         @opacity[yn7][xp6] +=s32
  664.         @opacity[yn7][xp7] +=s36
  665.         @opacity[yn7][xp8] +=s42
  666.         @opacity[yn6][xp7] +=s32
  667.         @opacity[yn6][xp8] +=s37
  668.         @opacity[yn6][xp9] +=s44
  669.         @opacity[yn5][xp8] +=s33
  670.         @opacity[yn5][xp9] +=s40
  671.         @opacity[yn4][xp8] +=s29
  672.         @opacity[yn4][xp9] +=s35
  673.         @opacity[yn4][xp10] +=s43
  674.         @opacity[yn3][xp9] +=s34
  675.         @opacity[yn3][xp10] +=s41
  676.         @opacity[yn2][xp9] +=s32
  677.         @opacity[yn2][xp10] +=s39
  678.         @opacity[yn1][xp9] +=s31
  679.         @opacity[yn1][xp10] +=s38
  680.        
  681.         @opacity[yp10][xp1] +=s38
  682.         @opacity[yp10][xp2] +=s39
  683.         @opacity[yp10][xp3] +=s41
  684.         @opacity[yp9][xp1] +=s31
  685.         @opacity[yp9][xp2] +=s32
  686.         @opacity[yp9][xp3] +=s34
  687.         @opacity[yp9][xp4] +=s35
  688.         @opacity[yp9][xp5] +=s40
  689.         @opacity[yp8][xp4] +=s29
  690.         @opacity[yp8][xp5] +=s33
  691.         @opacity[yp8][xp6] +=s37
  692.         @opacity[yp8][xp7] +=s42
  693.         @opacity[yp7][xp6] +=s32
  694.         @opacity[yp7][xp7] +=s36
  695.         @opacity[yp7][xp8] +=s42
  696.         @opacity[yp6][xp7] +=s32
  697.         @opacity[yp6][xp8] +=s37
  698.         @opacity[yp6][xp9] +=s44
  699.         @opacity[yp5][xp8] +=s33
  700.         @opacity[yp5][xp9] +=s40
  701.         @opacity[yp4][xp8] +=s29
  702.         @opacity[yp4][xp9] +=s35
  703.         @opacity[yp4][xp10] +=s43
  704.         @opacity[yp3][xp9] +=s34
  705.         @opacity[yp3][xp10] +=s41
  706.         @opacity[yp2][xp9] +=s32
  707.         @opacity[yp2][xp10] +=s39
  708.         @opacity[yp1][xp9] +=s31
  709.         @opacity[yp1][xp10] +=s38
  710.        
  711.         @opacity[y][xn9] +=s30
  712.         @opacity[y][xn10] +=s37
  713.         @opacity[y][xp9] +=s30
  714.         @opacity[y][xp10] +=s37
  715.         @opacity[yn9][x] +=s30
  716.         @opacity[yn10][x] +=s37
  717.         @opacity[yp9][x] +=s30
  718.         @opacity[yp10][x] +=s37
  719.         end
  720.      
  721.      
  722. #=end    
  723.   end
  724. #--------------------------------------------------------------------------
  725. # * Light Map
  726. #--------------------------------------------------------------------------
  727.  
  728. #--------------------------------------------------------------------------
  729. # * Event Data Setup(get information from events)
  730. #--------------------------------------------------------------------------
  731.   def get_event_data
  732.     for event in $game_map.events.values
  733.       if event.list && event.list[0].code == 108
  734.         i=1
  735.         loop do
  736.           if event.list[0].parameters.to_s == i.to_s
  737.             @xx[i]=event.x*32
  738.             @yy[i]=event.y*32
  739.             $sensitivity_2[i]=event.list[1].parameters.to_s .to_i
  740.             @r_value[i]=rand(event.list[2].parameters.to_s .to_i+1)
  741.           end
  742.           break if i== @light_limit
  743.           i+=1
  744.         end
  745.          
  746.       end
  747.     end
  748.   end
  749.  
  750. #--------------------------------------------------------------------------
  751. # * Event Data Setup(get information from events)
  752. #--------------------------------------------------------------------------
  753.     #--------------------------------------------------------------------------
  754.     # * Get Frame Rate
  755.     #--------------------------------------------------------------------------
  756.     def get_frame_rate
  757. t = Time.now
  758. @compare1 != t.sec ? (  @compare1 , count_on = t.sec , true ) : nil
  759. count_on ? (count_on,frame_rate,@count_rate=false,@count_rate,0) : @count_rate+=1
  760.    frame_rate
  761.   end
  762.     #--------------------------------------------------------------------------
  763.     # * Get Frame Rate
  764.     #--------------------------------------------------------------------------
  765. #--------------------------------------------------------------------------
  766. # * Frame Update (perform algorithms that calculate opacity of each coordinations)
  767. #--------------------------------------------------------------------------
  768.   def update
  769.   frame_rate=get_frame_rate
  770.   @frame_rate=@frame_rate==nil ? 0 : (frame_rate == nil ? @frame_rate : frame_rate )
  771.   @frame= @frame_rate>37 ? 2 :(@frame_rate<36 ? 4 :(3))
  772.  
  773.     if @ccc2%@frame==0
  774.    if @ccc==0  
  775.       if $light_switch==1
  776. #------------------
  777.  get_event_data
  778. #------------------
  779.  
  780.  
  781.         @random[0]=rand($flick+1)
  782.         @player_coor_x= (($game_player.real_x-$game_map.display_x)/4+16)/32.to_i
  783.         @player_coor_y= (($game_player.real_y-$game_map.display_y)/4+16)/32.to_i
  784.         @sensitivity[0]=$sensitivity_2[0]+@random[0]
  785.    
  786.       i=1
  787.       loop do
  788.           break if @xx[i]==nil
  789.           @event_coor_x[i]=(((@xx[i]-$game_map.display_x/4)+16)/32).to_i
  790.           @event_coor_y[i]=(((@yy[i]-$game_map.display_y/4)+16)/32).to_i
  791.           @sensitivity[i]=$sensitivity_2[i]+@r_value[i]
  792.           i+=1
  793.         end
  794.  
  795.  
  796. #-------------------
  797. @event_seq=1
  798.  
  799. for @y in 0..15
  800.   for @x in 0..20
  801. @opacity[@y][@x]=-@tone
  802.    end
  803.   end
  804. light_map(@sensitivity[0],0,@player_coor_x,@player_coor_y)
  805.  
  806.  
  807.  
  808. loop do
  809.   break if @xx[@event_seq]==nil  
  810.   if (@player_coor_x-@event_coor_x[@event_seq]).abs<@x_limit && (@player_coor_y-@event_coor_y[@event_seq]).abs<@y_limit
  811. #++++++
  812.  
  813. light_map(@sensitivity[@event_seq],@event_seq,@event_coor_x[@event_seq],@event_coor_y[@event_seq])
  814.  
  815.  end
  816. #++++++  
  817.   @event_seq+=1
  818. end
  819.  
  820. #++++++
  821.  
  822. for @y in 0..15
  823.   for @x in 0..20
  824.        @light_level_indicator=-[[@opacity[@y][@x],0].min,-@tone].max
  825.         @viewport[0][@y][@x].tone=$light_level[@light_level_indicator]#between 0 and -@tone
  826.   end
  827. end
  828. #++++++
  829. #--------------------
  830.     @on != nil ? @on=nil : nil
  831.       else
  832. #-------------------        
  833.         if @on==nil
  834.  
  835.           for @y in 0..15
  836.             for @x in 0..20
  837.               a=Tone.new(0,0,0, 0)
  838.                  for i in 0..4
  839.                 @viewport[i][@y][@x].tone =a
  840.               end
  841.             end
  842.           end
  843.           @on=true
  844.         end
  845. #-------------------        
  846.       end
  847.     else
  848.               for @y in 0..15
  849.          for @x in 0..20
  850.               @viewport[@ccc][@y][@x].tone=@viewport[@ccc-1][@y][@x].tone
  851.           end
  852.         end
  853. #-------------------
  854. end
  855. @ccc+=1
  856. @ccc==5 ? @ccc=0 : nil
  857.     end
  858. @ccc2+=1
  859. @ccc2==@frame ?     @ccc2=0  : nil
  860.  
  861.  
  862.     alias_update
  863.   end
  864. #--------------------------------------------------------------------------
  865. # * Frame Update (perform algorithms that calculate opacity of each coordinations)
  866. #--------------------------------------------------------------------------
  867. end
  868. #==============================================================================
  869. #==============================================================================
  870. #==============================================================================
  871. #=end
  872.  
  873.  
Expand to see the code.


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)
Image
smoother circle

Image
different light circle radius

update photo(19-7-2009)
Image
Image
Image
light don't seem to be ignoring other anymore~

Set light circles for events
Image

Updated photo(28-8-2009)
Image
the resolutions of the light circles are improved(7*7pixels)
no reply? or i hv done anything wrong?
dis script existed b4?
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^^
no problem man, i deleted my pic cause yours look better :) cant wait to see a smoother version i like what u can do with this script.
Heh, I will try my best to improve on it!
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!
This is perfect for a poke'mon style cave lighting!
Can you darken the screen to near black and intensify the light radius?
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
hmmm it is alot smoother, i like it better now :)
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!
^.^

Another script to be add in my project.

😀
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)
The bug is now fixed, thnks!
The light is smoother but its lagging too much now =/
RM is soo limited....
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.
to kwik2thakatch, is that when the screen is displaying the menu, the background map is being displayed as well?
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.
There is another perfect script that my game will contain, can you put the demo please?
I've seen may of these but this one rocks! It's so easy to use since you don't have to do anything! lol :haha:

Like people have said before though, it would be nice if you could add a few features like call script at a certin point and dismiss script. Another cool feature i'd like to see is a "flicker" effect for things like candles or torches. Makes it more realistic.
this script seems awesome but i was wondering if there was any way you could make it customizable so if say u wanted the light around a fire it would appear red, like the fire light. Or, for example, if you wanted to make a glowing bug or something you could make it glow purple.
I'm trying to figure out the script commands but I keep coming up with syntax errors when I call script.

This should work:
$game_player.change_sensitivity(5,4)

But it does nothing.

When I use:
$game_player.change_sensitivity2(5,4)
I get:

NoMethodError occurred while running script

undefined method 'change_sensitivity2' for
#<Game_Player:0x75b04b0>
I have accidentally deleted my explanation about the script but will make another as soon as possible~

to BlueEagle7, you are right. There are something problems with my script and I have corrected the problem that you stated before. Thanks for your comment~

to nicol100, I will try to make it as soon as possible~

to Sirus01 and thenotorioustater, thanks for your idea and I will try to make it^^

to Barchetta ,
--> $game_player.change_sensitivity(5,"sensitivity_2")
the code above means that i want a light of power value equals to 5 , put on only hero

--> $game_player.change_sensitivity(2,"sensitivity")
the code above means that i want a light of power value equals to 2 , put on hero and events

the way of writing out the code I think is a bit of confusing and wasting time which I should improve it long time ago...very sorry for that lol~
if you still can't make it, then just write :
$sensitivity=5
$sensitivity_2[A]=5
where A equals the event id that you wish to change its light radius(if A==0, it direct to hero)
$sensitivity is a universal light radius which mean if u add the value of $sensitivity, both hero and events' light radius will be added.
can anyone tell me exactly how to use this script? Please.
Nice to meet you Zealo^^

~To use this script, place this script just above Main.
~The hero and events settings have to be configured.
~Set the event's configuration by referring to the photo showed above(I have just updated it)
~To change hero's light circle radius, change the value of $sensitivity_2[0].
~To change both hero and all events' light circle radius, change the value of $sensitivity.
~To make hero's light circle flick, change $flick to value of 1 or higher.
~To ignore the script's effect, change $light_switch to value of 0.

Hopefully this helps you...
Hello. Cool script, I'm definitely going to use this. One question:

Can I change the @tone value with a call script?

I want some maps to be darker than others... And some maps to be normal without any darkness!

Thanks in advance.
to DreadOmen:
Thanks for your comment.
Yes, I have just updated the script. You can call $scene.spriteset.tone=A, where A is a number.
The bigger the number, the darker the tone is.
If you want the map without any darkness, just put $light_switch=0.
This script is awesome, but it quickly takes my processor to 100% activity and then lags a lot, never letting the processor usage get lower until I shut the game off. Maybe you should look into a more efficient way of controlling the geometric calculations?

But anyway, could you provide me a really simple version of the script, with decreased quality? I really don't need it to be as pretty as it is right now... I just need a dyamic light circle that works as well as yours, doesn't matter if it's a plain white blob interacting with an undithered dark background. Could you please fill this request?
Funny, I noticed that when I accidentally typed "$slight_switch=0" in call script instead of "$light_switch=0" like I meant to, then started the game, the hero's light circle started as a small circle then grew to fill the whole map. I had a call script "$sensitivity_2[0]-=-1" on the same map, and I noticed that when I changed the "hero sensitivity" to a positive number the light circle did the opposite, it dimmed. I found this by accident, but is this a considered part of the script?

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=63866