#------------------------------------------------------------------------------- # 移動可能場所の可視化 for VXAce 製作者:奏ねこま(おとぶきねこま) #------------------------------------------------------------------------------- # プレイヤーが現在位置から移動可能な場所に色を付ける機能を提供します。 # # [ 使い方 ] # #  マップ画面でF6キーを押すと色が付きます。もう一度F6キーを押すと消えます。 # # [ 斜め移動判定タイプについて ] # #  斜め移動判定タイプはご利用のスクリプト(斜め移動を可能にしているスクリプト) # に合わせて選択してください。 # よくわからない場合はとりあえず1~3まで1つずつ試してみてください。 # # [ 利用規約 ] ................................................................. # 本スクリプトの利用者は、RPGツクールVXAceの正規ユーザーに限られます。 # 商用、非商用、ゲームの内容(年齢制限など)を問わず利用可能です。 # ゲームへの利用の際、報告や出典元の記載等は必須ではありません。 # 二次配布や転載、ソースコードURLやダウンロードURLへの直接リンクは禁止します。 # (スクリプトを利用したゲームに同梱する形での結果的な配布はOKです) # 不具合対応以外のサポートやリクエストは受け付けておりません。 # 本スクリプトにより生じたいかなる問題においても、一切の責任を負いかねます。 # [ 改訂履歴 ] ................................................................. # Version 1.02 2021/08/19 進行方向による移動可否がわかる表示に変更 # Version 1.01 2019/12/02 斜め移動に暫定対応 # Version 1.00 2019/12/01 初版 # -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ # Web Site: http://makonet.sakura.ne.jp/rpg_tkool/ # Twitter : https://twitter.com/koma_neko #------------------------------------------------------------------------------- # 設定 #------------------------------------------------------------------------------- module MAKONET010_PassableChecker #色(RGB値[R, G, B]) COLOR = [255, 0, 0] #不透明度(0~255) ALPHA = 128 #斜め移動判定タイプ # 0 -> 斜め移動なし # 1 -> passable?タイプ # 2 -> diagobal_passable?タイプ # 3 -> 1 & 2 DIAGONAL_CHECK_TYPE = 0 #テストモードのみ(true/false) TEST_ONLY = true end #------------------------------------------------------------------------------- # Sprite_Passable #------------------------------------------------------------------------------- class Sprite_Passable < Sprite include MAKONET010_PassableChecker def initialize(x, y, viewport) super(viewport) @character = Game_CharacterBase.new @character.moveto(x, y) self.bitmap = Bitmap.new(32, 32) rect = getRect(x, y) self.bitmap.fill_rect(rect[:x], rect[:y], rect[:width], rect[:height], Color.new(COLOR[0], COLOR[1], COLOR[2], ALPHA)) update end def getRect(px, py) x = 0 y = 0 width = 32 height = 32 if !$game_player.map_passable?(px, py, 2) height -= 2 end if !$game_player.map_passable?(px, py, 4) x += 2 width -= 2 end if !$game_player.map_passable?(px, py, 6) width -= 2 end if !$game_player.map_passable?(px, py, 8) y += 2 height -= 2 end return { :x => x, :y => y, :width => width, :height => height } end def update super update_position end def update_position self.x = @character.screen_x - 16 self.y = @character.screen_y - 32 + @character.shift_y self.z = @character.screen_z end end #------------------------------------------------------------------------------- # Spriteset_Map #------------------------------------------------------------------------------- class Spriteset_Map include MAKONET010_PassableChecker alias :makonet010_update :update def update makonet010_update if $TEST || !TEST_ONLY if Input.trigger?(:F6) if @passable_sprites @passable_sprites.each{|sprite| sprite.dispose } @passable_sprites = nil else check_tile = {} checked_tile = {} d1 = [2, 4, 6, 8] d2 = [1, 3, 7, 9] d3 = [[4, 2], [6, 2], [4, 8], [6, 8]] xy1 = [[0, 1], [-1, 0], [1, 0], [0, -1]] xy2 = [[-1, 1], [1, 1], [-1, -1], [1, -1]] check_tile[[$game_player.x, $game_player.y]] = [$game_player.x, $game_player.y] @passable_sprites = []; begin check_tile.keys.each{|key| x = check_tile[key][0]; y = check_tile[key][1]; for i in 0...4 if $game_player.passable?(x, y, d1[i]) _x = x + xy1[i][0]; _y = y + xy1[i][1]; if !checked_tile[[_x, _y]] check_tile[[_x, _y]] = [_x, _y] end end if [1, 3].include?(DIAGONAL_CHECK_TYPE) && $game_player.passable?(x, y, d2[i]) _x = x + xy2[i][0]; _y = y + xy2[i][1]; if !checked_tile[[_x, _y]] check_tile[[_x, _y]] = [_x, _y] end end if [2, 3].include?(DIAGONAL_CHECK_TYPE) && $game_player.diagonal_passable?(x, y, d3[i][0], d3[i][1]) _x = x + xy2[i][0]; _y = y + xy2[i][1]; if !checked_tile[[_x, _y]] check_tile[[_x, _y]] = [_x, _y] end end end checked_tile[key] = true; check_tile.delete(key) @passable_sprites.push(Sprite_Passable.new(x, y, @viewport2)) } end while check_tile.length > 0 end end if @passable_sprites @passable_sprites.each{|sprite| sprite.update } end end end alias :makonet010_dispose :dispose def dispose makonet010_dispose if @passable_sprites @passable_sprites.each{|sprite| sprite.dispose } @passable_sprites = nil end end end