Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

4 Pages V   1 2 3 > »   
Reply to this topicStart new topic
> ~[Light Effects VX]~
Kylock
post May 20 2008, 07:24 PM
Post #1


Level 6
Group Icon

Group: Member
Posts: 85
Type: Scripter
RM Skill: Advanced




Light Effects VX
by Kylock (originally for RMXP by Near Fantastica)


This script will make things glow. A screenshot will explain it best.



#==============================================================================
# ● 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.
#==============================================================================


Installation Instructions
1. Insert the script somewhere below Materials and above Main
2. Copy le.png to your Pictures folder in your game.

le.png:

The Script

[Show/Hide] The Script

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 = 100
          @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 = 100
          @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 = 150
          @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 = 150
          @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,-100,-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,-100,-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



Usage
To make an event have a light effect, simply insert a Comment anywhere in the event code that includes the name of the effect in all capital letter. Example:


Enjoy,
Kylock

This post has been edited by Kylock: May 21 2008, 08:20 AM


__________________________
Go to the top of the page
 
+Quote Post
   
Tenchu-San
post May 20 2008, 07:38 PM
Post #2


Scribe & Defender of RRR.
Group Icon

Group: Revolutionary
Posts: 265
Type: Developer
RM Skill: Skilled




Kylock you are a Scripting God amongst men. That is something I was looking for and you couldn't have made it ANY easier. Kudos to you my friend, kudos.


__________________________

I'm not arrogant, I'm confident.
"Only the wicked shall fear my blade, for the grace of God shall defend the innocent from my wrath."
^ A quote that popped into my head during a hot summer night.
Come visit my devblog for my RMVX project: Exile of the Sun. Or check out the Topic here at RRR!
[Show/Hide] Genius, pure genius.

Go to the top of the page
 
+Quote Post
   
Kylock
post May 20 2008, 08:04 PM
Post #3


Level 6
Group Icon

Group: Member
Posts: 85
Type: Scripter
RM Skill: Advanced




QUOTE (Tenchu-San @ May 20 2008, 10:52 PM) *
Kylock you are a Scripting God amongst men. That is something I was looking for and you couldn't have made it ANY easier. Kudos to you my friend, kudos.


Lol, just to be clear, most of the code here is not mine, I only adapted it for VX (took a bit of rewriting) but I missed the functionality from my old games back in the day.

I'm glad other people find this useful.


__________________________
Go to the top of the page
 
+Quote Post
   
Kuuki
post May 21 2008, 10:39 AM
Post #4



Group Icon

Group: Member
Posts: 1
Type: Event Designer
RM Skill: Advanced




Great Script!
Thanks
Go to the top of the page
 
+Quote Post
   
X-Snake-X
post May 21 2008, 01:05 PM
Post #5


Level 6
Group Icon

Group: Member
Posts: 88
Type: Event Designer
RM Skill: Skilled




Very nice Script^^
I might use it wink.gif


__________________________

I'm from Germany o.o
Go to the top of the page
 
+Quote Post
   
maker2008
post May 21 2008, 03:04 PM
Post #6


Level 1
Group Icon

Group: Member
Posts: 11
Type: Event Designer
RM Skill: Advanced




Thank you very very much
Go to the top of the page
 
+Quote Post
   
Puppet Of Fate
post May 21 2008, 05:57 PM
Post #7


Please join my site!
Group Icon

Group: Revolutionary
Posts: 675
Type: Mapper
RM Skill: Advanced




I like it! I'll bookmark this for later.


__________________________
Go to the top of the page
 
+Quote Post
   
Taintedh
post May 25 2008, 02:43 AM
Post #8


Level 1
Group Icon

Group: Member
Posts: 7
Type: None
RM Skill: Undisclosed




Now if I could just manage to animate the campfire event... Anyone got a clue how to do this? sad.gif
Go to the top of the page
 
+Quote Post
   
thinkabout
post May 25 2008, 12:52 PM
Post #9


Level 3
Group Icon

Group: Member
Posts: 44
Type: Event Designer
RM Skill: Skilled




I have a problem here, lets see....
-I have an event (Event Lamp) that has 2 pages.
-In page 1 there is an image of a shutdown lamp (just a lamp) with nothing in the event commands
-In page 2, there is an image of a lighted lamp (the same lamp but yellow), this page needs the "light" switch to be on, I put the "LIGHT" comment there
-I have another event (Event Switch), it turns on or off the "light" switch

so
-The light switch is turned off by default
-I turn it on
-The lamp event changes pages to the lighted lamp, but there is no LIGHT effect
-When I change map and come back, NOW there is the LIGHT effect.
-So I go to turn it off
-The Lamp event goes back to page 1, and the lamp is off, but the LIGHT effect is still there
-When I change maps, NOW the LIGHT effect is gone

QUOTE
Now if I could just manage to animate the campfire event... Anyone got a clue how to do this?

you can try to have a charset with the campfire, with the fire in different directions, like this: \ | /
then put that charset in the campfire event, and select the Stepping Animation option of the event.


This post has been edited by thinkabout: May 25 2008, 12:56 PM


__________________________
Keep thinking.....
Go to the top of the page
 
+Quote Post
   
tomhgamer
post Jun 2 2008, 01:38 PM
Post #10


Level 1
Group Icon

Group: Member
Posts: 6
Type: Developer
RM Skill: Beginner




Great job! Is it possible to get it so the fire script could glow blue or green for the green and blue fire torches?
Go to the top of the page
 
+Quote Post
   
Kylock
post Jun 2 2008, 06:46 PM
Post #11


Level 6
Group Icon

Group: Member
Posts: 85
Type: Scripter
RM Skill: Advanced




