查看: 2794|回复: 7

[已经解决] 八方行走

[复制链接]
梦石
0
星屑
50
在线时间
7 小时
注册时间
2013-10-27
回帖
22
发表于 2013-11-2 14:55:47 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
我找了几个不错的人物行走图,但图片是由八个方向的,该怎么让角色可以向八个方向行走?顺便求一个VA的脚本教程,作为脚本白制作总很麻烦{:2_263:}
梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2013-11-2 16:12:11 | 显示全部楼层
本帖最后由 tseyik 于 2013-11-2 18:05 编辑

先把圖放上来看看
八方向行走

$Actor61.png

$Actor61.png

$Actor61-X.png

$Actor61-X.png

斜行圖規格

斜行圖規格

  1. #==============================================================================
  2. # ■ 注釈取得スクリプト (VX Ace用)
  3. #------------------------------------------------------------------------------
  4. # 製作者     : CanariAlternate
  5. # サイト名   : カルトの鳥篭
  6. # サイトURL  : [url]http://canarialt.blog.fc2.com[/url]
  7. #------------------------------------------------------------------------------
  8. # ■ 概要 : 注釈を取得する処理を定義する。
  9. #
  10. # ■ 必須 : なし
  11. #
  12. # ■ 位置 : 「Game_Event」より下
  13. #------------------------------------------------------------------------------
  14. # ■ 注釈での設定方法
  15. #   以下の例のように実行内容の1行目から注釈以外のコマンドまでの注釈のどこかに
  16. #   キーワードを記述すると有効(結果を反転してる場合には無効)になります。
  17. #
  18. #             例 : 実行内容
  19. #                   ◆注釈:キーワードA キーワードC
  20. #                   :    :キーワードG キーワードF
  21. #                   :    :キーワードE
  22. #                   ◆注釈:キーワードD
  23. #                   :    :キーワードH キーワードB
  24. #                   ◆変数の操作などの注釈以外のイベントコマンド
  25. #                   ◆注釈:ここ以下に書いても無視される。
  26. #                   ◆
  27. #
  28. # ※キーワードとなる文字列の設定は正規表現です。詳しいことはヘルプを「正規表現」で検索すると出てきます。
  29. #   簡単に言うと / で囲まれた文字列があるかないかで判定します。
  30. #   \ とか ! みたいな記号を使いたい時はヘルプを参照して下さい。
  31. #   設定例、/\[キーワード\]/  #=>  [キーワード]
  32. #
  33. # ※キーワードを記述すると有効と無効が切り替わります。初期状態は無効です。
  34. #   例 : 初期状態を反転, 記述したイベントの全ての頁を反転, 記述した頁のみを反転
  35. #   まず  「初期状態を反転」                  で有効に
  36. #   次に  「記述したイベントの全ての頁を反転」で無効に
  37. #   最後に「記述した頁のみを反転」            で有効に
  38. #------------------------------------------------------------------------------
  39. # 更新履歴 : 2012/10/05 Ver1.00 コードを共通処理スクリプトに統一
  40. #            2012/10/06 Ver1.01 コードを共通処理スクリプトから分離
  41. #            2012/10/08 Ver1.02 コードの整理
  42. #            2013/02/19 Ver1.03 共通処理スクリプトの廃止による変更を施した。
  43. #==============================================================================

  44. $imported ||= {}
  45. $imported[:CanariAlternate_EventNote] = true

  46. #==============================================================================
  47. # ■ Calt
  48. #------------------------------------------------------------------------------
  49. #  CanariAlternateが製作したスクリプトの管理用モジュール
  50. #==============================================================================
  51. module Calt
  52.   #--------------------------------------------------------------------------
  53.   # ● イベントコマンドから注釈を取得 [新規]
  54.   #--------------------------------------------------------------------------
  55.   def self.Read_EventNote(list)
  56.     return String.new unless list && list[i = 0].code == 108
  57.     note = list[i].parameters[0]
  58.     note += "\n#{list[i].parameters[0]}" while [108, 408].include?(list[i += 1].code)
  59.     return note
  60.   end
  61. end

  62. #==============================================================================
  63. # ■ Game_Event
  64. #------------------------------------------------------------------------------
  65. #  イベントを扱うクラスです。条件判定によるイベントページ切り替えや、並列処理
  66. # イベント実行などの機能を持っており、Game_Map クラスの内部で使用されます。
  67. #==============================================================================
  68. class Game_Event < Game_Character
  69.   #--------------------------------------------------------------------------
  70.   # ● イベントページの設定をセットアップ [追加]
  71.   #--------------------------------------------------------------------------
  72.   alias setup_page_settings_EventNote setup_page_settings
  73.   def setup_page_settings
  74.     setup_page_settings_EventNote
  75.     setup_note_settings
  76.   end
  77.   #--------------------------------------------------------------------------
  78.   # ● イベントページ更新時に注釈から設定を取得 [新規]
  79.   #--------------------------------------------------------------------------
  80.   def setup_note_settings
  81.     # 注釈の取得処理はここに追加
  82.   end
  83.   #--------------------------------------------------------------------------
  84.   # ● 1頁目の注釈にキーワードが含まれているか判定 [新規]
  85.   #--------------------------------------------------------------------------
  86.   def whole_note_include?(keyword)
  87.     return @event.pages[0].event_note =~ keyword ? true : false
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # ● この頁の注釈にキーワードが含まれているか判定 [新規]
  91.   #--------------------------------------------------------------------------
  92.   def event_note_include?(keyword)
  93.     return @page.event_note =~ keyword ? true : false
  94.   end
  95. end

  96. #==============================================================================
  97. # ■ RPG::Event::Page
  98. #------------------------------------------------------------------------------
  99. #  イベントページのデータクラス。
  100. #==============================================================================
  101. class RPG::Event::Page
  102.   #--------------------------------------------------------------------------
  103.   # ● 取得する注釈内容を変更 [新規]
  104.   #--------------------------------------------------------------------------
  105.   attr_writer   :event_note
  106.   #--------------------------------------------------------------------------
  107.   # ● この頁の注釈を取得 [新規]
  108.   #--------------------------------------------------------------------------
  109.   def event_note
  110.     return @event_note ||= Calt::Read_EventNote(@list)
  111.   end
  112. end
复制代码
  1. #==============================================================================
  2. # ■ プレイヤーの8方向移動+斜め歩行グラに対応+その他 (VX Ace用)
  3. #------------------------------------------------------------------------------
  4. # 製作者     : CanariAlternate
  5. # サイト名   : カルトの鳥篭
  6. # サイトURL  : [url]http://canarialt.blog.fc2.com[/url]
  7. #------------------------------------------------------------------------------
  8. # ■ 概要 : 移動関連の機能を詰め込んだスクリプトです。
  9. #           必要な機能だけ追加するように設定することも出来ます。
  10. #           「プレイヤー操作拡張」「斜め向き画像の実装」「ダッシュの入力を反転」「斜めの通行可能判定」
  11. # ■ 必須 : 「注釈取得スクリプト」※斜め歩行グラフィックを使用しない場合は不要
  12. #
  13. # ■ 位置 : 「イベント起動判定拡張」より下
  14. #           「注釈取得スクリプト」より下
  15. #------------------------------------------------------------------------------
  16. # ■ 機能 : プレイヤーの8方向移動&斜め移動でスムーズに移動など
  17. #           臼井の会様にて配布されている斜め歩行グラフィックに対応
  18. #           走行状態をダッシュのデフォルトにする。
  19. #           プレイヤーの移動操作禁止と許可をスイッチで切り替える。
  20. #           斜めの通行可能判定をオートタイル(A1タイル)を考慮したものに変更
  21. #------------------------------------------------------------------------------
  22. # 更新履歴 : 2013/07/08 Ver1.00 複数のスクリプトを再設計し、これにまとめた。
  23. #            2013/07/10 Ver1.01 斜め向きでの起動不可が機能していないバグを修正した。
  24. #            2013/07/10 Ver1.02 スクリプトの設定に関する説明を修正した。
  25. #==============================================================================

  26. $imported ||= {}
  27. $imported[:CanariAlternate_MoveSystems] = true

  28. #==============================================================================
  29. # ■ Calt
  30. #------------------------------------------------------------------------------
  31. #  CanariAlternateが製作したスクリプト用のモジュールです。
  32. #==============================================================================
  33. module Calt
  34.   #----------------------------------------------------------------------------
  35.   # ◆プレイヤーの8方向移動を使用するか
  36.   DiagonalMovePlayer = true   # true / false
  37.   #
  38.   # 設定した番後のスイッチがONの時は8方向移動を禁止(0の場合は常にOFF)
  39.   DiagonalMoveProhibition = 0 # スイッチ番号
  40.   #
  41.   # 設定した番号のスイッチがONの時は斜め方向の移動に失敗した場合に
  42.   # 滑るように縦または横に移動する機能を無効化(0の場合は常にOFF)
  43.   DiagonalMoveSlide = 0       # スイッチ番号
  44.   #
  45.   # そのキーを押している間は斜め移動しか出来なくなるキーを設定(nil を設定で無効)
  46.   # キー候補一覧 :SHIFT :CTRL :ALT :A :B :C :X :Y :Z :L :R :F5 :F6 :F7 :F8 :F9
  47.   DiagonalMoveOnlyKey = :ALT  # Inputモジュールの定数
  48.   #
  49.   # そのキーを押している間は移動はせず方向転換をするキーを設定(nil を設定で無効)
  50.   # キー候補一覧 :SHIFT :CTRL :ALT :A :B :C :X :Y :Z :L :R :F5 :F6 :F7 :F8 :F9
  51.   ChangeTurnModeKey = :CTRL   # Inputモジュールの定数
  52.   #----------------------------------------------------------------------------
  53.   # ◆斜め歩行グラフィックを使用するか
  54.   DiagonalCharacterGraphic = true # true / false
  55.   #
  56.   # 斜め向きでの起動不可のキーワード
  57.   # ※プレイヤーに斜めの歩行グラフィックを用意すると斜め方向からイベントを起動出来るようになります。
  58.   # 一部のイベントは斜め方向から起動されると都合が悪い場合があります。(例えば、扉など)
  59.   # イベントの実行内容の先頭に注釈でキーワードを記述することで斜め方向から起動出来なくなります。
  60.   DiagonalNotStartNote    = /\[斜め向きでの起動不可\]/  # 記述した頁に適用
  61.   DiagonalNotStartAllNote = /\<斜め向きでの起動不可\>/  # 全ての頁に適用(1頁目に記述)
  62.   DiagonalNotStartReverse = false                       # 全てのイベントの初期状態を反転
  63.   #
  64.   # 斜め歩行グラフィック画像の名前
  65.   # ※この名前の画像を用意すると斜めを向いた時にその画像になる
  66.   #
  67.   # ◇画像名の先頭に $ がついている場合(1キャラ分の画像)
  68.   #   初期設定では斜め向き画像の名前は 画像名-X となる。
  69.   #   例えば、$mainActor に斜め画像をつけたければ $mainActor-X という画像を用意する。
  70.   DiagonalCharacterName      = "%s-X"
  71.   #
  72.   # ◇画像名の先頭に $ がついていない場合(8キャラ分の画像)
  73.   #   初期設定では斜め向き画像の名前は $画像名-X-番号 となる。
  74.   #   番号は 1~8 でどのキャラの斜め画像か指定する。1 2 3 4
  75.   #                                                 5 6 7 8
  76.   #   例えば、actor5 の4番のキャラに斜め画像をつけたければ $actor5-X-4 という画像を用意する。
  77.   DiagonalCharacterIndexName = "$%s-X-%s"
  78.   #----------------------------------------------------------------------------
  79.   # ◆走行状態をダッシュのデフォルトにするを使用するか
  80.   DashDefaultDash = true  # true / false
  81.   #
  82.   # 設定した番号のスイッチがONの時は歩行がデフォルトになる(0の場合は常にOFF)
  83.   DashDefaultWalk = 0     # スイッチ番号
  84.   #----------------------------------------------------------------------------
  85.   # ◆プレイヤーの移動操作禁止を使用するか
  86.   PlayerImpossibleOperation = true  # true / false
  87.   #
  88.   # 設定した番号のスイッチがONの時はプレイヤーの移動操作を禁止(0の場合は常にOFF)
  89.   MoveByInputProhibition = 0        # スイッチ番号
  90.   #----------------------------------------------------------------------------
  91.   # ◆斜めの通行可能判定をオートタイル(A1タイル)を考慮したものに変更を使用するか
  92.   DiagonalMoveNatural = true  # true / false
  93.   #
  94.   # 斜め通過を許可する地形タグ(A1タイルに設定した場合は元々が許可なので禁止に)
  95.   # ここで設定した地形タグを設定したタイルは斜め通過を許可(A1タイルは禁止)する。
  96.   DiagonalMoveNaturalTag = [] # 例 [1, 2, 5]
  97.   #----------------------------------------------------------------------------
  98. end

  99. ###############################################################################
  100. # ■ プレイヤーの8方向移動に関する変更
  101. ###############################################################################
  102. if Calt::DiagonalMovePlayer
  103. #==============================================================================
  104. # ■ Game_CharacterBase
  105. #------------------------------------------------------------------------------
  106. #  キャラクターを扱う基本のクラスです。全てのキャラクターに共通する、座標やグ
  107. # ラフィックなどの基本的な情報を保持します。
  108. #==============================================================================
  109. class Game_CharacterBase
  110.   #--------------------------------------------------------------------------
  111.   # ● キャラクターの斜め画像の有無を取得 [新規]
  112.   #--------------------------------------------------------------------------
  113.   def character_diagonal
  114.     return false
  115.   end
  116. end

  117. #==============================================================================
  118. # ■ Game_Player
  119. #------------------------------------------------------------------------------
  120. #  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの
  121. # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
  122. #==============================================================================
  123. class Game_Player < Game_Character
  124.   #--------------------------------------------------------------------------
  125.   # ● 方向ボタン入力による移動処理 [◆再定義]
  126.   #--------------------------------------------------------------------------
  127.   def move_by_input
  128.     return if !movable? || $game_map.interpreter.running?
  129.     if $game_switches[Calt::DiagonalMoveProhibition]
  130.       move_4_way  # 斜め移動を禁止のスイッチがON (4方向移動)
  131.     else
  132.       move_8_way  # 斜め移動を禁止のスイッチがOFF(8方向移動)
  133.     end
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # ● 4方向移動の処理 [新規]
  137.   #--------------------------------------------------------------------------
  138.   def move_4_way
  139.     if Calt::ChangeTurnModeKey && Input.press?(Calt::ChangeTurnModeKey)
  140.       set_direction(Input.dir4) if Input.dir4 > 0 # 方向転換
  141.     else
  142.       move_straight(Input.dir4) if Input.dir4 > 0 # 移動処理
  143.     end
  144.   end
  145.   #--------------------------------------------------------------------------
  146.   # ● 8方向移動の処理 [新規]
  147.   #--------------------------------------------------------------------------
  148.   def move_8_way
  149.     if Calt::ChangeTurnModeKey && Input.press?(Calt::ChangeTurnModeKey)
  150.       if character_diagonal
  151.         # 方向転換(斜め画像あり)
  152.         if Input.dir8 > 0
  153.           if Calt::DiagonalMoveOnlyKey && Input.press?(Calt::DiagonalMoveOnlyKey)
  154.             set_direction(Input.dir8) if Input.dir8 % 2 == 1  # 方向転換(斜めのみ)
  155.           else
  156.             set_direction(Input.dir8)                         # 方向転換8方向
  157.           end
  158.         end
  159.       else
  160.         set_direction(Input.dir4) if Input.dir4 > 0 # 方向転換(斜め画像なし)
  161.       end
  162.     else
  163.       # 移動処理8方向
  164.       if (d = Input.dir8) > 0
  165.         case d
  166.         when 1 ; move_diagonal_select(4, 2)
  167.         when 3 ; move_diagonal_select(6, 2)
  168.         when 7 ; move_diagonal_select(4, 8)
  169.         when 9 ; move_diagonal_select(6, 8)
  170.         else
  171.           # 移動処理4方向
  172.           unless Calt::DiagonalMoveOnlyKey && Input.press?(Calt::DiagonalMoveOnlyKey)
  173.             move_straight(d)
  174.           end
  175.         end
  176.       end
  177.     end
  178.   end
  179.   #--------------------------------------------------------------------------
  180.   # ● 滑り移動の有無を判定して適当な方の斜め移動を実行 [新規]
  181.   #--------------------------------------------------------------------------
  182.   def move_diagonal_select(horz, vert)
  183.     if $game_switches[Calt::DiagonalMoveSlide] ||
  184.        Calt::DiagonalMoveOnlyKey && Input.press?(Calt::DiagonalMoveOnlyKey)
  185.       move_diagonal(horz, vert)       # 滑り移動は無効
  186.     else
  187.       move_diagonal_slide(horz, vert) # 滑り移動は有効
  188.     end
  189.   end
  190.   #--------------------------------------------------------------------------
  191.   # ● 移動成功か判定(滑り移動付き斜めに移動の処理用) [新規]
  192.   #--------------------------------------------------------------------------
  193.   def move_succeed_slide?
  194.     return true if @move_succeed                  # 普通に移動成功の場合
  195.     return true if $game_map.any_event_starting?  # イベントを起動準備中の場合
  196.     return true if $game_map.interpreter.running? # イベントを実行中の場合
  197.     return false
  198.   end
  199.   #--------------------------------------------------------------------------
  200.   # ● 滑り移動付き斜めに移動(プレイヤー操作専用) [新規]
  201.   #--------------------------------------------------------------------------
  202.   def move_diagonal_slide(horz, vert, turn_ok = true)
  203.     old_direction = @direction  # 現在の向きを記憶
  204.     if Calt::DiagonalCharacterGraphic
  205.       move_diagonal(horz, vert, turn_ok)  # 斜めグラを使用する場合
  206.     else
  207.       move_diagonal(horz, vert)           # 斜めグラを使用しない場合
  208.     end
  209.     new_direction = @direction  # 新しい向きを記憶
  210.     unless move_succeed_slide?
  211.       if old_direction == 2 || old_direction == 8
  212.         direction1 = horz  # 現在、縦の場合は横優先
  213.         direction2 = vert
  214.       elsif old_direction == 4 || old_direction == 6
  215.         direction1 = vert  # 現在、横の場合は縦優先
  216.         direction2 = horz
  217.       else
  218.         direction1 = vert  # 現在、斜めの場合は縦優先
  219.         direction2 = horz
  220.       end
  221.       if passable?(x, y, direction1)
  222.         move_straight(direction1, turn_ok)  # 移動可能なので移動
  223.         #@direction = new_direction if Calt::DiagonalCharacterGraphic  # 向きを斜めに戻す
  224.       elsif passable?(x, y, direction2)
  225.         move_straight(direction2, turn_ok)  # 移動可能なので移動
  226.         #@direction = new_direction if Calt::DiagonalCharacterGraphic  # 向きを斜めに戻す
  227.       else
  228.         # 縦横ともに移動不可なのでイベントの起動を試行
  229.         move_straight(direction1, turn_ok)
  230.         move_straight(direction2, turn_ok) unless move_succeed_slide?
  231.         # 縦横ともに起動不可の場合は向きを戻す
  232.         @direction = new_direction unless move_succeed_slide?
  233.       end
  234.     end
  235.   end
  236. end
  237. end

  238. ###############################################################################
  239. # ■ 斜め歩行グラフィックに関する変更
  240. ###############################################################################
  241. if Calt::DiagonalCharacterGraphic
  242. #==============================================================================
  243. # ■ Game_Map
  244. #------------------------------------------------------------------------------
  245. #  マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
  246. # このクラスのインスタンスは $game_map で参照されます。
  247. #==============================================================================
  248. class Game_Map
  249.   #--------------------------------------------------------------------------
  250.   # ● 特定の方向に 1 マスずらした X 座標の計算(ループ補正なし)[追加]
  251.   #--------------------------------------------------------------------------
  252.   alias x_with_direction_MoveSystems x_with_direction
  253.   def x_with_direction(x, d)
  254.     d = d == 1 || d == 7 ? 4 : 6 if d % 2 == 1 && d != 5 # dをx方向に変換
  255.     x_with_direction_MoveSystems(x, d)
  256.   end
  257.   #--------------------------------------------------------------------------
  258.   # ● 特定の方向に 1 マスずらした Y 座標の計算(ループ補正なし)[追加]
  259.   #--------------------------------------------------------------------------
  260.   alias y_with_direction_MoveSystems y_with_direction
  261.   def y_with_direction(y, d)
  262.     d = d == 1 || d == 3 ? 2 : 8 if d % 2 == 1 && d != 5 # dをy方向に変換
  263.     y_with_direction_MoveSystems(y, d)
  264.   end
  265.   #--------------------------------------------------------------------------
  266.   # ● 特定の方向に 1 マスずらした X 座標の計算(ループ補正あり)[追加]
  267.   #--------------------------------------------------------------------------
  268.   alias round_x_with_direction_MoveSystems round_x_with_direction
  269.   def round_x_with_direction(x, d)
  270.     d = d == 1 || d == 7 ? 4 : 6 if d % 2 == 1 && d != 5 # dをx方向に変換
  271.     round_x_with_direction_MoveSystems(x, d)
  272.   end
  273.   #--------------------------------------------------------------------------
  274.   # ● 特定の方向に 1 マスずらした Y 座標の計算(ループ補正あり)[追加]
  275.   #--------------------------------------------------------------------------
  276.   alias round_y_with_direction_MoveSystems round_y_with_direction
  277.   def round_y_with_direction(y, d)
  278.     d = d == 1 || d == 3 ? 2 : 8 if d % 2 == 1 && d != 5 # dをy方向に変換
  279.     round_y_with_direction_MoveSystems(y, d)
  280.   end
  281.   #--------------------------------------------------------------------------
  282.   # ● 通常キャラの通行可能判定 [追加]
  283.   #--------------------------------------------------------------------------
  284.   alias passable_MoveSystems? passable?
  285.   def passable?(x, y, d, *args)
  286.     if d % 2 == 1 && d != 5
  287.       horz = d == 1 || d == 7 ? 4 : 6
  288.       vert = d == 1 || d == 3 ? 2 : 8
  289.       x2 = round_x_with_direction(x, horz)
  290.       y2 = round_y_with_direction(y, vert)
  291.       return (passable_MoveSystems?(x, y, vert, *args) &&
  292.               passable_MoveSystems?(x, y2, 10 - vert, *args) &&
  293.               passable_MoveSystems?(x, y2, horz, *args)) ||
  294.              (passable_MoveSystems?(x, y, horz, *args) &&
  295.               passable_MoveSystems?(x2, y, 10 - horz, *args) &&
  296.               passable_MoveSystems?(x2, y, vert, *args))
  297.     else
  298.       return passable_MoveSystems?(x, y, d, *args)
  299.     end
  300.   end
  301. end

  302. #==============================================================================
  303. # ■ Game_CharacterBase
  304. #------------------------------------------------------------------------------
  305. #  キャラクターを扱う基本のクラスです。全てのキャラクターに共通する、座標やグ
  306. # ラフィックなどの基本的な情報を保持します。
  307. #==============================================================================
  308. class Game_CharacterBase
  309.   #--------------------------------------------------------------------------
  310.   # ● 公開インスタンス変数
  311.   #--------------------------------------------------------------------------
  312.   attr_reader :character_diagonal  # キャラクターの斜め画像の有無を取得
  313.                                    # ■変数への直接アクセスによる取得は禁止■
  314.   #--------------------------------------------------------------------------
  315.   # ● 公開メンバ変数の初期化 [追加]
  316.   #--------------------------------------------------------------------------
  317.   alias init_public_members_MoveSystems init_public_members
  318.   def init_public_members
  319.     init_public_members_MoveSystems
  320.     @character_diagonal = false
  321.   end
  322.   #--------------------------------------------------------------------------
  323.   # ● 斜め向きか判定 [新規]
  324.   #--------------------------------------------------------------------------
  325.   def direction_diagonal?(d = @direction)
  326.     return d % 2 == 1 && d != 5
  327.   end
  328.   #--------------------------------------------------------------------------
  329.   # ● 斜め画像の有無を設定 [新規]
  330.   #--------------------------------------------------------------------------
  331.   def set_character_diagonal(flag)
  332.     @character_diagonal = flag
  333.     unless @character_diagonal
  334.       # 斜め向きの画像が無い場合の処理
  335.       if direction_diagonal?
  336.         @direction = @direction > 5 ? 8 : 2
  337.       end
  338.       if direction_diagonal?(@prelock_direction)
  339.         @prelock_direction = @prelock_direction > 5 ? 8 : 2
  340.       end
  341.     end
  342.   end
  343.   #--------------------------------------------------------------------------
  344.   # ● 指定方向に向き変更 [◆再定義]
  345.   #--------------------------------------------------------------------------
  346.   def set_direction(d)
  347.     if character_diagonal || !direction_diagonal?(d)
  348.       @direction = d if !@direction_fix && d != 0
  349.     elsif !@direction_fix && d != 0
  350.       @direction = d > 5 ? 8 : 2
  351.     end
  352.     @stop_count = 0
  353.   end
  354.   #--------------------------------------------------------------------------
  355.   # ● 通行可能判定 [追加]
  356.   #--------------------------------------------------------------------------
  357.   alias passable_MoveSystems? passable?
  358.   def passable?(x, y, d)
  359.     if direction_diagonal?(d)
  360.       horz = d == 1 || d == 7 ? 4 : 6
  361.       vert = d == 1 || d == 3 ? 2 : 8
  362.       diagonal_passable?(x, y, horz, vert)  # 斜め向きの時は斜めの判定を実行
  363.     else
  364.       passable_MoveSystems?(x, y, d)
  365.     end
  366.   end
  367.   #--------------------------------------------------------------------------
  368.   # ● まっすぐに移動 [追加]
  369.   #--------------------------------------------------------------------------
  370.   alias move_straight_MoveSystems move_straight
  371.   def move_straight(d, turn_ok = true)
  372.     if direction_diagonal?(d)
  373.       horz = d == 1 || d == 7 ? 4 : 6
  374.       vert = d == 1 || d == 3 ? 2 : 8
  375.       move_diagonal(horz, vert, turn_ok) # 斜め向きの時は斜め移動を実行
  376.     else
  377.       move_straight_MoveSystems(d, turn_ok)
  378.     end
  379.   end
  380.   #--------------------------------------------------------------------------
  381.   # ● 斜めに移動 [◆再定義]
  382.   #--------------------------------------------------------------------------
  383.   def move_diagonal(horz, vert, turn_ok = true) # 向き変更の可否を追加
  384.     @move_succeed = diagonal_passable?(x, y, horz, vert)
  385.     if @move_succeed
  386.       set_direction_diagonal(horz, vert)  # 向き変更
  387.       @x = $game_map.round_x_with_direction(@x, horz)
  388.       @y = $game_map.round_y_with_direction(@y, vert)
  389.       @real_x = $game_map.x_with_direction(@x, reverse_dir(horz))
  390.       @real_y = $game_map.y_with_direction(@y, reverse_dir(vert))
  391.       increase_steps
  392.     elsif turn_ok
  393.       set_direction_diagonal(horz, vert)  # 向き変更
  394.       check_event_trigger_touch_front if character_diagonal  # 斜め画像がある
  395.     end
  396.   end
  397.   #--------------------------------------------------------------------------
  398.   # ● 向きの変更(斜め向き) [新規]
  399.   #--------------------------------------------------------------------------
  400.   def set_direction_diagonal(horz, vert)
  401.     if character_diagonal
  402.       d = horz == 4 ? (vert == 2 ? 1 : 7) : (vert == 2 ? 3 : 9)
  403.       set_direction(d)  # 斜め画像があれば斜めを向く
  404.     else
  405.       set_direction(horz) if @direction == reverse_dir(horz)
  406.       set_direction(vert) if @direction == reverse_dir(vert)
  407.     end
  408.   end
  409. end

  410. #==============================================================================
  411. # ■ Game_Character
  412. #------------------------------------------------------------------------------
  413. #  主に移動ルートなどの処理を追加したキャラクターのクラスです。Game_Player、
  414. # Game_Follower、GameVehicle、Game_Event のスーパークラスとして使用されます。
  415. #==============================================================================
  416. class Game_Character < Game_CharacterBase
  417.   #--------------------------------------------------------------------------
  418.   # ● 距離に最適な向きを向く [新規]
  419.   #--------------------------------------------------------------------------
  420.   def set_diagonal_distance_xy_from(sx, sy)
  421.     # distance_x_from, distance_y_fromの返り値をそれぞれsx, syに入れて使う。
  422.     sxabs = sx.abs
  423.     syabs = sy.abs
  424.     if sx == 0 || sy == 0 || (sxabs - syabs).abs * 2 >= sxabs + syabs
  425.       if sxabs > syabs
  426.         set_direction(sx > 0 ? 4 : 6)
  427.       elsif sy != 0
  428.         set_direction(sy > 0 ? 8 : 2)
  429.       end
  430.     else
  431.       set_direction_diagonal(sx > 0 ? 4 : 6, sy > 0 ? 8 : 2)
  432.     end
  433.   end
  434.   #--------------------------------------------------------------------------
  435.   # ● ジャンプ [追加]
  436.   #--------------------------------------------------------------------------
  437.   alias jump_MoveSystems jump
  438.   def jump(x_plus, y_plus)
  439.     jump_MoveSystems(x_plus, y_plus)
  440.     set_diagonal_distance_xy_from(-x_plus, -y_plus) if character_diagonal
  441.   end
  442.   #--------------------------------------------------------------------------
  443.   # ● キャラクターに近づく(斜め移動可) [追加]
  444.   #--------------------------------------------------------------------------
  445.   alias move_toward_character_MoveSystems move_toward_character
  446.   def move_toward_character(character)
  447.     return move_toward_character_MoveSystems(character) unless character_diagonal
  448.     sx = distance_x_from(character.x)
  449.     sy = distance_y_from(character.y)
  450.     if sx == 0 || sy == 0
  451.       if sx.abs > sy.abs
  452.         move_straight(sx > 0 ? 4 : 6)
  453.         move_straight(sy > 0 ? 8 : 2) if !@move_succeed && sy != 0
  454.       elsif sy != 0
  455.         move_straight(sy > 0 ? 8 : 2)
  456.         move_straight(sx > 0 ? 4 : 6) if !@move_succeed && sx != 0
  457.       end
  458.     else
  459.       move_diagonal(sx > 0 ? 4 : 6, sy > 0 ? 8 : 2)
  460.       if !@move_succeed
  461.         if sx.abs > sy.abs
  462.           move_straight(sx > 0 ? 4 : 6)
  463.           move_straight(sy > 0 ? 8 : 2) if !@move_succeed && sy != 0
  464.         elsif sy != 0
  465.           move_straight(sy > 0 ? 8 : 2)
  466.           move_straight(sx > 0 ? 4 : 6) if !@move_succeed && sx != 0
  467.         end
  468.       end
  469.     end
  470.   end
  471.   #--------------------------------------------------------------------------
  472.   # ● キャラクターから遠ざかる(斜め移動可) [追加]
  473.   #--------------------------------------------------------------------------
  474.   alias move_away_from_character_MoveSystems move_away_from_character
  475.   def move_away_from_character(character)
  476.     return move_away_from_character_MoveSystems(character) unless character_diagonal
  477.     sx = distance_x_from(character.x)
  478.     sy = distance_y_from(character.y)
  479.     if sx == 0 || sy == 0
  480.       if sx.abs > sy.abs
  481.         move_straight(sx > 0 ? 6 : 4)
  482.         move_straight(sy > 0 ? 2 : 8) if !@move_succeed && sy != 0
  483.       elsif sy != 0
  484.         move_straight(sy > 0 ? 2 : 8)
  485.         move_straight(sx > 0 ? 6 : 4) if !@move_succeed && sx != 0
  486.       end
  487.     else
  488.       move_diagonal(sx > 0 ? 6 : 4, sy > 0 ? 2 : 8)
  489.       if !@move_succeed
  490.         if sx.abs > sy.abs
  491.           move_straight(sx > 0 ? 6 : 4)
  492.           move_straight(sy > 0 ? 2 : 8) if !@move_succeed && sy != 0
  493.         elsif sy != 0
  494.           move_straight(sy > 0 ? 2 : 8)
  495.           move_straight(sx > 0 ? 6 : 4) if !@move_succeed && sx != 0
  496.         end
  497.       end
  498.     end
  499.   end
  500.   #--------------------------------------------------------------------------
  501.   # ● キャラクターの方を向く(斜め向き可) [追加]
  502.   #--------------------------------------------------------------------------
  503.   alias turn_toward_character_MoveSystems turn_toward_character
  504.   def turn_toward_character(character)
  505.     return turn_toward_character_MoveSystems(character) unless character_diagonal
  506.     sx = distance_x_from(character.x)
  507.     sy = distance_y_from(character.y)
  508.     set_diagonal_distance_xy_from(sx, sy)
  509.   end
  510.   #--------------------------------------------------------------------------
  511.   # ● キャラクターの逆を向く(斜め向き可) [追加]
  512.   #--------------------------------------------------------------------------
  513.   alias turn_away_from_character_MoveSystems turn_away_from_character
  514.   def turn_away_from_character(character)
  515.     return turn_away_from_character_MoveSystems(character) unless character_diagonal
  516.     sx = distance_x_from(character.x)
  517.     sy = distance_y_from(character.y)
  518.     set_diagonal_distance_xy_from(-sx, -sy)
  519.   end
  520.   #--------------------------------------------------------------------------
  521.   # ● 右に 90 度回転 [◆再定義]
  522.   #--------------------------------------------------------------------------
  523.   def turn_right_90
  524.     case @direction
  525.     when 2;  set_direction(4)
  526.     when 4;  set_direction(8)
  527.     when 6;  set_direction(2)
  528.     when 8;  set_direction(6)
  529.     when 1;  set_direction(7)
  530.     when 3;  set_direction(1)
  531.     when 7;  set_direction(9)
  532.     when 9;  set_direction(3)
  533.     end
  534.   end
  535.   #--------------------------------------------------------------------------
  536.   # ● 左に 90 度回転 [◆再定義]
  537.   #--------------------------------------------------------------------------
  538.   def turn_left_90
  539.     case @direction
  540.     when 2;  set_direction(6)
  541.     when 4;  set_direction(2)
  542.     when 6;  set_direction(8)
  543.     when 8;  set_direction(4)
  544.     when 1;  set_direction(3)
  545.     when 3;  set_direction(9)
  546.     when 7;  set_direction(1)
  547.     when 9;  set_direction(7)
  548.     end
  549.   end
  550.   #--------------------------------------------------------------------------
  551.   # ● 右に 45 度回転 [新規]
  552.   #--------------------------------------------------------------------------
  553.   def turn_right_45
  554.     return turn_right_90 unless character_diagonal
  555.     case @direction
  556.     when 1;  set_direction(4)
  557.     when 2;  set_direction(1)
  558.     when 3;  set_direction(2)
  559.     when 4;  set_direction(7)
  560.     when 6;  set_direction(3)
  561.     when 7;  set_direction(8)
  562.     when 8;  set_direction(9)
  563.     when 9;  set_direction(6)
  564.     end
  565.   end
  566.   #--------------------------------------------------------------------------
  567.   # ● 左に 45 度回転 [新規]
  568.   #--------------------------------------------------------------------------
  569.   def turn_left_45
  570.     return turn_left_90 unless character_diagonal
  571.     case @direction
  572.     when 1;  set_direction(2)
  573.     when 2;  set_direction(3)
  574.     when 3;  set_direction(6)
  575.     when 4;  set_direction(1)
  576.     when 6;  set_direction(9)
  577.     when 7;  set_direction(4)
  578.     when 8;  set_direction(7)
  579.     when 9;  set_direction(8)
  580.     end
  581.   end
  582.   #--------------------------------------------------------------------------
  583.   # ● 右に 135 度回転 [新規]
  584.   #--------------------------------------------------------------------------
  585.   def turn_right_135
  586.     return turn_right_90 unless character_diagonal
  587.     case @direction
  588.     when 1;  set_direction(8)
  589.     when 2;  set_direction(7)
  590.     when 3;  set_direction(4)
  591.     when 4;  set_direction(9)
  592.     when 6;  set_direction(1)
  593.     when 7;  set_direction(6)
  594.     when 8;  set_direction(3)
  595.     when 9;  set_direction(2)
  596.     end
  597.   end
  598.   #--------------------------------------------------------------------------
  599.   # ● 左に 135 度回転 [新規]
  600.   #--------------------------------------------------------------------------
  601.   def turn_left_135
  602.     return turn_left_90 unless character_diagonal
  603.     case @direction
  604.     when 1;  set_direction(6)
  605.     when 2;  set_direction(9)
  606.     when 3;  set_direction(8)
  607.     when 4;  set_direction(3)
  608.     when 6;  set_direction(7)
  609.     when 7;  set_direction(2)
  610.     when 8;  set_direction(1)
  611.     when 9;  set_direction(4)
  612.     end
  613.   end
  614.   #--------------------------------------------------------------------------
  615.   # ● 右か左に 45 度回転 [新規]
  616.   #--------------------------------------------------------------------------
  617.   def turn_right_or_left_45
  618.     case rand(2)
  619.     when 0;  turn_right_45
  620.     when 1;  turn_left_45
  621.     end
  622.   end
  623.   #--------------------------------------------------------------------------
  624.   # ● 右か左に 135 度回転 [新規]
  625.   #--------------------------------------------------------------------------
  626.   def turn_right_or_left_135
  627.     case rand(2)
  628.     when 0;  turn_right_135
  629.     when 1;  turn_left_135
  630.     end
  631.   end
  632.   #--------------------------------------------------------------------------
  633.   # ● ランダムに方向転換(斜め向き可) [追加]
  634.   #--------------------------------------------------------------------------
  635.   alias turn_random_MoveSystems turn_random
  636.   def turn_random
  637.     return turn_random_MoveSystems unless character_diagonal
  638.     d = 1 + rand(8)
  639.     d += 1 if d > 4
  640.     set_direction(d)
  641.   end
  642.   #--------------------------------------------------------------------------
  643.   # ● ランダムに移動(斜め向き可) [追加]
  644.   #--------------------------------------------------------------------------
  645.   alias move_random_MoveSystems move_random
  646.   def move_random
  647.     return move_random_MoveSystems unless character_diagonal
  648.     d = 1 + rand(8)
  649.     d += 1 if d > 4
  650.     move_straight(d, false)
  651.   end
  652. end

  653. #==============================================================================
  654. # ■ Game_Player
  655. #------------------------------------------------------------------------------
  656. #  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの
  657. # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
  658. #==============================================================================
  659. class Game_Player < Game_Character
  660.   #--------------------------------------------------------------------------
  661.   # ● 歩行グラフィック 斜め画像の有無を取得 [新規]
  662.   #--------------------------------------------------------------------------
  663.   def character_diagonal
  664.     return @character_diagonal if @vehicle_type == :walk  # 歩行の場合は通常通り
  665.     # プレイヤーに斜め画像が無い場合は処理が面倒なので乗り物に斜め画像があっても無効
  666.     return @character_diagonal && vehicle.character_diagonal # 乗り物に搭乗中はその乗り物
  667.   end
  668.   #--------------------------------------------------------------------------
  669.   # ● 斜めに移動 [◆再定義]
  670.   #--------------------------------------------------------------------------
  671.   def move_diagonal(horz, vert, turn_ok = true) # 向き変更の可否を追加
  672.     @followers.move if diagonal_passable?(@x, @y, horz, vert)
  673.     super
  674.   end
  675. end

  676. #==============================================================================
  677. # ■ Game_Event
  678. #------------------------------------------------------------------------------
  679. #  イベントを扱うクラスです。条件判定によるイベントページ切り替えや、並列処理
  680. # イベント実行などの機能を持っており、Game_Map クラスの内部で使用されます。
  681. #==============================================================================
  682. class Game_Event < Game_Character
  683.   #--------------------------------------------------------------------------
  684.   # ● 公開インスタンス変数
  685.   #--------------------------------------------------------------------------
  686.   attr_accessor :diagonal_dont_start      # 斜め向きでのイベント起動不可
  687.   #--------------------------------------------------------------------------
  688.   # ● 公開メンバ変数の初期化 [追加]
  689.   #--------------------------------------------------------------------------
  690.   alias init_public_members_MoveSystems2 init_public_members
  691.   def init_public_members
  692.     init_public_members_MoveSystems2
  693.     @diagonal_dont_start = false
  694.   end
  695.   #--------------------------------------------------------------------------
  696.   # ● 斜め向きでのイベント起動不可か判定 [新規]
  697.   #--------------------------------------------------------------------------
  698.   def diagonal_dont_start?
  699.     event_result = event_note_include?(Calt::DiagonalNotStartNote)
  700.     whole_result = whole_note_include?(Calt::DiagonalNotStartAllNote)
  701.     return event_result ^ whole_result ^ Calt::DiagonalNotStartReverse
  702.   end
  703.   #--------------------------------------------------------------------------
  704.   # ● 注釈から設定を取得する処理 [追加]
  705.   #--------------------------------------------------------------------------
  706.   alias setup_page_settings_MoveSystems setup_page_settings
  707.   def setup_page_settings
  708.     setup_page_settings_MoveSystems
  709.     @diagonal_dont_start = diagonal_dont_start?
  710.   end
  711.   unless $imported[:CanariAlternate_EventEveryone]
  712.     #--------------------------------------------------------------------------
  713.     # ● イベント起動 [追加]
  714.     #--------------------------------------------------------------------------
  715.     alias start_MoveSystems start
  716.     def start
  717.       return if $game_player.direction_diagonal? && @diagonal_dont_start
  718.       start_MoveSystems
  719.     end
  720.   else
  721.     #--------------------------------------------------------------------------
  722.     # ● イベント起動(イベント起動判定拡張との競合回避バージョン) [追加]
  723.     #--------------------------------------------------------------------------
  724.     alias start_MoveSystems start
  725.     def start
  726.       @invoker_event ||= $game_player # 明示されてない場合はプレイヤーが実行者
  727.       if @invoker_event.direction_diagonal? && @diagonal_dont_start
  728.         @invoker_event = nil if @invoker_event  # 処理終了時に初期化
  729.         return
  730.       end
  731.       start_MoveSystems
  732.     end
  733.   end
  734. end

  735. #==============================================================================
  736. # ■ Sprite_Character
  737. #------------------------------------------------------------------------------
  738. #  キャラクター表示用のスプライトです。Game_Character クラスのインスタンスを
  739. # 監視し、スプライトの状態を自動的に変化させます。
  740. #==============================================================================
  741. class Sprite_Character < Sprite_Base
  742.   #--------------------------------------------------------------------------
  743.   # ● 転送元ビットマップの更新 [◆再定義]
  744.   #--------------------------------------------------------------------------
  745.   def update_bitmap
  746.     if graphic_changed?
  747.       @tile_id = @character.tile_id
  748.       @character_name = @character.character_name
  749.       @character_index = @character.character_index
  750.       if @tile_id > 0
  751.         set_tile_bitmap
  752.         @cross_character_name = nil  # 初期化
  753.         @character.set_character_diagonal(false)  # 斜め画像無しを設定
  754.       else
  755.         set_character_bitmap
  756.         @cross_character_name = get_cross_character_name # 斜め向き画像名の取得
  757.       end
  758.       @cross_bitmap = false  # 初期化
  759.     end
  760.   end
  761.   #--------------------------------------------------------------------------
  762.   # ● 斜め向き画像名の取得 [新規]
  763.   #--------------------------------------------------------------------------
  764.   def get_cross_character_name
  765.     if @character_name =~ /^\!?\$./
  766.       setting = Calt::DiagonalCharacterName
  767.       cross_name = sprintf(setting, @character_name)
  768.     else
  769.       setting = Calt::DiagonalCharacterIndexName
  770.       index = @character.character_index
  771.       cross_name = sprintf(setting, @character_name, index + 1)
  772.     end
  773.     begin
  774.       Cache.character(cross_name) # 取得を試みて失敗なら斜め画像は存在しない
  775.     rescue
  776.       @character.set_character_diagonal(false)  # 斜め画像無しを設定
  777.       return nil
  778.     end
  779.     @character.set_character_diagonal(true) # 斜め画像有りを設定
  780.     return cross_name
  781.   end
  782.   #--------------------------------------------------------------------------
  783.   # ● 斜め向きキャラクターのビットマップを設定 [新規]
  784.   #--------------------------------------------------------------------------
  785.   def set_cross_character_bitmap
  786.     unless @cross_character_name
  787.       p "エラー:斜め向き画像が存在しないキャラが斜め向きになっています!!"
  788.       return
  789.     end
  790.     self.bitmap = Cache.character(@cross_character_name)
  791.     @cw = bitmap.width / 3
  792.     @ch = bitmap.height / 4
  793.     self.ox = @cw / 2
  794.     self.oy = @ch
  795.   end
  796.   #--------------------------------------------------------------------------
  797.   # ● 転送元矩形の更新 [◆再定義]
  798.   #--------------------------------------------------------------------------
  799.   def update_src_rect
  800.     if @tile_id == 0
  801.       d = @character.direction
  802.       if @character.direction_diagonal?
  803.         index = 0
  804.         unless @cross_bitmap
  805.           set_cross_character_bitmap  # 斜め向き画像をセット
  806.           @cross_bitmap = true
  807.         end
  808.         d = case d
  809.         when 1; 2 # 左斜め下(1行目)
  810.         when 7; 4 # 左斜め上(2行目)
  811.         when 3; 6 # 右斜め下(3行目)
  812.         when 9; 8 # 右斜め上(4行目)
  813.         end
  814.       else
  815.         index = @character.character_index
  816.         if @cross_bitmap
  817.           set_character_bitmap  # 通常の画像をセット
  818.           @cross_bitmap = false
  819.         end
  820.       end
  821.       pattern = @character.pattern < 3 ? @character.pattern : 1
  822.       sx = (index % 4 * 3 + pattern) * @cw
  823.       sy = (index / 4 * 4 + (d - 2) / 2) * @ch
  824.       self.src_rect.set(sx, sy, @cw, @ch)
  825.     end
  826.   end
  827. end
  828. end

  829. ###############################################################################
  830. # ■ 走行状態をダッシュのデフォルトにするに関する変更
  831. ###############################################################################
  832. if Calt::DashDefaultDash
  833. #==============================================================================
  834. # ■ Game_Player
  835. #------------------------------------------------------------------------------
  836. #  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの
  837. # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
  838. #==============================================================================
  839. class Game_Player < Game_Character
  840.   #--------------------------------------------------------------------------
  841.   # ● ダッシュ状態判定 [◆再定義]
  842.   #--------------------------------------------------------------------------
  843.   def dash?
  844.     return false if @move_route_forcing || $game_map.disable_dash? || vehicle
  845.     return Input.press?(:A) ^ !$game_switches[Calt::DashDefaultWalk]
  846.   end
  847. end
  848. end

  849. ###############################################################################
  850. # ■ プレイヤーの移動操作禁止に関する変更
  851. ###############################################################################
  852. if Calt::PlayerImpossibleOperation
  853. #==============================================================================
  854. # ■ Game_Player
  855. #------------------------------------------------------------------------------
  856. #  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの
  857. # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
  858. #==============================================================================
  859. class Game_Player < Game_Character
  860.   #--------------------------------------------------------------------------
  861.   # ● ダッシュ状態判定 [追加]
  862.   #--------------------------------------------------------------------------
  863.   alias dash_MoveSystems? dash?
  864.   def dash?
  865.     return false if $game_switches[Calt::MoveByInputProhibition]
  866.     return dash_MoveSystems?
  867.   end
  868.   #--------------------------------------------------------------------------
  869.   # ● 方向ボタン入力による移動処理 [追加]
  870.   #--------------------------------------------------------------------------
  871.   alias move_by_input_MoveSystems move_by_input
  872.   def move_by_input
  873.     return if $game_switches[Calt::MoveByInputProhibition]
  874.     move_by_input_MoveSystems
  875.   end
  876. end
  877. end

  878. ###############################################################################
  879. # ■ 斜めの通行可能判定をオートタイル(A1タイル)を考慮したものに変更に関する変更
  880. ###############################################################################
  881. if Calt::DiagonalMoveNatural
  882. #==============================================================================
  883. # ■ Game_CharacterBase
  884. #------------------------------------------------------------------------------
  885. #  キャラクターを扱う基本のクラスです。全てのキャラクターに共通する、座標やグ
  886. # ラフィックなどの基本的な情報を保持します。
  887. #==============================================================================
  888. class Game_CharacterBase
  889.   #--------------------------------------------------------------------------
  890.   # ● 定数
  891.   #--------------------------------------------------------------------------
  892.   AutoTile_UpLeft    = {34=>:T, 35=>:T, 42=>:T, 43=>:T, 46=>:T} # 左上が通行可のパターン
  893.   AutoTile_UpRight   = {36=>:T, 37=>:T, 42=>:T, 45=>:T, 46=>:T} # 右上が通行可のパターン
  894.   AutoTile_DownLeft  = {40=>:T, 41=>:T, 43=>:T, 44=>:T, 46=>:T} # 左下が通行可のパターン
  895.   AutoTile_DownRight = {38=>:T, 39=>:T, 44=>:T, 45=>:T, 46=>:T} # 右下が通行可のパターン
  896.   #--------------------------------------------------------------------------
  897.   # ● 斜めの通行可能判定 [◆再定義]
  898.   #--------------------------------------------------------------------------
  899.   def diagonal_passable?(x, y, horz, vert)
  900.     x2 = $game_map.round_x_with_direction(x, horz)
  901.     y2 = $game_map.round_y_with_direction(y, vert)
  902.     route_vert = passable?(x, y, vert) && passable?(x, y2, horz)  # 縦横ルート
  903.     route_horz = passable?(x, y, horz) && passable?(x2, y, vert)  # 横縦ルート
  904.     return true if route_vert && route_horz # 全ルート通行可能
  905.     if map_passable?(x, y, horz) && map_passable?(x, y, vert) &&
  906.        map_passable?(x2, y2, reverse_dir(horz)) &&
  907.        map_passable?(x2, y2, reverse_dir(vert)) &&
  908.        !collide_with_characters?(x2, y2)
  909.       # 現在地と移動先は斜めに通行可
  910.       if route_vert || passable_tile?(x, y2, horz, vert, false)
  911.         if route_horz || passable_tile?(x2, y, horz, vert, true)
  912.           return true
  913.         end
  914.       end
  915.     end
  916.     return false # 通行不可
  917.   end
  918.   #--------------------------------------------------------------------------
  919.   # ● 斜めの通行可能判定(タイル判定) [新規]
  920.   #--------------------------------------------------------------------------
  921.   def passable_tile?(x, y, horz, vert, route_horz=false)
  922.     $game_map.all_tiles(x, y).each do |tile_id|
  923.       flag = $game_map.tileset.flags[tile_id]
  924.       next if flag & 0x10 != 0          # [☆] : 通行に影響しない
  925.       if tile_id.between?(2048, 2815)   # A1タイル(海・水辺など)
  926.         return false if Calt::DiagonalMoveNaturalTag.include?(flag >> 12) # 通行不可
  927.         auto_id = (tile_id - 2048) % 48 # オートタイルのパターンを取得
  928.         auto_id_list = auto_id_list_A1_tile(horz, vert, route_horz)
  929.         return false unless auto_id_list[auto_id] # 通行不可
  930.       else
  931.         unless diagonal_passable_tile?(flag, horz, vert, route_horz)
  932.           return false unless Calt::DiagonalMoveNaturalTag.include?(flag >> 12) # 通行不可
  933.         end
  934.       end
  935.       return false if collide_with_characters?(x, y) # イベントとの衝突判定
  936.       return true # 通行可
  937.     end
  938.     return false  # 通行不可
  939.   end
  940.   #--------------------------------------------------------------------------
  941.   # ● 通行可能なA1タイルの配列を取得 [新規]
  942.   #--------------------------------------------------------------------------
  943.   def auto_id_list_A1_tile(horz, vert, route_horz)
  944.     if horz == 4 # 方向とルートに対応する通行可のパターンを取得
  945.       if vert == 2
  946.         return route_horz ? AutoTile_DownRight : AutoTile_UpLeft
  947.       else
  948.         return route_horz ? AutoTile_UpRight : AutoTile_DownLeft
  949.       end
  950.     else
  951.       if vert == 2
  952.         return route_horz ? AutoTile_DownLeft : AutoTile_UpRight
  953.       else
  954.         return route_horz ? AutoTile_UpLeft : AutoTile_DownRight
  955.       end
  956.     end
  957.   end
  958.   #--------------------------------------------------------------------------
  959.   # ● 斜め通行可能なタイルか判定 [新規]
  960.   #--------------------------------------------------------------------------
  961.   def diagonal_passable_tile?(flag, horz, vert, route_horz)
  962.     corner_flag = if horz == 4
  963.       vert == 2 ? (route_horz ? 0x05 : 0x0a) : (route_horz ? 0x0c : 0x03)
  964.     else
  965.       vert == 2 ? (route_horz ? 0x03 : 0x0c) : (route_horz ? 0x0a : 0x05)
  966.     end
  967.     return flag & corner_flag == 0x00 ? true : false
  968.   end
  969. end
  970. end
