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":3b7f0jmx said:
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

The window lights that was posted in this thread acted as though it was a plug 'n play script, at least for me. All I did was add it to a project, add a lit window tile to a random map, and it worked like a charm.
 
yes its a plug script or so we made it. if you have problems its because of different script prolly. or maybe using mack tiles? was made for normal rtp ubt dont think that cause problem like error msg
 

Mean1

Member

I dont have different tile sets no. I tried adding the one posted on the first reply and got an error on line 14. Which makes no sense because it is the same exact script. I dont know. It was something cool I liked. W/e I can live with out or make an event for each window. Does the light move any? or is it sitting still? Like in real life when you look at light filtering through a window you can see dust and particles, as if it was moving?
 
Mean1":2qnhojf4 said:
I dont have different tile sets no. I tried adding the one posted on the first reply and got an error on line 14. Which makes no sense because it is the same exact script. I dont know. It was something cool I liked. W/e I can live with out or make an event for each window. Does the light move any? or is it sitting still? Like in real life when you look at light filtering through a window you can see dust and particles, as if it was moving?

What error are you getting? What does it say? Also, in response to your last question: That would require a particle system, which generally makes RMXP laggy. (Unless you want to take a shorcut and use an animation instead, which can also make it laggy if its used too much)
 

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