Khas Awesome Light Effects Script help with errors

i have this script for Khas and i have an error: Script 'Lighting' line 248: Syntax Error Occured. unexpected ',' expecting ')' load_bitmap (Graphics / Lights /", filename

i tried altering the , to ) and it gave me another error im not a code expert and not sure what or where else i have problems in this code or if its the most recent. any help would be appreciated.

# ------------------------------------------------- ------------------------------
# * [ACE] Khas Awesome Light Effects
# ------------------------------------------------- ------------------------------
# * For Khas Arcthunder - arcthunder.site40.net
# * Version: 1.0 BR
# * Released on: 12/01/2012
#
# ------------------------------------------------- ------------------------------
# * Terms of Use
# ------------------------------------------------- ------------------------------
# When using any script made by Khas, you agree to the following terms
# 1. You must give credit if using any Khas Khas script;
# 2. All Khas scripts are licensed under Creative Commons;
# 3. All Khas scripts are for non-commercial projects, if you need
# Khas some script in your commercial project (accepted applications for this type
# Project), please email [email hidden] with the request;
# 4. All Khas scripts are for personal use, you can use and edit for use
# In your project, but you can not post any modified version;
# 5. You can not give credit to himself by posting some script Khas;
# 6. If you want to share a script Khas, do not post the direct link to
# Download, just redirect the user to arcthunder.site40.net
#
# ------------------------------------------------- ------------------------------
# Features *
# ------------------------------------------------- ------------------------------
# - Realistic Light Effects
# - Real light (no more walls!)
# - Light Sources static (not moving)
# - Dynamic light source (a flashlight for the player, for example)
# - Effects can join multiple
# - Easy setup
# - Use a comment
#
# ------------------------------------------------- ------------------------------
# * IMPORTANT - Performance
# ------------------------------------------------- ------------------------------
# This script may become heavy to very old processors! The Awesome
# Light Effects been tested on a Core 2 Duo E4500 and a Core i5 without lag.
# However, besides the processor, there are several factors that influence the performance
# The script:
#
# 1. Map Size
# This script parses the map in search of surfaces to cut the light. In a
# Map very large, the number of surfaces can greatly affecting
# Performance LIGHT DYNAMICS. The size of the map does not influence on the lights
# Static.
#
# 2. Number of effects
# This script draws the effects on the screen, according to its position. Prior to
# Update them, their position is verified. Therefore, in very large maps
# Over-come the effects may occur lag. Note that this is only a
# Prediction because the current tests was not detected lag.
#
# 3. Image Size
# The image size of dynamic light directly influences the performance.
# The light cutting is done line by line, the higher the image resolution,
# More time will be spent to cut it. The recommendation is up to 200x200 pixels.
#
# ------------------------------------------------- ------------------------------
# * IMPORTANT - Images of Light
# ------------------------------------------------- ------------------------------
# For the correct functioning of the script, the images of light MUST obey
# The following criteria:
#
# 1. The image size MUST be even. Example: 150x150
# 2. The image MUST be square with dimensions EQUAL. Example: 156x156
# 3. The image MUST be in inverted colors! Nescessário This is because the
# Script to draw inverts the effect on surface effects.
# Remember that the black color will be transparent!
#
# ------------------------------------------------- ------------------------------
# * Instructions - 1. Configuring static effects
# ------------------------------------------------- ------------------------------
# To configure static effects, go to the configuration (below) and
# Define the effects within the hash Effects. Make the following:
#
X # => [image, opacity, change, cut] <= Remember that comma at the end!
#
# Where:
# Image => Image Name the folder "Graphics / Lights";
# Opacity => Opacity image;
# Change => POSITIVE Change opacity;
Cut # => true Place to crop the image and false not to cut;
X # => is the ID of the effect to be used in the events. Use an ID for each effect.
#
# See the effects preconfigured to understand how it works.
#
# ------------------------------------------------- ------------------------------
# * Instructions - 2. Using effects on event:
# ------------------------------------------------- ------------------------------
# To use the definite effect on an event, place the following comment:
#
# [Light x]
#
# Where x should be set ID effect.
#
# ------------------------------------------------- ------------------------------
# * Instructions - 3. Using dynamic light (flashlight)
# ------------------------------------------------- ------------------------------
# The flashlight is automatically initialized as invisible. You can use the
# The following methods with the command "Call Script":
#
# L = $ game_map.lantern
# Adiquire the flashlight in a variable.
# You can use all the commands below with "$ game_map.lantern" to
# Instead of adiquirir the flashlight in a variable, but be careful as
# The command "Call Script" dice code and can generate errors.
#
L.set_graphic # (I)
# Change the graph flashlight to i, where i must be the name in quotation marks,
# Image folder Graphics / Lights
#
# L.set_multiple_graphics (h)
# Change the graphics of the flashlight to h, where h must be a hash with the following
# Format:
#
# H = {2 => 'ld', 4 => "ll", 6 => "lr", 8 => "lu"}
#
# Where:
# "Ld" is the name of the image when the wearer is facing down;
# "Ll" is the name of the image when the wearer is facing left;
# "Lr" is the name of the image when the wearer is facing right;
# "Lu" is the name of the image when the wearer is facing up.
#
# L.change_owner (char)
# Change the bearer of the torch to char, where char can be:
# $ Game_player <= Player;
# Self_event <= The event in which the command is invoked;
# $ Game_map.events [x] <= x The event ID of the map.
#
# L.set_opacity (o, p)
# Set the opacity of the lantern, where:
# Is the opacity standard;
# P is the variation POSITIVE opacity.
#
# L.show
# After configuring the flashlight with the above commands, use this command to
# Make the flashlight visible.
#
# L.hide
# Use this command to hide the flashlight.
#
# ------------------------------------------------- ------------------------------
# * Instructions - 4. Using the surface effects (Call Script)
# ------------------------------------------------- ------------------------------
# Awesome Light Effects The effects draws on a surface. That
# The effects are visible, the surface effects should be visible.
# To use the surface effects, use the commands below:
#
# S = $ game_map.effect_surface
# Adiquire the surface in a variable.
# You can use all the commands below with "$ game_map.effect_surface" to
# Instead of adiquirir the surface in a variable, but be careful as
# The command "Call Script" dice code and can generate errors.
#
S.set_color # (r, g, 😎
# Change the color of the surface instantly to the color provided:
# R => red color value;
# G => green color value;
# B => blue color value.
#
# S.set_alpha (a)
# Change the opacity to the surface instantly.
#
# S.change_color (time, r, g, 😎
# Change just the color of the surface at a time, where:
# Time => time to change (in frames);
# R => red color value;
# G => green color value;
# B => blue color value.
#
# S.change_color (time, r, g, b, a)
# Change the surface color and opacity at a certain time, where:
# Time => time to change (in frames);
# R => red color value;
# G => green color value;
# B => blue color value;
# A => opacity.
#
# S.change_alpha (time to)
# Change the opacity of the surface at a certain time, where:
# Time => time to change (in frames);
# A => opacity.
#
# ------------------------------------------------- ------------------------------
# * Instructions - 5. Using the Surface effects (Event)
# ------------------------------------------------- ------------------------------
# You can access the surface effects by the command "Tint Screen"
# To do so, set the option "Surface_UE" (in settings) to true. Case
# Want to disable this option and have control over the tone of the screen, place the
# Option "Surface_UE" to false.
#
# Note the following details, if you use this option:
# 1. The color values ​​must be between 0 and 255;
# 2. The time is in frames;
# 3. The value "Grey" will be sent as the opacity of the surface.
#
# ------------------------------------------------- ------------------------------
# * Instructions - 6. Configuring Tags Map
# ------------------------------------------------- ------------------------------
# In order that the lights are cut accurately and realistically, there are 3 types
# Behavior for tile: roof, wall and block. Think so
# Logic: a roof creates shadows as roof, a wall as a wall, and
# So on.
#
# For this, the tileset tags MUST be configured. By default, they are
# Configured to 6,7 and 8. See the demo to get a sense of how this works.
#
# Note that the script will only analyze the first layer (layer A) of the map. Certain
# Tilesets will not work if the tiles are not configured so
# Correct. Also note that this script depends on the proper mapping to work,
# Pay attention to the details of your map.
#
# ------------------------------------------------- ------------------------------
# * Configuration
# ------------------------------------------------- ------------------------------
module Light_Core
Effects = {# Do not change this!
# ------------------------------------------------- ------------------------------
# ADD BELOW ITS EFFECTS!
# ------------------------------------------------- ------------------------------
0 => ['light', 255.0, true],
1 => ["torch", 200,20, true],
2 => ["torch_m", 180.30, true],
3 => ["light_s", 255,0, true],
# ------------------------------------------------- ------------------------------
# End of configuration effects
# ------------------------------------------------- ------------------------------
} # Do not change this!
# Z coordinate of the surface effects:
# = 180 Surface_Z
# Enable control surface by "Tint Screen"?
Surface_UE = true
# Tag to the surface behave as "roof"
Roof_Tag = 5
# Tag to the surface behave like "wall"
Wall_Tag = 6
# Tag to the surface behave as "block" (like the roof)
Block_Tag = 7
# Constant angle correction (no change)
ACC = Math.tan (Math :: PI/26)
end
# ------------------------------------------------- ------------------------------
# End of configuration - Start of script
# ------------------------------------------------- ------------------------------
Cache module
def self.light (filename)
load_bitmap ("Graphics / Lights /", filename
end
end
module Light_Bitcore
include Light_Core
def self.initialize
@ Buffer = {}
Effects.values.each {| effect | Light_Bitcore.push (effect [0])}
end
self :: def [] (key)
return @ @ buffer [key]
end
def self.push (key)
return if @ @ buffer.keys.include? (key)
@ @ Buffer [key] = Cache.light (key)
end
end
Light_Bitcore.initialize
class Light_SSource
attr_reader: real_x
attr_reader: real_y
attr_reader: range
attr_accessor: bitmap
attr_reader: w
attr_reader: h
attr_reader: hs
def initialize (char, bitmap, opacity, plus, hs)
sync (char)
@ Key = bitmap
@ Bitmap = Light_Bitcore [@ key]. Clone
@ Range = @ bitmap.width / 2
@ W = @ bitmap.width
@ H = @ bitmap.height
@ Mr = @ range - 16
@ Opacity = opacity
@ = Plus plus
@ Hs = hs
surrender if @ hs
end
def render
tx = x
y = ty
tsx = x + @ range
tsy = y + @ range
dr = 2 * @ range
for $ s in game_map.surfaces
next if! s.visible? (tsx, tsy) | |! s.within? (tx, dr + tx, ty, ty + dr)
s.render_shadow (tx, ty, tsx, tsy, @ range, @ bitmap)
end
end
def restore
[email hidden] return?
@ Bitmap = Light_Bitcore [@ key]. Clone
surrender if @ hs
end
def opacity
Plus @ == 0? @ Opacity: (@ opacity + rand (@ plus))
end
def sx
return $ game_map.adjust_x (@ real_x) * 32 - @ mr
end
def sy
return $ game_map.adjust_y (@ real_y) * 32 - @ mr
end
def sync (char)
@ Real_x = char.real_x
@ Real_y = char.real_y
end
def x
return (* 32 real_x @ - @ mr). to_f
end
def y
return (* 32 real_y @ - @ mr). to_f
end
def dispose
[email hidden] return?
@ Bitmap.dispose
@ Bitmap = nil
end
end
class Light_DSource <Light_SSource
attr_reader: bitmap
attr_reader: visible
def initialize
@ Key = nil
@ Bitmap = nil
@ Opacity = 255
@ Plus = 0
@ Char = $ game_player
@ Visible = false
end
def set_opacity (o, p)
@ Opacity = the
@ = P plus
end
def set_graphic (sb)
dispose
@ Key = {2 => sb, 4 => sb, 6 => sb, 8 => sb}
Light_Bitcore.push (sb)
@ Bitmap =
@ Range = @ bitmap [2]. Width / 2
@ W = @ bitmap [2]. Width
@ H = @ bitmap [2]. Height
@ Mr = @ range - 16
end
def set_multiple_graphics (ba)
dispose
@ Key = ba
@ Key.values.each {| key | Light_Bitcore.push (key)}
@ Bitmap =
@ Range = @ bitmap [2]. Width / 2
@ W = @ bitmap [2]. Width
@ H = @ bitmap [2]. Height
@ Mr = @ range - 16
end
def get_graphic
return @ bitmap [@ char.direction]. clone
end
def show
[email hidden] return?
@ Visible = true
end
def hide
@ Visible = false
end
def restore
[email hidden] return?
@ Key.values.each {| key | Light_Bitcore.push (key)}
@ Bitmap =
end
def dispose
[email hidden] return?
@ Bitmap.values.each {| b |} b.dispose
@ Bitmap = nil
end
def change_owner (char)
@ Char = char
end
def render
end
def sx
return $ game_map.adjust_x (@ char.real_x) * 32 - @ mr
end
def sy
return $ game_map.adjust_y (@ char.real_y) * 32 - @ mr
end
def x
return (* 32 char.real_x @ - @ mr). to_f
end
def y
return (* 32 char.real_y @ - @ mr). to_f
end
end
class Light_Surface
def initialize
@ @ Ta = a = 0
Tr @ = @ r = 255
@ Tg = @ g = 255
Tb @ @ = b = 255
Va @ vr = @ = @ = @ vg = vb 0.0
@ Timer = 0
end
def refresh
return if @ timer == 0
+ @ A = @ va
@ = @ R + vr
@ G = @ vg +
@ = @ B + vb
$ Game_map.light_surface.opacity = @ a
@ Timer - = 1
end
def change_color (time r, g, b, a = nil)
r = 0 if r <0, r = 255 if r> 255
g = 0 if g <0, g = 255 if g> 255
b = 0 if b <0, if b = b 255> 255
unless a.nil?
if a = 0 and a <0, if a = 255 to> 255
end
@ Timer = time
@ Tr = 255-r
@ Tg = 255-g
Tb @ b-= 255
= Va @ (a.nil? 0 (a @-a). To_f / timer @)
@ Vr = (tr @ - @ r). To_f / @ timer
@ Vg = (tg @ - @ g). To_f / @ timer
@ Vb = (tb @ - @ 😎 . To_f / @ timer
end
def change_alpha (time to)
if a = 0 and a <0, if a = 255 to> 255
@ Timer = time
@ Ta = a
@ Vr = @ @ vg = vb = 0.0
= Va @ (@ a-a). To_f / timer @
end
def set_color (r, g, 😎
r = 0 if r <0, r = 255 if r> 255
g = 0 if g <0, g = 255 if g> 255
b = 0 if b <0, if b = b 255> 255
Tr @ = @ r = 255-r
@ @ Tg =-g = 255 g
Tb @ = @ = 255 b-b
Va @ vr = @ = @ = @ vg = vb 0.0
@ Timer = 0
end
def set_alpha (a)
if a = 0 and a <0, if a = 255 to> 255
@ @ Ta = a = a
$ Game_map.light_surface.opacity = @ a
Va @ vr = @ = @ = @ vg = vb 0.0
@ Timer = 0
end
def alpha
@ return the
end
def color
Color.new return (@ r, @ g, @ 😎
end
end
class Game_Map
include Light_Core
attr_accessor: light_surface
attr_accessor: light_sources
attr_accessor: surfaces
attr_accessor: effect_surface
attr_accessor: lantern
alias kbl_setup_events setup_events
alias kbl_initialize initialize
alias update kbl_update
def initialize
kbl_initialize
@ Effect_surface = Light_Surface.new
@ Lantern = Light_DSource.new
end
def update (arg)
@ Effect_surface.refresh if arg
kbl_update (arg)
end
first_tag def (x, y)
tag = tileset.flags [tile_id (x, y, 0)] >> 12
return tag> 0? tag: 0
end
def setup_events
@ Light_sources.nil? ? @ Light_sources = []: @ light_sources.clear
setup_surfaces
merge_surfaces
kbl_setup_events
end
def setup_surfaces
@ Surfaces = []
for x in 0 .. (width-1)
for y in 0 .. (height-1)
tag = first_tag (x, y)
if tag == Wall_Tag
tile_id i = (x, y, 0)
if i == 0x02 & 0x02
@ << Block_SD.new surfaces (32 x *, y * 32 * 32 x 32, y 32 *)
end
if i == 0x04 & 0x04
@ Surfaces Block_WR.new << (x * 32 +31, y * 32 * 32 +31 x, y +32 * 32)
@ << Block_IL.new surfaces (32 x 32 *, y * 32 * 32 +32 x, y +32 * 32)
end
if i == 0x01 & 0x01
@ Surfaces Block_IR.new << (32-1 x *, y * 32 32 to 1 x *, y * 32 +32)
@ << Block_WL.new surfaces (32 x *, y * 32 * x 32 32 * y +32)
end
elsif tag == Roof_Tag
tile_id i = (x, y, 0)
@ Surfaces Block_SU.new << (x * 32, y * 32, x * 32 +32, y * 32) if i == 0x02 & 0x02
@ Surfaces Block_SR.new << (x * 32 +31, y * 32, x * 32 +31, y * 32 +32) if i == 0x04 & 0x04
@ Surfaces Block_SL.new << (x * 32, y * 32, x * 32, y * 32 +32) if i == 0x01 & 0x01
elsif tag == Block_Tag
f = tileset.flags [tile_id (x, y, 0)]
@ << Block_SL.new surfaces (32 x *, y * 32 32 * x, y +32 * 32) if f & == 0x02 0x02
@ Surfaces Block_SR.new << (x * 32 +31, y * 32 * 32 +31 x, y +32 * 32) if f & == 0x04 0x04
@ << Block_SU.new surfaces (32 x *, y * 32 * 32 x 32, y * 32) if f & == 0x08 0x08
end
end
end
end
def merge_surfaces
new_surfaces = []
hs = []; vs = []
ws = [], is = []
surface is in @ surfaces
if surface.type & 0x05 == 0
surface hs <<
else
if surface.type & 0x010 == 0
vs. surface <<
else
if surface.type & 0x08 == 0
ws << surface
else
surface is <<
end
end
end
end
surface is in hs
surface.ready? next: = true surface.ready
for s in hs
next if s.ready | | s.y1! = surface.y1 | | surface.type! = s.type
if s.x2 == surface.x1
surface.x1 = s.x1
s.trash = true
s.ready = true
surface.ready = false
elsif s.x1 == surface.x2
surface.x2 = s.x2
s.trash = true
s.ready = true
surface.ready = false
end
end
end
hs.each {| s | @ surfaces.delete (s) if s.trash}
surface is in vs
surface.ready? next: surface.ready
s is in vs
next if s.ready | | s.x1! = surface.x1
if s.y2 == surface.y1
surface.y1 = s.y1
s.trash = true
s.ready = true
surface.ready = false
elsif s.y1 == surface.y2
surface.y2 = s.y2
s.trash = true
s.ready = true
surface.ready = false
end
end
end
vs.each {| s | @ surfaces.delete (s) if s.trash}
surface is in ws
surface.ready? next: surface.ready
s is in ws
next if s.ready | | s.x1! = surface.x1
if s.y2 == surface.y1
surface.y1 = s.y1
s.trash = true
s.ready = true
surface.ready = false
elsif s.y1 == surface.y2
surface.y2 = s.y2
s.trash = true
s.ready = true
surface.ready = false
end
end
end
ws.each {| s | @ surfaces.delete (s) if s.trash}
surface is in is
surface.ready? next: surface.ready
s is in is
next if s.ready | | s.x1! = surface.x1
if s.y2 == surface.y1
surface.y1 = s.y1
s.trash = true
s.ready = true
surface.ready = false
elsif s.y1 == surface.y2
surface.y2 = s.y2
s.trash = true
s.ready = true
surface.ready = false
end
end
end
is.each {| s | @ surfaces.delete (s) if s.trash}
end
end
class Game_Event <Game_Character
alias kbl_initialize initialize
alias kbl_setup_page setup_page
def initialize (m, e)
@ Light = nil
kbl_initialize (m, e)
end
def setup_page (np)
kbl_setup_page (np)
setup_light (np.nil?)
end
def setup_light (dispose)
[email hidden]?
$ Game_map.light_sources.delete (self)
@ Light.dispose
@ Light = nil
end
unless dispose && @ list.nil?
command is in @ list
if command.code == 108 && command.parameters [0]. include? ("[light")
command.parameters [0]. scan (/ \ [light ([0.0-9.9] +) \] /)
effect = Light_Core :: Effects [$ 1.to_i]
@ = Light_SSource.new light (self, effect [0] effect [1] effect [2] effect [3])
$ Self game_map.light_sources <<
return
end
end
end
end
def draw_light
sx = @ light.sx
sy = @ light.sy
w = @ light.w
h = @ light.h
return if sx> 544 && sy> 416 && sx + w <0 && sy + h <0
$ Game_map.light_surface.bitmap.blt (sx, sy, @ light.bitmap, Rect.new (0,0, w, h) @ light.opacity)
end
def dispose_light
@ Light.dispose
end
def restore_light
@ Light.restore
end
end
if Light_Core :: Surface_UE
class Game_Interpreter
def command_223
wait (@ params [1]) if @ params [2]
end
end
end
class Game_Interpreter
def self_event
return $ game_map.events [@ event_id]
end
end
class Block_Surface
include Light_Core
attr_accessor: x1
attr_accessor: y1
attr_accessor: x2
attr_accessor: y2
attr_accessor: ready
attr_accessor: trash
def initialize (x1, y1, x2, y2)
@ X1 = x1
@ Y1 = y1
@ X2 = x2
@ Y2 = y2
@ Ready = false
@ Trash = false
end
Within def? (MIN_X, max_x, MIN_Y, max_y)
return @ x2> x1 MIN_X && @ <@ max_x && y2> y1 MIN_Y && @ <max_y
end
end
class Block_SL <Block_Surface
attr_reader: type
def initialize (x1, y1, x2, y2)
super (x1, y1, x2, y2)
@ Type = 0x01
end
def visible? (sx, sy)
return sx <@ x1
end
def render_shadow (phx, phy, sx, sy, range, bitmap)
@ M1 = (@ sy-y1) / (@ x1-sx)
@ N1 = sy - sx * @ m1
@ M2 = (@ sy-y2) / (x2-sx @)
@ N2 = sy - sx * @ m2
for x in @ x1 .. (sx + range)
init = shadow_iy (x)
bitmap.clear_rect (x-PHX, init-phy, 1, shadow_fy (x)-init +3)
end
end
shadow_iy def (x)
return @ @ m1 * x + n1
end
shadow_fy def (x)
return @ m2 * x + @ n2
end
end
class Block_SR <Block_Surface
attr_reader: type
def initialize (x1, y1, x2, y2)
super (x1, y1, x2, y2)
@ Type = 0x04
end
def visible? (sx, sy)
return sx> @ x1
end
def render_shadow (phx, phy, sx, sy, range, bitmap)
@ M1 = (@ sy-y1) / (@ x1-sx)
@ N1 = sy - sx * @ m1
@ M2 = (@ sy-y2) / (x2-sx @)
@ N2 = sy - sx * @ m2
for x in (sx-range). to_i .. @ x1
init = shadow_iy (x)
bitmap.clear_rect (x-PHX, init-phy, 1, shadow_fy (x)-init +3)
end
end
shadow_iy def (x)
return @ @ m1 * x + n1
end
shadow_fy def (x)
return @ m2 * x + @ n2
end
end
class Block_IL <Block_Surface
attr_reader: type
def initialize (x1, y1, x2, y2)
super (x1, y1, x2, y2)
@ Type = 0x019
end
def visible? (sx, sy)
return sx <@ x1 && sy> @ y1
end
def render_shadow (phx, phy, sx, sy, range, bitmap)
@ M1 = (@ sy-y1) / (@ x1-sx)
N1 = y1 @ @ - @ @ m1 * x1
@ M2 = (@ sy-y2) / (x2-sx @)
@ @ M2 = 0 if m2> 0
N2 = y2 @ @ - @ @ m2 * x2
for x in @ x1 .. (sx + range)
init = shadow_iy (x). bloom
bitmap.clear_rect (x-PHX, init-3-phy, 1, shadow_fy (x)-init +3)
end
end
shadow_iy def (x)
return @ @ m1 * x + n1
end
shadow_fy def (x)
return @ m2 * x + @ n2
end
end
class Block_IR <Block_Surface
attr_reader: type
def initialize (x1, y1, x2, y2)
super (x1, y1, x2, y2)
@ Type = 0x01c
end
def visible? (sx, sy)
return sx> sy && @ x1> y1 @
end
def render_shadow (phx, phy, sx, sy, range, bitmap)
@ M1 = (@ sy-y1) / (@ x1-sx)
N1 = y1 @ @ - @ @ m1 * x1
@ M2 = (@ sy-y2) / (x2-sx @)
@ M2 = 0 if @ m2 <0
N2 = y2 @ @ - @ @ m2 * x2
for x in (sx-range). to_i .. @ x1
init = shadow_iy (x). bloom
bitmap.clear_rect (x-PHX, init-3-phy, 1, shadow_fy (x)-init +3)
end
end
shadow_iy def (x)
return @ @ m1 * x + n1
end
shadow_fy def (x)
return @ m2 * x + @ n2
end
end
class Block_WL <Block_Surface
attr_reader: type
def initialize (x1, y1, x2, y2)
super (x1, y1, x2, y2)
@ Type = 0x011
end
def visible? (sx, sy)
return sx <@ x1 && sy <@ y2
end
def render_shadow (phx, phy, sx, sy, range, bitmap)
@ M1 = (@ sy-y1) / (@ x1-sx)
@ N1 = sy - sx * @ m1
@ M2 = (@ sy-y2) / (x2-sx @)
@ N2 = sy - sx * @ m2
for x in @ x1 .. (sx + range)
init = shadow_iy (x)
bitmap.clear_rect (x-PHX, init-phy, 1, shadow_fy (x)-init +2)
end
end
shadow_iy def (x)
return @ @ m1 * x + n1
end
shadow_fy def (x)
return @ m2 * x + @ n2
end
end
class Block_WR <Block_Surface
attr_reader: type
def initialize (x1, y1, x2, y2)
super (x1, y1, x2, y2)
@ Type = 0x014
end
def visible? (sx, sy)
return sx> @ x1 && sy <@ y2
end
def render_shadow (phx, phy, sx, sy, range, bitmap)
@ M1 = (@ sy-y1) / (@ x1-sx)
@ N1 = sy - sx * @ m1
@ M2 = (@ sy-y2) / (x2-sx @)
@ N2 = sy - sx * @ m2
for x in (sx-range). to_i .. @ x1
init = shadow_iy (x)
bitmap.clear_rect (x-PHX, init-phy, 1, shadow_fy (x)-init +2)
end
end
shadow_iy def (x)
return @ @ m1 * x + n1
end
shadow_fy def (x)
return @ m2 * x + @ n2
end
end
class Block_SU <Block_Surface
attr_reader: type
def initialize (x1, y1, x2, y2)
super (x1, y1, x2, y2)
@ Type = 0x02
end
def visible? (sx, sy)
return sy <@ y1
end
def render_shadow (phx, phy, sx, sy, range, bitmap)
if @ x1 == sx
@ M1 = nil
else
@ M1 = (@ sy-y1) / (@ x1-sx)
@ M1 + = ACC if @ m1 <-ACC
N1 = y1 @ @ - @ @ m1 * x1
end
if @ x2 == sx
@ M2 = nil
else
@ M2 = (@ sy-y2) / (x2-sx @)
@ N2 = sy - sx * @ m2
end
for y in y1 @ .. (sy + range)
init = shadow_ix (y)
bitmap.clear_rect (init-phx, phy-y, shadow_fx (y) +1.1-init)
end
end
shadow_ix def (y)
[email hidden]? ? X1 @: (y @-n1) / m1 @
end
shadow_fx def (y)
[email hidden]? ? X2 @: (y @-n2) / m2 @
end
end
class Block_SD <Block_Surface
attr_reader: type
def initialize (x1, y1, x2, y2)
super (x1, y1, x2, y2)
@ Type = 0x08
end
def visible? (sx, sy)
return sy> @ y1
end
def render_shadow (phx, phy, sx, sy, range, bitmap)
if @ x1 == sx
@ M1 = nil
else
@ M1 = (@ sy-y1) / (@ x1-sx)
@ M1 - m1 = if @ ACC> ACC
@ N1 = sy - sx * @ m1
end
if x2 == sx
@ M2 = nil
else
@ M2 = (@ sy-y2) / (x2-sx @)
@ N2 = sy - sx * @ m2
end
for y in (sy-range). to_i .. @ y1
init = shadow_ix (y)
bitmap.clear_rect (init-phx, phy-y, shadow_fx (y) +1.1-init)
end
end
shadow_ix def (y)
[email hidden]? ? X1 @: (y @-n1) / m1 @
end
shadow_fx def (y)
[email hidden]? ? X2 @: (y @-n2) / m2 @
end
end
class Spriteset_Map
include Light_Core
alias kbl_initialize initialize
alias update kbl_update
alias kbl_dispose dispose
def initialize
setup_lights
kbl_initialize
end
def update
kbl_update
update_lights
end
def dispose
kbl_dispose
dispose_lights
end
def dispose_lights
$ Game_map.lantern.dispose
$ Game_map.light_sources.each {| source | source.dispose_light}
$ Game_map.light_surface.bitmap.dispose
$ Game_map.light_surface.dispose
$ Game_map.light_surface = nil
end
def update_lights
$ Game_map.light_surface.bitmap.clear
$ Game_map.light_surface.bitmap.fill_rect (0,0,544,416, $ game_map.effect_surface.color)
$ Game_map.light_sources.each {| source | source.draw_light}
return unless $ game_map.lantern.visible
@ Btr = $ game_map.lantern.get_graphic
x = $ game_map.lantern.x
y = $ game_map.lantern.y
r = $ game_map.lantern.range
sx = x + r
sy = y + r
dr = r * 2
Game_map.surfaces.each {$ | s | s.render_shadow (x, y, sx, sy, r, @ btr) if s.visible? (Sx, sy) && s.within? (X, x + dr y , y + dr)}
end
def setup_lights
@ Btr = nil
$ Game_map.lantern.restore
$ Game_map.light_sources.each {| source | source.restore_light}
$ Game_map.light_surface = Sprite.new
$ Game_map.light_surface.bitmap Bitmap.new = (544.416)
$ Game_map.light_surface.bitmap.fill_rect (0,0,544,416, $ game_map.effect_surface.color)
$ Game_map.light_surface.blend_type = 2
Game_map.light_surface.opacity = $ $ game_map.effect_surface.alpha
$ Game_map.light_surface.z = Surface_Z
end
end

Original thread: https://forums.rpgmakerweb.com/threads/khas-awesome-light-effects-script-help-with-errors.18677/