万王之王 KOK King of Kings

 找回密码
 加入我们
查看: 957|回复: 6

按键精灵:根据当前坐标去计算拾取范围或者npc的地址码

[复制链接]
发表于 2017-11-20 11:14 | 显示全部楼层 |阅读模式
本帖最后由 seemifly 于 2017-11-20 11:21 编辑

这里给出一个思路,希望可以帮助到大家。
  1. [General]
  2. SyntaxVersion=2
  3. BeginHotkey=121
  4. BeginHotkeyMod=0
  5. PauseHotkey=0
  6. PauseHotkeyMod=0
  7. StopHotkey=123
  8. StopHotkeyMod=0
  9. RunOnce=1
  10. EnableWindow=
  11. MacroID=80b3da3c-1d70-4f0d-9279-c48195503760
  12. Description=¥ú«Æ ’Ω ø
  13. Enable=1
  14. AutoRun=0
  15. [Repeat]
  16. Type=0
  17. Number=1
  18. [SetupUI]
  19. Type=2
  20. QUI=
  21. [Relative]
  22. SetupOCXFile=
  23. [Comment]

  24. [Script]
  25. Global hwnd, DelayForEachRound, Weapon1, Weapon2, StartCoorX,StartCoorY,ShopLoc,AmtEachRound,AmtEarn
  26. hwnd = Plugin.Window.MousePoint()
  27. Call ¥ÛƒÆ◊¢≤·∞Û∂®

  28. DelayForEachRound = 50000
  29. Weapon1 = "biubiu"
  30. Weapon2 = "great sword"
  31. StartCoorX = 32
  32. StartCoorY = 33
  33. ShopLoc = 2228257
  34. AmtEachRound = 1850
  35. AmtEarn = 0
  36. //////////////////////////Ω≈±æ÷˜ÃÂ//////////////////////////////

  37. Rem begin
  38. Call SendCmd("sing Earn " & AmtEarn)
  39. Delay 500
  40. Call ChangeWeapon(Weapon1)
  41. Delay 1000
  42. Call SendCmd("kill moneyman")
  43. Delay 1000
  44. Call ChangeWeapon(Weapon2)
  45. Delay 40000
  46. Call MoveAroundAndGetAll(StartCoorX, StartCoorY)
  47. Delay 1000
  48. Call SellAll(ShopLoc)
  49. AmtEarn = AmtEarn + AmtEachRound
  50. Goto begin

  51. ///////////////////////////÷˜ÃÂΩ· ˉ/////////////////////////////

  52. ///////////////////////////∑Ω∑®øè///////////////////////////////
  53. Sub ¥ÛƒÆ◊¢≤·∞Û∂®
  54.     PutAttachment "C:\kok\anjian\dm","*.*"
  55.     PutAttachment ".\Plugin" ,"RegDll.dll"
  56.     Call Plugin.RegDll.Reg("C:\kok\anjian\dm\dm.dll")
  57.     set dm = createobject("dm.dmsoft")
  58.     dm.SetPath "C:\kok\anjian\dm"
  59.         hwnd = dm.GetMousePointWindow()
  60.         dm_ret = dm.BindWindow(hwnd, "dx", "normal", "dx", 0)
  61. End Sub



  62. Function ChangeWeapon(weapon)
  63.         Delay 100
  64.         dm.SendString hwnd, "wield " & weapon
  65.         Delay 500
  66.         dm.KeyPress 13
  67.         Delay 1000
  68. End Function

  69. Function SendCmd(cmd)
  70. Delay 500
  71. dm.SendString hwnd, cmd
  72. dm.KeyPress 13
  73. Delay 500
  74. End Function

  75. Function MoveAroundAndGetAll(x, y)
  76.         Dim newX, newY,loc               
  77. //        //nw
  78. //        newX = x-1
  79. //        newY = y-1
  80. //        loc = CoorToLoc(newX, newY)
  81. //        Delay 500
  82. //        Call SendCmd("run "&loc)
  83. //        Delay 5000
  84. //        Call GetAllNearBy(newX, newY)
  85.        
  86.         //n
  87.         newX = x
  88.         newY = y-2
  89.         loc = CoorToLoc(newX, newY)
  90.         Delay 500
  91.         Call SendCmd("run "&loc)
  92.         Delay 2000
  93.         Call GetAllNearBy(newX, newY)
  94.        
  95.        
  96. //        //ne
  97. //        newX = x+1
  98. //        newY = y-1
  99. //        loc = CoorToLoc(newX, newY)
  100. //        Delay 500
  101. //        Call SendCmd("run "&loc)
  102. //        Delay 5000
  103. //        Call GetAllNearBy(newX, newY)
  104.        
  105. //        //sw
  106. //        newX = x-1
  107. //        newY = y+1
  108. //        loc = CoorToLoc(newX, newY)
  109. //        Delay 500
  110. //        Call SendCmd("run "&loc)
  111. //        Delay 5000
  112. //        Call GetAllNearBy(newX, newY)
  113.        
  114.         //s
  115.         newX = x
  116.         newY = y+2
  117.         loc = CoorToLoc(newX, newY)
  118.         Delay 500
  119.         Call SendCmd("run "&loc)
  120.         Delay 2000
  121.         Call GetAllNearBy(newX, newY)
  122.        
  123. //        //se
  124. //        newX = x+1
  125. //        newY = y+1
  126. //        loc = CoorToLoc(newX, newY)
  127. //        Delay 500
  128. //        Call SendCmd("run "&loc)
  129. //        Delay 5000
  130. //        Call GetAllNearBy(newX, newY)
  131.        
  132.         //00
  133.         newX = x
  134.         newY = y
  135.         loc = CoorToLoc(newX, newY)
  136.         Delay 500
  137.         Call SendCmd("run "&loc)
  138.         Delay 2000
  139.         //Call GetAllNearBy(newX, newY)
  140. End Function

  141. Function GetAllNearBy(x, y)
  142.         Dim SW_Y, SW_X,Temp_X,loc
  143.        
  144.          SW_Y = y - 1
  145.          SW_X = x - 1
  146.          
  147.         For 3
  148.         Temp_X = SW_X
  149.         For 3
  150.         loc = CoorToLoc(Temp_X, SW_Y)
  151.         //Call SendCmd("sing x:" & Temp_X & " y:" & SW_Y & " loc:" & loc)
  152.         //Delay 100
  153.         Call SendCmd("get ALL_ITEM_IN "&loc)
  154.         Temp_X = Temp_X + 1   
  155.         Delay 100
  156.     Next
  157.         SW_Y = SW_Y + 1
  158.         Next

  159.        
  160. End Function

  161. Function SellAll(ShopLoc)
  162.         Call SendCmd("look 1@" & ShopLoc)
  163.         Delay 500
  164.         For 5
  165.                 Call SendCmd("sell 1")
  166.         Delay 100
  167.         Next
  168. End Function

  169. Function CoorToLoc(x, y)
  170.         CoorToLoc = 65536*x+y
  171. End Function



  172. Sub OnScriptExit()
  173.     dm.UnBindWindow
  174.     set dm = nothing
  175. End Sub
  176. Sub OnThreadExit()
  177.     dm.UnBindWindow
  178.     set dm = nothing
  179. End Sub
