gather.tin 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. #nop vim: set filetype=tt:;
  2. /*
  3. 本文件属于 PaoTin++ 的一部分
  4. ===========
  5. PaoTin++ © 2020~2024 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 享有并保留一切法律权利
  6. 你可以在遵照 GPLv3 协议的基础之上使用、修改及重新分发本程序。
  7. ===========
  8. */
  9. ///=== {
  10. ///// 采药/帮贡通用机器人
  11. ///// };
  12. #var bot_gather[META] {
  13. {NAME} {采集机器人}
  14. {DESC} {采药、帮贡资材通用机器人}
  15. {AUTHOR} {担子炮}
  16. {NOTE} {本文件属于 PaoTin++ 的一部分}
  17. };
  18. #func {bot/gather.Init} {
  19. #return true;
  20. };
  21. VAR {采集机器人工作模式,开始寻找} {gather.find} {bhfind};
  22. VAR {采集机器人工作模式,开始采集} {gather.cmd} {bhgather};
  23. VAR {采集机器人工作模式,移动角色} {gather.move} {bhmove};
  24. #alias {gather.Find} {
  25. #local task {%1};
  26. #if { "$task" == "{bh|bg|banghui|bangpai|banggong|帮派}" } {
  27. #var gather.find {bhfind};
  28. #var gather.cmd {bhgather};
  29. #var gather.move {bhmove};
  30. };
  31. #elseif { "$task" == "{yao|cy|caiyao|yaoshi|采药|药师}" } {
  32. #var gather.find {gather};
  33. #var gather.cmd {gather};
  34. #var gather.move {lookfor};
  35. };
  36. #class gather.lookfor open;
  37. #var caiyao-move-dir {};
  38. #alias {caiyao.lookfor.reset} {
  39. #class {gather.lookfor} open;
  40. #var caiyao-map-lineNo {0};
  41. #var caiyao-map-me {};
  42. #list caiyao-map-yao create {};
  43. #class {gather.lookfor} close;
  44. };
  45. #alias {caiyao.lookfor.move} {
  46. #local idx {};
  47. #local meRow {$caiyao-map-me[row]};
  48. #local meCol {$caiyao-map-me[col]};
  49. #local first-d {9999};
  50. #foreach {*caiyao-map-yao[]} {idx} {
  51. #local yao {$caiyao-map-yao[$idx]};
  52. #local row {$yao[row]};
  53. #local col {$yao[col]};
  54. #local distance {0};
  55. #local row-diff {0};
  56. #local col-diff {0};
  57. #local cmd1 {};
  58. #local cmd2 {};
  59. #if { $row > $meRow } {
  60. #math row-diff {$row - $meRow};
  61. #format cmd1 {s};
  62. };
  63. #elseif { $meRow > $row } {
  64. #math row-diff {$meRow - $row};
  65. #format cmd1 {n};
  66. };
  67. #else {
  68. #format row-diff {0};
  69. #format cmd1 {};
  70. };
  71. #if { $col > $meCol } {
  72. #math col-diff {$col - $meCol};
  73. #format cmd2 {e};
  74. };
  75. #elseif { $meCol > $col } {
  76. #math col-diff {$meCol - $col};
  77. #format cmd2 {w};
  78. };
  79. #else {
  80. #format col-diff {0};
  81. #format cmd2 {};
  82. };
  83. #if { $row-diff > $col-diff } {
  84. #format distance {$row-diff};
  85. };
  86. #else {
  87. #format distance {$col-diff};
  88. };
  89. #if { $distance < $first-d } {
  90. #format first-d {$distance};
  91. #format caiyao-move-dir {$cmd1$cmd2};
  92. };
  93. };
  94. #if { $first-d < 9999 } {
  95. #delay gather.move {$gather.move $caiyao-move-dir} 2;
  96. };
  97. };
  98. #action {^看你手忙脚乱的!采药不是赶集。$} {
  99. #delay gather.move { $gather.move $caiyao-move-dir} 1;
  100. };
  101. #action {^你现在搜索的位置似乎有些{药材|帮派资材},可以用{bh|}gather命令采集。$} {
  102. $gather.cmd;
  103. };
  104. #action {^你采集到了一些%%1。$} { caiyaoLog %%0 };
  105. #action {^可是什么也没有采到。$} { caiyaoLog %%0 };
  106. #action {^%*摘采难度大大超过了你能力范围%*$} { caiyaoLog %%0 };
  107. #action {^这里的药材被采完了。$} { lookfor };
  108. #action {^你要采药,必须需要找个药锄来。$} { wield yao chu };
  109. #action {药锄,因为多次使用,已经被彻底损坏了$} { wield yao chu };
  110. #action {^这里不是你要寻找帮派资材的地方。$} { #class gather.lookfor kill };
  111. #action {^这里的药材已经被采光了。$} {
  112. okLog 采药完成。;
  113. #class gather.lookfor kill;
  114. };
  115. #action {^$} {
  116. #if { $caiyao-map-lineNo != 0 } {
  117. caiyao.lookfor.move;
  118. caiyao.lookfor.reset;
  119. };
  120. };
  121. #action {^你发现了%*份帮派资材,并运送回了%*$} {
  122. okLog 帮贡任务完成。;
  123. group; group %%0;
  124. gquery -me;
  125. #class gather.lookfor kill;
  126. };
  127. #action {^{(█|★|♀)+}$} {
  128. #local line {%%0};
  129. #replace line {█} {.;};
  130. #replace line {★} {O;};
  131. #replace line {♀} {*;};
  132. #math caiyao-map-lineNo {$caiyao-map-lineNo + 1};
  133. #local item {};
  134. #local index {1};
  135. #foreach {$line} {item} {
  136. #if { "$item" == "*" } {
  137. #var caiyao-map-me {
  138. {row}{$caiyao-map-lineNo}
  139. {col}{$index}
  140. };
  141. };
  142. #elseif { "$item" == "O" } {
  143. #local yao {
  144. {row}{$caiyao-map-lineNo}
  145. {col}{$index}
  146. };
  147. #list caiyao-map-yao add {{$yao}};
  148. };
  149. #math index {$index + 1};
  150. };
  151. };
  152. #class gather.lookfor close;
  153. $gather.find;
  154. };