Hi people of RMXP.org, :biggrin:
I would like to request a little script to make the visual side of games better. I've noticed that people using Window Lights and Kyock's Light Effects experience problems when they use "Fadeout Screen" / "Fadein Screen" like Prophecy: the Demon Kingdom by Sagitar. (It's a good example of an RMVX game with charm, try it!)
Basically, when the screen is meant to fade to black, the light effects/winow lights are still left behind. Use this screenshot for an example:
My beautiful darkness with free light effects... enjoy...
So there's my problem. Basically I need it so that Light Effects and Window Lights fade out along with the screen so if the screen is black whilst talking is going on, then it won't look bad.
Here's the two scripts in case you don't know where to find them:
Window Lights
Light Effects
[/i]
So if anyone can help it would be much appreciated and will be credited! Thanks for your help in advance! :biggrin:
Amos36
I would like to request a little script to make the visual side of games better. I've noticed that people using Window Lights and Kyock's Light Effects experience problems when they use "Fadeout Screen" / "Fadein Screen" like Prophecy: the Demon Kingdom by Sagitar. (It's a good example of an RMVX game with charm, try it!)
Basically, when the screen is meant to fade to black, the light effects/winow lights are still left behind. Use this screenshot for an example:
My beautiful darkness with free light effects... enjoy...
So there's my problem. Basically I need it so that Light Effects and Window Lights fade out along with the screen so if the screen is black whilst talking is going on, then it won't look bad.
Here's the two scripts in case you don't know where to find them:
Window Lights
Code:
module GameBaker
 AutoLightTiles = Hash.new
 AutoLightTiles[280] = [8,4,16,56]
 AutoLightTiles[281] = [9,4,14,48]
 AutoLightTiles[283] = [12,5,10,36]
 AutoLightTiles[296] = [7,10,18,64]
 AutoLightTiles[297] = [9,10,14,64]
 AutoLightTiles[299] = [7,12,18,64]
 AutoLightTiles[300] = [7,12,18,64]
 AutoLightTiles[301] = [7,3,18,56]
 AutoLightTiles[302] = [7,3,18,48]
 AutoLightTiles[303] = [7,3,18,36]
Â
 AutoLightColors = Hash.new([255,255,255])
 AutoLightColors[299] = [128,200,255]
Â
 AutoLightStart = Hash.new(255)
 AutoLightStart[281] = 220
 AutoLightStart[283] = 134
 AutoLightStart[296] = 196
 AutoLightStart[297] = 220
 AutoLightStart[302] = 220
 AutoLightStart[303] = 134
Â
 AutoLightOpac = "125"
 AutoLightZ = 100000
end
Â
class Spriteset_Map
 alias gamebaker_autolight_init initialize
 def initialize
  create_gblights
  gamebaker_autolight_init
 end
Â
 alias gamebaker_autolight_disp dispose
 def dispose
  if @gb_autolights
   @gb_autolights.dispose if !@gb_autolights.disposed?
   @gb_autolights = nil
  end
  gamebaker_autolight_disp
 end
Â
 alias gamebaker_autolight_upd update
 def update
  update_gblights
  gamebaker_autolight_upd
 end
Â
 def update_gblights
  return if !@gb_autolights
  @gb_autolights.opacity = eval(GameBaker::AutoLightOpac).to_i
  @gb_autolights.ox = $game_map.display_x / 8
  @gb_autolights.oy = $game_map.display_y / 8
 end
Â
 def create_gblights
  data = $game_map.data
  for x in 0...$game_map.width
   for y in 0...$game_map.height
    next if data[x,y,2] == 0
    if GameBaker::AutoLightTiles.include?(data[x,y,2])
     create_gblight(data[x,y,2],x,y)
    end
   end
  end
 end
Â
 def create_gblight(num,x,y)
  sg = GameBaker::AutoLightTiles[num]
  light = Bitmap.new(sg[2],sg[3])
  clr = GameBaker::AutoLightColors[num]
  start = GameBaker::AutoLightStart[num]
  num = (start).to_f
  numup = num / (sg[3] + 6).to_f
  for i in 0...sg[3]
   rect = Rect.new(0,i,sg[2],i+1)
   color = Color.new(clr[0],clr[1],clr[2],num.to_i)
   light.fill_rect(rect,color)
   num = (num -= numup)
   num = (num -= numup) if i < 6
  end
  if !@gb_autolights
   @gb_autolights = Sprite.new
   @gb_autolights.bitmap = Bitmap.new($game_map.width * 32,$game_map.height * 32)
   @gb_autolights.z = GameBaker::AutoLightZ
   @gb_autolights.opacity = eval(GameBaker::AutoLightOpac).to_i
  end
  @gb_autolights.bitmap.blt((x * 32) + sg[0],(y * 32) + sg[1],light,
   Rect.new(0,0,sg[2],sg[3]))
 end
end
Light Effects
Code:
#==============================================================================
# â– Light Effects VX 1.1
# Â Â 5.21.2008
#------------------------------------------------------------------------------
# Â Script by: Kylock (originally for RMXP by Near Fantastica)
#==============================================================================
# Â To make an event glow, give it a Comment: with any of the supported light
# modes.
# Â The SWITCH setting below will disable light effects from updating with the
# switch is on.
#==============================================================================
# â— Change Log
#------------------------------------------------------------------------------
# 1.0 - Original Release
# 1.1 - New light modes added: LIGHT2, TORCH, TORCH2
# Â Â - Changed sprite blend mode to ADD (looks slightly better)
# Â Â - Fire-based lights are now red in color
#==============================================================================
# â— Light Modes
#------------------------------------------------------------------------------
# Â GROUND - Medium steady white light.
# Â FIRE Â - Large red light with a slight flicker.
# Â LIGHT Â - Small steady white light.
# Â LIGHT2 - X-Large steady white light.
# Â TORCH Â - X-Large red light with a heavy flicker.
# Â TORCH2 - X-Large red light with a sleight flicker.
#==============================================================================
Â
class Spriteset_Map
 alias les_spriteset_map_initalize initialize
 alias les_spriteset_map_dispose dispose
 alias les_spriteset_map_update update
 def initialize
  @light_effects = []
  setup_lights
  les_spriteset_map_initalize
  update
 end
 def dispose
  les_spriteset_map_dispose
  for effect in @light_effects
   effect.light.dispose
  end
  @light_effects = []
 end
 def update
  les_spriteset_map_update
  update_light_effects
 end
 def setup_lights
  for event in $game_map.events.values
   next if event.list == nil
   for i in 0...event.list.size
    if event.list[i].code == 108 and event.list[i].parameters == ["GROUND"]
     type = "GROUND"
     light_effects = Light_Effect.new(event,type)
     light_effects.light.zoom_x = 2
     light_effects.light.zoom_y = 2
     light_effects.light.opacity = 75
     @light_effects.push(light_effects)
    end
    if event.list[i].code == 108 and event.list[i].parameters == ["FIRE"]
     type = "FIRE"
     light_effects = Light_Effect.new(event,type)
     light_effects.light.zoom_x = 300 / 100.0
     light_effects.light.zoom_y = 300 / 100.0
     light_effects.light.opacity = 125
     @light_effects.push(light_effects)
    end
    if event.list[i].code == 108 and event.list[i].parameters == ["LIGHT"]
     type = "LIGHT"
     light_effects = Light_Effect.new(event,type)
     light_effects.light.zoom_x = 1
     light_effects.light.zoom_y = 1
     light_effects.light.opacity = 150
     @light_effects.push(light_effects)
    end
    if event.list[i].code == 108 and event.list[i].parameters == ["LIGHT2"]
     type = "LIGHT2"
     light_effects = Light_Effect.new(event,type)
     light_effects.light.zoom_x = 6
     light_effects.light.zoom_y = 6
     light_effects.light.opacity = 150
     @light_effects.push(light_effects)
    end
    if event.list[i].code == 108 and event.list[i].parameters == ["TORCH"]
     type = "TORCH"
     light_effects = Light_Effect.new(event,type)
     light_effects.light.zoom_x = 6
     light_effects.light.zoom_y = 6
     light_effects.light.opacity = 230
     @light_effects.push(light_effects)
    end
    if event.list[i].code == 108 and event.list[i].parameters == ["TORCH2"]
     type = "TORCH2"
     light_effects = Light_Effect.new(event,type)
     light_effects.light.zoom_x = 6
     light_effects.light.zoom_y = 6
     light_effects.light.opacity = 230
     @light_effects.push(light_effects)
    end
   end
  end
  for effect in @light_effects
   case effect.type
   when "GROUND"
    effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
    effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
    effect.light.blend_type = 1
   when "FIRE"
    effect.light.x = (effect.event.real_x - 600 - $game_map.display_x) / 8 + rand(6) - 3
    effect.light.y = (effect.event.real_y - 600 - $game_map.display_y) / 8 + rand(6) - 3
    effect.light.tone = Tone.new(255,-100,-255,  0)
    effect.light.blend_type = 1
   when "LIGHT"
    effect.light.x = (-0.25 / 2 * $game_map.display_x) + (effect.event.x * 32) - 15
    effect.light.y = (-0.25 / 2 * $game_map.display_y) + (effect.event.y * 32) - 15
    effect.light.blend_type = 1
   when "LIGHT2"
    effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
    effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
    effect.light.blend_type = 1
   when "TORCH"
    effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
    effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
    effect.light.tone = Tone.new(255,-110,-255,  0)
    effect.light.blend_type = 1
   when "TORCH2"
    effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
    effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
    effect.light.tone = Tone.new(255,-110,-255,  0)
    effect.light.blend_type = 1
   end
  end
 end
 def update_light_effects
  if $game_switches[1]
   for effect in @light_effects
    next if effect.type == "FIRE" || effect.type == "TORCH"
    effect.light.visible = false
   end
  else
   for effect in @light_effects
    next if effect.type == "FIRE" || effect.type == "TORCH"
    effect.light.visible = true
   end
  end
  for effect in @light_effects
   case effect.type
   when "GROUND"
    effect.light.x = (effect.event.real_x - 400 - $game_map.display_x) / 8
    effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 8
   when "FIRE"
    effect.light.x = (effect.event.real_x - 600 - $game_map.display_x) / 8 + rand(6) - 3
    effect.light.y = (effect.event.real_y - 600 - $game_map.display_y) / 8 + rand(6) - 3
    effect.light.opacity = rand(10) + 90
   when "LIGHT"
    effect.light.x = (-0.25 / 2 * $game_map.display_x) + (effect.event.x * 32) - 15
    effect.light.y = (-0.25 / 2 * $game_map.display_y) + (effect.event.y * 32) - 15
   when "LIGHT2"
    effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
    effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
   when "TORCH"
    effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20 + rand(20) - 10
    effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8 + rand(20) - 10
    effect.light.opacity = rand(30) + 70
   when "TORCH2"
    effect.light.x = (effect.event.real_x - 1200 - $game_map.display_x) / 8 - 20
    effect.light.y = (effect.event.real_y - 1200 - $game_map.display_y) / 8
    effect.light.opacity = rand(10) + 90
   end
  end
 end
end
Â
class Light_Effect
 attr_accessor :light
 attr_accessor :event
 attr_accessor :type
 def initialize(event, type)
  @light = Sprite.new
  @light.bitmap = Cache.picture("le.png")
  @light.visible = true
  @light.z = 1000
  @event = event
  @type = type
 end
end
So if anyone can help it would be much appreciated and will be credited! Thanks for your help in advance! :biggrin:
Amos36