Procházet zdrojové kódy

feat(pkuxkx): 增加北侠副本管理模块,增加四个进出副本有关的实用 event

dzp před 2 roky
rodič
revize
ba07878dd8

+ 3 - 0
mud/pkuxkx/plugins/basic/busy.tin

@@ -89,6 +89,8 @@ VAR {正在等待的回调列表}    busy.wait-list {};
 #action {^你正忙{|ID=basic/busy}$} {
     #undelay busy.on-idle;
 
+	char.MarkBusy;
+
     #if { &busy.wait-list[] == 0 } {
         #return;
     };
@@ -105,6 +107,7 @@ VAR {正在等待的回调列表}    busy.wait-list {};
 
 #action {^你不忙{|ID=basic/busy}$} {
     #undelay busy.checkbusy;
+	char.UnmarkBusy;
     #delay {busy.on-idle} {busy.on-idle} 0;
     #line gag;
 };

+ 6 - 11
mud/pkuxkx/plugins/basic/char/gmcp.tin

@@ -71,8 +71,6 @@ event.Define {char/nofight} {无参} {$MODULE} {角色脱离战斗};
 };
 
 #alias {char.gmcp.status} {
-    #local busy     {};
-    #local fight    {};
     #local hasHP1   {0};
     #local hasHP2   {0};
     #local hasScore {0};
@@ -116,11 +114,8 @@ event.Define {char/nofight} {无参} {$MODULE} {角色脱离战斗};
                 #local needUpdate[$health]  {true};
             };
             #else {
-                #if { "$name" == "忙" } {
-                    #local busy {$value};
-                };
-                #elseif { "$name" == "战斗中" } {
-                    #local fight {$value};
+                #if { "$name" == "{忙|战斗中}" } {
+					char.set-flag $name $value false;
                 };
             };
 
@@ -180,11 +175,11 @@ event.Define {char/nofight} {无参} {$MODULE} {角色脱离战斗};
             };
         };
 
-        #if { "$char.HPSummarize.Echo" == "自动" && $hasHP1 } {
-            char.HPSummarize;
+        #if { $hasHP1 } {
+            char.HPSummarize 自动;
         };
-        #elseif { "$char.HPSummarize.Echo" == "总是" } {
-            char.HPSummarize;
+        #else {
+            char.HPSummarize 总是;
         };
 
         event.Emit char/hpbrief;

+ 69 - 5
mud/pkuxkx/plugins/basic/char/hp.tin

@@ -311,31 +311,46 @@ hp -neili 格式:
     #var char[HP][当前真元]  {@char.hp.expandBigNumber{%2}};
     #var char[HP][食物]      {@char.hp.expandBigNumber{%3}};
     #var char[HP][饮水]      {@char.hp.expandBigNumber{%4}};
-    #var char[HP][战斗中]    {false};
-    #var char[HP][忙]        {false};
 
     speedo.Set {当前真气}   {$char[HP][当前真气]}   {true} {10};
     speedo.Set {食物}       {$char[HP][食物]}       {true} {10};
     speedo.Set {饮水}       {$char[HP][饮水]}       {true} {10};
 
     #if { "%5" == "1" } {
-        #var char[HP][战斗中] {true};
+        char.set-flag 战斗中 true false;
+    };
+    #else {
+        char.set-flag 战斗中 false false;
     };
 
     #if { "%6" == "1" } {
-        #var char[HP][忙] {true};
+        char.set-flag 忙 true false;
+    };
+    #else {
+        char.set-flag 忙 false false;
     };
 
     event.Emit char/hpbrief;
 
     #unvar char.parsingHP;
 
-    char.HPSummarize;
+    char.HPSummarize 自动;
 
     #line gag;
 } {2.0};
 
+#nop char.HPSummarize.Echo 有三种选择: 从不、自动、总是
 #alias {char.HPSummarize} {
+    #local level {%1};
+
+    #if { "$char.HPSummarize.Echo" == "从不" } {
+        #return;
+    };
+
+    #if { "$char.HPSummarize.Echo" == "自动" && "$level" != "自动" } {
+        #return;
+    };
+
     #local head     {};
     #local tail     {};
     #local safety   {};
