Project1

标题: 求角色不停前进的脚本 [打印本页]

作者: 我在孤岛等你    时间: 2014-2-9 10:46
标题: 求角色不停前进的脚本
本帖最后由 我在孤岛等你 于 2014-2-9 18:07 编辑

                                                                                           ↑      
要放在事件上用脚本进行,能调节速度,角色依然可以用←↓→调节方向。
我知道可以用事件做,但调不了方向与速度。
作者: 恐惧剑刃    时间: 2014-2-9 11:59
就是这样了。。。。。。。。。。。。。。。

# 事件 脚本 输入 $game_temp.start_move = true 开始移动
# 事件 脚本 输入 $game_temp.move_turn = n 改变方向 0 上 1 下 2 左 3 右

# PS 一旦启用 将无视方向键!

class Game_Temp
  attr_accessor :start_move
  attr_accessor :move_turn
  alias initialize_move initialize
  def initialize
    initialize_move
    @start_move = false
    @move_turn = 0
  end
end
class Game_Player < Game_Character
  def update
    # 本地变量记录移动信息
    last_moving = moving?
    # 移动中、事件执行中、强制移动路线中、
    # 信息窗口一个也不显示的时候
    unless moving? or $game_system.map_interpreter.running? or
           @move_route_forcing or $game_temp.message_window_showing
      # 如果方向键被按下、主角就朝那个方向移动
      unless $game_temp.start_move
        case Input.dir4
        when 2
          move_down
        when 4
          move_left
        when 6
          move_right
        when 8
          move_up
        end
      end
      start_move
    end
    # 本地变量记忆坐标
    last_real_x = @real_x
    last_real_y = @real_y
    super
    # 角色向下移动、画面上的位置在中央下方的情况下
    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
    # 不在移动中的情况下
    unless moving?
      # 上次主角移动中的情况
      if last_moving
        # 与同位置的事件接触就判定为事件启动
        result = check_event_trigger_here([1,2])
        # 没有可以启动的事件的情况下
        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
  end
  def start_move
    if $game_temp.start_move
      case $game_temp.move_turn
      when 0 # 上
        move_up
      when 1 # 下
        move_down
      when 2 # 左
        move_left
      when 3 # 右
        move_right
      end
    end
  end
end





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