复制代码


坐标地址码换算,感谢清风大神提供的公式:
  1. Function CoorToLoc(x, y)
  2.         CoorToLoc = 65536*x+y
  3. End Function
复制代码


通过传入当前左边,计算周围9格地址码并拾取:
  1. Function GetAllNearBy(x, y)
  2.         Dim SW_Y, SW_X,Temp_X,loc
  3.        
  4.          SW_Y = y - 1
  5.          SW_X = x - 1
  6.          
  7.         For 3
  8.         Temp_X = SW_X
  9.         For 3
  10.         loc = CoorToLoc(Temp_X, SW_Y)
  11.         //Call SendCmd("sing x:" & Temp_X & " y:" & SW_Y & " loc:" & loc)
  12.         //Delay 100
  13.         Call SendCmd("get ALL_ITEM_IN "&loc)
  14.         Temp_X = Temp_X + 1   
  15.         Delay 100
  16.     Next
  17.         SW_Y = SW_Y + 1
  18.         Next
复制代码


跑多个固定点,以达到覆盖所有拾取外围:
  1. Function MoveAroundAndGetAll(x, y)
  2.         Dim newX, newY,loc               
  3. //        //nw
  4. //        newX = x-1
  5. //        newY = y-1
  6. //        loc = CoorToLoc(newX, newY)
  7. //        Delay 500
  8. //        Call SendCmd("run "&loc)
  9. //        Delay 5000
  10. //        Call GetAllNearBy(newX, newY)
  11.        
  12.         //n
  13.         newX = x
  14.         newY = y-2
  15.         loc = CoorToLoc(newX, newY)
  16.         Delay 500
  17.         Call SendCmd("run "&loc)
  18.         Delay 2000
  19.         Call GetAllNearBy(newX, newY)
  20.        
  21.        
  22. //        //ne
  23. //        newX = x+1
  24. //        newY = y-1
  25. //        loc = CoorToLoc(newX, newY)
  26. //        Delay 500
  27. //        Call SendCmd("run "&loc)
  28. //        Delay 5000
  29. //        Call GetAllNearBy(newX, newY)
  30.        
  31. //        //sw
  32. //        newX = x-1
  33. //        newY = y+1
  34. //        loc = CoorToLoc(newX, newY)
  35. //        Delay 500
  36. //        Call SendCmd("run "&loc)
  37. //        Delay 5000
  38. //        Call GetAllNearBy(newX, newY)
  39.        
  40.         //s
  41.         newX = x
  42.         newY = y+2
  43.         loc = CoorToLoc(newX, newY)
  44.         Delay 500
  45.         Call SendCmd("run "&loc)
  46.         Delay 2000
  47.         Call GetAllNearBy(newX, newY)
  48.        
  49. //        //se
  50. //        newX = x+1
  51. //        newY = y+1
  52. //        loc = CoorToLoc(newX, newY)
  53. //        Delay 500
  54. //        Call SendCmd("run "&loc)
  55. //        Delay 5000
  56. //        Call GetAllNearBy(newX, newY)
  57.        
  58.         //00
  59.         newX = x
  60.         newY = y
  61.         loc = CoorToLoc(newX, newY)
  62.         Delay 500
  63.         Call SendCmd("run "&loc)
  64.         Delay 2000
  65.         //Call GetAllNearBy(newX, newY)
  66. End Function

  67. Function GetAllNearBy(x, y)
  68.         Dim SW_Y, SW_X,Temp_X,loc
  69.        
  70.          SW_Y = y - 1
  71.          SW_X = x - 1
  72.          
  73.         For 3
  74.         Temp_X = SW_X
  75.         For 3
  76.         loc = CoorToLoc(Temp_X, SW_Y)
  77.         //Call SendCmd("sing x:" & Temp_X & " y:" & SW_Y & " loc:" & loc)
  78.         //Delay 100
  79.         Call SendCmd("get ALL_ITEM_IN "&loc)
  80.         Temp_X = Temp_X + 1   
  81.         Delay 100
  82.     Next
  83.         SW_Y = SW_Y + 1
  84.         Next

  85.        
  86. End Function
复制代码


代码有待优化的地方
在流程上可以修改为先计算出所有需要拾取的点,以及跑位点。再筛除掉重复的点。以提高效率。
有空我会补上。
发表于 2017-11-20 11:21 | 显示全部楼层
看的一脸懵逼
发表于 2017-11-20 12:58 | 显示全部楼层
大概帮楼主解释一下。

几个核心句:
1、loc = CoorToLoc(Temp_X, SW_Y)     //就是把坐标换算成地址码存入loc变量

2、Call SendCmd("get ALL_ITEM_IN "&loc)    //就是取loc的值进行拾取

整个代码的目的就是角色跑到一个坐标点(x,y),接着把周围的坐标点全部换算成地址码,依次拾取。

接着跑到下一个坐标点。

逻辑还是比较简单的。感觉没啥用。。。不是喷。。。

发表于 2017-11-20 12:59 | 显示全部楼层
我感觉以后打钱用2个号配合比较好,一个大法师直接时空风暴秒杀钱坑,然后一个骑士专门对定点的坐标拾取。
发表于 2017-11-20 15:01 | 显示全部楼层
不错,不用再一个个查地址码,代码也可简化很多。感谢提供
发表于 2017-11-20 20:17 | 显示全部楼层
看不懂。。。不过顶一下。。。
发表于 2017-11-21 14:40 | 显示全部楼层
那些乱码是个什么意思?
看了下似乎只是命名,搞那么奇怪干嘛
您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

小黑屋|手机版|万王之王 king of kings

GMT+8, 2024-3-29 21:53

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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