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

Project1

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

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

[复制链接]

Lv4.逐梦者

梦石
0
星屑
12157
在线时间
4435 小时
注册时间
2014-4-11
帖子
5955

开拓者

跳转到指定楼层
1
发表于 2014-11-14 21:17:58 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
我把自己穿透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
复制代码

Lv5.捕梦者

梦石
0
星屑
33071
在线时间
5103 小时
注册时间
2012-11-19
帖子
4878

开拓者

2
发表于 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 各类型脚本/插件定制
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
7
星屑
1113
在线时间
334 小时
注册时间
2008-1-28
帖子
1566
3
发表于 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 新生 《箱子新世界》
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
52 小时
注册时间
2014-11-6
帖子
23
4
发表于 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自然是不会有的,适用于战斗事件比较少的情况。
脚本同理,更精确,还可以省几行。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

薄凉看客

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

评分

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

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-22 10:07

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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