Day/Night and Clear Lights with Clock

I like this script a lot, but seem to be having a bug with my combat system (atoa cbs with atb), It seems that any time youre in battle at midnight the combat is ended and the player is brought back to the map, I cant find any particular variable conflicts, or code overlaps. I figure the easiest way to handle this is to simply disable the timer during combat, since i kind of wanted to do that any way. How could I go about intergrating that?
So no one found a way to make some sort of light show on your character while moving?

My game is going to be very dark and I wish I could use some small light source around my character since using a picture as light source is not going to work with this script.
This script in itself is pretty nice, but it would be cool, if you added the ability to use light if you had a certain item, as well as have the light source follow the events. I started on it myself, got it to follow events and such, but the way you draw the bitmap made it lag a little when I redrew for new positions, Id work on it more but dont have enough time.
Wish someone does.

I could use it for having a light source in my project to use during the night. (In my project during the night it's very very dark apart of some lights like fires or tvs, lamps etc etc but these won't be everywhere specially when outside in the world.)
I've been looking over the script, and I believe I found a small error in the Rect overlap? function (from line 144):
  1. def overlap?(rect)
  2.     corners = []
  3.     corners << [rect.x, rect.y] #UL
  4.     corners << [rect.x+rect.width, rect.y] #UR
  5.     corners << [rect.x+rect.width, rect.y+height] #LR
  6.     corners << [rect.x, rect.y+height] #LL
Expand to see the code.

should read:
  1. def overlap?(rect)
  2.     corners = []
  3.     corners << [rect.x, rect.y] #UL
  4.     corners << [rect.x+rect.width, rect.y] #UR
  5.     corners << [rect.x+rect.width, rect.y+rect.height] #LR
  6.     corners << [rect.x, rect.y+rect.height] #LL
Expand to see the code.


I'm doing a bit more tinkering to see if the lights can follow the player/moving events (right now, they don't seem to update and just stay in place, even if the player moves...) Will post updates as I go!
If anyone's still interested in getting a light for the player, try this (hope you don't mind me messing around with your script ;)

At the top, create a variable: DEFAULT_RADIUS = 100 and change the value to what you want the player's light radius to be.

In "create_lights" (line 295), add the following segment above the line "for event in $game_map.events.values":
  1.  def create_lights
  2.     if $game_switches[CAVE_SWITCH] == true
  3.       @lights[$game_player] = Light.new($game_player, DEFAULT_RADIUS)
  4.     elsif @lights[$game_player] != nil
  5.       @lights.delete($game_player)
  6.     end
  7.    
  8.     for event in $game_map.events.values
  9.       ...
  10.     end
  11.   end
Expand to see the code.


In "def update", add the following before the last end (line 441):
  1.  def update
  2.     ...
  3.     for light in @lights.values
  4.       if light.x != light.old_x or light.y != light.old_y
  5.       refresh
  6.       return
  7.     end
  8.  
  9.   end
Expand to see the code.

Finally, change "class Light" (line 461) to the following:
  1. class Light
  2.   attr_reader :old_x
  3.   attr_reader :old_y
  4.  
  5.   def initialize(event, size)
  6.     @event = event
  7.     @size = size
  8.     @old_x = self.x
  9.     @old_y = self.y
  10.   end
  11.   def size
  12.     return @size
  13.   end
  14.   def x
  15.     return @event.real_x/4 + 16
  16.   end
  17.   def y
  18.     return @event.real_y/4 + 16
  19.   end
  20. end
Expand to see the code.





Unfortunately, the downside to moving lights is that it lags. A LOT. If you have at least two lights overlapping, and one of them moves, refreshing every frame will drain the frame rate (for me, combined with my pixelmovement ABS scripts, down to around 7fps on a large map :sad: ). I've identified the problem to be the "sub" function. Gonna hand this over to any scripting gurus out there, any way to make it more efficient?
I just tried it but was getting several errors so I switched back and besides until the lag is removed from moving lights I'd rather not use it, but it's nice people are still trying to fix this script.

I hope someday it gets fixed, I really would love a sort of light source I could use on my character when you find a flash light for example which can be switched on/off.
Oops, sorry. What errors are you getting? I'll try and test it on a clean project later and see how much it lags then.
It shouldnt lag is it only updates lights in a viewport correct? Maybe Ill give it one more go ^^
Fixed my above post, it should work now.
Unfortunately the lag issue still stands... I think partly because instead of updating each light individually, it refreshes the whole nighttime effect (every single light). When I have time later I'll look into creating a refresh function for each individual light sprite.
EDIT LOG:

I get an error as well its the way the accessors in Class Light are set up, they should be
  1.  
  2. attr_accessor :old_x
  3. attr_accessor :old_y
  4.  
Expand to see the code.


instead of

  1.  
  2. attr_accessor: old_x
  3. attr_accessor: old_y
  4.  
Expand to see the code.



EDIT:


I honestly think it would be easier to do this in VX/RGSS2 because you would be able to clear_rect, and set the rect as the portions between graphics in contact, then use the blt function to set the graphic without lag. I did so in XP, minus the clearing of rects, I also tried using sprites with the same idea, and clearing their bitmap contact location with the fill_rect(rect, Color.new(0,0,0,0)) function it worked, but parts of the graphic still mixed up with others creating an area that was darker than the dark itself, theoretically, this could work if you didnt mind making the darkness only be a set opacity of 255, so total darkness with parts of sprites cut up to match up with others.

EDIT 2: Because that .sub function just kills the render speed, I even tried speeding up the frame rate, I tried only subbing ones the player is in contact with, but again same killer frame rate >< of 4 frames a sec lol
Yup, sorry. I caught that and a few other errors (updated in my post back there) in case you didn't notice.
Ok so I tried it again but I am getting an error on this line:


  1.   alias dns_dispose dispose
Expand to see the code.


Line 533

undefined method 'dispose' for class 'Nighttime::Spriteset_Map'

Now it could be some confliction with some other script I use (Probably blizz abs) just like gubbid edited version of this script that has functional lights going off without having to leave the map or open/close menu to update if visible or not but I just wanted to point it out.
Try switching out the

  1. alias dns_dispose dispose
Expand to see the code.


with your own and replacing the dns_dispose with your own,it could be conflicting

try using
  1.  
  2. alias reaper0001_dispose dispose
  3. def dispose
  4. [...]
  5. reaper0001_dispose
  6. [...]
  7. end
  8.  
  9. #instead of:
  10.  
  11. alias dns_dispose dispose
  12. def dispose
  13. [...]
  14. dns_dispose
  15. [...]
  16. end
  17.  
  18.  
Expand to see the code.


