#============================================================================== # ■ Numset #------------------------------------------------------------------------------ #  定数を扱うモジュールです。 #============================================================================== module Numset SLIDE_SPEED = 5 EVENT_SLIDE = true SLIDE_MOVE = 6 # 前方移動の地形タグ MOVE_UP = 7 # 上方移動の地形タグ MOVE_DOWN = 8 # 下方移動の地形タグ MOVE_LEFT = 9 # 左方移動の地形タグ MOVE_RIGHT = 10 # 右方移動の地形タグ end #============================================================================== # ■ Game_Character #------------------------------------------------------------------------------ #  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event # クラスのスーパークラスとして使用されます。 #============================================================================== class Game_Character #-------------------------------------------------------------------------- # ● 通行可能判定 # x : X 座標 # y : Y 座標 # d : 方向 (0,2,4,6,8) ※ 0 = 全方向通行不可の場合を判定 (ジャンプ用) #-------------------------------------------------------------------------- def passable?(x, y, d) # 新しい座標を求める new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0) new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0) # 座標がマップ外の場合 unless $game_map.valid?(new_x, new_y) # 通行不可 return false end # すり抜け ON の場合 if @through # 通行可 return true end # 移動元のタイルから指定方向に出られない場合 unless $game_map.passable?(x, y, d, self) # 通行不可 return false end # 移動先のタイルに指定方向から入れない場合 unless $game_map.passable?(new_x, new_y, 10 - d) # 通行不可 return false end # 全イベントのループ for event in $game_map.events.values # イベントの座標が移動先と一致した場合 if event.x == new_x and event.y == new_y # すり抜け OFF なら unless event.through # 自分と相手が同一の場合 if self == event # 通行可 return true end # 自分がイベントの場合 if self != $game_player # 通行不可 return false end # 自分がプレイヤーで、相手のグラフィックがキャラクターの場合 if event.character_name != "" # 通行不可 return false end end end end # プレイヤーの座標が移動先と一致した場合 if $game_player.x == new_x and $game_player.y == new_y # すり抜け OFF なら unless $game_player.through # 自分と相手が同一の場合 if self.is_a?(Game_Player) # 通行可 return true end # 自分のグラフィックがキャラクターの場合 if @character_name != "" # 通行不可 return false end end end # 通行可 return true end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- alias :base_update_move :update_move def update_move # 強制移動が許可されているか if Numset::EVENT_SLIDE or self.is_a?(Game_Player) case @direction when 2 slide = move_slide(@x, @y - 1, $game_map.terrain_tag(@x, @y - 1)) when 4 slide = move_slide(@x + 1, @y, $game_map.terrain_tag(@x + 1, @y)) when 6 slide = move_slide(@x - 1, @y, $game_map.terrain_tag(@x - 1, @y)) when 8 slide = move_slide(@x, @y + 1, $game_map.terrain_tag(@x, @y + 1)) end if slide != 0 # 移動速度強制変更 ms = @move_speed @move_speed = Numset::SLIDE_SPEED base_update_move # 呼び戻す @move_speed = ms # 移動時アニメが ON の場合 if @walk_anime # アニメカウントを 1.5 減らす @anime_count -= 1.5 # 移動時アニメが OFF で、停止時アニメが ON の場合 elsif @step_anime # アニメカウントを 1 減らす @anime_count -= 1 end else base_update_move end if move_slide(@x, @y, terrain_tag) != 0 # 強制移動床に止まった場合 if @x * 128 == @real_x and @y * 128 == @real_y case move_slide(@x, @y, terrain_tag) when Numset::SLIDE_MOVE move_forward when Numset::MOVE_UP move_up when Numset::MOVE_DOWN move_down when Numset::MOVE_LEFT move_left when Numset::MOVE_RIGHT move_right end end end else base_update_move end end def move_slide(x, y, tag) # すべる床 if tag == Numset::SLIDE_MOVE and passable?(x, y, @direction) return tag # 上移動床 elsif tag == Numset::MOVE_UP and passable?(x, y, 8) return tag # 下移動床 elsif tag == Numset::MOVE_DOWN and passable?(x, y, 2) return tag # 左移動床 elsif tag == Numset::MOVE_LEFT and passable?(x, y, 4) return tag # 右移動床 elsif tag == Numset::MOVE_RIGHT and passable?(x, y, 6) return tag else return 0 end end end