#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=: # DRG Fade Effect Room # Version: 2.25 # Author : LiTTleDRAgo #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=: module LiTTleDRAgo FADE_ROOM = { #----------------------------------------------------------------- # Editable Section # # - Format : # MAP_ID => "Command", # # -or- # # MAP_ID => { # 'ROOM_1' => "Command", # 'ROOM_2' => "Command", # 'ROOM_3' => "Command", # }, #----------------------------------------------------------------- 1 => " (0,0,9,7) ", 2 => { 'Left Room' => " (0,0,9,7) ", 'Right Room' => " ([9,0,19,7]) ", 'Middle Room' => " (0,7,19,14),[0,7,19,14] ", }, } #----------------------------------------------------------------- # - List of Command # * Color config # or # * Fade time (in frames) # # * Add mask # (x1,y1,x2,y2) # * Hide mask in contact # hide if player in area between (x1,y1) (x2,y2) # (.....),[x1,y1,x2,y2] # * Add mask + Hide in contact # equal to (x1,y1,x2,y2),[x1,y1,x2,y2] # ([x1,y1,x2,y2]) #----------------------------------------------------------------- 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) alias_method :drg132_dispos, :dispose if !method_defined?(:drg132_dispos) #-------------------------------------------------------------------------- # * Objects Initialization #-------------------------------------------------------------------------- def init_fadesprite @fade_sprite.each {|m| m[0].dispose } if @fade_sprite @fade_sprite = [] @fade_time = [16,16] @fade_oxy = [0,0] @fade_picture = Bitmap.new(1,1) @fade_effect = a = ($game_system.fade_room[$game_map.map_id] || '').dup a = a.invert.keys.join if a && a.is_a?(Hash) a.to_s.split(/\n/).to_a.each {|a| create_fade_effect(a)} if a $game_map.events.keys.sort.each {|b| $game_map.events[b].class.send(:attr_reader, :event)# {@event} next unless $game_map.events[b].event.name =~ /ObjectMask/i $game_map.events[b].list.each {|c| create_fade_effect(c.parameters[0])}} end #-------------------------------------------------------------------------- # * check_fade_parameter #-------------------------------------------------------------------------- def create_fade_effect(parameter) if parameter =~ //i j = [$1.to_i,$2.to_i,$3.to_i,255] elsif parameter =~ //i j = [$1.to_i,$2.to_i,$3.to_i,$4.to_i] end if parameter =~ //i @fade_time = [$1.to_i,$2.to_i] end if parameter =~ //i @fade_oxy = [$1.to_i,$2.to_i] end if parameter =~ //i b = ["#{$1}","#{$2}"] b = (b == ['0']*2) ? [1,1] : ["Graphics/#{b.join('/')}"] @fade_picture = Bitmap.new(*b) end @fade_color = Color.new(*j) if !j.nil? && j[0..2] != [0]*3 if parameter =~ /\((.+?),(.+?),(\d+),(\d+)\)/ a = [$1.to_i,$2.to_i,$3.to_i,$4.to_i] parameter =~ /\[(\d+),(\d+),(\d+),(\d+)\]/ e = [$1.to_i,$2.to_i,$3.to_i,$4.to_i] elsif parameter =~ /\(\[(\d+),(\d+),(\d+),(\d+)\]\)/ a = e = [$1.to_i,$2.to_i,$3.to_i,$4.to_i] elsif parameter =~ /\(\[(\d+),(\d+)\]\)/ a = e = [$1.to_i,$2.to_i] a = e = [a,e].flatten end return unless !a.nil? && a.flatten[0].is_a?(Numeric) && @fade_color sw = [a[2]-a[0].abs, a[3]-a[1].abs] sa = [sw[0] > 0 ? 16 : 0 , sw[1] > 0 ? 16 : 0] x,y = [a[0]*32+sa[0],0].max, [a[1]*32+sa[1],0].max w,h = [sw[0],1].max*32,[sw[1],1].max*32 s = Sprite.new s.bitmap = Bitmap.new(w,h) s.bitmap.fill_rect(0,0,s.bitmap.width,s.bitmap.height,@fade_color) s.bitmap.stretch_blt(s.bitmap.rect, @fade_picture, @fade_picture.rect) s.x, s.y, s.z, tc = x, y, 998, Color.new(*[0]*4) if parameter =~ /<(\d+),(\d+),(\d+),(\d+)>/ a,b,c,d = $1.to_i,$2.to_i,$3.to_i,$4.to_i s.bitmap.fill_rect(a*32-s.x+16,b*32-s.y+16,(c-a)*32,(d-b)*32,tc) end mask = [s, e, [], fade_coord_player] 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+)}>/ a,b,c,d = $1.to_i,$2.to_i,$3.to_i,$4.to_i s.bitmap.fill_rect(a*32-s.x+16,b*32-s.y+16,(c-a)*32,(d-b)*32,tc) mask[2] = [a,b,c,d] end mask[0].ox, mask[0].oy = $game_map.display_x/4, $game_map.display_y/4 mask[4..6] = (mask[1][0]..mask[1][2]),(mask[1][1]..mask[1][3]),@fade_time mask[7..11] = s.bitmap.dup,0,0,@fade_oxy[0],@fade_oxy[1] mask[0].opacity = mask[4] === mask[3][0] && mask[5] === 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 $game_system.init_fade_room if $game_system.fade_room.nil? ($game_system.fade_room[$game_map.map_id] || '') != @fade_effect || @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 = fade_coord_player a = [mask[4] === a[0] && mask[5] === a[1] && (mask[2].empty? || !((mask[2][0]..mask[2][2]) === a[0] && (mask[2][1]..mask[2][3]) === a[1])), mask[0].opacity,mask[6]].flatten mask[0].opacity = a[0] ? [a[1] - a[3],0].max : [a[1] + a[2], 255].min next if mask[10] == 0 && mask[11] == 0 w,h = mask[0].bitmap.width, mask[0].bitmap.height mask[0].bitmap.blt(mask[8],mask[9], mask[7], mask[7].rect ) mask[0].bitmap.blt(mask[8],h+mask[9], mask[7], mask[7].rect ) mask[0].bitmap.blt(mask[8],-h+mask[9], mask[7], mask[7].rect ) mask[0].bitmap.blt(w+mask[8],mask[9], mask[7], mask[7].rect ) mask[0].bitmap.blt(-w+mask[8],mask[9], mask[7], mask[7].rect ) mask[0].bitmap.blt(w+mask[8],h+mask[9], mask[7], mask[7].rect ) mask[0].bitmap.blt(w+mask[8],-h+mask[9], mask[7], mask[7].rect ) mask[0].bitmap.blt(-w+mask[8],h+mask[9], mask[7], mask[7].rect ) mask[0].bitmap.blt(-w+mask[8],-h+mask[9], mask[7], mask[7].rect ) mask[8] = mask[8] >= w || mask[8] <= -w ? 0 : mask[8] + mask[10] mask[9] = mask[9] >= h || mask[9] <= -h ? 0 : mask[9] + mask[11] } drg132_update end #-------------------------------------------------------------------------- # * Frame Dispose #-------------------------------------------------------------------------- def dispose @fade_sprite.each {|mask| mask[0].dispose } if @fade_sprite drg132_dispos end #-------------------------------------------------------------------------- # * Fade Coord Player #-------------------------------------------------------------------------- def fade_coord_player return [$game_player.real_x/128, $game_player.real_y/128] return [$game_player.x, $game_player.y] end end #============================================================================== # ** Game_System #------------------------------------------------------------------------------ # This class handles data surrounding the system. # Refer to "$game_system" for the instance of this class. #============================================================================== class Game_System #-------------------------------------------------------------------------- # * init_fade_room #-------------------------------------------------------------------------- def init_fade_room() @fade_room = LiTTleDRAgo::FADE_ROOM end #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :fade_room end $drg_fade_room = true