@@ -544,6 +559,55 @@ hp -neili 格式:
     };
 };
 
+///=== {
+// ## char.MarkBusy <布尔值>
+//    设置角色的忙状态。
+// };
+#alias {char.MarkBusy} {char.set-flag 忙 true};
+
+///=== {
+// ## char.UnmarkBusy <布尔值>
+//    取消角色的忙状态。
+// };
+#alias {char.UnmarkBusy} {char.set-flag 忙 false};
+
+///=== {
+// ## char.MarkFight <布尔值>
+//    设置角色的战斗状态。
+// };
+#alias {char.MarkFight} {char.set-flag 战斗中 false};
+
+///=== {
+// ## char.UnmarkFight <布尔值>
+//    取消角色的战斗状态。
+// };
+#alias {char.UnmarkFight} {char.set-flag 战斗中 false};
+
+#alias {char.set-flag} {
+    #local flag  {%1};
+    #local value {%2};
+    #local summ  {@default{%3;true}};
+
+    #if { "$char[HP][$flag]" == "$value" } {
+        #return;
+    };
+
+    #var char[HP][$flag] {$value};
+
+    #switch {"$flag/$value"} {
+        #case {"忙/true"}       {event.Emit char/busy};
+        #case {"忙/false"}      {event.Emit char/nobusy};
+        #case {"战斗中/true"}   {event.Emit char/fight};
+        #case {"战斗中/false"}  {event.Emit char/nofight};
+    };
+
+    event.Emit char/hpbrief;
+
+    #if { "$summ" == "true" } {
+        char.HPSummarize 自动;
+    };
+};
+
 ///=== {
 // #@ char.IsBusy
 //    如果角色正忙,则返回真,否则返回假。无参数。

+ 1 - 0
mud/pkuxkx/plugins/basic/map/__init__.tin

