设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2579|回复: 1
打印 上一主题 下一主题

[已经解决] 求帮忙修改一下脚本

[复制链接]

Lv2.观梦者

梦石
0
星屑
374
在线时间
308 小时
注册时间
2015-7-2
帖子
56
跳转到指定楼层
1
发表于 2015-7-24 14:40:21 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
2星屑
怎么把这个重力脚本的斜四方形行走改为八方向行走??

RUBY 代码复制
  1. $ud_ok = true #上下失效
  2. $airjump = 1  #空中连跳
  3. #==============================================================================
  4. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  5. #==============================================================================
  6.  
  7. # ————————————————————————————————————
  8. # 全方向ドット移動 Ver ε
  9. # 配布元・サポートURL
  10. # [url]http://members.jcom.home.ne.jp/cogwheel/[/url]
  11.  
  12. #==============================================================================
  13. # ■ Game_Player
  14. #------------------------------------------------------------------------------
  15. #  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの
  16. # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
  17. #==============================================================================
  18. class Game_Player < Game_Character
  19.   #--------------------------------------------------------------------------
  20.   # ● 定数
  21.   #--------------------------------------------------------------------------
  22.   UP    = 48                  # 上方向の余裕(0 < UP < 63)
  23.   DOWN  = 16                  # 下方向の余裕(0 < DOWN <63)
  24.   SIDE  = 32                  # 左右方向の余裕(0 < SIDE <63)
  25.   SLANT = false               # 移動ルートの斜め移動時、速度修正
  26.   JUMPMAX = 100              
  27.   JUMPADD = 10              
  28.   #--------------------------------------------------------------------------
  29.   # ● 公開インスタンス変数
  30.   #--------------------------------------------------------------------------
  31.   attr_reader   :event                    # イベント時移動速度
  32.   attr_accessor :move_speed               # 移動速度
  33.   #--------------------------------------------------------------------------
  34.   # ● フレーム更新
  35.   #--------------------------------------------------------------------------
  36.   alias :update_original :update
  37.   def update
  38.     # @walk:歩行速度 @dash:ダッシュ時移動速度
  39.     # @event:イベント時移動速度(0の時は、イベント時に速度変更をしない)
  40.     @walk  = 4
  41.     @dash  = 5
  42.     @event = 4
  43.     @dot_m = true
  44.     #ダッシュ機能。エンターキーが押されている間、移動速度を変更する。
  45.     unless moving? or $game_system.map_interpreter.running? or
  46.             @move_route_forcing or $game_temp.message_window_showing
  47.       if @walk != @dash
  48.         if Input.press?(Input::C)
  49.           if @move_speed != @dash
  50.             @move_speed = @dash
  51.           end
  52.         else
  53.           if @move_speed != @walk
  54.             @move_speed = @walk
  55.           end
  56.         end
  57.       end
  58.     end
  59.     if @revise_x == nil and @revise_y == nil
  60.       @revise_x = 0
  61.       @revise_y = 0
  62.     end
  63.     unless @dot_m
  64.       update_original
  65.       return
  66.     end
  67.     if @move_route_forcing
  68.       # ローカル変数に移動中かどうかを記憶
  69.       last_moving = moving?
  70.       # ローカル変数に座標を記憶
  71.       last_real_x = @real_x
  72.       last_real_y = @real_y
  73.       # 座標がずれている場合
  74.       if (@revise_x != 0 or @revise_y != 0) and not jumping? and @move == true
  75.         if @revise_x != @real_x - @x * 128 or @revise_y != @real_y - @y * 128
  76.           @revise_x = @real_x - @x * 128
  77.           @revise_y = @real_y - @y * 128
  78.         end
  79.         # 移動距離distance1と目標距離distance2を設定
  80.         distance1 = 2 ** @move_speed
  81.         distance2 = Math.sqrt(@revise_x ** 2 + @revise_y ** 2)
  82.         # 移動距離が目標距離を越えた場合
  83.         if distance1 > distance2
  84.           # 強制的に補正座標を零にする
  85.           @real_x = @real_x - @revise_x
  86.           @real_y = @real_y - @revise_y
  87.           @revise_x = 0
  88.           @revise_y = 0
  89.           anime_update
  90.         # 移動距離が目標距離に達しない場合
  91.         else
  92.           # 移動距離分目標距離に近づく
  93.           @real_x -= (distance1 * @revise_x / distance2).round
  94.           @real_y -= (distance1 * @revise_y / distance2).round
  95.           @revise_x = @real_x - @x * 128
  96.           @revise_y = @real_y - @y * 128
  97.           anime_update
  98.         end
  99.       else
  100.         super
  101.       end
  102.     else
  103.       @move = false
  104.       # 移動中、イベント実行中、移動ルート強制中、
  105.       # メッセージウィンドウ表示中のいずれでもない場合
  106.       unless moving? or $game_system.map_interpreter.running? or
  107.              @move_route_forcing or $game_temp.message_window_showing
  108.         @event_run = false
  109.         # 方向ボタンが押されていれば、その方向へプレイヤーを移動
  110. #---------------------------上下失效-----------------------------------------
  111.       case Input.dir8
  112.         when 1
  113.           $ud_ok ? move_lower_left_p : move_left_p
  114.         when 2
  115. #          $ud_ok ? move_down_p : move_down_aaaagq
  116.           move_down_p if $ud_ok
  117.         when 3
  118.          $ud_ok ? move_lower_right_p : move_right_p
  119.         when 4
  120.           move_left_p
  121.         when 6
  122.           move_right_p
  123.         when 7
  124.          $ud_ok ? move_upper_left_p : move_left_p
  125.         when 8
  126. #         $ud_ok ? move_up_p : move_up_aaaagq
  127.          move_up_p if $ud_ok
  128.         when 9
  129.          $ud_ok ? move_upper_right_p : move_right_p
  130.         end
  131.       end
  132.       # ローカル変数に座標を記憶
  133.       last_real_x = @real_x
  134.       last_real_y = @real_y
  135.       # 移動処理
  136.       @real_x = @x * 128 + @revise_x
  137.       @real_y = @y * 128 + @revise_y
  138.       # ローカル変数に移動中かどうかを記憶
  139.       last_moving = moving?
  140.       # 座標更新
  141.       move_on
  142.       # 現在の座標と以前の座標が異なる場合
  143.       if (last_real_x != @real_x or last_real_y != @real_y)
  144.         @move_distance = 0 if @move_distance == nil
  145.         @move_distance += Math.sqrt((last_real_x - @real_x) ** 2 +
  146.                                       (last_real_y - @real_y) ** 2)
  147.         if @move_distance >= 128
  148.           @move_distance %= 128
  149.           increase_steps
  150.         end
  151.         # アニメーションを更新
  152.         anime_update
  153.       else
  154.         @pattern = 0
  155.       end
  156.     end
  157.     # キャラクターが下に移動し、かつ画面上の位置が中央より下の場合
  158.     if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  159.       # マップを下にスクロール
  160.       $game_map.scroll_down(@real_y - last_real_y)
  161.     end
  162.     # キャラクターが左に移動し、かつ画面上の位置が中央より左の場合
  163.     if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  164.       # マップを左にスクロール
  165.       $game_map.scroll_left(last_real_x - @real_x)
  166.     end
  167.     # キャラクターが右に移動し、かつ画面上の位置が中央より右の場合
  168.     if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  169.       # マップを右にスクロール
  170.       $game_map.scroll_right(@real_x - last_real_x)
  171.     end
  172.     # キャラクターが上に移動し、かつ画面上の位置が中央より上の場合
  173.     if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  174.       # マップを上にスクロール
  175.       $game_map.scroll_up(last_real_y - @real_y)
  176.     end
  177.     # 前回プレイヤーが移動中だった場合
  178.     if last_moving
  179.       # 同位置のイベントとの接触によるイベント起動判定
  180.       result = check_event_trigger_here([1,2])
  181.       if result == true
  182.         if (last_real_x / 128.0).round != @x and
  183.             (last_real_y / 128.0).round != @y
  184.           if @direction == 2 or @direction == 8
  185.             if (last_real_x / 128.0).round > @x
  186.               turn_left
  187.             else
  188.               turn_right
  189.             end
  190.           else
  191.             if (last_real_y / 128.0).round > @y
  192.               turn_up
  193.             else
  194.               turn_down
  195.             end
  196.           end
  197.         elsif (last_real_x / 128.0).round > @x
  198.           turn_left
  199.         elsif (last_real_x / 128.0).round < @x
  200.           turn_right
  201.         elsif (last_real_y / 128.0).round > @y
  202.           turn_up
  203.         elsif (last_real_y / 128.0).round < @y
  204.           turn_down
  205.         end
  206.       end
  207.       # 起動したイベントがない場合
  208.       if result == false
  209.         # デバッグモードが ON かつ CTRL キーが押されている場合を除き
  210.         unless $DEBUG and Input.press?(Input::CTRL)
  211.           # エンカウント カウントダウン
  212.           if @encounter_count > 0
  213.             @encounter_count -= 1
  214.           end
  215.         end
  216.       end
  217.     end
  218. #-----------------------按跳跃-----------------------------------------------
  219. # A ボタンが押された場合
  220.     if Input.press?(Input::A) and not $ud_ok
  221.       @twojump = 1 if @twojump == 0 and down1(((@x * 128 + @revise_x) / 128.0).round,
  222.           ((@y * 128 + @revise_y) / 128.0).round, 5, true)
  223.       if (not @apassed) and @twojump <= $airjump
  224.         @apassed = true
  225.         @jumpnow = JUMPMAX
  226.         @twojump += 1
  227.       else
  228.         @jumpnow += 3        
  229.       end
  230.     else
  231.       @apassed = false
  232.     end
  233. #----------------------自由落体--------------------------------
  234.     if not $ud_ok
  235.       @jumpnow -= 10
  236.       if @jumpnow < 0
  237.         @jumpnow = [@jumpnow, -JUMPMAX].max
  238.         if not down1(((@x * 128 + @revise_x) / 128.0).round,
  239.           ((@y * 128 + @revise_y) / 128.0).round, -@jumpnow, true)
  240.           @jumpnow = 0
  241.           @twojump = 0
  242.         end
  243.       elsif @jumpnow > 0
  244.         @jumpnow = [@jumpnow, JUMPMAX].min
  245.         if not up1(((@x * 128 + @revise_x) / 128.0).round,
  246.           ((@y * 128 + @revise_y) / 128.0).round, @jumpnow, true)
  247.           @jumpnow = 0
  248.         end
  249.       end
  250.     end
  251.     if Input.trigger?(Input::C)
  252.       # 同位置および正面のイベント起動判定
  253.       check_event_trigger_here([0])
  254.       check_event_trigger_there([0,1,2])
  255.     end
  256.   end
  257.   #--------------------------------------------------------------------------
  258.   # ● オブジェクト初期化
  259.   #--------------------------------------------------------------------------
  260.   def initialize
  261.     @jumpnow = 0
  262.     @twojump = 0
  263.     @apassed = false
  264.     @revise_x = 0
  265.     @revise_y = 0
  266.     @move == false
  267.     super
  268.   end
  269.   #--------------------------------------------------------------------------
  270.   # ● 移動判定
  271.   #--------------------------------------------------------------------------
  272.   def moving?
  273.     unless @dot_m
  274.       result = super
  275.       return result
  276.     end
  277.     # 強制移動の場合オリジナルの判定をさせる
  278.     if @move_route_forcing
  279.       if @move == false
  280.         return false
  281.       end
  282.       super
  283.     # 通常時は現座標が実座標と異なる場合のみ移動中と判定
  284.     else
  285.       return (@x != (@real_x / 128.0).round or @y != (@real_y / 128.0).round)
  286.     end
  287.   end
  288.   #--------------------------------------------------------------------------
  289.   # ● 移動判定
  290.   #--------------------------------------------------------------------------
  291.   def moving_a?
  292.     if @move == false
  293.       if (@move_route.list[@move_route_index].code <= 14 or
  294.           @move_route.list[@move_route_index].code == 25)
  295.         @move = true
  296.       end
  297.       return false
  298.     end
  299.     moving?
  300.   end
  301.   #--------------------------------------------------------------------------
  302.   # ● フレーム更新 (ジャンプ)
  303.   #--------------------------------------------------------------------------
  304.   def update_jump
  305.     # ジャンプカウントを 1 減らす
  306.     @jump_count -= 1
  307.     # 新しい座標を計算
  308.     @real_x = (@real_x * @jump_count + @x * 128) / (@jump_count + 1)
  309.     @real_y = (@real_y * @jump_count + @y * 128) / (@jump_count + 1)
  310.     if @jump_count == 0
  311.       @revise_x = 0
  312.       @revise_y = 0
  313.     end
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   # ● 移動タイプ : カスタム
  317.   #--------------------------------------------------------------------------
  318.   def move_type_custom
  319.     unless @dot_m
  320.       super
  321.       return
  322.     end
  323.     # 停止中でなければ中断
  324.     if jumping? or moving_a?
  325.       return
  326.     end
  327.     # 移動コマンドのリストの最後に到達するまでループ
  328.     while @move_route_index < @move_route.list.size
  329.       # 移動コマンドを取得
  330.       command = @move_route.list[@move_route_index]
  331.       # コマンドコード 0 番 (リストの最後) の場合
  332.       if command.code == 0
  333.         # オプション [動作を繰り返す] が ON の場合
  334.         if @move_route.repeat
  335.           # 移動ルートのインデックスを最初に戻す
  336.           @move_route_index = 0
  337.         end
  338.         # オプション [動作を繰り返す] が OFF の場合
  339.         unless @move_route.repeat
  340.           # 移動ルート強制中の場合
  341.           if @move_route_forcing and not @move_route.repeat
  342.             # 移動ルートの強制を解除
  343.             @move_route_forcing = false
  344.             # オリジナルの移動ルートを復帰
  345.             @move_route = @original_move_route
  346.             @move_route_index = @original_move_route_index
  347.             @original_move_route = nil
  348.           end
  349.           # 停止カウントをクリア
  350.           @stop_count = 0
  351.         end
  352.         return
  353.       end
  354.       # 移動系コマンド (下に移動~ジャンプ) の場合
  355.       if command.code <= 14
  356.         # コマンドコードで分岐
  357.         case command.code
  358.         when 1  # 下に移動
  359.           move_down
  360.         when 2  # 左に移動
  361.           move_left
  362.         when 3  # 右に移動
  363.           move_right
  364.         when 4  # 上に移動
  365.           move_up
  366.         when 5  # 左下に移動
  367.           move_lower_left
  368.         when 6  # 右下に移動
  369.           move_lower_right
  370.         when 7  # 左上に移動
  371.           move_upper_left
  372.         when 8  # 右上に移動
  373.           move_upper_right
  374.         when 9  # ランダムに移動
  375.           move_random
  376.         when 10  # プレイヤーに近づく
  377.           move_toward_player
  378.         when 11  # プレイヤーから遠ざかる
  379.           move_away_from_player
  380.         when 12  # 一歩前進
  381.           move_forward
  382.         when 13  # 一歩後退
  383.           move_backward
  384.         when 14  # ジャンプ
  385.           jump(command.parameters[0], command.parameters[1])
  386.         end
  387.         # オプション [移動できない場合は無視] が OFF で、移動失敗の場合
  388.         if not @move_route.skippable and not moving? and not jumping?
  389.           return
  390.         end
  391.         @move_route_index += 1
  392.         return
  393.       end
  394.       # ウェイトの場合
  395.       if command.code == 15
  396.         # ウェイトカウントを設定
  397.         @wait_count = command.parameters[0] * 2 - 1
  398.         @move_route_index += 1
  399.         return
  400.       end
  401.       # 向き変更系のコマンドの場合
  402.       if command.code >= 16 and command.code <= 26
  403.         # コマンドコードで分岐
  404.         case command.code
  405.         when 16  # 下を向く
  406.           turn_down
  407.         when 17  # 左を向く
  408.           turn_left
  409.         when 18  # 右を向く
  410.           turn_right
  411.         when 19  # 上を向く
  412.           turn_up
  413.         when 20  # 右に 90 度回転
  414.           turn_right_90
  415.         when 21  # 左に 90 度回転
  416.           turn_left_90
  417.         when 22  # 180 度回転
  418.           turn_180
  419.         when 23  # 右か左に 90 度回転
  420.           turn_right_or_left_90
  421.         when 24  # ランダムに方向転換
  422.           turn_random
  423.         when 25  # プレイヤーの方を向く
  424.           turn_toward_player
  425.         when 26  # プレイヤーの逆を向く
  426.           turn_away_from_player
  427.         end
  428.         @move_route_index += 1
  429.         return
  430.       end
  431.       # その他のコマンドの場合
  432.       if command.code >= 27
  433.         # コマンドコードで分岐
  434.         case command.code
  435.         when 27  # スイッチ ON
  436.           $game_switches[command.parameters[0]] = true
  437.           $game_map.need_refresh = true
  438.         when 28  # スイッチ OFF
  439.           $game_switches[command.parameters[0]] = false
  440.           $game_map.need_refresh = true
  441.         when 29  # 移動速度の変更
  442.           @move_speed = command.parameters[0]
  443.         when 30  # 移動頻度の変更
  444.           @move_frequency = command.parameters[0]
  445.         when 31  # 移動時アニメ ON
  446.           @walk_anime = true
  447.         when 32  # 移動時アニメ OFF
  448.           @walk_anime = false
  449.         when 33  # 停止時アニメ ON
  450.           @step_anime = true
  451.         when 34  # 停止時アニメ OFF
  452.           @step_anime = false
  453.         when 35  # 向き固定 ON
  454.           @direction_fix = true
  455.         when 36  # 向き固定 OFF
  456.           @direction_fix = false
  457.         when 37  # すり抜け ON
  458.           @through = true
  459.         when 38  # すり抜け OFF
  460.           @through = false
  461.         when 39  # 最前面に表示 ON
  462.           @always_on_top = true
  463.         when 40  # 最前面に表示 OFF
  464.           @always_on_top = false
  465.         when 41  # グラフィック変更
  466.           @tile_id = 0
  467.           @character_name = command.parameters[0]
  468.           @character_hue = command.parameters[1]
  469.           if @original_direction != command.parameters[2]
  470.             @direction = command.parameters[2]
  471.             @original_direction = @direction
  472.             @prelock_direction = 0
  473.           end
  474.           if @original_pattern != command.parameters[3]
  475.             @pattern = command.parameters[3]
  476.             @original_pattern = @pattern
  477.           end
  478.         when 42  # 不透明度の変更
  479.           @opacity = command.parameters[0]
  480.         when 43  # 合成方法の変更
  481.           @blend_type = command.parameters[0]
  482.         when 44  # SE の演奏
  483.           $game_system.se_play(command.parameters[0])
  484.         when 45  # スクリプト
  485.           result = eval(command.parameters[0])
  486.         end
  487.         @move_route_index += 1
  488.         return
  489.       end
  490.     end
  491.   end
  492.   #--------------------------------------------------------------------------
  493.   # ● 下に移動
  494.   #--------------------------------------------------------------------------
  495.   def move_down_p
  496.     # 下を向く
  497.     turn_down
  498.     # 移動距離を算出
  499.     distance = 2 ** @move_speed
  500.     down1(((@x * 128 + @revise_x) / 128.0).round,
  501.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  502.   end
  503.   def move_down_aaaagq
  504.     distance = 2 ** @move_speed
  505.     down1(((@x * 128 + @revise_x) / 128.0).round,
  506.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  507.   end
  508.   #--------------------------------------------------------------------------
  509.   # ● 下に移動可能かどうかの判定1
  510.   #--------------------------------------------------------------------------
  511.   def down1(x, y, distance, down = false)
  512.     result = down2(x, y, distance)
  513.     if result == false
  514.       @event_run = check_event_trigger_touch(x, y+1)
  515.       return result
  516.     end
  517.     if @revise_x < -SIDE
  518.       result = down2(x, y + 1, distance, 4)
  519.       result &= down2(x - 1, y, distance)
  520.       if result == false
  521.         if down
  522.           move_lower_right_p
  523.           if @revise_x > SIDE
  524.             @revise_x = SIDE
  525.           end
  526.         end
  527.         return result
  528.       end
  529.     elsif @revise_x > SIDE
  530.       result = down2(x, y + 1, distance, 6)
  531.       result &= down2(x + 1, y, distance)
  532.       if result == false
  533.         if down
  534.           move_lower_left_p
  535.           if @revise_x < -SIDE
  536.             @revise_x = -SIDE
  537.           end
  538.         end
  539.         return result
  540.       end
  541.     end
  542.     # 下に移動可能ならば距離分移動
  543.     @revise_y += distance
  544.     return result
  545.   end
  546.   #--------------------------------------------------------------------------
  547.   # ● 下に移動可能かどうかの判定2
  548.   #--------------------------------------------------------------------------
  549.   def down2(x, y, distance, d = 2)
  550.     if @revise_y + distance > DOWN
  551.       unless passable?(x, y, d)
  552.         if @revise_y < DOWN
  553.           @revise_y = DOWN
  554.         end
  555.         return false
  556.       end
  557.     end
  558.     return true
  559.   end
  560.   #--------------------------------------------------------------------------
  561.   # ● 左に移動
  562.   #--------------------------------------------------------------------------
  563.   def move_left_p
  564.     # 左を向く
  565.     turn_left
  566.     distance = 2 ** @move_speed
  567.     left1(((@x * 128 + @revise_x) / 128.0).round,
  568.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  569.   end
  570.   #--------------------------------------------------------------------------
  571.   # ● 左に移動可能かどうかの判定1
  572.   #--------------------------------------------------------------------------
  573.   def left1(x, y, distance, left = false)
  574.     result = left2(x, y, distance)
  575.     if result == false
  576.       @event_run = check_event_trigger_touch(x-1, y)
  577.       return result
  578.     end
  579.     if @revise_y < -UP and $ud_ok
  580.       result = left2(x - 1, y, distance, 8)
  581.       result &= left2(x, y - 1, distance)
  582.       if result == false
  583.         if left
  584.           move_lower_left_p
  585.           if @revise_y > DOWN
  586.             @revise_y = DOWN
  587.           end
  588.         end
  589.         return result
  590.       end
  591.     elsif @revise_y > DOWN and $ud_ok
  592.       result = left2(x - 1, y, distance, 2)
  593.       result &= left2(x, y + 1, distance)
  594.       if result == false
  595.         if left
  596.           move_upper_left_p
  597.           if @revise_y < -UP
  598.             @revise_y = -UP
  599.           end
  600.         end
  601.         return result
  602.       end
  603.     end
  604.     @revise_x -= distance
  605.     return result
  606.   end
  607.   #--------------------------------------------------------------------------
  608.   # ● 左に移動可能かどうかの判定2
  609.   #--------------------------------------------------------------------------
  610.   def left2(x, y, distance, d = 4)
  611.     if @revise_x - distance < -SIDE
  612.       unless passable?(x, y, d)
  613.         if @revise_x > -SIDE
  614.           @revise_x = -SIDE
  615.         end
  616.         return false
  617.       end
  618.     end
  619.     return true
  620.   end
  621.   #--------------------------------------------------------------------------
  622.   # ● 右に移動
  623.   #--------------------------------------------------------------------------
  624.   def move_right_p
  625.       # 右を向く
  626.       turn_right
  627.     distance = 2 ** @move_speed
  628.     right1(((@x * 128 + @revise_x) / 128.0).round,
  629.             ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  630.   end
  631.   #--------------------------------------------------------------------------
  632.   # ● 右に移動可能かどうかの判定1
  633.   #--------------------------------------------------------------------------
  634.   def right1(x, y, distance, right = false)
  635.     result = right2(x, y, distance)
  636.     if result == false
  637.       @event_run = check_event_trigger_touch(x+1, y)
  638.       return result
  639.     end
  640.     if @revise_y < -UP and $ud_ok
  641.       result = right2(x + 1, y, distance, 8)
  642.       result &= right2(x, y - 1, distance)
  643.       if result == false
  644.         if right
  645.           move_lower_right_p
  646.           if @revise_y > DOWN
  647.             @revise_y = DOWN
  648.           end
  649.         end
  650.         return result
  651.       end
  652.     elsif @revise_y > DOWN and $ud_ok
  653.       result = right2(x + 1, y, distance, 2)
  654.       result &= right2(x, y + 1, distance)
  655.       if result == false
  656.         if right
  657.           move_upper_right_p
  658.           if @revise_y < -UP
  659.             @revise_y = -UP
  660.           end
  661.         end
  662.         return result
  663.       end
  664.     end
  665.     @revise_x += distance
  666.     return result
  667.   end
  668.   #--------------------------------------------------------------------------
  669.   # ● 右に移動可能かどうかの判定2
  670.   #--------------------------------------------------------------------------
  671.   def right2(x, y, distance, d = 6)
  672.     if @revise_x + distance > SIDE
  673.       unless passable?(x, y, d)
  674.         if @revise_x < SIDE
  675.           @revise_x = SIDE
  676.         end
  677.         return false
  678.       end
  679.     end
  680.     return true
  681.   end
  682.   #--------------------------------------------------------------------------
  683.   # ● 上に移動
  684.   #--------------------------------------------------------------------------
  685.   def move_up_p
  686.     # 上を向く
  687.     turn_up
  688.     # 下に移動
  689.     distance = 2 ** @move_speed
  690.     up1(((@x * 128 + @revise_x) / 128.0).round,
  691.         ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  692.   end
  693.   def move_up_aaaagq
  694.     distance = 2 ** @move_speed
  695.     up1(((@x * 128 + @revise_x) / 128.0).round,
  696.         ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  697.   end
  698.   #--------------------------------------------------------------------------
  699.   # ● 上に移動可能かどうかの判定1
  700.   #--------------------------------------------------------------------------
  701.   def up1(x, y, distance, up = false)
  702.     result = up2(x, y, distance)
  703.     if result == false
  704.       @event_run = check_event_trigger_touch(x, y-1)
  705.       return result
  706.     end
  707.     if @revise_x < -SIDE
  708.       result = up2(x, y - 1, distance, 4)
  709.       result &= up2(x - 1, y, distance)
  710.       if result == false
  711.         if up
  712.           move_upper_right_p
  713.           if @revise_x > SIDE
  714.             @revise_x = SIDE
  715.           end
  716.         end
  717.         return result
  718.       end
  719.     elsif @revise_x > SIDE
  720.       result = up2(x, y - 1, distance, 6)
  721.       result &= up2(x + 1, y, distance)
  722.       if result == false
  723.         if up
  724.           move_upper_left_p
  725.           if @revise_x < -SIDE
  726.             @revise_x = -SIDE
  727.           end
  728.         end
  729.         return result
  730.       end
  731.     end
  732.     @revise_y -= distance
  733.     return result
  734.   end
  735.   #--------------------------------------------------------------------------
  736.   # ● 上に移動可能かどうかの判定2
  737.   #--------------------------------------------------------------------------
  738.   def up2(x, y, distance, d = 8)
  739.     if @revise_y - distance < -UP
  740.       unless passable?(x, y, d)
  741.         if @revise_y > -UP
  742.           @revise_y = -UP
  743.         end
  744.         return false
  745.       end
  746.     end
  747.     return true
  748.   end
  749.   #--------------------------------------------------------------------------
  750.   # ● 左下に移動
  751.   #--------------------------------------------------------------------------
  752.   def move_lower_left_p
  753.     # 向き固定でない場合
  754.     unless @direction_fix
  755.       # 右向きだった場合は左を、上向きだった場合は下を向く
  756.       @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  757.     end
  758.     # 左下に移動
  759.     distance = (2 ** @move_speed) / Math.sqrt(2)
  760.     if @direction == 2
  761.       turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
  762.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  763.       turn_down if @event_run
  764.       unless @event_run
  765.         if last_move?(@real_x, @real_y, 2, distance)
  766.           result = check_event_trigger_here([1,2], false)
  767.           if result == true
  768.             return
  769.           end
  770.         end
  771.         move_on
  772.         if @revise_y > DOWN and -UP > @revise_y - distance
  773.           @revise_y = DOWN
  774.         end
  775.         turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
  776.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  777.         turn_left if @event_run
  778.       end
  779.     else
  780.       turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
  781.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  782.       turn_left if @event_run
  783.       unless @event_run
  784.         if last_move?(@real_x, @real_y, 4, distance)
  785.           result = check_event_trigger_here([1,2], false)
  786.           if result == true
  787.             return
  788.           end
  789.         end
  790.         move_on
  791.         if  @revise_x + distance> SIDE and -SIDE > @revise_x
  792.           @revise_x = -SIDE
  793.         end
  794.         turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
  795.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  796.         turn_down if @event_run
  797.       end
  798.     end
  799.   end
  800.   #--------------------------------------------------------------------------
  801.   # ● 右下に移動
  802.   #--------------------------------------------------------------------------
  803.   def move_lower_right_p
  804.     # 向き固定でない場合
  805.     unless @direction_fix
  806.       # 左向きだった場合は右を、上向きだった場合は下を向く
  807.       @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  808.     end
  809.     # 右下に移動
  810.     distance = (2 ** @move_speed) / Math.sqrt(2)
  811.     if @direction == 2
  812.       turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
  813.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  814.       turn_down if @event_run
  815.       unless @event_run
  816.         if last_move?(@real_x, @real_y, 2, distance)
  817.           result = check_event_trigger_here([1,2], false)
  818.           if result == true
  819.             return
  820.           end
  821.         end
  822.         move_on
  823.         if @revise_y > DOWN and -UP > @revise_y - distance
  824.           @revise_y = DOWN
  825.         end
  826.         turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
  827.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  828.         turn_right if @event_run
  829.       end
  830.     else
  831.       turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
  832.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  833.       turn_right if @event_run
  834.       unless @event_run
  835.         if last_move?(@real_x, @real_y, 6, distance)
  836.           result = check_event_trigger_here([1,2], false)
  837.           if result == true
  838.             return
  839.           end
  840.         end
  841.         move_on
  842.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  843.           @revise_x = SIDE
  844.         end
  845.         turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
  846.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  847.         turn_down if @event_run
  848.       end
  849.     end
  850.   end
  851.   #--------------------------------------------------------------------------
  852.   # ● 左上に移動
  853.   #--------------------------------------------------------------------------
  854.   def move_upper_left_p
  855.     # 向き固定でない場合
  856.     unless @direction_fix
  857.       # 右向きだった場合は左を、下向きだった場合は上を向く
  858.       @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  859.     end
  860.     # 左上に移動
  861.     distance = (2 ** @move_speed) / Math.sqrt(2)
  862.     if @direction == 8
  863.       turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
  864.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  865.       turn_up if @event_run
  866.       unless @event_run
  867.         if last_move?(@real_x, @real_y, 8, distance)
  868.           result = check_event_trigger_here([1,2], false)
  869.           if result == true
  870.             return
  871.           end
  872.         end
  873.         move_on
  874.         if @revise_y + distance > DOWN and -UP > @revise_y
  875.           @revise_y = -UP
  876.         end
  877.         turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
  878.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  879.         turn_left if @event_run
  880.       end
  881.     else
  882.       turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
  883.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  884.       turn_left if @event_run
  885.       unless @event_run
  886.         if last_move?(@real_x, @real_y, 4, distance)
  887.           result = check_event_trigger_here([1,2], false)
  888.           if result == true
  889.             return
  890.           end
  891.         end
  892.         move_on
  893.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  894.           @revise_x = SIDE
  895.         end
  896.         turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
  897.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  898.         turn_up if @event_run
  899.       end
  900.     end
  901.   end
  902.   #--------------------------------------------------------------------------
  903.   # ● 右上に移動
  904.   #--------------------------------------------------------------------------
  905.   def move_upper_right_p
  906.     # 向き固定でない場合
  907.     unless @direction_fix
  908.       # 左向きだった場合は右を、下向きだった場合は上を向く
  909.       @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  910.     end
  911.     # 右上に移動
  912.     distance = (2 ** @move_speed) / Math.sqrt(2)
  913.     if @direction == 8
  914.       turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
  915.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  916.       turn_up if @event_run
  917.       unless @event_run
  918.         if last_move?(@real_x, @real_y, 8, distance)
  919.           result = check_event_trigger_here([1,2], false)
  920.           if result == true
  921.             return
  922.           end
  923.         end
  924.         move_on
  925.         if @revise_y + distance > DOWN and -UP > @revise_y
  926.           @revise_y = -UP
  927.         end
  928.         turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
  929.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  930.         turn_right if @event_run
  931.       end
  932.     else
  933.       turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
  934.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  935.       turn_right if @event_run
  936.       unless @event_run
  937.         if last_move?(@real_x, @real_y, 6, distance)
  938.           result = check_event_trigger_here([1,2], false)
  939.           if result == true
  940.             return
  941.           end
  942.         end
  943.         move_on
  944.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  945.           @revise_x = SIDE
  946.         end
  947.         turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
  948.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  949.         turn_up if @event_run
  950.       end
  951.     end
  952.   end
  953.   #--------------------------------------------------------------------------
  954.   # ● 同位置のイベント起動判定
  955.   #--------------------------------------------------------------------------
  956.   def check_event_trigger_here(triggers, run = true)
  957.     result = false
  958.     # イベント実行中の場合
  959.     if $game_system.map_interpreter.running?
  960.       return result
  961.     end
  962.     # 全イベントのループ
  963.     for event in $game_map.events.values
  964.       # イベントの座標とトリガーが一致した場合
  965.       if event.x == ((@x * 128 + @revise_x) / 128.0).round and
  966.           event.y == ((@y * 128 + @revise_y) / 128.0).round and
  967.           triggers.include?(event.trigger)
  968.         # ジャンプ中以外で、起動判定が同位置のイベントなら
  969.         if not event.jumping? and event.over_trigger?
  970.           if event.list.size > 1
  971.             if run == true
  972.               event.start
  973.             end
  974.             result = true
  975.           end
  976.         end
  977.       end
  978.     end
  979.     return result
  980.   end
  981.   #--------------------------------------------------------------------------
  982.   # ● 座標修正
  983.   #--------------------------------------------------------------------------
  984.   def move_on
  985.     if @y < (@y + @revise_y / 128.0).round
  986.       @y += 1
  987.       @revise_y -= 128
  988.     end
  989.     if @x > (@x + @revise_x / 128.0).round
  990.       @x -= 1
  991.       @revise_x += 128
  992.     end
  993.     if @x < (@x + @revise_x / 128.0).round
  994.       @x += 1
  995.       @revise_x -= 128
  996.     end
  997.     if @y > (@y + @revise_y / 128.0).round
  998.       @y -= 1
  999.       @revise_y += 128
  1000.     end
  1001.   end
  1002.   #--------------------------------------------------------------------------
  1003.   # ● アニメーションアップデート
  1004.   #--------------------------------------------------------------------------
  1005.   def anime_update
  1006.     # 移動時アニメが ON の場合
  1007.     if @walk_anime
  1008.       # アニメカウントを 1.5 増やす
  1009.       @anime_count += 1.5
  1010.     # 移動時アニメが OFF で、停止時アニメが ON の場合
  1011.     elsif @step_anime
  1012.       # アニメカウントを 1 増やす
  1013.       @anime_count += 1
  1014.     end
  1015.     # アニメカウントが最大値を超えた場合
  1016.     # ※最大値は、基本値 18 から移動速度 * 1 を引いた値
  1017.     if @anime_count > 18 - @move_speed * 2
  1018.       # 停止時アニメが OFF かつ 停止中の場合
  1019.       if not @step_anime and @stop_count > 0
  1020.         # パターンをオリジナルに戻す
  1021.         @pattern = @original_pattern
  1022.       # 停止時アニメが ON または 移動中の場合
  1023.       else
  1024.         # パターンを更新
  1025.         @pattern = (@pattern + 1) % 4
  1026.       end
  1027.       # アニメカウントをクリア
  1028.       @anime_count = 0
  1029.     end
  1030.   end
  1031.   #--------------------------------------------------------------------------
  1032.   # ● 指定位置に移動
  1033.   #--------------------------------------------------------------------------
  1034.   # オリジナルのイベントを改名
  1035.   alias :moveto_original :moveto
  1036.   def moveto(x, y)
  1037.     # 補正座標を初期化
  1038.     @revise_x = 0
  1039.     @revise_y = 0
  1040.     # オリジナルのイベントを呼び出し
  1041.     moveto_original(x, y)
  1042.   end
  1043.   #--------------------------------------------------------------------------
  1044.   # ● 移動したかどうかの判定
  1045.   #--------------------------------------------------------------------------
  1046.   def last_move?(x, y, direction, distance)
  1047.     if direction == 2 or direction == 6
  1048.       distance *= -1
  1049.     end
  1050.     if (direction == 2 or direction == 8) and
  1051.         (y / 128.0).round != ((y - distance) / 128.0).round
  1052.       return true
  1053.     end
  1054.     if (direction == 4 or direction == 6) and
  1055.         (x / 128.0).round != ((x - distance) / 128.0).round
  1056.       return true
  1057.     end
  1058.     return false
  1059.   end
  1060. end
  1061.  
  1062. #==============================================================================
  1063. # ■ Game_Character (分割定義 1)
  1064. #------------------------------------------------------------------------------
  1065. #  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event
  1066. # クラスのスーパークラスとして使用されます。
  1067. #==============================================================================
  1068.  
  1069. class Game_Character
  1070.   #--------------------------------------------------------------------------
  1071.   # ● フレーム更新 (移動)
  1072.   #--------------------------------------------------------------------------
  1073.   def update_move
  1074.     # 移動速度からマップ座標系での移動距離に変換
  1075.     distance = 2 ** @move_speed
  1076.     if @x * 128 != @real_x and @y * 128 != @real_y and Game_Player::SLANT
  1077.       distance /= Math.sqrt(2)
  1078.     end
  1079.     # 論理座標が実座標より下の場合
  1080.     if @y * 128 > @real_y
  1081.       # 下に移動
  1082.       @real_y = [@real_y + distance, @y * 128].min
  1083.     end
  1084.     # 論理座標が実座標より左の場合
  1085.     if @x * 128 < @real_x
  1086.       # 左に移動
  1087.       @real_x = [@real_x - distance, @x * 128].max
  1088.     end
  1089.     # 論理座標が実座標より右の場合
  1090.     if @x * 128 > @real_x
  1091.       # 右に移動
  1092.       @real_x = [@real_x + distance, @x * 128].min
  1093.     end
  1094.     # 論理座標が実座標より上の場合
  1095.     if @y * 128 < @real_y
  1096.       # 上に移動
  1097.       @real_y = [@real_y - distance, @y * 128].max
  1098.     end
  1099.     # 移動時アニメが ON の場合
  1100.     if @walk_anime
  1101.       # アニメカウントを 1.5 増やす
  1102.       @anime_count += 1.5
  1103.     # 移動時アニメが OFF で、停止時アニメが ON の場合
  1104.     elsif @step_anime
  1105.       # アニメカウントを 1 増やす
  1106.       @anime_count += 1
  1107.     end
  1108.   end
  1109. end
  1110.  
  1111. #==============================================================================
  1112. # ■ Game_Event
  1113. #------------------------------------------------------------------------------
  1114. #  イベントを扱うクラスです。条件判定によるイベントページ切り替えや、並列処理
  1115. # イベント実行などの機能を持っており、Game_Map クラスの内部で使用されます。
  1116. #==============================================================================
  1117.  
  1118. class Game_Event < Game_Character
  1119.   #--------------------------------------------------------------------------
  1120.   # ● イベント起動
  1121.   #--------------------------------------------------------------------------
  1122.   def start
  1123.     # 実行内容が空でない場合
  1124.     if @list.size > 1
  1125.       # $game_player.event が0でない場合
  1126.       if $game_player.event != 0
  1127.         # 移動速度を $game_player.event にする
  1128.         $game_player.move_speed = $game_player.event
  1129.       end
  1130.       @starting = true
  1131.     end
  1132.   end
  1133. end
  1134.  
  1135. #==============================================================================
  1136. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  1137. #==============================================================================





我用的八方向行走脚本






# 使用方法:将本脚本插入到main之前。如果你使用了雅土版的八方向走脚本,请确保这个脚本的顺序位置,在雅土八方向走脚本的后面。

# 预先处理:请输入每一步的帧数和总共可用的方向数

$c3_每一步的帧数 = 8
$c3_总共可用的方向数 = 8 #——建议不要修改这个。如果要伪8方向的,就用伪的好了。

# 图片处理与功能说明:

# 1、每一步的帧数:
#    众所周知,RMXP的移动行走图是一个方向共有4帧,很多人都觉得这个帧数有点少。
# 使用这个脚本之后,只要将 $c3_每一步的帧数 这个变量设置一个需要的帧数即可修改
# 单方向移动帧数为相应输入值。修改后,需要用photoshop将所有用到的素材的横排
# 调整为相应帧数,比如输入了8则要将每一行设置8个图像(即每一个行走图有8列)。

# 2、可用方向调整(可用数量:4、8):
#    当为4方向时没有任何变化,还是一个图4行,上左右下4个方向。
#    如果想使用8方向走,将需要八方向行走的行走图在延伸扩大的画布中按照左下、右下、左上、右上继续排布图像。
# 即,行走图图片从上到下的面向排列顺序为:下,左,右,上,左下,右下,左上,右上。
#    至于不需要8方向走的普通的NPC(character),使用photoshop将画布向下扩大一倍即可使用。
#    需要注意的是,如果需要斜方向飞鸟,请不要忘记自制素材。

# 特别提示:   
#     使用本脚本前请先考虑清楚是否要做这种效果。因为使用本脚本后需要用photoshop处理character行走图素材
# 虽然这种处理用photoshop定义动作只需要5分钟即可全部完成,但在制作阶段会感觉不是很爽(具体的用了才知道)
# 作者的建议是,如果你没有足够的制作经验,使用这个脚本得不偿失。请确保自己的能力属于“高手”级别!

# 附赠功能:
#     可以让NPC角色随机8方向走,方法是:NPC角色移动路线为“自定义”,然后自定义里面使用脚本,输入c8即可
#     可以让NPC角色随机4斜角方向走,方法是:NPC角色移动路线为“自定义”,然后自定义里面使用脚本,输入c4即可
#     可以使用真·斜4方向行走,参考脚本53行开始

# 作者:carol3
###########################################################################################################################
###########################################################################################################################

class Game_Player < Game_Character
  if $c3_总共可用的方向数 == 8
    def update
      last_moving = moving?
      unless moving? or $game_system.map_interpreter.running? or
             @move_route_forcing or $game_temp.message_window_showing
        # 用井号后面的东西替代前面的,就可以实现斜4方向走
        case Input.dir8
        when 2
          move_down #move_lower_left
        when 4
          move_left #move_upper_left
        when 6
          move_right #move_lower_right
        when 8
          move_up #move_upper_right
        when 1
          move_lower_left
        when 3
          move_lower_right
        when 7
          move_upper_left
        when 9
          move_upper_right
        end
      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 check_event_trigger_there(triggers)
      result = false
      # 事件执行中的情况下
      if $game_system.map_interpreter.running?
        return result
      end
      # 计算正面坐标
      new_x = @x
      new_y = @y
      case @direction
      when 1
        new_x -= 1
        new_y += 1
      when 2
        new_y += 1
      when 3
        new_x += 1
        new_y += 1
      when 4
        new_x -= 1
      when 6
        new_x += 1
      when 7
        new_x -= 1
        new_y -= 1
      when 8
        new_y -= 1
      when 9
        new_x += 1
        new_y -= 1
      end
      # 全部事件的循环
      for event in $game_map.events.values
        # 事件坐标与目标一致的情况下
        if event.x == new_x and event.y == new_y and
           triggers.include?(event.trigger)
          # 跳跃中以外的情况下、启动判定是正面的事件
          if not event.jumping? and not event.over_trigger?
            event.start
            result = true
          end
        end
      end
      # 找不到符合条件的事件的情况下
      if result == false
        # 正面的元件是计数器的情况下
        if $game_map.counter?(new_x, new_y)
          # 计算 1 元件里侧的坐标
          new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
          new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
          # 全事件的循环
          for event in $game_map.events.values
            # 事件坐标与目标一致的情况下
            if event.x == new_x and event.y == new_y and
               triggers.include?(event.trigger)
              # 跳跃中以外的情况下、启动判定是正面的事件
              if not event.jumping? and not event.over_trigger?
                event.start
                result = true
              end
            end
          end
        end
      end
      return result
    end
    #--------------------------------------------------------------------------
    # ● 向左下移动
    #--------------------------------------------------------------------------
    def move_lower_left
      # 没有固定面向的场合
      unless @direction_fix
        # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
        @direction = 1#(@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
      end
      # 下→左、左→下 的通道可以通行的情况下
      if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
         (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
        # 更新坐标
        @x -= 1
        @y += 1
        # 增加步数
        increase_steps
      else
        check_event_trigger_touch(@x-1, @y+1)
      end
    end
    #--------------------------------------------------------------------------
    # ● 向右下移动
    #--------------------------------------------------------------------------
    def move_lower_right
      # 没有固定面向的场合
      unless @direction_fix
        # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
        @direction = 3#(@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
      end
      # 下→右、右→下 的通道可以通行的情况下
      if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
         (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
        # 更新坐标
        @x += 1
        @y += 1
        # 增加步数
        increase_steps
      else
        check_event_trigger_touch(@x+1, @y+1)
      end
    end
    #--------------------------------------------------------------------------
    # ● 向左上移动
    #--------------------------------------------------------------------------
    def move_upper_left
      # 没有固定面向的场合
      unless @direction_fix
        # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
        @direction = 7#(@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
      end
      # 上→左、左→上 的通道可以通行的情况下
      if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
         (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
        # 更新坐标
        @x -= 1
        @y -= 1
        # 增加步数
        increase_steps
      else
        check_event_trigger_touch(@x-1, @y-1)
      end
    end
    #--------------------------------------------------------------------------
    # ● 向右上移动
    #--------------------------------------------------------------------------
    def move_upper_right
      # 没有固定面向的场合
      unless @direction_fix
        # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
        @direction = 9#(@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
      end
      # 上→右、右→上 的通道可以通行的情况下
      if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
         (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
        # 更新坐标
        @x += 1
        @y -= 1
        # 增加步数
        increase_steps
      else
        check_event_trigger_touch(@x+1, @y-1)
      end
    end
    #--------------------------------------------------------------------------
    # ● 雅土左下移動
    #--------------------------------------------------------------------------
    def move_lower_left_p
      unless @direction_fix
        @direction = 1
      end
      distance = (2 ** @move_speed) / Math.sqrt(2)
      turn_left unless down1(@x, @y, distance)
      turn_down if @event
      turn_down unless left1(@x, @y, distance) unless @event
      turn_left if @event
    end
    #--------------------------------------------------------------------------
    # ● 雅土右下移動
    #--------------------------------------------------------------------------
    def move_lower_right_p
      unless @direction_fix
        @direction = 3
      end
      distance = (2 ** @move_speed) / Math.sqrt(2)
      turn_right unless down1(@x, @y, distance)
      turn_down if @event
      turn_down unless right1(@x, @y, distance) unless @event
      turn_right if @event
    end
    #--------------------------------------------------------------------------
    # ● 雅土左上移動
    #--------------------------------------------------------------------------
    def move_upper_left_p
      unless @direction_fix
        @direction = 7
      end
      distance = (2 ** @move_speed) / Math.sqrt(2)
      turn_left unless up1(@x, @y, distance)
      turn_up if @event
      turn_up unless left1(@x, @y, distance) unless @event
      turn_left if @event
    end
    #--------------------------------------------------------------------------
    # ● 雅土右上移動
    #--------------------------------------------------------------------------
    def move_upper_right_p
      unless @direction_fix
        @direction = 9
      end
      distance = (2 ** @move_speed) / Math.sqrt(2)
      turn_right unless up1(@x, @y, distance)
      turn_up if @event
      turn_up unless right1(@x, @y, distance) unless @event
      turn_right if @event
    end
  end
end


class Sprite_Character < RPG::Sprite
  def update
    super
    # 元件 ID、文件名、色相与现在的情况存在差异的情况下
    if @tile_id != @character.tile_id or
       @character_name != @character.character_name or
       @character_hue != @character.character_hue
      # 记忆元件 ID 与文件名、色相
      @tile_id = @character.tile_id
      @character_name = @character.character_name
      @character_hue = @character.character_hue
      # 元件 ID 为有效值的情况下
      if @tile_id >= 384
        self.bitmap = RPG::Cache.tile($game_map.tileset_name,
          @tile_id, @character.character_hue)
        self.src_rect.set(0, 0, 32, 32)
        self.ox = 16
        self.oy = 32
      # 元件 ID 为无效值的情况下
      else
        self.bitmap = RPG::Cache.character(@character.character_name,
          @character.character_hue)
        @cw = bitmap.width / $c3_每一步的帧数
        if $c3_总共可用的方向数==4
          @ch = bitmap.height / 4
        else
          @ch = bitmap.height / 8
        end
        self.ox = @cw / 2
        self.oy = @ch
      end
    end
    # 设置可视状态
    self.visible = (not @character.transparent)
    # 图形是角色的情况下
    if @tile_id == 0
      # 设置传送目标的矩形
      sx = @character.pattern * @cw
      if $c3_总共可用的方向数==8
        case @character.direction
        when 2
          sy = 0 * @ch
        when 4
          sy = 1 * @ch
        when 6
          sy = 2 * @ch
        when 8
          sy = 3 * @ch
        when 1
          sy = 4 * @ch
        when 3
          sy = 5 * @ch
        when 7
          sy = 6 * @ch
        when 9
          sy = 7 * @ch
        end
      else
        sy = (@character.direction - 2) / 2 * @ch
      end
      self.src_rect.set(sx, sy, @cw, @ch)
    end
    # 设置脚本的坐标
    self.x = @character.screen_x
    self.y = @character.screen_y
    self.z = @character.screen_z(@ch)
    # 设置不透明度、合成方式、茂密
    self.opacity = @character.opacity
    self.blend_type = @character.blend_type
    self.bush_depth = @character.bush_depth
    # 动画
    if @character.animation_id != 0
      animation = $data_animations[@character.animation_id]
      animation(animation, true)
      @character.animation_id = 0
    end
  end
end

class Game_Character
  def c8
    # 随机 0~5 的分支
    case rand(10)
    when 0..3  # 随机
      move_random
    when 4  # 前进一步
      move_forward
    when 5  # 暂时停止
      @stop_count = 0
    when 6..9  #另外4方向随机
      c4
    end
  end
  def c4
    case rand(5)
    when 0
      move_upper_left
    when 1
      move_upper_right
    when 2
      move_lower_left
    when 3
      move_lower_right
    when 4
      @stop_count = 0
    end
  end
      
  def update
    # 跳跃中、移动中、停止中的分支
    if jumping?
      update_jump
    elsif moving?
      update_move
    else
      update_stop
    end
    # 动画计数超过最大值的情况下
    # ※最大值等于基本值减去移动速度 * 1 的值
    if @anime_count > 16*4/$c3_每一步的帧数 - @move_speed * 2
      # 停止动画为 OFF 并且在停止中的情况下
      if not @step_anime and @stop_count > 0
        # 还原为原来的图形
        @pattern = @original_pattern
      # 停止动画为 ON 并且在移动中的情况下
      else
        # 更新图形
        @pattern = (@pattern + 1) % $c3_每一步的帧数
      end
      # 清除动画计数
      @anime_count = 0
    end
    # 等待中的情况下
    if @wait_count > 0
      # 减少等待计数
      @wait_count -= 1
      return
    end
    # 强制移动路线的场合
    if @move_route_forcing
      # 自定义移动
      move_type_custom
      return
    end
    # 事件执行待机中并且为锁定状态的情况下
    if @starting or lock?
      # 不做规则移动
      return
    end
    # 如果停止计数超过了一定的值(由移动频度算出)
    if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
      # 移动类型分支
      case @move_type
      when 1  # 随机
        move_type_random
      when 2  # 接近
        move_type_toward_player
      when 3  # 自定义
        move_type_custom
      end
    end
  end
end

class Window_Base < Window
  def draw_actor_graphic(actor, x, y)
    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
    cw = bitmap.width / $c3_每一步的帧数
    ch = bitmap.height / $c3_总共可用的方向数
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  end
end

class Game_Character
  #--------------------------------------------------------------------------
  # ● 面向主角的方向
  #--------------------------------------------------------------------------
  def turn_toward_player
    # 求得与主角的坐标差
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    # 坐标相等的场合下
    if sx == 0 and sy == 0
      return
    end
    # 横侧距离长的情况下
    if sx.abs > sy.abs
      # 将左右方向变更为朝向主角的方向
      sx > 0 ? turn_left : turn_right
    # 竖侧距离长的情况下
    else
      # 将上下方向变更为朝向主角的方向
      sy > 0 ? turn_up : turn_down
    end
    if sx == -1 and sy == -1
      @direction = 3
      @stop_count = 0
    elsif sx == -1 and sy == 1
      @direction = 9
      @stop_count = 0
    elsif sx == 1 and sy == -1
      @direction = 1
      @stop_count = 0
    elsif sx == 1 and sy == 1
      @direction = 7
      @stop_count = 0
    end
  end
end

#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================

最佳答案

查看完整内容

看看我整的这个能不能用:

评分

参与人数 1星屑 +35 收起 理由
RyanBern + 35 手动认可奖励

查看全部评分

Lv3.寻梦者

梦石
0
星屑
1095
在线时间
381 小时
注册时间
2010-10-9
帖子
386

开拓者

2
发表于 2015-7-24 14:40:22 | 只看该作者
看看我整的这个能不能用:
  1. $ud_ok = true #上下失效
  2. $airjump = 1  #空中连跳
  3. #==============================================================================
  4. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  5. #==============================================================================

  6. # ————————————————————————————————————
  7. # 全方向ドット移動 Ver ε
  8. # 配布元・サポートURL
  9. # [url]http://members.jcom.home.ne.jp/cogwheel/[/url]

  10. #==============================================================================
  11. # ■ Game_Player
  12. #------------------------------------------------------------------------------
  13. #  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの
  14. # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
  15. #==============================================================================
  16. class Game_Player < Game_Character
  17.   #--------------------------------------------------------------------------
  18.   # ● 定数
  19.   #--------------------------------------------------------------------------
  20.   UP    = 48                  # 上方向の余裕(0 < UP < 63)
  21.   DOWN  = 16                  # 下方向の余裕(0 < DOWN <63)
  22.   SIDE  = 32                  # 左右方向の余裕(0 < SIDE <63)
  23.   SLANT = false               # 移動ルートの斜め移動時、速度修正
  24.   JUMPMAX = 100              
  25.   JUMPADD = 10              
  26.   #--------------------------------------------------------------------------
  27.   # ● 公開インスタンス変数
  28.   #--------------------------------------------------------------------------
  29.   attr_reader   :event                    # イベント時移動速度
  30.   attr_accessor :move_speed               # 移動速度
  31.   #--------------------------------------------------------------------------
  32.   # ● フレーム更新
  33.   #--------------------------------------------------------------------------
  34.   alias :update_original :update
  35.   def update
  36.     # @walk:歩行速度 @dash:ダッシュ時移動速度
  37.     # @event:イベント時移動速度(0の時は、イベント時に速度変更をしない)
  38.     @walk  = 4
  39.     @dash  = 5
  40.     @event = 4
  41.     @dot_m = true
  42.     #ダッシュ機能。エンターキーが押されている間、移動速度を変更する。
  43.     unless moving? or $game_system.map_interpreter.running? or
  44.             @move_route_forcing or $game_temp.message_window_showing
  45.       if @walk != @dash
  46.         if Input.press?(Input::C)
  47.           if @move_speed != @dash
  48.             @move_speed = @dash
  49.           end
  50.         else
  51.           if @move_speed != @walk
  52.             @move_speed = @walk
  53.           end
  54.         end
  55.       end
  56.     end
  57.     if @revise_x == nil and @revise_y == nil
  58.       @revise_x = 0
  59.       @revise_y = 0
  60.     end
  61.     unless @dot_m
  62.       update_original
  63.       return
  64.     end
  65.     if @move_route_forcing
  66.       # ローカル変数に移動中かどうかを記憶
  67.       last_moving = moving?
  68.       # ローカル変数に座標を記憶
  69.       last_real_x = @real_x
  70.       last_real_y = @real_y
  71.       # 座標がずれている場合
  72.       if (@revise_x != 0 or @revise_y != 0) and not jumping? and @move == true
  73.         if @revise_x != @real_x - @x * 128 or @revise_y != @real_y - @y * 128
  74.           @revise_x = @real_x - @x * 128
  75.           @revise_y = @real_y - @y * 128
  76.         end
  77.         # 移動距離distance1と目標距離distance2を設定
  78.         distance1 = 2 ** @move_speed
  79.         distance2 = Math.sqrt(@revise_x ** 2 + @revise_y ** 2)
  80.         # 移動距離が目標距離を越えた場合
  81.         if distance1 > distance2
  82.           # 強制的に補正座標を零にする
  83.           @real_x = @real_x - @revise_x
  84.           @real_y = @real_y - @revise_y
  85.           @revise_x = 0
  86.           @revise_y = 0
  87.           anime_update
  88.         # 移動距離が目標距離に達しない場合
  89.         else
  90.           # 移動距離分目標距離に近づく
  91.           @real_x -= (distance1 * @revise_x / distance2).round
  92.           @real_y -= (distance1 * @revise_y / distance2).round
  93.           @revise_x = @real_x - @x * 128
  94.           @revise_y = @real_y - @y * 128
  95.           anime_update
  96.         end
  97.       else
  98.         super
  99.       end
  100.     else
  101.       @move = false
  102.       # 移動中、イベント実行中、移動ルート強制中、
  103.       # メッセージウィンドウ表示中のいずれでもない場合
  104.       unless moving? or $game_system.map_interpreter.running? or
  105.              @move_route_forcing or $game_temp.message_window_showing
  106.         @event_run = false
  107.         # 方向ボタンが押されていれば、その方向へプレイヤーを移動
  108. #---------------------------上下失效-----------------------------------------
  109. if $c3_总共可用的方向数 == 8
  110.        case Input.dir8
  111.         when 1
  112.           $ud_ok ? move_lower_left_p : move_left_p
  113.         when 2
  114. #          $ud_ok ? move_down_p : move_down_aaaagq
  115.           move_down_p if $ud_ok
  116.         when 3
  117.          $ud_ok ? move_lower_right_p : move_right_p
  118.         when 4
  119.           move_left_p
  120.         when 6
  121.           move_right_p
  122.         when 7
  123.          $ud_ok ? move_upper_left_p : move_left_p
  124.         when 8
  125. #         $ud_ok ? move_up_p : move_up_aaaagq
  126.          move_up_p if $ud_ok
  127.         when 9
  128.          $ud_ok ? move_upper_right_p : move_right_p
  129.        end
  130.       end
  131.     end
  132.       # ローカル変数に座標を記憶
  133.       last_real_x = @real_x
  134.       last_real_y = @real_y
  135.       # 移動処理
  136.       @real_x = @x * 128 + @revise_x
  137.       @real_y = @y * 128 + @revise_y
  138.       # ローカル変数に移動中かどうかを記憶
  139.       last_moving = moving?
  140.       # 座標更新
  141.       move_on
  142.       # 現在の座標と以前の座標が異なる場合
  143.       if (last_real_x != @real_x or last_real_y != @real_y)
  144.         @move_distance = 0 if @move_distance == nil
  145.         @move_distance += Math.sqrt((last_real_x - @real_x) ** 2 +
  146.                                       (last_real_y - @real_y) ** 2)
  147.         if @move_distance >= 128
  148.           @move_distance %= 128
  149.           increase_steps
  150.         end
  151.         # アニメーションを更新
  152.         anime_update
  153.       else
  154.         @pattern = 0
  155.       end
  156.     end
  157.     # キャラクターが下に移動し、かつ画面上の位置が中央より下の場合
  158.     if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  159.       # マップを下にスクロール
  160.       $game_map.scroll_down(@real_y - last_real_y)
  161.     end
  162.     # キャラクターが左に移動し、かつ画面上の位置が中央より左の場合
  163.     if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  164.       # マップを左にスクロール
  165.       $game_map.scroll_left(last_real_x - @real_x)
  166.     end
  167.     # キャラクターが右に移動し、かつ画面上の位置が中央より右の場合
  168.     if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  169.       # マップを右にスクロール
  170.       $game_map.scroll_right(@real_x - last_real_x)
  171.     end
  172.     # キャラクターが上に移動し、かつ画面上の位置が中央より上の場合
  173.     if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  174.       # マップを上にスクロール
  175.       $game_map.scroll_up(last_real_y - @real_y)
  176.     end
  177.     # 前回プレイヤーが移動中だった場合
  178.     if last_moving
  179.       # 同位置のイベントとの接触によるイベント起動判定
  180.       result = check_event_trigger_here([1,2])
  181.       if result == true
  182.         if (last_real_x / 128.0).round != @x and
  183.             (last_real_y / 128.0).round != @y
  184.           if @direction == 2 or @direction == 8
  185.             if (last_real_x / 128.0).round > @x
  186.               turn_left
  187.             else
  188.               turn_right
  189.             end
  190.           else
  191.             if (last_real_y / 128.0).round > @y
  192.               turn_up
  193.             else
  194.               turn_down
  195.             end
  196.           end
  197.         elsif (last_real_x / 128.0).round > @x
  198.           turn_left
  199.         elsif (last_real_x / 128.0).round < @x
  200.           turn_right
  201.         elsif (last_real_y / 128.0).round > @y
  202.           turn_up
  203.         elsif (last_real_y / 128.0).round < @y
  204.           turn_down
  205.         end
  206.       end
  207.       # 起動したイベントがない場合
  208.       if result == false
  209.         # デバッグモードが ON かつ CTRL キーが押されている場合を除き
  210.         unless $DEBUG and Input.press?(Input::CTRL)
  211.           # エンカウント カウントダウン
  212.           if @encounter_count > 0
  213.             @encounter_count -= 1
  214.           end
  215.         end
  216.       end
  217.     end
  218. #-----------------------按跳跃-----------------------------------------------
  219. # A ボタンが押された場合
  220.     if Input.press?(Input::A) and not $ud_ok
  221.       @twojump = 1 if @twojump == 0 and down1(((@x * 128 + @revise_x) / 128.0).round,
  222.           ((@y * 128 + @revise_y) / 128.0).round, 5, true)
  223.       if (not @apassed) and @twojump <= $airjump
  224.         @apassed = true
  225.         @jumpnow = JUMPMAX
  226.         @twojump += 1
  227.       else
  228.         @jumpnow += 3        
  229.       end
  230.     else
  231.       @apassed = false
  232.     end
  233. #----------------------自由落体--------------------------------
  234.     if not $ud_ok
  235.       @jumpnow -= 10
  236.       if @jumpnow < 0
  237.         @jumpnow = [@jumpnow, -JUMPMAX].max
  238.         if not down1(((@x * 128 + @revise_x) / 128.0).round,
  239.           ((@y * 128 + @revise_y) / 128.0).round, -@jumpnow, true)
  240.           @jumpnow = 0
  241.           @twojump = 0
  242.         end
  243.       elsif @jumpnow > 0
  244.         @jumpnow = [@jumpnow, JUMPMAX].min
  245.         if not up1(((@x * 128 + @revise_x) / 128.0).round,
  246.           ((@y * 128 + @revise_y) / 128.0).round, @jumpnow, true)
  247.           @jumpnow = 0
  248.         end
  249.       end
  250.     end
  251.     if Input.trigger?(Input::C)
  252.       # 同位置および正面のイベント起動判定
  253.       check_event_trigger_here([0])
  254.       check_event_trigger_there([0,1,2])
  255.     end
  256.   end
  257.   #--------------------------------------------------------------------------
  258.   # ● オブジェクト初期化
  259.   #--------------------------------------------------------------------------
  260.   def initialize
  261.     @jumpnow = 0
  262.     @twojump = 0
  263.     @apassed = false
  264.     @revise_x = 0
  265.     @revise_y = 0
  266.     @move == false
  267.     super
  268.   end
  269.   #--------------------------------------------------------------------------
  270.   # ● 移動判定
  271.   #--------------------------------------------------------------------------
  272.   def moving?
  273.     unless @dot_m
  274.       result = super
  275.       return result
  276.     end
  277.     # 強制移動の場合オリジナルの判定をさせる
  278.     if @move_route_forcing
  279.       if @move == false
  280.         return false
  281.       end
  282.       super
  283.     # 通常時は現座標が実座標と異なる場合のみ移動中と判定
  284.     else
  285.       return (@x != (@real_x / 128.0).round or @y != (@real_y / 128.0).round)
  286.     end
  287.   end
  288.   #--------------------------------------------------------------------------
  289.   # ● 移動判定
  290.   #--------------------------------------------------------------------------
  291.   def moving_a?
  292.     if @move == false
  293.       if (@move_route.list[@move_route_index].code <= 14 or
  294.           @move_route.list[@move_route_index].code == 25)
  295.         @move = true
  296.       end
  297.       return false
  298.     end
  299.     moving?
  300.   end
  301.   #--------------------------------------------------------------------------
  302.   # ● フレーム更新 (ジャンプ)
  303.   #--------------------------------------------------------------------------
  304.   def update_jump
  305.     # ジャンプカウントを 1 減らす
  306.     @jump_count -= 1
  307.     # 新しい座標を計算
  308.     @real_x = (@real_x * @jump_count + @x * 128) / (@jump_count + 1)
  309.     @real_y = (@real_y * @jump_count + @y * 128) / (@jump_count + 1)
  310.     if @jump_count == 0
  311.       @revise_x = 0
  312.       @revise_y = 0
  313.     end
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   # ● 移動タイプ : カスタム
  317.   #--------------------------------------------------------------------------
  318.   def move_type_custom
  319.     unless @dot_m
  320.       super
  321.       return
  322.     end
  323.     # 停止中でなければ中断
  324.     if jumping? or moving_a?
  325.       return
  326.     end
  327.     # 移動コマンドのリストの最後に到達するまでループ
  328.     while @move_route_index < @move_route.list.size
  329.       # 移動コマンドを取得
  330.       command = @move_route.list[@move_route_index]
  331.       # コマンドコード 0 番 (リストの最後) の場合
  332.       if command.code == 0
  333.         # オプション [動作を繰り返す] が ON の場合
  334.         if @move_route.repeat
  335.           # 移動ルートのインデックスを最初に戻す
  336.           @move_route_index = 0
  337.         end
  338.         # オプション [動作を繰り返す] が OFF の場合
  339.         unless @move_route.repeat
  340.           # 移動ルート強制中の場合
  341.           if @move_route_forcing and not @move_route.repeat
  342.             # 移動ルートの強制を解除
  343.             @move_route_forcing = false
  344.             # オリジナルの移動ルートを復帰
  345.             @move_route = @original_move_route
  346.             @move_route_index = @original_move_route_index
  347.             @original_move_route = nil
  348.           end
  349.           # 停止カウントをクリア
  350.           @stop_count = 0
  351.         end
  352.         return
  353.       end
  354.       # 移動系コマンド (下に移動~ジャンプ) の場合
  355.       if command.code <= 14
  356.         # コマンドコードで分岐
  357.         case command.code
  358.         when 1  # 下に移動
  359.           move_down
  360.         when 2  # 左に移動
  361.           move_left
  362.         when 3  # 右に移動
  363.           move_right
  364.         when 4  # 上に移動
  365.           move_up
  366.         when 5  # 左下に移動
  367.           move_lower_left
  368.         when 6  # 右下に移動
  369.           move_lower_right
  370.         when 7  # 左上に移動
  371.           move_upper_left
  372.         when 8  # 右上に移動
  373.           move_upper_right
  374.         when 9  # ランダムに移動
  375.           move_random
  376.         when 10  # プレイヤーに近づく
  377.           move_toward_player
  378.         when 11  # プレイヤーから遠ざかる
  379.           move_away_from_player
  380.         when 12  # 一歩前進
  381.           move_forward
  382.         when 13  # 一歩後退
  383.           move_backward
  384.         when 14  # ジャンプ
  385.           jump(command.parameters[0], command.parameters[1])
  386.         end
  387.         # オプション [移動できない場合は無視] が OFF で、移動失敗の場合
  388.         if not @move_route.skippable and not moving? and not jumping?
  389.           return
  390.         end
  391.         @move_route_index += 1
  392.         return
  393.       end
  394.       # ウェイトの場合
  395.       if command.code == 15
  396.         # ウェイトカウントを設定
  397.         @wait_count = command.parameters[0] * 2 - 1
  398.         @move_route_index += 1
  399.         return
  400.       end
  401.       # 向き変更系のコマンドの場合
  402.       if command.code >= 16 and command.code <= 26
  403.         # コマンドコードで分岐
  404.         case command.code
  405.         when 16  # 下を向く
  406.           turn_down
  407.         when 17  # 左を向く
  408.           turn_left
  409.         when 18  # 右を向く
  410.           turn_right
  411.         when 19  # 上を向く
  412.           turn_up
  413.         when 20  # 右に 90 度回転
  414.           turn_right_90
  415.         when 21  # 左に 90 度回転
  416.           turn_left_90
  417.         when 22  # 180 度回転
  418.           turn_180
  419.         when 23  # 右か左に 90 度回転
  420.           turn_right_or_left_90
  421.         when 24  # ランダムに方向転換
  422.           turn_random
  423.         when 25  # プレイヤーの方を向く
  424.           turn_toward_player
  425.         when 26  # プレイヤーの逆を向く
  426.           turn_away_from_player
  427.         end
  428.         @move_route_index += 1
  429.         return
  430.       end
  431.       # その他のコマンドの場合
  432.       if command.code >= 27
  433.         # コマンドコードで分岐
  434.         case command.code
  435.         when 27  # スイッチ ON
  436.           $game_switches[command.parameters[0]] = true
  437.           $game_map.need_refresh = true
  438.         when 28  # スイッチ OFF
  439.           $game_switches[command.parameters[0]] = false
  440.           $game_map.need_refresh = true
  441.         when 29  # 移動速度の変更
  442.           @move_speed = command.parameters[0]
  443.         when 30  # 移動頻度の変更
  444.           @move_frequency = command.parameters[0]
  445.         when 31  # 移動時アニメ ON
  446.           @walk_anime = true
  447.         when 32  # 移動時アニメ OFF
  448.           @walk_anime = false
  449.         when 33  # 停止時アニメ ON
  450.           @step_anime = true
  451.         when 34  # 停止時アニメ OFF
  452.           @step_anime = false
  453.         when 35  # 向き固定 ON
  454.           @direction_fix = true
  455.         when 36  # 向き固定 OFF
  456.           @direction_fix = false
  457.         when 37  # すり抜け ON
  458.           @through = true
  459.         when 38  # すり抜け OFF
  460.           @through = false
  461.         when 39  # 最前面に表示 ON
  462.           @always_on_top = true
  463.         when 40  # 最前面に表示 OFF
  464.           @always_on_top = false
  465.         when 41  # グラフィック変更
  466.           @tile_id = 0
  467.           @character_name = command.parameters[0]
  468.           @character_hue = command.parameters[1]
  469.           if @original_direction != command.parameters[2]
  470.             @direction = command.parameters[2]
  471.             @original_direction = @direction
  472.             @prelock_direction = 0
  473.           end
  474.           if @original_pattern != command.parameters[3]
  475.             @pattern = command.parameters[3]
  476.             @original_pattern = @pattern
  477.           end
  478.         when 42  # 不透明度の変更
  479.           @opacity = command.parameters[0]
  480.         when 43  # 合成方法の変更
  481.           @blend_type = command.parameters[0]
  482.         when 44  # SE の演奏
  483.           $game_system.se_play(command.parameters[0])
  484.         when 45  # スクリプト
  485.           result = eval(command.parameters[0])
  486.         end
  487.         @move_route_index += 1
  488.         return
  489.       end
  490.     end
  491.   end
  492.   #--------------------------------------------------------------------------
  493.   # ● 下に移動
  494.   #--------------------------------------------------------------------------
  495.   def move_down_p
  496.     # 下を向く
  497.     turn_down
  498.     # 移動距離を算出
  499.     distance = 2 ** @move_speed
  500.     down1(((@x * 128 + @revise_x) / 128.0).round,
  501.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  502.   end
  503.   def move_down_aaaagq
  504.     distance = 2 ** @move_speed
  505.     down1(((@x * 128 + @revise_x) / 128.0).round,
  506.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  507.   end
  508.   #--------------------------------------------------------------------------
  509.   # ● 下に移動可能かどうかの判定1
  510.   #--------------------------------------------------------------------------
  511.   def down1(x, y, distance, down = false)
  512.     result = down2(x, y, distance)
  513.     if result == false
  514.       @event_run = check_event_trigger_touch(x, y+1)
  515.       return result
  516.     end
  517.     if @revise_x < -SIDE
  518.       result = down2(x, y + 1, distance, 4)
  519.       result &= down2(x - 1, y, distance)
  520.       if result == false
  521.         if down
  522.           move_lower_right_p
  523.           if @revise_x > SIDE
  524.             @revise_x = SIDE
  525.           end
  526.         end
  527.         return result
  528.       end
  529.     elsif @revise_x > SIDE
  530.       result = down2(x, y + 1, distance, 6)
  531.       result &= down2(x + 1, y, distance)
  532.       if result == false
  533.         if down
  534.           move_lower_left_p
  535.           if @revise_x < -SIDE
  536.             @revise_x = -SIDE
  537.           end
  538.         end
  539.         return result
  540.       end
  541.     end
  542.     # 下に移動可能ならば距離分移動
  543.     @revise_y += distance
  544.     return result
  545.   end
  546.   #--------------------------------------------------------------------------
  547.   # ● 下に移動可能かどうかの判定2
  548.   #--------------------------------------------------------------------------
  549.   def down2(x, y, distance, d = 2)
  550.     if @revise_y + distance > DOWN
  551.       unless passable?(x, y, d)
  552.         if @revise_y < DOWN
  553.           @revise_y = DOWN
  554.         end
  555.         return false
  556.       end
  557.     end
  558.     return true
  559.   end
  560.   #--------------------------------------------------------------------------
  561.   # ● 左に移動
  562.   #--------------------------------------------------------------------------
  563.   def move_left_p
  564.     # 左を向く
  565.     turn_left
  566.     distance = 2 ** @move_speed
  567.     left1(((@x * 128 + @revise_x) / 128.0).round,
  568.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  569.   end
  570.   #--------------------------------------------------------------------------
  571.   # ● 左に移動可能かどうかの判定1
  572.   #--------------------------------------------------------------------------
  573.   def left1(x, y, distance, left = false)
  574.     result = left2(x, y, distance)
  575.     if result == false
  576.       @event_run = check_event_trigger_touch(x-1, y)
  577.       return result
  578.     end
  579.     if @revise_y < -UP and $ud_ok
  580.       result = left2(x - 1, y, distance, 8)
  581.       result &= left2(x, y - 1, distance)
  582.       if result == false
  583.         if left
  584.           move_lower_left_p
  585.           if @revise_y > DOWN
  586.             @revise_y = DOWN
  587.           end
  588.         end
  589.         return result
  590.       end
  591.     elsif @revise_y > DOWN and $ud_ok
  592.       result = left2(x - 1, y, distance, 2)
  593.       result &= left2(x, y + 1, distance)
  594.       if result == false
  595.         if left
  596.           move_upper_left_p
  597.           if @revise_y < -UP
  598.             @revise_y = -UP
  599.           end
  600.         end
  601.         return result
  602.       end
  603.     end
  604.     @revise_x -= distance
  605.     return result
  606.   end
  607.   #--------------------------------------------------------------------------
  608.   # ● 左に移動可能かどうかの判定2
  609.   #--------------------------------------------------------------------------
  610.   def left2(x, y, distance, d = 4)
  611.     if @revise_x - distance < -SIDE
  612.       unless passable?(x, y, d)
  613.         if @revise_x > -SIDE
  614.           @revise_x = -SIDE
  615.         end
  616.         return false
  617.       end
  618.     end
  619.     return true
  620.   end
  621.   #--------------------------------------------------------------------------
  622.   # ● 右に移動
  623.   #--------------------------------------------------------------------------
  624.   def move_right_p
  625.       # 右を向く
  626.       turn_right
  627.     distance = 2 ** @move_speed
  628.     right1(((@x * 128 + @revise_x) / 128.0).round,
  629.             ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  630.   end
  631.   #--------------------------------------------------------------------------
  632.   # ● 右に移動可能かどうかの判定1
  633.   #--------------------------------------------------------------------------
  634.   def right1(x, y, distance, right = false)
  635.     result = right2(x, y, distance)
  636.     if result == false
  637.       @event_run = check_event_trigger_touch(x+1, y)
  638.       return result
  639.     end
  640.     if @revise_y < -UP and $ud_ok
  641.       result = right2(x + 1, y, distance, 8)
  642.       result &= right2(x, y - 1, distance)
  643.       if result == false
  644.         if right
  645.           move_lower_right_p
  646.           if @revise_y > DOWN
  647.             @revise_y = DOWN
  648.           end
  649.         end
  650.         return result
  651.       end
  652.     elsif @revise_y > DOWN and $ud_ok
  653.       result = right2(x + 1, y, distance, 2)
  654.       result &= right2(x, y + 1, distance)
  655.       if result == false
  656.         if right
  657.           move_upper_right_p
  658.           if @revise_y < -UP
  659.             @revise_y = -UP
  660.           end
  661.         end
  662.         return result
  663.       end
  664.     end
  665.     @revise_x += distance
  666.     return result
  667.   end
  668.   #--------------------------------------------------------------------------
  669.   # ● 右に移動可能かどうかの判定2
  670.   #--------------------------------------------------------------------------
  671.   def right2(x, y, distance, d = 6)
  672.     if @revise_x + distance > SIDE
  673.       unless passable?(x, y, d)
  674.         if @revise_x < SIDE
  675.           @revise_x = SIDE
  676.         end
  677.         return false
  678.       end
  679.     end
  680.     return true
  681.   end
  682.   #--------------------------------------------------------------------------
  683.   # ● 上に移動
  684.   #--------------------------------------------------------------------------
  685.   def move_up_p
  686.     # 上を向く
  687.     turn_up
  688.     # 下に移動
  689.     distance = 2 ** @move_speed
  690.     up1(((@x * 128 + @revise_x) / 128.0).round,
  691.         ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  692.   end
  693.   def move_up_aaaagq
  694.     distance = 2 ** @move_speed
  695.     up1(((@x * 128 + @revise_x) / 128.0).round,
  696.         ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  697.   end
  698.   #--------------------------------------------------------------------------
  699.   # ● 上に移動可能かどうかの判定1
  700.   #--------------------------------------------------------------------------
  701.   def up1(x, y, distance, up = false)
  702.     result = up2(x, y, distance)
  703.     if result == false
  704.       @event_run = check_event_trigger_touch(x, y-1)
  705.       return result
  706.     end
  707.     if @revise_x < -SIDE
  708.       result = up2(x, y - 1, distance, 4)
  709.       result &= up2(x - 1, y, distance)
  710.       if result == false
  711.         if up
  712.           move_upper_right_p
  713.           if @revise_x > SIDE
  714.             @revise_x = SIDE
  715.           end
  716.         end
  717.         return result
  718.       end
  719.     elsif @revise_x > SIDE
  720.       result = up2(x, y - 1, distance, 6)
  721.       result &= up2(x + 1, y, distance)
  722.       if result == false
  723.         if up
  724.           move_upper_left_p
  725.           if @revise_x < -SIDE
  726.             @revise_x = -SIDE
  727.           end
  728.         end
  729.         return result
  730.       end
  731.     end
  732.     @revise_y -= distance
  733.     return result
  734.   end
  735.   #--------------------------------------------------------------------------
  736.   # ● 上に移動可能かどうかの判定2
  737.   #--------------------------------------------------------------------------
  738.   def up2(x, y, distance, d = 8)
  739.     if @revise_y - distance < -UP
  740.       unless passable?(x, y, d)
  741.         if @revise_y > -UP
  742.           @revise_y = -UP
  743.         end
  744.         return false
  745.       end
  746.     end
  747.     return true
  748.   end
  749.   #--------------------------------------------------------------------------
  750.   # ● 左下に移動
  751.   #--------------------------------------------------------------------------
  752.   def move_lower_left_p
  753.     # 向き固定でない場合
  754.     unless @direction_fix
  755.       # 右向きだった場合は左を、上向きだった場合は下を向く
  756.       @direction = 1#(@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  757.     end
  758.     # 左下に移動
  759.     distance = (2 ** @move_speed) / Math.sqrt(2)
  760.     down1(((@x * 128 + @revise_x) / 128.0).round,
  761.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  762.     left1(((@x * 128 + @revise_x) / 128.0).round,
  763.                             ((@y * 128 + @revise_y) / 128.0).round, distance)            
  764.       unless @event_run
  765.         
  766.         if last_move?(@real_x, @real_y, 2, distance) or last_move?(@real_x, @real_y, 4, distance)
  767.                   result = check_event_trigger_here([1,2], false)
  768.           if result == true
  769.             return
  770.           end
  771.         end
  772.         move_on
  773.         if @revise_y > DOWN and -UP > @revise_y - distance
  774.           @revise_y = DOWN
  775.         end
  776.         if  @revise_x + distance> SIDE and -SIDE > @revise_x
  777.           @revise_x = -SIDE
  778.         end
  779.     end
  780.   end
  781.   #--------------------------------------------------------------------------
  782.   # ● 右下に移動
  783.   #--------------------------------------------------------------------------
  784.   def move_lower_right_p
  785.     # 向き固定でない場合
  786.     unless @direction_fix
  787.       # 右向きだった場合は左を、上向きだった場合は下を向く
  788.       @direction = 3#(@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  789.     end
  790.     # 右下に移動
  791.     distance = (2 ** @move_speed) / Math.sqrt(2)
  792.     down1(((@x * 128 + @revise_x) / 128.0).round,
  793.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  794.     right1(((@x * 128 + @revise_x) / 128.0).round,
  795.                             ((@y * 128 + @revise_y) / 128.0).round, distance)            
  796.       unless @event_run
  797.         
  798.         if last_move?(@real_x, @real_y, 2, distance) or last_move?(@real_x, @real_y, 6, distance)
  799.                   result = check_event_trigger_here([1,2], false)
  800.           if result == true
  801.             return
  802.           end
  803.         end
  804.         move_on
  805.         if @revise_y > DOWN and -UP > @revise_y - distance
  806.           @revise_y = DOWN
  807.         end
  808.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  809.           @revise_x = SIDE
  810.         end
  811.     end   
  812.   end
  813.   #--------------------------------------------------------------------------
  814.   # ● 左上に移動
  815.   #--------------------------------------------------------------------------
  816.   def move_upper_left_p
  817.         # 向き固定でない場合
  818.     unless @direction_fix
  819.       # 右向きだった場合は左を、上向きだった場合は下を向く
  820.       @direction = 7#(@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  821.     end
  822.     # 左上に移動
  823.     distance = (2 ** @move_speed) / Math.sqrt(2)
  824.     up1(((@x * 128 + @revise_x) / 128.0).round,
  825.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  826.     left1(((@x * 128 + @revise_x) / 128.0).round,
  827.                             ((@y * 128 + @revise_y) / 128.0).round, distance)            
  828.       unless @event_run
  829.         if last_move?(@real_x, @real_y, 8, distance) or last_move?(@real_x, @real_y, 4, distance)
  830.                   result = check_event_trigger_here([1,2], false)
  831.           if result == true
  832.             return
  833.           end
  834.         end
  835.         move_on
  836.         if @revise_y + distance > DOWN and -UP > @revise_y
  837.           @revise_y = -UP
  838.         end
  839.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  840.           @revise_x = SIDE
  841.         end
  842.     end
  843.   end
  844.   #--------------------------------------------------------------------------
  845.   # ● 右上に移動
  846.   #--------------------------------------------------------------------------
  847.   def move_upper_right_p
  848.             # 向き固定でない場合
  849.     unless @direction_fix
  850.       # 右向きだった場合は左を、上向きだった場合は下を向く
  851.       @direction = 9#(@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  852.     end
  853.     # 右上に移動
  854.     distance = (2 ** @move_speed) / Math.sqrt(2)
  855.     up1(((@x * 128 + @revise_x) / 128.0).round,
  856.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  857.     right1(((@x * 128 + @revise_x) / 128.0).round,
  858.                             ((@y * 128 + @revise_y) / 128.0).round, distance)            
  859.       unless @event_run
  860.         if last_move?(@real_x, @real_y, 8, distance) or last_move?(@real_x, @real_y, 6, distance)
  861.                   result = check_event_trigger_here([1,2], false)
  862.           if result == true
  863.             return
  864.           end
  865.         end
  866.         move_on
  867.         if @revise_y + distance > DOWN and -UP > @revise_y
  868.           @revise_y = -UP
  869.         end
  870.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  871.           @revise_x = SIDE
  872.         end
  873.     end
  874.   end
  875.   #--------------------------------------------------------------------------
  876.   # ● 同位置のイベント起動判定
  877.   #--------------------------------------------------------------------------
  878.   def check_event_trigger_here(triggers, run = true)
  879.     result = false
  880.     # イベント実行中の場合
  881.     if $game_system.map_interpreter.running?
  882.       return result
  883.     end
  884.     # 全イベントのループ
  885.     for event in $game_map.events.values
  886.       # イベントの座標とトリガーが一致した場合
  887.       if event.x == ((@x * 128 + @revise_x) / 128.0).round and
  888.           event.y == ((@y * 128 + @revise_y) / 128.0).round and
  889.           triggers.include?(event.trigger)
  890.         # ジャンプ中以外で、起動判定が同位置のイベントなら
  891.         if not event.jumping? and event.over_trigger?
  892.           if event.list.size > 1
  893.             if run == true
  894.               event.start
  895.             end
  896.             result = true
  897.           end
  898.         end
  899.       end
  900.     end
  901.     return result
  902.   end
  903.   #--------------------------------------------------------------------------
  904.   # ● 座標修正
  905.   #--------------------------------------------------------------------------
  906.   def move_on
  907.     if @y < (@y + @revise_y / 128.0).round
  908.       @y += 1
  909.       @revise_y -= 128
  910.     end
  911.     if @x > (@x + @revise_x / 128.0).round
  912.       @x -= 1
  913.       @revise_x += 128
  914.     end
  915.     if @x < (@x + @revise_x / 128.0).round
  916.       @x += 1
  917.       @revise_x -= 128
  918.     end
  919.     if @y > (@y + @revise_y / 128.0).round
  920.       @y -= 1
  921.       @revise_y += 128
  922.     end
  923.   end
  924.   #--------------------------------------------------------------------------
  925.   # ● アニメーションアップデート
  926.   #--------------------------------------------------------------------------
  927.   def anime_update
  928.     # 移動時アニメが ON の場合
  929.     if @walk_anime
  930.       # アニメカウントを 1.5 増やす
  931.       @anime_count += 1.5
  932.     # 移動時アニメが OFF で、停止時アニメが ON の場合
  933.     elsif @step_anime
  934.       # アニメカウントを 1 増やす
  935.       @anime_count += 1
  936.     end
  937.     # アニメカウントが最大値を超えた場合
  938.     # ※最大値は、基本値 18 から移動速度 * 1 を引いた値
  939.     if @anime_count > 18 - @move_speed * 2
  940.       # 停止時アニメが OFF かつ 停止中の場合
  941.       if not @step_anime and @stop_count > 0
  942.         # パターンをオリジナルに戻す
  943.         @pattern = @original_pattern
  944.       # 停止時アニメが ON または 移動中の場合
  945.       else
  946.         # パターンを更新
  947.         @pattern = (@pattern + 1) % 4
  948.       end
  949.       # アニメカウントをクリア
  950.       @anime_count = 0
  951.     end
  952.   end
  953.   #--------------------------------------------------------------------------
  954.   # ● 指定位置に移動
  955.   #--------------------------------------------------------------------------
  956.   # オリジナルのイベントを改名
  957.   alias :moveto_original :moveto
  958.   def moveto(x, y)
  959.     # 補正座標を初期化
  960.     @revise_x = 0
  961.     @revise_y = 0
  962.     # オリジナルのイベントを呼び出し
  963.     moveto_original(x, y)
  964.   end
  965.   #--------------------------------------------------------------------------
  966.   # ● 移動したかどうかの判定
  967.   #--------------------------------------------------------------------------
  968.   def last_move?(x, y, direction, distance)
  969.     if direction == 2 or direction == 6
  970.       distance *= -1
  971.     end
  972.     if (direction == 2 or direction == 8) and
  973.         (y / 128.0).round != ((y - distance) / 128.0).round
  974.       return true
  975.     end
  976.     if (direction == 4 or direction == 6) and
  977.         (x / 128.0).round != ((x - distance) / 128.0).round
  978.       return true
  979.     end
  980.     return false
  981.   end
  982.   end


  983. #==============================================================================
  984. # ■ Game_Character (分割定義 1)
  985. #------------------------------------------------------------------------------
  986. #  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event
  987. # クラスのスーパークラスとして使用されます。
  988. #==============================================================================

  989. class Game_Character
  990.   #--------------------------------------------------------------------------
  991.   # ● フレーム更新 (移動)
  992.   #--------------------------------------------------------------------------
  993.   def update_move
  994.     # 移動速度からマップ座標系での移動距離に変換
  995.     distance = 2 ** @move_speed
  996.     if @x * 128 != @real_x and @y * 128 != @real_y and Game_Player::SLANT
  997.       distance /= Math.sqrt(2)
  998.     end
  999.     # 論理座標が実座標より下の場合
  1000.     if @y * 128 > @real_y
  1001.       # 下に移動
  1002.       @real_y = [@real_y + distance, @y * 128].min
  1003.     end
  1004.     # 論理座標が実座標より左の場合
  1005.     if @x * 128 < @real_x
  1006.       # 左に移動
  1007.       @real_x = [@real_x - distance, @x * 128].max
  1008.     end
  1009.     # 論理座標が実座標より右の場合
  1010.     if @x * 128 > @real_x
  1011.       # 右に移動
  1012.       @real_x = [@real_x + distance, @x * 128].min
  1013.     end
  1014.     # 論理座標が実座標より上の場合
  1015.     if @y * 128 < @real_y
  1016.       # 上に移動
  1017.       @real_y = [@real_y - distance, @y * 128].max
  1018.     end
  1019.     # 移動時アニメが ON の場合
  1020.     if @walk_anime
  1021.       # アニメカウントを 1.5 増やす
  1022.       @anime_count += 1.5
  1023.     # 移動時アニメが OFF で、停止時アニメが ON の場合
  1024.     elsif @step_anime
  1025.       # アニメカウントを 1 増やす
  1026.       @anime_count += 1
  1027.     end
  1028.   end
  1029.     #--------------------------------------------------------------------------
  1030.     # ● 正面事件的启动判定
  1031.     #--------------------------------------------------------------------------
  1032.     def check_event_trigger_there(triggers)
  1033.       result = false
  1034.       # 事件执行中的情况下
  1035.       if $game_system.map_interpreter.running?
  1036.         return result
  1037.       end
  1038.       # 计算正面坐标
  1039.       new_x = @x
  1040.       new_y = @y
  1041.       case @direction
  1042.       when 1
  1043.         new_x -= 1
  1044.         new_y += 1
  1045.       when 2
  1046.         new_y += 1
  1047.       when 3
  1048.         new_x += 1
  1049.         new_y += 1
  1050.       when 4
  1051.         new_x -= 1
  1052.       when 6
  1053.         new_x += 1
  1054.       when 7
  1055.         new_x -= 1
  1056.         new_y -= 1
  1057.       when 8
  1058.         new_y -= 1
  1059.       when 9
  1060.         new_x += 1
  1061.         new_y -= 1
  1062.       end
  1063.       # 全部事件的循环
  1064.       for event in $game_map.events.values
  1065.         # 事件坐标与目标一致的情况下
  1066.         if event.x == new_x and event.y == new_y and
  1067.            triggers.include?(event.trigger)
  1068.           # 跳跃中以外的情况下、启动判定是正面的事件
  1069.           if not event.jumping? and not event.over_trigger?
  1070.             event.start
  1071.             result = true
  1072.           end
  1073.         end
  1074.       end
  1075.       # 找不到符合条件的事件的情况下
  1076.       if result == false
  1077.         # 正面的元件是计数器的情况下
  1078.         if $game_map.counter?(new_x, new_y)
  1079.           # 计算 1 元件里侧的坐标
  1080.           new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  1081.           new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  1082.           # 全事件的循环
  1083.           for event in $game_map.events.values
  1084.             # 事件坐标与目标一致的情况下
  1085.             if event.x == new_x and event.y == new_y and
  1086.                triggers.include?(event.trigger)
  1087.               # 跳跃中以外的情况下、启动判定是正面的事件
  1088.               if not event.jumping? and not event.over_trigger?
  1089.                 event.start
  1090.                 result = true
  1091.               end
  1092.             end
  1093.           end
  1094.         end
  1095.       end
  1096.       return result
  1097.     end
  1098. end

  1099. #==============================================================================
  1100. # ■ Game_Event
  1101. #------------------------------------------------------------------------------
  1102. #  イベントを扱うクラスです。条件判定によるイベントページ切り替えや、並列処理
  1103. # イベント実行などの機能を持っており、Game_Map クラスの内部で使用されます。
  1104. #==============================================================================

  1105. class Game_Event < Game_Character
  1106.   #--------------------------------------------------------------------------
  1107.   # ● イベント起動
  1108.   #--------------------------------------------------------------------------
  1109.   def start
  1110.     # 実行内容が空でない場合
  1111.     if @list.size > 1
  1112.       # $game_player.event が0でない場合
  1113.       if $game_player.event != 0
  1114.         # 移動速度を $game_player.event にする
  1115.         $game_player.move_speed = $game_player.event
  1116.       end
  1117.       @starting = true
  1118.     end
  1119.   end
  1120. end

  1121. #==============================================================================
  1122. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  1123. #==============================================================================
复制代码
  1. # 使用方法:将本脚本插入到main之前。如果你使用了雅土版的八方向走脚本,请确保这个脚本的顺序位置,在雅土八方向走脚本的后面。

  2. # 预先处理:请输入每一步的帧数和总共可用的方向数

  3. $c3_每一步的帧数 = 8
  4. $c3_总共可用的方向数 = 8 #——建议不要修改这个。如果要伪8方向的,就用伪的好了。

  5. # 图片处理与功能说明:

  6. # 1、每一步的帧数:
  7. #    众所周知,RMXP的移动行走图是一个方向共有4帧,很多人都觉得这个帧数有点少。
  8. # 使用这个脚本之后,只要将 $c3_每一步的帧数 这个变量设置一个需要的帧数即可修改
  9. # 单方向移动帧数为相应输入值。修改后,需要用photoshop将所有用到的素材的横排
  10. # 调整为相应帧数,比如输入了8则要将每一行设置8个图像(即每一个行走图有8列)。

  11. # 2、可用方向调整(可用数量:4、8):
  12. #    当为4方向时没有任何变化,还是一个图4行,上左右下4个方向。
  13. #    如果想使用8方向走,将需要八方向行走的行走图在延伸扩大的画布中按照左下、右下、左上、右上继续排布图像。
  14. # 即,行走图图片从上到下的面向排列顺序为:下,左,右,上,左下,右下,左上,右上。
  15. #    至于不需要8方向走的普通的NPC(character),使用photoshop将画布向下扩大一倍即可使用。
  16. #    需要注意的是,如果需要斜方向飞鸟,请不要忘记自制素材。

  17. # 特别提示:   
  18. #     使用本脚本前请先考虑清楚是否要做这种效果。因为使用本脚本后需要用photoshop处理character行走图素材
  19. # 虽然这种处理用photoshop定义动作只需要5分钟即可全部完成,但在制作阶段会感觉不是很爽(具体的用了才知道)
  20. # 作者的建议是,如果你没有足够的制作经验,使用这个脚本得不偿失。请确保自己的能力属于“高手”级别!

  21. # 附赠功能:
  22. #     可以让NPC角色随机8方向走,方法是:NPC角色移动路线为“自定义”,然后自定义里面使用脚本,输入c8即可
  23. #     可以让NPC角色随机4斜角方向走,方法是:NPC角色移动路线为“自定义”,然后自定义里面使用脚本,输入c4即可
  24. #     可以使用真·斜4方向行走,参考脚本53行开始

  25. # 作者:carol3
  26. ###########################################################################################################################
  27. ###########################################################################################################################
  28. class Sprite_Character < RPG::Sprite
  29.   def update
  30.     super
  31.     # 元件 ID、文件名、色相与现在的情况存在差异的情况下
  32.     if @tile_id != @character.tile_id or
  33.        @character_name != @character.character_name or
  34.        @character_hue != @character.character_hue
  35.       # 记忆元件 ID 与文件名、色相
  36.       @tile_id = @character.tile_id
  37.       @character_name = @character.character_name
  38.       @character_hue = @character.character_hue
  39.       # 元件 ID 为有效值的情况下
  40.       if @tile_id >= 384
  41.         self.bitmap = RPG::Cache.tile($game_map.tileset_name,
  42.           @tile_id, @character.character_hue)
  43.         self.src_rect.set(0, 0, 32, 32)
  44.         self.ox = 16
  45.         self.oy = 32
  46.       # 元件 ID 为无效值的情况下
  47.       else
  48.         self.bitmap = RPG::Cache.character(@character.character_name,
  49.           @character.character_hue)
  50.         @cw = bitmap.width / $c3_每一步的帧数
  51.         if $c3_总共可用的方向数==4
  52.           @ch = bitmap.height / 4
  53.         else
  54.           @ch = bitmap.height / 8
  55.         end
  56.         self.ox = @cw / 2
  57.         self.oy = @ch
  58.       end
  59.     end
  60.     # 设置可视状态
  61.     self.visible = (not @character.transparent)
  62.     # 图形是角色的情况下
  63.     if @tile_id == 0
  64.       # 设置传送目标的矩形
  65.       sx = @character.pattern * @cw
  66.       if $c3_总共可用的方向数==8
  67.         case @character.direction
  68.         when 2
  69.           sy = 0 * @ch
  70.         when 4
  71.           sy = 1 * @ch
  72.         when 6
  73.           sy = 2 * @ch
  74.         when 8
  75.           sy = 3 * @ch
  76.         when 1
  77.           sy = 4 * @ch
  78.         when 3
  79.           sy = 5 * @ch
  80.         when 7
  81.           sy = 6 * @ch
  82.         when 9
  83.           sy = 7 * @ch
  84.         end
  85.       else
  86.         sy = (@character.direction - 2) / 2 * @ch
  87.       end
  88.       self.src_rect.set(sx, sy, @cw, @ch)
  89.     end
  90.     # 设置脚本的坐标
  91.     self.x = @character.screen_x
  92.     self.y = @character.screen_y
  93.     self.z = @character.screen_z(@ch)
  94.     # 设置不透明度、合成方式、茂密
  95.     self.opacity = @character.opacity
  96.     self.blend_type = @character.blend_type
  97.     self.bush_depth = @character.bush_depth
  98.     # 动画
  99.     if @character.animation_id != 0
  100.       animation = $data_animations[@character.animation_id]
  101.       animation(animation, true)
  102.       @character.animation_id = 0
  103.     end
  104.   end
  105. end

  106. class Game_Character
  107.   def c8
  108.     # 随机 0~5 的分支
  109.     case rand(10)
  110.     when 0..3  # 随机
  111.       move_random
  112.     when 4  # 前进一步
  113.       move_forward
  114.     when 5  # 暂时停止
  115.       @stop_count = 0
  116.     when 6..9  #另外4方向随机
  117.       c4
  118.     end
  119.   end
  120.   def c4
  121.     case rand(5)
  122.     when 0
  123.       move_upper_left
  124.     when 1
  125.       move_upper_right
  126.     when 2
  127.       move_lower_left
  128.     when 3
  129.       move_lower_right
  130.     when 4
  131.       @stop_count = 0
  132.     end
  133.   end
  134.       
  135.   def update
  136.     # 跳跃中、移动中、停止中的分支
  137.     if jumping?
  138.       update_jump
  139.     elsif moving?
  140.       update_move
  141.     else
  142.       update_stop
  143.     end
  144.     # 动画计数超过最大值的情况下
  145.     # ※最大值等于基本值减去移动速度 * 1 的值
  146.     if @anime_count > 16*4/$c3_每一步的帧数 - @move_speed * 2
  147.       # 停止动画为 OFF 并且在停止中的情况下
  148.       if not @step_anime and @stop_count > 0
  149.         # 还原为原来的图形
  150.         @pattern = @original_pattern
  151.       # 停止动画为 ON 并且在移动中的情况下
  152.       else
  153.         # 更新图形
  154.         @pattern = (@pattern + 1) % $c3_每一步的帧数
  155.       end
  156.       # 清除动画计数
  157.       @anime_count = 0
  158.     end
  159.     # 等待中的情况下
  160.     if @wait_count > 0
  161.       # 减少等待计数
  162.       @wait_count -= 1
  163.       return
  164.     end
  165.     # 强制移动路线的场合
  166.     if @move_route_forcing
  167.       # 自定义移动
  168.       move_type_custom
  169.       return
  170.     end
  171.     # 事件执行待机中并且为锁定状态的情况下
  172.     if @starting or lock?
  173.       # 不做规则移动
  174.       return
  175.     end
  176.     # 如果停止计数超过了一定的值(由移动频度算出)
  177.     if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
  178.       # 移动类型分支
  179.       case @move_type
  180.       when 1  # 随机
  181.         move_type_random
  182.       when 2  # 接近
  183.         move_type_toward_player
  184.       when 3  # 自定义
  185.         move_type_custom
  186.       end
  187.     end
  188.   end
  189. end
  190. class Window_Base < Window
  191.   def draw_actor_graphic(actor, x, y)
  192.     bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  193.     cw = bitmap.width / $c3_每一步的帧数
  194.     ch = bitmap.height / $c3_总共可用的方向数
  195.     src_rect = Rect.new(0, 0, cw, ch)
  196.     self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  197.   end
  198. end
  199. class Game_Character
  200.   #--------------------------------------------------------------------------
  201.   # ● 面向主角的方向
  202.   #--------------------------------------------------------------------------
  203.   def turn_toward_player
  204.     # 求得与主角的坐标差
  205.     sx = @x - $game_player.x
  206.     sy = @y - $game_player.y
  207.     # 坐标相等的场合下
  208.     if sx == 0 and sy == 0
  209.       return
  210.     end
  211.     # 横侧距离长的情况下
  212.     if sx.abs > sy.abs
  213.       # 将左右方向变更为朝向主角的方向
  214.       sx > 0 ? turn_left : turn_right
  215.     # 竖侧距离长的情况下
  216.     else
  217.       # 将上下方向变更为朝向主角的方向
  218.       sy > 0 ? turn_up : turn_down
  219.     end
  220.     if sx == -1 and sy == -1
  221.       @direction = 3
  222.       @stop_count = 0
  223.     elsif sx == -1 and sy == 1
  224.       @direction = 9
  225.       @stop_count = 0
  226.     elsif sx == 1 and sy == -1
  227.       @direction = 1
  228.       @stop_count = 0
  229.     elsif sx == 1 and sy == 1
  230.       @direction = 7
  231.       @stop_count = 0
  232.     end
  233.   end
  234. end

  235. #==============================================================================
  236. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  237. #==============================================================================
复制代码

评分

参与人数 1星屑 +10 收起 理由
九维拟世 + 10 认可答案

查看全部评分

回复

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-2 11:09

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表