Project1

标题: 关于八方向走的问题 [打印本页]

作者: 越前リョーマ    时间: 2007-7-10 02:26
标题: 关于八方向走的问题
# ————————————————————————————————————
# 全方向ドット移動 Ver ε
# 配布元・サポートURL
# http://members.jcom.home.ne.jp/cogwheel/

#==============================================================================
# ■ Game_Player
#------------------------------------------------------------------------------
#  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの
# 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # ● 定数
  #--------------------------------------------------------------------------
  UP    = 48                  # 上方向の余裕(0 < UP < 63)
  DOWN  = 16                  # 下方向の余裕(0 < DOWN <63)
  SIDE  = 32                  # 左右方向の余裕(0 < SIDE <63)
  SLANT = false               # 移動ルートの斜め移動時、速度修正
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader   :event                    # イベント時移動速度
  attr_accessor :move_speed               # 移動速度
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  alias :update_original :update
  def update
    # @walk:歩行速度 @dash:ダッシュ時移動速度
    # @event:イベント時移動速度(0の時は、イベント時に速度変更をしない)
    @walk  = 4
    @dash  = 5
    @event = 4
    @dot_m = true
    #ダッシュ機能。エンターキーが押されている間、移動速度を変更する。
    unless moving? or $game_system.map_interpreter.running? or
            @move_route_forcing or $game_temp.message_window_showing
      if @walk != @dash
        if Input.press?(Input::C)
          if @move_speed != @dash
            @move_speed = @dash
          end
        else
          if @move_speed != @walk
            @move_speed = @walk
          end
        end
      end
    end
    if @revise_x == nil and @revise_y == nil
      @revise_x = 0
      @revise_y = 0
    end
    unless @dot_m
      update_original
      return
    end
    if @move_route_forcing
      # ローカル変数に移動中かどうかを記憶
      last_moving = moving?
      # ローカル変数に座標を記憶
      last_real_x = @real_x
      last_real_y = @real_y
      # 座標がずれている場合
      if (@revise_x != 0 or @revise_y != 0) and not jumping? and @move == true
        if @revise_x != @real_x - @x * 128 or @revise_y != @real_y - @y * 128
          @revise_x = @real_x - @x * 128
          @revise_y = @real_y - @y * 128
        end
        # 移動距離distance1と目標距離distance2を設定
        distance1 = 2 ** @move_speed
        distance2 = Math.sqrt(@revise_x ** 2 + @revise_y ** 2)
        # 移動距離が目標距離を越えた場合
        if distance1 > distance2
          # 強制的に補正座標を零にする
          @real_x = @real_x - @revise_x
          @real_y = @real_y - @revise_y
          @revise_x = 0
          @revise_y = 0
          anime_update
        # 移動距離が目標距離に達しない場合
        else
          # 移動距離分目標距離に近づく
          @real_x -= (distance1 * @revise_x / distance2).round
          @real_y -= (distance1 * @revise_y / distance2).round
          @revise_x = @real_x - @x * 128
          @revise_y = @real_y - @y * 128
          anime_update
        end
      else
        super
      end
    else
      @move = false
      # 移動中、イベント実行中、移動ルート強制中、
      # メッセージウィンドウ表示中のいずれでもない場合
      unless moving? or $game_system.map_interpreter.running? or
             @move_route_forcing or $game_temp.message_window_showing
        @event_run = false
        # 方向ボタンが押されていれば、その方向へプレイヤーを移動
        case Input.dir8
        when 1
          move_lower_left_p
        when 2
          move_down_p
        when 3
          move_lower_right_p
        when 4
          move_left_p
        when 6
          move_right_p
        when 7
          move_upper_left_p
        when 8
          move_up_p
        when 9
          move_upper_right_p
        end
      end
      # ローカル変数に座標を記憶
      last_real_x = @real_x
      last_real_y = @real_y
      # 移動処理
      @real_x = @x * 128 + @revise_x
      @real_y = @y * 128 + @revise_y
      # ローカル変数に移動中かどうかを記憶
      last_moving = moving?
      # 座標更新
      move_on
      # 現在の座標と以前の座標が異なる場合
      if (last_real_x != @real_x or last_real_y != @real_y)
        @move_distance = 0 if @move_distance == nil
        @move_distance += Math.sqrt((last_real_x - @real_x) ** 2 +
                                      (last_real_y - @real_y) ** 2)
        if @move_distance >= 128
          @move_distance %= 128
          increase_steps
        end
        # アニメーションを更新
        anime_update
      else
        @pattern = 0
      end
    end
    # キャラクターが下に移動し、かつ画面上の位置が中央より下の場合
    if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
      # マップを下にスクロール
      $game_map.scroll_down(@real_y - last_real_y)
    end
    # キャラクターが左に移動し、かつ画面上の位置が中央より左の場合
    if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
      # マップを左にスクロール
      $game_map.scroll_left(last_real_x - @real_x)
    end
    # キャラクターが右に移動し、かつ画面上の位置が中央より右の場合
    if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
      # マップを右にスクロール
      $game_map.scroll_right(@real_x - last_real_x)
    end
    # キャラクターが上に移動し、かつ画面上の位置が中央より上の場合
    if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
      # マップを上にスクロール
      $game_map.scroll_up(last_real_y - @real_y)
    end
    # 前回プレイヤーが移動中だった場合
    if last_moving
      # 同位置のイベントとの接触によるイベント起動判定
      result = check_event_trigger_here([1,2])
      if result == true
        if (last_real_x / 128.0).round != @x and
            (last_real_y / 128.0).round != @y
          if @direction == 2 or @direction == 8
            if (last_real_x / 128.0).round > @x
              turn_left
            else
              turn_right
            end
          else
            if (last_real_y / 128.0).round > @y
              turn_up
            else
              turn_down
            end
          end
        elsif (last_real_x / 128.0).round > @x
          turn_left
        elsif (last_real_x / 128.0).round < @x
          turn_right
        elsif (last_real_y / 128.0).round > @y
          turn_up
        elsif (last_real_y / 128.0).round < @y
          turn_down
        end
      end
      # 起動したイベントがない場合
      if result == false
        # デバッグモードが ON かつ CTRL キーが押されている場合を除き
        unless $DEBUG and Input.press?(Input::CTRL)
          # エンカウント カウントダウン
          if @encounter_count > 0
            @encounter_count -= 1
          end
        end
      end
    end
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      # 同位置および正面のイベント起動判定
      check_event_trigger_here([0])
      check_event_trigger_there([0,1,2])
    end
  end
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    @revise_x = 0
    @revise_y = 0
    @move == false
    super
  end
  #--------------------------------------------------------------------------
  # ● 移動判定
  #--------------------------------------------------------------------------
  def moving?
    unless @dot_m
      result = super
      return result
    end
    # 強制移動の場合オリジナルの判定をさせる
    if @move_route_forcing
      if @move == false
        return false
      end
      super
    # 通常時は現座標が実座標と異なる場合のみ移動中と判定
    else
      return (@x != (@real_x / 128.0).round or @y != (@real_y / 128.0).round)
    end
  end
  #--------------------------------------------------------------------------
  # ● 移動判定
  #--------------------------------------------------------------------------
  def moving_a?
    if @move == false
      if (@move_route.list[@move_route_index].code <= 14 or
          @move_route.list[@move_route_index].code == 25)
        @move = true
      end
      return false
    end
    moving?
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (ジャンプ)
  #--------------------------------------------------------------------------
  def update_jump
    # ジャンプカウントを 1 減らす
    @jump_count -= 1
    # 新しい座標を計算
    @real_x = (@real_x * @jump_count + @x * 128) / (@jump_count + 1)
    @real_y = (@real_y * @jump_count + @y * 128) / (@jump_count + 1)
    if @jump_count == 0
      @revise_x = 0
      @revise_y = 0
    end
  end
  #--------------------------------------------------------------------------
  # ● 移動タイプ : カスタム
  #--------------------------------------------------------------------------
  def move_type_custom
    unless @dot_m
      super
      return
    end
    # 停止中でなければ中断
    if jumping? or moving_a?
      return
    end
    # 移動コマンドのリストの最後に到達するまでループ
    while @move_route_index < @move_route.list.size
      # 移動コマンドを取得
      command = @move_route.list[@move_route_index]
      # コマンドコード 0 番 (リストの最後) の場合
      if command.code == 0
        # オプション [動作を繰り返す] が ON の場合
        if @move_route.repeat
          # 移動ルートのインデックスを最初に戻す
          @move_route_index = 0
        end
        # オプション [動作を繰り返す] が OFF の場合
        unless @move_route.repeat
          # 移動ルート強制中の場合
          if @move_route_forcing and not @move_route.repeat
            # 移動ルートの強制を解除
            @move_route_forcing = false
            # オリジナルの移動ルートを復帰
            @move_route = @original_move_route
            @move_route_index = @original_move_route_index
            @original_move_route = nil
          end
          # 停止カウントをクリア
          @stop_count = 0
        end
        return
      end
      # 移動系コマンド (下に移動~ジャンプ) の場合
      if command.code <= 14
        # コマンドコードで分岐
        case command.code
        when 1  # 下に移動
          move_down
        when 2  # 左に移動
          move_left
        when 3  # 右に移動
          move_right
        when 4  # 上に移動
          move_up
        when 5  # 左下に移動
          move_lower_left
        when 6  # 右下に移動
          move_lower_right
        when 7  # 左上に移動
          move_upper_left
        when 8  # 右上に移動
          move_upper_right
        when 9  # ランダムに移動
          move_random
        when 10  # プレイヤーに近づく
          move_toward_player
        when 11  # プレイヤーから遠ざかる
          move_away_from_player
        when 12  # 一歩前進
          move_forward
        when 13  # 一歩後退
          move_backward
        when 14  # ジャンプ
          jump(command.parameters[0], command.parameters[1])
        end
        # オプション [移動できない場合は無視] が OFF で、移動失敗の場合
        if not @move_route.skippable and not moving? and not jumping?
          return
        end
        @move_route_index += 1
        return
      end
      # ウェイトの場合
      if command.code == 15
        # ウェイトカウントを設定
        @wait_count = command.parameters[0] * 2 - 1
        @move_route_index += 1
        return
      end
      # 向き変更系のコマンドの場合
      if command.code >= 16 and command.code <= 26
        # コマンドコードで分岐
        case command.code
        when 16  # 下を向く
          turn_down
        when 17  # 左を向く
          turn_left
        when 18  # 右を向く
          turn_right
        when 19  # 上を向く
          turn_up
        when 20  # 右に 90 度回転
          turn_right_90
        when 21  # 左に 90 度回転
          turn_left_90
        when 22  # 180 度回転
          turn_180
        when 23  # 右か左に 90 度回転
          turn_right_or_left_90
        when 24  # ランダムに方向転換
          turn_random
        when 25  # プレイヤーの方を向く
          turn_toward_player
        when 26  # プレイヤーの逆を向く
          turn_away_from_player
        end
        @move_route_index += 1
        return
      end
      # その他のコマンドの場合
      if command.code >= 27
        # コマンドコードで分岐
        case command.code
        when 27  # スイッチ ON
          $game_switches[command.parameters[0]] = true
          $game_map.need_refresh = true
        when 28  # スイッチ OFF
          $game_switches[command.parameters[0]] = false
          $game_map.need_refresh = true
        when 29  # 移動速度の変更
          @move_speed = command.parameters[0]
        when 30  # 移動頻度の変更
          @move_frequency = command.parameters[0]
        when 31  # 移動時アニメ ON
          @walk_anime = true
        when 32  # 移動時アニメ OFF
          @walk_anime = false
        when 33  # 停止時アニメ ON
          @step_anime = true
        when 34  # 停止時アニメ OFF
          @step_anime = false
        when 35  # 向き固定 ON
          @direction_fix = true
        when 36  # 向き固定 OFF
          @direction_fix = false
        when 37  # すり抜け ON
          @through = true
        when 38  # すり抜け OFF
          @through = false
        when 39  # 最前面に表示 ON
          @always_on_top = true
        when 40  # 最前面に表示 OFF
          @always_on_top = false
        when 41  # グラフィック変更
          @tile_id = 0
          @character_name = command.parameters[0]
          @character_hue = command.parameters[1]
          if @original_direction != command.parameters[2]
            @direction = command.parameters[2]
            @original_direction = @direction
            @prelock_direction = 0
          end
          if @original_pattern != command.parameters[3]
            @pattern = command.parameters[3]
            @original_pattern = @pattern
          end
        when 42  # 不透明度の変更
          @opacity = command.parameters[0]
        when 43  # 合成方法の変更
          @blend_type = command.parameters[0]
        when 44  # SE の演奏
          $game_system.se_play(command.parameters[0])
        when 45  # スクリプト
          result = eval(command.parameters[0])
        end
        @move_route_index += 1
        return
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 下に移動
  #--------------------------------------------------------------------------
  def move_down_p
    # 下を向く
    turn_down
    # 移動距離を算出
    distance = 2 ** @move_speed
    down1(((@x * 128 + @revise_x) / 128.0).round,
          ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  end
  #--------------------------------------------------------------------------
  # ● 下に移動可能かどうかの判定1
  #--------------------------------------------------------------------------
  def down1(x, y, distance, down = false)
    result = down2(x, y, distance)
    if result == false
      @event_run = check_event_trigger_touch(x, y+1)
      return result
    end
    if @revise_x < -SIDE
      result = down2(x, y + 1, distance, 4)
      result &= down2(x - 1, y, distance)
      if result == false
        if down
          move_lower_right_p
          if @revise_x > SIDE
            @revise_x = SIDE
          end
        end
        return result
      end
    elsif @revise_x > SIDE
      result = down2(x, y + 1, distance, 6)
      result &= down2(x + 1, y, distance)
      if result == false
        if down
          move_lower_left_p
          if @revise_x < -SIDE
            @revise_x = -SIDE
          end
        end
        return result
      end
    end
    # 下に移動可能ならば距離分移動
    @revise_y += distance
    return result
  end
  #--------------------------------------------------------------------------
  # ● 下に移動可能かどうかの判定2
  #--------------------------------------------------------------------------
  def down2(x, y, distance, d = 2)
    if @revise_y + distance > DOWN
      unless passable?(x, y, d)
        if @revise_y < DOWN
          @revise_y = DOWN
        end
        return false
      end
    end
    return true
  end
  #--------------------------------------------------------------------------
  # ● 左に移動
  #--------------------------------------------------------------------------
  def move_left_p
    # 左を向く
    turn_left
    distance = 2 ** @move_speed
    left1(((@x * 128 + @revise_x) / 128.0).round,
          ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  end
  #--------------------------------------------------------------------------
  # ● 左に移動可能かどうかの判定1
  #--------------------------------------------------------------------------
  def left1(x, y, distance, left = false)
    result = left2(x, y, distance)
    if result == false
      @event_run = check_event_trigger_touch(x-1, y)
      return result
    end
    if @revise_y < -UP
      result = left2(x - 1, y, distance, 8)
      result &= left2(x, y - 1, distance)
      if result == false
        if left
          move_lower_left_p
          if @revise_y > DOWN
            @revise_y = DOWN
          end
        end
        return result
      end
    elsif @revise_y > DOWN
      result = left2(x - 1, y, distance, 2)
      result &= left2(x, y + 1, distance)
      if result == false
        if left
   


我用了以后就一个效果,
是八方向了,
但怎么有两个人在一起呢。。。?
作者: 越前リョーマ    时间: 2007-7-10 02:26
标题: 关于八方向走的问题
# ————————————————————————————————————
# 全方向ドット移動 Ver ε
# 配布元・サポートURL
# http://members.jcom.home.ne.jp/cogwheel/

#==============================================================================
# ■ Game_Player
#------------------------------------------------------------------------------
#  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの
# 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # ● 定数
  #--------------------------------------------------------------------------
  UP    = 48                  # 上方向の余裕(0 < UP < 63)
  DOWN  = 16                  # 下方向の余裕(0 < DOWN <63)
  SIDE  = 32                  # 左右方向の余裕(0 < SIDE <63)
  SLANT = false               # 移動ルートの斜め移動時、速度修正
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader   :event                    # イベント時移動速度
  attr_accessor :move_speed               # 移動速度
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  alias :update_original :update
  def update
    # @walk:歩行速度 @dash:ダッシュ時移動速度
    # @event:イベント時移動速度(0の時は、イベント時に速度変更をしない)
    @walk  = 4
    @dash  = 5
    @event = 4
    @dot_m = true
    #ダッシュ機能。エンターキーが押されている間、移動速度を変更する。
    unless moving? or $game_system.map_interpreter.running? or
            @move_route_forcing or $game_temp.message_window_showing
      if @walk != @dash
        if Input.press?(Input::C)
          if @move_speed != @dash
            @move_speed = @dash
          end
        else
          if @move_speed != @walk
            @move_speed = @walk
          end
        end
      end
    end
    if @revise_x == nil and @revise_y == nil
      @revise_x = 0
      @revise_y = 0
    end
    unless @dot_m
      update_original
      return
    end
    if @move_route_forcing
      # ローカル変数に移動中かどうかを記憶
      last_moving = moving?
      # ローカル変数に座標を記憶
      last_real_x = @real_x
      last_real_y = @real_y
      # 座標がずれている場合
      if (@revise_x != 0 or @revise_y != 0) and not jumping? and @move == true
        if @revise_x != @real_x - @x * 128 or @revise_y != @real_y - @y * 128
          @revise_x = @real_x - @x * 128
          @revise_y = @real_y - @y * 128
        end
        # 移動距離distance1と目標距離distance2を設定
        distance1 = 2 ** @move_speed
        distance2 = Math.sqrt(@revise_x ** 2 + @revise_y ** 2)
        # 移動距離が目標距離を越えた場合
        if distance1 > distance2
          # 強制的に補正座標を零にする
          @real_x = @real_x - @revise_x
          @real_y = @real_y - @revise_y
          @revise_x = 0
          @revise_y = 0
          anime_update
        # 移動距離が目標距離に達しない場合
        else
          # 移動距離分目標距離に近づく
          @real_x -= (distance1 * @revise_x / distance2).round
          @real_y -= (distance1 * @revise_y / distance2).round
          @revise_x = @real_x - @x * 128
          @revise_y = @real_y - @y * 128
          anime_update
        end
      else
        super
      end
    else
      @move = false
      # 移動中、イベント実行中、移動ルート強制中、
      # メッセージウィンドウ表示中のいずれでもない場合
      unless moving? or $game_system.map_interpreter.running? or
             @move_route_forcing or $game_temp.message_window_showing
        @event_run = false
        # 方向ボタンが押されていれば、その方向へプレイヤーを移動
        case Input.dir8
        when 1
          move_lower_left_p
        when 2
          move_down_p
        when 3
          move_lower_right_p
        when 4
          move_left_p
        when 6
          move_right_p
        when 7
          move_upper_left_p
        when 8
          move_up_p
        when 9
          move_upper_right_p
        end
      end
      # ローカル変数に座標を記憶
      last_real_x = @real_x
      last_real_y = @real_y
      # 移動処理
      @real_x = @x * 128 + @revise_x
      @real_y = @y * 128 + @revise_y
      # ローカル変数に移動中かどうかを記憶
      last_moving = moving?
      # 座標更新
      move_on
      # 現在の座標と以前の座標が異なる場合
      if (last_real_x != @real_x or last_real_y != @real_y)
        @move_distance = 0 if @move_distance == nil
        @move_distance += Math.sqrt((last_real_x - @real_x) ** 2 +
                                      (last_real_y - @real_y) ** 2)
        if @move_distance >= 128
          @move_distance %= 128
          increase_steps
        end
        # アニメーションを更新
        anime_update
      else
        @pattern = 0
      end
    end
    # キャラクターが下に移動し、かつ画面上の位置が中央より下の場合
    if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
      # マップを下にスクロール
      $game_map.scroll_down(@real_y - last_real_y)
    end
    # キャラクターが左に移動し、かつ画面上の位置が中央より左の場合
    if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
      # マップを左にスクロール
      $game_map.scroll_left(last_real_x - @real_x)
    end
    # キャラクターが右に移動し、かつ画面上の位置が中央より右の場合
    if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
      # マップを右にスクロール
      $game_map.scroll_right(@real_x - last_real_x)
    end
    # キャラクターが上に移動し、かつ画面上の位置が中央より上の場合
    if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
      # マップを上にスクロール
      $game_map.scroll_up(last_real_y - @real_y)
    end
    # 前回プレイヤーが移動中だった場合
    if last_moving
      # 同位置のイベントとの接触によるイベント起動判定
      result = check_event_trigger_here([1,2])
      if result == true
        if (last_real_x / 128.0).round != @x and
            (last_real_y / 128.0).round != @y
          if @direction == 2 or @direction == 8
            if (last_real_x / 128.0).round > @x
              turn_left
            else
              turn_right
            end
          else
            if (last_real_y / 128.0).round > @y
              turn_up
            else
              turn_down
            end
          end
        elsif (last_real_x / 128.0).round > @x
          turn_left
        elsif (last_real_x / 128.0).round < @x
          turn_right
        elsif (last_real_y / 128.0).round > @y
          turn_up
        elsif (last_real_y / 128.0).round < @y
          turn_down
        end
      end
      # 起動したイベントがない場合
      if result == false
        # デバッグモードが ON かつ CTRL キーが押されている場合を除き
        unless $DEBUG and Input.press?(Input::CTRL)
          # エンカウント カウントダウン
          if @encounter_count > 0
            @encounter_count -= 1
          end
        end
      end
    end
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      # 同位置および正面のイベント起動判定
      check_event_trigger_here([0])
      check_event_trigger_there([0,1,2])
    end
  end
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    @revise_x = 0
    @revise_y = 0
    @move == false
    super
  end
  #--------------------------------------------------------------------------
  # ● 移動判定
  #--------------------------------------------------------------------------
  def moving?
    unless @dot_m
      result = super
      return result
    end
    # 強制移動の場合オリジナルの判定をさせる
    if @move_route_forcing
      if @move == false
        return false
      end
      super
    # 通常時は現座標が実座標と異なる場合のみ移動中と判定
    else
      return (@x != (@real_x / 128.0).round or @y != (@real_y / 128.0).round)
    end
  end
  #--------------------------------------------------------------------------
  # ● 移動判定
  #--------------------------------------------------------------------------
  def moving_a?
    if @move == false
      if (@move_route.list[@move_route_index].code <= 14 or
          @move_route.list[@move_route_index].code == 25)
        @move = true
      end
      return false
    end
    moving?
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (ジャンプ)
  #--------------------------------------------------------------------------
  def update_jump
    # ジャンプカウントを 1 減らす
    @jump_count -= 1
    # 新しい座標を計算
    @real_x = (@real_x * @jump_count + @x * 128) / (@jump_count + 1)
    @real_y = (@real_y * @jump_count + @y * 128) / (@jump_count + 1)
    if @jump_count == 0
      @revise_x = 0
      @revise_y = 0
    end
  end
  #--------------------------------------------------------------------------
  # ● 移動タイプ : カスタム
  #--------------------------------------------------------------------------
  def move_type_custom
    unless @dot_m
      super
      return
    end
    # 停止中でなければ中断
    if jumping? or moving_a?
      return
    end
    # 移動コマンドのリストの最後に到達するまでループ
    while @move_route_index < @move_route.list.size
      # 移動コマンドを取得
      command = @move_route.list[@move_route_index]
      # コマンドコード 0 番 (リストの最後) の場合
      if command.code == 0
        # オプション [動作を繰り返す] が ON の場合
        if @move_route.repeat
          # 移動ルートのインデックスを最初に戻す
          @move_route_index = 0
        end
        # オプション [動作を繰り返す] が OFF の場合
        unless @move_route.repeat
          # 移動ルート強制中の場合
          if @move_route_forcing and not @move_route.repeat
            # 移動ルートの強制を解除
            @move_route_forcing = false
            # オリジナルの移動ルートを復帰
            @move_route = @original_move_route
            @move_route_index = @original_move_route_index
            @original_move_route = nil
          end
          # 停止カウントをクリア
          @stop_count = 0
        end
        return
      end
      # 移動系コマンド (下に移動~ジャンプ) の場合
      if command.code <= 14
        # コマンドコードで分岐
        case command.code
        when 1  # 下に移動
          move_down
        when 2  # 左に移動
          move_left
        when 3  # 右に移動
          move_right
        when 4  # 上に移動
          move_up
        when 5  # 左下に移動
          move_lower_left
        when 6  # 右下に移動
          move_lower_right
        when 7  # 左上に移動
          move_upper_left
        when 8  # 右上に移動
          move_upper_right
        when 9  # ランダムに移動
          move_random
        when 10  # プレイヤーに近づく
          move_toward_player
        when 11  # プレイヤーから遠ざかる
          move_away_from_player
        when 12  # 一歩前進
          move_forward
        when 13  # 一歩後退
          move_backward
        when 14  # ジャンプ
          jump(command.parameters[0], command.parameters[1])
        end
        # オプション [移動できない場合は無視] が OFF で、移動失敗の場合
        if not @move_route.skippable and not moving? and not jumping?
          return
        end
        @move_route_index += 1
        return
      end
      # ウェイトの場合
      if command.code == 15
        # ウェイトカウントを設定
        @wait_count = command.parameters[0] * 2 - 1
        @move_route_index += 1
        return
      end
      # 向き変更系のコマンドの場合
      if command.code >= 16 and command.code <= 26
        # コマンドコードで分岐
        case command.code
        when 16  # 下を向く
          turn_down
        when 17  # 左を向く
          turn_left
        when 18  # 右を向く
          turn_right
        when 19  # 上を向く
          turn_up
        when 20  # 右に 90 度回転
          turn_right_90
        when 21  # 左に 90 度回転
          turn_left_90
        when 22  # 180 度回転
          turn_180
        when 23  # 右か左に 90 度回転
          turn_right_or_left_90
        when 24  # ランダムに方向転換
          turn_random
        when 25  # プレイヤーの方を向く
          turn_toward_player
        when 26  # プレイヤーの逆を向く
          turn_away_from_player
        end
        @move_route_index += 1
        return
      end
      # その他のコマンドの場合
      if command.code >= 27
        # コマンドコードで分岐
        case command.code
        when 27  # スイッチ ON
          $game_switches[command.parameters[0]] = true
          $game_map.need_refresh = true
        when 28  # スイッチ OFF
          $game_switches[command.parameters[0]] = false
          $game_map.need_refresh = true
        when 29  # 移動速度の変更
          @move_speed = command.parameters[0]
        when 30  # 移動頻度の変更
          @move_frequency = command.parameters[0]
        when 31  # 移動時アニメ ON
          @walk_anime = true
        when 32  # 移動時アニメ OFF
          @walk_anime = false
        when 33  # 停止時アニメ ON
          @step_anime = true
        when 34  # 停止時アニメ OFF
          @step_anime = false
        when 35  # 向き固定 ON
          @direction_fix = true
        when 36  # 向き固定 OFF
          @direction_fix = false
        when 37  # すり抜け ON
          @through = true
        when 38  # すり抜け OFF
          @through = false
        when 39  # 最前面に表示 ON
          @always_on_top = true
        when 40  # 最前面に表示 OFF
          @always_on_top = false
        when 41  # グラフィック変更
          @tile_id = 0
          @character_name = command.parameters[0]
          @character_hue = command.parameters[1]
          if @original_direction != command.parameters[2]
            @direction = command.parameters[2]
            @original_direction = @direction
            @prelock_direction = 0
          end
          if @original_pattern != command.parameters[3]
            @pattern = command.parameters[3]
            @original_pattern = @pattern
          end
        when 42  # 不透明度の変更
          @opacity = command.parameters[0]
        when 43  # 合成方法の変更
          @blend_type = command.parameters[0]
        when 44  # SE の演奏
          $game_system.se_play(command.parameters[0])
        when 45  # スクリプト
          result = eval(command.parameters[0])
        end
        @move_route_index += 1
        return
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 下に移動
  #--------------------------------------------------------------------------
  def move_down_p
    # 下を向く
    turn_down
    # 移動距離を算出
    distance = 2 ** @move_speed
    down1(((@x * 128 + @revise_x) / 128.0).round,
          ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  end
  #--------------------------------------------------------------------------
  # ● 下に移動可能かどうかの判定1
  #--------------------------------------------------------------------------
  def down1(x, y, distance, down = false)
    result = down2(x, y, distance)
    if result == false
      @event_run = check_event_trigger_touch(x, y+1)
      return result
    end
    if @revise_x < -SIDE
      result = down2(x, y + 1, distance, 4)
      result &= down2(x - 1, y, distance)
      if result == false
        if down
          move_lower_right_p
          if @revise_x > SIDE
            @revise_x = SIDE
          end
        end
        return result
      end
    elsif @revise_x > SIDE
      result = down2(x, y + 1, distance, 6)
      result &= down2(x + 1, y, distance)
      if result == false
        if down
          move_lower_left_p
          if @revise_x < -SIDE
            @revise_x = -SIDE
          end
        end
        return result
      end
    end
    # 下に移動可能ならば距離分移動
    @revise_y += distance
    return result
  end
  #--------------------------------------------------------------------------
  # ● 下に移動可能かどうかの判定2
  #--------------------------------------------------------------------------
  def down2(x, y, distance, d = 2)
    if @revise_y + distance > DOWN
      unless passable?(x, y, d)
        if @revise_y < DOWN
          @revise_y = DOWN
        end
        return false
      end
    end
    return true
  end
  #--------------------------------------------------------------------------
  # ● 左に移動
  #--------------------------------------------------------------------------
  def move_left_p
    # 左を向く
    turn_left
    distance = 2 ** @move_speed
    left1(((@x * 128 + @revise_x) / 128.0).round,
          ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  end
  #--------------------------------------------------------------------------
  # ● 左に移動可能かどうかの判定1
  #--------------------------------------------------------------------------
  def left1(x, y, distance, left = false)
    result = left2(x, y, distance)
    if result == false
      @event_run = check_event_trigger_touch(x-1, y)
      return result
    end
    if @revise_y < -UP
      result = left2(x - 1, y, distance, 8)
      result &= left2(x, y - 1, distance)
      if result == false
        if left
          move_lower_left_p
          if @revise_y > DOWN
            @revise_y = DOWN
          end
        end
        return result
      end
    elsif @revise_y > DOWN
      result = left2(x - 1, y, distance, 2)
      result &= left2(x, y + 1, distance)
      if result == false
        if left
   


我用了以后就一个效果,
是八方向了,
但怎么有两个人在一起呢。。。?
作者: 越前リョーマ    时间: 2007-7-10 02:26
脚本下部分,因为字太多了~
       move_upper_left_p
          if @revise_y < -UP
            @revise_y = -UP
          end
        end
        return result
      end
    end
    @revise_x -= distance
    return result
  end
  #--------------------------------------------------------------------------
  # ● 左に移動可能かどうかの判定2
  #--------------------------------------------------------------------------
  def left2(x, y, distance, d = 4)
    if @revise_x - distance < -SIDE
      unless passable?(x, y, d)
        if @revise_x > -SIDE
          @revise_x = -SIDE
        end
        return false
      end
    end
    return true
  end
  #--------------------------------------------------------------------------
  # ● 右に移動
  #--------------------------------------------------------------------------
  def move_right_p
      # 右を向く
      turn_right
    distance = 2 ** @move_speed
    right1(((@x * 128 + @revise_x) / 128.0).round,
            ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  end
  #--------------------------------------------------------------------------
  # ● 右に移動可能かどうかの判定1
  #--------------------------------------------------------------------------
  def right1(x, y, distance, right = false)
    result = right2(x, y, distance)
    if result == false
      @event_run = check_event_trigger_touch(x+1, y)
      return result
    end
    if @revise_y < -UP
      result = right2(x + 1, y, distance, 8)
      result &= right2(x, y - 1, distance)
      if result == false
        if right
          move_lower_right_p
          if @revise_y > DOWN
            @revise_y = DOWN
          end
        end
        return result
      end
    elsif @revise_y > DOWN
      result = right2(x + 1, y, distance, 2)
      result &= right2(x, y + 1, distance)
      if result == false
        if right
          move_upper_right_p
          if @revise_y < -UP
            @revise_y = -UP
          end
        end
        return result
      end
    end
    @revise_x += distance
    return result
  end
  #--------------------------------------------------------------------------
  # ● 右に移動可能かどうかの判定2
  #--------------------------------------------------------------------------
  def right2(x, y, distance, d = 6)
    if @revise_x + distance > SIDE
      unless passable?(x, y, d)
        if @revise_x < SIDE
          @revise_x = SIDE
        end
        return false
      end
    end
    return true
  end
  #--------------------------------------------------------------------------
  # ● 上に移動
  #--------------------------------------------------------------------------
  def move_up_p
    # 上を向く
    turn_up
    # 下に移動
    distance = 2 ** @move_speed
    up1(((@x * 128 + @revise_x) / 128.0).round,
        ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  end
  #--------------------------------------------------------------------------
  # ● 上に移動可能かどうかの判定1
  #--------------------------------------------------------------------------
  def up1(x, y, distance, up = false)
    result = up2(x, y, distance)
    if result == false
      @event_run = check_event_trigger_touch(x, y-1)
      return result
    end
    if @revise_x < -SIDE
      result = up2(x, y - 1, distance, 4)
      result &= up2(x - 1, y, distance)
      if result == false
        if up
          move_upper_right_p
          if @revise_x > SIDE
            @revise_x = SIDE
          end
        end
        return result
      end
    elsif @revise_x > SIDE
      result = up2(x, y - 1, distance, 6)
      result &= up2(x + 1, y, distance)
      if result == false
        if up
          move_upper_left_p
          if @revise_x < -SIDE
            @revise_x = -SIDE
          end
        end
        return result
      end
    end
    @revise_y -= distance
    return result
  end
  #--------------------------------------------------------------------------
  # ● 上に移動可能かどうかの判定2
  #--------------------------------------------------------------------------
  def up2(x, y, distance, d = 8)
    if @revise_y - distance < -UP
      unless passable?(x, y, d)
        if @revise_y > -UP
          @revise_y = -UP
        end
        return false
      end
    end
    return true
  end
  #--------------------------------------------------------------------------
  # ● 左下に移動
  #--------------------------------------------------------------------------
  def move_lower_left_p
    # 向き固定でない場合
    unless @direction_fix
      # 右向きだった場合は左を、上向きだった場合は下を向く
      @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
    end
    # 左下に移動
    distance = (2 ** @move_speed) / Math.sqrt(2)
    if @direction == 2
      turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
                              ((@y * 128 + @revise_y) / 128.0).round, distance)
      turn_down if @event_run
      unless @event_run
        if last_move?(@real_x, @real_y, 2, distance)
          result = check_event_trigger_here([1,2], false)
          if result == true
            return
          end
        end
        move_on
        if @revise_y > DOWN and -UP > @revise_y - distance
          @revise_y = DOWN
        end
        turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
                              ((@y * 128 + @revise_y) / 128.0).round, distance)
        turn_left if @event_run
      end
    else
      turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
                              ((@y * 128 + @revise_y) / 128.0).round, distance)
      turn_left if @event_run
      unless @event_run
        if last_move?(@real_x, @real_y, 4, distance)
          result = check_event_trigger_here([1,2], false)
          if result == true
            return
          end
        end
        move_on
        if  @revise_x + distance> SIDE and -SIDE > @revise_x
          @revise_x = -SIDE
        end
        turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
                              ((@y * 128 + @revise_y) / 128.0).round, distance)
        turn_down if @event_run
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 右下に移動
  #--------------------------------------------------------------------------
  def move_lower_right_p
    # 向き固定でない場合
    unless @direction_fix
      # 左向きだった場合は右を、上向きだった場合は下を向く
      @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
    end
    # 右下に移動
    distance = (2 ** @move_speed) / Math.sqrt(2)
    if @direction == 2
      turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
                              ((@y * 128 + @revise_y) / 128.0).round, distance)
      turn_down if @event_run
      unless @event_run
        if last_move?(@real_x, @real_y, 2, distance)
          result = check_event_trigger_here([1,2], false)
          if result == true
            return
          end
        end
        move_on
        if @revise_y > DOWN and -UP > @revise_y - distance
          @revise_y = DOWN
        end
        turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
                              ((@y * 128 + @revise_y) / 128.0).round, distance)
        turn_right if @event_run
      end
    else
      turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
                              ((@y * 128 + @revise_y) / 128.0).round, distance)
      turn_right if @event_run
      unless @event_run
        if last_move?(@real_x, @real_y, 6, distance)
          result = check_event_trigger_here([1,2], false)
          if result == true
            return
          end
        end
        move_on
        if @revise_x > SIDE and -SIDE > @revise_x - distance
          @revise_x = SIDE
        end
        turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
                              ((@y * 128 + @revise_y) / 128.0).round, distance)
        turn_down if @event_run
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 左上に移動
  #--------------------------------------------------------------------------
  def move_upper_left_p
    # 向き固定でない場合
    unless @direction_fix
      # 右向きだった場合は左を、下向きだった場合は上を向く
      @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
    end
    # 左上に移動
    distance = (2 ** @move_speed) / Math.sqrt(2)
    if @direction == 8
      turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
                            ((@y * 128 + @revise_y) / 128.0).round, distance)
      turn_up if @event_run
      unless @event_run
        if last_move?(@real_x, @real_y, 8, distance)
          result = check_event_trigger_here([1,2], false)
          if result == true
            return
          end
        end
        move_on
        if @revise_y + distance > DOWN and -UP > @revise_y
          @revise_y = -UP
        end
        turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
                              ((@y * 128 + @revise_y) / 128.0).round, distance)
        turn_left if @event_run
      end
    else
      turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
                            ((@y * 128 + @revise_y) / 128.0).round, distance)
      turn_left if @event_run
      unless @event_run
        if last_move?(@real_x, @real_y, 4, distance)
          result = check_event_trigger_here([1,2], false)
          if result == true
            return
          end
        end
        move_on
        if @revise_x > SIDE and -SIDE > @revise_x - distance
          @revise_x = SIDE
        end
        turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
                              ((@y * 128 + @revise_y) / 128.0).round, distance)
        turn_up if @event_run
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 右上に移動
  #--------------------------------------------------------------------------
  def move_upper_right_p
    # 向き固定でない場合
    unless @direction_fix
      # 左向きだった場合は右を、下向きだった場合は上を向く
      @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
    end
    # 右上に移動
    distance = (2 ** @move_speed) / Math.sqrt(2)
    if @direction == 8
      turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
                            ((@y * 128 + @revise_y) / 128.0).round, distance)
      turn_up if @event_run
      unless @event_run
        if last_move?(@real_x, @real_y, 8, distance)
          result = check_event_trigger_here([1,2], false)
          if result == true
            return
          end
        end
        move_on
        if @revise_y + distance > DOWN and -UP > @revise_y
          @revise_y = -UP
        end
        turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
                              ((@y * 128 + @revise_y) / 128.0).round, distance)
        turn_right if @event_run
      end
    else
      turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
                            ((@y * 128 + @revise_y) / 128.0).round, distance)
      turn_right if @event_run
      unless @event_run
        if last_move?(@real_x, @real_y, 6, distance)
          result = check_event_trigger_here([1,2], false)
          if result == true
            return
          end
        end
        move_on
        if @revise_x > SIDE and -SIDE > @revise_x - distance
          @revise_x = SIDE
        end
        turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
                              ((@y * 128 + @revise_y) / 128.0).round, distance)
        turn_up if @event_run
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 同位置のイベント起動判定
  #--------------------------------------------------------------------------
  def check_event_trigger_here(triggers, run = true)
    result = false
    # イベント実行中の場合
    if $game_system.map_interpreter.running?
      return result
    end
    # 全イベントのループ
    for event in $game_map.events.values
      # イベントの座標とトリガーが一致した場合
      if event.x == ((@x * 128 + @revise_x) / 128.0).round and
          event.y == ((@y * 128 + @revise_y) / 128.0).round and
          triggers.include?(event.trigger)
        # ジャンプ中以外で、起動判定が同位置のイベントなら
        if not event.jumping? and event.over_trigger?
          if event.list.size > 1
            if run == true
              event.start
            end
            result = true
          end
        end
      end
    end
    return result
  end
  #--------------------------------------------------------------------------
  # ● 座標修正
  #--------------------------------------------------------------------------
  def move_on
    if @y < (@y + @revise_y / 128.0).round
      @y += 1
      @revise_y -= 128
    end
    if @x > (@x + @revise_x / 128.0).round
      @x -= 1
      @revise_x += 128
    end
    if @x < (@x + @revise_x / 128.0).round
      @x += 1
      @revise_x -= 128
    end
    if @y > (@y + @revise_y / 128.0).round
      @y -= 1
      @revise_y += 128
    end
  end
  #--------------------------------------------------------------------------
  # ● アニメーションアップデート
  #--------------------------------------------------------------------------
  def anime_update
    # 移動時アニメが ON の場合
    if @walk_anime
      # アニメカウントを 1.5 増やす
      @anime_count += 1.5
    # 移動時アニメが OFF で、停止時アニメが ON の場合
    elsif @step_anime
      # アニメカウントを 1 増やす
      @anime_count += 1
    end
    # アニメカウントが最大値を超えた場合
    # ※最大値は、基本値 18 から移動速度 * 1 を引いた値
    if @anime_count > 18 - @move_speed * 2
      # 停止時アニメが OFF かつ 停止中の場合
      if not @step_anime and @stop_count > 0
        # パターンをオリジナルに戻す
        @pattern = @original_pattern
      # 停止時アニメが ON または 移動中の場合
      else
        # パターンを更新
        @pattern = (@pattern + 1) % 4
      end
      # アニメカウントをクリア
      @anime_count = 0
    end
  end
  #--------------------------------------------------------------------------
  # ● 指定位置に移動
  #--------------------------------------------------------------------------
  # オリジナルのイベントを改名
  alias :moveto_original :moveto
  def moveto(x, y)
    # 補正座標を初期化
    @revise_x = 0
    @revise_y = 0
    # オリジナルのイベントを呼び出し
    moveto_original(x, y)
  end
  #--------------------------------------------------------------------------
  # ● 移動したかどうかの判定
  #--------------------------------------------------------------------------
  def last_move?(x, y, direction, distance)
    if direction == 2 or direction == 6
      distance *= -1
    end
    if (direction == 2 or direction == 8) and
        (y / 128.0).round != ((y - distance) / 128.0).round
      return true
    end
    if (direction == 4 or direction == 6) and
        (x / 128.0).round != ((x - distance) / 128.0).round
      return true
    end
    return false
  end