@@ -24,6 +24,7 @@ event.Define {map/walk/failed}   {无参} {$MODULE} {走路机器人运行失败
 event.Define {map/init}          {无参} {$MODULE} {map 模块开始初始化。};
 
 load-file mud/pkuxkx/plugins/basic/map/room.tin;
+load-file mud/pkuxkx/plugins/basic/map/dungeon.tin;
 load-file mud/pkuxkx/plugins/basic/map/gmcp.tin;
 load-file mud/pkuxkx/plugins/basic/map/area.tin;
 load-file mud/pkuxkx/plugins/basic/map/node.tin;

+ 123 - 0
mud/pkuxkx/plugins/basic/map/dungeon.tin

@@ -0,0 +1,123 @@
+#nop 房间信息解析模块之副本管理;
+
+VAR {当前副本}      {gCurrentDungeon}    {主站};
+VAR {上一个副本}    {gPrevDungeon}       {主站};
+
+event.Define {map/EnterDungeon}     {无参} {$MODULE} {进入副本,副本的名称在变量 gCurrentDungeon 中。};
+event.Define {map/LeaveDungeon}     {无参} {$MODULE} {离开副本,副本的名称在变量 gPrevDungeon 中。};
+event.Define {map/EnterDungeonIdle} {无参} {$MODULE} {进入副本,且不再 busy,副本的名称在变量 gCurrentDungeon 中。};
+event.Define {map/LeaveDungeonIdle} {无参} {$MODULE} {离开副本,且不再 busy,副本的名称在变量 gPrevDungeon 中。};
+
+event.HandleOnce {map/init} {map/dungeon} {map} {map.Dungeon.Init};
+
+#alias {map.Dungeon.Init} {
+    event.Handle {map/GotRoomInfo}      {map/dungeon} {map} {map.Dungeon.locate};
+    event.Handle {map/EnterDungeon}     {map/dungeon} {map} {map.EnterDungeon.notice};
+    event.Handle {map/LeaveDungeon}     {map/dungeon} {map} {map.LeaveDungeon.notice};
+    event.Handle {map/EnterDungeonIdle} {map/dungeon} {map} {map.EnterDungeon.notice idle};
+    event.Handle {map/LeaveDungeonIdle} {map/dungeon} {map} {map.LeaveDungeon.notice idle};
+};
+
+#alias {map.EnterDungeon.notice} {
+    #if { "%1" == "idle" } {
+        warnLog 你来到了「$gCurrentDungeon」,你不忙。;
+    };
+    #else {
+        warnLog 你来到了「$gCurrentDungeon」。;
+        #tick dungeon.checkbusy {checkbusy} 1;
+        busy.Wait {
+            #untick dungeon.checkbusy;
+            event.Emit map/EnterDungeonIdle;
+        };
+    };
+};
+
+#alias {map.LeaveDungeon.notice} {
+    #if { "%1" == "idle" } {
+        okLog 你离开了「$gPrevDungeon」,你不忙。;
+    };
+    #else {
+        okLog 你离开了「$gPrevDungeon」。;
+        #tick dungeon.checkbusy {checkbusy} 1;
+        busy.Wait {
+            #untick dungeon.checkbusy;
+            event.Emit map/LeaveDungeonIdle;
+        };
+    };
+};
+
+#alias {map.Dungeon.locate} {
+    #if { "$gMapRoom[name]" == "" } {
+        errLog 房间信息解析不正确。;
+        #return;
+    };
+
+    #local dungeon {主站};
+
+    #if { "$gMapRoom[name]" == "%+1..S[%+1..S]" } {
+        #local dungeon {$gMapRoom[name]};
+        #replace dungeon                {%+1..S[%+1..S]} {&2};
+        #replace dungeon {任务副本} {};
+        #replace gMapRoom[name]         {[{[^\[]*}]} {};
+        #replace gMapRoom[colorName]    {[{[^\[]*}]} {};
+    };
+
+    #if { "$dungeon" == "$gCurrentDungeon" } {
+        #return;
+    };
+
+    #var gPrevDungeon       {$gCurrentDungeon};
+    #var gCurrentDungeon    {$dungeon};
+
+    #if { "$dungeon" == "主站" } {
+        event.Emit map/LeaveDungeon;
+    };
+    #else {
+        event.Emit map/EnterDungeon;
+    };
+};
+
+#action {^准备进入%S⏳$E} {
+    map.dungeon.change {%1};
+};
+
+#action {^准备退出%S...$E} {
+    map.dungeon.change {%1};
+};
+
+#alias {map.dungeon.change} {
+    #local dungeon {%1};
+
+    #nop 计有:藏经阁、鄱阳湖、万安塔、保卫襄阳、剿匪、团战、大航海等常规任务副本;
+    #nop 及剑心居、北侠影视城、游侠等三个特别副本;
+    #if { "$dungeon" != "{\[(.*)任务副本\]|北侠影视城|剑心居|游侠}" } {
+        #return;
+    };
+
+    #class map.dungeon.change open;
+
+    #action {^你进入了%1。{|ID=map/dungeon}$} {map.dungeon.change.done};
+    #action {^你退出了%1。{|ID=map/dungeon}$} {map.dungeon.change.done};
+
+    #alias {map.dungeon.change.sync} {
+        #class map.dungeon.change kill;
+        #untick map.dungeon.change.sync;
+        sync.Ignore map.dungeon.change.sync;
+        look;
+    };
+
+    #alias {map.dungeon.change.done} {
+        xtt.Tick {map.dungeon.change.sync} {
+            sync.Ignore map.dungeon.change.sync;
+            sync.Wait {map.dungeon.change.sync} {map.dungeon.change.sync};
+        } 1;
+    };
+
+    #delay {map.dungeon.change.wait} {map.dungeon.change.done} 5;
+
+    #class dungeon.enter.wait close;
+};
+
+#action {^请使用 leave 自己的id 来退出副本。$E} {leave $user[id]; #line gag};
+
+#alias {enter jxj} {enter jianxinju} {5.5};