复制代码

评分

参与人数 1星屑 +66 收起 理由
熊喵酱 + 66 认可答案

查看全部评分

回复

使用道具 举报

百合控

梦石
0
星屑
6548
在线时间
1275 小时
注册时间
2013-8-21
回帖
3522

开拓者

发表于 2013-11-2 16:17:45 | 显示全部楼层
据我所知还没有比较好的VA新手脚本教程,可以看看图书馆里面的
八方行走脚本:
(插入到【插件脚本】以下,【Main】以上)
  1. #==============================================================================
  2. # ■ VXAce-RGSS3-26 8方向移動 [Ver.1.0.0]          by Claimh
  3. #------------------------------------------------------------------------------
  4. # 8方向の移動が可能となります。
  5. # 斜め移動ができない時に縦or横に移動できる場合は縦or横に移動するようになります。
  6. #==============================================================================

  7. class Game_Player < Game_Character
  8.   #--------------------------------------------------------------------------
  9.   # ● 方向ボタン入力による移動処理
  10.   #--------------------------------------------------------------------------
  11.   def move_by_input
  12.     return if !movable? || $game_map.interpreter.running?
  13.     if [1, 3, 7, 9].include?(Input.dir8)
  14.       case Input.dir8
  15.       when 1; move_diagonal(4, 2)
  16.       when 3; move_diagonal(6, 2)
  17.       when 7; move_diagonal(4, 8)
  18.       when 9; move_diagonal(6, 8)
  19.       end
  20.       return if @move_succeed
  21.     end
  22.     move_straight(Input.dir4) if Input.dir4 > 0
  23.   end
  24. end


  25. class Game_CharacterBase
  26.   #--------------------------------------------------------------------------
  27.   # ● 斜めに移動
  28.   #     horz : 横方向(4 or 6)
  29.   #     vert : 縦方向(2 or 8)
  30.   #--------------------------------------------------------------------------
  31.   alias move_diagonal_8dir move_diagonal
  32.   def move_diagonal(horz, vert)
  33.     if !passable?(@x, @y, horz) and !passable?(@x, @y, vert)
  34.       @move_succeed = false
  35.       return
  36.     end
  37.     return move_straight(horz) if passable?(@x, @y, horz) and !passable?(@x, @y, vert)
  38.     return move_straight(vert) if !passable?(@x, @y, horz) and passable?(@x, @y, vert)
  39.     move_diagonal_8dir(horz, vert)
  40.   end
  41. end