[...] Is just my way of substituting prior content. SO find dns_dispose in the def dispose and change it as well.
PandoraShock wrote:
I honestly think it would be easier to do this in VX/RGSS2 because you would be able to clear_rect, and set the rect as the portions between graphics in contact, then use the blt function to set the graphic without lag. I did so in XP, minus the clearing of rects, I also tried using sprites with the same idea, and clearing their bitmap contact location with the fill_rect(rect, Color.new(0,0,0,0)) function it worked, but parts of the graphic still mixed up with others creating an area that was darker than the dark itself, theoretically, this could work if you didnt mind making the darkness only be a set opacity of 255, so total darkness with parts of sprites cut up to match up with others.

EDIT 2: Because that .sub function just kills the render speed, I even tried speeding up the frame rate, I tried only subbing ones the player is in contact with, but again same killer frame rate >< of 4 frames a sec lol

Hey, thanks for trying! Out of curiosity, could you post the code for using sprites and the fill_rect(rect, Color.new(0,0,0,0)) function? I'd like to see how you did it (and in my project, the darkness is always 255 anyway :P).
regi wrote:
PandoraShock wrote:
I honestly think it would be easier to do this in VX/RGSS2 because you would be able to clear_rect, and set the rect as the portions between graphics in contact, then use the blt function to set the graphic without lag. I did so in XP, minus the clearing of rects, I also tried using sprites with the same idea, and clearing their bitmap contact location with the fill_rect(rect, Color.new(0,0,0,0)) function it worked, but parts of the graphic still mixed up with others creating an area that was darker than the dark itself, theoretically, this could work if you didnt mind making the darkness only be a set opacity of 255, so total darkness with parts of sprites cut up to match up with others.

EDIT 2: Because that .sub function just kills the render speed, I even tried speeding up the frame rate, I tried only subbing ones the player is in contact with, but again same killer frame rate >< of 4 frames a sec lol

Hey, thanks for trying! Out of curiosity, could you post the code for using sprites and the fill_rect(rect, Color.new(0,0,0,0)) function? I'd like to see how you did it (and in my project, the darkness is always 255 anyway :P).




FUUUUU!!! XD I deleted it, and CCleaned b4 getting on HBgames, Q_Q I'm so sorry! When I get some time I'll re-do it!

EDIT: Working on it now, I'm going to try to use Graphics.frame_reset to help speed it up, as well as try to set it up in RGSS2

EDIT 2:

Image That is the problem Im talking about. But I have a solution... Instead of drawing all this stuff in a Sprite single... sprite, we could draw each glow on its own Sprite, then have a fill.. which would be 640, 480 in size (doesnt need to scale to the map), the glow sprites would clear... or fill a rect with Color.new(0,0,0,0) at their location in the fill for the night, something like:

  1.  
  2. @fillnight.bitmap.full_rect(light_rect, Color.new(0,0,0,0))
  3.  
Expand to see the code.


Then we could have a for loop, for catching if any of the lights are in another lights area, and if they are they cut out the touching portions of each light touching.

its either that... or we could make the light its own... Autotile?, and have it draw itself as if it was an auto tile, so parts that connect would move together to create 1 light instead of 2+, I kinda like this idea better because it would take less sprites and.. would look pretty damn cool...

Just my thoughts here is my current edit of the script.
  1.  
  2. =begin
  3. ---------------------------------------------
  4. DAY_NIGHT_LIGHT_SYSTEM
  5. ---------------------------------------------
  6. by
  7. - Brewmeister
  8. - Gubid
  9. - Star
  10. ---------------------------------------------
  11. =end
  12.  
  13.  
  14. #-----------------------------------
  15. # Editing of the Script
  16. #-----------------------------------
  17.  
  18.  
  19. # How many real time minutes does it take for a whole gameday to go by?
  20. # Normal time would be 24 minutes so a minute in game goes by every second.
  21. #-----------------------------------
  22. GAME_DAY_IN_REAL_MINUTES = 24
  23.  
  24.  
  25. # Current_Game_Day is the variable of the current day
  26. #-----------------------------------
  27. CURRENT_GAME_DAY = 15
  28.  
  29. # Day you want Game_Day to start at.
  30. #-----------------------------------
  31. INTIALIZE_GAME_DAY = 1
  32.  
  33.  
  34. # If Flickercolon is true the : in the 00:00 flashes every second
  35. #-----------------------------------
  36. FLICKERCOLON = true
  37.  
  38. # Hour_variable is the variable of the current hour
  39. #-----------------------------------
  40. HOUR_VARIABLE = 9
  41.  
  42. # Inside_Switch is the switch set to make insides darker, not meant for caves
  43. #-----------------------------------
  44. INSIDE_SWITCH = 9
  45.  
  46. # Inside_Opacity is the opacity set to increase when entering insides
  47. #-----------------------------------
  48. INSIDE_OPACITY = 10
  49.  
  50. # Cave_Switch is the switch set meant for caves
  51. #-----------------------------------
  52. CAVE_SWITCH = 11
  53.  
  54. # Cave_Opacity is the total opacity you want when entering caves.  Generally
  55. # Should be set higher than the highest darkness.
  56. #-----------------------------------
  57. CAVE_OPACITY = 220
  58.  
  59. # if AM_AND_PM is true, everything is not in military time
  60. #-----------------------------------
  61. AM_AND_PM = true
  62.  
  63. # Starthour is the hour the game starts at
  64. #-----------------------------------
  65. STARTHOUR = 2
  66.  
  67. # New_hour is the variable that changes the current hour.  You must use this in
  68. # order to change the hour.  It will not tell you the current hour, only
  69. # Hour_variable can tell the current hour.
  70. #-----------------------------------
  71. NEW_HOUR = 10
  72.  
  73. # Set this switch to on in order to hide the clock
  74. #-----------------------------------
  75. INVISIBLE_TIMER_SWITCH = 10
  76. DEFAULT_RADIUS = 200
  77.  
  78.  
  79. #---------------------------------------------
  80. #Bitmap
  81. #---------------------------------------------
  82. class Bitmap
  83.   def sub(ox,oy,light)
  84.     ox -= (light.width / 2)
  85.     oy -= (light.height / 2)
  86.     for x in 0...light.width
  87.       for y in 0...light.height
  88.         lt_color = light.get_pixel(x,y)
  89.         ds_color = self.get_pixel(x + ox,y + oy)
  90.         ds_color.alpha -= lt_color.alpha
  91.         self.set_pixel(x + ox,y + oy,ds_color)
  92.       end
  93.     end
  94.   end
  95. end
  96.  
  97. #---------------------------------------------
  98. #end Bitmap
  99. #---------------------------------------------
  100.  
  101.  
  102. #---------------------------------------------
  103. #Game_System
  104. #---------------------------------------------
  105. class Game_System  
  106.   alias init_gme_sys initialize
  107.   def initialize
  108.     init_gme_sys
  109.     @timer_working = true
  110.     @timer_remember = 0
  111.     @timer = STARTHOUR * 2400
  112.   end
  113. def update
  114.     # reduce timer by 1
  115.     if @timer_working
  116.       if @timer > 57600
  117.         @timer = 0
  118.          $game_variables[CURRENT_GAME_DAY] += 1
  119.       else
  120.           if @timer_remember != 0 and @timer != @timer_remember
  121.           @timer = @timer_remember
  122.           @timer_remember = 0
  123.           else
  124.           @timer += (1 * (24/GAME_DAY_IN_REAL_MINUTES))
  125.           end
  126.       end
  127.     elsif @timer_remember != @timer and @timer_working == false
  128.       @timer_remember = @timer
  129.     end
  130.   end
  131. end
  132.  
  133. #---------------------------------------------
  134. #end Game_System
  135. #---------------------------------------------
  136.  
  137.  
  138.  
  139.  
  140. #---------------------------------------------
  141. #Sprite_Timer
  142. #---------------------------------------------
  143. class Sprite_Timer < Sprite
  144.   def initialize
  145.     super
  146.     self.bitmap = Bitmap.new(120, 20)
  147.     self.bitmap.font.name = "Arial"
  148.     self.bitmap.font.size = 15
  149.     self.x = 620 - self.bitmap.width
  150.     self.y = 0
  151.     self.z = 2000
  152.     @flicker = true
  153.     if $game_variables[CURRENT_GAME_DAY] < INTIALIZE_GAME_DAY
  154.       $game_variables[CURRENT_GAME_DAY] = INTIALIZE_GAME_DAY
  155.       end
  156.     update
  157.   end
  158.   def update
  159.     super
  160.     # Set timer to visible if working
  161.     if $game_switches[INVISIBLE_TIMER_SWITCH] == true
  162.     self.visible = false
  163.   else
  164.     self.visible = true
  165.     end
  166.         if $game_variables[NEW_HOUR] != 0 and
  167.            $game_variables[NEW_HOUR] != $game_variables[HOUR_VARIABLE]
  168.       $game_system.timer = $game_variables[NEW_HOUR] * 2400
  169.       if  $game_system.timer > 57600
  170.         $game_system.timer % 57600
  171.         $game_variables[CURRENT_GAME_DAY] += 1
  172.       end
  173.       $game_variables[NEW_HOUR] = 0
  174.       end
  175.     # If timer needs to be redrawn
  176.       if $game_system.timer / Graphics.frame_rate != @total_sec and $game_system.timer_working
  177.       # Clear window contents
  178.       self.bitmap.clear
  179.       # Calculate total number of seconds
  180.       @total_sec = $game_system.timer / Graphics.frame_rate
  181.       # Make a string for displaying the timer
  182.       case $game_variables[HOUR_VARIABLE]
  183.       when 0,1,2,3,4,5,18,19,20,21,22,23,24
  184.       moon_and_sun = RPG::Cache.picture("Moon")
  185.       cw = moon_and_sun.width
  186.       ch = moon_and_sun.height
  187.       rect = Rect.new(0, 0, cw, ch)
  188.       when 6,7,8,9,10,11,12,13,14,15,16,17
  189.       moon_and_sun = RPG::Cache.picture("Sun")
  190.       cw = moon_and_sun.width
  191.       ch = moon_and_sun.height
  192.       rect = Rect.new(0, 0, cw, ch)
  193.     end
  194.       if $game_variables[HOUR_VARIABLE] > 24
  195.       moon_and_sun = RPG::Cache.picture("Moon")
  196.       cw = moon_and_sun.width
  197.       ch = moon_and_sun.height
  198.       rect = Rect.new(0, 0, cw, ch)
  199.       end
  200.       if AM_AND_PM == true
  201.         if $game_variables[HOUR_VARIABLE] > 12
  202.           min = (@total_sec - 720) / 60
  203.           sec = @total_sec % 60
  204.         else
  205.           min = @total_sec / 60
  206.           sec = @total_sec % 60
  207.         end
  208.             if $game_variables[HOUR_VARIABLE] > 11 and $game_variables[HOUR_VARIABLE] != 24
  209.               setting = "PM"
  210.             else
  211.               setting = "AM"
  212.             end
  213.             if FLICKERCOLON == true and @flicker == false
  214.             text = sprintf("%02d %02d " + setting, min, sec)
  215.              @flicker = true
  216.           else
  217.             text = sprintf("%02d:%02d " + setting, min, sec)
  218.             if FLICKERCOLON == true
  219.               @flicker = false
  220.             end
  221.           end
  222.       else
  223.         min = @total_sec / 60
  224.         sec = @total_sec % 60
  225.         text = sprintf("%02d:%02d", min, sec)
  226.         end
  227.       if $game_variables[HOUR_VARIABLE] > 12 and AM_AND_PM == true
  228.       $game_variables[HOUR_VARIABLE] = min + 12
  229.       else
  230.       $game_variables[HOUR_VARIABLE] = min
  231.       end
  232.       $sec = sec
  233.       # Draw timer
  234.       rect2 = Rect.new(1, 1, 120, 20)
  235.       self.bitmap.font.color.set(0, 0, 0)
  236.       self.bitmap.draw_text(rect2, text, 1)
  237.       self.bitmap.font.color.set(255, 255, 255)
  238.       self.bitmap.draw_text(self.bitmap.rect, text, 1)
  239.       self.bitmap.blt(90, 0, moon_and_sun, rect)
  240.       end
  241.   end
  242. end
  243.  
  244. #---------------------------------------------
  245. #end Sprite_Timer
  246. #---------------------------------------------
  247.  
  248. #---------------------------------------------
  249. #Game_Event
  250. #---------------------------------------------
  251. class Game_Event < Game_Character
  252.   attr_reader :erased
  253.   attr_accessor :is_light
  254.   alias init_gm_evnt_lights initialize
  255.   def initialize(*args)
  256.     init_gm_evnt_lights(*args)
  257.     @is_light = false
  258.   end
  259.   alias refresh_gm_evnt_lights refresh
  260.   def refresh
  261.     tmp_page = @page
  262.     refresh_gm_evnt_lights
  263.     if tmp_page != @page
  264.       @is_light = false
  265.     end
  266.   end
  267. end
  268.  
  269. #---------------------------------------------
  270. #end Game_Event
  271. #---------------------------------------------
  272.  
  273. #---------------------------------------------
  274. #Sprite_Nighttime
  275. #---------------------------------------------
  276.  
  277. class Nighttime < Sprite
  278.   def initialize(x,y)
  279.     super()
  280.     @width = $game_map.width * 32
  281.     @height = $game_map.height * 32
  282.     @lights = {}
  283.     self.x = x
  284.     self.y = y
  285.     self.bitmap = Bitmap.new(@width, @height)
  286.     self.bitmap.clear
  287.     fillnight
  288.   end
  289.   def refresh(ox=nil, nx=nil, oy=nil, ny=nil, size=nil)
  290.     self.bitmap.clear
  291.     create_lights if @change == nil
  292.     fillnight(ox, nx, oy, ny, size)
  293.   end
  294.  
  295.   def create_lights
  296.    
  297.     if $game_switches[CAVE_SWITCH] == true
  298.       @lights[$game_player] = Light.new($game_player, DEFAULT_RADIUS)
  299.     elsif @lights[$game_player] != nil
  300.       @lights.delete($game_player)
  301.     end
  302.    
  303.     for event in $game_map.events.values
  304.       for i in 0...event.list.size
  305.         if event.list[i].code == 108 #comment
  306.           if event.erased and event.list[i].parameters[0].include?("light")
  307.             @lights.delete(event)
  308.             next
  309.           elsif event.list[i].parameters[0].include?("light")
  310.             size = event.list[i].parameters[0].delete("light").to_i #convert text to interger
  311.             @lights[event] = Light.new(event, size) unless @lights.keys.include?(event)
  312.             event.is_light = true
  313.             next
  314.           end
  315.         end
  316.       end
  317.       #in the event page is changed and it is no longer a light.. remove it.
  318.       if @lights[event] != nil and event.is_light == false
  319.         @lights.delete(event)
  320.        end
  321.     end
  322.   end
  323.   def fillnight(ox=nil, nx=nil, oy=nil, ny=nil, size=nil)
  324.     if $sec == nil
  325.       $sec = 0
  326.     end
  327.     if $game_switches[INSIDE_SWITCH] == true
  328.       extralpha = INSIDE_OPACITY
  329.     else
  330.       extralpha = 0
  331.       end
  332.      case $game_variables[HOUR_VARIABLE]
  333.     when 0, 1, 23
  334.     startop = 210 - extralpha
  335.     when 2
  336.     startop = 210 - ($sec / 2) + extralpha
  337.     when 3
  338.     startop = 180 - ($sec / 2) + extralpha
  339.     when 4
  340.     startop = 150 - ($sec / 2) + extralpha
  341.     when 5
  342.     startop = 120 - ($sec / 2) + extralpha
  343.     when 6
  344.     startop = 90 - ($sec / 2) + extralpha
  345.     when 7
  346.     startop = 60 - ($sec / 2) + extralpha
  347.     when 8
  348.     startop = 30 - ($sec / 2) + extralpha
  349.     when 9, 10, 11, 12, 13, 14, 15
  350.     startop = 0 + extralpha
  351.     when 16
  352.     startop = 0 + ($sec / 2) + extralpha
  353.     when 17
  354.     startop = 30 + ($sec / 2) + extralpha
  355.     when 18
  356.     startop = 60 + ($sec / 2) + extralpha
  357.     when 19
  358.     startop = 90 + ($sec / 2) + extralpha
  359.     when 20
  360.     startop = 120 + ($sec / 2) + extralpha
  361.     when 21
  362.     startop = 150 + ($sec / 2) + extralpha
  363.     when 22
  364.     startop = 180 + ($sec / 2) + extralpha
  365.   end
  366.   if $game_switches[CAVE_SWITCH] == true
  367.     startop = CAVE_OPACITY
  368.     end
  369.    
  370.     self.bitmap.fill_rect(0, 0, @width, @height, Color.new(0,0,0,255))
  371.     #image_sub = RPG::Cache.picture("LightSUB").clone
  372.    # image_blt = RPG::Cache.picture("LightBLT").clone
  373.     #base_rect = image_sub.rect
  374.    # lwidth = (size/100.0)
  375.    # s = base_rect.width*lwidth
  376.    # self.bitmap.fill_rect(ox, oy, s, s, Color.new(0,0,0,0))
  377.     self.opacity = startop
  378.     # Now subtract out the lights
  379.     # Testing with a single light at tile 7,11
  380.     apply_lights(nx, ny)
  381.   end
  382.   def apply_lights(nx, ny)
  383.     applied_space = []
  384.        
  385.     for light in @lights.values
  386.       image_sub = RPG::Cache.picture("LightSUB").clone
  387.       image_blt = RPG::Cache.picture("LightBLT").clone
  388.       base_rect = image_sub.rect
  389.       overlapLights = []
  390.       size = (light.size/100.0)
  391.       lwidth = base_rect.width*size
  392.       light_rect = Rect.new(light.x-(lwidth/2), light.y-(lwidth/2), lwidth, lwidth)
  393.       for applied_rect in applied_space
  394.         if light_rect.overlap?(applied_rect)
  395.           overlapLights << light_rect.area_in_overlap(applied_rect)
  396.         end
  397.       end
  398.       #now draw it
  399.       if overlapLights.size == 0 #no overlap detected.. then just BLT it into the image
  400.         self.bitmap.fill_rect(light_rect, Color.new(0,0,0,0))
  401.         self.bitmap.stretch_blt(light_rect, image_blt, base_rect)
  402.       else
  403.        
  404.         light_rect = Rect.new(light.x-(lwidth/2), light.y-(lwidth/2), lwidth, lwidth)
  405.         self.bitmap.fill_rect(light_rect, Color.new(0,0,0,0))
  406.         self.bitmap.stretch_blt(light_rect, image_blt, base_rect)
  407.       end
  408.       applied_space << light_rect
  409.       image_sub.dispose
  410.       image_blt.dispose
  411.     end
  412.   end
  413.   def update
  414.     if $game_switches[INSIDE_SWITCH] == true
  415.       extralpha = INSIDE_OPACITY
  416.     else
  417.       extralpha = 0
  418.       end
  419.     case $game_variables[HOUR_VARIABLE]
  420.     when 0, 1, 23
  421.     self.opacity = 210 - extralpha
  422.     when 2
  423.     self.opacity = 210 - ($sec / 2) + extralpha
  424.     when 3
  425.     self.opacity = 180 - ($sec / 2) + extralpha
  426.     when 4
  427.     self.opacity = 150 - ($sec / 2) + extralpha
  428.     when 5
  429.     self.opacity = 120 - ($sec / 2) + extralpha
  430.     when 6
  431.     self.opacity = 90 - ($sec / 2) + extralpha
  432.     when 7
  433.     self.opacity = 60 - ($sec / 2) + extralpha
  434.     when 8
  435.     self.opacity = 30 - ($sec / 2) + extralpha
  436.     when 9, 10, 11, 12, 13, 14, 15
  437.     self.opacity = 0 + extralpha
  438.     when 16
  439.     self.opacity = 0 + ($sec / 2) + extralpha
  440.     when 17
  441.     self.opacity = 30 + ($sec / 2) + extralpha
  442.     when 18
  443.     self.opacity = 60 + ($sec / 2) + extralpha
  444.     when 19
  445.     self.opacity = 90 + ($sec / 2) + extralpha
  446.     when 20
  447.     self.opacity = 120 + ($sec / 2) + extralpha
  448.     when 21
  449.     self.opacity = 150 + ($sec / 2) + extralpha
  450.     when 22
  451.     self.opacity = 180 + ($sec / 2) + extralpha
  452.     end
  453.       if $game_switches[CAVE_SWITCH] == true
  454.     startop = CAVE_OPACITY
  455.    
  456.   end
  457.  
  458.   @oswitch =  false if @oswitch == nil
  459.  
  460.   if $game_switches[CAVE_SWITCH] == true
  461.   @oswitch = true
  462. else
  463.   @oswitch = false
  464.   @change = nil
  465.   @time = nil
  466.   end
  467.  
  468.   if @time != nil and @time == 1
  469.     @change = true
  470.     @time += 1
  471.   end
  472.  
  473.   for light in @lights.values
  474.       if light.x != light.old_x or light.y != light.old_y or (@oswitch == true and @times == nil)
  475.       refresh(light.x, light.old_x, light.y, light.old_y, light.size)
  476.       Graphics.frame_reset
  477.       @oswitch = false
  478.       @times = 1
  479.       return
  480.       end
  481.    
  482.      
  483.   end
  484.  
  485.   end
  486.  
  487.  
  488.    
  489. end
  490.  
  491.  
  492.  
  493. class Rect
  494.   def overlap?(rect)
  495.     corners = []
  496.     corners << [rect.x, rect.y] #UL
  497.     corners << [rect.x+rect.width, rect.y] #UR
  498.     corners << [rect.x+rect.width, rect.y+height] #LR
  499.     corners << [rect.x, rect.y+height] #LL
  500.     for corner in corners
  501.       if corner[0].between?(self.x, self.x+width) and corner[1].between?(self.y, self.y+height)
  502.         return true
  503.       end
  504.     end
  505.     return false
  506.   end
  507.   def area_in_overlap(rect)
  508.     return rect
  509.   end
  510. end
  511.  
  512. #---------------------------------------------
  513. #Class Light
  514. #---------------------------------------------
  515.  
  516. class Light
  517.   attr_reader :old_x
  518.   attr_reader :old_y
  519.  
  520.   def initialize(event, size)
  521.     @event = event
  522.     @size = size
  523.     @old_x = self.x
  524.     @old_y = self.y
  525.   end
  526.  
  527.   def size
  528.     return @size
  529.   end
  530.  
  531.   def x
  532.     return @event.real_x/4 + 16
  533.   end
  534.  
  535.   def y
  536.     return @event.real_y/4 + 16
  537.   end
  538. end
  539.  
  540.  
  541. #---------------------------------------------
  542. #end Sprite_Nighttime
  543. #---------------------------------------------
  544.  
  545. #---------------------------------------------
  546. #Spriteset_Map
  547. #---------------------------------------------
  548. class Spriteset_Map
  549.   alias init_spr_map_lights initialize
  550.   def initialize
  551.     # Make nighttime sprite
  552.     @nighttime = Nighttime.new(0,0)
  553.     @nighttime.z = 2000
  554.     init_spr_map_lights
  555.     @nighttime.refresh
  556.     @map_idd = $game_map.map_id
  557.   end
  558.    alias dns_dispose dispose
  559.    def dispose
  560.      dns_dispose
  561.      @nighttime.dispose
  562.    end
  563.   alias upd_spr_map_lights update
  564.   def update
  565.     upd_spr_map_lights
  566.     # Update nighttime sprite
  567.     @nighttime.ox = $game_map.display_x / 4
  568.     @nighttime.oy = $game_map.display_y / 4
  569.     if @hour_day != $game_variables[HOUR_VARIABLE]
  570.       $game_map.refresh
  571.       @hour_day = $game_variables[HOUR_VARIABLE]
  572.       end
  573.     if @map_idd != $game_map.map_id
  574.       @nighttime.refresh
  575.       @map_idd = $game_map.map_id
  576.       end
  577.     @nighttime.update
  578.   end
  579. end
  580. #---------------------------------------------
  581. #end Spriteset_Map
  582. #---------------------------------------------
  583.  
