| 
 
| 赞 | 168 |  
| VIP | 6 |  
| 好人卡 | 208 |  
| 积分 | 225 |  
| 经验 | 137153 |  
| 最后登录 | 2025-4-1 |  
| 在线时间 | 8598 小时 |  
 Lv5.捕梦者 
	梦石0 星屑22499 在线时间8598 小时注册时间2011-12-31帖子3361 | 
| 本帖最后由 tseyik 于 2013-9-15 22:12 编辑 
 
 复制代码#==============================================================================
# ■リージョン可視領域設定 for RGSS3 Ver1.02-β
# □作成者 kure
#===============================================================================
module KURE
  module RegionSee
    REGION_SEE = []
    NORMAL_REGION = []
    NORMAL_MAP = []
    
    #適用エリア設定
      #アクターを中心として消去するタイルイベントの範囲を設定します。
      AREA_X = 30
      AREA_Y = 30
      
      #この設定を適用しないMAPIDの設定
      NORMAL_MAP = []
    
    #通常リージョン
    #設定されたリージョンは設定が適用されない
    NORMAL_REGION = []
    
    #複数リージョン設定
    #REGION_SEE[リージョンID] = [見えるリージョン]
    REGION_SEE[6] = [1,2]
    REGION_SEE[7] = [2,3]
    REGION_SEE[8] = [3,4]
    REGION_SEE[9] = [4,5]
    
    #リージョン未設定のマスの処理
    
      #表示設定
      # 0 = リージョン設定マスに乗れば見えなくなる
      # 1 = 常に見える
      ZERO_REGION_SEE_MODE = 0
    
      #動作処理
      # 0 = 他のリージョンと同じ動作(リージョン未設定のみ見える)
      # 1 = 全てのマスが見える
      ZERO_REGION_ACT_MODE = 1
    
  end
end
#==============================================================================
# ■ Sprite_Character
#==============================================================================
class Sprite_Character < Sprite_Base
  #--------------------------------------------------------------------------
  # ● その他の更新(再定義)
  #--------------------------------------------------------------------------
  def update_other
    self.opacity = @character.opacity
    self.blend_type = @character.blend_type
    self.bush_depth = @character.bush_depth
    self.visible = [email protected] && [email protected]
  end
end
#==============================================================================
# ■ Game_Map
#==============================================================================
class Game_Map
  attr_accessor :keep_map_data            # マップデータ保存
  #--------------------------------------------------------------------------
  # ● セットアップ(エイリアス再定義)
  #--------------------------------------------------------------------------
  alias k_transcolor_before_setup setup
  def setup(map_id)
    k_transcolor_before_setup(map_id)
    @keep_map_data = @map.data.clone
  end
  #--------------------------------------------------------------------------
  # ● 指定座標にあるタイル ID の取得(エイリアス再定義)
  #--------------------------------------------------------------------------
  alias k_transcolor_before_tile_id tile_id
  def tile_id(x, y, z)
    if @keep_map_data
      return @keep_map_data[x, y, z] if @keep_map_data[x, y, z]
      return 0 unless @keep_map_data[x, y, z]
    end
    
    k_transcolor_before_tile_id(x, y, z)
  end
end
#==============================================================================
# ■ Game_CharacterBase
#==============================================================================
class Game_CharacterBase
  attr_accessor :transparent2              # 透明状態  
