# ▼▲▼ No78. Xムーブ ▼▲▼ # # update 2007/12/18 # #============================================================================== # --- プレイヤー移動速度設定 --- #============================================================================== module XMoveSmoother #-------------------------------------------------------------------------- # オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super xmove_reset end #-------------------------------------------------------------------------- # ずれリセット #-------------------------------------------------------------------------- def xmove_reset @xf = 0 @yf = 0 end #-------------------------------------------------------------------------- # 接触イベントの判定 と 歩数カウント #-------------------------------------------------------------------------- def check_event_touch_here_x if @xf == 0 increase_steps return check_event_trigger_here([1,2]) end return false end def check_event_touch_here_y if @yf == 0 increase_steps return check_event_trigger_here([1,2]) end return false end #-------------------------------------------------------------------------- # 通行可能?[拡張版] #-------------------------------------------------------------------------- def passablex?(x, y, d) # ずれ補正のみ による移動可 case d when 2 return true if @yf < 0 when 4 return true if @xf > 0 when 6 return true if @xf < 0 when 8 return true if @yf > 0 end # 通常の通行可能判定 result = passable?(x, y, d) # ぶれによる追加判定 unless (@xf == 0 and @yf == 0) case d when 2, 8 nx = @xf > 0 ? 1 : (@xf < 0 ? -1 : 0) ny = d == 2 ? 1 : -1 nd = @xf > 0 ? 6 : (@xf < 0 ? 4 : 0) result &= passable?(x + nx, y, d) result &= passable?(x, y + ny, nd) when 4, 6 nx = d == 6 ? 1 : -1 ny = @yf > 0 ? 1 : (@yf < 0 ? -1 : 0) nd = @yf > 0 ? 2 : (@yf < 0 ? 8 : 0) result &= passable?(x + nx, y, nd) result &= passable?(x, y + ny, d) end end # 結果 return result end #-------------------------------------------------------------------------- # 下に移動 #-------------------------------------------------------------------------- def move_down(turn_enabled = true) # 移動指定されているなら本来どおり or 移動速度4でない場合 return super if @move_route_forcing or @move_speed != 4 # 下を向く if turn_enabled turn_down end # 通行可能な場合 if passablex?(@x, @y, 2) # ぶれを更新 @yf += 1 if @yf >= 3 @yf = -2 @y += 1 end # 接触判定 check_event_touch_here_y # 通行不可能な場合 else # 接触イベントの起動判定 if check_event_trigger_touch(@x, @y+1) turn_down xmove_reset return end # ぬるり if turn_enabled and @yf == 0 and passable?(@x, @y, 2) if @xf >= 1 and (not passable?(@x+1, @y, 2) or not passable?(@x, @y+1, 6)) @xf -= 1 check_event_touch_here_x elsif @xf <= -1 and (not passable?(@x-1, @y, 2) or not passable?(@x, @y+1, 4)) @xf += 1 check_event_touch_here_x end end end end #-------------------------------------------------------------------------- # 左に移動 #-------------------------------------------------------------------------- def move_left(turn_enabled = true) # 移動指定されているなら本来どおり or 移動速度4でない場合 return super if @move_route_forcing or @move_speed != 4 # 左を向く if turn_enabled turn_left end # 通行可能な場合 if passablex?(@x, @y, 4) # ぶれを更新 @xf -= 1 if @xf <= -3 @xf = 2 @x -= 1 end # 接触判定 check_event_touch_here_x # 通行不可能な場合 else # 接触イベントの起動判定 if check_event_trigger_touch(@x-1, @y) turn_left xmove_reset return end # ぬるり if @xf == 0 and turn_enabled and passable?(@x, @y, 4) if @yf >= 1 and (not passable?(@x, @y+1, 4) or not passable?(@x-1, @y, 2)) @yf -= 1 check_event_touch_here_y elsif @yf <= -1 and (not passable?(@x, @y-1, 4) or not passable?(@x-1, @y, 8)) @yf += 1 check_event_touch_here_y end end end end #-------------------------------------------------------------------------- # 右に移動 #-------------------------------------------------------------------------- def move_right(turn_enabled = true) # 移動指定されているなら本来どおり or 移動速度4でない場合 return super if @move_route_forcing or @move_speed != 4 # 右を向く if turn_enabled turn_right end # 通行可能な場合 if passablex?(@x, @y, 6) # ぶれを更新 @xf += 1 if @xf >= 3 @xf = -2 @x += 1 end # 接触判定 check_event_touch_here_x # 通行不可能な場合 else # 接触イベントの起動判定 if check_event_trigger_touch(@x+1, @y) turn_right xmove_reset return end # ぬるり if turn_enabled and @xf == 0 and passable?(@x, @y, 6) if @yf >= 1 and (not passable?(@x, @y+1, 6) or not passable?(@x+1, @y, 2)) @yf -= 1 check_event_touch_here_y elsif @yf <= -1 and (not passable?(@x, @y-1, 6) or not passable?(@x+1, @y, 8)) @yf += 1 check_event_touch_here_y end end end end #-------------------------------------------------------------------------- # 上に移動 #-------------------------------------------------------------------------- def move_up(turn_enabled = true) # 移動指定されているなら本来どおり or 移動速度4でない場合 return super if @move_route_forcing or @move_speed != 4 # 上を向く if turn_enabled turn_up end # 通行可能な場合 if passablex?(@x, @y, 8) # ぶれを更新 @yf -= 1 if @yf <= -3 @yf = 2 @y -= 1 end # 接触判定 check_event_touch_here_y # 通行不可能な場合 else # 接触イベントの起動判定 if check_event_trigger_touch(@x, @y-1) turn_up xmove_reset return end # ぬるり if turn_enabled and @yf == 0 and passable?(@x, @y, 8) if @xf >= 1 and (not passable?(@x+1, @y, 8) or not passable?(@x, @y-1, 6)) @xf -= 1 check_event_touch_here_x elsif @xf <= -1 and (not passable?(@x-1, @y, 8) or not passable?(@x, @y-1, 4)) @xf += 1 check_event_touch_here_x end end end end #-------------------------------------------------------------------------- # 左下に移動 #-------------------------------------------------------------------------- def move_lower_left # 移動指定されているなら本来どおり or 移動速度4でない場合 return super if @move_route_forcing or @move_speed != 4 # 左を向く turn_left move_down(false) move_left(false) end #-------------------------------------------------------------------------- # 右下に移動 #-------------------------------------------------------------------------- def move_lower_right # 移動指定されているなら本来どおり or 移動速度4でない場合 return super if @move_route_forcing or @move_speed != 4 # 下を向く turn_down move_down(false) move_right(false) end #-------------------------------------------------------------------------- # 左上に移動 #-------------------------------------------------------------------------- def move_upper_left # 移動指定されているなら本来どおり or 移動速度4でない場合 return super if @move_route_forcing or @move_speed != 4 # 上を向く turn_up move_up(false) move_left(false) end #-------------------------------------------------------------------------- # 右上に移動 #-------------------------------------------------------------------------- def move_upper_right # 移動指定されているなら本来どおり or 移動速度4でない場合 return super if @move_route_forcing or @move_speed != 4 # 右を向く turn_right move_up(false) move_right(false) end #-------------------------------------------------------------------------- # 座標の瞬時更新 #-------------------------------------------------------------------------- def refresh_position @real_x = @x * 128 + (@xf * 25.6).to_i @real_y = @y * 128 + (@yf * 25.6).to_i end #-------------------------------------------------------------------------- # 移動中判定 [オーバーライド] #-------------------------------------------------------------------------- def moving? # イベント実行中の場合 return super if $game_system.map_interpreter.running? return super if @move_route_forcing @xf = 0 if @xf == nil @yf = 0 if @yf == nil # 論理座標と実座標が違っていれば移動中 return (@real_x != @x * 128 + (@xf * 25.6).to_i or @real_y != @y * 128 + (@yf * 25.6).to_i ) end #-------------------------------------------------------------------------- # ○ フレーム更新 (移動) [オーバーライド] #-------------------------------------------------------------------------- def update_move # 移動指定されているなら本来どおり or 移動速度4でない場合 if $game_system.map_interpreter.running? or @move_route_forcing or @move_speed != 4 xmove_reset super else super # 表示位置を更新 refresh_position end end #-------------------------------------------------------------------------- # 歩数増加 #-------------------------------------------------------------------------- def increase_steps super # イベント実行中の場合 return if $game_system.map_interpreter.running? # デバッグモードが ON かつ CTRL キーが押されている場合を除き unless $DEBUG and Input.press?(Input::CTRL) # エンカウント カウントダウン if @encounter_count > 0 @encounter_count -= 1 if $game_map.bush?(self.x, self.y) @encounter_extra += 80 end end end end #-------------------------------------------------------------------------- # 移動ルートの強制 #-------------------------------------------------------------------------- def force_move_route(move_route) xmove_reset super end end class Game_Player < Game_Character include XMoveSmoother end