Envision, Create, Share

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

[VX] Little Visual Effect People Will Find Useful!

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:
Problems%20with%20Lighting.jpg

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
[/i]

So if anyone can help it would be much appreciated and will be credited! Thanks for your help in advance! :biggrin:

Amos36
 

Mean1

Member

I dont know how to change the effect of the window lights but I wanted to ask you how you got your Window Lights to even work. I want that script so badly but when I put it in I get an error. Line 60. Did you get this error? and if you did how did you fix it? if not my bad.
I know there is an event process on the 3rd page thats called Advanced Script. I think you have to do something with that because it can alter a script a believe. Although I have no clue because I dont understand it so i could be wrong about it too
 
Mean1,

It's not hard. All you do is past the script in and copy over the le.png picture in the first post of that thread. I'm sorry but I had no problem with the script. If you want to set up lights then add a comment with "GROUND" or "LIGHT2" or something like that.

Amos36
 
The problem is relatively simple. As best I cen tell, the images that display the lights have a higher z axis than the game screen fadein/fadeout does, and thus, they are displayed over it. I haven't taken a look at the scripts themselves, but that seems to be the probelm, based on the screenshot.
 
OK, I checked out the scripts. The problem is the z axis, but also, the problem is that it isn't drawn in the same viewport as the map. Whoever put together these scripts wasn't exactly the brightest bulb, if they made that mistake. Let me take apart the scripts and see what I can do.

Edit: When you said "fadeout screen" and "fadein screen", what did you mean? Did you mean the "change screen color tone" command? Just wanted to double check, because I can fix that, but it also means that the lights will just blend with the rest of the map if you change the screen tone.

edit2: oops, sorry! I didn't realize this was for VX! I'll mod it for VX instead.

OK, just change line 26 of the first script to something like 100, and that one should be fine. I'll get tot he second one in a minute.
 
Dargor":r9g0cwkq said:
The simple solution, put the light sprite in the right viewport in Spriteset_Map. It should be @viewport1.


Actually, no. That just leaves it as is. (I think. That's the viewport used for screen brightness, the fadein and fadeout) Why not place it in viewport1?

Edit: Here, try this. I haven't tested it, but it should work.

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.code == 108 and event.list[i].parameters == ["GROUND"]

          type = "GROUND"

          light_effects = Light_Effect.new(event,type, @viewport1)

          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, @viewport1)

          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, @viewport1)

          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, @viewport1)

          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, @viewport1)

          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, @viewport1)

          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, viewport)

    @light = Sprite.new(viewport)

    @light.bitmap = Cache.picture("le.png")

    @light.visible = true

    @light.z = 3000

    @event = event

    @type = type

  end

end
 
Actually, no. That just leaves it as is. (I think. That's the viewport used for screen brightness, the fadein and fadeout) Why not place it in viewport1?

That's the point. If placed in viewport3, the sprites will still be over the characters (which are in viewport2) and will be affected by the tone change. Viewport1 has a lower priority than viewport2 and 3, it's used for the tilemap, panorama and things like that.
 
Dargor":2ujsarwg said:
Actually, no. That just leaves it as is. (I think. That's the viewport used for screen brightness, the fadein and fadeout) Why not place it in viewport1?

That's the point. If placed in viewport3, the sprites will still be over the characters (which are in viewport2) and will be affected by the tone change. Viewport1 has a lower priority than viewport2 and 3, it's used for the tilemap, panorama and things like that.

Ahh, I see. I didn't look at viewport2. I just assumed that the characters were in viewport1 like in RMXP. Lemme change my script.
 
Dargor":57bwtd0w said:
Sorry, I made a mistake, characters are indeed in viewport1. Only the timer, weather and pictures are in viewport. So both viewport 2 and 3 are good.
Well, it depends. If you want to have the lights display above time, weather, or pictures, you can put them in viewport2 or viewport3. Otherwise just put them in viewport1.
 
Amos36":gt8nmi1p said:
This post has been busy. I've changed the Z to 5 on both scripts. This seems to work for now. Thanks for the help!

A z of 5 might be too low. The player's z position changes as he moves up and down the y axis, and it might go above 5. I haven't looked at the forumla for that in a while.
 

Mean1

Member

I have VX. I found it on a VX site.
Line 60 is wanting a number for x in $Game_Map

The number is set to 0 for right now but I have no clue what to put. This is my error.
 

Mean1

Member

The Light Effects was originally for XP made by Near Fantastica, Kylock translated it into VX.
As for the Window Lights, I am not sure as I dont have it in my script base because it does not work. And I want it to work lol
 

Thank you for viewing

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

Discord

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

Content

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