查看: 2236|回复: 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
星屑
34511
在线时间
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])
复制代码
修改后脚本大致如下
  1. #==============================================================================
  2. # ■ Game_Player
  3. #------------------------------------------------------------------------------
  4. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  5. # 本类的实例请参考 $game_player。
  6. #==============================================================================

  7. class Game_Player < Game_Character
  8.   #--------------------------------------------------------------------------
  9.   # ● 正面事件的启动判定
  10.   #--------------------------------------------------------------------------
  11.   def check_event_trigger_there(triggers)
  12.     result = false
  13.     # 事件执行中的情况下
  14.     if $game_system.map_interpreter.running?
  15.       return result
  16.     end
  17.     # 计算正面坐标
  18.     #--------------------------------------------------------------------------
  19.     new_x = @through ? @x : (@x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0))
  20.     new_y = @through ? @y : (@y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0))
  21.     #--------------------------------------------------------------------------
  22.     # 全部事件的循环
  23.     for event in $game_map.events.values
  24.       # 事件坐标与目标一致的情况下
  25.       if event.x == new_x and event.y == new_y and
  26.          triggers.include?(event.trigger)
  27.         # 跳跃中以外的情况下、启动判定是正面的事件
  28.         if not event.jumping? and not event.over_trigger?
  29.           event.start
  30.           result = true
  31.         end
  32.       end
  33.     end
  34.     # 找不到符合条件的事件的情况下
  35.     if result == false
  36.       # 正面的元件是计数器的情况下
  37.       if $game_map.counter?(new_x, new_y)
  38.         # 计算 1 元件里侧的坐标
  39.         #--------------------------------------------------------------------------
  40.         new_x = @through ? @x : (@x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0))
  41.         new_y = @through ? @y : (@y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0))
  42.         #--------------------------------------------------------------------------
  43.         # 全事件的循环
  44.         for event in $game_map.events.values
  45.           # 事件坐标与目标一致的情况下
  46.           if event.x == new_x and event.y == new_y and
  47.              triggers.include?(event.trigger)
  48.             # 跳跃中以外的情况下、启动判定是正面的事件
  49.             if not event.jumping? and not event.over_trigger?
  50.               event.start
  51.               result = true
  52.             end
  53.           end
  54.         end
  55.       end
  56.     end
  57.     return result
  58.   end
  59.   #--------------------------------------------------------------------------
  60.   # ● 画面更新
  61.   #--------------------------------------------------------------------------
  62.   def update
  63.     # 本地变量记录移动信息
  64.     last_moving = moving?
  65.     # 移动中、事件执行中、强制移动路线中、
  66.     # 信息窗口一个也不显示的时候
  67.     unless moving? or $game_system.map_interpreter.running? or
  68.            @move_route_forcing or $game_temp.message_window_showing
  69.       # 如果方向键被按下、主角就朝那个方向移动
  70.       case Input.dir4
  71.       when 2
  72.         move_down
  73.       when 4
  74.         move_left
  75.       when 6
  76.         move_right
  77.       when 8
  78.         move_up
  79.       end
  80.     end
  81.     # 本地变量记忆坐标
  82.     last_real_x = @real_x
  83.     last_real_y = @real_y
  84.     super
  85.     # 角色向下移动、画面上的位置在中央下方的情况下
  86.     if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  87.       # 画面向下卷动
  88.       $game_map.scroll_down(@real_y - last_real_y)
  89.     end
  90.     # 角色向左移动、画面上的位置在中央左方的情况下
  91.     if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  92.       # 画面向左卷动
  93.       $game_map.scroll_left(last_real_x - @real_x)
  94.     end
  95.     # 角色向右移动、画面上的位置在中央右方的情况下
  96.     if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  97.       # 画面向右卷动
  98.       $game_map.scroll_right(@real_x - last_real_x)
  99.     end
  100.     # 角色向上移动、画面上的位置在中央上方的情况下
  101.     if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  102.       # 画面向上卷动
  103.       $game_map.scroll_up(last_real_y - @real_y)
  104.     end
  105.     # 不在移动中的情况下
  106.     unless moving?
  107.       # 上次主角移动中的情况
  108.       if last_moving
  109.         #--------------------------------------------------------------------------
  110.         check_event_trigger_there([0,1,2]) if @through
  111.         #--------------------------------------------------------------------------
  112.         # 与同位置的事件接触就判定为事件启动
  113.         result = check_event_trigger_here([1,2])
  114.         # 没有可以启动的事件的情况下
  115.         if result == false
  116.           # 调试模式为 ON 并且按下 CTRL 键的情况下除外
  117.           unless $DEBUG and Input.press?(Input::CTRL)
  118.             # 遇敌计数下降
  119.             if @encounter_count > 0
  120.               @encounter_count -= 1
  121.             end
  122.           end
  123.         end
  124.       end
  125.       # 按下 C 键的情况下
  126.       if Input.trigger?(Input::C)
  127.         # 判定为同位置以及正面的事件启动
  128.         check_event_trigger_here([0])
  129.         check_event_trigger_there([0,1,2])
  130.       end
  131.     end
  132.   end
  133. end
复制代码

评分

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

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部