找回密码
 注册
搜索
查看: 1563|回复: 21

自动打护具

[复制链接]
门派:明教
发表于 2020-3-1 00:12:27 | 显示全部楼层 |阅读模式
本帖最后由 kkfromch@tj 于 2020-3-1 19:09 编辑

话不多说,直接上code:

armor.lua底部——

  1. ------自动打护具by无法风2020.2.29------
  2. function dazaoSomething()
  3.             job.name='dazao'
  4.         tmp.dazao=0
  5.         local l_result
  6.         local l_dazao
  7.         local l_dazaoTimes
  8.                 local l_dazaoValue
  9.         l_result=utils.inputbox ("你需要打造的护具ID是", "dazaoID", GetVariable("dazaoID"), "宋体" , "12")
  10.         if not isNil(l_result) then
  11.                 SetVariable("dazaoID",l_result)
  12.                 l_dazao=l_result
  13.                 print(GetVariable("dazaoID"))
  14.          end
  15.         l_result=utils.inputbox ("你需要打造的次数", "dazaoTimes", GetVariable("dazaoTimes"), "宋体" , "12")
  16.         if not isNil(l_result) then
  17.                 SetVariable("dazaoTimes",l_result)
  18.                 l_dazaoTimes=l_result
  19.                 print(GetVariable("dazaoTimes"))
  20.          end
  21.                 l_result=utils.inputbox ("你需要保存的属性值(例如:2就是属性>=2的保存)。", "dazaoValue", GetVariable("dazaoValue"), "宋体" , "12")
  22.         if not isNil(l_result) then
  23.                 SetVariable("dazaoValue",l_result)
  24.                 l_dazaoValue=l_result
  25.                 print(GetVariable("dazaoValue"))
  26.          end
  27.         DeleteTriggerGroup("dazaoSomething")
  28.         create_trigger_t('dazaoSomething1',"^(> )*你忙碌了好一阵之后,总算织造完了",'','dazaoSomething_check')
  29.                 create_trigger_t('dazaoSomething2',"^(> )*你很得意的拿起刚织造好的(\\D*)左看右看。",'','armor_name')
  30.                 create_trigger_t('dazaoSomething3',"^(> )*你的剪刀坏掉了!",'','jiandao_broken')
  31.         SetTriggerOption("dazaoSomething1","group","dazaoSomething")
  32.                 SetTriggerOption("dazaoSomething2","group","dazaoSomething")
  33.                 SetTriggerOption("dazaoSomething3","group","dazaoSomething")
  34.         check_busy(dazao_food_check)
  35. end
  36. function dazao_food_check()
  37.    exe('hp')
  38.    if hp.food<100 or hp.water<100 then
  39.       return go(dazao_eat_go,'武当山','茶亭')
  40.    else
  41.           checkBags()
  42.           return checkWait(dazaoArmorStart,2)
  43.    end
  44. end
  45. function dazao_eat_go()
  46.    if locl.room=="茶亭" then
  47.    flag.food=0  
  48.    step_docheck()
  49.    wait.make(function()
  50.        wait.time(common_walk)
  51.        exe('sit chair;knock table;get tao;#3(eat tao)')
  52.    end)
  53.    wait.make(function()
  54.        wait.time(1)
  55.        exe('get cha;#3(drink cha);drop cha;drop tao;#3(drink jiudai);fill jiudai')
  56.        quick_locate=1
  57.        return check_bei(dazao_food_check)
  58.    end)
  59.     else
  60.        return go(dazao_eat_go,'武当山','茶亭')
  61.     end
  62. end
  63. function jiandao_broken()
  64.         flag.jiandao=false
  65. end
  66. function dazaoArmorStart()
  67.         if not Bag["剪刀"] then
  68.            cntr1 = countR(3)
  69.            return go(dazaoQu,"扬州城","杂货铺")
  70.         else
  71.            flag.jiandao=true
  72.            return check_busy(dazaoGo)
  73.     end
  74. end
  75. function dazaoQu()
  76.     exe('qu jian dao')
  77.     checkBags()
  78.     return check_bei(dazaoQuCheck,1)
  79. end
  80. function dazaoQuCheck()
  81.         if cntr1()> 0 and not Bag["剪刀"] then
  82.            return dazaoQu()
  83.         end
  84.     if Bag["剪刀"] then
  85.            flag.jiandao=true
  86.            return check_busy(dazaoGo)
  87.         else
  88.            flag.jiandao=false
  89.            return dazaoFind()
  90.         end
  91. end
  92. function dazaoGo()
  93.         weapon_unwield()
  94.         exe('follow none;wield jian dao')
  95.         return dazaoArmorGoon()
  96. end
  97. dazaoFollow=function()
  98.     flag.find = 1
  99.         exe('follow yangcan popo')
  100.         create_timer_s('walkWait4',0.5,'follow_yangcan_popo')
  101. end
  102. function follow_popo()
  103.         exe('follow yangcan popo')
  104. end
  105. dazaoFind=function()
  106.     DeleteTriggerGroup("dazaoFind")
  107.     create_trigger_t('dazaoFind1','^(> )*\\s*养蚕婆婆\\(Yangcan popo\\)','','dazaoFollow')
  108.     create_trigger_t('dazaoFind2','^(> )*这里没有 yangcan popo','','dazaoFindGoon')
  109.         create_trigger_t('dazaoFind3','^(> )*你决定跟随\\D*一起行动。','','dazaoBuy')
  110.         create_trigger_t('dazaoFind4','^(> )*你已经这样做了。','','dazaoBuy')
  111.         create_trigger_t('dazaoFind5','^(> )*你.*从养蚕婆婆那里买下了一把剪刀。','','dazaoBuy_done')
  112.     SetTriggerOption("dazaoFind1","group","dazaoFind")
  113.         SetTriggerOption("dazaoFind2","group","dazaoFind")
  114.         SetTriggerOption("dazaoFind3","group","dazaoFind")
  115.         SetTriggerOption("dazaoFind4","group","dazaoFind")
  116.         SetTriggerOption("dazaoFind5","group","dazaoFind")
  117.         EnableTriggerGroup("dazaoFind",false)
  118.         cntr1 = countR(20)
  119.         return go(dazaoFact,"changan/northjie2")
  120. end
  121. function dazaoBuy_done()
  122.         flag.jiandao=true
  123. end
  124. dazaoFact=function()
  125.         EnableTriggerGroup("dazaoFind",true)
  126.         exe('look')
  127.         return find()
  128. end
  129. dazaoBuy=function()
  130.         EnableTimer('walkWait4',false)
  131.         EnableTriggerGroup("dazaoFind",false)
  132.         EnableTrigger("dazaoFind5",true)
  133.         exe('buy jian dao')
  134.         locate()
  135.         checkBags()
  136.         return checkWait(dazaoItem,2)
  137. end
  138. dazaoItem=function()
  139.         print(Bag["剪刀"])
  140.         if cntr1()>0 and not flag.jiandao then
  141.            return dazaoBuy()
  142.         end
  143.         if not flag.jiandao then
  144.            return dazaoGoCun()
  145.         else
  146.            return check_busy(dazaoGo)
  147.         end
  148. end
  149. dazaoFindGoon=function()
  150.         EnableTimer('walkWait4',false)
  151.     flag.wait=0
  152.         flag.find=0
  153.         return walk_wait()
  154. end
  155. dazaoGoCun=function()
  156.     EnableTriggerGroup("dazaoFind",false)
  157.         EnableTimer("walkWait4",false)
  158.         cntr2 = countR(3)
  159.         exe('unwield jian dao')
  160.         return go(dazaoCun,"扬州城","杂货铺")
  161. end
  162. dazaoCun=function()
  163.     exe('unwield jian dao')
  164.     if not Bag["剪刀"] then
  165.        return dazao_finish()
  166.         end
  167.     if cntr2()>0 and Bag["剪刀"] then
  168.            exe('cun jian dao')
  169.            checkBags()
  170.            return check_busy(dazaoCun,1)
  171.         end
  172.         return dazao_finish()
  173. end
  174. function dazaoSomething_check()
  175.         create_trigger_t('dazaoArmorLog','^(> )*它的功能有:【(\\N*)】','','dazao_checkItem')
  176.         SetTriggerOption("dazaoArmorLog","group","dazaolog")
  177.         check_busy(dazaoSomething_check1)
  178. end
  179. function dazaoSomething_check1()
  180.         exe('look '..GetVariable("dazaoID"))
  181. end
  182. function dazao_checkItem(n,l,w)
  183.         dazaoArmorCheckValue(w[2])
  184.         DeleteTriggerGroup("dazaolog")
  185. end
  186. function dazaoArmorCheckValue(msg)
  187.         local tmpitem=0
  188.         local tmptotal=0
  189.         for v in pairs(fqyytmp.attValue) do
  190.                 _,_,tmpitem=string.find(msg,v.."+(%d+)")
  191.                 if tmpitem~=nil then
  192.                         print(v..":"..tmpitem)
  193.                         if (v=='悟性' or v=='身法' or v=='力量' or v=='根骨') and tmpitem*1>=tonumber(GetVariable("dazaoValue")) then
  194.                fqyytmp.goCunArmor=1
  195.                            if tmpitem*1>=5 then
  196.                                   tmp.dazao=tonumber(GetVariable("dazaoTimes"))
  197.                                   messageShow('出神器了,本次打造终止!','red','black')
  198.                            end
  199.             end
  200.                 end
  201.         end
  202.     if fqyytmp.goCunArmor==1 then
  203.            fqyytmp.goCunArmor=0
  204.            fqyyArmorMessage('装备属性:'..msg)
  205.            return dazaoArmorSave()
  206.     else
  207.            return dazaoArmorDis()
  208.         end       
  209. end
  210. function armor_name(n,l,w)
  211.         if w[2]==nil then return end
  212.         fqyytmp.tmpArmorName=w[2]
  213.         if string.find(w[2],'青龙') or string.find(w[2],'白虎') or string.find(w[2],'玄武') or string.find(w[2],'朱雀') then
  214.            fqyytmp.goCunArmor=1
  215.         end
  216.         print('fqyytmp.tmpArmorName='..fqyytmp.tmpArmorName)
  217. end
  218. function dazaoArmorSave()
  219.         Bag[fqyytmp.tmpArmorName]=true
  220.         go(dazaoArmorSave1,'city/zahuopu')
  221. end
  222. function dazaoArmorSave1()
  223.     if Bag[fqyytmp.tmpArmorName] then
  224.            exe('cun '..GetVariable("dazaoID"))
  225.            checkBags()
  226.            return check_busy(dazaoArmorSave1,1)
  227.         end
  228.         fqyyArmorMessage('保存了'..fqyytmp.tmpArmorName)
  229.         return dazaoArmorGoon()       
  230. end
  231. function dazaoArmorGoon()
  232.         go(dazaoSomething_add,'zhiye/caifengpu1')
  233. end
  234. function dazaoSomething_add()
  235.         DeleteTriggerGroup("armorDis")
  236.     if locl.room~='裁缝铺' then
  237.            return dazaoArmorGoon()
  238.         end
  239.     if tmp.dazao>=tonumber(GetVariable("dazaoTimes")) then
  240.        EnableTriggerGroup("dazaoSomething",false)
  241.        DeleteTriggerGroup("dazaoSomething")
  242.        return check_busy(dazaoGoCun)
  243.     end
  244.         if not flag.jiandao then
  245.            return dazaoFind()
  246.         end
  247.     check_busy(dazaoSomething_dazao)
  248. end
  249. function dazaoSomething_dazao()
  250.         tmp.dazao=tmp.dazao or 0
  251.     tmp.dazao=tmp.dazao+1
  252.         fqyytmp.goCunArmor=0
  253.     print('本次打造第'..tmp.dazao..'次,预计打造'..GetVariable("dazaoTimes")..'次。')
  254.     exe('weave '..GetVariable("dazaoID"))
  255. end
  256. function dazaoArmorDis()
  257.     create_trigger_t('armorDis1','^(> )*(\\D*)被拆解为一堆(\\D*)落在桌上,被你拣起收进背囊。','','dazaoSomething_add')
  258.         SetTriggerOption("armorDis1","group","armorDis")
  259.         exe('dismantle '..GetVariable("dazaoID"))
  260.         exe('y')
  261. end
  262. function dazao_finish()
  263.         job.name='idle'
  264.         flag.jiandao=false
  265.         DeleteTriggerGroup("dazaoSomething")
  266.         DeleteTriggerGroup("dazaoFind")
  267.         DeleteTriggerGroup("dazaolog")
  268.         DeleteTriggerGroup("armorDis")
  269.     exe('drop jian dao')
  270.         return check_food()
  271. end
复制代码

评分

1

查看全部评分

门派:明教
 楼主| 发表于 2020-3-1 00:15:24 | 显示全部楼层
shujian.lua——

  1. function setAlias()
  2.         create_alias_s('dzsome','dzsome','dazaoSomething')
复制代码


下边语句加到idle_set()函数里,打得时间久得话,可以屏蔽发呆函数。
  1.         if job.name=='dazao' then
  2.            exe('aq')
  3.            print('正在打造中...')
  4.            return
  5.         end
复制代码
门派:明教
 楼主| 发表于 2020-3-1 00:18:35 | 显示全部楼层
lujing.lua——

下边语句加到find_nobody=function()函数,末尾语句return go(check_heal,'大理城','药铺') 的前边,作用是找不到养蚕婆婆的话,把打造的一堆触发器都关掉,免得这些触发器干扰机器人运转。

  1.         if job.name=='dazao' then
  2.            return dazao_finish()
  3.         end
复制代码
门派:明教
 楼主| 发表于 2020-3-1 00:21:13 | 显示全部楼层
使用说明:

1. stop
2. dzsome
3. 输入需要打造的护具id,次数和保留的属性值。
4. 机器人先去杂货铺检查是否有剪刀,有就取出来去长安裁缝铺打造,没有就自动寻找养蚕婆婆购买,如果打造过程中剪刀坏掉,也会自动购买,并继续打造。
5. 如果打造次数到了,或者没有买到剪刀,自动返回任务。
6. 发呆已屏蔽,但未考虑吃喝问题,请勿长时间挂机打造,这不是全自动。