Expand to see the code.
I get a no method error on line 299 with your version pandora.

Undefined method 'size' for nil:NilCLass

On one map I didn't get an error but when I tried on another map that error pops up.
The autotile is a pretty cool idea, but sadly, only works if there's no/less of an opacity gradient, because the image is too small to capture (e.g. see Wachunga's fog of war: there's no gradient, it just goes from darkness to clear):
Image

Unless we rewrite a new autotile feature that uses a larger image, it's going to be difficult to work :\
(Here's the one I tried to make, you can check it out and see the glitches for yourself.)
Image

EDIT: working on a new one that's a larger sprite, gotta fix the upper-right corner but I'll see how it turns out later today:
Image

I definitely like your idea of drawing each sprite separately and filling the map with darkness, though.
Looks nice Regi, ill take a look at some coding for the autotiles see how they are put together in script.

:)

EDIT: Ill also take a look at the sprite version too
When i saw that autotile I thought you could do the lights like the script by using it while creating maps but it only makes small circles hehe

If someone manages to make an almost lag free light around the character with the possibility on increasing it's range with a script call I was thinking on the possibility of having my project set during the night all the time.
Maybe what you could do with the lights is instead of setting the rbg value of each pixel, you could add to it. That would stop all the messed up overlaps.

Edit. Ignore this post. I just checked the source.
Still haven't given up on the lighting system. I've been thinking of a new method that could possibly have MUCH less lag.

