Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Cache
- def self.lights(filename)
- load_bitmap("Graphics/Lights/",filename)
- end
- end
- class Game_Event < Game_Character
- def light(charsprite)
- owo = '<light[ ]*=?[ ]*([\w*\d*\s*]*)[ ]*?,?[ ]*?(true|false)?,?(.*)>'
- rgxp = /<lfx[ ]*(::|=)?[ ]*(.*)>/i
- return if @page.nil?
- @page.list.each do |item|
- if [108,408].include?(item.code)
- txt = item.parameters[0]
- return nil unless txt =~ rgxp
- filename = txt =~ /fn[ ]*=?[ ]*([\w*\d*\s*]*)/i ? $1.to_s : nil
- flicker = txt =~ /f[ ]*=?[ ]*\[(\d+),(\d+)\]/i ? [$1.to_i,$2.to_i] : nil
- zx = txt =~ /zx[ ]*=?[ ]*(\d*)/i ? $1.to_i : 1
- zy = txt =~ /zy[ ]*=?[ ]*(\d*)/i ? $1.to_i : 1
- blend = txt =~ /b[ ]*=?[ ]*[0|1|2]/i ? $1.to_i : nil
- color = nil
- if txt =~ /clr[ ]*=?[ ]*\[(\d+),?[ ]*(\d+),?[ ]*,(\d+),?[ ]*(\d+)?\]/i
- color = Color.new($1.to_f,$2.to_f,$3.to_f,$4.nil? ? 255 : $4.to_f)
- end
- if FileTest.exist?(sprintf("Graphics/Lights/%s.png", filename))
- s = Sprite_Light.new(self,charsprite)
- s.bitmap = Cache.lights(filename).clone
- s.flicker = flicker
- s.zoom_x = zx
- s.zoom_y = zy
- s.color = color unless color.nil?
- s.blend_type = blend unless blend.nil?
- return s
- end
- end
- end
- return nil
- end
- end
- class Spriteset_Map
- attr_accessor :lightfxs
- alias init_lightfxs initialize
- def initialize
- @lightfxs = []
- init_lightfxs
- setup_lightz
- end
- def setup_lightz
- $game_map.events.values.each do |i|
- s = nil
- @character_sprites.each do |c| s = c if c.character == i end
- @lightfxs[i.id] = i.light(s)
- end
- end
- alias update_lightfxs update
- def update
- update_lightfxs
- update_lightz
- end
- alias dispose_lightfxs dispose
- def dispose
- dispose_lightz
- dispose_lightfxs
- end
- def update_lightz
- @lightfxs.each do |s| s.update unless s.nil? or s.disposed? or s.bitmap.nil? or s.bitmap.disposed? end
- end
- def dispose_lightz
- @lightfxs.each do |s| s.dispose unless s.nil? or s.disposed? end
- end
- end
- class Sprite_Light < Sprite_Base
- attr_accessor :flicker
- def initialize(event,charsprite)
- @event = event
- @charsprite = charsprite
- @flicker = false
- super(nil)
- set_xyz
- end
- def update
- super
- set_xyz
- if !@flicker.nil?
- self.visible = (rand(@flicker[0]) != @flicker[0]-1)
- self.opacity = 255-rand(@flicker[1])
- else
- self.visible = true
- self.opacity = 150
- end
- end
- def set_xyz
- a = (@event.screen_x.to_f)
- b = (@event.screen_y.to_f)
- a -= (self.width/2)+((self.zoom_x-1)*self.width/2)
- b -= self.height+((self.zoom_y-1)*self.height/2)
- self.x = a
- self.y = b
- self.z = @event.screen_z
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement