查看: 2185|回复: 4

[已经过期] 怎么让我在穿透ON下,也能被NPC碰到启动事件

[复制链接]
梦石
0
星屑
12161
在线时间
4435 小时
注册时间
2014-4-11
回帖
5616

开拓者

发表于 2014-11-14 21:17:58 | 显示全部楼层 |阅读模式

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

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

×
我把自己穿透ON了后,所有NPC都穿过去了。本来他们身上有启动战斗事件的,也都没触发穿过去了。
并不是触发不了。是特别难触发了。在那来回跑了好几次才触发。
把事件也改成穿透就可以启动。但是我不想事件是穿透的,那样他们会跑到不该跑的地方去。
我想这可能是默认的脚本有关。默认的好象是要坐标对应才会启动吧,能改改吗。
  1.   #--------------------------------------------------------------------------
  2.   # ● 接触事件启动判定
  3.   #--------------------------------------------------------------------------
  4.   def check_event_trigger_touch(x, y)
  5.     # 事件执行中的情况下
  6.     if $game_system.map_interpreter.running?
  7.       return
  8.     end
  9.     # 目标为 [与事件接触] 以及和主角坐标一致的情况下
  10.     if @trigger == 2 and x == $game_player.x and y == $game_player.y
  11.       # 除跳跃中以外的情况、启动判定就是正面的事件
  12.       if not jumping? and not over_trigger?
  13.         start
  14.       end
  15.     end
  16.     end
复制代码
梦石
0
星屑
34465
在线时间
5096 小时
注册时间
2012-11-19
回帖
4715

开拓者

发表于 2014-11-14 23:03:18 | 显示全部楼层
  1. #--------------------------------------------------------------------------
  2.   def over_trigger?
  3.     # 图形是角色、没有开启穿透的情况下
  4.     if @character_name != "" and not @through
  5.       # 启动判定是正面
  6.       return false
  7.     end
  8.     # 地图上的这个位置不能通行的情况下
  9.     unless $game_map.passable?(@x, @y, 0)
  10.       # 启动判定是正面
  11.       return false
  12.     end
  13.     # 启动判定在同位置
  14.     return true
  15.   end
复制代码
把那个 and not @through 注释掉试下。

点评

所以我是想能不能把x == $game_player.x换成坐标相差1就启动事件,而不用重叠  发表于 2014-11-15 12:45
本身就是与事件接触的。是明怪。  发表于 2014-11-15 12:08
把事件改成 与事件接触 试试。  发表于 2014-11-15 00:26
没效果  发表于 2014-11-14 23:45

评分

参与人数 1星屑 +100 收起 理由
RyanBern + 100 塞糖

查看全部评分

xp vx va mv  va mz 各类型脚本/插件定制
回复

使用道具 举报

梦石
7
星屑
1113
在线时间
334 小时
注册时间
2008-1-28
回帖
1506
发表于 2014-11-15 14:21:23 | 显示全部楼层
本帖最后由 未命名 于 2014-11-16 00:07 编辑

问题想得太简单了……我再思考下……

——————————————————————————————

将 Game_Event 的 197行 if not jumping? and over_trigger?
的and over_trigger?注释掉。

至于副作用不是很清楚,不穿透还是可以用的。

——————————————————————————————
证据: XP默认.rar (188.47 KB, 下载次数: 36)

可能是你改了其他脚本的缘故吧,我是按原脚本改的。

点评

我现在把Game_Event和Game_Player里面的和跳跃有关的都#了,not @through也#了,就可以用了  发表于 2014-11-16 00:24
怎么会没用……我明明测试过的。  发表于 2014-11-16 00:05
这个我昨天也试过。没用。我觉得还是应该设XY坐标相差1就启动事件好些,不知道怎么写  发表于 2014-11-15 18:33

评分

参与人数 1星屑 +100 收起 理由
RyanBern + 100 塞糖

查看全部评分

终于有可以放在这里的游戏了……
极短13 新生 《箱子新世界》
回复

使用道具 举报