end

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

class Game_Character
  #--------------------------------------------------------------------------
  # ● フレーム更新 (移動)
  #--------------------------------------------------------------------------
  def update_move
    # 移動速度からマップ座標系での移動距離に変換
    distance = 2 ** @move_speed
    if @x * 128 != @real_x and @y * 128 != @real_y and Game_Player::SLANT
      distance /= Math.sqrt(2)
    end
    # 論理座標が実座標より下の場合
    if @y * 128 > @real_y
      # 下に移動
      @real_y = [@real_y + distance, @y * 128].min
    end
    # 論理座標が実座標より左の場合
    if @x * 128 < @real_x
      # 左に移動
      @real_x = [@real_x - distance, @x * 128].max
    end
    # 論理座標が実座標より右の場合
    if @x * 128 > @real_x
      # 右に移動
      @real_x = [@real_x + distance, @x * 128].min
    end
    # 論理座標が実座標より上の場合
    if @y * 128 < @real_y
      # 上に移動
      @real_y = [@real_y - distance, @y * 128].max
    end
    # 移動時アニメが ON の場合
    if @walk_anime
      # アニメカウントを 1.5 増やす
      @anime_count += 1.5
    # 移動時アニメが OFF で、停止時アニメが ON の場合
    elsif @step_anime
      # アニメカウントを 1 増やす
      @anime_count += 1
    end
  end