end
#==============================================================================
# ■ Game_Player
#==============================================================================
class Game_Player < Game_Character
  attr_accessor :keep_passed_region            # リージョンID保存
  #--------------------------------------------------------------------------
  # ● 歩数増加(エイリアス再定義)
  #--------------------------------------------------------------------------
  alias k_transcolor_before_increase_steps increase_steps
  def increase_steps
    refresh_region_tile(@x, @y) unless KURE::RegionSee::NORMAL_MAP.include?($game_map.map_id)
    k_transcolor_before_increase_steps
  end
  #--------------------------------------------------------------------------
  # ● 場所移動の実行(エイリアス再定義)
  #--------------------------------------------------------------------------
  alias k_transcolor_before_perform_transfer perform_transfer
  def perform_transfer
    keep_x = @new_x
    keep_y = @new_y
    keep_id = @new_map_id
    keep_trans = 0
    keep_trans = 1 if transfer?
    
    k_transcolor_before_perform_transfer
    if keep_trans == 1
      refresh_region_tile(keep_x, keep_y) unless KURE::RegionSee::NORMAL_MAP.include?(keep_id)
    end
  end
  #--------------------------------------------------------------------------
  # ● タイルの更新(追加定義)
  #--------------------------------------------------------------------------
  def refresh_region_tile(x,y)    
    id = $game_map.region_id(x, y)
    
    if @keep_passed_region != id
      @keep_passed_region = id
      width = $game_map.width
      height = $game_map.height
      
      
      x1 = [0,@x - (KURE::RegionSee::AREA_X / 2).to_i].max
      x2 = [@x + (KURE::RegionSee::AREA_X / 2).to_i,width].min
      y1 = [0,@y - (KURE::RegionSee::AREA_Y / 2).to_i].max
      y2 = [@y + (KURE::RegionSee::AREA_Y / 2).to_i,height].min
      
      rigion_area = Array.new
      #指定リージョンのエリアのみを取得
      for w in x1..x2
        for h in y1..y2
          see = 0
          event = $game_map.events_xy(w,h)
          see = 1 if $game_map.region_id(w, h) == @keep_passed_region
          
          #リージョンの設定
          if KURE::RegionSee::REGION_SEE[@keep_passed_region]
            see = 1 if KURE::RegionSee::REGION_SEE[@keep_passed_region].include?($game_map.region_id(w, h))
          end 
          
          #0リージョン上では全てが見える設定の場合
          if @keep_passed_region == 0
            see = 1 if KURE::RegionSee::ZERO_REGION_ACT_MODE == 1
          end
          
          see = 1 if KURE::RegionSee::NORMAL_REGION.include?(@keep_passed_region)
            
          #0リージョンは常に見える設定の場合
          if $game_map.region_id(w, h) == 0
            see = 2 if KURE::RegionSee::ZERO_REGION_SEE_MODE == 1
          end
          
          rigion_area.push([w,h,see]) if see != 0
          
          #一旦タイルイベントを消去
          $game_map.data[w, h, 0] = 0
          $game_map.data[w, h, 1] = 0
          $game_map.data[w, h, 2] = 0
            
          event.each do |ev|
            ev.transparent2 = true
          end
          
        end
      end
      
      #見える範囲を適用する
      rigion_area.each do |area|
        if area[2] == 1
          s_x_area1 = [0,area[0] - 1].max
          s_x_area2 = [width,area[0] + 1].min
          s_y_area1 = [0,area[1] - 1].max
          s_y_area2 = [height,area[1] + 1].min
        
          for sw in s_x_area1..s_x_area2
            for sy in s_y_area1..s_y_area2
              #タイルイベントを復活 
              event = $game_map.events_xy(sw,sy)
              $game_map.data[sw, sy, 0] = $game_map.keep_map_data[sw, sy, 0]
              $game_map.data[sw, sy, 1] = $game_map.keep_map_data[sw, sy, 1]
              $game_map.data[sw, sy, 2] = $game_map.keep_map_data[sw, sy, 2]
            
              event.each do |ev|
                  ev.transparent2 = false
              end
              
            end
          end
          
        elsif area[2] == 2
          sw = area[0]
          sy = area[1]
          event = $game_map.events_xy(sw,sy)
          $game_map.data[sw, sy, 0] = $game_map.keep_map_data[sw, sy, 0]
          $game_map.data[sw, sy, 1] = $game_map.keep_map_data[sw, sy, 1]
          $game_map.data[sw, sy, 2] = $game_map.keep_map_data[sw, sy, 2]
            
          event.each do |ev|
            ev.transparent2 = false
          end
        
        end
      end
          
    end
  end
  
end
 | 
 评分
查看全部评分
 |