梦石
0
星屑
50
在线时间
52 小时
注册时间
2014-11-6
回帖
23
发表于 2014-11-15 23:38:49 | 显示全部楼层
纯事件如下:
执行内容:
变量[1]<<<角色的X坐标
变量[1]-=本事件的X坐标
IF 变量[1]<=1
[]if 变量[1]>=1
[][]变量[1]<<<角色的Y坐标
[][]变量[1]-=本事件的Y坐标
[][]IF 变量[1]<=1
[][][]if 变量[1]>=1
[][][][]战斗处理
[][][][]独立开关
[][][]endif
[][]ENDIF
[]endif
ENDIF

每个事件需要占用一个变量,不过换地图的话变量可以回收利用。BUG自然是不会有的,适用于战斗事件比较少的情况。
脚本同理,更精确,还可以省几行。
回复

使用道具 举报

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
回帖
1223
发表于 2014-11-16 00:31:28 | 显示全部楼层
本帖最后由 恐惧剑刃 于 2014-11-16 00:37 编辑

找到Game_Player
142行改为
  1. new_x = @through ? @x : (@x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0))
复制代码
143行改为
  1. new_y = @through ? @y : (@y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0))
复制代码
类似的
161行改为
  1. new_x = @through ? @x : (@x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0))
复制代码
162行改为
  1. new_y = @through ? @y : (@y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0))
复制代码
250行下方加一行
  1. check_event_trigger_there if @through([0,1,2])
复制代码
修改后脚本大致如下
[pre lang="ruby" line="1"]#==============================================================================
# ■ Game_Player
#------------------------------------------------------------------------------
#  处理主角的类。事件启动的判定、以及地图的滚动等功能。
# 本类的实例请参考 $game_player。
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # ● 正面事件的启动判定
  #--------------------------------------------------------------------------
  def check_event_trigger_there(triggers)
    result = false
    # 事件执行中的情况下
    if $game_system.map_interpreter.running?
      return result
    end
    # 计算正面坐标
    #--------------------------------------------------------------------------
    new_x = @through ? @x : (@x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0))
    new_y = @through ? @y : (@y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0))
    #--------------------------------------------------------------------------
    # 全部事件的循环
    for event in $game_map.events.values
      # 事件坐标与目标一致的情况下
      if event.x == new_x and event.y == new_y and
         triggers.include?(event.trigger)
        # 跳跃中以外的情况下、启动判定是正面的事件
        if not event.jumping? and not event.over_trigger?
          event.start
          result = true
        end
      end
    end
    # 找不到符合条件的事件的情况下
    if result == false
      # 正面的元件是计数器的情况下
      if $game_map.counter?(new_x, new_y)
        # 计算 1 元件里侧的坐标
        #--------------------------------------------------------------------------
        new_x = @through ? @x : (@x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0))
        new_y = @through ? @y : (@y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0))
        #--------------------------------------------------------------------------
        # 全事件的循环
        for event in $game_map.events.values
          # 事件坐标与目标一致的情况下
          if event.x == new_x and event.y == new_y and
             triggers.include?(event.trigger)
            # 跳跃中以外的情况下、启动判定是正面的事件
            if not event.jumping? and not event.over_trigger?
              event.start
              result = true
            end
          end
        end
      end
    end
    return result
  end
  #--------------------------------------------------------------------------
  # ● 画面更新
  #--------------------------------------------------------------------------
  def update
    # 本地变量记录移动信息
    last_moving = moving?
    # 移动中、事件执行中、强制移动路线中、
    # 信息窗口一个也不显示的时候
    unless moving? or $game_system.map_interpreter.running? or
           @move_route_forcing or $game_temp.message_window_showing
      # 如果方向键被按下、主角就朝那个方向移动
      case Input.dir4
      when 2
        move_down
      when 4
        move_left
      when 6
        move_right
      when 8
        move_up
      end
    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
        #--------------------------------------------------------------------------
        check_event_trigger_there([0,1,2]) if @through
        #--------------------------------------------------------------------------
        # 与同位置的事件接触就判定为事件启动
        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
end
[/pre]

评分

参与人数 1星屑 +100 收起 理由
RyanBern + 100 塞糖

查看全部评分

回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部