复制代码
萌新瑟瑟发抖
看到我请叫我去干活
回复

使用道具 举报

梦石
0
星屑
50
在线时间
7 小时
注册时间
2013-10-27
回帖
22
 楼主| 发表于 2013-11-2 16:53:58 | 显示全部楼层
本帖最后由 白梦 于 2013-11-2 16:56 编辑

好了谢谢你们的答复与热情的帮助

点评

另外回复的时候记得@一下别人,不然除非守在电脑前,别人根本不知道你回复了,毕竟这是你的主题  发表于 2013-11-2 16:55
这个和版本无关,代码都是英文,中文和日文都只是注释  发表于 2013-11-2 16:55
回复

使用道具 举报

梦石
0
星屑
50
在线时间
7 小时
注册时间
2013-10-27
回帖
22
 楼主| 发表于 2013-11-2 17:01:13 | 显示全部楼层
唔,你们两个给我的脚本效果差不多,为什么一个这么长?顺便问一句怎么@别人啊......
回复

使用道具 举报

百合控

梦石
0
星屑
6548
在线时间
1275 小时
注册时间
2013-8-21
回帖
3522

开拓者

发表于 2013-11-2 17:09:14 | 显示全部楼层
白梦 发表于 2013-11-2 17:01
唔,你们两个给我的脚本效果差不多,为什么一个这么长?顺便问一句怎么@别人啊...... ...