花了2个小时临时写的,测试了3个小时,基本上感觉没啥问题了,不论是dismantle还是自动保存,还是买剪刀存剪刀,都没发现有问题。

如果大家发现有什么不足,欢迎留言,我会找时间再完善!
门派:明教
发表于 2020-3-1 00:34:12 来自手机 | 显示全部楼层
谢谢风神无私的奉献   
门派:明教
发表于 2020-3-1 00:37:04 来自手机 | 显示全部楼层
明天去跟风打造几个试试去
门派:明教
发表于 2020-3-1 00:37:59 | 显示全部楼层
不错,明天尝试下 ,感谢                                                                       
门派:明教
 楼主| 发表于 2020-3-1 00:58:16 | 显示全部楼层
没啥,主要是难得m这么积极,咱也得配合把机器人更新搞上去吧?

不能老m吭哧瘪肚之的更新,咱们搞机器的都不响应吧?

走起,走起!
门派:明教
发表于 2020-3-1 01:04:15 | 显示全部楼层
感谢小风神分享,这一句好像少了个'
create_trigger_t('dazaoArmorLog','^(> )*它的功能有:【(\\N*)】,'','dazao_checkItem')
是不是该是这样?
  1. create_trigger_t('dazaoArmorLog','^(> )*它的功能有:【(\\N*)】','','dazao_checkItem')
复制代码
门派:明教
 楼主| 发表于 2020-3-1 01:06:09 | 显示全部楼层
aoxue@tj 发表于 2020-3-1 01:04
感谢小风神分享,这一句好像少了个'
create_trigger_t('dazaoArmorLog','^(> )*它的功能有:【(\\N*)】,' ...

没错,你再仔细看看,都是单引号!

没有用双引号。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|书剑永恒MUD ( 闽ICP备14012032号|闽公网安备 35050202000162号 )

GMT+8, 2025-6-4 21:21 , Processed in 0.040097 second(s), 27 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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