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

Project1

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

[已经过期] 关于八方人物跟随

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
293 小时
注册时间
2010-7-21
帖子
574
跳转到指定楼层
1
发表于 2010-9-13 17:46:27 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
# ————————————————————————————————————

# ▼▲▼ XRXS13. パーティ列車移動 ver.1.02 ▼▲▼
#
# Train_Actor
#
#

module Train_Actor




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





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





# 定数
#Input::DOWN = 2
#Input::LEFT = 4
#Input::RIGHT = 6
#Input::UP = 6
DOWN_LEFT = 1
DOWN_RIGHT = 3
UP_LEFT = 7
UP_RIGHT = 9
JUMP = 5
#==============================================================================
# ■ Game_Party_Actor
#------------------------------------------------------------------------------
#  
#==============================================================================
class Game_Party_Actor < Game_Character
def initialize
  super()
  @through = true
end
def setup(actor)
  # キャラクターのファイル名と色相を設定
  if actor != nil
    @character_name = actor.character_name
    @character_hue = actor.character_hue
  else
    @character_name = ""
    @character_hue = 0
  end
  # 不透明度と合成方法を初期化
  @opacity = 255
  @blend_type = 0
end
def screen_z(height = 0)
  if $game_player.x == @x and $game_player.y == @y
    return $game_player.screen_z(height) - 1
  end
  super(height)
end
#--------------------------------------------------------------------------
# ● 下に移動
# turn_enabled : その場での向き変更を許可するフラグ
#--------------------------------------------------------------------------
def move_down(turn_enabled = true)
  # 下を向く
  if turn_enabled
    turn_down
  end
  # 通行可能な場合
  if passable?(@x, @y, Input::DOWN)
    # 下を向く
    turn_down
    # 座標を更新
    @y += 1
    increase_steps
  end
end
#--------------------------------------------------------------------------
# ● 左に移動
# turn_enabled : その場での向き変更を許可するフラグ
#--------------------------------------------------------------------------
def move_left(turn_enabled = true)
  # 左を向く
  if turn_enabled
    turn_left
  end
  # 通行可能な場合
  if passable?(@x, @y, Input::LEFT)
    # 左を向く
    turn_left
    # 座標を更新
    @x -= 1
    increase_steps
  end
end
#--------------------------------------------------------------------------
# ● 右に移動
# turn_enabled : その場での向き変更を許可するフラグ
#--------------------------------------------------------------------------
def move_right(turn_enabled = true)
  # 右を向く
  if turn_enabled
    turn_right
  end
  # 通行可能な場合
  if passable?(@x, @y, Input::RIGHT)
    # 右を向く
    turn_right
    # 座標を更新
    @x += 1
    increase_steps
  end
end
#--------------------------------------------------------------------------
# ● 上に移動
# turn_enabled : その場での向き変更を許可するフラグ
#--------------------------------------------------------------------------
def move_up(turn_enabled = true)
  # 上を向く
  if turn_enabled
    turn_up
  end
  # 通行可能な場合
  if passable?(@x, @y, Input::UP)
    # 上を向く
    turn_up
    # 座標を更新
    @y -= 1
    increase_steps
  end
end
#--------------------------------------------------------------------------
# ● 左下に移動
#--------------------------------------------------------------------------
def move_lower_left
  # 向き固定でない場合
  unless @direction_fix
    # 右向きだった場合は左を、上向きだった場合は下を向く
    @direction = 1
  end
  # 下→左、左→下 のどちらかのコースが通行可能な場合
  if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
     (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
    # 座標を更新
    @x -= 1
    @y += 1
    increase_steps
  end
end
#--------------------------------------------------------------------------
# ● 右下に移動
#--------------------------------------------------------------------------
def move_lower_right
  # 向き固定でない場合
  unless @direction_fix
    # 左向きだった場合は右を、上向きだった場合は下を向く
    @direction = 3
  end
  # 下→右、右→下 のどちらかのコースが通行可能な場合
  if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
     (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
    # 座標を更新
    @x += 1
    @y += 1
    increase_steps
  elsif passable?(@x, @y, Input::DOWN)
    @direction = 2
    @y += 1
    increase_steps
  elsif passable?(@x, @y, Input::RIGHT)
    @direction = 6
    @x += 1
    increase_steps
  end
end
#--------------------------------------------------------------------------
# ● 左上に移動
#--------------------------------------------------------------------------
def move_upper_left
  # 向き固定でない場合
  unless @direction_fix
    # 右向きだった場合は左を、下向きだった場合は上を向く
    @direction = 7
  end
  # 上→左、左→上 のどちらかのコースが通行可能な場合
  if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
     (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
    # 座標を更新
    @x -= 1
    @y -= 1
    increase_steps
  end
end
#--------------------------------------------------------------------------
# ● 右上に移動
#--------------------------------------------------------------------------
def move_upper_right
  # 向き固定でない場合
  unless @direction_fix
    # 左向きだった場合は右を、下向きだった場合は上を向く
    @direction = 9
  end
  # 上→右、右→上 のどちらかのコースが通行可能な場合
  if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
     (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
    # 座標を更新
    @x += 1
    @y -= 1
    increase_steps
  end
end
attr_writer :move_speed
attr_writer :step_anime
end
#==============================================================================
# ■ Spriteset_Map_Module
#------------------------------------------------------------------------------
#  
#==============================================================================
module Spriteset_Map_Module
def setup_actor_character_sprites?
  return @setup_actor_character_sprites_flag != nil
end
def setup_actor_character_sprites(characters)
  if !setup_actor_character_sprites?
    index_game_player = 0
    @character_sprites.each_index do |i|
      if @character_sprites[i].character.instance_of?(Game_Player)
        index_game_player = i
        break
      end
    end
    for character in characters.reverse
      @character_sprites.unshift(
       Sprite_Character.new(@viewport1, character)
       )
    end
    @setup_actor_character_sprites_flag = true
  end
end
end
#==============================================================================
# ■ Scene_Map_Module
#------------------------------------------------------------------------------
#  
#==============================================================================
module Scene_Map_Module
def setup_actor_character_sprites(characters)
  @spriteset.setup_actor_character_sprites(characters)
end
end
#==============================================================================
# ■ Game_Party_Module
#------------------------------------------------------------------------------
#  
#==============================================================================
module Game_Party_Module
def return_char(i)
return @characters[i]
end
def set_transparent_actors(transparent)
  @transparent = transparent
end
def setup_actor_character_sprites
  if @characters == nil
    @characters = []
    for i in 1 ... TRAIN_ACTOR_SIZE_MAX
      @characters.push(Game_Party_Actor.new)
    end
  end
  for i in 1 ... TRAIN_ACTOR_SIZE_MAX
    @characters[i - 1].setup(actors[i])
  end
  if $scene.class.method_defined?('setup_actor_character_sprites')
    $scene.setup_actor_character_sprites(@characters)
  end
end
def update_party_actors
  setup_actor_character_sprites
  transparent = $game_player.transparent
  if transparent == false
    if TRANSPARENT_SWITCH
      transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX]
    end
  end
  for character in @characters
    character.transparent = transparent
    character.move_speed = $game_player.move_speed
    character.update
  end
end
def moveto_party_actors( x, y )
  setup_actor_character_sprites
  for character in @characters
    character.moveto( x, y )
  end
  if @move_list == nil
    @move_list = []
  end
  move_list_setup
end
def move_party_actors
  if @move_list == nil
    @move_list = []
    move_list_setup
  end
  @move_list.each_index do |i|
  if @characters[i] != nil
    case @move_list[i].type
    when Input::DOWN
      @characters[i].move_down(@move_list[i].args[0])
    when Input::LEFT
      @characters[i].move_left(@move_list[i].args[0])
    when Input::RIGHT
      @characters[i].move_right(@move_list[i].args[0])
    when Input::UP
      @characters[i].move_up(@move_list[i].args[0])
    when DOWN_LEFT
      @characters[i].move_lower_left
    when DOWN_RIGHT
      @characters[i].move_lower_right
    when UP_LEFT
      @characters[i].move_upper_left
    when UP_RIGHT
      @characters[i].move_upper_right
    when JUMP
      @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1])
    end
  end
end
end
#==============================================================================
# ■ Move_List_Element
#------------------------------------------------------------------------------
#  
#==============================================================================
class Move_List_Element
  def initialize(type,args)
    @type = type
    @args = args
  end
  def type()
    return @type
  end
  def args()
    return @args
  end
end
def move_list_setup
  for i in 0 .. TRAIN_ACTOR_SIZE_MAX
    @move_list[i] = nil
  end
end
def add_move_list(type,*args)
  @move_list.unshift(Move_List_Element.new(type,args)).pop
end
def move_down_party_actors(turn_enabled = true)
  move_party_actors
  add_move_list(Input::DOWN,turn_enabled)
end
def move_left_party_actors(turn_enabled = true)
  move_party_actors
  add_move_list(Input::LEFT,turn_enabled)
end
def move_right_party_actors(turn_enabled = true)
  move_party_actors
  add_move_list(Input::RIGHT,turn_enabled)
end
def move_up_party_actors(turn_enabled = true)
  move_party_actors
  add_move_list(Input::UP,turn_enabled)
end
def move_lower_left_party_actors
  move_party_actors
  add_move_list(DOWN_LEFT)
end
def move_lower_right_party_actors
  move_party_actors
  add_move_list(DOWN_RIGHT)
end
def move_upper_left_party_actors
  move_party_actors
  add_move_list(UP_LEFT)
end
def move_upper_right_party_actors
  move_party_actors
  add_move_list(UP_RIGHT)
end
def jump_party_actors(x_plus, y_plus)
  move_party_actors
  add_move_list(JUMP,x_plus, y_plus)
end
end
module Game_Player_Module
def update
  $game_party.update_party_actors
  super
end
def moveto( x, y )
  $game_party.moveto_party_actors( x, y )
  super( x, y )
end
def move_down(turn_enabled = true)
  if passable?(@x, @y, Input::DOWN)
    $game_party.move_down_party_actors(turn_enabled)
  #..........................................................................
  elsif passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN) and
        can_go?(@x, @y + 1)
    @direction = 1
    $game_party.move_lower_left_party_actors
    increase_steps
  elsif passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN) and
        can_go?(@x, @y + 1)
    @direction = 3
    $game_party.move_lower_right_party_actors
    increase_steps
  #..........................................................................
  end
  super(turn_enabled)
