#============================================================================== # # ■水中判定スクリプト■ # # 浅瀬や海上にいるキャラに茂み属性を適用します。 # # 作成日:2015/9/5 # 作成者:かげろう # URL:http://cgpoldpersonteam.blog.fc2.com/ # #============================================================================== #============================================================================== # 自由に設定してください #============================================================================== module UnderwaterCheck # プライオリティに応じた茂み属性の深さ # 左から「通常キャラの下」「通常キャラと同じ」「通常キャラの上」 BUSH = [ 0, 8, 0] #茂み SHALLOWS = [32, 8, 0] #浅瀬(小型船の通行可能チップ) DEPTHS = [32, 12, 0] #海 (大型船の通行可能チップ) # 32で、通常規格のキャラクターが完全に水没します # 特定条件で茂み属性を無視する(true:無視する false:無視しない) IGNORE_VEHICLE = true #乗り物の場合 IGNORE_JUMP = true #ジャンプ中の場合 IGNORE_OBJECT = false #オブジェクトの場合 # オブジェクトとは、!がついている画像とタイル画像を指します end #============================================================================== # 以下はいじらないでください #============================================================================== class Game_Map #-------------------------------------------------------------------------- # ● 茂み判定 # x : X 座標 # y : Y 座標 #-------------------------------------------------------------------------- def bush?(x, y) return 0 if $game_map.events == nil #エラーを防ぐ return 0 unless valid?(x, y) if @passages[@map.data[x, y, 1]] & 0x40 == 0x40 return 1 elsif boat_passable?(x, y)#小型船が動ける範囲 return 2 elsif ship_passable?(x, y)#大型船が動ける範囲 return 3 end return 0 end end class Game_Character #-------------------------------------------------------------------------- # ● 茂み深さの更新 #-------------------------------------------------------------------------- def update_bush_depth if @driving and UnderwaterCheck::IGNORE_VEHICLE @bush_depth = 0 elsif @jump_count > 0 and UnderwaterCheck::IGNORE_JUMP @bush_depth = 0 elsif object? and UnderwaterCheck::IGNORE_OBJECT @bush_depth = 0 else bush = $game_map.bush?(@x, @y) if bush == 1 and not moving? @bush_depth = UnderwaterCheck::BUSH[@priority_type] elsif bush == 2 and not moving? @bush_depth = UnderwaterCheck::SHALLOWS[@priority_type] elsif bush == 3 and not moving? @bush_depth = UnderwaterCheck::DEPTHS[@priority_type] elsif bush == 0 @bush_depth = 0 end end end end