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

Project1

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

[已经过期] 谁能帮我把这个重力脚本修改一下啊。。

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
21 小时
注册时间
2012-12-1
帖子
15
跳转到指定楼层
1
 楼主| 发表于 2013-1-26 18:35:20 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 hcm 于 2013-2-9 14:23 编辑

我向右走的时候是以自己为中心,可是一向左走的时候自己就不是中心了……
脚本内容如下:
  1. $ud_ok = true #上下失效
  2. $airjump = 0  #空中连跳
  3. #==============================================================================
  4. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  5. #==============================================================================

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

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

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

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

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

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

  1153. #==============================================================================
  1154. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  1155. #==============================================================================
复制代码
.
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-9-23 06:27

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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