カイワレダイコン 2015/12/31 23:57

4方向専用なめらか移動

斜め移動用の歩行グラフィックが無く、8方向移動すると違和感があったので作成。
このスクリプトは移動出来なかった時に「通行可能な方向に一歩移動する」という物なので
ちょっと特殊かもしれません。
カウンター属性とイベントには反応しません。

このスクリプトはひきも記は閉鎖しましたさんの
RGSS2_壁衝突音
http://hikimoki.sakura.ne.jp/

ArtificialProvidenceさんの
RGSS3 移動失敗時SE演奏&歩行アニメ、8方向移動スクリプトを参考にさせて頂きました。
http://artificialprovidence.web.fc2.com/



#============================================================================== # なめらか4 # 作成:みづき # ブログ:カイワレダイコン(http://b.dlsite.net/RG30248/) #-------------------------------------------------------------------------- =begin 入れるだけで動作します。設定項目はありません。 このスクリプトは移動出来なかった時に 「通行可能な方向に一歩移動する」という物です。予めご了承下さい。 尚、バグ修正は不可能な可能性が高いと思われます。合わせてご了承下さい。 ■がチェックするマスです。 ■■■ ■↓■ ■↑■ ■■■ ■■ ■■ ■← →■ ■■ ■■ 木 ↑ こんな感じで正面のみ移動不可の場合は左右ランダムです。 このスクリプトはひきも記は閉鎖しましたさんの RGSS2_壁衝突音 http://hikimoki.sakura.ne.jp/ と ArtificialProvidenceさんの RGSS3 移動失敗時SE演奏&歩行アニメ、8方向移動スクリプトを参考にさせて頂きました。 http://artificialprovidence.web.fc2.com/ =end #============================================================================== class Game_Player < Game_Character #-------------------------------------------------------------------------- # ● まっすぐに移動 #-------------------------------------------------------------------------- alias nameraka_four_move_straight move_straight def move_straight(d, turn_ok = true) nameraka_four_move_straight(d, turn_ok) return if !movable? || $game_map.interpreter.running? f_x = $game_map.round_x_with_direction(@x, @direction) # 前方チェック f_y = $game_map.round_y_with_direction(@y, @direction) return false if $game_map.counter?(f_x, f_y) # カウンターはスルー # 移動失敗 && # 正面にイベントが無い if !@move_succeed && $game_map.events_xy(f_x, f_y).empty? case Input.dir4 when 2 if passable?(x-1, y, d) && diagonal_passable?(x, y, 4, 2) && # 左/左下 passable?(x+1, y, d) && diagonal_passable?(x, y, 6, 2) # 右/右下 case rand(2) when 0 ; move_straight(4) # 左 when 1 ; move_straight(6) # 右 end elsif passable?(x-1, y, d) && diagonal_passable?(x, y, 4, 2) # 左/左下 move_straight(4) # 左 elsif passable?(x+1, y, d) && diagonal_passable?(x, y, 6, 2) # 右/右下 move_straight(6) # 右 else ; return end when 4 if passable?(x, y+1, d) && diagonal_passable?(x, y, 4, 2) && # 下/左下 passable?(x, y-1, d) && diagonal_passable?(x, y, 4, 8) # 上/左上 case rand(2) when 0 ; move_straight(2) # 下 when 1 ; move_straight(8) # 上 end elsif passable?(x, y+1, d) && diagonal_passable?(x, y, 4, 2) # 下/左下 move_straight(2) # 下 elsif passable?(x, y-1, d) && diagonal_passable?(x, y, 4, 8) # 上/左上 move_straight(8) # 上 else ; return end when 6 if passable?(x, y+1, d) && diagonal_passable?(x, y, 6, 2) && # 下/右下 passable?(x, y-1, d) && diagonal_passable?(x, y, 6, 8) # 上/右上 case rand(2) when 0 ; move_straight(2) # 下 when 1 ; move_straight(8) # 上 end elsif passable?(x, y+1, d) && diagonal_passable?(x, y, 6, 2) # 下/右下 move_straight(2) # 下 elsif passable?(x, y-1, d) && diagonal_passable?(x, y, 6, 8) # 上/右上 move_straight(8) # 上 else ; return end when 8 if passable?(x-1, y, d) && diagonal_passable?(x, y, 4, 8) && # 左/左上 passable?(x+1, y, d) && diagonal_passable?(x, y, 6, 8) # 右/右上 case rand(2) when 0 ; move_straight(4) # 左 when 1 ; move_straight(6) # 右 end elsif passable?(x-1, y, d) && diagonal_passable?(x, y, 4, 8) # 左/左上 move_straight(4) # 左 elsif passable?(x+1, y, d) && diagonal_passable?(x, y, 6, 8) # 右/右上 move_straight(6) # 右 else ; return end end # case Input end # if !@move_succeed && $g end # def end # class

最新の記事

月別アーカイブ

限定特典から探す

記事を検索