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

Project1

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

[已经过期] 【求助】怎么让重力系统对角色有影响

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
111 小时
注册时间
2014-3-27
帖子
11
跳转到指定楼层
1
发表于 2015-7-7 17:16:18 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

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

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

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

Lv1.梦旅人

梦石
0
星屑
211
在线时间
845 小时
注册时间
2014-5-5
帖子
944
4
发表于 2015-7-8 18:49:14 | 只看该作者
1342562673 发表于 2015-7-8 16:20
就是和人物一样的效果

恕我愚笨
还是不理解你所说的效果是神马.
如果是想让这脚本生效
就要新建一个事件为  并行处理
事件第三页的 脚本 输入 $ud_ok = false     
                                 $airjump = 1

记得要打开 独立开关

想解除的话 就把脚本改为  $ud_ok = true

评分

参与人数 1星屑 +150 收起 理由
hys111111 + 150 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
111 小时
注册时间
2014-3-27
帖子
11
3
 楼主| 发表于 2015-7-8 16:20:07 | 只看该作者
邪月长啸 发表于 2015-7-8 12:43
具体的影响是什么?你都迷说清楚

就是和人物一样的效果
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
211
在线时间
845 小时
注册时间
2014-5-5
帖子
944
2
发表于 2015-7-8 12:43:24 | 只看该作者
具体的影响是什么?你都迷说清楚
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-23 07:29

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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