Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================#
- # ** ILFX - Icy Light Effects ~ ENV Version
- #------------------------------------------------------------------------------#
- # ** Created by : IceDragon
- # ** Script-Status : Addon (ENV)
- # ** Date Created : 8/25/2010
- # ** Date Modified : 10/14/2010
- # ** Version : 1.0
- #------------------------------------------------------------------------------#
- # This is a fully custom light effects.
- # Credit goes to Kylock and BulletX for there light effects scripts.
- # Without them I wouldn't be able to write this.
- #------------------------------------------------------------------------------#
- $imported = {} if $imported == nil
- if $imported["IEX_Environment"]
- $ilfx_light_on = IEX::ENVIRONMENT::LIGHT_SYSTEM
- else
- $ilfx_light_on = true
- end
- if $ilfx_light_on
- $imported["ICY_LightFX"] = true
- module ICY
- module ILFX
- DEFAULT_IMAGE = "le.png" # Default Image used as light, located in Picture Folder
- # This is were you define all the light effects.
- # It follows a basic setting
- # "Name of Light Effect" => {
- # :zoom_x => width zoom for light,
- # :zoom_y => height zoom for light,
- # :opacity => 0 - 255 Opacity of light,
- # :tone => Tone used on light. (Use 'Tone.new(0, 0, 0, 255)' as default)
- # :blend_type => 0 for normal, 1 for additive, 2 for subtractive
- # :flicker_type => Currently there are only 3 types of flickers
- # SML_FLICK, MED_FLICK and LRG_FLICK
- # :custom_image => Custom Image used instead of default (Set to nil if you want it to use the default)
- # }
- LIGHT_EFFECTS = { # Don't touch this
- "FIRE" => {
- :zoom_x => 300 / 100.0, # 3
- :zoom_y => 300 / 100.0, # 3
- :opacity => 100,
- :type => "FIRE",
- :tone => Tone.new(255,-100,-255, 0),
- :blend_type => 1,
- :flicker_type => "SML_FLICK",
- :custom_image => nil,
- } , # Next Effect
- "LIGHT" => {
- :zoom_x => 1,
- :zoom_y => 1,
- :opacity => 150,
- :type => "LIGHT",
- :tone => Tone.new(0,0,0,0),
- :blend_type => 1,
- :flicker_type => "SML_FLICK",
- :custom_image => nil,
- } , # Next Effect
- "LIGHT2" => {
- :zoom_x => 6,
- :zoom_y => 6,
- :opacity => 150,
- :type => "LIGHT",
- :tone => Tone.new(0,0,0,0),
- :blend_type => 1,
- :flicker_type => "SML_FLICK",
- :custom_image => nil,
- } , # Next Effect
- "LIGHT3" => {
- :zoom_x => 1,
- :zoom_y => 1,
- :opacity => 150,
- :type => "LIGHT",
- :tone => Tone.new(0,0,0,0),
- :blend_type => 1,
- :flicker_type => "MED_FLICK",
- :custom_image => nil,
- } , # Next Effect
- "TORCH" => {
- :zoom_x => 6,
- :zoom_y => 6,
- :opacity => 150,
- :type => "TORCH",
- :tone => Tone.new(255,-100,-255, 0),
- :blend_type => 1,
- :flicker_type => "LRG_FLICK",
- :custom_image => nil,
- } , # Next Effect
- "TORCH2" => {
- :zoom_x => 6,
- :zoom_y => 6,
- :opacity => 150,
- :type => "TORCH",
- :tone => Tone.new(255,-100,-255, 0),
- :blend_type => 1,
- :flicker_type => "MED_FLICK",
- :custom_image => nil,
- } , # Next Effect
- "TORCH3" => {
- :zoom_x => 300 / 100.0,
- :zoom_y => 300 / 100.0,
- :opacity => 100,
- :type => "TORCH",
- :tone => Tone.new(0,0,0,0),
- :blend_type => 1,
- :flicker_type => "MED_FLICK",
- :custom_image => nil,
- } , # Next Effect
- "GROUND" => {
- :zoom_x => 2,
- :zoom_y => 2,
- :opacity => 100,
- :type => "GROUND",
- :tone => Tone.new(0,0,0,0),
- :blend_type => 1,
- :flicker_type => "MED_FLICK",
- :custom_image => nil,
- } , # Next Effect
- "GROUND2" => {
- :zoom_x => 2,
- :zoom_y => 2,
- :opacity => 100,
- :type => "GROUND",
- :tone => Tone.new(0,0,0,0),
- :blend_type => 1,
- :flicker_type => "MED_FLICK",
- :custom_image => nil,
- } , # Next Effect
- "GROUND3" => {
- :zoom_x => 2,
- :zoom_y => 2,
- :opacity => 100,
- :type => "GROUND",
- :tone => Tone.new(255,-255,-255, 255),
- :blend_type => 1,
- :flicker_type => "SML_FLICK",
- :custom_image => nil,
- } , # Next Effect
- "GROUND4" => {
- :zoom_x => 2,
- :zoom_y => 2,
- :opacity => 100,
- :type => "GROUND",
- :tone => Tone.new(-255,255,-255, 100),
- :blend_type => 1,
- :flicker_type => "MED_FLICK",
- :custom_image => nil,
- } , # Next Effect
- "GROUND5" => {
- :zoom_x => 2,
- :zoom_y => 2,
- :opacity => 100,
- :type => "GROUND",
- :tone => Tone.new(-255,255,255, 100),
- :blend_type => 1,
- :flicker_type => "MED_FLICK",
- :custom_image => nil,
- } , # Next Effect
- # Added effects
- "GREENGLOW" => {
- :zoom_x => 2,
- :zoom_y => 2,
- :opacity => 100,
- :type => "FIRE",
- :tone => Tone.new(-100, 100,-255, 0),
- :blend_type => 1,
- :flicker_type => "MED_FLICK",
- :custom_image => nil,
- } , # Next Effect
- }
- LIGHT_TYPES_SWITCH = {
- "FIRE" => 131,
- "LIGHT" => 132,
- "TORCH" => 133,
- "GROUND" => 134}
- UPDATE_WAIT = 1 # Update only every x frames, higher rates reduce lag but causes light drag
- # This switch is tagged along with the $light_switch
- # Even if you try to set this manually In-Game it will forcefully reset
- # Therefore it is only to be used with Day - Night Events
- # If you don't want to use this put 'nil' without quotes.
- GLOBAL_LIGHT_SWITCH = 513
- # Should there be Time System Support
- # Currently this will work with Jets Time System and ITS - Icy Time System
- # Just set the corresponding swithces which follow
- # If you set this to false, you can ignore the following stuff.
- TIME_SYSTEM_SUPPORT = true
- # The switch that will turn on when it is Dusk.
- DUSK_SWITCH = 560
- # The switch that will turn on when it is Night.
- NIGHT_SWITCH = 557
- # The switch that will turn on when it is Dawn.
- DAWN_SWITCH = 558
- # The switch that will turn on when it is Day.
- DAY_SWITCH = 559
- end
- end
- #------------------------------------------------------------------------------#
- # BRAKES!!! Where do you think your going!! No Touchie!!
- #------------------------------------------------------------------------------#
- module ICY
- module REGEXP
- module ILFX
- LFX_OFF_X = /<(?:LFX_OFF_X|lfx off x)[ ]*(\d+)>/i
- LFX_OFF_Y = /<(?:LFX_OFF_Y|lfx off y)[ ]*(\d+)>/i
- LFX_OFF_Z = /<(?:LFX_OFF_Z|lfx off z)[ ]*(\d+)>/i
- LFX_PRIO_LIGHT = /<(?:PRIO_LIGHT|prio light)>/i
- SML_FLICK = /(?:SML_FLICK|sml flick)/i
- MED_FLICK = /(?:MED_FLICK|med flick)/i
- LRG_FLICK = /(?:LRG_FLICK|lrg flick)/i
- OVERRIDE_MAIN = /<(?:OVERRIDE|ALWAYS_ON|always on)>/i
- end
- end
- end
- #==============================================================================
- # ** Spriteset_Map
- #------------------------------------------------------------------------------
- # This class brings together map screen sprites, tilemaps, etc. It's used
- # within the Scene_Map class.
- #==============================================================================
- class Spriteset_Map
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- alias ilfx_light_fx_initialize initialize unless $@
- def initialize(*args)
- @light_effects = []
- ilfx_light_fx_initialize(*args)
- @old_bool = nil
- check_lighting_cond
- initialize_lights
- end
- #--------------------------------------------------------------------------
- # * Dispose
- #--------------------------------------------------------------------------
- alias ilfx_light_fx_dispose dispose unless $@
- def dispose(*args)
- dispose_lights
- ilfx_light_fx_dispose(*args)
- end
- def dispose_lights
- for effect in @light_effects
- effect.dispose_light
- effect = nil
- end
- @light_effects.clear
- @light_effects = []
- ensure @light_effects.empty?
- end
- def check_lighting_cond
- if ICY::ILFX::TIME_SYSTEM_SUPPORT
- if $game_switches[ICY::ILFX::NIGHT_SWITCH]
- bool = true
- $game_map.need_refresh = true
- elsif $game_switches[ICY::ILFX::DUSK_SWITCH]
- bool = true
- $game_map.need_refresh = true
- elsif $game_switches[ICY::ILFX::DAWN_SWITCH]
- bool = false
- $game_map.need_refresh = true
- elsif $game_switches[ICY::ILFX::DAY_SWITCH]
- bool = false
- $game_map.need_refresh = true
- else
- bool = true
- $game_map.need_refresh = true
- end
- else
- bool = true
- $game_map.need_refresh = true
- end
- $light_switch = bool
- if ICY::ILFX::GLOBAL_LIGHT_SWITCH != nil
- $game_switches[ICY::ILFX::GLOBAL_LIGHT_SWITCH] = bool
- end
- return if @old_bool == bool
- dispose_lights
- @old_bool = bool
- initialize_lights
- end
- def ilfx_off_x(event)
- o_o = 0
- if event.list == nil
- o_o = 0
- else
- for i in 0...event.list.size
- if event.list[i].code == 108
- event.list[i].parameters.to_s.split(/[\r\n]+/).each { |line|
- case line
- when ICY::REGEXP::ILFX::LFX_OFF_X
- o_o += $1.to_i
- end }
- end
- end
- end
- return o_o
- end
- def ilfx_off_y(event)
- o_o = 0
- if event.list == nil
- o_o = 0
- else
- for i in 0...event.list.size
- if event.list[i].code == 108
- event.list[i].parameters.to_s.split(/[\r\n]+/).each { |line|
- case line
- when ICY::REGEXP::ILFX::LFX_OFF_Y
- o_o += $1.to_i
- end }
- end
- end
- end
- return o_o
- end
- def ilfx_prio_z(event)
- o_o = 0
- if event.list == nil
- o_o = 0
- else
- for i in 0...event.list.size
- if event.list[i].code == 108
- event.list[i].parameters.to_s.split(/[\r\n]+/).each { |line|
- case line
- when ICY::REGEXP::ILFX::LFX_OFF_Z
- o_o += $1.to_i
- when ICY::REGEXP::ILFX::LFX_PRIO_LIGHT
- o_o += event.screen_z
- end }
- end
- end
- end
- return o_o
- end
- def ilfx_always_on(event)
- if event.list == nil
- return false
- else
- for i in 0...event.list.size
- if event.list[i].code == 108
- event.list[i].parameters.to_s.split(/[\r\n]+/).each { |line|
- case line
- when ICY::REGEXP::ILFX::OVERRIDE_MAIN
- return true
- end }
- end
- end
- end
- return false
- end
- def initialize_lights
- icy_lights_fx = ICY::ILFX::LIGHT_EFFECTS
- return if @light_effects.empty? == false
- for event in $game_map.events.values
- next if event.list == nil
- for i in 0...event.list.size
- for light in icy_lights_fx.keys
- next if light == nil
- if event.list[i].code == 108 and event.list[i].parameters == [light]
- type = icy_lights_fx[light][:type]
- light_effects = Light_Effect.new(event, type, light)
- light_effects.light.zoom_x = icy_lights_fx[light][:zoom_x]
- light_effects.light.zoom_y = icy_lights_fx[light][:zoom_y]
- light_effects.light.opacity = icy_lights_fx[light][:opacity]
- light_effects.movement = icy_lights_fx[light][:flicker_type]
- light_effects.always_on = ilfx_always_on(event)
- @light_effects.push(light_effects)
- end
- end
- end
- end
- for effect in @light_effects
- next if effect == nil
- eve = effect.event
- x_size = icy_lights_fx[effect.lname][:zoom_x] * 200
- y_size = icy_lights_fx[effect.lname][:zoom_y] * 200
- x_l = (eve.real_x - x_size - $game_map.display_x) / 8
- y_l = (eve.real_y - y_size - $game_map.display_y) / 8
- x_o = ilfx_off_x(effect.event)
- y_o = ilfx_off_y(effect.event)
- effect.light.x = x_l + x_o
- effect.light.y = y_l + y_o
- effect.light.tone = icy_lights_fx[effect.lname][:tone]
- effect.light.blend_type = icy_lights_fx[effect.lname][:blend_type]
- if ICY::REGEXP::ILFX::SML_FLICK =~ effect.movement
- effect.flick_type = 1
- elsif ICY::REGEXP::ILFX::MED_FLICK =~ effect.movement
- effect.flick_type = 2
- elsif ICY::REGEXP::ILFX::LRG_FLICK =~ effect.movement
- effect.flick_type = 3
- else
- effect.flick_type = 0
- end
- z_set = ilfx_prio_z(effect.event)
- if z_set != 0 or z_set != nil
- effect.light.z = z_set
- else
- effect.light.z = 400
- end
- effect.update
- end
- end # End initialize_lights
- def ilfx_flicker(zoom_x, zoom_y, opacity, type, light)
- avg = (zoom_x + zoom_y) / 2
- x_f = 0
- y_f = 0
- op_f = ICY::ILFX::LIGHT_EFFECTS[light][:opacity]
- case type.to_s
- when ICY::REGEXP::ILFX::SML_FLICK # SML_FLICK
- val = avg / 30
- x_f = rand(val)
- y_f = rand(val)
- op_f = ICY::ILFX::LIGHT_EFFECTS[light][:opacity] - rand(10)
- when ICY::REGEXP::ILFX::MED_FLICK # MED_FLICK
- val = avg / 20
- x_f = rand(val)
- y_f = rand(val)
- op_f = ICY::ILFX::LIGHT_EFFECTS[light][:opacity] - rand(18)
- when ICY::REGEXP::ILFX::LRG_FLICK # LRG_FLICK
- val = avg / 10
- x_f = rand(val)
- y_f = rand(val)
- op_f = ICY::ILFX::LIGHT_EFFECTS[light][:opacity] - rand(23)
- else
- x_f = 0
- y_f = 0
- op_f = ICY::ILFX::LIGHT_EFFECTS[light][:opacity]
- end
- return [x_f, y_f, op_f]
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- alias ilfx_light_fx_update update unless $@
- def update
- ilfx_light_fx_update
- check_lighting_cond
- update_light_effects
- update_all_light_types
- end
- def update_light_effects
- icy_lights_fx = ICY::ILFX::LIGHT_EFFECTS
- for effect in @light_effects
- next if effect == nil
- if effect.always_on
- effect.light.visible = true
- else
- effect.light.visible = $light_switch
- end
- next if effect.light.visible == false
- effect.up_wait
- next if effect.want_update? == false
- lname = effect.lname
- zoom_x = icy_lights_fx[lname][:zoom_x]
- zoom_y = icy_lights_fx[lname][:zoom_y]
- opacity = icy_lights_fx[lname][:opacity]
- flick_type = icy_lights_fx[lname][:flicker_type]
- fx_arra = []
- fx_arra = ilfx_flicker(zoom_x, zoom_y, opacity, flick_type, lname)
- eve = effect.event
- x_size = icy_lights_fx[effect.lname][:zoom_x] * 200
- y_size = icy_lights_fx[effect.lname][:zoom_y] * 200
- if icy_lights_fx[effect.lname][:zoom_x] == 1
- x_l = (-0.25 / 2 * $game_map.display_x) + (effect.event.x * 32) - 15
- else
- x_l = (eve.real_x - x_size - $game_map.display_x) / 8
- end
- if icy_lights_fx[effect.lname][:zoom_y] == 1
- y_l = (-0.25 / 2 * $game_map.display_y) + (effect.event.y * 32) - 15
- else
- y_l = (eve.real_y - y_size - $game_map.display_y) / 8
- end
- x_o = ilfx_off_x(effect.event)
- y_o = ilfx_off_y(effect.event)
- effect.light.x = x_l + x_o - fx_arra[0]
- effect.light.y = y_l + y_o - fx_arra[1]
- effect.light.opacity = fx_arra[2]
- effect.update
- end
- end
- def update_all_light_types
- for ltype in ICY::ILFX::LIGHT_TYPES_SWITCH.keys
- next if ltype == nil
- for effect in @light_effects
- next if effect == nil
- if effect.type == ltype and $game_switches[ICY::ILFX::LIGHT_TYPES_SWITCH[ltype]]
- effect.light.visible = false
- elsif $light_switch and $game_switches[ICY::ILFX::LIGHT_TYPES_SWITCH[ltype]] == false
- effect.light.visible = true
- end
- end
- end
- end
- end
- class Light_Effect
- attr_accessor :light
- attr_accessor :event
- attr_accessor :type
- attr_accessor :lname
- attr_accessor :movement
- attr_accessor :selfwait
- attr_accessor :flick_type
- attr_accessor :always_on
- def initialize(event, type, lname)
- @light = Sprite.new
- if ICY::ILFX::LIGHT_EFFECTS[lname].has_key?(:custom_image)
- if ICY::ILFX::LIGHT_EFFECTS[lname][:custom_image] != nil
- @light.bitmap = Cache.picture(ICY::ILFX::LIGHT_EFFECTS[lname][:custom_image])
- else
- @light.bitmap = Cache.picture(ICY::ILFX::DEFAULT_IMAGE)
- end
- else
- @light.bitmap = Cache.picture(ICY::ILFX::DEFAULT_IMAGE)
- end
- @light.visible = true
- @event = event
- @type = type
- @lname = lname
- @selfwait = 0
- @always_on = false
- end
- def dispose_light
- if @light != nil
- @light.visible = false
- @light.dispose
- @light = nil
- end
- end
- def update
- return if @light == nil
- @light.update
- end
- def want_update?
- return true if @selfwait == ICY::ILFX::UPDATE_WAIT
- return false
- end
- def up_wait
- @selfwait = (@selfwait + 1) % (ICY::ILFX::UPDATE_WAIT + 1)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment