查看: 1197|回复: 1

[已经过期] 关于重力脚本,求大神帮忙

[复制链接]
梦石
0
星屑
265
在线时间
286 小时
注册时间
2009-11-7
回帖
39

开拓者

发表于 2015-2-8 18:02:27 | 显示全部楼层 |阅读模式

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

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

×
新人想做一个马里奥 ,如何实现跳跃时暂时改变行走图为“跳跃行走图“?
  1. $ud_ok = false #上下失效
  2. $airjump = 0  #空中连跳
  3. #==============================================================================
  4. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  5. #==============================================================================

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

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

  1060. #==============================================================================
  1061. # ■ Game_Character (分割定義 1)
  1062. #------------------------------------------------------------------------------
  1063. #  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event
  1064. # クラスのスーパークラスとして使用されます。
  1065. #==============================================================================

  1066. class Game_Character
  1067.   #--------------------------------------------------------------------------
  1068.   # ● フレーム更新 (移動)
  1069.   #--------------------------------------------------------------------------
  1070.   def update_move
  1071.     # 移動速度からマップ座標系での移動距離に変換
  1072.     distance = 2 ** @move_speed
  1073.     if @x * 128 != @real_x and @y * 128 != @real_y and Game_Player::SLANT
  1074.       distance /= Math.sqrt(2)
  1075.     end
  1076.     # 論理座標が実座標より下の場合
  1077.     if @y * 128 > @real_y
  1078.       # 下に移動
  1079.       @real_y = [@real_y + distance, @y * 128].min
  1080.     end
  1081.     # 論理座標が実座標より左の場合
  1082.     if @x * 128 < @real_x
  1083.       # 左に移動
  1084.       @real_x = [@real_x - distance, @x * 128].max
  1085.     end
  1086.     # 論理座標が実座標より右の場合
  1087.     if @x * 128 > @real_x
  1088.       # 右に移動
  1089.       @real_x = [@real_x + distance, @x * 128].min
  1090.     end
  1091.     # 論理座標が実座標より上の場合
  1092.     if @y * 128 < @real_y
  1093.       # 上に移動
  1094.       @real_y = [@real_y - distance, @y * 128].max
  1095.     end
  1096.     # 移動時アニメが ON の場合
  1097.     if @walk_anime
  1098.       # アニメカウントを 1.5 増やす
  1099.       @anime_count += 1.5
  1100.     # 移動時アニメが OFF で、停止時アニメが ON の場合
  1101.     elsif @step_anime
  1102.       # アニメカウントを 1 増やす
  1103.       @anime_count += 1
  1104.     end
  1105.   end
  1106. end

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

  1113. class Game_Event < Game_Character
  1114.   #--------------------------------------------------------------------------
  1115.   # ● イベント起動
  1116.   #--------------------------------------------------------------------------
  1117.   def start
  1118.     # 実行内容が空でない場合
  1119.     if @list.size > 1
  1120.       # $game_player.event が0でない場合
  1121.       if $game_player.event != 0
  1122.         # 移動速度を $game_player.event にする
  1123.         $game_player.move_speed = $game_player.event
  1124.       end
  1125.       @starting = true
  1126.     end
  1127.   end
  1128. end

  1129. #==============================================================================
  1130. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  1131. #==============================================================================
复制代码
QQ截图20150208175742.jpg
梦石
0
星屑
175
在线时间
332 小时
注册时间
2013-7-6
回帖
316
发表于 2015-2-11 17:51:36 | 显示全部楼层
  1. $ud_ok = false #上下失效
  2. $airjump = 0  #空中连跳
  3. #==============================================================================
  4. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  5. #==============================================================================

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

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

  1082. #==============================================================================
  1083. # ■ Game_Character (分割定義 1)
  1084. #------------------------------------------------------------------------------
  1085. #  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event
  1086. # クラスのスーパークラスとして使用されます。
  1087. #==============================================================================

  1088. class Game_Character
  1089.   #--------------------------------------------------------------------------
  1090.   # ● フレーム更新 (移動)
  1091.   #--------------------------------------------------------------------------
  1092.   def update_move
  1093.     # 移動速度からマップ座標系での移動距離に変換
  1094.     distance = 2 ** @move_speed
  1095.     if @x * 128 != @real_x and @y * 128 != @real_y and Game_Player::SLANT
  1096.       distance /= Math.sqrt(2)
  1097.     end
  1098.     # 論理座標が実座標より下の場合
  1099.     if @y * 128 > @real_y
  1100.       # 下に移動
  1101.       @real_y = [@real_y + distance, @y * 128].min
  1102.     end
  1103.     # 論理座標が実座標より左の場合
  1104.     if @x * 128 < @real_x
  1105.       # 左に移動
  1106.       @real_x = [@real_x - distance, @x * 128].max
  1107.     end
  1108.     # 論理座標が実座標より右の場合
  1109.     if @x * 128 > @real_x
  1110.       # 右に移動
  1111.       @real_x = [@real_x + distance, @x * 128].min
  1112.     end
  1113.     # 論理座標が実座標より上の場合
  1114.     if @y * 128 < @real_y
  1115.       # 上に移動
  1116.       @real_y = [@real_y - distance, @y * 128].max
  1117.     end
  1118.     # 移動時アニメが ON の場合
  1119.     if @walk_anime
  1120.       # アニメカウントを 1.5 増やす
  1121.       @anime_count += 1.5
  1122.     # 移動時アニメが OFF で、停止時アニメが ON の場合
  1123.     elsif @step_anime
  1124.       # アニメカウントを 1 増やす
  1125.       @anime_count += 1
  1126.     end
  1127.   end
  1128. end

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

  1135. class Game_Event < Game_Character
  1136.   #--------------------------------------------------------------------------
  1137.   # ● イベント起動
  1138.   #--------------------------------------------------------------------------
  1139.   def start
  1140.     # 実行内容が空でない場合
  1141.     if @list.size > 1
  1142.       # $game_player.event が0でない場合
  1143.       if $game_player.event != 0
  1144.         # 移動速度を $game_player.event にする
  1145.         $game_player.move_speed = $game_player.event
  1146.       end
  1147.       @starting = true
  1148.     end
  1149.   end
  1150. end

  1151. #==============================================================================
  1152. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  1153. #==============================================================================
复制代码
把跳跃图改为jump.png放在character文件夹里,角色设置默认行走图就行了。
偶是熬夜学编程的傻子
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部