深入浅出制作全自动Mud机器人-条件指令
Script脚本
1
帖子
1
发布者
14
浏览
-
条件指令解决的是复杂Mud配置的问题。
Mud全自动机器人本质是一个典型的后台服务,和后台服务器一样,配置基本是多个纯文(变量)本来进行的。
同时,由于一般的Mud客户端的变量设置都没有语法支持,基本就是纯纯文本。所以会需要一个易写易读的配置格式。
这种情况下,我引入了条件指令的格式。
具体格式为
条件1 条件参数1,!条件2>#指令.参数 数据逗号分隔多个条件,前置感叹号代表取反,必须所有条件都符合。
指令参数数据看具体的实现,先不深入。
具体使用什么条件,就是从上往下依次读,看条件匹配,匹配了,就执行,不继续执行(特殊配置可能继续匹配)。
不匹配看下一条。
这样人脑比较好解读。
同时,为了避免过于复杂的场合难以解读,还引入了可选的分组的概念
分组1:条件1 条件参数1,!条件2>#指令.参数 数据这样能直观的进行组别判断。
以我最复杂的战斗设置为例
大概是这么个画风
#before #wpon;yun recover; #start yong cuff.jingang;perform unarmed.chang1;perform finger.chao and strike.qimen yun recover perform finger.chao and strike.qimen #block 秦岭 ctype qinling>#apply #before yun recover;$wpon;summon xiao;unwield xiao #start yong cuff.jingang;wield xiao;perform sword.feilong qin and finger.ding qin;get xiao;unwield xiao wield xiao;perform sword.feilong qin and finger.ding qin;get xiao;unwield xiao注意,这里还引入了block区块的概念
条件本身是有一个全局注册的
大概代码为
//注册maxexp 条件 App.Quests.Conditions.RegisterMatcher(App.Quests.Conditions.NewMatcher("maxexp", function (data, target) { return App.Data.Player.HP["经验"] <= (data - 0) })) //注册yueli 条件 App.Quests.Conditions.RegisterMatcher(App.Quests.Conditions.NewMatcher("yueli", function (data, target) { return App.Data.Player.Score["阅历"] >= (data - 0) })) //注册pot 条件 App.Quests.Conditions.RegisterMatcher(App.Quests.Conditions.NewMatcher("pot", function (data, target) { return App.Data.Player.HP["潜能"] >= (data - 0) })) //注册quest 条件 App.Quests.Conditions.RegisterMatcher(App.Quests.Conditions.NewMatcher("quest", function (data, target) { let rq = App.Quests.Running return rq && rq.ID == data })) -
J jarlyyn 在 引用了 此主题