北大侠客行MUD论坛

 找回密码
 注册
搜索
热搜: 新手 wiki 升级
查看: 5296|回复: 3

新学lua,打坐吐纳,欢迎拍砖

[复制链接]
发表于 2011-12-3 09:22:20 | 显示全部楼层 |阅读模式
  1. local info = {}

  2. info.job = "tn" -- or tn
  3. info.job0 = nil --保存工作状态
  4. info.double = false --是否双倍内力
  5. info.eforce = 10 --有效内功的十分之一
  6. info.qx = 0 --气血
  7. info.qxmax = 0
  8. info.js = 0
  9. info.jsmax = 0
  10. info.jl = 0
  11. info.jlmax = 0
  12. info.nl = 0
  13. info.nlmax = 0
  14. info.food = "ganliang"
  15. info.water = "jiudai"
  16. info.sleep_to = ""
  17. info.sleep_back = ""

  18. function test(name, line, wildcards)
  19. print("name:" .. name);
  20. print("line:" .. line);
  21. for i, v in ipairs(wildcards) do
  22. print("wcs[" .. i .. "]:" .. v);
  23. end
  24. end

  25. function gethp(name, line, wildcards)
  26. SetVariable ( "exp" , wildcards[1] );
  27. SetVariable ( "pot" , wildcards[2] );
  28. SetVariable ( "nlmax" , wildcards[3] );
  29. SetVariable ( "nl" , wildcards[4] );
  30. SetVariable ( "jlmax" , wildcards[5] );
  31. SetVariable ( "jl" , wildcards[6] );
  32. SetVariable ( "qxmax" , wildcards[8] );
  33. SetVariable ( "qx" , wildcards[9] );
  34. SetVariable ( "jsmax" , wildcards[11] );
  35. SetVariable ( "js" , wildcards[12] );
  36. end

  37. function info_init()
  38. info.qx = tonumber (GetVariable ("qx"))
  39. info.qxmax = tonumber (GetVariable ("qxmax"))
  40. info.js = tonumber (GetVariable ("js"))
  41. info.jsmax = tonumber (GetVariable ("jsmax"))
  42. info.jl = tonumber (GetVariable ("jl"))
  43. info.jlmax = tonumber (GetVariable ("jlmax"))
  44. info.nl = tonumber (GetVariable ("nl"))
  45. info.nlmax = tonumber (GetVariable ("nlmax"))
  46. info.enforce = tonumber (GetVariable ("enforce"))
  47. info.job = GetVariable ("job")
  48. if info.job == nil then
  49. SetVariable ("job", "dz")
  50. info.job = "dz"
  51. end
  52. end

  53. function check(name, line, wildcards)
  54. if wildcards[1] == "正" then
  55. --DoAfterSpecial (1, 'SendNoEcho("checkbusy")', 12)
  56. AddTimer ("my_timer", 0, 0, 1, "", 1 + 4 + 1024 + 16384, "busy")
  57. end
  58. if wildcards[1] == "不" then
  59. Send("hpbrief")
  60. Send("set job on")
  61. end
  62. end

  63. function dojob(name, line, wildcards)
  64. AddTimer ("my_timer_fadai", 0, 8, 30, "", 1 + 4 + 1024 + 16384, "busy")
  65. Send("eat " .. info.food)
  66. Send("drink " .. info.water)
  67. if info.job == 'dz' then
  68. dz()
  69. end
  70. if info.job == 'tn' then
  71. tn()
  72. end
  73. end

  74. function dz()
  75. info_init()

  76. if info.nl < 100 then
  77. print("内力不够啊,等待30秒恢复")
  78. --DoAfterSpecial (30, 'SendNoEcho("checkbusy")', 12)
  79. AddTimer ("my_timer", 0, 0, 30, "", 1 + 4 + 1024 + 16384, "busy")
  80. return
  81. end

  82. local diff = 2 * info.nlmax - info.nl + 1
  83. diff = (info.nlmax < 1000) and math.ceil(diff/2) or diff

  84. if info.double then
  85. if diff <= info.qx then
  86. local _diff = (info.nlmax < 1000) and diff*2 or diff
  87. print("_diff:" .. _diff)
  88. if _diff + info.nl > info.nlmax * 2 then
  89. info.job = info.job0
  90. info.job0 = nil
  91. info.double = nil
  92. print("双倍内力恢复完成,继续未完成的工作:" .. info.job)
  93. SendNoEcho("checkbusy")
  94. return
  95. end
  96. end
  97. end

  98. if info.js < info.jsmax * 0.6 then
  99. print("精神不佳啊,恢复(exert regenerate)")
  100. --Send("exert regenerate")
  101. --DoAfterSpecial (15, 'SendNoEcho("checkbusy")', 12)
  102. AddTimer ("my_timer", 0, 0, 15, "", 1 + 4 + 1024 + 16384, "busy")
  103. return
  104. end

  105. if info.qx < info.qxmax * 0.3 then
  106. print("气血不佳啊,恢复(exert recover)")
  107. --Send("exert recover")
  108. --DoAfterSpecial (15, 'SendNoEcho("checkbusy")', 12)
  109. AddTimer ("my_timer", 0, 0, 15, "", 1 + 4 + 1024 + 16384, "busy")
  110. return
  111. end

  112. diff = (diff > info.qx * 0.8) and (math.floor((info.qx / info.enforce) / 2) * info.enforce) or diff

  113. diff = (diff < 10) and 10 or diff

  114. Send("dazuo " .. diff)
  115. SendNoEcho("checkbusy")

  116. end

  117. function tn()
  118. info_init()

  119. if info.nl < 100 then
  120. print("内力不够啊,等待30秒恢复")
  121. info.job0 = info.job
  122. info.job = "dz"
  123. info.double = true
  124. --DoAfterSpecial (30, 'SendNoEcho("checkbusy")', 12)
  125. AddTimer ("my_timer", 0, 0, 30, "", 1 + 4 + 1024 + 16384, "busy")
  126. return
  127. end

  128. local diff = 2 * info.jlmax - info.jl + 1
  129. diff = (info.jlmax < 1000) and math.ceil(diff/2) or diff

  130. if info.qx < info.qxmax * 0.6 then
  131. print("气血不佳啊,恢复(exert recover)")
  132. --Send("exert recover")
  133. --DoAfterSpecial (15, 'SendNoEcho("checkbusy")', 12)
  134. AddTimer ("my_timer", 0, 0, 15, "", 1 + 4 + 1024 + 16384, "busy")
  135. return
  136. end

  137. if info.js < info.jsmax * 0.3 then
  138. print("精神不佳啊,恢复(exert regenerate)")
  139. Send("exert regenerate")
  140. --DoAfterSpecial (1, 'SendNoEcho("checkbusy")', 12)
  141. AddTimer ("my_timer", 0, 0, 1, "", 1 + 4 + 1024 + 16384, "busy")
  142. return
  143. end

  144. diff = (diff > info.js * 0.8) and (math.floor((info.js / info.enforce) / 2) * info.enforce) or diff

  145. diff = (diff < 10) and 10 or diff

  146. Send("tuna " .. diff)
  147. SendNoEcho("checkbusy")

  148. end

  149. function busy()
  150. SendNoEcho("checkbusy")
  151. end

  152. function start()
  153. EnableTriggerGroup ("dztn", true)
  154. Send("checkbusy")
  155. end

  156. function stop()
  157. DeleteTimer("my_timer")
  158. DeleteTimer("my_timer_fadai")
  159. EnableTriggerGroup ("dztn", false)
  160. end
复制代码

北大侠客行MUD,中国最好的MUD

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
北大侠客行Mud(pkuxkx.net),最好的中文Mud游戏!
 楼主| 发表于 2011-12-3 09:41:15 | 显示全部楼层
使用起来很简单啊
北大侠客行Mud(pkuxkx.net),最好的中文Mud游戏!
发表于 2011-12-3 09:41:22 | 显示全部楼层
北大侠客行Mud(pkuxkx.net),最好的中文Mud游戏!
发表于 2019-3-20 09:32:45 | 显示全部楼层
北大侠客行Mud(pkuxkx.net),最好的中文Mud游戏!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|北大侠客行MUD ( 京ICP备16065414号-1 )

GMT+8, 2024-4-17 05:30 AM , Processed in 0.012369 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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