Guest User

Bobson script changes

a guest
Jun 19th, 2012
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.60 KB | None | 0 0
  1. #include <ImageSearch.au3>
  2. #include <File.au3>
  3. #include <Date.au3>
  4.  
  5. Global $Paused
  6. Global $ingamewait
  7. Global $wintitle="Diablo III"
  8. Global $winhandle=Wingethandle($wintitle)
  9. Global $runtimeHour, $runtimeMins, $runtimeSecs, $runtime, $sruntime
  10. Global $runtimeinit = TimerInit()
  11. Global $CellerRunTime = TimerInit()
  12. Global $debug_log = True ; Set to True to turn on debug logging
  13.  
  14. Opt('MouseCoordMode', 2)
  15. Opt('PixelCoordMode', 2)
  16.  
  17. HotKeySet("=","Leave") ;script started by pressing =
  18. HotKeySet("-","Pause") ;script paused by pressing -
  19. HotKeySet("x","Stop") ;script stopped by pressing x
  20.  
  21. $go = True
  22. $default_resolutionX = 1920
  23. $default_resolutionY = 1080
  24. $x_ratio = @Desktopwidth / $default_resolutionX
  25. $y_ratio = @Desktopheight / $default_resolutionY
  26.  
  27. Call("debugLog","Default X resolution: " & $default_resolutionX)
  28. Call("debugLog","Default Y resolution: " & $default_resolutionY)
  29. Call("debugLog","X Ratio: " & $x_ratio)
  30. Call("debugLog","Y Ratio: " & $y_ratio)
  31.  
  32. ;ImageSearch Looting Variables
  33. $ImgLoot = False ; set this to true if you want to use ImageSearch looting system.
  34. $OldLoot = True ; set this to true if you want to use PixelSearch looting system.
  35. $directory = "C:\pics\" ; CHANGE THIS! Point it to the directory with the imagesearch pngs
  36. $totalItems = 17 ; This needs to match the number of pngs you are loading
  37. Global $pick[$totalItems]
  38. $currentArrayItem = 0
  39. $gX = 0
  40. $gY = 0
  41. $gX0 = 0
  42. $gY0 = 0
  43.  
  44. $pick[0] = "uare.png|40"
  45. $pick[1] = "tome.png|40"
  46. $pick[2] = "legendaryA.png|20"
  47. $pick[3] = "legendaryE.png|20"
  48. $pick[4] = "legendaryI.png|10"
  49. $pick[5] = "legendaryO.png|20"
  50. $pick[6] = "legendaryU.png|20"
  51. $pick[7] = "setA.png|30"
  52. $pick[8] = "setE.png|30"
  53. $pick[9] = "setU.png|30"
  54. $pick[10] = "setO.png|30"
  55. $pick[11] = "setI.png|30"
  56. $pick[12] = "rareA.png|20" ; comment/delete these and adjust $totalItems to disable rare looting
  57. $pick[13] = "rareE.png|20"
  58. $pick[14] = "rareI.png|20"
  59. $pick[15] = "rareO.png|20"
  60. $pick[16] = "rareU.png|20" ; end comment
  61.  
  62. $LootGems = False ; Old Methods set to true if you don't want to use imagesearch - This is shit and shouldn't be used.
  63. $LootRares = True ; Old Methods set to true if you don't want to use imagesearch
  64.  
  65.  
  66. $Amethyst = 0xAC7FFF
  67. $Ruby = 0xB01D2D
  68. $Emerald = 0x58EE33
  69. $Topaz = 0xFFFF59
  70. $SetLoot = 0x02CE01
  71. $RareLoot = 0xBBBB00
  72. $yellow = 0xFFF000 ; yellow color code (repair icon)
  73. $red = 0xD90000 ; red color code (repair icon)
  74.  
  75.  
  76. $Timer = false ; set this to true and the bot will randomly wait (5% chance) in town for 30-60 seconds before starting over
  77. $walktime = 3600 ; time in ms the script waits for you to enter and load the cellar. Slow this down for slower move speeds and loading times
  78. $loadtime = 4500 ; time in ms the script waits for the game to load before it starts pathfinding. Slow this down for slower hard drives
  79. $tptime = 7000 ; time in ms the script waits for teleport before exiting the game
  80.  
  81. $Leave = False
  82. $Dead = False
  83. $Window = False
  84. $Logout = False
  85. $i = 0
  86.  
  87. ;Logging Var
  88. $Deaths=0
  89. $Repairs=0
  90. $Found=0
  91. $NotFound=0
  92. $RunNum=0
  93.  
  94. $Firstrun=True
  95. $movewait=2000
  96. $gunfire=5500
  97. $leftfire=600
  98. $rightfire=600
  99.  
  100. Call("RestartRun")
  101.  
  102. Func RestartRun()
  103. Call("debugLog","Enter RestartRun() winhandle: " & $winhandle)
  104. Call("debugLog","Active window title: " & WinGetTitle ($winhandle))
  105. While $go
  106. if($Leave) Then
  107. $CellerRunTime = TimerInit()
  108. $RunNum = $Found + $NotFound
  109. $Repairp = $Repairs / $RunNum
  110. $DeathsP = $Deaths / $RunNum
  111. $FoundP = $Found / $RunNum
  112. $NotfoundP = $NotFound / $RunNum
  113. $i = 0
  114.  
  115. Call("debugLog","Main script loop start")
  116.  
  117. ToolTip("Cellars Found: " & $Found & " (" & Round($FoundP * 100,.00) & "%" & ")" & @CRLF & "Cellars Not Found: " & $NotFound & " (" & Round($NotFoundP * 100,.00) & "%" & ")"& _
  118. @CRLF & "Deaths: " & $Deaths & " (" & Round($DeathsP * 100,.00) & "%" & ")"& @CRLF & "Repairs: " & $Repairs & " (" & Round($RepairP * 100,.00) & "%" & ")", 20, 20, "Run Time: " & Call("Update_Time",$runtimeinit), 1)
  119.  
  120.  
  121. If($Firstrun=True) Then
  122. $Firstrun=False
  123. Call("debugLog","FirstRun")
  124. Call("InputReqScrn")
  125. EndIf
  126.  
  127. Call("CheckExit")
  128.  
  129. Sleep(950) ;had to add this since the icon doesn't show up RIGHT away in game
  130.  
  131. Call("CheckDead")
  132.  
  133. If $Dead Then
  134. Call("debugLog","Exiting loop, dead 1")
  135. ContinueLoop
  136. EndIf
  137.  
  138. Call("CheckRepair")
  139.  
  140. If $Window Then
  141. Call("debugLog","First Window InputReqScrn")
  142. Call("InputReqScrn")
  143. $Window = False
  144. ContinueLoop
  145. ElseIf $Dead or $Logout Then
  146. $Dead=False
  147. Call("debugLog","Exiting loop, dead 1")
  148. ContinueLoop
  149. EndIf
  150.  
  151. Call("debugLog","jumping to cellar")
  152.  
  153. MouseMove(Round(0 * $x_ratio),Round(250 * $y_ratio), 1) ;starts the main run
  154. Send("{3 down}")
  155. Sleep(1600)
  156. Send("{3 up}")
  157. Send("1")
  158. ;Send("2")
  159. ;Sleep(500)
  160.  
  161. $celrwait=0
  162. Do
  163. sleep(20)
  164. $celrwait=$celrwait+1
  165. $Pixel28 = PixelSearch(Round(500*$x_ratio),Round(500*$y_ratio), Round(100*$x_ratio), Round(100*$y_ratio),0x668CE7, 35) ; Save time if cellar isn't there
  166. Until (Not @Error OR $celrwait=10)
  167.  
  168. if Not @error Then
  169. ;MouseMove(Round(100*$x_ratio),Round(650*$y_ratio))
  170. ;Send("4")
  171. ;Sleep(250)
  172. Send("2")
  173. Sleep(250)
  174. MouseClick("middle",Round(0*$x_ratio),Round(700*$y_ratio)) ;get a better view of the cellar for better identification - reduces miss clicks
  175.  
  176. ;MouseMove(Round(255*$x_ratio),Round(290*$y_ratio),1) ;moves cursor over to the cellar so the proper blue pixel becomes highlighted
  177.  
  178. Sleep($movewait)
  179. EndIf
  180.  
  181.  
  182. Call("CheckDead")
  183.  
  184. If $Dead Then
  185. Call("debugLog","Exiting loop, dead 2")
  186. ContinueLoop
  187. EndIf
  188.  
  189. If $Window Then
  190. Call("InputReqScrn")
  191. ;~ $Window = False
  192. ContinueLoop
  193. ElseIf $Logout Then
  194. Call("debugLog","Exiting loop, dead 2")
  195. ContinueLoop
  196. EndIf
  197.  
  198. Call("debugLog","cellar check")
  199.  
  200. ;Sleep(250)
  201.  
  202.  
  203. $celrwait=0
  204. Do
  205. sleep(20)
  206. $celrwait=$celrwait+1
  207. ;$Pixel2 = PixelSearch(0,0, Round(600*$x_ratio), Round(400*$y_ratio),0x334FB7,3) ;checks for open cellar (in a 600x400 box from the top left - where it should always be)
  208. ;$Pixel2 = PixelSearch(Round(400*$x_ratio),Round(400*$y_ratio), Round(150*$x_ratio), Round(250*$y_ratio),0x668CE7, 20)
  209. $Pixel2 = PixelSearch(Round(1269*$x_ratio),Round(337*$y_ratio), Round(797*$x_ratio), Round(0*$y_ratio),0x668CE7, 10)
  210. Until (Not @Error OR $celrwait=3)
  211.  
  212. If Not @error Then
  213. ;Call("debugLog","cellar check successful")
  214. ;Send("2")
  215. ;Sleep(80)
  216. ;Send("1")
  217. ;Sleep(120)
  218. ;MouseClick("left",Round(255*$x_ratio),Round(290*$y_ratio)) ;Entrance to cellar
  219. MouseClick("left",$Pixel2[0],$Pixel2[1]) ;Entrance to cellar
  220. Call("Cellarwait")
  221.  
  222. Call("CheckDead")
  223.  
  224. If $Dead Then
  225. Call("debugLog","Exiting loop, dead 3")
  226. ContinueLoop
  227. EndIf
  228.  
  229. MouseClick("middle",Round(40*$x_ratio),Round(797*$y_ratio)) ;moves to doorway leading to rare inside cellar
  230. Sleep(3100)
  231. MouseMove(Round(440*$x_ratio),Round(80*$y_ratio),1) ;hovers over the rare Sarkoth
  232. Send(4)
  233. Sleep(700)
  234. Send("{SHIFTDOWN}")
  235. MouseDown("right") ;attack middle
  236. Sleep($gunfire)
  237. MouseMove(Round(521 * $x_ratio),Round(260 * $y_ratio),1) ;attack left, add more sleep time if you can't kill minion on left
  238. Sleep($leftfire)
  239. MouseMove(Round(620 * $x_ratio),Round(20 * $y_ratio),1) ;break the table & chair
  240. Sleep($rightfire)
  241. MouseUP("right")
  242. ;MouseClick("right",Round(620*$x_ratio),Round(20*$y_ratio),2)
  243. Sleep(10)
  244. Send("{SHIFTUP}")
  245. Sleep(400)
  246. MouseClick("middle",Round(564*$x_ratio),Round(222*$y_ratio)) ;location of sarkoth after death
  247. Sleep(2100)
  248. ;MouseClick("middle",Round(650*$x_ratio),Round(523*$y_ratio)) ;move to left top corner for gold
  249. ;Sleep(1100)
  250. ;MouseClick("middle",Round(1320*$x_ratio),Round(315*$y_ratio)) ;move to right top corner for gold
  251. ;Sleep(1100)
  252. ;MouseClick("middle",Round(880*$x_ratio),Round(748*$y_ratio)) ;move to middle before looting
  253.  
  254. If ($OldLoot) Then
  255. Call("CheckLoot", $SetLoot)
  256. Call("CheckLoot", $RareLoot)
  257. EndIf
  258.  
  259. If ($ImgLoot) Then
  260. Call("pickItems")
  261. EndIf
  262.  
  263. Call("debugLog","teleport back to city")
  264. MouseClick("right",Round(688*$x_ratio),Round(931*$y_ratio)) ; turn off Archon for teleport
  265. Send("t")
  266. Sleep($tptime)
  267.  
  268. Call("RandomSleep")
  269. Call("CheckDead")
  270. If $Dead Then
  271. Call("debugLog","Exiting loop, dead 4")
  272. ContinueLoop
  273. EndIf
  274.  
  275. If Not $Logout And Not $Dead And Not $Window Then
  276. Call("debugLog","You died")
  277. Sleep(300)
  278. Send("{ESCAPE}") ;menu
  279. Sleep(200)
  280. Call("Logs","killed")
  281. MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  282. Sleep($loadtime)
  283. Call("CheckDead")
  284. If $Dead Then
  285. Call("debugLog","Exiting loop, dead 5")
  286. ContinueLoop
  287. EndIf
  288. If Not $Logout Then
  289. Call("InputReqScrn")
  290. EndIf
  291. Else
  292. Call("InputReqScrn")
  293. $Window = False ; reset the flag so it doesn't think a window is always up
  294. EndIf
  295. Else
  296. mousemove(962,518,1)
  297. ;Send("1")
  298. ;Sleep(200)
  299. Send("4")
  300. Sleep(620)
  301. send("2")
  302. Sleep(600)
  303. send("{SHIFTDOWN}")
  304. sleep(200)
  305. Mouseclick("left")
  306. sleep(300)
  307. send("{SHIFTUP}")
  308. sleep(600)
  309. Send("t")
  310. Sleep($tptime)
  311. Call("CheckDead")
  312. If $Dead Then
  313. Call("debugLog","Exiting loop, dead 6")
  314. ContinueLoop
  315. EndIf
  316. Call("RandomSleep")
  317. Call("Logs","notpresent")
  318. If Not $Logout And Not $Dead And Not $Window Then
  319. Sleep(300)
  320. Send("{ESCAPE}") ;menu
  321. Sleep(200)
  322. Call("CheckDead")
  323. If $Dead Then
  324. Call("debugLog","Exiting loop, dead 7")
  325. ContinueLoop
  326. EndIf
  327. MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  328. Sleep($loadtime)
  329. If Not $Logout Then
  330. Call("InputReqScrn")
  331. EndIf
  332. Else
  333. Call("InputReqScrn")
  334. $Window = False ; reset the flag so it doesn't think a window is always up
  335. EndIf
  336. EndIf
  337. EndIf
  338. WEnd
  339. ;Call("InputReqScrn")
  340. EndFunc
  341.  
  342. Func CheckDead()
  343.  
  344. Call("debugLog","Enter CheckDead()")
  345.  
  346. Call("CheckWindow")
  347.  
  348. $YouHaveDied = PixelSearch(Round(620*$x_ratio), Round(325*$y_ratio), Round(625*$x_ratio), Round(330*$y_ratio), 0xFFFFFF) ; checks for white text "YOU HAVE DIED"
  349. If Not @error Then
  350. If Not $Window Then
  351. Call("debugLog","You have been found to be dead")
  352. $Dead = True
  353. Call("Logs","dead")
  354. Sleep(100)
  355. Send("{Escape}")
  356. Sleep(10)
  357. MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  358. ;Sleep(11000)
  359. ;Call("InputReqScrn")
  360. $Firstrun=True
  361. Else
  362. Call("debugLog","You have been found to be alive1")
  363. Call("InputReqScrn")
  364. $Dead = False
  365. EndIf
  366. Else
  367. Call("debugLog","You have been found to be alive2")
  368. $Dead = False
  369. EndIf
  370.  
  371. $LogoutTimerCancel = PixelSearch(Round(900*$x_ratio), Round(240*$y_ratio), Round(1010*$x_ratio), Round(290*$y_ratio), 0x993827) ; checks for cancel button on logout timer
  372. If Not @error Then
  373. Call("debugLog","Found logout timer cancel button")
  374. Sleep(11000)
  375. Sleep($loadtime)
  376. If Not $Window Then
  377. Call("debugLog","You are dead and logging out")
  378. $Dead = True
  379. $Logout = True
  380. Sleep($loadtime)
  381. Call("InputReqScrn")
  382. Else
  383. Call("InputReqScrn")
  384. $Logout = False
  385. EndIf
  386. Else
  387. $Logout = False
  388. EndIf
  389. EndFunc
  390.  
  391. Func CheckWindow()
  392.  
  393. Call("debugLog","Enter CheckWindow()")
  394.  
  395. $CloseButton = PixelSearch(Round(1570*$x_ratio), Round(110*$y_ratio), Round(1590*$x_ratio), Round(120*$y_ratio), 0x8C2300) ; checks for the red color of the "X" on an open window
  396. If Not @error Then
  397. Call("debugLog","Open window found, closing windows")
  398. Sleep(200)
  399. Send("{SPACE}") ;close any open windows
  400. $Window = True
  401. Else
  402. $Window = False
  403. EndIf
  404. EndFunc
  405.  
  406. Func CheckExit()
  407.  
  408. Call("debugLog","Enter CheckExit()")
  409.  
  410. $ExitButton = PixelSearch(Round(1190*$x_ratio), Round(400*$y_ratio), Round(1200*$x_ratio), Round(440*$y_ratio), 0x14100E) ; checks for the grey border of the exit prompt
  411. If Not @error Then
  412. Call("debugLog","Found exit prompt")
  413. Send("{ESCAPE}")
  414. Sleep(100)
  415. Send("{SPACE}") ;close any open windows
  416. Sleep(200)
  417. MouseMove(1,1) ; reset cursor position before checking for button
  418. $Resume = Hex(PixelGetColor(Round(140*$x_ratio), Round(420*$y_ratio)), 6) ; checks if resume button can be pressed
  419. If $Resume == "400900" Or $Resume == "380900" Then
  420. Call("debugLog","Resume button color 400900 or 380900 - fail?")
  421. Sleep(200)
  422. Call("InputReqScrn")
  423. EndIf
  424. EndIf
  425. EndFunc
  426.  
  427. Func CheckRepair()
  428.  
  429. Call("debugLog","Enter DoCheckRepair()")
  430.  
  431. $RepairArea = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $yellow)
  432. If Not @error Then
  433. Call("debugLog","Yellow repair needed")
  434. Call("DoRepair")
  435. EndIf
  436.  
  437. $RepairAreaRed = PixelSearch(Round(1480*$x_ratio), 0, Round(1570*$x_ratio), Round(100*$y_ratio), $red)
  438. If Not @error Then
  439. Call("debugLog","Red repair needed")
  440. Call("DoRepair")
  441. EndIf
  442.  
  443. EndFunc
  444.  
  445. Func DoRepair()
  446.  
  447. Call("debugLog","Enter DoRepair()")
  448.  
  449. ;$Repairs=$Repairs+1
  450. Sleep(100)
  451. Send("t")
  452. Sleep($tptime)
  453. Call("debugLog","begin movement towards merchant")
  454. MouseClick("left", Round(1480*$x_ratio),Round(281*$y_ratio)) ;begin movement towards merchant
  455. Sleep(1900)
  456. MouseClick("left", Round(1316*$x_ratio),Round(206*$y_ratio)) ;moves to get merchant in screen
  457. Sleep(1900)
  458. MouseClick("left", Round(845*$x_ratio),Round(225*$y_ratio)) ;NPC Merchant to the right of cain's home
  459. Sleep(1200)
  460. MouseClick("left", Round(521*$x_ratio),Round(506*$y_ratio)) ;button to open up repair menu
  461. Sleep(400)
  462. Call("debugLog","Clicking button to pay for repairs")
  463. MouseClick("left", Round(260*$x_ratio),Round(595*$y_ratio)) ;button to pay for repairs
  464. Sleep(200)
  465. Call("CheckDead")
  466. If Not $Dead and Not $Logout Then
  467. Send("{ESCAPE}") ;closes repair tab
  468. Sleep(100)
  469. Send("{ESCAPE}") ;menu
  470. Sleep(10)
  471. MouseClick("left", Round(960*$x_ratio),Round(580*$y_ratio)) ;button to leave game
  472. Call("Logs","repair")
  473. Sleep($loadtime)
  474. Call("InputReqScrn")
  475. EndIf
  476. EndFunc
  477.  
  478. Func CheckLoot($lootColor)
  479.  
  480. Call("debugLog","Enter CheckLoot()")
  481.  
  482. ;Sleep(Random(500,2000))
  483.  
  484. ;$SetLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), 0x02CE01, 2) ; set loot
  485. $Loot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $lootColor, 2) ; Look for loot based on $lootColor
  486. If Not @error Then
  487. Call("debugLog","Picking up loot")
  488. MouseClick ('left', $Loot[0], $Loot[1])
  489. Sleep(Random(700,900))
  490. $i+= 1
  491. If $i <= 6 Then
  492. Call("CheckLoot", $lootColor)
  493. EndIf
  494. EndIf
  495.  
  496. ;If $LootRares Then
  497. ; $RareLoot = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), 0xBBBB00, 2) ; rare loot (darker for compatibility);
  498. ;If Not @error Then
  499. ; Call("debugLog","Picking up rare")
  500. ;MouseClick ('left', $RareLoot[0], $RareLoot[1])
  501. ;Sleep(Random(700,900))
  502. ;$i+= 1
  503. ;If $i <= 6 Then
  504. ; Call("CheckLoot")
  505. ; EndIf
  506. ;EndIf
  507. ;Else
  508. ;Call("pickItems")
  509. ;EndIf
  510.  
  511. #cs
  512. If $LootGems Then
  513. ;$AmethystDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Amethyst,8)
  514. ;If Not @error Then
  515. ; Call("debugLog","Picking up Amethyst")
  516. ;MouseClick("left", $AmethystDrop[0], $AmethystDrop[1])
  517. ;Sleep(Random(900,1400))
  518. ;$i+= 1
  519. ;If $i <= 10 Then
  520. ; Call("CheckLoot")
  521. ; EndIf
  522. ;EndIf
  523.  
  524. $RubyDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Ruby,6)
  525. If Not @error Then
  526. Call("debugLog","Picking up Ruby")
  527. MouseClick("left", $RubyDrop[0], $RubyDrop[1])
  528. Sleep(Random(900,1400))
  529. $i+= 1
  530. If $i <= 10 Then
  531. Call("CheckLoot")
  532. EndIf
  533. EndIf
  534.  
  535. $EmeraldDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Emerald,11)
  536. If Not @error Then
  537. Call("debugLog","Picking up Emerald")
  538. MouseClick("left", $EmeraldDrop[0], $EmeraldDrop[1])
  539. Sleep(Random(900,1400))
  540. $i+= 1
  541. If $i <= 10 Then
  542. Call("CheckLoot")
  543. EndIf
  544. EndIf
  545.  
  546. $TopazDrop = PixelSearch(Round(400*$x_ratio), 0, Round(1690*$x_ratio), Round(900*$y_ratio), $Topaz,2)
  547. If Not @error Then ; change to 'If Not @error Then' if you want to search for topazes
  548. Call("debugLog","Picking up Topaz")
  549. MouseClick("left", $TopazDrop[0], $TopazDrop[1])
  550. Sleep(Random(900,1400))
  551. $i+= 1
  552. If $i <= 10 Then
  553. Call("CheckLoot")
  554. EndIf
  555. EndIf
  556. EndIf
  557. #ce
  558. EndFunc
  559.  
  560.  
  561.  
  562. Func pickItems()
  563. Call("debugLog","Enter pickItems()")
  564. $currentArrayItem = 0
  565. For $gI = 0 to ($totalItems - 1)
  566. $array = StringSplit($pick[$gI],"|")
  567. $file = $array[1]
  568. $accuracy = $array[2]
  569. $urlString = $directory & $file
  570. Call("debugLog", "Checking for " & $urlString)
  571. $Target = _ImageSearchArea($urlString,1,0,0,Round(1920*$x_ratio),Round(1080*$y_ratio),$gX,$gY,$accuracy)
  572. While $i <= 12 ; max: 13 gems and pieces of gear to loot
  573. If Not $Target = 1 Then
  574. If ($gX > 0) Then
  575. Call("debugLog", "Found " & $urlString & " at location: " & $gX & "," & $gY)
  576. MouseClick("left", $gX, $gY, 1, 0)
  577. Sleep(Random(700, 900))
  578. MouseMove(14,14,0) ;Reset cursor position, it doesn't need to hover
  579. Sleep(5)
  580. EndIf
  581. $Target = _ImageSearchArea($urlString,1,0,0,Round(1920*$x_ratio),Round(1080*$y_ratio),$gX,$gY,$accuracy)
  582. $i+= 1
  583. Else
  584. ExitLoop
  585. EndIf
  586. WEnd
  587. Next
  588. EndFunc
  589.  
  590.  
  591. Func InputReqScrn()
  592.  
  593. Call("debugLog","Enter InputReqScrn")
  594.  
  595. Menuwait()
  596.  
  597. Call("debugLog","Clicking resume game button")
  598. MouseClick("left", Round(198*$x_ratio),Round(417*$y_ratio)) ;button to resume game from main menu
  599.  
  600. Ingamewait()
  601.  
  602. ;Call("debugLog","Check for input required screen")
  603. ;$Target = _ImageSearchArea($directory & "InputReq.png",1,0,0,@DesktopHeight,@DesktopWidth,$gX0,$gY0,0)
  604. ;If $Target And ($gX > 15) And ($gY > 15) Then
  605. ; Call("debugLog","Input required screen found")
  606. ; sleep(1500)
  607.  
  608. ; MouseClick("Left",959,632)
  609. ; Sleep(Random(1500000,300000))
  610.  
  611. ; Call("debugLog","Clicking resume game button")
  612. ; MouseClick("left", Round(198*$x_ratio),Round(417*$y_ratio)) ;button to resume game from main menu
  613.  
  614. ; $gX0 = 0
  615. ; $gY0 = 0
  616.  
  617. ; Ingamewait()
  618.  
  619. ;EndIf
  620. EndFunc
  621.  
  622. Func Menuwait()
  623. Call("debugLog","Enter Menuwait()")
  624.  
  625. $menuwait=0
  626. Do
  627. sleep(100)
  628. $menuwait=$menuwait+1
  629. PixelSearch(1630*$x_ratio ,990*$y_ratio, 1660*$x_ratio ,1030*$y_ratio, 0xF5D068, 20, 1, $winhandle) ; this function waits for that helmet button to appear on the lower right of the main menu
  630. Until (Not @Error OR $menuwait=100)
  631.  
  632. If $menuwait=100 Then
  633. Call("debugLog","Menuwait check fail, could not find helmet button")
  634. send("{ESC}")
  635. sleep(2000)
  636. send("{ESC}")
  637. $menuwait=0
  638. Else
  639. Call("debugLog","Menuwait check success, found helmet button")
  640. EndIf
  641.  
  642. $menuwait=0
  643. sleep(100)
  644.  
  645. EndFunc
  646.  
  647. Func Ingamewait()
  648.  
  649. Call("debugLog","Enter Ingamewait()")
  650.  
  651. Do
  652. sleep(100)
  653. $ingamewait=$ingamewait+1
  654. PixelSearch(1100*$x_ratio ,1000*$y_ratio,1140*$x_ratio ,1060*$y_ratio, 0x426AFA, 20, 1, $winhandle) ; this function waits until the blue townportal button appears to recognize that we are ingame
  655. Until (Not @Error OR $ingamewait=100)
  656.  
  657. If Not @Error Then
  658. Call("debugLog","Ingamewait check success, found town portal button")
  659. Else
  660. Call("debugLog","Ingamewait check failed check, time out, did not find town portal button")
  661. EndIf
  662. $ingamewait=0
  663. sleep(200)
  664. EndFunc
  665.  
  666.  
  667.  
  668. Func Cellarwait()
  669. Call("debugLog","Enter Cellarwait()")
  670. $menuwait=0
  671.  
  672. Do
  673. sleep(100)
  674. $menuwait=$menuwait+1
  675. PixelSearch(811*$x_ratio ,222*$y_ratio, 900*$x_ratio ,320*$y_ratio, 0xFDFD34, 40, 1, $winhandle) ; This function waits until the light of the lamp next to the entrance appears
  676. Until (Not @Error OR $menuwait=100)
  677.  
  678. If Not @Error Then
  679. Call("debugLog","Ingamewait check success, found the lamp")
  680. Else
  681. Call("debugLog","Ingamewait check failed check, time out, did not find the lamp")
  682. EndIf
  683.  
  684. $menuwait=0
  685. EndFunc
  686.  
  687.  
  688. Func RandomSleep()
  689. if ($timer) then
  690. Sleep(Random(2000,240000))
  691. EndIf
  692. EndFunc
  693.  
  694. Func Logs($LogStats)
  695. $Sarkothkill=Iniread("Sarkoth.ini","Misc","Sarkothkill",0)
  696. $Sarkothnotfound=Iniread("Sarkoth.ini","Misc","Sarkothnotfound",0)
  697. $Died=Iniread("Sarkoth.ini","Misc","Died",0)
  698. $Repair=Iniread("Sarkoth.ini","Misc","Repair",0)
  699. $RunNum = $Found + $NotFound
  700. $Repairp = $Repairs / $RunNum
  701. $DeathsP = $Deaths / $RunNum
  702. $FoundP = $Found / $RunNum
  703. $NotfoundP = $NotFound / $RunNum
  704.  
  705. If $LogStats = "repair" Then
  706. _FileWriteLog("Botlog_test.txt", "Repaired Items, it took " & Call("Update_Time",$CellerRunTime))
  707. $Repairs=$Repairs+1
  708. $Repair=$Repair+1
  709. ;$NotFound=$NotFound+1
  710. $Sarkothnotfound=$Sarkothnotfound+1
  711. $RunNum = $Found + $NotFound
  712. $Repairp = $Repairs / $RunNum
  713. $DeathsP = $Deaths / $RunNum
  714. $FoundP = $Found / $RunNum
  715. $NotfoundP = $NotFound / $RunNum
  716. IniWrite("Sarkoth.ini","Misc","Died",$Repair)
  717. IniWrite("Sarkoth.ini","Misc","Sarkothnotfound",$Sarkothnotfound)
  718. ToolTip("Cellars Found: " & $Found & " (" & Round($FoundP * 100,.00) & "%" & ")" & @CRLF & "Cellars Not Found: " & $NotFound & " (" & Round($NotFoundP * 100,.00) & "%" & ")"& _
  719. @CRLF & "Deaths: " & $Deaths & " (" & Round($DeathsP * 100,.00) & "%" & ")"& @CRLF & "Repairs: " & $Repairs & " (" & Round($RepairP * 100,.00) & "%" & ")", 20, 20, "Run Time: " & Call("Update_Time",$runtimeinit), 1)
  720. ElseIf $LogStats = "dead" then
  721. _FileWriteLog("Botlog_test.txt", "Oh my you have died, it took " & Call("Update_Time",$CellerRunTime))
  722. $Died=$Died+1
  723. $Sarkothnotfound=$Sarkothnotfound+1
  724. $Deaths=$Deaths+1
  725. $NotFound=$NotFound+1
  726. $RunNum = $Found + $NotFound
  727. $Repairp = $Repairs / $RunNum
  728. $DeathsP = $Deaths / $RunNum
  729. $FoundP = $Found / $RunNum
  730. $NotfoundP = $NotFound / $RunNum
  731. IniWrite("Sarkoth.ini","Misc","Died",$Died)
  732. IniWrite("Sarkoth.ini","Misc","Sarkothnotfound",$Sarkothnotfound)
  733. ToolTip("Cellars Found: " & $Found & " (" & Round($FoundP * 100,.00) & "%" & ")" & @CRLF & "Cellars Not Found: " & $NotFound & " (" & Round($NotFoundP * 100,.00) & "%" & ")"& _
  734. @CRLF & "Deaths: " & $Deaths & " (" & Round($DeathsP * 100,.00) & "%" & ")"& @CRLF & "Repairs: " & $Repairs & " (" & Round($RepairP * 100,.00) & "%" & ")", 20, 20, "Run Time: " & Call("Update_Time",$runtimeinit), 1)
  735. ElseIf $LogStats = "killed" then
  736. _FileWriteLog("Botlog_test.txt", "Sarkoth down, it took " & Call("Update_Time",$CellerRunTime))
  737. $Sarkothkill=$Sarkothkill+1
  738. $Found=$Found+1
  739. $RunNum = $Found + $NotFound
  740. $Repairp = $Repairs / $RunNum
  741. $DeathsP = $Deaths / $RunNum
  742. $FoundP = $Found / $RunNum
  743. $NotfoundP = $NotFound / $RunNum
  744. IniWrite("Sarkoth.ini","Misc","Sarkothkill",$Sarkothkill)
  745. ToolTip("Cellars Found: " & $Found & " (" & Round($FoundP * 100,.00) & "%" & ")" & @CRLF & "Cellars Not Found: " & $NotFound & " (" & Round($NotFoundP * 100,.00) & "%" & ")"& _
  746. @CRLF & "Deaths: " & $Deaths & " (" & Round($DeathsP * 100,.00) & "%" & ")"& @CRLF & "Repairs: " & $Repairs & " (" & Round($RepairP * 100,.00) & "%" & ")", 20, 20, "Run Time: " & Call("Update_Time",$runtimeinit), 1)
  747. ElseIf $LogStats = "notpresent" then
  748. _FileWriteLog("Botlog_test.txt", "Cellar Not Found, it took " & Call("Update_Time",$CellerRunTime))
  749. $Sarkothnotfound=$Sarkothnotfound+1
  750. $Notfound=$NotFound+1
  751. $RunNum = $Found + $NotFound
  752. $Repairp = $Repairs / $RunNum
  753. $DeathsP = $Deaths / $RunNum
  754. $FoundP = $Found / $RunNum
  755. $NotfoundP = $NotFound / $RunNum
  756. IniWrite("Sarkoth.ini","Misc","Sarkothnotfound",$Sarkothnotfound)
  757. ToolTip("Cellars Found: " & $Found & " (" & Round($FoundP * 100,.00) & "%" & ")" & @CRLF & "Cellars Not Found: " & $NotFound & " (" & Round($NotFoundP * 100,.00) & "%" & ")"& _
  758. @CRLF & "Deaths: " & $Deaths & " (" & Round($DeathsP * 100,.00) & "%" & ")"& @CRLF & "Repairs: " & $Repairs & " (" & Round($RepairP * 100,.00) & "%" & ")", 20, 20, "Run Time: " & Call("Update_Time",$runtimeinit), 1)
  759. ElseIf $LogStats = "stoped" Then
  760. _FileWriteLog("Botlog_test.txt", @CRLF & "************************************************" & @CRLF & _
  761. "Chancity's Dank Celler" & @CRLF & "Run has completed in: " & Call("Update_Time",$runtimeinit) & @CRLF & _
  762. "Total Cellars Found: " & $Found & " (" & Round($FoundP * 100,.00) & "%" & ")" & @CRLF & "Total Cellars Not Found: " & $NotFound & " (" & Round($NotFoundP * 100,.00) & "%" & ")" & @CRLF & "Totals Deaths: " & $Deaths & " (" & Round($DeathsP * 100,.00) & "%" & ")" & @CRLF & _
  763. "Total Repairs: " & $Repairs & " (" & Round($RepairP * 100,.00) & "%" & ")" & @CRLF & "************************************************")
  764. EndIf
  765. EndFunc
  766.  
  767. Func debugLog($LogStats)
  768. if($debug_log) Then
  769. _FileWriteLog("Botlog_debug.txt", $LogStats)
  770. EndIf
  771. EndFunc
  772.  
  773. Func Update_Time($time)
  774. _TicksToTime(Int(TimerDiff($time)), $runtimeHour, $runtimeMins, $runtimeSecs)
  775. $runtime = StringFormat("%02i:%02i:%02i", $runtimeHour, $runtimeMins, $runtimeSecs)
  776. Return $runtime
  777. EndFunc ;==>Update_Time
  778.  
  779. Func Pause()
  780. $Leave = False
  781. EndFunc
  782.  
  783. Func Stop() ;to allow the script to stop
  784. Call("Logs","stoped")
  785. Exit
  786. EndFunc
  787.  
  788. Func Leave()
  789. $Leave = True
  790. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment