Project1

标题: 事件的跳跃问题[若解出加500] [打印本页]

作者: ★_茄孓    时间: 2008-5-18 20:34
标题: 事件的跳跃问题[若解出加500]
  1. =begin
  2. ====================================================================
  3. 重力状态:(在每个地图都要设置一下,"并行处理")
  4. $ud_ok = false     
  5. $airjump = 1
  6. ====================================================================
  7. 解除重力:(在我的这个游戏里用于爬楼梯)
  8. $ud_ok = true
  9. =end
  10. #==============================================================================
  11. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  12. #==============================================================================
  13. $ud_ok = true     
  14. $airjump = 1
  15. # ————————————————————————————————————
  16. # 全方向ドット移動 Ver ε
  17. # 配布元・サポートURL
  18. # http://members.jcom.home.ne.jp/cogwheel/

  19. #==============================================================================
  20. # ■ Game_Player
  21. #------------------------------------------------------------------------------
  22. #  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの
  23. # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
  24. #==============================================================================
  25. class Game_Player < Game_Character
  26.   #--------------------------------------------------------------------------
  27.   # ● 定数
  28.   #--------------------------------------------------------------------------
  29.   UP    = 48                  # 上方向の余裕(0 < UP < 63)
  30.   DOWN  = 16                  # 下方向の余裕(0 < DOWN <63)
  31.   SIDE  = 32                  # 左右方向の余裕(0 < SIDE <63)
  32.   SLANT = false               # 移動ルートの斜め移動時、速度修正
  33.   JUMPMAX = 100     
  34.   JUMPADD = 10              
  35.   #--------------------------------------------------------------------------
  36.   # ● 公開インスタンス変数
  37.   #--------------------------------------------------------------------------
  38.   attr_reader   :event                    # イベント時移動速度
  39.   attr_accessor :move_speed               # 移動速度
  40.   #--------------------------------------------------------------------------
  41.   # ● フレーム更新
  42.   #--------------------------------------------------------------------------
  43.   alias :update_original :update
  44.   def update
  45.     # @walk:歩行速度 @dash:ダッシュ時移動速度
  46.     # @event:イベント時移動速度(0の時は、イベント時に速度変更をしない)
  47.     @walk  = 4
  48.     @dash  = 5
  49.     @event = 4
  50.     @dot_m = true
  51.     #ダッシュ機能。エンターキーが押されている間、移動速度を変更する。
  52.     unless moving? or $game_system.map_interpreter.running? or
  53.             @move_route_forcing or $game_temp.message_window_showing
  54.       if @walk != @dash
  55.         if Input.press?(Input::C) and $game_variables[3500] == 1553
  56.           if @move_speed != @dash
  57.             @move_speed = @dash
  58.           end
  59.         else
  60.           if @move_speed != @walk
  61.             @move_speed = @walk
  62.           end
  63.         end
  64.       end
  65.     end
  66.     if @revise_x == nil and @revise_y == nil
  67.       @revise_x = 0
  68.       @revise_y = 0
  69.     end
  70.     unless @dot_m
  71.       update_original
  72.       return
  73.     end
  74.     if @move_route_forcing
  75.       # ローカル変数に移動中かどうかを記憶
  76.       last_moving = moving?
  77.       # ローカル変数に座標を記憶
  78.       last_real_x = @real_x
  79.       last_real_y = @real_y
  80.       # 座標がずれている場合
  81.       if (@revise_x != 0 or @revise_y != 0) and not jumping? and @move == true
  82.         if @revise_x != @real_x - @x * 128 or @revise_y != @real_y - @y * 128
  83.           @revise_x = @real_x - @x * 128
  84.           @revise_y = @real_y - @y * 128
  85.         end
  86.         # 移動距離distance1と目標距離distance2を設定
  87.         distance1 = 2 ** @move_speed
  88.         distance2 = Math.sqrt(@revise_x ** 2 + @revise_y ** 2)
  89.         # 移動距離が目標距離を越えた場合
  90.         if distance1 > distance2
  91.           # 強制的に補正座標を零にする
  92.           @real_x = @real_x - @revise_x
  93.           @real_y = @real_y - @revise_y
  94.           @revise_x = 0
  95.           @revise_y = 0
  96.           anime_update
  97.         # 移動距離が目標距離に達しない場合
  98.         else
  99.           # 移動距離分目標距離に近づく
  100.           @real_x -= (distance1 * @revise_x / distance2).round
  101.           @real_y -= (distance1 * @revise_y / distance2).round
  102.           @revise_x = @real_x - @x * 128
  103.           @revise_y = @real_y - @y * 128
  104.           anime_update
  105.         end
  106.       else
  107.         super
  108.       end
  109.     else
  110.       @move = false
  111.       # 移動中、イベント実行中、移動ルート強制中、
  112.       # メッセージウィンドウ表示中のいずれでもない場合
  113.       unless moving? or $game_system.map_interpreter.running? or
  114.              @move_route_forcing or $game_temp.message_window_showing
  115.         @event_run = false
  116.         # 方向ボタンが押されていれば、その方向へプレイヤーを移動
  117. #---------------------------上下失效-----------------------------------------
  118.       case Input.dir8
  119.         when 1
  120.           $ud_ok ? move_lower_left_p : move_left_p
  121.         when 2
  122. #          $ud_ok ? move_down_p : move_down_aaaagq
  123.           move_down_p if $ud_ok
  124.         when 3
  125.          $ud_ok ? move_lower_right_p : move_right_p
  126.         when 4
  127.           move_left_p
  128.         when 6
  129.           move_right_p
  130.         when 7
  131.          $ud_ok ? move_upper_left_p : move_left_p
  132.         when 8
  133. #         $ud_ok ? move_up_p : move_up_aaaagq
  134.          move_up_p if $ud_ok
  135.         when 9
  136.          $ud_ok ? move_upper_right_p : move_right_p
  137.         end
  138.       end
  139.       # ローカル変数に座標を記憶
  140.       last_real_x = @real_x
  141.       last_real_y = @real_y
  142.       # 移動処理
  143.       @real_x = @x * 128 + @revise_x
  144.       @real_y = @y * 128 + @revise_y
  145.       # ローカル変数に移動中かどうかを記憶
  146.       last_moving = moving?
  147.       # 座標更新
  148.       move_on
  149.       # 現在の座標と以前の座標が異なる場合
  150.       if (last_real_x != @real_x or last_real_y != @real_y)
  151.         @move_distance = 0 if @move_distance == nil
  152.         @move_distance += Math.sqrt((last_real_x - @real_x) ** 2 +
  153.                                       (last_real_y - @real_y) ** 2)
  154.         if @move_distance >= 128
  155.           @move_distance %= 128
  156.           increase_steps
  157.         end
  158.         # アニメーションを更新
  159.         anime_update
  160.       else
  161.         @pattern = 0
  162.       end
  163.     end
  164.     # キャラクターが下に移動し、かつ画面上の位置が中央より下の場合
  165.     if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  166.       # マップを下にスクロール
  167.       $game_map.scroll_down(@real_y - last_real_y)
  168.     end
  169.     # キャラクターが左に移動し、かつ画面上の位置が中央より左の場合
  170.     if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  171.       # マップを左にスクロール
  172.       $game_map.scroll_left(last_real_x - @real_x)
  173.     end
  174.     # キャラクターが右に移動し、かつ画面上の位置が中央より右の場合
  175.     if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  176.       # マップを右にスクロール
  177.       $game_map.scroll_right(@real_x - last_real_x)
  178.     end
  179.     # キャラクターが上に移動し、かつ画面上の位置が中央より上の場合
  180.     if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  181.       # マップを上にスクロール
  182.       $game_map.scroll_up(last_real_y - @real_y)
  183.     end
  184.     # 前回プレイヤーが移動中だった場合
  185.     if last_moving
  186.       # 同位置のイベントとの接触によるイベント起動判定
  187.       result = check_event_trigger_here([1,2])
  188.       if result == true
  189.         if (last_real_x / 128.0).round != @x and
  190.             (last_real_y / 128.0).round != @y
  191.           if @direction == 2 or @direction == 8
  192.             if (last_real_x / 128.0).round > @x
  193.               turn_left
  194.             else
  195.               turn_right
  196.             end
  197.           else
  198.             if (last_real_y / 128.0).round > @y
  199.               turn_up
  200.             else
  201.               turn_down
  202.             end
  203.           end
  204.         elsif (last_real_x / 128.0).round > @x
  205.           turn_left
  206.         elsif (last_real_x / 128.0).round < @x
  207.           turn_right
  208.         elsif (last_real_y / 128.0).round > @y
  209.           turn_up
  210.         elsif (last_real_y / 128.0).round < @y
  211.           turn_down
  212.         end
  213.       end
  214.       # 起動したイベントがない場合
  215.       if result == false
  216.         # デバッグモードが ON かつ CTRL キーが押されている場合を除き
  217.         unless $DEBUG and Input.press?(Input::CTRL)
  218.           # エンカウント カウントダウン
  219.           if @encounter_count > 0
  220.             @encounter_count -= 1
  221.           end
  222.         end
  223.       end
  224.     end
  225. #-----------------------按跳跃-----------------------------------------------
  226. # A ボタンが押された場合
  227.     if Input.press?(Input::UP) and not $ud_ok
  228.       @twojump = 1 if @twojump == 0 and down1(((@x * 128 + @revise_x) / 128.0).round,
  229.           ((@y * 128 + @revise_y) / 128.0).round, 5, true)
  230.       if (not @apassed) and @twojump <= $airjump
  231.         @apassed = true
  232.         @jumpnow = JUMPMAX
  233.         @twojump += 1
  234.       else
  235.         @jumpnow += 3        
  236.       end
  237.     else
  238.       @apassed = false
  239.     end
  240. #----------------------自由落体--------------------------------
  241.     if not $ud_ok
  242.       @jumpnow -= 10
  243.       if @jumpnow < 0
  244.         @jumpnow = [@jumpnow, -JUMPMAX].max
  245.         if not down1(((@x * 128 + @revise_x) / 128.0).round,
  246.           ((@y * 128 + @revise_y) / 128.0).round, -@jumpnow, true)
  247.           @jumpnow = 0
  248.           @twojump = 0
  249.         end
  250.       elsif @jumpnow > 0
  251.         @jumpnow = [@jumpnow, JUMPMAX].min
  252.         if not up1(((@x * 128 + @revise_x) / 128.0).round,
  253.           ((@y * 128 + @revise_y) / 128.0).round, @jumpnow, true)
  254.           @jumpnow = 0
  255.         end
  256.       end
  257.     end
  258.     if Input.trigger?(Input::C)
  259.       # 同位置および正面のイベント起動判定
  260.       check_event_trigger_here([0])
  261.       check_event_trigger_there([0,1,2])
  262.     end
  263.   end
  264.   #--------------------------------------------------------------------------
  265.   # ● オブジェクト初期化
  266.   #--------------------------------------------------------------------------
  267.   def initialize
  268.     @jumpnow = 0
  269.     @twojump = 0
  270.     @apassed = false
  271.     @revise_x = 0
  272.     @revise_y = 0
  273.     @move == false
  274.     super
  275.   end
  276.   #--------------------------------------------------------------------------
  277.   # ● 移動判定
  278.   #--------------------------------------------------------------------------
  279.   def moving?
  280.     unless @dot_m
  281.       result = super
  282.       return result
  283.     end
  284.     # 強制移動の場合オリジナルの判定をさせる
  285.     if @move_route_forcing
  286.       if @move == false
  287.         return false
  288.       end
  289.       super
  290.     # 通常時は現座標が実座標と異なる場合のみ移動中と判定
  291.     else
  292.       return (@x != (@real_x / 128.0).round or @y != (@real_y / 128.0).round)
  293.     end
  294.   end
  295.   #--------------------------------------------------------------------------
  296.   # ● 移動判定
  297.   #--------------------------------------------------------------------------
  298.   def moving_a?
  299.     if @move == false
  300.       if (@move_route.list[@move_route_index].code <= 14 or
  301.           @move_route.list[@move_route_index].code == 25)
  302.         @move = true
  303.       end
  304.       return false
  305.     end
  306.     moving?
  307.   end
  308.   #--------------------------------------------------------------------------
  309.   # ● フレーム更新 (ジャンプ)
  310.   #--------------------------------------------------------------------------
  311.   def update_jump
  312.     # ジャンプカウントを 1 減らす
  313.     @jump_count -= 1
  314.     # 新しい座標を計算
  315.     @real_x = (@real_x * @jump_count + @x * 128) / (@jump_count + 1)
  316.     @real_y = (@real_y * @jump_count + @y * 128) / (@jump_count + 1)
  317.     if @jump_count == 0
  318.       @revise_x = 0
  319.       @revise_y = 0
  320.     end
  321.   end
  322.   #--------------------------------------------------------------------------
  323.   # ● 移動タイプ : カスタム
  324.   #--------------------------------------------------------------------------
  325.   def move_type_custom
  326.     unless @dot_m
  327.       super
  328.       return
  329.     end
  330.     # 停止中でなければ中断
  331.     if jumping? or moving_a?
  332.       return
  333.     end
  334.     # 移動コマンドのリストの最後に到達するまでループ
  335.     while @move_route_index < @move_route.list.size
  336.       # 移動コマンドを取得
  337.       command = @move_route.list[@move_route_index]
  338.       # コマンドコード 0 番 (リストの最後) の場合
  339.       if command.code == 0
  340.         # オプション [動作を繰り返す] が ON の場合
  341.         if @move_route.repeat
  342.           # 移動ルートのインデックスを最初に戻す
  343.           @move_route_index = 0
  344.         end
  345.         # オプション [動作を繰り返す] が OFF の場合
  346.         unless @move_route.repeat
  347.           # 移動ルート強制中の場合
  348.           if @move_route_forcing and not @move_route.repeat
  349.             # 移動ルートの強制を解除
  350.             @move_route_forcing = false
  351.             # オリジナルの移動ルートを復帰
  352.             @move_route = @original_move_route
  353.             @move_route_index = @original_move_route_index
  354.             @original_move_route = nil
  355.           end
  356.           # 停止カウントをクリア
  357.           @stop_count = 0
  358.         end
  359.         return
  360.       end
  361.       # 移動系コマンド (下に移動~ジャンプ) の場合
  362.       if command.code <= 14
  363.         # コマンドコードで分岐
  364.         case command.code
  365.         when 1  # 下に移動
  366.           move_down
  367.         when 2  # 左に移動
  368.           move_left
  369.         when 3  # 右に移動
  370.           move_right
  371.         when 4  # 上に移動
  372.           move_up
  373.         when 5  # 左下に移動
  374.           move_lower_left
  375.         when 6  # 右下に移動
  376.           move_lower_right
  377.         when 7  # 左上に移動
  378.           move_upper_left
  379.         when 8  # 右上に移動
  380.           move_upper_right
  381.         when 9  # ランダムに移動
  382.           move_random
  383.         when 10  # プレイヤーに近づく
  384.           move_toward_player
  385.         when 11  # プレイヤーから遠ざかる
  386.           move_away_from_player
  387.         when 12  # 一歩前進
  388.           move_forward
  389.         when 13  # 一歩後退
  390.           move_backward
  391.         when 14  # ジャンプ
  392.           jump(command.parameters[0], command.parameters[1])
  393.         end
  394.         # オプション [移動できない場合は無視] が OFF で、移動失敗の場合
  395.         if not @move_route.skippable and not moving? and not jumping?
  396.           return
  397.         end
  398.         @move_route_index += 1
  399.         return
  400.       end
  401.       # ウェイトの場合
  402.       if command.code == 15
  403.         # ウェイトカウントを設定
  404.         @wait_count = command.parameters[0] * 2 - 1
  405.         @move_route_index += 1
  406.         return
  407.       end
  408.       # 向き変更系のコマンドの場合
  409.       if command.code >= 16 and command.code <= 26
  410.         # コマンドコードで分岐
  411.         case command.code
  412.         when 16  # 下を向く
  413.           turn_down
  414.         when 17  # 左を向く
  415.           turn_left
  416.         when 18  # 右を向く
  417.           turn_right
  418.         when 19  # 上を向く
  419.           turn_up
  420.         when 20  # 右に 90 度回転
  421.           turn_right_90
  422.         when 21  # 左に 90 度回転
  423.           turn_left_90
  424.         when 22  # 180 度回転
  425.           turn_180
  426.         when 23  # 右か左に 90 度回転
  427.           turn_right_or_left_90
  428.         when 24  # ランダムに方向転換
  429.           turn_random
  430.         when 25  # プレイヤーの方を向く
  431.           turn_toward_player
  432.         when 26  # プレイヤーの逆を向く
  433.           turn_away_from_player
  434.         end
  435.         @move_route_index += 1
  436.         return
  437.       end
  438.       # その他のコマンドの場合
  439.       if command.code >= 27
  440.         # コマンドコードで分岐
  441.         case command.code
  442.         when 27  # スイッチ ON
  443.           $game_switches[command.parameters[0]] = true
  444.           $game_map.need_refresh = true
  445.         when 28  # スイッチ OFF
  446.           $game_switches[command.parameters[0]] = false
  447.           $game_map.need_refresh = true
  448.         when 29  # 移動速度の変更
  449.           @move_speed = command.parameters[0]
  450.         when 30  # 移動頻度の変更
  451.           @move_frequency = command.parameters[0]
  452.         when 31  # 移動時アニメ ON
  453.           @walk_anime = true
  454.         when 32  # 移動時アニメ OFF
  455.           @walk_anime = false
  456.         when 33  # 停止時アニメ ON
  457.           @step_anime = true
  458.         when 34  # 停止時アニメ OFF
  459.           @step_anime = false
  460.         when 35  # 向き固定 ON
  461.           @direction_fix = true
  462.         when 36  # 向き固定 OFF
  463.           @direction_fix = false
  464.         when 37  # すり抜け ON
  465.           @through = true
  466.         when 38  # すり抜け OFF
  467.           @through = false
  468.         when 39  # 最前面に表示 ON
  469.           @always_on_top = true
  470.         when 40  # 最前面に表示 OFF
  471.           @always_on_top = false
  472.         when 41  # グラフィック変更
  473.           @tile_id = 0
  474.           @character_name = command.parameters[0]
  475.           @character_hue = command.parameters[1]
  476.           if @original_direction != command.parameters[2]
  477.             @direction = command.parameters[2]
  478.             @original_direction = @direction
  479.             @prelock_direction = 0
  480.           end
  481.           if @original_pattern != command.parameters[3]
  482.             @pattern = command.parameters[3]
  483.             @original_pattern = @pattern
  484.           end
  485.         when 42  # 不透明度の変更
  486.           @opacity = command.parameters[0]
  487.         when 43  # 合成方法の変更
  488.           @blend_type = command.parameters[0]
  489.         when 44  # SE の演奏
  490.           $game_system.se_play(command.parameters[0])
  491.         when 45  # スクリプト
  492.           result = eval(command.parameters[0])
  493.         end
  494.         @move_route_index += 1
  495.         return
  496.       end
  497.     end
  498.   end
