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

Project1

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

[已经过期] XP的重力脚本怎么对事件起效?或者有其他重力脚本吗?

[复制链接]

Lv2.观梦者

梦石
0
星屑
322
在线时间
158 小时
注册时间
2015-7-3
帖子
186
跳转到指定楼层
1
发表于 2017-3-11 18:10:37 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
其他游戏里扒出来的脚本,不知道原帖在哪
想要让其他NPC或者怪物也受重力影响
不然什么怪都会飞了 - -|||

本来想贴上来脚本的,但是,,,
405 很抱歉,由于您访问的URL有可能对网站造成安全威胁,您的访问被阻断

Lv2.观梦者

梦石
0
星屑
322
在线时间
158 小时
注册时间
2015-7-3
帖子
186
2
 楼主| 发表于 2017-3-11 18:12:04 | 只看该作者
  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.     [url=home.php?mod=space&uid=348285]@walk[/url]  = 4
  48.     [url=home.php?mod=space&uid=81012]@Dash[/url]  = 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)
  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 Kboard.keyboard($R_Key_UP)==true 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
  499.   #--------------------------------------------------------------------------
  500.   # ● 下に移動
  501.   #--------------------------------------------------------------------------
  502.   def move_down_p
  503.     # 下を向く
  504.     turn_down
  505.     # 移動距離を算出
  506.     distance = 2 ** @move_speed
  507.     down1(((@x * 128 + @revise_x) / 128.0).round,
  508.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  509.   end
  510.   def move_down_aaaagq
  511.     distance = 2 ** @move_speed
  512.     down1(((@x * 128 + @revise_x) / 128.0).round,
  513.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  514.   end
  515.   #--------------------------------------------------------------------------
  516.   # ● 下に移動可能かどうかの判定1
  517.   #--------------------------------------------------------------------------
  518.   def down1(x, y, distance, down = false)
  519.     result = down2(x, y, distance)
  520.     if result == false
  521.       @event_run = check_event_trigger_touch(x, y+1)
  522.       return result
  523.     end
  524.     if @revise_x < -SIDE
  525.       result = down2(x, y + 1, distance, 4)
  526.       result &= down2(x - 1, y, distance)
  527.       if result == false
  528.         if down
  529.           move_lower_right_p
  530.           if @revise_x > SIDE
  531.             @revise_x = SIDE
  532.           end
  533.         end
  534.         return result
  535.       end
  536.     elsif @revise_x > SIDE
  537.       result = down2(x, y + 1, distance, 6)
  538.       result &= down2(x + 1, y, distance)
  539.       if result == false
  540.         if down
  541.           move_lower_left_p
  542.           if @revise_x < -SIDE
  543.             @revise_x = -SIDE
  544.           end
  545.         end
  546.         return result
  547.       end
  548.     end
  549.     # 下に移動可能ならば距離分移動
  550.     @revise_y += distance
  551.     return result
  552.   end
  553.   #--------------------------------------------------------------------------
  554.   # ● 下に移動可能かどうかの判定2
  555.   #--------------------------------------------------------------------------
  556.   def down2(x, y, distance, d = 2)
  557.     if @revise_y + distance > DOWN
  558.       unless passable?(x, y, d)
  559.         if @revise_y < DOWN
  560.           @revise_y = DOWN
  561.         end
  562.         return false
  563.       end
  564.     end
  565.     return true
  566.   end
  567.   #--------------------------------------------------------------------------
  568.   # ● 左に移動
  569.   #--------------------------------------------------------------------------
  570.   def move_left_p
  571.     # 左を向く
  572.     turn_left
  573.     distance = 2 ** @move_speed
  574.     left1(((@x * 128 + @revise_x) / 128.0).round,
  575.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  576.   end
  577.   #--------------------------------------------------------------------------
  578.   # ● 左に移動可能かどうかの判定1
  579.   #--------------------------------------------------------------------------
  580.   def left1(x, y, distance, left = false)
  581.     result = left2(x, y, distance)
  582.     if result == false
  583.       @event_run = check_event_trigger_touch(x-1, y)
  584.       return result
  585.     end
  586.     if @revise_y < -UP and $ud_ok
  587.       result = left2(x - 1, y, distance, 8)
  588.       result &= left2(x, y - 1, distance)
  589.       if result == false
  590.         if left
  591.           move_lower_left_p
  592.           if @revise_y > DOWN
  593.             @revise_y = DOWN
  594.           end
  595.         end
  596.         return result
  597.       end
  598.     elsif @revise_y > DOWN and $ud_ok
  599.       result = left2(x - 1, y, distance, 2)
  600.       result &= left2(x, y + 1, distance)
  601.       if result == false
  602.         if left
  603.           move_upper_left_p
  604.           if @revise_y < -UP
  605.             @revise_y = -UP
  606.           end
  607.         end
  608.         return result
  609.       end
  610.     end
  611.     @revise_x -= distance
  612.     return result
  613.   end
  614.   #--------------------------------------------------------------------------
  615.   # ● 左に移動可能かどうかの判定2
  616.   #--------------------------------------------------------------------------
  617.   def left2(x, y, distance, d = 4)
  618.     if @revise_x - distance < -SIDE
  619.       unless passable?(x, y, d)
  620.         if @revise_x > -SIDE
  621.           @revise_x = -SIDE
  622.         end
  623.         return false
  624.       end
  625.     end
  626.     return true
  627.   end
  628.   #--------------------------------------------------------------------------
  629.   # ● 右に移動
  630.   #--------------------------------------------------------------------------
  631.   def move_right_p
  632.       # 右を向く
  633.       turn_right
  634.     distance = 2 ** @move_speed
  635.     right1(((@x * 128 + @revise_x) / 128.0).round,
  636.             ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  637.   end
  638.   #--------------------------------------------------------------------------
  639.   # ● 右に移動可能かどうかの判定1
  640.   #--------------------------------------------------------------------------
  641.   def right1(x, y, distance, right = false)
  642.     result = right2(x, y, distance)
  643.     if result == false
  644.       @event_run = check_event_trigger_touch(x+1, y)
  645.       return result
  646.     end
  647.     if @revise_y < -UP and $ud_ok
  648.       result = right2(x + 1, y, distance, 8)
  649.       result &= right2(x, y - 1, distance)
  650.       if result == false
  651.         if right
  652.           move_lower_right_p
  653.           if @revise_y > DOWN
  654.             @revise_y = DOWN
  655.           end
  656.         end
  657.         return result
  658.       end
  659.     elsif @revise_y > DOWN and $ud_ok
  660.       result = right2(x + 1, y, distance, 2)
  661.       result &= right2(x, y + 1, distance)
  662.       if result == false
  663.         if right
  664.           move_upper_right_p
  665.           if @revise_y < -UP
  666.             @revise_y = -UP
  667.           end
  668.         end
  669.         return result
  670.       end
  671.     end
  672.     @revise_x += distance
  673.     return result
  674.   end
  675.   #--------------------------------------------------------------------------
  676.   # ● 右に移動可能かどうかの判定2
  677.   #--------------------------------------------------------------------------
  678.   def right2(x, y, distance, d = 6)
  679.     if @revise_x + distance > SIDE
  680.       unless passable?(x, y, d)
  681.         if @revise_x < SIDE
  682.           @revise_x = SIDE
  683.         end
  684.         return false
  685.       end
  686.     end
  687.     return true
  688.   end
  689.   #--------------------------------------------------------------------------
  690.   # ● 上に移動
  691.   #--------------------------------------------------------------------------
  692.   def move_up_p
  693.     # 上を向く
  694.     turn_up
  695.     # 下に移動
  696.     distance = 2 ** @move_speed
  697.     up1(((@x * 128 + @revise_x) / 128.0).round,
  698.         ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  699.   end
  700.   def move_up_aaaagq
  701.     distance = 2 ** @move_speed
  702.     up1(((@x * 128 + @revise_x) / 128.0).round,
  703.         ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  704.   end
  705.   #--------------------------------------------------------------------------
  706.   # ● 上に移動可能かどうかの判定1
  707.   #--------------------------------------------------------------------------
  708.   def up1(x, y, distance, up = false)
  709.     result = up2(x, y, distance)
  710.     if result == false
  711.       @event_run = check_event_trigger_touch(x, y-1)
  712.       return result
  713.     end
  714.     if @revise_x < -SIDE
  715.       result = up2(x, y - 1, distance, 4)
  716.       result &= up2(x - 1, y, distance)
  717.       if result == false
  718.         if up
  719.           move_upper_right_p
  720.           if @revise_x > SIDE
  721.             @revise_x = SIDE
  722.           end
  723.         end
  724.         return result
  725.       end
  726.     elsif @revise_x > SIDE
  727.       result = up2(x, y - 1, distance, 6)
  728.       result &= up2(x + 1, y, distance)
  729.       if result == false
  730.         if up
  731.           move_upper_left_p
  732.           if @revise_x < -SIDE
  733.             @revise_x = -SIDE
  734.           end
  735.         end
  736.         return result
  737.       end
  738.     end
  739.     @revise_y -= distance
  740.     return result
  741.   end
  742.   #--------------------------------------------------------------------------
  743.   # ● 上に移動可能かどうかの判定2
  744.   #--------------------------------------------------------------------------
  745.   def up2(x, y, distance, d = 8)
  746.     if @revise_y - distance < -UP
  747.       unless passable?(x, y, d)
  748.         if @revise_y > -UP
  749.           @revise_y = -UP
  750.         end
  751.         return false
  752.       end
  753.     end
  754.     return true
  755.   end
  756.   #--------------------------------------------------------------------------
  757.   # ● 左下に移動
  758.   #--------------------------------------------------------------------------
  759.   def move_lower_left_p
  760.     # 向き固定でない場合
  761.     unless @direction_fix
  762.       # 右向きだった場合は左を、上向きだった場合は下を向く
  763.       @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  764.     end
  765.     # 左下に移動
  766.     distance = (2 ** @move_speed) / Math.sqrt(2)
  767.     if @direction == 2
  768.       turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
  769.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  770.       turn_down if @event_run
  771.       unless @event_run
  772.         if last_move?(@real_x, @real_y, 2, distance)
  773.           result = check_event_trigger_here([1,2], false)
  774.           if result == true
  775.             return
  776.           end
  777.         end
  778.         move_on
  779.         if @revise_y > DOWN and -UP > @revise_y - distance
  780.           @revise_y = DOWN
  781.         end
  782.         turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
  783.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  784.         turn_left if @event_run
  785.       end
  786.     else
  787.       turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
  788.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  789.       turn_left if @event_run
  790.       unless @event_run
  791.         if last_move?(@real_x, @real_y, 4, distance)
  792.           result = check_event_trigger_here([1,2], false)
  793.           if result == true
  794.             return
  795.           end
  796.         end
  797.         move_on
  798.         if  @revise_x + distance> SIDE and -SIDE > @revise_x
  799.           @revise_x = -SIDE
  800.         end
  801.         turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
  802.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  803.         turn_down if @event_run
  804.       end
  805.     end
  806.   end
  807.   #--------------------------------------------------------------------------
  808.   # ● 右下に移動
  809.   #--------------------------------------------------------------------------
  810.   def move_lower_right_p
  811.     # 向き固定でない場合
  812.     unless @direction_fix
  813.       # 左向きだった場合は右を、上向きだった場合は下を向く
  814.       @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  815.     end
  816.     # 右下に移動
  817.     distance = (2 ** @move_speed) / Math.sqrt(2)
  818.     if @direction == 2
  819.       turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
  820.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  821.       turn_down if @event_run
  822.       unless @event_run
  823.         if last_move?(@real_x, @real_y, 2, distance)
  824.           result = check_event_trigger_here([1,2], false)
  825.           if result == true
  826.             return
  827.           end
  828.         end
  829.         move_on
  830.         if @revise_y > DOWN and -UP > @revise_y - distance
  831.           @revise_y = DOWN
  832.         end
  833.         turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
  834.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  835.         turn_right if @event_run
  836.       end
  837.     else
  838.       turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
  839.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  840.       turn_right if @event_run
  841.       unless @event_run
  842.         if last_move?(@real_x, @real_y, 6, distance)
  843.           result = check_event_trigger_here([1,2], false)
  844.           if result == true
  845.             return
  846.           end
  847.         end
  848.         move_on
  849.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  850.           @revise_x = SIDE
  851.         end
  852.         turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
  853.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  854.         turn_down if @event_run
  855.       end
  856.     end
  857.   end
  858.   #--------------------------------------------------------------------------
  859.   # ● 左上に移動
  860.   #--------------------------------------------------------------------------
  861.   def move_upper_left_p
  862.     # 向き固定でない場合
  863.     unless @direction_fix
  864.       # 右向きだった場合は左を、下向きだった場合は上を向く
  865.       @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  866.     end
  867.     # 左上に移動
  868.     distance = (2 ** @move_speed) / Math.sqrt(2)
  869.     if @direction == 8
  870.       turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
  871.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  872.       turn_up if @event_run
  873.       unless @event_run
  874.         if last_move?(@real_x, @real_y, 8, distance)
  875.           result = check_event_trigger_here([1,2], false)
  876.           if result == true
  877.             return
  878.           end
  879.         end
  880.         move_on
  881.         if @revise_y + distance > DOWN and -UP > @revise_y
  882.           @revise_y = -UP
  883.         end
  884.         turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
  885.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  886.         turn_left if @event_run
  887.       end
  888.     else
  889.       turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
  890.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  891.       turn_left if @event_run
  892.       unless @event_run
  893.         if last_move?(@real_x, @real_y, 4, distance)
  894.           result = check_event_trigger_here([1,2], false)
  895.           if result == true
  896.             return
  897.           end
  898.         end
  899.         move_on
  900.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  901.           @revise_x = SIDE
  902.         end
  903.         turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
  904.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  905.         turn_up if @event_run
  906.       end
  907.     end
  908.   end
  909.   #--------------------------------------------------------------------------
  910.   # ● 右上に移動
  911.   #--------------------------------------------------------------------------
  912.   def move_upper_right_p
  913.     # 向き固定でない場合
  914.     unless @direction_fix
  915.       # 左向きだった場合は右を、下向きだった場合は上を向く
  916.       @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  917.     end
  918.     # 右上に移動
  919.     distance = (2 ** @move_speed) / Math.sqrt(2)
  920.     if @direction == 8
  921.       turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
  922.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  923.       turn_up if @event_run
  924.       unless @event_run
  925.         if last_move?(@real_x, @real_y, 8, distance)
  926.           result = check_event_trigger_here([1,2], false)
  927.           if result == true
  928.             return
  929.           end
  930.         end
  931.         move_on
  932.         if @revise_y + distance > DOWN and -UP > @revise_y
  933.           @revise_y = -UP
  934.         end
  935.         turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
  936.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  937.         turn_right if @event_run
  938.       end
  939.     else
  940.       turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
  941.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  942.       turn_right if @event_run
  943.       unless @event_run
  944.         if last_move?(@real_x, @real_y, 6, distance)
  945.           result = check_event_trigger_here([1,2], false)
  946.           if result == true
  947.             return
  948.           end
  949.         end
  950.         move_on
  951.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  952.           @revise_x = SIDE
  953.         end
  954.         turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
  955.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  956.         turn_up if @event_run
  957.       end
  958.     end
  959.   end
  960.   #--------------------------------------------------------------------------
  961.   # ● 同位置のイベント起動判定
  962.   #--------------------------------------------------------------------------
  963.   def check_event_trigger_here(triggers, run = true)
  964.     result = false
  965.     # イベント実行中の場合
  966.     if $game_system.map_interpreter.running?
  967.       return result
  968.     end
  969.     # 全イベントのループ
  970.     for event in $game_map.events.values
  971.       # イベントの座標とトリガーが一致した場合
  972.       if event.x == ((@x * 128 + @revise_x) / 128.0).round and
  973.           event.y == ((@y * 128 + @revise_y) / 128.0).round and
  974.           triggers.include?(event.trigger)
  975.         # ジャンプ中以外で、起動判定が同位置のイベントなら
  976.         if not event.jumping? and event.over_trigger?
  977.           if event.list.size > 1
  978.             if run == true
  979.               event.start
  980.             end
  981.             result = true
  982.           end
  983.         end
  984.       end
  985.     end
  986.     return result
  987.   end
  988.   #--------------------------------------------------------------------------
  989.   # ● 座標修正
  990.   #--------------------------------------------------------------------------
  991.   def move_on
  992.     if @y < (@y + @revise_y / 128.0).round
  993.       @y += 1
  994.       @revise_y -= 128
  995.     end
  996.     if @x > (@x + @revise_x / 128.0).round
  997.       @x -= 1
  998.       @revise_x += 128
  999.     end
  1000.     if @x < (@x + @revise_x / 128.0).round
  1001.       @x += 1
  1002.       @revise_x -= 128
  1003.     end
  1004.     if @y > (@y + @revise_y / 128.0).round
  1005.       @y -= 1
  1006.       @revise_y += 128
  1007.     end
  1008.   end
  1009.   #--------------------------------------------------------------------------
  1010.   # ● アニメーションアップデート
  1011.   #--------------------------------------------------------------------------
  1012.   def anime_update
  1013.     # 移動時アニメが ON の場合
  1014.     if @walk_anime
  1015.       # アニメカウントを 1.5 増やす
  1016.       @anime_count += 1.5
  1017.     # 移動時アニメが OFF で、停止時アニメが ON の場合
  1018.     elsif @step_anime
  1019.       # アニメカウントを 1 増やす
  1020.       @anime_count += 1
  1021.     end
  1022.     # アニメカウントが最大値を超えた場合
  1023.     # ※最大値は、基本値 18 から移動速度 * 1 を引いた値
  1024.     if @anime_count > 18 - @move_speed * 2
  1025.       # 停止時アニメが OFF かつ 停止中の場合
  1026.       if not @step_anime and @stop_count > 0
  1027.         # パターンをオリジナルに戻す
  1028.         @pattern = @original_pattern
  1029.       # 停止時アニメが ON または 移動中の場合
  1030.       else
  1031.         # パターンを更新
  1032.         @pattern = (@pattern + 1) % 4
  1033.       end
  1034.       # アニメカウントをクリア
  1035.       @anime_count = 0
  1036.     end
  1037.   end
  1038.   #--------------------------------------------------------------------------
  1039.   # ● 指定位置に移動
  1040.   #--------------------------------------------------------------------------
  1041.   # オリジナルのイベントを改名
  1042.   alias :moveto_original :moveto
  1043.   def moveto(x, y)
  1044.     # 補正座標を初期化
  1045.     @revise_x = 0
  1046.     @revise_y = 0
  1047.     # オリジナルのイベントを呼び出し
  1048.     moveto_original(x, y)
  1049.   end
  1050.   #--------------------------------------------------------------------------
  1051.   # ● 移動したかどうかの判定
  1052.   #--------------------------------------------------------------------------
  1053.   def last_move?(x, y, direction, distance)
  1054.     if direction == 2 or direction == 6
  1055.       distance *= -1
  1056.     end
  1057.     if (direction == 2 or direction == 8) and
  1058.         (y / 128.0).round != ((y - distance) / 128.0).round
  1059.       return true
  1060.     end
  1061.     if (direction == 4 or direction == 6) and
  1062.         (x / 128.0).round != ((x - distance) / 128.0).round
  1063.       return true
  1064.     end
  1065.     return false
  1066.   end
  1067. end

  1068. #==============================================================================
  1069. # ■ Game_Character (分割定義 1)
  1070. #------------------------------------------------------------------------------
  1071. #  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event
  1072. # クラスのスーパークラスとして使用されます。
  1073. #==============================================================================

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

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

  1121. class Game_Event < Game_Character
  1122.   #--------------------------------------------------------------------------
  1123.   # ● イベント起動
  1124.   #--------------------------------------------------------------------------
  1125.   def start
  1126.     # 実行内容が空でない場合
  1127.     if @list.size > 1
  1128.       # $game_player.event が0でない場合
  1129.       if $game_player.event != 0
  1130.         # 移動速度を $game_player.event にする
  1131.         $game_player.move_speed = $game_player.event
  1132.       end
  1133.       @starting = true
  1134.     end
  1135.   end
  1136. end

  1137. #==============================================================================
  1138. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  1139. #==============================================================================
复制代码
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
33238
在线时间
10501 小时
注册时间
2009-3-15
帖子
4757
3
发表于 2017-3-11 18:28:25 | 只看该作者
这不是最常见的重力脚本么..
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
34877
在线时间
4148 小时
注册时间
2007-12-15
帖子
9983
4
发表于 2017-3-12 14:35:30 | 只看该作者
本帖最后由 89444640 于 2017-3-12 14:38 编辑

不清楚你这是哪个版本的,
重力脚本生效的脚本是通用的
首先,
不建议用脚本写的每个地图都建立。
建议禁止存盘。
建立单独存盘点,存盘点建立并行处理事件。
脚本
$ud_ok = false
$airjump = 0

若天代码 $t空中跳跃=1是两段跳 余此类推
执行任何事件时候,必须先用脚本
$ud_ok = true
关闭重力
事件执行结束后再运行前一个脚本

脚本目前仍然有的一些问题,站立的位置并总有些上下浮动,但是若去掉浮动跳跃会较为生硬,而且有一些地方会比视觉上跳的高度要矮一些。
影响正常rpg模式人物的通行范围,会因为上下浮动而略大,会有走入墙壁中的情况出现。
偶尔会影响角色朝向,造成16格的行走图只能用最左边一排,而且最后静止位置必定给你弄成左上第一帧,只要脚本处理过,所有的进度只能重打此问题才会消失,因此必须在不用时候,让玩家手动从脚本裤中删除,除非有脚本,运行某一段重力时间后,自动执行从脚本库中删除此脚本的方法,否则无解。

似乎见过对其他角色也生效的重力,未使用。因此不知道具体情况

点评

然后乃说的前两个问题遇到过,感觉没影响,不过最后说的那个问题没看懂  发表于 2017-3-12 14:50
对角色起效的用法是知道的,只是想对其他角色奇效吶。。。开始做的时候没注意,后来做怪物时发现怪物居然会飞。  发表于 2017-3-12 14:49
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-8 06:22

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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