end
def move_left(turn_enabled = true)
  if passable?(@x, @y, Input::LEFT)
    $game_party.move_left_party_actors(turn_enabled)
  #..........................................................................
  elsif passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT) and
        can_go?(@x - 1, @y)
    @direction = 7
    $game_party.move_upper_left_party_actors
    increase_steps
  elsif passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT) and
        can_go?(@x - 1, @y)
    @direction = 1
    $game_party.move_lower_left_party_actors
    increase_steps
  #..........................................................................
  end
  super(turn_enabled)
end
def move_right(turn_enabled = true)
  if passable?(@x, @y, Input::RIGHT)
    $game_party.move_right_party_actors(turn_enabled)
  #..........................................................................
  elsif passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT) and
        can_go?(@x + 1, @y)
    @direction = 9
    $game_party.move_upper_right_party_actors
    increase_steps
  elsif passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT) and
        can_go?(@x + 1, @y)
    @direction = 3
    $game_party.move_lower_right_party_actors
    increase_steps
  #..........................................................................
  end
  super(turn_enabled)
end
def move_up(turn_enabled = true)
  if passable?(@x, @y, Input::UP)
    $game_party.move_up_party_actors(turn_enabled)
  #..........................................................................
  elsif passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP) and
        can_go?(@x, @y - 1)
    @direction = 7
    $game_party.move_upper_left_party_actors
    increase_steps
  elsif passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP) and
        can_go?(@x, @y - 1)
    @direction = 9
    $game_party.move_upper_right_party_actors
    increase_steps
  #..........................................................................
  end
  super(turn_enabled)
end
def move_lower_left
  # 下→左、左→下 のどちらかのコースが通行可能な場合
  @direction = 1
  if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
     (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
    $game_party.move_lower_left_party_actors
    increase_steps
  #..........................................................................
  elsif passable?(@x, @y, Input::DOWN) and can_go?(@x - 1, @y + 1)
    $game_party.move_down_party_actors
    @direction = 2
    increase_steps
  elsif passable?(@x, @y, Input::LEFT) and can_go?(@x - 1, @y + 1)
    $game_party.move_left_party_actors
    @direction = 4
    increase_steps
  #..........................................................................
  end
  super
end
def move_lower_right
  # 下→右、右→下 のどちらかのコースが通行可能な場合
  @direction = 3
  if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
     (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
    $game_party.move_lower_right_party_actors
    increase_steps
  #..........................................................................
  elsif passable?(@x, @y, Input::DOWN) and can_go?(@x + 1, @y + 1)
    $game_party.move_down_party_actors
    @direction = 2
    increase_steps
  elsif passable?(@x, @y, Input::RIGHT) and can_go?(@x + 1, @y + 1)
    $game_party.move_right_party_actors
    @direction = 6
    increase_steps
  #..........................................................................
  end
  super
end
def move_upper_left
  # 上→左、左→上 のどちらかのコースが通行可能な場合
  @direction = 7
  if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
     (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
    $game_party.move_upper_left_party_actors
    increase_steps
  #..........................................................................
  elsif passable?(@x, @y, Input::UP) and can_go?(@x - 1, @y - 1)
    $game_party.move_up_party_actors
    @direction = 8
    increase_steps
  elsif passable?(@x, @y, Input::LEFT) and can_go?(@x - 1, @y - 1)
    $game_party.move_left_party_actors
    @direction = 4
    increase_steps
  #..........................................................................
  end
  super
end
def move_upper_right
  # 上→右、右→上 のどちらかのコースが通行可能な場合
  @direction = 9
  if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
     (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
    $game_party.move_upper_right_party_actors
    increase_steps
  #..........................................................................
  elsif passable?(@x, @y, Input::UP) and can_go?(@x + 1, @y - 1)
    $game_party.move_up_party_actors
    @direction = 8
    increase_steps
  elsif passable?(@x, @y, Input::RIGHT) and can_go?(@x + 1, @y - 1)
    $game_party.move_right_party_actors
    @direction = 6
    increase_steps
  #..........................................................................
  end
  super
end
def jump(x_plus, y_plus)
  # 新しい座標を計算
  new_x = @x + x_plus
  new_y = @y + y_plus
  # 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
  if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
    $game_party.jump_party_actors(x_plus, y_plus)
  end
  super(x_plus, y_plus)
end
attr_reader :move_speed
attr_reader :step_anime
end
end # module Train_Actor
#==============================================================================
# ■ Game_Party
#------------------------------------------------------------------------------
#  
#==============================================================================
class Game_Party
  include Train_Actor::Game_Party_Module
end
#==============================================================================
# ■ Game_Player
#------------------------------------------------------------------------------
#  
#==============================================================================
class Game_Player
  include Train_Actor::Game_Player_Module
end
#==============================================================================
# ■ Spriteset_Map
#------------------------------------------------------------------------------
#  
#==============================================================================
class Spriteset_Map
  include Train_Actor::Spriteset_Map_Module
end
#==============================================================================
# ■ Scene_Map
#------------------------------------------------------------------------------
#  
#==============================================================================
class Scene_Map
  include Train_Actor::Scene_Map_Module
end




人物跟随暂停了只有前面1个人有待机。。。后面的人物都卡住了的样子···不动了!···请那位朋友帮忙解决!:)

Lv5.捕梦者 (管理员)

老黄鸡

梦石
0
星屑
41976
在线时间
7654 小时
注册时间
2009-7-6
帖子
13527

开拓者贵宾

2
发表于 2010-9-13 20:16:52 | 只看该作者
如果改用伪八方向也许可以,如果不想改,就要让跟随的人物也隶属于八方向脚本,我还没那么厉害。。。
RGDirect - DirectX驱动的RGSS,点我了解.
(排满,暂停)RM全系列成套系统定制请联系QQ1213237796
不接受对其他插件维护的委托
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
29 小时
注册时间
2010-7-5
帖子
483
3
发表于 2010-9-13 21:01:56 | 只看该作者
楼上正解,附赠伪八方,用这个脚本覆盖Game_Player吧,这个和人物跟随不冲突
  1. #==============================================================================
  2. # ■ Game_Player
  3. #------------------------------------------------------------------------------
  4. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  5. # 本类的实例请参考 $game_player。
  6. #==============================================================================

  7. class Game_Player < Game_Character
  8.   #--------------------------------------------------------------------------
  9.   # ● 恒量
  10.   #--------------------------------------------------------------------------
  11.   CENTER_X = (320 - 16) * 4   # 画面中央的 X 坐标 * 4
  12.   CENTER_Y = (240 - 16) * 4   # 画面中央的 Y 坐标 * 4
  13.   #--------------------------------------------------------------------------
  14.   # ● 可以通行判定
  15.   #     x : X 坐标
  16.   #     y : Y 坐标
  17.   #     d : 方向 (0,2,4,6,8)  ※ 0 = 全方向不能通行的情况判定 (跳跃用)
  18.   #--------------------------------------------------------------------------
  19.   def passable?(x, y, d)
  20.     # 求得新的坐标
  21.     new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
  22.     new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
  23.     # 坐标在地图外的情况下
  24.     unless $game_map.valid?(new_x, new_y)
  25.       # 不能通行
  26.       return false
  27.     end
  28.     # 调试模式为 ON 并且 按下 CTRL 键的情况下
  29.     if $DEBUG and Input.press?(Input::CTRL)
  30.       # 可以通行
  31.       return true
  32.     end
  33.     super
  34.   end
  35.   #--------------------------------------------------------------------------
  36.   # ● 像通到画面中央一样的设置地图的显示位置
  37.   #--------------------------------------------------------------------------
  38.   def center(x, y)
  39.     max_x = ($game_map.width - 20) * 128
  40.     max_y = ($game_map.height - 15) * 128
  41.     $game_map.display_x = [0, [x * 128 - CENTER_X, max_x].min].max
  42.     $game_map.display_y = [0, [y * 128 - CENTER_Y, max_y].min].max
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   # ● 向指定的位置移动
  46.   #     x : X 座標
  47.   #     y : Y 座標
  48.   #--------------------------------------------------------------------------
  49.   def moveto(x, y)
  50.     super
  51.     # 自连接
  52.     center(x, y)
  53.     # 生成遇敌计数
  54.     make_encounter_count
  55.   end
  56.   #--------------------------------------------------------------------------
  57.   # ● 增加步数
  58.   #--------------------------------------------------------------------------
  59.   def increase_steps
  60.     super
  61.     # 不是强制移动路线的场合
  62.     unless @move_route_forcing
  63.       # 增加步数
  64.       $game_party.increase_steps
  65.       #######################################################################
  66.       for actor in $game_party.actors
  67.       #如果需要应用于所有角色就去掉底下这行。
  68.       actor.hp += 1
  69.       end
  70.       #######################################################################
  71.       # 步数是偶数的情况下
  72.       if $game_party.steps % 2 == 0
  73.         # 检查连续伤害
  74.         $game_party.check_map_slip_damage
  75.       end
  76.     end
  77.   end
  78.   #--------------------------------------------------------------------------
  79.   # ● 获取遇敌计数
  80.   #--------------------------------------------------------------------------
  81.   def encounter_count
  82.     return @encounter_count
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # ● 生成遇敌计数
  86.   #--------------------------------------------------------------------------
  87.   def make_encounter_count
  88.     # 两种颜色震动的图像
  89.     if $game_map.map_id != 0
  90.       n = $game_map.encounter_step
  91.       @encounter_count = rand(n) + rand(n) + 1
  92.     end
  93.   end
  94.   #--------------------------------------------------------------------------
  95.   # ● 刷新
  96.   #--------------------------------------------------------------------------
  97.   def refresh
  98.     # 同伴人数为 0 的情况下
  99.     if $game_party.actors.size == 0
  100.       # 清除角色的文件名及对像
  101.       @character_name = ""
  102.       @character_hue = 0
  103.       # 分支结束
  104.       return
  105.     end
  106.     # 获取带头的角色
  107.     actor = $game_party.actors[0]
  108.     # 设置角色的文件名及对像
  109.     @character_name = actor.character_name
  110.     @character_hue = actor.character_hue
  111.     # 初始化不透明度和合成方式子
  112.     @opacity = 255
  113.     @blend_type = 0
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   # ● 同位置的事件启动判定
  117.   #--------------------------------------------------------------------------
  118.   def check_event_trigger_here(triggers)
  119.     result = false
  120.     # 事件执行中的情况下
  121.     if $game_system.map_interpreter.running?
  122.       return result
  123.     end
  124.     # 全部事件的循环
  125.     for event in $game_map.events.values
  126.       # 事件坐标与目标一致的情况下
  127.       if event.x == @x and event.y == @y and triggers.include?(event.trigger)
  128.         # 跳跃中以外的情况下、启动判定是同位置的事件
  129.         if not event.jumping? and event.over_trigger?
  130.           event.start
  131.           result = true
  132.         end
  133.       end
  134.     end
  135.     return result
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # ● 正面事件的启动判定
  139.   #--------------------------------------------------------------------------
  140.   def check_event_trigger_there(triggers)
  141.     result = false
  142.     # 事件执行中的情况下
  143.     if $game_system.map_interpreter.running?
  144.       return result
  145.     end
  146.     # 计算正面坐标
  147.     new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  148.     new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  149.     # 全部事件的循环
  150.     for event in $game_map.events.values
  151.       # 事件坐标与目标一致的情况下
  152.       if event.x == new_x and event.y == new_y and
  153.          triggers.include?(event.trigger)
  154.         # 跳跃中以外的情况下、启动判定是正面的事件
  155.         if not event.jumping? and not event.over_trigger?
  156.           event.start
  157.           result = true
  158.         end
  159.       end
  160.     end
  161.     # 找不到符合条件的事件的情况下
  162.     if result == false
  163.       # 正面的元件是计数器的情况下
  164.       if $game_map.counter?(new_x, new_y)
  165.         # 计算 1 元件里侧的坐标
  166.         new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  167.         new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  168.         # 全事件的循环
  169.         for event in $game_map.events.values
  170.           # 事件坐标与目标一致的情况下
  171.           if event.x == new_x and event.y == new_y and
  172.              triggers.include?(event.trigger)
  173.             # 跳跃中以外的情况下、启动判定是正面的事件
  174.             if not event.jumping? and not event.over_trigger?
  175.               event.start
  176.               result = true
  177.             end
  178.           end
  179.         end
  180.       end
  181.     end
  182.     return result
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   # ● 接触事件启动判定
  186.   #--------------------------------------------------------------------------
  187.   def check_event_trigger_touch(x, y)
  188.     result = false
  189.     # 事件执行中的情况下
  190.     if $game_system.map_interpreter.running?
  191.       return result
  192.     end
  193.     # 全事件的循环
  194.     for event in $game_map.events.values
  195.       # 事件坐标与目标一致的情况下
  196.       if event.x == x and event.y == y and [1,2].include?(event.trigger)
  197.         # 跳跃中以外的情况下、启动判定是正面的事件
  198.         if not event.jumping? and not event.over_trigger?
  199.           event.start
  200.           result = true
  201.         end
  202.       end
  203.     end
  204.     return result
  205.   end
  206.   #--------------------------------------------------------------------------
  207.   # ● 画面更新
  208.   #--------------------------------------------------------------------------
  209.   def update
  210.     # 本地变量记录移动信息
  211.     last_moving = moving?
  212.     # 移动中、事件执行中、强制移动路线中、
  213.     # 信息窗口一个也不显示的时候
  214.     unless moving? or $game_system.map_interpreter.running? or
  215.            @move_route_forcing or $game_temp.message_window_showing
  216.       # 如果方向键被按下、主角就朝那个方向移动
  217.       case Input.dir8
  218.       when 2
  219.         move_down
  220.       when 4
  221.         move_left
  222.       when 6
  223.         move_right
  224.       when 8
  225.         move_up
  226.       when 1
  227.         move_lower_left
  228.       when 3
  229.         move_lower_right
  230.       when 7  
  231.         move_upper_left
  232.       when 9
  233.         move_upper_right
  234.       end
  235.     end
  236.     # 本地变量记忆坐标
  237.     last_real_x = @real_x
  238.     last_real_y = @real_y
  239.     super
  240.     # 角色向下移动、画面上的位置在中央下方的情况下
  241.     if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  242.       # 画面向下卷动
  243.       $game_map.scroll_down(@real_y - last_real_y)
  244.     end
  245.     # 角色向左移动、画面上的位置在中央左方的情况下
  246.     if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  247.       # 画面向左卷动
  248.       $game_map.scroll_left(last_real_x - @real_x)
  249.     end
  250.     # 角色向右移动、画面上的位置在中央右方的情况下
  251.     if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  252.       # 画面向右卷动
  253.       $game_map.scroll_right(@real_x - last_real_x)
  254.     end
  255.     # 角色向上移动、画面上的位置在中央上方的情况下
  256.     if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  257.       # 画面向上卷动
  258.       $game_map.scroll_up(last_real_y - @real_y)
  259.     end
  260.     # 不在移动中的情况下
  261.     unless moving?
  262.       # 上次主角移动中的情况
  263.       if last_moving
  264.         # 与同位置的事件接触就判定为事件启动
  265.         result = check_event_trigger_here([1,2])
  266.         # 没有可以启动的事件的情况下
  267.         if result == false
  268.           # 调试模式为 ON 并且按下 CTRL 键的情况下除外
  269.           unless $DEBUG and Input.press?(Input::CTRL)
  270.             # 遇敌计数下降
  271.             if @encounter_count > 0
  272.               @encounter_count -= 1
  273.             end
  274.           end
  275.         end
  276.       end
  277.       # 按下 C 键的情况下
  278.       if Input.trigger?(Input::C)
  279.         # 判定为同位置以及正面的事件启动
  280.         check_event_trigger_here([0])
  281.         check_event_trigger_there([0,1,2])
  282.       end
  283.     end
  284.   end
  285. end
复制代码
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-7-20 18:36

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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