Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- Thomas Edison VX
- Version: 0.1
- Author: BulletXt ([email protected])
- Date: 12/06/2009
- Script based upon Kylock's (http://www.rpgmakervx.net/index.php?showtopic=2432)
- Description:
- To make an event glow, put a Comment inside event with the name of one of the
- light modes in the table below.
- When importing this script to a new project, be sure to copy
- Graphics/Pictures/le.png to your project.
- You can make a specific light type turn off/on by turning
- one of the following switches id ON/off. By default, the switches are off so
- the lights will show. Of course, turning all switches to ON will make all
- light types go off.
- The parameters you can modify for each light type are as follows:
- Name: What you put in the comment for the event.
- Switch: The switch that deactivates this type of light.
- Zoom: The radius of the light in units of 32 pixels.
- Opacity: The opacity of the light.
- Vert: The upwards offset for the light, use in case you want torches, etc.
- Flicker: The random offset of the position when flickering, in pixels.
- 0 creates a steady light source.
- -1 will hold the position, but flicker the opacity.
- RGBK: The tone values for the source. Work like the Tint Picture command.
- You can also make custom effects if you know a bit of Ruby.
- =end
- module BLXT
- #id switch that if ON turns off FIRE mode lights
- FIRE = 87
- #id switch that if ON turns off LIGHT mode lights
- LIGHT = 86
- #id switch that if ON turns off GROUND mode lights
- GROUND = 85
- #id switch that if ON turns off TORCH mode lights
- TORCH = 84
- LIGHT_TYPES = {
- # Name Switch Zoom Opacity Vert Flicker R G B K
- "DORMANT" => [ 0, 1, 0, 0, 0, 0, 0, 0, 0 ],
- #Use this for things that can be "off" when the player saves.
- "FIRE" => [ FIRE, 3, 100, 0, 3, 255,-100,-255, 0 ],
- "LIGHT" => [ LIGHT, 1, 150, 0, 0, 0, 0, 0, 0 ],
- "LIGHT2" => [ LIGHT, 6, 150, 20, 0, 0, 0, 0, 0 ],
- "LIGHT3" => [ LIGHT, 1, 150, 20, -1, 0, 0, 0, 0 ],
- "TORCH" => [ TORCH, 6, 150, 20, 10, 255,-100,-255, 0 ],
- "TORCH2" => [ TORCH, 6, 150, 20, -1, 255,-100,-255, 0 ],
- "TORCH3" => [ TORCH, 3, 100, 0, 3, 255,-100,-255, 0 ],
- "GROUND" => [GROUND, 2, 100, 0, 0, 0, 0, 0, 0 ],
- "GROUND2" => [GROUND, 2, 100, 0, -1, 0, 0, 0, 0 ],
- "GROUND3" => [GROUND, 2, 100, 0, 0, 255,-255,-255, 255 ],
- "GROUND4" => [GROUND, 2, 100, 0, 0,-255, 255,-255, 100 ],
- "GROUND5" => [GROUND, 2, 100, 0, 0,-255, 255, 255, 100 ],
- }
- # this value can be true or false. If true, it enables compatibility with
- # KGC_DayNight script. When it's night, lights will automatically go on, when
- # morning comes back lights will go off. If you set this to true, be sure to
- # place this script below KGC_DayNight script in the Scripting Editor of VX.
- ENABLE_KGC_DAY_NIGHT_SCRIPT = true
- =begin
- This value must be exactly the same of "PHASE_VARIABLE" setting in KGC_DayNight
- script. By default the script sets it to 11.
- To make the event light go on/off with DayNight system, set the event page
- to be triggered with this variable id and set it to be 1 or above.
- =end
- KGC_DAY_NIGHT_SCRIPT_VARIABLE = 11
- end
- =begin
- You can make custom effects here.
- Some values you can use:
- @light.
- opacity
- x
- y
- zoom_x
- zoom_y
- tone
- @phase (value from 0 to 120 for use in pulsing lights)
- $cm_light_ticker (goes from 0 to 600 over a period of 10 seconds)
- =end
- class Light_Effect
- def custom_effects
- case @key
- when "TORCH"
- @light.opacity = rand(30) + 70
- when "CRYSTAL"
- @light.opacity = 100 + Math.cos(($cm_light_ticker - 300 + @phase) / (Math::PI*15))*15
- end
- end
- end
- #=============================================================================#
- # Things may break if code is modified beyond this point. #
- #=============================================================================#
- $bulletxt_day_check = 0
- $cm_light_ticker = 0
- class Spriteset_Map
- alias bulletxt_spriteset_map_initalize initialize
- def initialize
- @light_effects = []
- initialize_lights
- bulletxt_spriteset_map_initalize
- update
- end
- alias bulletxt_spriteset_map_dispose dispose
- def dispose
- bulletxt_spriteset_map_dispose
- for effect in @light_effects
- effect.light.dispose
- end
- @light_effects = []
- end
- alias bulletxt_spriteset_map_update update
- def update
- bulletxt_spriteset_map_update
- check_day_night if BLXT::ENABLE_KGC_DAY_NIGHT_SCRIPT
- update_light_effects
- end
- def check_day_night
- #if night
- if $bulletxt_day_check == 0
- if $game_variables[BLXT::KGC_DAY_NIGHT_SCRIPT_VARIABLE] == 1
- $bulletxt_day_check = 1
- end
- else
- #if morning
- if $game_variables[BLXT::KGC_DAY_NIGHT_SCRIPT_VARIABLE] == 3
- $game_variables[BLXT::KGC_DAY_NIGHT_SCRIPT_VARIABLE] = -1
- $bulletxt_day_check = 0
- end
- end
- end
- def initialize_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
- for k in BLXT::LIGHT_TYPES.keys
- p_array = [k]
- if event.list[i].parameters == p_array
- effect = Light_Effect.new(event, k)
- event.set_light_effect(effect)
- @light_effects.push(effect)
- end
- end
- end
- end
- end
- end
- def update_light_effects
- for effect in @light_effects
- if !effect.event.has_light_effect?
- effect.event.set_light_effect(effect)
- effect.reset
- end
- effect.update_light_effects
- end
- $cm_light_ticker = ($cm_light_ticker + 1) % 600
- #close def
- end
- #close class
- end
- class Light_Effect
- attr_accessor :light
- attr_accessor :event
- attr_reader :key
- def initialize(event, key)
- @light = Sprite.new
- @light.bitmap = Cache.picture("le.png")
- @light.visible = true
- @light.z = 1000
- @phase = rand(120)
- @event = event
- @lightswitch = 0
- @available = true
- setup(key)
- end
- def setup(key)
- @key = key
- light_params = BLXT::LIGHT_TYPES[key]
- @lightswitch = light_params[0]
- @light.zoom_y = light_params[1]
- @light.zoom_x = light_params[1]
- @light.opacity = light_params[2]
- @offset = (@light.width/2)*light_params[1]*8
- @vertical = light_params[3]
- @flicker = light_params[4]
- @light.blend_type = 1
- @light.tone = Tone.new(light_params[5], light_params[6], light_params[7],
- light_params[8])
- end
- def update_light_effects
- pos_flicker = @flicker > 0 ? @flicker : 0
- @light.x = (@event.real_x - @offset - $game_map.display_x) / 8 + 16 + rand(pos_flicker*2) - pos_flicker
- @light.y = (@event.real_y - @offset - $game_map.display_y) / 8 + 16 + rand(pos_flicker*2) - @vertical - pos_flicker
- @light.opacity = rand(10) + 90 if @flicker != 0
- if $game_switches[@lightswitch] == true or !@available or @event.erased?
- @light.visible = false
- else
- @light.visible = true
- end
- custom_effects
- end
- def reset
- @available = false
- return if @event.list == nil
- for i in 0...@event.list.size
- if @event.list[i].code == 108
- for k in BLXT::LIGHT_TYPES.keys
- p_array = [k]
- if @event.list[i].parameters == p_array
- setup(k)
- @available = true
- end
- end
- end
- end
- end
- end
- class Game_Event < Game_Character
- def set_light_effect(light_effect)
- @light_effect = light_effect
- end
- def has_light_effect?
- return @light_effect != nil
- end
- def erased?
- return @erased
- end
- alias setup_cm setup
- def setup(new_page)
- setup_cm(new_page)
- if has_light_effect?
- @light_effect.reset
- end
- end
- end
- class Scene_File < Scene_Base
- def do_save
- for event in $game_map.events.values
- event.set_light_effect(nil)
- end
- file = File.open(@savefile_windows[@index].filename, "wb")
- write_save_data(file)
- file.close
- return_scene
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment