#============================================================================== # ■ XP-RGSS-46 8方向移動+加速ダッシュ [Ver.1.2.0] by Claimh #------------------------------------------------------------------------------ # 8方向の移動とダッシュが可能となります。 # ダッシュは加速方式です。 #------------------------------------------------------------------------------ #【再定義】 # Game_Character : move_lower_left # move_lower_right # move_upper_left # move_upper_right # Game_Player : update #============================================================================== module Dash #------------------------------------------------------------------------------ # ダッシュ用ボタン KEY = Input::A # 初期速度 DASH_ST = 4.0 # 加速度 DASH_A = 0.2 # 加速段階 DASH_STEP = 4 #------------------------------------------------------------------------------ end #============================================================================== # ■ Game_Character #============================================================================== class Game_Character #-------------------------------------------------------------------------- # ● 左下に移動(再定義) #-------------------------------------------------------------------------- def move_lower_left # 向き固定でない場合 unless @direction_fix # 右向きだった場合は左を、上向きだった場合は下を向く @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction) end # 下→左、左→下 のどちらかのコースが通行可能な場合 if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) and (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2)) # 座標を更新 @x -= 1 @y += 1 # 歩数増加 increase_steps elsif passable?(@x, @y, 2) move_down elsif passable?(@x, @y, 4) move_left end end #-------------------------------------------------------------------------- # ● 右下に移動(再定義) #-------------------------------------------------------------------------- def move_lower_right # 向き固定でない場合 unless @direction_fix # 左向きだった場合は右を、上向きだった場合は下を向く @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction) end # 下→右、右→下 のどちらかのコースが通行可能な場合 if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) and (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2)) # 座標を更新 @x += 1 @y += 1 # 歩数増加 increase_steps elsif passable?(@x, @y, 2) move_down elsif passable?(@x, @y, 6) move_right end end #-------------------------------------------------------------------------- # ● 左上に移動(再定義) #-------------------------------------------------------------------------- def move_upper_left # 向き固定でない場合 unless @direction_fix # 右向きだった場合は左を、下向きだった場合は上を向く @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction) end # 上→左、左→上 のどちらかのコースが通行可能な場合 if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) and (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8)) # 座標を更新 @x -= 1 @y -= 1 # 歩数増加 increase_steps elsif passable?(@x, @y, 8) move_up elsif passable?(@x, @y, 4) move_left end end #-------------------------------------------------------------------------- # ● 右上に移動(再定義) #-------------------------------------------------------------------------- def move_upper_right # 向き固定でない場合 unless @direction_fix # 左向きだった場合は右を、下向きだった場合は上を向く @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction) end # 上→右、右→上 のどちらかのコースが通行可能な場合 if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) and (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8)) # 座標を更新 @x += 1 @y -= 1 # 歩数増加 increase_steps elsif passable?(@x, @y, 8) move_up elsif passable?(@x, @y, 6) move_right end end end #============================================================================== # ■ Game_Player #============================================================================== class Game_Player #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super init_walk_speed end #-------------------------------------------------------------------------- # ● フレーム更新(再定義) #-------------------------------------------------------------------------- def update # ローカル変数に移動中かどうかを記憶 last_moving = moving? # 移動中、イベント実行中、移動ルート強制中、 # メッセージウィンドウ表示中のいずれでもない場合 unless moving? or $game_system.map_interpreter.running? or @move_route_forcing or $game_temp.message_window_showing # ★8方向移動+ダッシュに対応 walk_speed_changer end # ローカル変数に座標を記憶 last_real_x = @real_x last_real_y = @real_y super # キャラクターが下に移動し、かつ画面上の位置が中央より下の場合 if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y # マップを下にスクロール $game_map.scroll_down(@real_y - last_real_y) end # キャラクターが左に移動し、かつ画面上の位置が中央より左の場合 if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X # マップを左にスクロール $game_map.scroll_left(last_real_x - @real_x) end # キャラクターが右に移動し、かつ画面上の位置が中央より右の場合 if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X # マップを右にスクロール $game_map.scroll_right(@real_x - last_real_x) end # キャラクターが上に移動し、かつ画面上の位置が中央より上の場合 if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y # マップを上にスクロール $game_map.scroll_up(last_real_y - @real_y) end # 移動中ではない場合 unless moving? # 前回プレイヤーが移動中だった場合 if last_moving # 同位置のイベントとの接触によるイベント起動判定 result = check_event_trigger_here([1,2]) # 起動したイベントがない場合 if result == false # デバッグモードが ON かつ CTRL キーが押されている場合を除き unless $DEBUG and Input.press?(Input::CTRL) # エンカウント カウントダウン if @encounter_count > 0 @encounter_count -= 1 end end end end # C ボタンが押された場合 if Input.trigger?(Input::C) # 同位置および正面のイベント起動判定 check_event_trigger_here([0]) check_event_trigger_there([0,1,2]) end end end #-------------------------------------------------------------------------- # ● 歩行向き #-------------------------------------------------------------------------- def walk_speed_changer # 方向ボタンが押されていれば、その方向へプレイヤーを移動 case Input.dir8 when 1; move_lower_left; speed_checker(0.2) when 2; move_down; speed_checker() when 3; move_lower_right; speed_checker(0.2) when 4; move_left; speed_checker() when 6; move_right; speed_checker() when 7; move_upper_left; speed_checker(0.2) when 8; move_up; speed_checker() when 9; move_upper_right; speed_checker(0.2) else; speed_checker() end end #-------------------------------------------------------------------------- # ● 歩行スピードチェック #-------------------------------------------------------------------------- def speed_checker(speed=0) # イベント実行中はスピード操作はしない if !$game_system.map_interpreter.running? if Input.press?(Dash::KEY) speed_up(speed) else speed_dw(speed) end change_speed(@walk_speed - speed) @event_change = false elsif @event_change != true # nilも考慮 @event_change = true @walk_speed = Dash::DASH_ST end end # 滑らかスピードアップ def speed_up(speed) if @walk_speed < (Dash::DASH_ST+(Dash::DASH_STEP * Dash::DASH_A)) @walk_speed += Dash::DASH_A end end # 滑らかスピードダウン def speed_dw(speed) if @walk_speed > Dash::DASH_ST @walk_speed -= Dash::DASH_A else @walk_speed = Dash::DASH_ST end end #-------------------------------------------------------------------------- # ● 歩行スピード初期化 #-------------------------------------------------------------------------- def init_walk_speed @walk_speed = Dash::DASH_ST end #-------------------------------------------------------------------------- # ● 歩行速度変更 #-------------------------------------------------------------------------- def change_speed(speed) @move_speed = speed end end #============================================================================== # ■ Game_Map #============================================================================== class Scene_Map #-------------------------------------------------------------------------- # ● 初期化 #-------------------------------------------------------------------------- def initialize $game_player.init_walk_speed end end