Skip to content

Commit

Permalink
fix(pkuxkx): 逍遥行支持走路失败时触发回调
Browse files Browse the repository at this point in the history
  • Loading branch information
dzpao committed May 8, 2024
1 parent c3171b6 commit e27331b
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 23 deletions.
4 changes: 4 additions & 0 deletions mud/pkuxkx/plugins/basic/map/node.tin
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ event.Define {map/GotNodeInfo} {无参} {$MODULE} {已经获取到节点信息
xtt.SendBatch {$node[args]};
sync.Wait {map.WalkNodes.walk-next};
};
#elseif { "$node[step]" == "Path" } {
event.HandleOnce map/walk/continue {map/path/end} {map/xiaoyao} {map.WalkNodes.walk-next};
path.Walk $node[args];
};
#elseif { "$node[step]" == "{[A-Z][A-Za-z0-9]+}" } {
#local bot {$node[step]};
event.HandleOnce map/walk/continue {map.$bot} {map} {map.WalkNodes.walk-next};
Expand Down
66 changes: 49 additions & 17 deletions mud/pkuxkx/plugins/basic/map/step.tin
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,14 @@ VAR {清除门卫命令,默认为 attack} map.step.crush.cmd {attack};
// - LxcEnter: 进凌霄城 LxcEnter 进凌霄城机器人
// - Maze: 迷宫走路 Maze/云海进 按照云海进入走法穿越迷宫
// - Path: 连续走路 Path/{n;w;e;s} 连续走好几个步骤,视同为一个 Step
// - Bot: 机器走路 Foo/bar 机器名为 Foo,并需要 bar 参数
// - Bot: 机器走路 Bot/foo 机器名为 foo,不带参数
// - Bot: 机器走路 Bot/foo/bar 机器名为 foo,并且需要 bar 参数
// - OldBot: 机器走路 Foo/bar 机器名为 Foo,并需要 bar 参数
//
// 这些走路方式因为其特殊性,已经基本上无法通过出口来完成了,因此要用专门的机器人来走路。
// 如果不同的房间存在于类似的行走方式,典型的比如渡口,那么机器人就具有一定的通用性。
// 否则机器人基本上是为某房间定制的。这里统一用 Bot 方式来表示,不再区分。规则是:
// 否则机器人基本上是为某房间定制的。大体上,机器分两种,一种是 MBS Bot,另一种是老式的
// 机器人写法,这里统一用 OldBot 方式来表示,不再区分。规则是:
//
// - 凡是大骆驼格式打头的命令,则一律当成机器走路来处理。后面用斜杠提供参数,
// 如果存在多个参数,以大括号包裹的字符串列表形式表示。
Expand All @@ -115,6 +118,7 @@ VAR {清除门卫命令,默认为 attack} map.step.crush.cmd {attack};
// - Answer: 回答口令 Answer/自立为王/north 回答自立为王,然后往北
// - Ask: 征得许可 Ask/shiwei/通传/east 向侍卫请求通传,然后向东
// - Unwield: 卸下武器 Unwield/east 卸下武器,然后向东
// - Guard: 通过守卫 Guard/xiao daotong/west 此处存在守卫 xiao daotong,把守西方
// 对于无法归类的关卡,可以用以下两个通用的方式来解决:
// - Prepare: 前置动作 Prepare/yell bridge/north 执行命令 yell bridge,然后向北
// - Postpare: 后置动作 Postpare/sheng bridge/north 向北离开之后,执行命令 sheng bridge
Expand Down Expand Up @@ -203,8 +207,10 @@ VAR {清除门卫命令,默认为 attack} map.step.crush.cmd {attack};
#match {"GuoJiang"} {map.pl.helper {} {GuoJiang} };
#match {"GuoHe"} {map.pl.helper {} {GuoHe} };
#match {"Ride"} {map.pl.helper {} {Ride} };
#match {"Ride/%+"} {map.pl.helper {} {Ride} {dir} {&1}; };
#match {"Maze/%+"} {map.pl.helper {} {Maze} {name} {&2}; };
#match {"Ride/%+"} {map.pl.helper {} {Ride} {dir} {&1} };
#match {"Maze/%+"} {map.pl.helper {} {Maze} {name} {&2} };
#match {"Bot/%+"} {map.pl.helper {} {Bot} {bot} {{name}{&1}} };
#match {"Bot/%+/%*"} {map.pl.helper {} {Bot} {bot} {{name}{&1}{args}{&2}} };

#match {"Cond/%+/%+"} {
#var step {&2};
Expand All @@ -218,7 +224,7 @@ VAR {清除门卫命令,默认为 attack} map.step.crush.cmd {attack};
};
};