Rather than redrawing the entire darkness sprite, each light would have its unique sprite, just like Sprite_Character. We would then use @blend_type = 2 (subtraction) to use the built-in subtraction feature. My only question is would "sub" work for non-character and non-picture sprites? I have little experience working with graphics, and would much appreciate any assistance.
So sprites have a blend_type variable? I'll get to work on this, it sounds really easy.

Edit. I might have made it work... maybe...
  1.  
  2.      
  3.     =begin
  4.     ---------------------------------------------
  5.     DAY_NIGHT_LIGHT_SYSTEM
  6.     ---------------------------------------------
  7.     by
  8.     - Brewmeister
  9.     - Gubid
  10.     - Star
  11.     ---------------------------------------------
  12.     =end
  13.      
  14.      
  15.     #-----------------------------------
  16.     # Editing of the Script
  17.     #-----------------------------------
  18.      
  19.      
  20.     # How many real time minutes does it take for a whole gameday to go by?
  21.     # Normal time would be 24 minutes so a minute in game goes by every second.
  22.     #-----------------------------------
  23.     GAME_DAY_IN_REAL_MINUTES = 24
  24.      
  25.      
  26.     # Current_Game_Day is the variable of the current day
  27.     #-----------------------------------
  28.     CURRENT_GAME_DAY = 15
  29.      
  30.     # Day you want Game_Day to start at.
  31.     #-----------------------------------
  32.     INTIALIZE_GAME_DAY = 1
  33.      
  34.      
  35.     # If Flickercolon is true the : in the 00:00 flashes every second
  36.     #-----------------------------------
  37.     FLICKERCOLON = true
  38.      
  39.     # Hour_variable is the variable of the current hour
  40.     #-----------------------------------
  41.     HOUR_VARIABLE = 9
  42.      
  43.     # Inside_Switch is the switch set to make insides darker, not meant for caves
  44.     #-----------------------------------
  45.     INSIDE_SWITCH = 9
  46.      
  47.     # Inside_Opacity is the opacity set to increase when entering insides
  48.     #-----------------------------------
  49.     INSIDE_OPACITY = 10
  50.      
  51.     # Cave_Switch is the switch set meant for caves
  52.     #-----------------------------------
  53.     CAVE_SWITCH = 11
  54.      
  55.     # Cave_Opacity is the total opacity you want when entering caves.  Generally
  56.     # Should be set higher than the highest darkness.
  57.     #-----------------------------------
  58.     CAVE_OPACITY = 220
  59.      
  60.     # if AM_AND_PM is true, everything is not in military time
  61.     #-----------------------------------
  62.     AM_AND_PM = true
  63.      
  64.     # Starthour is the hour the game starts at
  65.     #-----------------------------------
  66.     STARTHOUR = 2
  67.      
  68.     # New_hour is the variable that changes the current hour.  You must use this in
  69.     # order to change the hour.  It will not tell you the current hour, only
  70.     # Hour_variable can tell the current hour.
  71.     #-----------------------------------
  72.     NEW_HOUR = 10
  73.      
  74.     # Set this switch to on in order to hide the clock
  75.     #-----------------------------------
  76.     INVISIBLE_TIMER_SWITCH = 10
  77.    
  78.     # Set this switch to on to give the player a light
  79.     #-----------------------------------
  80.     FLASHLIGHT_SWITCH = 12
  81.     FLASHLIGHT_SIZE = 100
  82.      
  83.      
  84.      
  85.     #---------------------------------------------
  86.     #Bitmap
  87.     #---------------------------------------------
  88.     class Bitmap
  89.       def sub(ox,oy,light)
  90.         ox -= (light.width / 2)
  91.         oy -= (light.height / 2)
  92.         for x in 0...light.width
  93.           for y in 0...light.height
  94.             lt_color = light.get_pixel(x,y)
  95.             ds_color = self.get_pixel(x + ox,y + oy)
  96.             ds_color.alpha -= lt_color.alpha
  97.             self.set_pixel(x + ox,y + oy,ds_color)
  98.           end
  99.         end
  100.       end
  101.     end
  102.      
  103.     #---------------------------------------------
  104.     #end Bitmap
  105.     #---------------------------------------------
  106.      
  107.      
  108.     #---------------------------------------------
  109.     #Game_System
  110.     #---------------------------------------------
  111.     class Game_System  
  112.       alias init_gme_sys initialize
  113.       def initialize
  114.         init_gme_sys
  115.         @timer_working = true
  116.         @timer_remember = 0
  117.         @timer = STARTHOUR * 2400
  118.       end
  119.     def update
  120.         # reduce timer by 1
  121.         if @timer_working
  122.           if @timer > 57600
  123.             @timer = 0
  124.              $game_variables[CURRENT_GAME_DAY] += 1
  125.           else
  126.               if @timer_remember != 0 and @timer != @timer_remember
  127.               @timer = @timer_remember
  128.               @timer_remember = 0
  129.               else
  130.               @timer += (1 * (24/GAME_DAY_IN_REAL_MINUTES))
  131.               end
  132.           end
  133.         elsif @timer_remember != @timer and @timer_working == false
  134.           @timer_remember = @timer
  135.         end
  136.       end
  137.     end
  138.      
  139.     #---------------------------------------------
  140.     #end Game_System
  141.     #---------------------------------------------
  142.      
  143.      
  144.      
  145.      
  146.     #---------------------------------------------
  147.     #Sprite_Timer
  148.     #---------------------------------------------
  149.     class Sprite_Timer < Sprite
  150.       def initialize
  151.         super
  152.         self.bitmap = Bitmap.new(120, 20)
  153.         self.bitmap.font.name = "Arial"
  154.         self.bitmap.font.size = 15
  155.         self.x = 620 - self.bitmap.width
  156.         self.y = 0
  157.         self.z = 2000
  158.         @flicker = true
  159.         if $game_variables[CURRENT_GAME_DAY] < INTIALIZE_GAME_DAY
  160.           $game_variables[CURRENT_GAME_DAY] = INTIALIZE_GAME_DAY
  161.           end
  162.         update
  163.       end
  164.       def update
  165.         super
  166.         # Set timer to visible if working
  167.         if $game_switches[INVISIBLE_TIMER_SWITCH] == true
  168.         self.visible = false
  169.       else
  170.         self.visible = true
  171.         end
  172.             if $game_variables[NEW_HOUR] != 0 and
  173.                $game_variables[NEW_HOUR] != $game_variables[HOUR_VARIABLE]
  174.           $game_system.timer = $game_variables[NEW_HOUR] * 2400
  175.           if  $game_system.timer > 57600
  176.             $game_system.timer % 57600
  177.             $game_variables[CURRENT_GAME_DAY] += 1
  178.           end
  179.           $game_variables[NEW_HOUR] = 0
  180.           end
  181.         # If timer needs to be redrawn
  182.           if $game_system.timer / Graphics.frame_rate != @total_sec and $game_system.timer_working
  183.           # Clear window contents
  184.           self.bitmap.clear
  185.           # Calculate total number of seconds
  186.           @total_sec = $game_system.timer / Graphics.frame_rate
  187.           # Make a string for displaying the timer
  188.           case $game_variables[HOUR_VARIABLE]
  189.           when 0,1,2,3,4,5,18,19,20,21,22,23,24
  190.           moon_and_sun = RPG::Cache.picture("Moon")
  191.           cw = moon_and_sun.width
  192.           ch = moon_and_sun.height
  193.           rect = Rect.new(0, 0, cw, ch)
  194.           when 6,7,8,9,10,11,12,13,14,15,16,17
  195.           moon_and_sun = RPG::Cache.picture("Sun")
  196.           cw = moon_and_sun.width
  197.           ch = moon_and_sun.height
  198.           rect = Rect.new(0, 0, cw, ch)
  199.         end
  200.           if $game_variables[HOUR_VARIABLE] > 24
  201.           moon_and_sun = RPG::Cache.picture("Moon")
  202.           cw = moon_and_sun.width
  203.           ch = moon_and_sun.height
  204.           rect = Rect.new(0, 0, cw, ch)
  205.           end
  206.           if AM_AND_PM == true
  207.             if $game_variables[HOUR_VARIABLE] > 12
  208.               min = (@total_sec - 720) / 60
  209.               sec = @total_sec % 60
  210.             else
  211.               min = @total_sec / 60
  212.               sec = @total_sec % 60
  213.             end
  214.                 if $game_variables[HOUR_VARIABLE] > 11 and $game_variables[HOUR_VARIABLE] != 24
  215.                   setting = "PM"
  216.                 else
  217.                   setting = "AM"
  218.                 end
  219.                 if FLICKERCOLON == true and @flicker == false
  220.                 text = sprintf("%02d %02d " + setting, min, sec)
  221.                  @flicker = true
  222.               else
  223.                 text = sprintf("%02d:%02d " + setting, min, sec)
  224.                 if FLICKERCOLON == true
  225.                   @flicker = false
  226.                 end
  227.               end
  228.           else
  229.             min = @total_sec / 60
  230.             sec = @total_sec % 60
  231.             text = sprintf("%02d:%02d", min, sec)
  232.             end
  233.           if $game_variables[HOUR_VARIABLE] > 12 and AM_AND_PM == true
  234.           $game_variables[HOUR_VARIABLE] = min + 12
  235.           else
  236.           $game_variables[HOUR_VARIABLE] = min
  237.           end
  238.           $sec = sec
  239.           # Draw timer
  240.           rect2 = Rect.new(1, 1, 120, 20)
  241.           self.bitmap.font.color.set(0, 0, 0)
  242.           self.bitmap.draw_text(rect2, text, 1)
  243.           self.bitmap.font.color.set(255, 255, 255)
  244.           self.bitmap.draw_text(self.bitmap.rect, text, 1)
  245.           self.bitmap.blt(90, 0, moon_and_sun, rect)
  246.           end
  247.       end
  248.     end
  249.      
  250.     #---------------------------------------------
  251.     #end Sprite_Timer
  252.     #---------------------------------------------
  253.      
  254.     #---------------------------------------------
  255.     #Game_Event
  256.     #---------------------------------------------
  257.     class Game_Event < Game_Character
  258.       attr_reader :erased
  259.       attr_accessor :is_light
  260.       alias init_gm_evnt_lights initialize
  261.       def initialize(*args)
  262.         init_gm_evnt_lights(*args)
  263.         @is_light = false
  264.       end
  265.       alias refresh_gm_evnt_lights refresh
  266.       def refresh
  267.         tmp_page = @page
  268.         refresh_gm_evnt_lights
  269.         if tmp_page != @page
  270.           @is_light = false
  271.         end
  272.       end
  273.     end
  274.      
  275.     #---------------------------------------------
  276.     #end Game_Event
  277.     #---------------------------------------------
  278.      
  279.     #---------------------------------------------
  280.     #Sprite_Nighttime
  281.     #---------------------------------------------
  282.      
  283.     class Nighttime < Sprite
  284.       def initialize(x,y)
  285.         super()
  286.         @width      = $game_map.width * 32
  287.         @height     = $game_map.height * 32
  288.         @lights     = {}
  289.         @sprites    = []
  290.         self.x      = x
  291.         self.y      = y
  292.         self.bitmap = Bitmap.new(@width, @height)
  293.         self.bitmap.clear
  294.         fillnight
  295.       end
  296.       def refresh
  297.         self.bitmap.clear
  298.         create_lights
  299.         fillnight
  300.       end
  301.      
  302.       def create_lights
  303.         for event in $game_map.events.values
  304.           unless event.erased or event.list == nil
  305.           for i in 0...event.list.size
  306.             if event.list[i].code == 108 #comment
  307.               if event.erased and event.list[i].parameters[0].include?("light")
  308.                 @lights.delete(event)
  309.                 next
  310.               elsif event.list[i].parameters[0].include?("light")
  311.                 size = event.list[i].parameters[0].delete("light").to_i #convert text to interger
  312.                 @lights[event] = Light.new(event, size) unless @lights.keys.include?(event)
  313.                 event.is_light = true
  314.                 next
  315.               end
  316.             end
  317.           end
  318.           #in the event page is changed and it is no longer a light.. remove it.
  319.           if @lights[event] != nil and event.is_light == false
  320.             @lights.delete(event)
  321.            end
  322.         end
  323.       end
  324.       if $game_switches[FLASHLIGHT_SWITCH] and $game_switches[CAVE_SWITCH]
  325.         @lights[$game_player] = Light.new($game_player, FLASHLIGHT_SIZE)
  326.       end
  327.     end
  328.       def fillnight
  329.         if $sec == nil
  330.           $sec = 0
  331.         end
  332.         if $game_switches[INSIDE_SWITCH] == true
  333.           extralpha = INSIDE_OPACITY
  334.         else
  335.           extralpha = 0
  336.           end
  337.          case $game_variables[HOUR_VARIABLE]
  338.         when 0, 1, 23
  339.         startop = 210 - extralpha
  340.         when 2
  341.         startop = 210 - ($sec / 2) + extralpha
  342.         when 3
  343.         startop = 180 - ($sec / 2) + extralpha
  344.         when 4
  345.         startop = 150 - ($sec / 2) + extralpha
  346.         when 5
  347.         startop = 120 - ($sec / 2) + extralpha
  348.         when 6
  349.         startop = 90 - ($sec / 2) + extralpha
  350.         when 7
  351.         startop = 60 - ($sec / 2) + extralpha
  352.         when 8
  353.         startop = 30 - ($sec / 2) + extralpha
  354.         when 9, 10, 11, 12, 13, 14, 15
  355.         startop = 0 + extralpha
  356.         when 16
  357.         startop = 0 + ($sec / 2) + extralpha
  358.         when 17
  359.         startop = 30 + ($sec / 2) + extralpha
  360.         when 18
  361.         startop = 60 + ($sec / 2) + extralpha
  362.         when 19
  363.         startop = 90 + ($sec / 2) + extralpha
  364.         when 20
  365.         startop = 120 + ($sec / 2) + extralpha
  366.         when 21
  367.         startop = 150 + ($sec / 2) + extralpha
  368.         when 22
  369.         startop = 180 + ($sec / 2) + extralpha
  370.       end
  371.       if $game_switches[CAVE_SWITCH] == true
  372.         startop = CAVE_OPACITY
  373.         end
  374.        
  375.         self.bitmap.fill_rect(0, 0, @width, @height, Color.new(0,0,0,255))
  376.         self.opacity = startop
  377.         # Now subtract out the lights
  378.         # Testing with a single light at tile 7,11
  379.         show_lights
  380.       end
  381.       def show_lights
  382.         applied_space = []
  383.         for light in @lights.values
  384.           image_sub = RPG::Cache.picture("LightSUB").clone
  385.           image_blt = RPG::Cache.picture("LightBLT").clone
  386.           base_rect = image_sub.rect
  387.           overlapLights = []
  388.           size = (light.size/100.0)
  389.           lwidth = base_rect.width*size
  390.           light_rect = Rect.new(light.x-(lwidth/2), light.y-(lwidth/2), lwidth, lwidth)
  391.           sprite = Sprite.new
  392.           sprite.bitmap = image_blt
  393.           sprite.x, sprite.y = light_rect.x, light_rect.y
  394.           sprite.z_index = 2001
  395.           sprite.blend_type = 2
  396.           image_sub.dispose
  397.           image_blt.dispose
  398.         end
  399.       end
  400.       def update
  401.         if $game_switches[INSIDE_SWITCH] == true
  402.           extralpha = INSIDE_OPACITY
  403.         else
  404.           extralpha = 0
  405.           end
  406.         case $game_variables[HOUR_VARIABLE]
  407.         when 0, 1, 23
  408.         self.opacity = 210 - extralpha
  409.         when 2
  410.         self.opacity = 210 - ($sec / 2) + extralpha
  411.         when 3
  412.         self.opacity = 180 - ($sec / 2) + extralpha
  413.         when 4
  414.         self.opacity = 150 - ($sec / 2) + extralpha
  415.         when 5
  416.         self.opacity = 120 - ($sec / 2) + extralpha
  417.         when 6
  418.         self.opacity = 90 - ($sec / 2) + extralpha
  419.         when 7
  420.         self.opacity = 60 - ($sec / 2) + extralpha
  421.         when 8
  422.         self.opacity = 30 - ($sec / 2) + extralpha
  423.         when 9, 10, 11, 12, 13, 14, 15
  424.         self.opacity = 0 + extralpha
  425.         when 16
  426.         self.opacity = 0 + ($sec / 2) + extralpha
  427.         when 17
  428.         self.opacity = 30 + ($sec / 2) + extralpha
  429.         when 18
  430.         self.opacity = 60 + ($sec / 2) + extralpha
  431.         when 19
  432.         self.opacity = 90 + ($sec / 2) + extralpha
  433.         when 20
  434.         self.opacity = 120 + ($sec / 2) + extralpha
  435.         when 21
  436.         self.opacity = 150 + ($sec / 2) + extralpha
  437.         when 22
  438.         self.opacity = 180 + ($sec / 2) + extralpha
  439.         end
  440.           if $game_switches[CAVE_SWITCH] == true
  441.         startop = CAVE_OPACITY
  442.         end
  443.         end
  444.     end
  445.     class Rect
  446.       def overlap?(rect)
  447.         corners = []
  448.         corners << [rect.x, rect.y] #UL
  449.         corners << [rect.x+rect.width, rect.y] #UR
  450.         corners << [rect.x+rect.width, rect.y+height] #LR
  451.         corners << [rect.x, rect.y+height] #LL
  452.         for corner in corners
  453.           if corner[0].between?(self.x, self.x+width) and corner[1].between?(self.y, self.y+height)
  454.             return true
  455.           end
  456.         end
  457.         return false
  458.       end
  459.       def area_in_overlap(rect)
  460.         return rect
  461.       end
  462.     end
  463.     class Light
  464.       def initialize(event, size)
  465.         @event = event
  466.         @size = size
  467.       end
  468.       def size
  469.         return @size
  470.       end
  471.       def x
  472.         return @event.real_x/4 + 16
  473.       end
  474.       def y
  475.         return @event.real_y/4 + 16
  476.       end
  477.     end
  478.      
  479.      
  480.     #---------------------------------------------
  481.     #end Sprite_Nighttime
  482.     #---------------------------------------------
  483.      
  484.     #---------------------------------------------
  485.     #Spriteset_Map
  486.     #---------------------------------------------
  487.     class Spriteset_Map
  488.       alias init_spr_map_lights initialize
  489.       def initialize
  490.         # Make nighttime sprite
  491.         @nighttime = Nighttime.new(0,0)
  492.         @nighttime.z = 2000
  493.         init_spr_map_lights
  494.         @nighttime.refresh
  495.         @map_idd = $game_map.map_id
  496.       end
  497.        alias dns_dispose dispose
  498.        def dispose
  499.          dns_dispose
  500.          @nighttime.dispose
  501.        end
  502.       alias upd_spr_map_lights update
  503.       def update
  504.         upd_spr_map_lights
  505.         # Update nighttime sprite
  506.         @nighttime.ox = $game_map.display_x / 4
  507.         @nighttime.oy = $game_map.display_y / 4
  508.         if @hour_day != $game_variables[HOUR_VARIABLE]
  509.           $game_map.refresh
  510.           @hour_day = $game_variables[HOUR_VARIABLE]
  511.           end
  512.         if @map_idd != $game_map.map_id
  513.           @nighttime.refresh
  514.           @map_idd = $game_map.map_id
  515.           end
  516.         @nighttime.update
  517.       end
  518.     end
  519.     #---------------------------------------------
  520.     #end Spriteset_Map
  521.     #---------------------------------------------
  522.  
Expand to see the code.
Unfortunately, the sprite's blend_type doesn't seem to subtract from the darkness, which is why I'm trying to figure out how "sub" works.
Maybe if I put the sprites above the darkness. Above post updated.
Sadly, no. I tried it with pictures and it didn't seem to work, which is why I suspect "sub" only subtracts from tiles and characters, not other bitmaps. It would be great if a scripting guru could confirm, though, or maybe explain how blend_type works.
New idea. What if I make a dll to do the sub function so it doesn't slow it down? Do you think that might work?
I have no idea, but it's worth a shot! I figure there must be some way to do it, though, since it's built in to the RPG engine for charactersets at least.
Alright, i should finish it by tomorrow.
:o I'd love to see this ^^

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