#============================================================================ # # ■8方向移動 □Ver.1.01 □製作者:月紳士 # ・RPGツクールVX用 RGSS2スクリプト # # ●…書き換えメソッド(競合注意) ◎…メソッドのエイリアス ○…新規メソッド # # ※二次配布禁止!配布元には利用規約があります。必ずそちらを見てください。 #------------------------------------------------------------------------------ # 更新履歴 # Ver.1.01 スクリプト微修正。既知の問題を確認。 #============================================================================ =begin  プレイヤー操作時に縦方向キーと横方向キーいずれかの同時押しで  斜めに移動させることが出来るようになるスクリプトです。  月紳士配布の「壁タイル拡張」「パーティーメンバーの追従」と併用が可能です。  いずれの場合も、このスクリプトがリスト上になるように導入してください。  既知の問題:特定のマップチップに対して斜め歩行でぶつかると        避けて4方向移動をする際に小刻みに震えてしまう。        キーを入れっぱなしで動きが止まってしまうことがある。        ※ 残念ながら修正の予定はありません。 =end #============================================================================== # ■ Game_Character #------------------------------------------------------------------------------ #  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event # クラスのスーパークラスとして使用されます。 #============================================================================== class Game_Character #-------------------------------------------------------------------------- # ● 左下に移動 #-------------------------------------------------------------------------- def move_lower_left if not passable?(@x-1, @y+1) # 左下に通行障害がある場合 if check_event_trigger_touch(@x-1, @y+1) # 接触イベントの起動判定 @move_failed = true return end end if not passable?(@x, @y+1) # 下に通行障害がある場合 unless check_event_trigger_touch(@x, @y+1) # 接触イベントの起動判定 move_left # イベントが無ければ左へ else turn_down @move_failed = true end elsif not passable?(@x-1, @y) # 左に通行障害がある場合 unless check_event_trigger_touch(@x-1, @y) # 接触イベントの起動判定 move_down # イベントが無ければ下へ else turn_left @move_failed = true end elsif passable?(@x-1, @y+1) # 通行可能 @direction = 4 unless @direction_fix @x -= 1 @y += 1 increase_steps @move_failed = false else move_left end end #-------------------------------------------------------------------------- # ● 右下に移動 #-------------------------------------------------------------------------- def move_lower_right if not passable?(@x+1, @y+1) # 右下に通行障害がある場合 if check_event_trigger_touch(@x+1, @y+1) # 接触イベントの起動判定 @move_failed = true return end end if not passable?(@x+1, @y) # 右に通行障害がある場合 unless check_event_trigger_touch(@x+1, @y) # 接触イベントの起動判定 move_down # イベントが無ければ下へ else turn_right @move_failed = true end elsif not passable?(@x, @y+1) # 下に通行障害がある場合 unless check_event_trigger_touch(@x, @y+1) # 接触イベントの起動判定 move_right # イベントが無ければ右へ else turn_down @move_failed = true end elsif passable?(@x+1, @y+1) # 通行可能 @direction = 2 unless @direction_fix @x += 1 @y += 1 increase_steps @move_failed = false else move_down end end #-------------------------------------------------------------------------- # ● 左上に移動 #-------------------------------------------------------------------------- def move_upper_left if not passable?(@x-1, @y-1) # 左上に通行障害がある場合 if check_event_trigger_touch(@x-1, @y-1) # 接触イベントの起動判定 @move_failed = true return end end if not passable?(@x-1, @y) # 左に通行障害がある場合 unless check_event_trigger_touch(@x-1, @y) # 接触イベントの起動判定 move_up # イベントが無ければ上へ else turn_left @move_failed = true end elsif not passable?(@x, @y-1) # 上に通行障害がある場合 unless check_event_trigger_touch(@x, @y-1) # 接触イベントの起動判定 move_left # イベントが無ければ左へ else turn_up @move_failed = true end elsif passable?(@x-1, @y-1) # 通行可能 @direction = 8 unless @direction_fix @x -= 1 @y -= 1 increase_steps @move_failed = false else move_up end end #-------------------------------------------------------------------------- # ● 右上に移動 #-------------------------------------------------------------------------- def move_upper_right if not passable?(@x+1, @y-1) # 右上に通行障害がある場合 if check_event_trigger_touch(@x+1, @y-1) # 接触イベントの起動判定 @move_failed = true return end end if not passable?(@x, @y-1) # 上に通行障害がある場合 unless check_event_trigger_touch(@x, @y-1) # 接触イベントの起動判定 move_right # イベントが無ければ右へ else turn_up @move_failed = true end elsif not passable?(@x+1, @y) # 右に通行障害がある場合 unless check_event_trigger_touch(@x+1, @y) # 接触イベントの起動判定 move_up # イベントが無ければ上へ else turn_right @move_failed = true end elsif passable?(@x+1, @y-1) # 通行可能 @direction = 6 unless @direction_fix @x += 1 @y -= 1 increase_steps @move_failed = false else move_right end end end #============================================================================== # ■ Game_Player #------------------------------------------------------------------------------ #  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。 #============================================================================== class Game_Player < Game_Character #-------------------------------------------------------------------------- # ● 方向ボタン入力による移動処理 #-------------------------------------------------------------------------- def move_by_input return unless movable? return if $game_map.interpreter.running? case Input.dir8 when 1; move_lower_left when 2; move_down when 3; move_lower_right when 4; move_left when 6; move_right when 7; move_upper_left when 8; move_up when 9; move_upper_right end end end