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

Project1

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

[已经解决] 有没有可能拦截地图事件,并在此前线执行一段代码?

[复制链接]

Lv4.逐梦者

梦石
0
星屑
19284
在线时间
3074 小时
注册时间
2013-1-11
帖子
1288
1
发表于 2019-10-14 09:01:47 | 显示全部楼层
本帖最后由 张咚咚 于 2019-10-14 15:46 编辑
  1. $map_event_proc = {
  2.   :map => {
  3.     1 => {
  4.       1 => proc{ p '1号地图1号事件执行前' },
  5.       2 => proc{ p '1号地图2号事件执行前' },
  6.     },
  7.   },
  8.   :common_event => {
  9.     1 => proc{ p '1号公共事件执行前' },
  10.     2 => proc{ p '2号公共事件执行前' },
  11.   },
  12. }
  13. class Interpreter
  14.   alias qqeat_start_before_interpreter_setup setup
  15.   def setup(list, event_id)
  16.     if list.is_a?(RPG::CommonEvent)
  17.       common_event_id = list.id
  18.       list = list.list
  19.     end
  20.     qqeat_start_before_interpreter_setup(list, event_id)
  21.     if common_event_id
  22.       proc = $map_event_proc[:common_event][common_event_id]
  23.       proc.call if proc
  24.     else
  25.       proc = $map_event_proc[:map][@map_id]
  26.       proc[@event_id].call if proc and proc[@event_id]
  27.     end
  28.   end
  29.   #--------------------------------------------------------------------------
  30.   # ● 公共事件
  31.   #--------------------------------------------------------------------------
  32.   def command_117
  33.     # 获取公共事件
  34.     common_event = $data_common_events[@parameters[0]]
  35.     # 公共事件有效的情况下
  36.     if common_event != nil
  37.       # 生成子解释器
  38.       @child_interpreter = Interpreter.new(@depth + 1)
  39.       @child_interpreter.setup(common_event, @event_id)
  40.     end
  41.     # 继续
  42.     return true
  43.   end
  44. end
复制代码

点评

哇!大神厉害啊……地图钩子已经完全问题了!可以满足我的一切需求,不过公共事件好像运行没效果,但好在这个需求不是紧迫,总之太谢谢了!  发表于 2019-10-14 17:41

评分

参与人数 1星屑 +100 +1 收起 理由
RyanBern + 100 + 1 认可答案

查看全部评分

回复 支持 1 反对 0

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-6 20:49

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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