#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=: # DRG Fade Effect Room # Version: 1.15 # Author : LiTTleDRAgo #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=: # วิธีใช้ ตั้งใน events ให้ตั้งชื่อเป็น ObjectMask แล้วใช้คำสั่ง คำอธิบายว่า # # ภาพสีที่จะปิดบังส่วนบน # ([0,0,9,7]) # ([ ])ใช้อาณาเขตปิดเปิดร่วมกัน # (0,7,19,14),[0,8,19,14] # ( )ปิด ,[ ]เปิด ใช้อาณาเขตปิดเปิดแยกกัน #============================================================================== # (x1,y1,x2,y2) # (จุดเริ่มx1y1 ,จุดสิ้นสุดx2y2) ปิดบังอาณาเขตที่กำหนดไว้ # [x1,y1,x2,y2] # (จุดเริ่มx1y1 ,จุดสิ้นสุดx2y2) เข้าอาณาเขตนึ้จะเปิด ที่บังก่อนหน้านี้ #============================================================================== # ** Game_Event #------------------------------------------------------------------------------ # This class deals with events. It handles functions including event page # switching via condition determinants, and running parallel process events. # It's used within the Game_Map class. #============================================================================== class Game_Event < Game_Character #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :event end #============================================================================== # ** Spriteset_Map #------------------------------------------------------------------------------ # This class brings together map screen sprites, tilemaps, etc. # It's used within the Scene_Map class. #============================================================================== class Spriteset_Map #-------------------------------------------------------------------------- # * Alias Listing #-------------------------------------------------------------------------- alias_method :drg132_update, :update if !method_defined?(:drg132_update) #-------------------------------------------------------------------------- # * Objects Initialization #-------------------------------------------------------------------------- def init_fadesprite @fade_sprite = [] $game_map.events.keys.sort.each {|i| next unless $game_map.events[i].event.name =~ /ObjectMask/i $game_map.events[i].list.each {|list| parameter = list.parameters[0] next if parameter.nil? if parameter =~ //i @color = Color.new($1.to_i, $2.to_i, $3.to_i) end @color = Color.new(40,40,40) if @color.nil? if parameter =~ /\((\d+),(\d+),(\d+),(\d+)\)/ a,b,c,d = $1.to_i,$2.to_i,$3.to_i,$4.to_i parameter =~ /\[(\d+),(\d+),(\d+),(\d+)\]/ e,f,g,h = $1.to_i,$2.to_i,$3.to_i,$4.to_i elsif parameter =~ /\(\[(\d+),(\d+),(\d+),(\d+)\]\)/ a,b,c,d = $1.to_i,$2.to_i,$3.to_i,$4.to_i e,f,g,h = a,b,c,d end next unless !a.nil? && a.is_a?(Numeric) sprite = Sprite.new(@viewport1) sprite.x, sprite.y = a*32+16, b*32+16 sprite.z = 998 sprite.bitmap = Bitmap.new((c-a)*32,(d-b)*32) sprite.bitmap.fill_rect(0,0,sprite.bitmap.width, sprite.bitmap.height,@color) if parameter =~ /<(\d+),(\d+),(\d+),(\d+)>/ sprite.bitmap.fill_rect($1.to_i * 32 - sprite.x + 16, $2.to_i * 32 - sprite.y + 16, ($3.to_i - $1.to_i) * 32, ($4.to_i - $2.to_i) * 32, Color.new(0, 0, 0, 0)) end mask = [sprite, [e, f, g, h], [], [$game_player.x,$game_player.y]] if parameter =~ /{(\d+),(\d+),(\d+),(\d+)}/ mask[2] = [$1.to_i, $2.to_i, $3.to_i, $4.to_i] end if parameter =~ /<{(\d+),(\d+),(\d+),(\d+)}>/ e,f,g,h = $1.to_i,$2.to_i,$3.to_i,$4.to_i sprite.bitmap.fill_rect(e*32-sprite.x+16,f*32-sprite.y+16, (g-e)*32,(h-f)*32, Color.new(0,0,0,0)) mask[2] = [e,f,g,h] end mask[0].opacity = (mask[1][0]..mask[1][2]) === mask[3][0] && (mask[1][1]..mask[1][3]) === mask[3][1] && (mask[2].empty? || !((mask[2][0]..mask[2][2]) === mask[3][0]&& (mask[2][1]..mask[2][3]) === mask[3][1])) ? 0 : 255 @fade_sprite << mask }} end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update @fade_sprite.nil? ? init_fadesprite : @fade_sprite.each {|mask| mask[0].ox, mask[0].oy = $game_map.display_x/4, $game_map.display_y/4 a = [(mask[1][0]..mask[1][2]) === $game_player.x && (mask[1][1]..mask[1][3]) === $game_player.y && (mask[2].empty? || !((mask[2][0]..mask[2][2]) === $game_player.x && (mask[2][1]..mask[2][3]) === $game_player.y)), mask[0].opacity] mask[0].opacity = a[0] ? [a[1] - 16, 0].max : [a[1] + 8, 255].min } drg132_update end end $drg_fade_room = true