啊……虽然功能是一样的,但是我的那个(简短的)只是单纯地实现八方移动,而没有使用不同行走图,所以满足楼主要求的是长的那个…………
——————————————
回复 001.png 可以提醒到对方
@ 002.png 也是同样的功能

评分

参与人数 1星屑 +66 收起 理由
熊喵酱 + 66 认可答案

查看全部评分

萌新瑟瑟发抖
看到我请叫我去干活
回复

使用道具 举报

梦石
0
星屑
50
在线时间
7 小时
注册时间
2013-10-27
回帖
22
 楼主| 发表于 2013-11-2 17:14:45 | 显示全部楼层
谢谢,不过看看我的等级o(︶︿︶)o 唉~~(掩目长谈)虽然你的脚本不能满足我的需求,但还是很感谢你。话说同是学生伤不起啊~~一周两天我就不说了

点评

教育局的都是坑  发表于 2013-11-2 17:36
我们这个周六放假了……据说这几天教育局抓得紧……  发表于 2013-11-2 17:27

评分

参与人数 1星屑 +15 收起 理由
熊喵酱 + 15 主動認可獎勵

查看全部评分

回复

使用道具 举报

梦石
0
星屑
50
在线时间
7 小时
注册时间
2013-10-27
回帖
22
 楼主| 发表于 2013-11-3 16:41:27 | 显示全部楼层
tseyik 发表于 2013-11-2 16:12
先把圖放上来看看
八方向行走

话说第708行有问题啊,刚刚还好好的,第二次打开就出问题了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部