#match {"{[A-Z][^/]*}/%+"} {map.pl.helper {} {Bot} {name} {&1}; #var link[args] {&2} };
#match {"{[A-Z][^/]*}/%+"} {map.pl.helper {} {OldBot} {name} {&1}; #var link[args] {&2} };

#match {"{[A-Z]+}"} {
#if { @dir.IsDir{@str.ToLower{$step}} } {
Expand All @@ -228,7 +234,7 @@ VAR {清除门卫命令,默认为 attack} map.step.crush.cmd {attack};
#var link[cmd] {$exit};
};
#else {
#var link[type] {Bot};
#var link[type] {OldBot};
#var link[name] {$step};
};
#var step {};
Expand All @@ -241,7 +247,7 @@ VAR {清除门卫命令,默认为 attack} map.step.crush.cmd {attack};
#var link[cmd] {$map.step.go.cmd $exit};
};
#else {
#var link[type] {Bot};
#var link[type] {OldBot};
#var link[name] {$step};
};
#var step {};
Expand All @@ -265,15 +271,21 @@ VAR {清除门卫命令,默认为 attack} map.step.crush.cmd {attack};
};

#alias {map.step.Try} {
#class map.step.Try.do open;
map.step.Try.do try {%1} {%2} {%3};
#class map.step.Try.do close;
};

#alias {map.step.Must} {
#class map.step.Try.do open;
map.step.Try.do must {%1} {%2} {%3};
#class map.step.Try.do close;
};

#alias {map.step.Should} {
#class map.step.Try.do open;
map.step.Try.do should {%1} {%2} {%3};
#class map.step.Try.do close;
};

#alias {map.step.Try.do} {
Expand Down Expand Up @@ -316,14 +328,14 @@ VAR {清除门卫命令,默认为 attack} map.step.crush.cmd {attack};
};

#case {"{Normal|Dynamic}"} {
event.HandleOnce GMCP.Move {map/step/try} {map} {map.step.Try.result};
event.ClassHandleOnce GMCP.Move {map/step/try} {map} {map.step.Try.result};
xtt.Send {$link[cmd]};
};

#case {"Hidden"} {
#local token {@sync.UUID{}};
#line sub var sync.Wait {
event.HandleOnce GMCP.Move {map/step/try} {map} {
event.ClassHandleOnce GMCP.Move {map/step/try} {map} {
sync.Ignore $token;
map.step.Try.ok;
};
Expand All @@ -337,12 +349,20 @@ VAR {清除门卫命令,默认为 attack} map.step.crush.cmd {attack};

#case {"{GuoJiang|GuoHe|Shalou|Ride}"} {
#local bot {$link[type]};
event.HandleOnce map/walk/continue {map.$bot} {map.step.Try.do} {map.step.Try.ok};
event.HandleOnce map/walk/failed {map.$bot} {map.step.Try.do} {map.step.Try.fail};
event.ClassHandleOnce map/walk/continue {map.$bot} {map.step.Try.do} {map.step.Try.ok};
event.ClassHandleOnce map/walk/failed {map.$bot} {map.step.Try.do} {map.step.Try.fail};
map.$bot;
};

#case {"Bot"} {
#case {"OldBot"} {
#local bot {$link[bot][name]};
#local args {$link[bot][args]};
event.ClassHandleOnce map/walk/continue {map.Bot} {map.step.Try.do} {map.step.Try.ok};
event.ClassHandleOnce map/walk/failed {map.Bot} {map.step.Try.do} {map.step.Try.fail};
map.Bot {$bot} {$args};
};

#case {"OldBot"} {
#local bot {$link[name]};

#if { ! @existsAlias{map.$bot} } {
Expand All @@ -351,8 +371,8 @@ VAR {清除门卫命令,默认为 attack} map.step.crush.cmd {attack};
#return;
};

event.HandleOnce map/walk/continue {map.$bot} {map.step.Try.do} {map.step.Try.ok};
event.HandleOnce map/walk/failed {map.$bot} {map.step.Try.do} {map.step.Try.fail};
event.ClassHandleOnce map/walk/continue {map.$bot} {map.step.Try.do} {map.step.Try.ok};
event.ClassHandleOnce map/walk/failed {map.$bot} {map.step.Try.do} {map.step.Try.fail};

#if { "$link[args]" == "" } {
map.$bot;
Expand All @@ -364,8 +384,8 @@ VAR {清除门卫命令,默认为 attack} map.step.crush.cmd {attack};

#case {"Maze"} {
#local maze {$link[name]};
event.HandleOnce map/walk/continue {map.Maze $maze} {map.explore.try-go} {map.step.Try.ok};
event.HandleOnce map/walk/failed {map.Maze $maze} {map.explore.try-go} {map.step.Try.fail};
event.ClassHandleOnce map/walk/continue {map.Maze $maze} {map.explore.try-go} {map.step.Try.ok};
event.ClassHandleOnce map/walk/failed {map.Maze $maze} {map.explore.try-go} {map.step.Try.fail};
map.Maze $maze;
};