QUOTE (thinkabout @ May 25 2008, 04:06 PM) *
I have a problem here, lets see....
-I have an event (Event Lamp) that has 2 pages.
-In page 1 there is an image of a shutdown lamp (just a lamp) with nothing in the event commands
-In page 2, there is an image of a lighted lamp (the same lamp but yellow), this page needs the "light" switch to be on, I put the "LIGHT" comment there
-I have another event (Event Switch), it turns on or off the "light" switch

so
-The light switch is turned off by default
-I turn it on
-The lamp event changes pages to the lighted lamp, but there is no LIGHT effect
-When I change map and come back, NOW there is the LIGHT effect.
-So I go to turn it off
-The Lamp event goes back to page 1, and the lamp is off, but the LIGHT effect is still there
-When I change maps, NOW the LIGHT effect is gone

QUOTE
Now if I could just manage to animate the campfire event... Anyone got a clue how to do this?

you can try to have a charset with the campfire, with the fire in different directions, like this: \ | /
then put that charset in the campfire event, and select the Stepping Animation option of the event.


My apologies for the late reply, I haven't been home for about a week. Anyway, I have also had trouble with this flaw. The original script by Near Fantastica that I adapted this one from worked in a way that it would only create light events when the map was loaded. Because of the method used, you can't really turn lights on and off using events without reloading the map. If you created a transfer player event that moved you to the same spot, you should get the desired effect, just a fade to black and back when you do it. That's the only way around this that I've found so far.


__________________________
Go to the top of the page
 
+Quote Post
   
sargunster
post Jun 12 2008, 07:20 PM
Post #12


Level 5
Group Icon

Group: Member
Posts: 65
Type: Event Designer
RM Skill: Beginner




wow amazing


__________________________

Go to the top of the page
 
+Quote Post
   
Tris
post Jun 13 2008, 10:47 AM
Post #13


Level 7
Group Icon

Group: Member
Posts: 97
Type: Scripter
RM Skill: Beginner




how do you make it dark?
Go to the top of the page
 
+Quote Post
   
darkrevenge
post Jun 13 2008, 11:45 AM
Post #14


Level 1
Group Icon

Group: Member
Posts: 10
Type: Event Designer
RM Skill: Advanced




I'm using Kylock's Time System VX 1.5 and I've noticed that this script doesn't work at night time...
Do anyone know how to make it work?
Thanks! ^^


__________________________

Stop Dreaming...
Start Something!!!!
My MSN... add me!
Go to the top of the page
 
+Quote Post
   
Kylock
post Jun 18 2008, 05:41 PM
Post #15


Level 6
Group Icon

Group: Member
Posts: 85
Type: Scripter
RM Skill: Advanced




QUOTE (darkrevenge @ Jun 13 2008, 02:59 PM) *
I'm using Kylock's Time System VX 1.5 and I've noticed that this script doesn't work at night time...
Do anyone know how to make it work?
Thanks! ^^


Find:
CODE
if $game_switches[1]


Change this to:
CODE
if !$game_switches[1]


this change will make lights on only at night, or you can just comment it out and the corresponding end statement to remove that part. I thought I made a constant for it, but it doesn't look like it's in this version. Since I'm on vacation from game making for awhile, this solution will have to do for now.


__________________________
Go to the top of the page
 
+Quote Post
   
icicle_mx
post Jun 25 2008, 11:48 PM
Post #16



Group Icon

Group: Member
Posts: 4
Type: None
RM Skill: Undisclosed




Simply, an amazing script. Thank you very much. You're genius! wink.gif
Go to the top of the page
 
+Quote Post
   
YanXie
post Jun 26 2008, 12:04 AM
Post #17


Because Tomorrow Will Surely Come...
Group Icon

Group: Revolutionary
Posts: 1,137
Type: None
RM Skill: Skilled




Hmm.. too bad that you're busy with work again.. tongue.gif

Still a good script though.

cheers, puppeto4. smile.gif


__________________________
how make teleport to graveyard then your character die?

AWAY FOR VACATION.
NOT HERE UNTIL JAN/FEB 2010 -w-/
Go to the top of the page
 
+Quote Post
   
icicle_mx
post Jun 26 2008, 07:25 PM
Post #18



Group Icon

Group: Member
Posts: 4
Type: None
RM Skill: Undisclosed




BTW, can you make a light on water reflection too? Like the river below the sun glare.
Go to the top of the page
 
+Quote Post
   
romaniac
post Jul 16 2008, 11:33 AM
Post #19



Group Icon

Group: Member
Posts: 1
Type: None
RM Skill: Undisclosed




FANTASTIC! I will definitely use it in my game! ^________^ Thanks a lot.
Go to the top of the page
 
+Quote Post
   
Ganon
post Jul 19 2008, 08:39 AM
Post #20


Level 11
Group Icon

Group: Revolutionary
Posts: 187
Type: Mapper
RM Skill: Skilled




This seems to return my tint to normal. I tint the screen very dark, but the light effects make it all the way up to full. Is there any way to fix this?


__________________________
[Show/Hide] random stuff

[Show/Hide] Get This?
Cna yuo raed tihs? Olny 55% of plepoe can.
I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor of the hmuan mnid, aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it dseno't mtaetr in waht oerdr the ltteres in a wrod are, the olny iproamtnt tihng is taht the frsit and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it whotuit a pboerlm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Azanmig huh? yaeh and I awlyas tghuhot slpeling was ipmorantt!
fi yuo cna raed tihs, palce it in yuor siantugre.

The following sentence is true. The previous sentence is false. This sentence is a lie.
QUOTE
Welcome to the Internet - where the men are men , the women are men and the children are the FBI


^New game dev team working on an action RPG.
Go to the top of the page
 
+Quote Post
   

4 Pages V   1 2 3 > » 
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 23rd May 2013 - 11:49 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker