找回密码
 注册
搜索
查看: 1508|回复: 28

修改mush的hs任务,出了一堆错,分享教训

[复制链接]
门派:天龙寺
发表于 2017-12-21 03:05:10 | 显示全部楼层 |阅读模式
目前公版的hs任务,时不时会出现发现npc却走过的情况,这时候系统提示"这里没有这个人。"然后就开始发呆.

前两天我打算修改这个bug,结果出了一堆错,下面把犯的这些错误给各位大神分享一下:

首先呢,我想抓"这里没有这个人。"这个提示,然后激发重新搜索,编好以后发现,发呆变成高频了,原来一旦开始hs2,遇到拦路npc,lujing.lua里面wipe_trigger开始启动自动杀npc,里面也有一个trigger是"这里没有这个人。",我的trigger被激发,wipe的trigger失效,就不继续走路了.

好吧,我就加了一句 'compare '..job.id,这样提示就变成 "xxx 不在这里",我抓这个trigger算了.

不料发现,还是解决不了问题,原来hs是用快速行走,这个地方会走过,重新搜索时还是会走过,不停重复的错过npc,还好自动找二次以后就停了,至少,不发呆了.

于是我就再加一个trigger,"^(> )*(\\S*) -",不停的记录当前房间名称,发现npc这个trigger被激发时立即记下当前房间名,一旦错过就直接奔回记录下的房间名重新搜索,避免重复错过.

这个问题的确解决了,又发现,每次在华山菜地做任务时,做完不回祭坛交首级,直接奔下一个任务点了.

琢磨很久,最后才发现,原来lujing.lua里面判断菜地也有一个trigger,和我刚才建的trigger重复了,我的trigger一旦激发,lujing.lua就不知道自己已经出了菜地,仍然暴走,直到最后放弃,奔下一个任务去了.

连续两处遇到重复trigger激发问题,于是我就去mush他家 Gammon Software的网站去找答案,原来可以通过设置SetTriggerOption,允许Trigger多次激发.

加了SetTriggerOption("huashan_miss","keep_evaluating","y"),终于可以跑出菜地了.

回过头来看,我其实应该把这个trigger放到huashan_find这个group里面,切首级后这个group会被false,也就不影响lujing.lua.
不过呢,学习了SetTriggerOption的一堆参数,也算值吧.

这些教训,估计很多大神早就明白,不过呢,分享一下自己的教训,给其他新人看看,避免弯路吧.

另外,由于我的mush被改得七零八落,实在没办法把修改后的模块共享给大家,如有需要,参考上面的思路自行修改吧.各位大神有更好的办法,也请多多指教.

评分

1

查看全部评分

门派:天龙寺
 楼主| 发表于 2017-12-21 03:06:18 | 显示全部楼层
这是mush网站关于SetTriggerOption的说明,搬运过来吧:

Sets the current value of a trigger option.

You must specify the name of an existing trigger, and a trigger option from the list given for GetTriggerOption. These are the same names as used in the XML world files for trigger options.

Note that you can neither get or set the "name" field. It is listed below for completeness in viewing triggers copied to the clipboard or in world files and plugins. You already know the name when getting the trigger option (it is TriggerName), and this function is provided to modify existing triggers, not rename them. To change the name of a trigger use ExportXML, modify the XML, and then ImportXML.

If SetTriggerOption is called from within a plugin, the triggers for the current plugin are used, not the "global" MUSHclient triggers.

For numeric options (such as "sequence") the supplied string will be converted to a number. It is an error if the string does not consist of digits (0 to 9). For the "user" option an optional leading sign is accepted.

For boolean options (such as "enabled") the supplied string may be:

"y", "Y", or "1" for true
"n", "N", or "0" for false

Also if you are using Lua you can supply simply true or false.

The various option names are:

"clipboard_arg": 0 - 10 - which wildcard to copy to the clipboard
"colour_change_type": 0=both, 1=foreground, 2=background
"custom_colour": 0=no change, 1 - 16, 17=other
"enabled": y/n - trigger is enabled
"expand_variables": y/n - expand variables (like @target)
"group": (string - group name)
"ignore_case": y/n - caseless matching
"inverse": y/n - only match if inverse, however see match_inverse
"italic": y/n - only match if italic, however see match_italic
"keep_evaluating": y/n - evaluate next trigger in sequence
"lines_to_match": 0 - 200 - how many lines to match for multi-line triggers
"lowercase_wildcard": y/n - make matching wildcards lower-case
"match": (string - what to match)
"match_style": (see below) - what style and colour combination to match on
"multi_line": y/n - multi-line trigger
"name": (string - name/label of trigger)
"new_style": (style(s) to change to: (bold (1) / underline (2) / italic (4) ) )
"omit_from_log": y/n - omit matching line from log file
"omit_from_output": y/n - omit matching line from output window
"one_shot": y/n - trigger is deleted after firing
"other_back_colour": (string - name of colour to change to)
"other_text_colour": (string - name of colour to change to)
"regexp": y/n - regular expression
"repeat": y/n - repeatedly evaluate on same line
"script": (string - name of function to call)
"send": (multi-line string - what to send)
"send_to": 0 - 14 - "send to" location (see below)
"sequence": 0 - 10000 - sequence in which to check - lower first
"sound": (string - sound file name to play)
"sound_if_inactive": y/n - play sound even if world inactive
"user": -2147483647 to 2147483647 - user-defined number
"variable": (string - name of variable to send to)


Options that match on colour, bold, inverse or underline are tested against the first matching character.


Send-to locations

"0" - send to MUD
"1" - put in command window
"2" - display in output window
"3" - put in status line
"4" - new notepad
"5" - append to notepad
"6" - put in log file
"7" - replace notepad
"8" - queue it
"9" - set a variable
"10" - re-parse as command
"11" - send to MUD as speedwalk
"12" - send to script engine
"13" - send without queuing
"14" - send to script engine - after omitting from output


Trigger match_style field will be as follows (in hex nibbles):

TBFS

T = what style to test
B = background colour
F = foreground colour
S = what style bits are wanted

Style bits:

NORMAL 0x0000 // normal text
HILITE 0x0001 // bold
UNDERLINE 0x0002 // underline
BLINK 0x0004 // italic (sent to client as blink)
INVERSE 0x0008 // need to invert it


MATCH_TEXT 0x0080 // match on text colour?
MATCH_BACK 0x0800 // match on background colour?
MATCH_HILITE 0x1000 // match on bold bit?
MATCH_UNDERLINE 0x2000 // match on underline?
MATCH_BLINK 0x4000 // match on blink?
MATCH_INVERSE 0x8000 // match on inverse?

Colours:

BLACK = 0
RED = 1
GREEN = 2
YELLOW = 3
BLUE = 4
MAGENTA = 5
CYAN = 6
WHITE = 7
门派:天龙寺
 楼主| 发表于 2017-12-21 03:22:55 | 显示全部楼层
还有一点,        faint版本的huashan.lua里面,有个bug还真不能乱改,就是下面这段

    DeleteTriggerGroup("huashan_find")
    create_trigger_t('huashan_find1','^( )*'..job.target..'\\((\\D*)\\)','','huashan_fight')
    create_trigger_t('huashan_find2','^(> )*看起来(\\D*)想杀死你!','','huashan_debug_fight')
    create_trigger_t('huashan_find2','^(> )*采花大盗正盯着你看,不知道打些什么主意。','','huashan_dadao')
    SetTriggerOption("huashan_find1","group","huashan_find")
    SetTriggerOption("huashan_find2","group","huashan_find")
    SetTriggerOption("huashan_find3","group","huashan_find")

明显有两个huashan_find2,我改的时候顺手就把后一个2改成3了,结果发现遇到老虎毒蛇等主动攻击的npc时,就发呆了,因为触发了这个trigger,打断了lujing里面的程序.以前这个trigger不惹事的原因,正是因为他写错了,前一个trigger被后一个trigger覆盖了,一直没成功触发.

我也不知道这个有啥用,先改成
    create_trigger_t('huashan_find2','^(> )*看起来'..job.target..'想杀死你!','','huashan_debug_fight')

目前看还没惹什么bug.

有读懂这个触发用处的大神,拜托指点一下,这样改对不对
门派:古墓派
发表于 2017-12-21 10:21:20 | 显示全部楼层
走过npc只有一种情况就是npc在no fight room,正常的房间npc会把你拦下来,busy直到开始战斗。
所以在路径里进行处理,比你这个要简单。比如如果是no fight room就使用慢速行走,其他的使用快速行走。
门派:姑苏慕容
发表于 2017-12-21 10:24:03 | 显示全部楼层
支持好学的同学!
门派:明教
发表于 2017-12-21 10:27:21 | 显示全部楼层
难道不是抓  这里没有 '..job.id..' 吗?为什么是“这个人”
而且,这个触发建立也是在看见的npc的时候,也不应该提前开启
门派:天龙寺
 楼主| 发表于 2017-12-21 15:57:11 | 显示全部楼层
fqyy@tj 发表于 2017-12-21 10:21
走过npc只有一种情况就是npc在no fight room,正常的房间npc会把你拦下来,busy直到开始战斗。
所以在路径 ...

我经常在昆仑的三圣堂遇到走过的情况,查了老书剑代码,这个地方应该不是no fight room。不知道为什么
门派:天龙寺
 楼主| 发表于 2017-12-21 16:22:50 | 显示全部楼层
xiren@tj 发表于 2017-12-21 10:27
难道不是抓  这里没有 '..job.id..' 吗?为什么是“这个人”
而且,这个触发建立也是在看见的npc的时候 ...

你说得对,触发的生存周期还是越短越好,没必要出现的时段就不应该出现。
例如这个huashan_find的TriggerGroup,是在go(huashanFindAct,dest.area,dest.room)函数前建立的还是之后建立,就能大大改变出现重名npc的概率。
门派:明教
发表于 2017-12-21 21:25:30 | 显示全部楼层
另外,看起来'..job.target..'想杀死你!的作用是什么呢?
就是当你在一个房间的时候,比如等待或者干脆就是前一秒刚到一个房间,下一瞬间NPC就自己走过来了,他会主动叫杀你,如果没有这个触发,机器人不会主动观察NPC并叫杀。
门派:天龙寺
 楼主| 发表于 2017-12-21 21:31:25 | 显示全部楼层
xiren@tj 发表于 2017-12-21 21:25
另外,看起来'..job.target..'想杀死你!的作用是什么呢?
就是当你在一个房间的时候,比如等待或者干脆就 ...

哦,多谢解惑,十分感谢....
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|书剑永恒MUD ( 闽ICP备14012032号|闽公网安备 35050202000162号 )

GMT+8, 2025-6-11 07:29 , Processed in 0.047101 second(s), 29 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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