复制代码

作者: ★_茄孓    时间: 2008-5-18 20:35
  1. #--------------------------------------------------------------------------
  2.   # ● 下に移動
  3.   #--------------------------------------------------------------------------
  4.   def move_down_p
  5.     # 下を向く
  6.     turn_down
  7.     # 移動距離を算出
  8.     distance = 2 ** @move_speed
  9.     down1(((@x * 128 + @revise_x) / 128.0).round,
  10.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  11.   end
  12.   def move_down_aaaagq
  13.     distance = 2 ** @move_speed
  14.     down1(((@x * 128 + @revise_x) / 128.0).round,
  15.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  16.   end
  17.   #--------------------------------------------------------------------------
  18.   # ● 下に移動可能かどうかの判定1
  19.   #--------------------------------------------------------------------------
  20.   def down1(x, y, distance, down = false)
  21.     result = down2(x, y, distance)
  22.     if result == false
  23.       @event_run = check_event_trigger_touch(x, y+1)
  24.       return result
  25.     end
  26.     if @revise_x < -SIDE
  27.       result = down2(x, y + 1, distance, 4)
  28.       result &= down2(x - 1, y, distance)
  29.       if result == false
  30.         if down
  31.           move_lower_right_p
  32.           if @revise_x > SIDE
  33.             @revise_x = SIDE
  34.           end
  35.         end
  36.         return result
  37.       end
  38.     elsif @revise_x > SIDE
  39.       result = down2(x, y + 1, distance, 6)
  40.       result &= down2(x + 1, y, distance)
  41.       if result == false
  42.         if down
  43.           move_lower_left_p
  44.           if @revise_x < -SIDE
  45.             @revise_x = -SIDE
  46.           end
  47.         end
  48.         return result
  49.       end
  50.     end
  51.     # 下に移動可能ならば距離分移動
  52.     @revise_y += distance
  53.     return result
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # ● 下に移動可能かどうかの判定2
  57.   #--------------------------------------------------------------------------
  58.   def down2(x, y, distance, d = 2)
  59.     if @revise_y + distance > DOWN
  60.       unless passable?(x, y, d)
  61.         if @revise_y < DOWN
  62.           @revise_y = DOWN
  63.         end
  64.         return false
  65.       end
  66.     end
  67.     return true
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   # ● 左に移動
  71.   #--------------------------------------------------------------------------
  72.   def move_left_p
  73.     # 左を向く
  74.     turn_left
  75.     distance = 2 ** @move_speed
  76.     left1(((@x * 128 + @revise_x) / 128.0).round,
  77.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # ● 左に移動可能かどうかの判定1
  81.   #--------------------------------------------------------------------------
  82.   def left1(x, y, distance, left = false)
  83.     result = left2(x, y, distance)
  84.     if result == false
  85.       @event_run = check_event_trigger_touch(x-1, y)
  86.       return result
  87.     end
  88.     if @revise_y < -UP and $ud_ok
  89.       result = left2(x - 1, y, distance, 8)
  90.       result &= left2(x, y - 1, distance)
  91.       if result == false
  92.         if left
  93.           move_lower_left_p
  94.           if @revise_y > DOWN
  95.             @revise_y = DOWN
  96.           end
  97.         end
  98.         return result
  99.       end
  100.     elsif @revise_y > DOWN and $ud_ok
  101.       result = left2(x - 1, y, distance, 2)
  102.       result &= left2(x, y + 1, distance)
  103.       if result == false
  104.         if left
  105.           move_upper_left_p
  106.           if @revise_y < -UP
  107.             @revise_y = -UP
  108.           end
  109.         end
  110.         return result
  111.       end
  112.     end
  113.     @revise_x -= distance
  114.     return result
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # ● 左に移動可能かどうかの判定2
  118.   #--------------------------------------------------------------------------
  119.   def left2(x, y, distance, d = 4)
  120.     if @revise_x - distance < -SIDE
  121.       unless passable?(x, y, d)
  122.         if @revise_x > -SIDE
  123.           @revise_x = -SIDE
  124.         end
  125.         return false
  126.       end
  127.     end
  128.     return true
  129.   end
  130.   #--------------------------------------------------------------------------
  131.   # ● 右に移動
  132.   #--------------------------------------------------------------------------
  133.   def move_right_p
  134.       # 右を向く
  135.       turn_right
  136.     distance = 2 ** @move_speed
  137.     right1(((@x * 128 + @revise_x) / 128.0).round,
  138.             ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  139.   end
  140.   #--------------------------------------------------------------------------
  141.   # ● 右に移動可能かどうかの判定1
  142.   #--------------------------------------------------------------------------
  143.   def right1(x, y, distance, right = false)
  144.     result = right2(x, y, distance)
  145.     if result == false
  146.       @event_run = check_event_trigger_touch(x+1, y)
  147.       return result
  148.     end
  149.     if @revise_y < -UP and $ud_ok
  150.       result = right2(x + 1, y, distance, 8)
  151.       result &= right2(x, y - 1, distance)
  152.       if result == false
  153.         if right
  154.           move_lower_right_p
  155.           if @revise_y > DOWN
  156.             @revise_y = DOWN
  157.           end
  158.         end
  159.         return result
  160.       end
  161.     elsif @revise_y > DOWN and $ud_ok
  162.       result = right2(x + 1, y, distance, 2)
  163.       result &= right2(x, y + 1, distance)
  164.       if result == false
  165.         if right
  166.           move_upper_right_p
  167.           if @revise_y < -UP
  168.             @revise_y = -UP
  169.           end
  170.         end
  171.         return result
  172.       end
  173.     end
  174.     @revise_x += distance
  175.     return result
  176.   end
  177.   #--------------------------------------------------------------------------
  178.   # ● 右に移動可能かどうかの判定2
  179.   #--------------------------------------------------------------------------
  180.   def right2(x, y, distance, d = 6)
  181.     if @revise_x + distance > SIDE
  182.       unless passable?(x, y, d)
  183.         if @revise_x < SIDE
  184.           @revise_x = SIDE
  185.         end
  186.         return false
  187.       end
  188.     end
  189.     return true
  190.   end
  191.   #--------------------------------------------------------------------------
  192.   # ● 上に移動
  193.   #--------------------------------------------------------------------------
  194.   def move_up_p
  195.     # 上を向く
  196.     turn_up
  197.     # 下に移動
  198.     distance = 2 ** @move_speed
  199.     up1(((@x * 128 + @revise_x) / 128.0).round,
  200.         ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  201.   end
  202.   def move_up_aaaagq
  203.     distance = 2 ** @move_speed
  204.     up1(((@x * 128 + @revise_x) / 128.0).round,
  205.         ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  206.   end
  207.   #--------------------------------------------------------------------------
  208.   # ● 上に移動可能かどうかの判定1
  209.   #--------------------------------------------------------------------------
  210.   def up1(x, y, distance, up = false)
  211.     result = up2(x, y, distance)
  212.     if result == false
  213.       @event_run = check_event_trigger_touch(x, y-1)
  214.       return result
  215.     end
  216.     if @revise_x < -SIDE
  217.       result = up2(x, y - 1, distance, 4)
  218.       result &= up2(x - 1, y, distance)
  219.       if result == false
  220.         if up
  221.           move_upper_right_p
  222.           if @revise_x > SIDE
  223.             @revise_x = SIDE
  224.           end
  225.         end
  226.         return result
  227.       end
  228.     elsif @revise_x > SIDE
  229.       result = up2(x, y - 1, distance, 6)
  230.       result &= up2(x + 1, y, distance)
  231.       if result == false
  232.         if up
  233.           move_upper_left_p
  234.           if @revise_x < -SIDE
  235.             @revise_x = -SIDE
  236.           end
  237.         end
  238.         return result
  239.       end
  240.     end
  241.     @revise_y -= distance
  242.     return result
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # ● 上に移動可能かどうかの判定2
  246.   #--------------------------------------------------------------------------
  247.   def up2(x, y, distance, d = 8)
  248.     if @revise_y - distance < -UP
  249.       unless passable?(x, y, d)
  250.         if @revise_y > -UP
  251.           @revise_y = -UP
  252.         end
  253.         return false
  254.       end
  255.     end
  256.     return true
  257.   end
  258.   #--------------------------------------------------------------------------
  259.   # ● 左下に移動
  260.   #--------------------------------------------------------------------------
  261.   def move_lower_left_p
  262.     # 向き固定でない場合
  263.     unless @direction_fix
  264.       # 右向きだった場合は左を、上向きだった場合は下を向く
  265.       @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  266.     end
  267.     # 左下に移動
  268.     distance = (2 ** @move_speed) / Math.sqrt(2)
  269.     if @direction == 2
  270.       turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
  271.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  272.       turn_down if @event_run
  273.       unless @event_run
  274.         if last_move?(@real_x, @real_y, 2, distance)
  275.           result = check_event_trigger_here([1,2], false)
  276.           if result == true
  277.             return
  278.           end
  279.         end
  280.         move_on
  281.         if @revise_y > DOWN and -UP > @revise_y - distance
  282.           @revise_y = DOWN
  283.         end
  284.         turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
  285.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  286.         turn_left if @event_run
  287.       end
  288.     else
  289.       turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
  290.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  291.       turn_left if @event_run
  292.       unless @event_run
  293.         if last_move?(@real_x, @real_y, 4, distance)
  294.           result = check_event_trigger_here([1,2], false)
  295.           if result == true
  296.             return
  297.           end
  298.         end
  299.         move_on
  300.         if  @revise_x + distance> SIDE and -SIDE > @revise_x
  301.           @revise_x = -SIDE
  302.         end
  303.         turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
  304.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  305.         turn_down if @event_run
  306.       end
  307.     end
  308.   end
  309.   #--------------------------------------------------------------------------
  310.   # ● 右下に移動
  311.   #--------------------------------------------------------------------------
  312.   def move_lower_right_p
  313.     # 向き固定でない場合
  314.     unless @direction_fix
  315.       # 左向きだった場合は右を、上向きだった場合は下を向く
  316.       @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  317.     end
  318.     # 右下に移動
  319.     distance = (2 ** @move_speed) / Math.sqrt(2)
  320.     if @direction == 2
  321.       turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
  322.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  323.       turn_down if @event_run
  324.       unless @event_run
  325.         if last_move?(@real_x, @real_y, 2, distance)
  326.           result = check_event_trigger_here([1,2], false)
  327.           if result == true
  328.             return
  329.           end
  330.         end
  331.         move_on
  332.         if @revise_y > DOWN and -UP > @revise_y - distance
  333.           @revise_y = DOWN
  334.         end
  335.         turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
  336.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  337.         turn_right if @event_run
  338.       end
  339.     else
  340.       turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
  341.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  342.       turn_right if @event_run
  343.       unless @event_run
  344.         if last_move?(@real_x, @real_y, 6, distance)
  345.           result = check_event_trigger_here([1,2], false)
  346.           if result == true
  347.             return
  348.           end
  349.         end
  350.         move_on
  351.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  352.           @revise_x = SIDE
  353.         end
  354.         turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
  355.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  356.         turn_down if @event_run
  357.       end
  358.     end
  359.   end
  360.   #--------------------------------------------------------------------------
  361.   # ● 左上に移動
  362.   #--------------------------------------------------------------------------
  363.   def move_upper_left_p
  364.     # 向き固定でない場合
  365.     unless @direction_fix
  366.       # 右向きだった場合は左を、下向きだった場合は上を向く
  367.       @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  368.     end
  369.     # 左上に移動
  370.     distance = (2 ** @move_speed) / Math.sqrt(2)
  371.     if @direction == 8
  372.       turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
  373.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  374.       turn_up if @event_run
  375.       unless @event_run
  376.         if last_move?(@real_x, @real_y, 8, distance)
  377.           result = check_event_trigger_here([1,2], false)
  378.           if result == true
  379.             return
  380.           end
  381.         end
  382.         move_on
  383.         if @revise_y + distance > DOWN and -UP > @revise_y
  384.           @revise_y = -UP
  385.         end
  386.         turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
  387.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  388.         turn_left if @event_run
  389.       end
  390.     else
  391.       turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
  392.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  393.       turn_left if @event_run
  394.       unless @event_run
  395.         if last_move?(@real_x, @real_y, 4, distance)
  396.           result = check_event_trigger_here([1,2], false)
  397.           if result == true
  398.             return
  399.           end
  400.         end
  401.         move_on
  402.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  403.           @revise_x = SIDE
  404.         end
  405.         turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
  406.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  407.         turn_up if @event_run
  408.       end
  409.     end
  410.   end
  411.   #--------------------------------------------------------------------------
  412.   # ● 右上に移動
  413.   #--------------------------------------------------------------------------
  414.   def move_upper_right_p
  415.     # 向き固定でない場合
  416.     unless @direction_fix
  417.       # 左向きだった場合は右を、下向きだった場合は上を向く
  418.       @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  419.     end
  420.     # 右上に移動
  421.     distance = (2 ** @move_speed) / Math.sqrt(2)
  422.     if @direction == 8
  423.       turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
  424.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  425.       turn_up if @event_run
  426.       unless @event_run
  427.         if last_move?(@real_x, @real_y, 8, distance)
  428.           result = check_event_trigger_here([1,2], false)
  429.           if result == true
  430.             return
  431.           end
  432.         end
  433.         move_on
  434.         if @revise_y + distance > DOWN and -UP > @revise_y
  435.           @revise_y = -UP
  436.         end
  437.         turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
  438.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  439.         turn_right if @event_run
  440.       end
  441.     else
  442.       turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
  443.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  444.       turn_right if @event_run
  445.       unless @event_run
  446.         if last_move?(@real_x, @real_y, 6, distance)
  447.           result = check_event_trigger_here([1,2], false)
  448.           if result == true
  449.             return
  450.           end
  451.         end
  452.         move_on
  453.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  454.           @revise_x = SIDE
  455.         end
  456.         turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
  457.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  458.         turn_up if @event_run
  459.       end
  460.     end
  461.   end
  462.   #--------------------------------------------------------------------------
  463.   # ● 同位置のイベント起動判定
  464.   #--------------------------------------------------------------------------
  465.   def check_event_trigger_here(triggers, run = true)
  466.     result = false
  467.     # イベント実行中の場合
  468.     if $game_system.map_interpreter.running?
  469.       return result
  470.     end
  471.     # 全イベントのループ
  472.     for event in $game_map.events.values
  473.       # イベントの座標とトリガーが一致した場合
  474.       if event.x == ((@x * 128 + @revise_x) / 128.0).round and
  475.           event.y == ((@y * 128 + @revise_y) / 128.0).round and
  476.           triggers.include?(event.trigger)
  477.         # ジャンプ中以外で、起動判定が同位置のイベントなら
  478.         if not event.jumping? and event.over_trigger?
  479.           if event.list.size > 1
  480.             if run == true
  481.               event.start
  482.             end
  483.             result = true
  484.           end
  485.         end
  486.       end
  487.     end
  488.     return result
  489.   end
  490.   #--------------------------------------------------------------------------
  491.   # ● 座標修正
  492.   #--------------------------------------------------------------------------
  493.   def move_on
  494.     if $坐标 == 1
  495.     if @y < (@y + @revise_y / 128.0).round
  496.       @y += 1
  497.       @revise_y -= 128
  498.     end
  499.     if @x > (@x + @revise_x / 128.0).round
  500.       @x -= 1
  501.       @revise_x += 128
  502.     end
  503.     if @x < (@x + @revise_x / 128.0).round
  504.       @x += 1
  505.       @revise_x -= 128
  506.     end
  507.     if @y > (@y + @revise_y / 128.0).round
  508.       @y -= 1
  509.       @revise_y += 128
  510.     end
  511.     end
  512.   end
  513.   #--------------------------------------------------------------------------
  514.   # ● アニメーションアップデート
  515.   #--------------------------------------------------------------------------
  516.   def anime_update
  517.     # 移動時アニメが ON の場合
  518.     if @walk_anime
  519.       # アニメカウントを 1.5 増やす
  520.       @anime_count += 1.5
  521.     # 移動時アニメが OFF で、停止時アニメが ON の場合
  522.     elsif @step_anime
  523.       # アニメカウントを 1 増やす
  524.       @anime_count += 1
  525.     end
  526.     # アニメカウントが最大値を超えた場合
  527.     # ※最大値は、基本値 18 から移動速度 * 1 を引いた値
  528.     if @anime_count > 18 - @move_speed * 2
  529.       # 停止時アニメが OFF かつ 停止中の場合
  530.       if not @step_anime and @stop_count > 0
  531.         # パターンをオリジナルに戻す
  532.         @pattern = @original_pattern
  533.       # 停止時アニメが ON または 移動中の場合
  534.       else
  535.         # パターンを更新
  536.         @pattern = (@pattern + 1) % 4
  537.       end
  538.       # アニメカウントをクリア
  539.       @anime_count = 0
  540.     end
  541.   end
  542.   #--------------------------------------------------------------------------
  543.   # ● 指定位置に移動
  544.   #--------------------------------------------------------------------------
  545.   # オリジナルのイベントを改名
  546.   alias :moveto_original :moveto
  547.   def moveto(x, y)
  548.     # 補正座標を初期化
  549.     @revise_x = 0
  550.     @revise_y = 0
  551.     # オリジナルのイベントを呼び出し
  552.     moveto_original(x, y)
  553.   end
  554.   #--------------------------------------------------------------------------
  555.   # ● 移動したかどうかの判定
  556.   #--------------------------------------------------------------------------
  557.   def last_move?(x, y, direction, distance)
  558.     if direction == 2 or direction == 6
  559.       distance *= -1
  560.     end
  561.     if (direction == 2 or direction == 8) and
  562.         (y / 128.0).round != ((y - distance) / 128.0).round
  563.       return true
  564.     end
  565.     if (direction == 4 or direction == 6) and
  566.         (x / 128.0).round != ((x - distance) / 128.0).round
  567.       return true
  568.     end
  569.     return false
  570.   end
  571. end

  572. #==============================================================================
  573. # ■ Game_Character (分割定義 1)
  574. #------------------------------------------------------------------------------
  575. #  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event
  576. # クラスのスーパークラスとして使用されます。
  577. #==============================================================================

  578. class Game_Character
  579.   #--------------------------------------------------------------------------
  580.   # ● フレーム更新 (移動)
  581.   #--------------------------------------------------------------------------
  582.   def update_move
  583.     # 移動速度からマップ座標系での移動距離に変換
  584.     distance = 2 ** @move_speed
  585.     if @x * 128 != @real_x and @y * 128 != @real_y and Game_Player::SLANT
  586.       distance /= Math.sqrt(2)
  587.     end
  588.     # 論理座標が実座標より下の場合
  589.     if @y * 128 > @real_y
  590.       # 下に移動
  591.       @real_y = [@real_y + distance, @y * 128].min
  592.     end
  593.     # 論理座標が実座標より左の場合
  594.     if @x * 128 < @real_x
  595.       # 左に移動
  596.       @real_x = [@real_x - distance, @x * 128].max
  597.     end
  598.     # 論理座標が実座標より右の場合
  599.     if @x * 128 > @real_x
  600.       # 右に移動
  601.       @real_x = [@real_x + distance, @x * 128].min
  602.     end
  603.     # 論理座標が実座標より上の場合
  604.     if @y * 128 < @real_y
  605.       # 上に移動
  606.       @real_y = [@real_y - distance, @y * 128].max
  607.     end
  608.     # 移動時アニメが ON の場合
  609.     if @walk_anime
  610.       # アニメカウントを 1.5 増やす
  611.       @anime_count += 1.5
  612.     # 移動時アニメが OFF で、停止時アニメが ON の場合
  613.     elsif @step_anime
  614.       # アニメカウントを 1 増やす
  615.       @anime_count += 1
  616.     end
  617.   end
  618. end

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

  625. class Game_Event < Game_Character
  626.   #--------------------------------------------------------------------------
  627.   # ● イベント起動
  628.   #--------------------------------------------------------------------------
  629.   def start
  630.     # 実行内容が空でない場合
  631.     if @list.size > 1
  632.       # $game_player.event が0でない場合
  633.       if $game_player.event != 0
  634.         # 移動速度を $game_player.event にする
  635.         $game_player.move_speed = $game_player.event
  636.       end
  637.       @starting = true
  638.     end
  639.   end
  640. end

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

作者: ★_茄孓    时间: 2008-5-18 20:36
两段脚本合起来的,以为太长无法发出来,所以分为上下2个部分。
这个是人物跳跃的脚本
不知道能不能让事件也拥有跳跃与重力功能




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1