Expand Down Expand Up @@ -403,11 +423,13 @@ VAR {清除门卫命令,默认为 attack} map.step.crush.cmd {attack};

#alias {map.step.Try.ok} {
event.Emit map/walk/continue map/step;
#class map.step.Try.do kill;
};

#alias {map.step.Try.fail} {
errLog 行走失败。;
event.Emit map/walk/failed map/step;
#class map.step.Try.do kill;
};

#alias {map.step.Try.result} {
Expand Down Expand Up @@ -496,10 +518,12 @@ VAR {清除门卫命令,默认为 attack} map.step.crush.cmd {attack};
ask shou jiang about 投军; map.step.Try.retry;
};

#nop 武当山的乌鸦岭;
#action {^小土匪把路一挡,狞笑道:怎么,想溜,没那么容易!$} {map.step.Try.crush {xiao tufei}};
#nop 北京的鳌府后院,不吃神行千里,杀人可进;
#action {^女管家挡住了你。$} {map.step.Try.crush {guan jia}};
#nop 扬州的财主后院,不吃神行千里,杀人可进;
#action {^崔员外挡住了你。$} {map.step.Try.crush {cui yuanwai}};
#action {^崔员外挡住了你的去路。$} {map.step.Try.crush {cui yuanwai}};

#nop 扬州的衙门大门;
#action {^衙役喝道:「威……武……」$} {map.step.Try.crush {ya yi}};
Expand Down Expand Up @@ -734,6 +758,14 @@ VAR {清除门卫命令,默认为 attack} map.step.crush.cmd {attack};
};
};

#alias {map.Bot} {
#local name {%1};
#local args {%2};

errLog TODO: map.Bot 尚未实现。;
map.step.Try.fail;
};

#alias {map.ui.step} {
map.step.Try {@map.RID{$gMapRoom}} {%1};
};
19 changes: 13 additions & 6 deletions mud/pkuxkx/plugins/basic/map/xiaoyao.tin
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,17 @@ VAR {逍遥行正在赶路} {xiaoyao.under-way} {0};
#local target {%1};
#local callback {%22};

#if { "$callback" == "" } {
#local callback {#0};
#local hook {map/xiaoyao/@uuid{}};

#class xiaoyao.Goto open;

#if { "$callback" != "" } {
#line sub {escapes;var} #alias {xiaoyao.Goto.end} {#class xiaoyao.Goto kill; $callback};
event.ClassHandleOnce {map/walk/continue} {$hook} {map/xiaoyao} {xiaoyao.Goto.end};
event.ClassHandleOnce {map/walk/failed} {$hook} {map/xiaoyao} {xiaoyao.Goto.end};
};

#local hook {map/xiaoyao/@uuid{}};
#line sub {escapes;var} event.HandleOnce {map/walk/continue} {$hook} {map/xiaoyao} {$callback};
#class xiaoyao.Goto close;

xiaoyao.goto {$target} {$hook} {xiaoyao.GotoThen};
};
Expand Down Expand Up @@ -423,7 +428,9 @@ VAR {逍遥行正在赶路} {xiaoyao.under-way} {0};

#alias {xiaoyao.goto.cancel} {
#local hook {%1};
event.UnHandle {map/walk/continue} {$hook} {map/xiaoyao};
#if { "$hook" != "" } {
event.DelayEmit {map/walk/failed} {$hook};
};
};

#alias {xiaoyao.walk-end} {
Expand Down Expand Up @@ -460,7 +467,7 @@ VAR {逍遥行正在赶路} {xiaoyao.under-way} {0};
#return;
};

#nop 空闲,没有移动,可能是节点,那么就具体调查一下。;
dbgLog map => 空闲,没有移动,看名字($gMapRoom[name])可能是节点,那么决定调查一下。;
event.HandleOnce {map/GotArea} {xiaoyao.locate} {map/xiaoyao} {xiaoyao.locate};
map.GetArea;
};
Expand Down
2 changes: 2 additions & 0 deletions plugins/basic/map/__init__.tin
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ load-file plugins/basic/map/step.tin;
load-file plugins/basic/map/path.tin;
load-file plugins/basic/map/xiaoyao.tin;
load-file plugins/basic/map/helper.tin;
load-file plugins/basic/map/maze.tin;
load-file plugins/basic/map/dfs.tin;
load-file plugins/basic/map/tab.tin;
load-file plugins/basic/map/utils.tin;

Expand Down

0 comments on commit e27331b

Please sign in to comment.