end

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

class Game_Event < Game_Character
  #--------------------------------------------------------------------------
  # ● イベント起動
  #--------------------------------------------------------------------------
  def start
    # 実行内容が空でない場合
    if @list.size > 1
      # $game_player.event が0でない場合
      if $game_player.event != 0
        # 移動速度を $game_player.event にする
        $game_player.move_speed = $game_player.event
      end
      @starting = true
    end
  end
end

#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================

作者: 哦几三    时间: 2007-7-10 02:45
提示: 作者被禁止或删除 内容自动屏蔽
作者: 越前リョーマ    时间: 2007-7-10 02:56
行走图就是洋娃娃的8方向的RO行走图啊……{/gg}
作者: 绝望    时间: 2007-7-10 07:46
提示: 作者被禁止或删除 内容自动屏蔽
作者: 越前リョーマ    时间: 2007-7-10 19:21
弄了半天,

也没人能解决这是什么问题啊……
作者: 梦境游魂    时间: 2007-7-11 02:00
原因很简单,在class Sprite_Character中行走图的显示方式还是四方向的,要改一下
  1.         self.bitmap = RPG::Cache.character(@character.character_name,
  2.           @character.character_hue)
  3.         @cw = bitmap.width / 4
  4.         @ch = bitmap.height / 4
  5.         self.ox = @cw / 2
  6.         self.oy = @ch
  7.       end
  8.     end
复制代码

改成
  1.         self.bitmap = RPG::Cache.character(@character.character_name,
  2.           @character.character_hue)
  3.         @cw = bitmap.width / 4
  4.         @ch = bitmap.height / 8
  5.         self.ox = @cw / 2
  6.         self.oy = @ch
  7.       end
  8.     end
复制代码

就行了!
作者: 越前リョーマ    时间: 2007-7-11 02:18
我去试试……
作者: 越前リョーマ    时间: 2007-7-11 02:22
OK~

谢谢啦!
作者: 越前リョーマ    时间: 2007-7-11 02:23
不过改了以后……

只有四个面……
作者: 梦境游魂    时间: 2007-7-11 02:33
那就再把
  1. case @character.direction
  2.        when 2
  3.          sy = 0 * @ch
  4.        when 4
  5.          sy = 1 * @ch
  6.        when 6
  7.          sy = 2 * @ch
  8.        when 8
  9.          sy = 3 * @ch
  10.        when 1
  11.          sy = 4 * @ch
  12.        when 3
  13.          sy = 5 * @ch
  14.        when 7
  15.          sy = 6 * @ch
  16.        when 9
  17.          sy = 7 * @ch
  18.        end
复制代码

加到
  1. if @tile_id == 0
  2.      # 设置传送目标的矩形
  3.      sx = @character.pattern * @cw
复制代码

后面
作者: 越前リョーマ    时间: 2007-7-11 02:51
还是一样……
作者: 梦境游魂    时间: 2007-7-11 04:04
知道了,少了一个人物跟随脚本
  1. # ————————————————————————————————————

  2. # ▼▲▼ XRXS13. パーティ列車移動 ver.1.02 ▼▲▼
  3. #
  4. # Train_Actor
  5. #
  6. #

  7. module Train_Actor




  8. #是否使用停止跟随的方法,也就是说,这里false改为true的时候,如果TRANSPARENT_SWITCHES_INDEX
  9. #开关打开,跟随的人物就消失了(其实只是变成透明而已)
  10. TRANSPARENT_SWITCH = false
  11. TRANSPARENT_SWITCHES_INDEX = 20
  12. #举例:第一个为true,第二个为20,则打开20号开关,后面的人都没了。





  13. #跟随人数的最大数目,可以更改为2、3什么的。
  14. TRAIN_ACTOR_SIZE_MAX = 4





  15. # 定数
  16. #Input::DOWN = 2
  17. #Input::LEFT = 4
  18. #Input::RIGHT = 6
  19. #Input::UP = 6
  20. DOWN_LEFT = 1
  21. DOWN_RIGHT = 3
  22. UP_LEFT = 7
  23. UP_RIGHT = 9
  24. JUMP = 5
  25. #==============================================================================
  26. # ■ Game_Party_Actor
  27. #------------------------------------------------------------------------------
  28. #  
  29. #==============================================================================
  30. class Game_Party_Actor < Game_Character
  31. def initialize
  32.   super()
  33.   @through = true
  34. end
  35. def setup(actor)
  36.   # キャラクターのファイル名と色相を設定
  37.   if actor != nil
  38.     @character_name = actor.character_name
  39.     @character_hue = actor.character_hue
  40.   else
  41.     @character_name = ""
  42.     @character_hue = 0
  43.   end
  44.   # 不透明度と合成方法を初期化
  45.   @opacity = 255
  46.   @blend_type = 0
  47. end
  48. def screen_z(height = 0)
  49.   if $game_player.x == @x and $game_player.y == @y
  50.     return $game_player.screen_z(height) - 1
  51.   end
  52.   super(height)
  53. end
  54. #--------------------------------------------------------------------------
  55. # ● 下に移動
  56. # turn_enabled : その場での向き変更を許可するフラグ
  57. #--------------------------------------------------------------------------
  58. def move_down(turn_enabled = true)
  59.   # 下を向く
  60.   if turn_enabled
  61.     turn_down
  62.   end
  63.   # 通行可能な場合
  64.   if passable?(@x, @y, Input::DOWN)
  65.     # 下を向く
  66.     turn_down
  67.     # 座標を更新
  68.     @y += 1
  69.     increase_steps
  70.   end
  71. end
  72. #--------------------------------------------------------------------------
  73. # ● 左に移動
  74. # turn_enabled : その場での向き変更を許可するフラグ
  75. #--------------------------------------------------------------------------
  76. def move_left(turn_enabled = true)
  77.   # 左を向く
  78.   if turn_enabled
  79.     turn_left
  80.   end
  81.   # 通行可能な場合
  82.   if passable?(@x, @y, Input::LEFT)
  83.     # 左を向く
  84.     turn_left
  85.     # 座標を更新
  86.     @x -= 1
  87.     increase_steps
  88.   end
  89. end
  90. #--------------------------------------------------------------------------
  91. # ● 右に移動
  92. # turn_enabled : その場での向き変更を許可するフラグ
  93. #--------------------------------------------------------------------------
  94. def move_right(turn_enabled = true)
  95.   # 右を向く
  96.   if turn_enabled
  97.     turn_right
  98.   end
  99.   # 通行可能な場合
  100.   if passable?(@x, @y, Input::RIGHT)
  101.     # 右を向く
  102.     turn_right
  103.     # 座標を更新
  104.     @x += 1
  105.     increase_steps
  106.   end
  107. end
  108. #--------------------------------------------------------------------------
  109. # ● 上に移動
  110. # turn_enabled : その場での向き変更を許可するフラグ
  111. #--------------------------------------------------------------------------
  112. def move_up(turn_enabled = true)
  113.   # 上を向く
  114.   if turn_enabled
  115.     turn_up
  116.   end
  117.   # 通行可能な場合
  118.   if passable?(@x, @y, Input::UP)
  119.     # 上を向く
  120.     turn_up
  121.     # 座標を更新
  122.     @y -= 1
  123.     increase_steps
  124.   end
  125. end
  126. #--------------------------------------------------------------------------
  127. # ● 左下に移動
  128. #--------------------------------------------------------------------------
  129. def move_lower_left
  130.   # 向き固定でない場合
  131.   unless @direction_fix
  132.     # 右向きだった場合は左を、上向きだった場合は下を向く
  133.     @direction = 1
  134.   end
  135.   # 下→左、左→下 のどちらかのコースが通行可能な場合
  136.   if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
  137.      (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
  138.     # 座標を更新
  139.     @x -= 1
  140.     @y += 1
  141.     increase_steps
  142.   end
  143. end
  144. #--------------------------------------------------------------------------
  145. # ● 右下に移動
  146. #--------------------------------------------------------------------------
  147. def move_lower_right
  148.   # 向き固定でない場合
  149.   unless @direction_fix
  150.     # 左向きだった場合は右を、上向きだった場合は下を向く
  151.     @direction = 3
  152.   end
  153.   # 下→右、右→下 のどちらかのコースが通行可能な場合
  154.   if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
  155.      (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
  156.     # 座標を更新
  157.     @x += 1
  158.     @y += 1
  159.     increase_steps
  160.   elsif passable?(@x, @y, Input::DOWN)
  161.     @direction = 2
  162.     @y += 1
  163.     increase_steps
  164.   elsif passable?(@x, @y, Input::RIGHT)
  165.     @direction = 6
  166.     @x += 1
  167.     increase_steps
  168.   end
  169. end
  170. #--------------------------------------------------------------------------
  171. # ● 左上に移動
  172. #--------------------------------------------------------------------------
  173. def move_upper_left
  174.   # 向き固定でない場合
  175.   unless @direction_fix
  176.     # 右向きだった場合は左を、下向きだった場合は上を向く
  177.     @direction = 7
  178.   end
  179.   # 上→左、左→上 のどちらかのコースが通行可能な場合
  180.   if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
  181.      (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
  182.     # 座標を更新
  183.     @x -= 1
  184.     @y -= 1
  185.     increase_steps
  186.   end
  187. end
  188. #--------------------------------------------------------------------------
  189. # ● 右上に移動
  190. #--------------------------------------------------------------------------
  191. def move_upper_right
  192.   # 向き固定でない場合
  193.   unless @direction_fix
  194.     # 左向きだった場合は右を、下向きだった場合は上を向く
  195.     @direction = 9
  196.   end
  197.   # 上→右、右→上 のどちらかのコースが通行可能な場合
  198.   if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
  199.      (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
  200.     # 座標を更新
  201.     @x += 1
  202.     @y -= 1
  203.     increase_steps
  204.   end
  205. end
  206. attr_writer :move_speed
  207. attr_writer :step_anime
  208. end
  209. #==============================================================================
  210. # ■ Spriteset_Map_Module
  211. #------------------------------------------------------------------------------
  212. #  
  213. #==============================================================================
  214. module Spriteset_Map_Module
  215. def setup_actor_character_sprites?
  216.   return @setup_actor_character_sprites_flag != nil
  217. end
  218. def setup_actor_character_sprites(characters)
  219.   if !setup_actor_character_sprites?
  220.     index_game_player = 0
  221.     @character_sprites.each_index do |i|
  222.       if @character_sprites[i].character.instance_of?(Game_Player)
  223.         index_game_player = i
  224.         break
  225.       end
  226.     end
  227.     for character in characters.reverse
  228.       @character_sprites.unshift(
  229.        Sprite_Character.new(@viewport1, character)
  230.        )
  231.     end
  232.     @setup_actor_character_sprites_flag = true
  233.   end
  234. end
  235. end
  236. #==============================================================================
  237. # ■ Scene_Map_Module
  238. #------------------------------------------------------------------------------
  239. #  
  240. #==============================================================================
  241. module Scene_Map_Module
  242. def setup_actor_character_sprites(characters)
  243.   @spriteset.setup_actor_character_sprites(characters)
  244. end
  245. end
  246. #==============================================================================
  247. # ■ Game_Party_Module
  248. #------------------------------------------------------------------------------
  249. #  
  250. #==============================================================================
  251. module Game_Party_Module
  252. def return_char(i)
  253. return @characters[i]
  254. end
  255. def set_transparent_actors(transparent)
  256.   @transparent = transparent
  257. end
  258. def setup_actor_character_sprites
  259.   if @characters == nil
  260.     @characters = []
  261.     for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  262.       @characters.push(Game_Party_Actor.new)
  263.     end
  264.   end
  265.   for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  266.     @characters[i - 1].setup(actors[i])
  267.   end
  268.   if $scene.class.method_defined?('setup_actor_character_sprites')
  269.     $scene.setup_actor_character_sprites(@characters)
  270.   end
  271. end
  272. def update_party_actors
  273.   setup_actor_character_sprites
  274.   transparent = $game_player.transparent
  275.   if transparent == false
  276.     if TRANSPARENT_SWITCH
  277.       transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX]
  278.     end
  279.   end
  280.   for character in @characters
  281.     character.transparent = transparent
  282.     character.move_speed = $game_player.move_speed
  283.     character.update
  284.   end
  285. end
  286. def moveto_party_actors( x, y )
  287.   setup_actor_character_sprites
  288.   for character in @characters
  289.     character.moveto( x, y )
  290.   end
  291.   if @move_list == nil
  292.     @move_list = []
  293.   end
  294.   move_list_setup
  295. end
  296. def move_party_actors
  297.   if @move_list == nil
  298.     @move_list = []
  299.     move_list_setup
  300.   end
  301.   @move_list.each_index do |i|
  302.   if @characters[i] != nil
  303.     case @move_list[i].type
  304.     when Input::DOWN
  305.       @characters[i].move_down(@move_list[i].args[0])
  306.     when Input::LEFT
  307.       @characters[i].move_left(@move_list[i].args[0])
  308.     when Input::RIGHT
  309.       @characters[i].move_right(@move_list[i].args[0])
  310.     when Input::UP
  311.       @characters[i].move_up(@move_list[i].args[0])
  312.     when DOWN_LEFT
  313.       @characters[i].move_lower_left
  314.     when DOWN_RIGHT
  315.       @characters[i].move_lower_right
  316.     when UP_LEFT
  317.       @characters[i].move_upper_left
  318.     when UP_RIGHT
  319.       @characters[i].move_upper_right
  320.     when JUMP
  321.       @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1])
  322.     end
  323.   end
  324. end
  325. end
  326. #==============================================================================
  327. # ■ Move_List_Element
  328. #------------------------------------------------------------------------------
  329. #  
  330. #==============================================================================
  331. class Move_List_Element
  332.   def initialize(type,args)
  333.     @type = type
  334.     @args = args
  335.   end
  336.   def type()
  337.     return @type
  338.   end
  339.   def args()
  340.     return @args
  341.   end
  342. end
  343. def move_list_setup
  344.   for i in 0 .. TRAIN_ACTOR_SIZE_MAX
  345.     @move_list[i] = nil
  346.   end
  347. end
  348. def add_move_list(type,*args)
  349.   @move_list.unshift(Move_List_Element.new(type,args)).pop
  350. end
  351. def move_down_party_actors(turn_enabled = true)
  352.   move_party_actors
  353.   add_move_list(Input::DOWN,turn_enabled)
  354. end
  355. def move_left_party_actors(turn_enabled = true)
  356.   move_party_actors
  357.   add_move_list(Input::LEFT,turn_enabled)
  358. end
  359. def move_right_party_actors(turn_enabled = true)
  360.   move_party_actors
  361.   add_move_list(Input::RIGHT,turn_enabled)
  362. end
  363. def move_up_party_actors(turn_enabled = true)
  364.   move_party_actors
  365.   add_move_list(Input::UP,turn_enabled)
  366. end
  367. def move_lower_left_party_actors
  368.   move_party_actors
  369.   add_move_list(DOWN_LEFT)
  370. end
  371. def move_lower_right_party_actors
  372.   move_party_actors
  373.   add_move_list(DOWN_RIGHT)
  374. end
  375. def move_upper_left_party_actors
  376.   move_party_actors
  377.   add_move_list(UP_LEFT)
  378. end
  379. def move_upper_right_party_actors
  380.   move_party_actors
  381.   add_move_list(UP_RIGHT)
  382. end
  383. def jump_party_actors(x_plus, y_plus)
  384.   move_party_actors
  385.   add_move_list(JUMP,x_plus, y_plus)
  386. end
  387. end
  388. module Game_Player_Module
  389. def update
  390.   $game_party.update_party_actors
  391.   super
  392. end
  393. def moveto( x, y )
  394.   $game_party.moveto_party_actors( x, y )
  395.   super( x, y )
  396. end
  397. def move_down(turn_enabled = true)
  398.   if passable?(@x, @y, Input::DOWN)
  399.     $game_party.move_down_party_actors(turn_enabled)
  400.   #..........................................................................
  401.   elsif passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN) and
  402.         can_go?(@x, @y + 1)
  403.     @direction = 1
  404.     $game_party.move_lower_left_party_actors
  405.     increase_steps
  406.   elsif passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN) and
  407.         can_go?(@x, @y + 1)
  408.     @direction = 3
  409.     $game_party.move_lower_right_party_actors
  410.     increase_steps
  411.   #..........................................................................
  412.   end
  413.   super(turn_enabled)
  414. end
  415. def move_left(turn_enabled = true)
  416.   if passable?(@x, @y, Input::LEFT)
  417.     $game_party.move_left_party_actors(turn_enabled)
  418.   #..........................................................................
  419.   elsif passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT) and
  420.         can_go?(@x - 1, @y)
  421.     @direction = 7
  422.     $game_party.move_upper_left_party_actors
  423.     increase_steps
  424.   elsif passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT) and
  425.         can_go?(@x - 1, @y)
  426.     @direction = 1
  427.     $game_party.move_lower_left_party_actors
  428.     increase_steps
  429.   #..........................................................................
  430.   end
  431.   super(turn_enabled)
  432. end
  433. def move_right(turn_enabled = true)
  434.   if passable?(@x, @y, Input::RIGHT)
  435.     $game_party.move_right_party_actors(turn_enabled)
  436.   #..........................................................................
  437.   elsif passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT) and
  438.         can_go?(@x + 1, @y)
  439.     @direction = 9
  440.     $game_party.move_upper_right_party_actors
  441.     increase_steps
  442.   elsif passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT) and
  443.         can_go?(@x + 1, @y)
  444.     @direction = 3
  445.     $game_party.move_lower_right_party_actors
  446.     increase_steps
  447.   #..........................................................................
  448.   end
  449.   super(turn_enabled)
  450. end
  451. def move_up(turn_enabled = true)
  452.   if passable?(@x, @y, Input::UP)
  453.     $game_party.move_up_party_actors(turn_enabled)
  454.   #..........................................................................
  455.   elsif passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP) and
  456.         can_go?(@x, @y - 1)
  457.     @direction = 7
  458.     $game_party.move_upper_left_party_actors
  459.     increase_steps
  460.   elsif passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP) and
  461.         can_go?(@x, @y - 1)
  462.     @direction = 9
  463.     $game_party.move_upper_right_party_actors
  464.     increase_steps
  465.   #..........................................................................
  466.   end
  467.   super(turn_enabled)
  468. end
  469. def move_lower_left
  470.   # 下→左、左→下 のどちらかのコースが通行可能な場合
  471.   @direction = 1
  472.   if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
  473.      (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
  474.     $game_party.move_lower_left_party_actors
  475.     increase_steps
  476.   #..........................................................................
  477.   elsif passable?(@x, @y, Input::DOWN) and can_go?(@x - 1, @y + 1)
  478.     $game_party.move_down_party_actors
  479.     @direction = 2
  480.     increase_steps
  481.   elsif passable?(@x, @y, Input::LEFT) and can_go?(@x - 1, @y + 1)
  482.     $game_party.move_left_party_actors
  483.     @direction = 4
  484.     increase_steps
  485.   #..........................................................................
  486.   end
  487.   super
  488. end
  489. def move_lower_right
  490.   # 下→右、右→下 のどちらかのコースが通行可能な場合
  491.   @direction = 3
  492.   if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
  493.      (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
  494.     $game_party.move_lower_right_party_actors
  495.     increase_steps
  496.   #..........................................................................
  497.   elsif passable?(@x, @y, Input::DOWN) and can_go?(@x + 1, @y + 1)
  498.     $game_party.move_down_party_actors
  499.     @direction = 2
  500.     increase_steps
  501.   elsif passable?(@x, @y, Input::RIGHT) and can_go?(@x + 1, @y + 1)
  502.     $game_party.move_right_party_actors
  503.     @direction = 6
  504.     increase_steps
  505.   #..........................................................................
  506.   end
  507.   super
  508. end
  509. def move_upper_left
  510.   # 上→左、左→上 のどちらかのコースが通行可能な場合
  511.   @direction = 7
  512.   if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
  513.      (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
  514.     $game_party.move_upper_left_party_actors
  515.     increase_steps
  516.   #..........................................................................
  517.   elsif passable?(@x, @y, Input::UP) and can_go?(@x - 1, @y - 1)
  518.     $game_party.move_up_party_actors
  519.     @direction = 8
  520.     increase_steps
  521.   elsif passable?(@x, @y, Input::LEFT) and can_go?(@x - 1, @y - 1)
  522.     $game_party.move_left_party_actors
  523.     @direction = 4
  524.     increase_steps
  525.   #..........................................................................
  526.   end
  527.   super
  528. end
  529. def move_upper_right
  530.   # 上→右、右→上 のどちらかのコースが通行可能な場合
  531.   @direction = 9
  532.   if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
  533.      (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
  534.     $game_party.move_upper_right_party_actors
  535.     increase_steps
  536.   #..........................................................................
  537.   elsif passable?(@x, @y, Input::UP) and can_go?(@x + 1, @y - 1)
  538.     $game_party.move_up_party_actors
  539.     @direction = 8
  540.     increase_steps
  541.   elsif passable?(@x, @y, Input::RIGHT) and can_go?(@x + 1, @y - 1)
  542.     $game_party.move_right_party_actors
  543.     @direction = 6
  544.     increase_steps
  545.   #..........................................................................
  546.   end
  547.   super
  548. end
  549. def jump(x_plus, y_plus)
  550.   # 新しい座標を計算
  551.   new_x = @x + x_plus
  552.   new_y = @y + y_plus
  553.   # 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
  554.   if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
  555.     $game_party.jump_party_actors(x_plus, y_plus)
  556.   end
  557.   super(x_plus, y_plus)
  558. end
  559. attr_reader :move_speed
  560. attr_reader :step_anime
  561. end
  562. end # module Train_Actor
  563. #==============================================================================
  564. # ■ Game_Party
  565. #------------------------------------------------------------------------------
  566. #  
  567. #==============================================================================
  568. class Game_Party
  569.   include Train_Actor::Game_Party_Module
  570. end
  571. #==============================================================================
  572. # ■ Game_Player
  573. #------------------------------------------------------------------------------
  574. #  
  575. #==============================================================================
  576. class Game_Player
  577.   include Train_Actor::Game_Player_Module
  578. end
  579. #==============================================================================
  580. # ■ Spriteset_Map
  581. #------------------------------------------------------------------------------
  582. #  
  583. #==============================================================================
  584. class Spriteset_Map
  585.   include Train_Actor::Spriteset_Map_Module
  586. end
  587. #==============================================================================
  588. # ■ Scene_Map
  589. #------------------------------------------------------------------------------
  590. #  
  591. #==============================================================================
  592. class Scene_Map
  593.   include Train_Actor::Scene_Map_Module
  594. end

复制代码

作者: 梦境游魂    时间: 2007-7-11 04:11
顺便删掉      sy = (@character.direction - 2) / 2 * @ch
(此句在
  1.        case @character.direction
  2.        when 2
  3.          sy = 0 * @ch
  4.        when 4
  5.          sy = 1 * @ch
  6.        when 6
  7.          sy = 2 * @ch
  8.        when 8
  9.          sy = 3 * @ch
  10.        when 1
  11.          sy = 4 * @ch
  12.        when 3
  13.          sy = 5 * @ch
  14.        when 7
  15.          sy = 6 * @ch
  16.        when 9
  17.          sy = 7 * @ch
  18.        end
复制代码


作者: 越前リョーマ    时间: 2007-7-11 04:48
还是一个样……
作者: 梦境游魂    时间: 2007-7-11 19:58
实在不行的话你用这个脚本好啦,需要之前的人物跟随脚本
  1. ###########################################################################################################################
  2. # 脚本功能:八方向走与多帧移动之图片修正 + 人物跟随。

  3. # 更新日期:2005年8月6日

  4. # 更新内容:增加斜方向触发,增加斜方向面向角色(1步之内)

  5. # 使用方法:将本脚本插入到main之前。如果你使用了雅土版的八方向走脚本,请确保这个脚本的顺序位置,在雅土八方向走脚本的后面。

  6. # 预先处理:请输入每一步的帧数和总共可用的方向数

  7. $c3_每一步的帧数 = 8
  8. $c3_总共可用的方向数 = 8 #——建议不要修改这个。如果要伪8方向的,就用伪的好了。

  9. # 图片处理与功能说明:

  10. # 1、每一步的帧数:
  11. #    众所周知,RMXP的移动行走图是一个方向共有4帧,很多人都觉得这个帧数有点少。
  12. # 使用这个脚本之后,只要将 $c3_每一步的帧数 这个变量设置一个需要的帧数即可修改
  13. # 单方向移动帧数为相应输入值。修改后,需要用photoshop将所有用到的素材的横排
  14. # 调整为相应帧数,比如输入了8则要将每一行设置8个图像(即每一个行走图有8列)。

  15. # 2、可用方向调整(可用数量:4、8):
  16. #    当为4方向时没有任何变化,还是一个图4行,上左右下4个方向。
  17. #    如果想使用8方向走,将需要八方向行走的行走图在延伸扩大的画布中按照左下、右下、左上、右上继续排布图像。
  18. # 即,行走图图片从上到下的面向排列顺序为:下,左,右,上,左下,右下,左上,右上。
  19. #    至于不需要8方向走的普通的NPC(character),使用photoshop将画布向下扩大一倍即可使用。
  20. #    需要注意的是,如果需要斜方向飞鸟,请不要忘记自制素材。

  21. # 特别提示:   
  22. #     使用本脚本前请先考虑清楚是否要做这种效果。因为使用本脚本后需要用photoshop处理character行走图素材
  23. # 虽然这种处理用photoshop定义动作只需要5分钟即可全部完成,但在制作阶段会感觉不是很爽(具体的用了才知道)
  24. # 作者的建议是,如果你没有足够的制作经验,使用这个脚本得不偿失。请确保自己的能力属于“高手”级别!

  25. # 附赠功能:
  26. #     可以让NPC角色随机8方向走,方法是:NPC角色移动路线为“自定义”,然后自定义里面使用脚本,输入c8即可
  27. #     可以让NPC角色随机4斜角方向走,方法是:NPC角色移动路线为“自定义”,然后自定义里面使用脚本,输入c4即可
  28. #     可以使用真·斜4方向行走,参考脚本53行开始

  29. # 作者:carol3
  30. ###########################################################################################################################
  31. ###########################################################################################################################
  32. class Game_Character
  33.   def event_is_in?(x, y)
  34.     for event in $game_map.events.values
  35.       # 事件坐标与目标一致的情况下
  36.       if event.x == x and event.y == y
  37.         # 跳跃中以外的情况下、启动判定是同位置的事件
  38.         return true
  39.       end
  40.     end
  41.     return false
  42.   end
  43.   def player_is_in?(x, y)
  44.     if $game_player.x == x and $game_player.y == y
  45.       return true
  46.     end
  47.     return false
  48.   end
  49.   def can_go?(x, y)
  50.     if player_is_in?(x, y) or event_is_in?(x, y)
  51.       return false
  52.     else
  53.       return true
  54.     end
  55.   end
  56.   #--------------------------------------------------------------------------
  57.   # ● 向下移动
  58.   #     turn_enabled : 本场地位置更改许可标志
  59.   #--------------------------------------------------------------------------
  60.   def move_down(turn_enabled = true)
  61.     # 面向下
  62.     if turn_enabled
  63.       turn_down
  64.     end
  65.     # 可以通行的场合
  66.     if passable?(@x, @y, 2)
  67.       # 面向下
  68.       turn_down
  69.       # 更新坐标
  70.       @y += 1
  71.       # 增加步数
  72.       increase_steps
  73.     #..........................................................................
  74.     elsif passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN) and
  75.           can_go?(@x, @y + 1)
  76.       unless @direction_fix
  77.         @direction = 1
  78.       end
  79.       @x -= 1
  80.       @y += 1
  81.       increase_steps
  82.     elsif passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN) and
  83.           can_go?(@x, @y + 1)
  84.       unless @direction_fix
  85.         @direction = 3
  86.       end
  87.       @x += 1
  88.       @y += 1
  89.       increase_steps
  90.     #..........................................................................
  91.     # 不能通行的情况下
  92.     else
  93.       # 接触事件的启动判定
  94.       check_event_trigger_touch(@x, @y+1)
  95.     end
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # ● 向左移动
  99.   #     turn_enabled : 本场地位置更改许可标志
  100.   #--------------------------------------------------------------------------
  101.   def move_left(turn_enabled = true)
  102.     # 面向左
  103.     if turn_enabled
  104.       turn_left
  105.     end
  106.     # 可以通行的情况下
  107.     if passable?(@x, @y, 4)
  108.       # 面向左
  109.       turn_left
  110.       # 更新坐标
  111.       @x -= 1
  112.       # 增加步数
  113.       increase_steps
  114.     #..........................................................................
  115.     elsif passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT) and
  116.           can_go?(@x - 1, @y)
  117.       unless @direction_fix
  118.         @direction = 7
  119.       end
  120.       @x -= 1
  121.       @y -= 1
  122.       increase_steps
  123.     elsif passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT) and
  124.           can_go?(@x - 1, @y)
  125.       unless @direction_fix
  126.         @direction = 1
  127.       end
  128.       @x -= 1
  129.       @y += 1
  130.       increase_steps
  131.     #..........................................................................
  132.     # 不能通行的情况下
  133.     else
  134.       # 接触事件的启动判定
  135.       check_event_trigger_touch(@x-1, @y)
  136.     end
  137.   end
  138.   #--------------------------------------------------------------------------
  139.   # ● 向右移动
  140.   #     turn_enabled : 本场地位置更改许可标志
  141.   #--------------------------------------------------------------------------
  142.   def move_right(turn_enabled = true)
  143.     # 面向右
  144.     if turn_enabled
  145.       turn_right
  146.     end
  147.     # 可以通行的场合
  148.     if passable?(@x, @y, 6)
  149.       # 面向右
  150.       turn_right
  151.       # 更新坐标
  152.       @x += 1
  153.       # 增加部数
  154.       increase_steps
  155.     #..........................................................................
  156.     elsif passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT) and
  157.           can_go?(@x + 1, @y)
  158.       unless @direction_fix
  159.         @direction = 9
  160.       end
  161.       @x += 1
  162.       @y -= 1
  163.       increase_steps
  164.     elsif passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT) and
  165.           can_go?(@x + 1, @y)
  166.       unless @direction_fix
  167.         @direction = 3
  168.       end
  169.       @x += 1
  170.       @y += 1
  171.       increase_steps
  172.     #..........................................................................
  173.     # 不能通行的情况下
  174.     else
  175.       # 接触事件的启动判定
  176.       check_event_trigger_touch(@x+1, @y)
  177.     end
  178.   end
  179.   #--------------------------------------------------------------------------
  180.   # ● 向上移动
  181.   #     turn_enabled : 本场地位置更改许可标志
  182.   #--------------------------------------------------------------------------
  183.   def move_up(turn_enabled = true)
  184.     # 面向上
  185.     if turn_enabled
  186.       turn_up
  187.     end
  188.     # 可以通行的情况下
  189.     if passable?(@x, @y, 8)
  190.       # 面向上
  191.       turn_up
  192.       # 更新坐标
  193.       @y -= 1
  194.       # 歩数増加
  195.       increase_steps
  196.     #..........................................................................
  197.     elsif passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP) and
  198.           can_go?(@x, @y - 1)
  199.       unless @direction_fix
  200.         @direction = 7
  201.       end
  202.       @x -= 1
  203.       @y -= 1
  204.       increase_steps
  205.     elsif passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP) and
  206.           can_go?(@x, @y - 1)
  207.       unless @direction_fix
  208.         @direction = 9
  209.       end
  210.       @x += 1
  211.       @y -= 1
  212.       increase_steps
  213.     #..........................................................................
  214.     # 不能通行的情况下
  215.     else
  216.       # 接触事件的启动判定
  217.       check_event_trigger_touch(@x, @y-1)
  218.     end
  219.   end
  220.   #--------------------------------------------------------------------------
  221.   # ● 向左下移动
  222.   #--------------------------------------------------------------------------
  223.   def move_lower_left
  224.     # 没有固定面向的场合
  225.     unless @direction_fix
  226.       # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  227.       @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  228.     end
  229.     # 下→左、左→下 的通道可以通行的情况下
  230.     if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
  231.        (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
  232.       # 更新坐标
  233.       @x -= 1
  234.       @y += 1
  235.       # 增加步数
  236.       increase_steps
  237.     #..........................................................................
  238.     elsif passable?(@x, @y, Input::DOWN) and can_go?(@x - 1, @y + 1)
  239.       unless @direction_fix
  240.         @direction = 2
  241.       end
  242.       @y += 1
  243.       increase_steps
  244.     elsif passable?(@x, @y, Input::LEFT) and can_go?(@x - 1, @y + 1)
  245.       unless @direction_fix
  246.         @direction = 4
  247.       end
  248.       @x -= 1
  249.       increase_steps
  250.     #..........................................................................
  251.     end
  252.   end
  253.   #--------------------------------------------------------------------------
  254.   # ● 向右下移动
  255.   #--------------------------------------------------------------------------
  256.   def move_lower_right
  257.     # 没有固定面向的场合
  258.     unless @direction_fix
  259.       # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  260.       @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  261.     end
  262.     # 下→右、右→下 的通道可以通行的情况下
  263.     if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
  264.        (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
  265.       # 更新坐标
  266.       @x += 1
  267.       @y += 1
  268.       # 增加步数
  269.       increase_steps
  270.     elsif passable?(@x, @y, Input::DOWN) and can_go?(@x + 1, @y + 1)
  271.       unless @direction_fix
  272.         @direction = 2
  273.       end
  274.       @y += 1
  275.       increase_steps
  276.     elsif passable?(@x, @y, Input::RIGHT) and can_go?(@x + 1, @y + 1)
  277.       unless @direction_fix
  278.         @direction = 6
  279.       end
  280.       @x += 1
  281.       increase_steps
  282.     end
  283.   end
  284.   #--------------------------------------------------------------------------
  285.   # ● 向左上移动
  286.   #--------------------------------------------------------------------------
  287.   def move_upper_left
  288.     # 没有固定面向的场合
  289.     unless @direction_fix
  290.       # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  291.       @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  292.     end
  293.     # 上→左、左→上 的通道可以通行的情况下
  294.     if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
  295.        (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
  296.       # 更新坐标
  297.       @x -= 1
  298.       @y -= 1
  299.       # 增加步数
  300.       increase_steps
  301.     #..........................................................................
  302.     elsif passable?(@x, @y, Input::UP) and can_go?(@x - 1, @y - 1)
  303.       unless @direction_fix
  304.         @direction = 8
  305.       end
  306.       @y -= 1
  307.       increase_steps
  308.     elsif passable?(@x, @y, Input::LEFT) and can_go?(@x - 1, @y - 1)
  309.       unless @direction_fix
  310.         @direction = 4
  311.       end
  312.       @x -= 1
  313.       increase_steps
  314.     #..........................................................................
  315.     end
  316.   end
  317.   #--------------------------------------------------------------------------
  318.   # ● 向右上移动
  319.   #--------------------------------------------------------------------------
  320.   def move_upper_right
  321.     # 没有固定面向的场合
  322.     unless @direction_fix
  323.       # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  324.       @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  325.     end
  326.     # 上→右、右→上 的通道可以通行的情况下
  327.     if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
  328.        (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
  329.       # 更新坐标
  330.       @x += 1
  331.       @y -= 1
  332.       # 增加步数
  333.       increase_steps
  334.     #..........................................................................
  335.     elsif passable?(@x, @y, Input::UP) and can_go?(@x + 1, @y - 1)
  336.       unless @direction_fix
  337.         @direction = 8
  338.       end
  339.       @y -= 1
  340.       increase_steps
  341.     elsif passable?(@x, @y, Input::RIGHT) and can_go?(@x + 1, @y - 1)
  342.       unless @direction_fix
  343.         @direction = 6
  344.       end
  345.       @x += 1
  346.       increase_steps
  347.     #..........................................................................
  348.     end
  349.   end
  350. end



  351. class Game_Player < Game_Character
  352. if $c3_总共可用的方向数 == 8
  353.    def update
  354.      last_moving = moving?
  355.      unless moving? or $game_system.map_interpreter.running? or
  356.             @move_route_forcing or $game_temp.message_window_showing
  357.        # 用井号后面的东西替代前面的,就可以实现斜4方向走
  358.        case Input.dir8
  359.        when 2
  360.          move_down #move_lower_left
  361.        when 4
  362.          move_left #move_upper_left
  363.        when 6
  364.          move_right #move_lower_right
  365.        when 8
  366.          move_up #move_upper_right
  367.        when 1
  368.          move_lower_left
  369.        when 3
  370.          move_lower_right
  371.        when 7
  372.          move_upper_left
  373.        when 9
  374.          move_upper_right
  375.        end
  376.      end
  377.      # 本地变量记忆坐标
  378.      last_real_x = @real_x
  379.      last_real_y = @real_y
  380.      super
  381.      # 角色向下移动、画面上的位置在中央下方的情况下
  382.      if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  383.        # 画面向下卷动
  384.        $game_map.scroll_down(@real_y - last_real_y)
  385.      end
  386.      # 角色向左移动、画面上的位置在中央左方的情况下
  387.      if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  388.        # 画面向左卷动
  389.        $game_map.scroll_left(last_real_x - @real_x)
  390.      end
  391.      # 角色向右移动、画面上的位置在中央右方的情况下
  392.      if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  393.        # 画面向右卷动
  394.        $game_map.scroll_right(@real_x - last_real_x)
  395.      end
  396.      # 角色向上移动、画面上的位置在中央上方的情况下
  397.      if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  398.        # 画面向上卷动
  399.        $game_map.scroll_up(last_real_y - @real_y)
  400.      end
  401.      # 不在移动中的情况下
  402.      unless moving?
  403.        # 上次主角移动中的情况
  404.        if last_moving
  405.          # 与同位置的事件接触就判定为事件启动
  406.          result = check_event_trigger_here([1,2])
  407.          # 没有可以启动的事件的情况下
  408.          if result == false
  409.            # 调试模式为 ON 并且按下 CTRL 键的情况下除外
  410.            unless $DEBUG and Input.press?(Input::CTRL)
  411.              # 遇敌计数下降
  412.              if @encounter_count > 0
  413.                @encounter_count -= 1
  414.              end
  415.            end
  416.          end
  417.        end
  418.        # 按下 C 键的情况下
  419.        if Input.trigger?(Input::C)
  420.          # 判定为同位置以及正面的事件启动
  421.          check_event_trigger_here([0])
  422.          check_event_trigger_there([0,1,2])
  423.        end
  424.      end
  425.    end
  426.    #--------------------------------------------------------------------------
  427.    # ● 正面事件的启动判定
  428.    #--------------------------------------------------------------------------
  429.    def check_event_trigger_there(triggers)
  430.      result = false
  431.      # 事件执行中的情况下
  432.      if $game_system.map_interpreter.running?
  433.        return result
  434.      end
  435.      # 计算正面坐标
  436.      new_x = @x
  437.      new_y = @y
  438.      case @direction
  439.      when 1
  440.        new_x -= 1
  441.        new_y += 1
  442.      when 2
  443.        new_y += 1
  444.      when 3
  445.        new_x += 1
  446.        new_y += 1
  447.      when 4
  448.        new_x -= 1
  449.      when 6
  450.        new_x += 1
  451.      when 7
  452.        new_x -= 1
  453.        new_y -= 1
  454.      when 8
  455.        new_y -= 1
  456.      when 9
  457.        new_x += 1
  458.        new_y -= 1
  459.      end
  460.      # 全部事件的循环
  461.      for event in $game_map.events.values
  462.        # 事件坐标与目标一致的情况下
  463.        if event.x == new_x and event.y == new_y and
  464.           triggers.include?(event.trigger)
  465.          # 跳跃中以外的情况下、启动判定是正面的事件
  466.          if not event.jumping? and not event.over_trigger?
  467.            event.start
  468.            result = true
  469.          end
  470.        end
  471.      end
  472.      # 找不到符合条件的事件的情况下
  473.      if result == false
  474.        # 正面的元件是计数器的情况下
  475.        if $game_map.counter?(new_x, new_y)
  476.          # 计算 1 元件里侧的坐标
  477.          new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  478.          new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  479.          # 全事件的循环
  480.          for event in $game_map.events.values
  481.            # 事件坐标与目标一致的情况下
  482.            if event.x == new_x and event.y == new_y and
  483.               triggers.include?(event.trigger)
  484.              # 跳跃中以外的情况下、启动判定是正面的事件
  485.              if not event.jumping? and not event.over_trigger?
  486.                event.start
  487.                result = true
  488.              end
  489.            end
  490.          end
  491.        end
  492.      end
  493.      return result
  494.    end
  495. end
  496. end


  497. class Sprite_Character < RPG::Sprite
  498. def update
  499.    super
  500.    # 元件 ID、文件名、色相与现在的情况存在差异的情况下
  501.    if @tile_id != @character.tile_id or
  502.       @character_name != @character.character_name or
  503.       @character_hue != @character.character_hue
  504.      # 记忆元件 ID 与文件名、色相
  505.      @tile_id = @character.tile_id
  506.      @character_name = @character.character_name
  507.      @character_hue = @character.character_hue
  508.      # 元件 ID 为有效值的情况下
  509.      if @tile_id >= 384
  510.        self.bitmap = RPG::Cache.tile($game_map.tileset_name,
  511.          @tile_id, @character.character_hue)
  512.        self.src_rect.set(0, 0, 32, 32)
  513.        self.ox = 16
  514.        self.oy = 32
  515.      # 元件 ID 为无效值的情况下
  516.      else
  517.        self.bitmap = RPG::Cache.character(@character.character_name,
  518.          @character.character_hue)
  519.        @cw = bitmap.width / $c3_每一步的帧数
  520.        if $c3_总共可用的方向数==4
  521.          @ch = bitmap.height / 4
  522.        else
  523.          @ch = bitmap.height / 8
  524.        end
  525.        self.ox = @cw / 2
  526.        self.oy = @ch
  527.      end
  528.    end
  529.    # 设置可视状态
  530.    self.visible = (not @character.transparent)
  531.    # 图形是角色的情况下
  532.    if @tile_id == 0
  533.      # 设置传送目标的矩形
  534.      sx = @character.pattern * @cw
  535.      if $c3_总共可用的方向数==8
  536.        case @character.direction
  537.        when 2
  538.          sy = 0 * @ch
  539.        when 4
  540.          sy = 1 * @ch
  541.        when 6
  542.          sy = 2 * @ch
  543.        when 8
  544.          sy = 3 * @ch
  545.        when 1
  546.          sy = 4 * @ch
  547.        when 3
  548.          sy = 5 * @ch
  549.        when 7
  550.          sy = 6 * @ch
  551.        when 9
  552.          sy = 7 * @ch
  553.        end
  554.      else
  555.        sy = (@character.direction - 2) / 2 * @ch
  556.      end
  557.      self.src_rect.set(sx, sy, @cw, @ch)
  558.    end
  559.    # 设置脚本的坐标
  560.    self.x = @character.screen_x
  561.    self.y = @character.screen_y
  562.    self.z = @character.screen_z(@ch)
  563.    # 设置不透明度、合成方式、茂密
  564.    self.opacity = @character.opacity
  565.    self.blend_type = @character.blend_type
  566.    self.bush_depth = @character.bush_depth
  567.    # 动画
  568.    if @character.animation_id != 0
  569.      animation = $data_animations[@character.animation_id]
  570.      animation(animation, true)
  571.      @character.animation_id = 0
  572.    end
  573.    #####################################################################
  574.    #id = $game_map.map_id
  575.    #name = $data_mapinfos[id].name
  576.    #if name.include?("★")
  577.    #  rage = name.split(/★/)[1]
  578.    #  min_rate = rage.split(/~/)[0].to_f
  579.    #  max_rate = rage.split(/~/)[1].to_f
  580.    #  rate =  min_rate + (@character.y.to_f / $game_map.height.to_f * (max_rate - min_rate))
  581.    #  self.zoom_x = self.zoom_y = rate
  582.    #  if @character.character_name.include?("★★")
  583.    #    self.zoom_x = self.zoom_y = 1
  584.    #  end
  585.    #end
  586.    ####################################################################
  587. end
  588. end

  589. class Game_Character
  590. def c8
  591.    # 随机 0~5 的分支
  592.    case rand(10)
  593.    when 0..3  # 随机
  594.      move_random
  595.    when 4  # 前进一步
  596.      move_forward
  597.    when 5  # 暂时停止
  598.      @stop_count = 0
  599.    when 6..9  #另外4方向随机
  600.      c4
  601.    end
  602. end
  603. def c4
  604.    case rand(5)
  605.    when 0
  606.      move_upper_left
  607.      @direction = 7
  608.    when 1
  609.      move_upper_right
  610.      @direction = 9
  611.    when 2
  612.      move_lower_left
  613.      @direction = 1
  614.    when 3
  615.      move_lower_right
  616.      @direction = 3
  617.    when 4
  618.      @stop_count = 0
  619.    end
  620. end
  621.      
  622. def update
  623.    # 跳跃中、移动中、停止中的分支
  624.    if jumping?
  625.      update_jump
  626.    elsif moving?
  627.      update_move
  628.    else
  629.      update_stop
  630.    end
  631.    # 动画计数超过最大值的情况下
  632.    # ※最大值等于基本值减去移动速度 * 1 的值
  633.    if @anime_count > 16 * 4/$c3_每一步的帧数 - @move_speed  * 2
  634.      # 停止动画为 OFF 并且在停止中的情况下
  635.      if not @step_anime and @stop_count > 0
  636.        # 还原为原来的图形
  637.        @pattern = @original_pattern
  638.      # 停止动画为 ON 并且在移动中的情况下
  639.      else
  640.        # 更新图形
  641.        @pattern = (@pattern + 1) % $c3_每一步的帧数
  642.      end
  643.      # 清除动画计数
  644.      @anime_count = 0
  645.    end
  646.    # 等待中的情况下
  647.    if @wait_count > 0
  648.      # 减少等待计数
  649.      @wait_count -= 1
  650.      return
  651.    end
  652.    # 强制移动路线的场合
  653.    if @move_route_forcing
  654.      # 自定义移动
  655.      move_type_custom
  656.      return
  657.    end
  658.    # 事件执行待机中并且为锁定状态的情况下
  659.    if @starting or lock?
  660.      # 不做规则移动
  661.      return
  662.    end
  663.    # 如果停止计数超过了一定的值(由移动频度算出)
  664.    if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
  665.      # 移动类型分支
  666.      case @move_type
  667.      when 1  # 随机
  668.        move_type_random
  669.      when 2  # 接近
  670.        move_type_toward_player
  671.      when 3  # 自定义
  672.        move_type_custom
  673.      end
  674.    end
  675. end
  676. end

  677. class Window_Base < Window
  678. def draw_actor_graphic(actor, x, y)
  679.    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  680.    cw = bitmap.width / $c3_每一步的帧数
  681.    ch = bitmap.height / $c3_总共可用的方向数
  682.    src_rect = Rect.new(0, 0, cw, ch)
  683.    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  684. end
  685. end

  686. class Game_Character
  687. #--------------------------------------------------------------------------
  688. # ● 面向主角的方向
  689. #--------------------------------------------------------------------------
  690. def turn_toward_player
  691.    # 求得与主角的坐标差
  692.    sx = @x - $game_player.x
  693.    sy = @y - $game_player.y
  694.    # 坐标相等的场合下
  695.    if sx == 0 and sy == 0
  696.      return
  697.    end
  698.    # 横侧距离长的情况下
  699.    if sx.abs > sy.abs
  700.      # 将左右方向变更为朝向主角的方向
  701.      sx > 0 ? turn_left : turn_right
  702.    # 竖侧距离长的情况下
  703.    else
  704.      # 将上下方向变更为朝向主角的方向
  705.      sy > 0 ? turn_up : turn_down
  706.    end
  707.    if sx == -1 and sy == -1
  708.      unless @direction_fix
  709.        @direction = 3
  710.      end
  711.      @stop_count = 0
  712.    elsif sx == -1 and sy == 1
  713.      unless @direction_fix
  714.        @direction = 9
  715.      end
  716.      @stop_count = 0
  717.    elsif sx == 1 and sy == -1
  718.      unless @direction_fix
  719.        @direction = 1
  720.      end
  721.      @stop_count = 0
  722.    elsif sx == 1 and sy == 1
  723.      unless @direction_fix
  724.        @direction = 7
  725.      end
  726.      @stop_count = 0
  727.    end
  728. end
  729. end
  730. #==============================================================================
  731. #==============================================================================
复制代码

作者: yuzhongke    时间: 2007-7-14 07:38
提示: 作者被禁止或删除 内容自动屏蔽
作者: yuzhongke    时间: 2007-7-14 07:39
提示: 作者被禁止或删除 内容自动屏蔽




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