Advertisement
mrbubble

Compatibility Patch: VE - Pixel Movement + KMS Minimap

Jul 19th, 2012
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.32 KB | None | 0 0
  1. #==============================================================================
  2. # Compatibility Patch :                                         v1.1 (7/19/12)
  3. #   Victor Engine - Pixel Movement + KMS Minimap
  4. #   Sapphire Action System IV + KMS Minimap
  5. #--------------------------------------------------------------------------
  6. # Script by:
  7. #     Mr. Bubble
  8. #--------------------------------------------------------------------------
  9. # Place this script below KMS Mini Map in your script edtior.
  10. #==============================================================================
  11.  
  12. class Game_MiniMap
  13.   #--------------------------------------------------------------------------
  14.   # ○ 通行可否テーブルの探索
  15.   #     x, y : 探索位置
  16.   #--------------------------------------------------------------------------
  17.   def scan_passage(x, y)
  18.     dx = x / @draw_grid_num.x
  19.     dy = y / @draw_grid_num.y
  20.  
  21.     # 探索済み
  22.     return if @passage_scan_table[dx, dy] == 1
  23.  
  24.     # マップ範囲外
  25.     return unless dx.between?(0, @passage_scan_table.xsize - 1)
  26.     return unless dy.between?(0, @passage_scan_table.ysize - 1)
  27.  
  28.     rx = (dx.to_i * @draw_grid_num.x.to_i)...((dx.to_i + 1) * @draw_grid_num.x.to_i)
  29.     ry = (dy.to_i * @draw_grid_num.y.to_i)...((dy.to_i + 1) * @draw_grid_num.y.to_i)
  30.     mw = $game_map.width  - 1
  31.     mh = $game_map.height - 1
  32.  
  33.     # 探索範囲内の通行テーブルを生成
  34.     rx.each { |x|
  35.       next unless x.between?(0, mw)
  36.       ry.each { |y|
  37.         next unless y.between?(0, mh)
  38.  
  39.         # 通行方向フラグ作成
  40.         # (↓、←、→、↑ の順に 1, 2, 4, 8 が対応)
  41.         flag = 0
  42.         [2, 4, 6, 8].each{ |d|
  43.           flag |= 1 << (d / 2 - 1) if $game_map.passable?(x, y, d)
  44.         }
  45.         @passage_table[x, y] = flag
  46.       }
  47.     }
  48.     @passage_scan_table[dx, dy] = 1
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # ○ 通行可能領域の描画
  52.   #--------------------------------------------------------------------------
  53.   def draw_map_foreground(bitmap)
  54.     range_x = (@draw_range_begin.x.to_i)..(@draw_range_end.x.to_i)
  55.     range_y = (@draw_range_begin.y.to_i)..(@draw_range_end.y.to_i)
  56.     map_w   = $game_map.width  - 1
  57.     map_h   = $game_map.height - 1
  58.     rect    = Rect.new(0, 0, @grid_size, @grid_size)
  59.    
  60.     range_x.each { |x|
  61.       next unless x.between?(0, map_w)
  62.       range_y.each { |y|
  63.  
  64.         next unless y.between?(0, map_h)
  65.         next if @passage_table[x, y] == 0
  66.         next if @wall_events.find { |e| e.x == x && e.y == y }  # 壁
  67.         # グリッド描画サイズ算出
  68.         rect.set(0, 0, @grid_size, @grid_size)
  69.         rect.x = (x - @draw_range_begin.x) * @grid_size
  70.         rect.y = (y - @draw_range_begin.y) * @grid_size
  71.         flag = @passage_table[x, y]
  72.         if flag & 0x01 == 0  # 下通行不能
  73.           rect.height -= 1
  74.         end
  75.         if flag & 0x02 == 0  # 左通行不能
  76.           rect.x     += 1
  77.           rect.width -= 1
  78.         end
  79.         if flag & 0x04 == 0  # 右通行不能
  80.           rect.width -= 1
  81.         end
  82.         if flag & 0x08 == 0  # 上通行不能
  83.           rect.y      += 1
  84.           rect.height -= 1
  85.         end
  86.         bitmap.fill_rect(rect, KMS_MiniMap::FOREGROUND_COLOR)
  87.       }
  88.     }
  89.   end # def
  90. end # class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement