Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
803
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.49 KB | None | 0 0
  1. ; -----------------------------------------------------------------------------------------
  2. ; Clicker Heroes Sw1ft Bot
  3. ; by Sw1ftb
  4.  
  5. ; Script home @ http://redd.it/3a3bmy
  6.  
  7. ;
  8. -- Complete file list -------------------------------------------------------------------
  9.  
  10. ; ch_bot_lib.ahk https://gist.github.com/swiftb/940bd6da6ad2bc9199b0#file-ch_bot_lib-ahk
  11. ; ch_sw1ft_bot.ahk https://gist.github.com/swiftb/940bd6da6ad2bc9199b0#file-ch_sw1ft_bot-ahk
  12. ; monster_clicker.ahk https://gist.github.com/swiftb/940bd6da6ad2bc9199b0#file-monster_clicker-ahk
  13.  
  14. ; New in v2.2 is the option to do all configuration in a separate settings file!
  15. ; Example @ http://pastebin.com/7haemd0h
  16.  
  17. ;
  18. -- Quick start guide --------------------------------------------------------------------
  19.  
  20. ; 1. Install the latest version of AutoHotkey from http://ahkscript.org/
  21. ; 2. Follow the instructions in the Mandatory Configuration section.
  22.  
  23. ; Problems/questions? Read the FAQ @ http://pastebin.com/awy9p847
  24.  
  25. ;
  26. -- Hotkeys ------------------------------------------------------------------------------
  27.  
  28. ;
  29. -- Configuration
  30. ; Alt+F5 to reload the script (needed after configuration changes and a client window resize)
  31. ; Alt+MiddleMouseButton to show the current cursor position
  32.  
  33. ;
  34. -- Quick tests (run these first)
  35. ; Ctrl+Alt+F1 should scroll down to the bottom
  36. ; Ctrl+Alt+F2 should switch to the relics tab and then back
  37.  
  38. ;
  39. -- Speed run loop function tests
  40. ; Alt+F1 to test the getClickable() function
  41. ; Alt+F2 to test the initRun() function
  42. ; Alt+F3 to test the speedRun() function
  43. ; Alt+F4 to test the ascend() function
  44.  
  45. ;
  46. -- Main bot functions
  47. ; Ctrl+F1 to loop speed runs
  48. ; Ctrl+F2 to start a deep run (requires a running monster_clicker.ahk)
  49.  
  50. ; Pause to pause/unpause the script
  51. ; Alt+Pause to abort active speed/deep runs and an initiated auto ascension
  52.  
  53. ;
  54. -- Re-gilding
  55. ; Ctrl+F6 to set previous ranger as re-gild target
  56. ; Ctrl+F7 to set next ranger as re-gild target
  57. ; Ctrl+F8 to move reGildCount gilds to the target ranger (will pause the monster clicker if running)
  58.  
  59. ;
  60. -- Toggle boolean (true/false) settings
  61. ; Shift+Ctrl+F1 to toggle the autoAscend flag
  62. ; Shift+Ctrl+F2 to toggle the screenShotRelics flag
  63. ; Shift+Ctrl+F3 to toggle the playNotificationSounds flag
  64. ; Shift+Ctrl+F4 to toggle the playWarningSounds flag
  65. ; Shift+Ctrl+F5 to toggle the showSplashTexts flag
  66. ; Shift+Ctrl+F12 to toggle the debug flag (currently to debug the speed run variable calculations)
  67.  
  68. ; -----------------------------------------------------------------------------------------
  69.  
  70. #Persistent
  71. #NoEnv
  72. #InstallKeybdHook
  73.  
  74. #Include %A_ScriptDir%
  75. #Include ch_bot_lib.ahk
  76.  
  77. SetControlDelay, -1
  78.  
  79. scriptName=CH Sw1ft Bot
  80. scriptVersion=2.2
  81. minLibVersion=1.2
  82.  
  83. script := scriptName . " v" . scriptVersion
  84.  
  85. ; -----------------------------------------------------------------------------------------
  86. ; -- Mandatory Configuration
  87. ; -----------------------------------------------------------------------------------------
  88.  
  89. ; In Clicker Heroes, turn off the "Show relic found popups" option.
  90.  
  91. ; What game client are you running?
  92. ; * Steam: Do the configuration at default window size (1136x640).
  93. ; Right-click the script taskbar icon, start Windows Spy and verify the client size.
  94. ; * Browser: Change "SetTitleMatchMode" and "browserTopMargin" in the ch_bot_lib.ahk file.
  95.  
  96. ; Refresh script with Alt+F5.
  97.  
  98. ; Quick test #1: Ctrl+Alt+F1 should scroll down to the bottom
  99. ; Quick test #2: Ctrl+Alt+F2 should switch to the relics tab and then back
  100.  
  101. ;
  102. -- Speed run ----------------------------------------------------------------------------
  103.  
  104. ; Set to your Iris level in game.
  105. irisLevel := 849 ; try to keep your Iris within 1001 levels of your optimal zone
  106.  
  107. ; Clicker Heroes Ancients Optimizer @ http://s3-us-west-2.amazonaws.com/clickerheroes/ancientssoul.html
  108.  
  109. ; Use the optimizer to set the optimal level and time:
  110. optimalLevel := 1805speedRunTime := 27 ; minutes (usually between 27 and 33 minutes)
  111.  
  112. ; In the Heroes tab you can verify that you are using the optimal ranger.
  113. gildedRanger := 5 ; the number of your main guilded ranger
  114. ; 1:Dread Knight, 2:Atlas, 3:Terra, 4:Phthalo, 5:Banana, 6:Lilin, 7:Cadmia, 8:Alabaster, 9:Astraea
  115.  
  116. ; The assistant will automatically try to set the correct initDownClicks and yLvlInit settings.
  117. ; It will also assist with Iris level recommendations.
  118. useConfigurationAssistant := true
  119.  
  120. ;
  121. -- Init run & ascend --------------------------------------------------------------------
  122.  
  123. ; These settings are affected by your Iris level.
  124.  
  125. ; A list of clicks needed to scroll down 4 heroes at a time, starting from the top.
  126. initDownClicks := [6,7,6,7,6,3] ; the assistant will override this value if active
  127.  
  128. ; This y coordinate is supposed to keep itself inside the top lvl up button when scrolling down according to the above "clicking pattern".
  129. yLvlInit := 240 ; the assistant will override this value if active
  130.  
  131. ; To get these two right, do this:
  132. ; 1. Ascend with a "clickable" available.
  133. ; 2. Click Alt+F1 (the script should pick up the clickable).
  134. ; 3. Scroll down to the bottom. What ranger is last?
  135. ; 4. From the list below, pick the matching settings:
  136.  
  137. ; Astraea [6,5,6,5,6,3], 241 (Iris > 2010)
  138. ; Alabaster [6,6,5,6,6,3], 259 (Iris > 1760)
  139. ; Cadmia [6,6,6,6,6,3], 240 (Iris > 1510)
  140. ; Lilin [6,6,6,6,6,3], 285 (Iris > 1260)
  141. ; Banana [6,7,6,7,6,3], 240 (Iris > 1010)
  142. ; Phthalo [6,7,7,6,7,3], 273 (Iris > 760)
  143. ; Terra [7,7,7,7,7,3], 240 (Iris > 510)
  144. ; Atlas [7,7,7,8,7,3], 273 (Iris > 260)
  145. ; Dread Knight [7,8,7,8,7,4], 257
  146.  
  147. ; E.g. if Phthalo is last, you set initDownClicks to [6,7,7,6,7,3] and yLvlInit to 273.
  148. ; In this case your Iris level should be somewhere between 760 and 1010.
  149.  
  150. ; 5. Now click Alt+F2 (the script should level up and upgrade all heroes from Cid to Frostleaf).
  151.  
  152. ; If some heroes where missed, make sure you have picked the suggested setting for your Iris level.
  153. ; If you are close to one of these Iris irisThresholds, you should move above it with some margin.
  154. ; E.g if your Iris is at 489, you should level it to at least 529, pick the setting for Terra,
  155. ; reload the script (Alt+F5), ascend with a clickable and try Alt+F2 again.
  156.  
  157. ; If it still does not work, it's either the "click down" pattern or the click coordinate that is off.
  158.  
  159. ; My "trick" getting this to work is taking a ruler, position it inside Cid's lvl up button,
  160. ; then count the down clicks needed to get to Fisherman. If the ruler is still inside the
  161. ; top lvl up button, I continue down to Forest Seer (still counting clicks). I repeat this
  162. ; till I find a click pattern and starting position that work. Notice that the last step
  163. ; is only from Beastlord to Aphrodite to get Grant and Frostleaf in view.
  164. ; You can get the final yLvlInit coordinate via the Alt+MiddleMouseButton hotkey.
  165.  
  166. ; 6. Now click Alt+F3 to start a speed run. If the script got to a ranger to early and could
  167. ; not buy all upgrades at once, then increase the thresholdFactor below.
  168. ; 7. When done, click Alt+F4 to run the ascend code.
  169. ; If it didn't ascend, adjust the ascDownClicks setting below and try again.
  170.  
  171. ascDownClicks := 26 ; # of down clicks needed to get the ascension button center:ish (after a full speed run)
  172.  
  173. ; If all worked so far, you are set to go!
  174.  
  175. ; -----------------------------------------------------------------------------------------
  176. ; -- Optional Settings
  177. ; -----------------------------------------------------------------------------------------
  178.  
  179. ; (Steam only) Want to run borderless fullscreen?
  180. ; 1. In Clicker Heroes, turn on the "Full Screen" option.
  181. ; 2. Change "fullScreenOption" to "true" in the ch_bot_lib.ahk file.
  182. ; 3. Refresh with Alt+F5.
  183.  
  184. ;
  185. -- Speed run ----------------------------------------------------------------------------
  186.  
  187. ; Adjust this setting so the script reach and can level your gilded ranger to >175 instantly.
  188. thresholdFactor := 0.5 ; -1, -0.5, 0, 0.5, 1
  189.  
  190. activateSkillsAtStart := true
  191.  
  192. hybridMode := false ; chain a deep run when the speed run finish
  193.  
  194. ; Added flag for v0.19.
  195. autoAscend := true ; Warning! Set to true will both salvage relics and ascend without any user intervention!
  196. autoAscendDelay := 10 ; warning timer (in seconds) before ascending
  197.  
  198. ; If you run the Steam client with autoAscend, you can screenshot every relic you salvage!
  199. screenShotRelics := false
  200.  
  201. ;
  202. -- Deep run -----------------------------------------------------------------------------
  203.  
  204. deepRunTime := 60 ; minutes
  205.  
  206. clickableHuntDelay := 15 ; hunt for a clickable every 15s
  207. stopHuntThreshold := 30 ; stop hunt when this many minutes remain of a deep run
  208.  
  209. ; Number of gilds to move over at a time
  210. reGildCount := 100 ; don't set this higher than 100 if you plan on moving gilds during a deep run
  211. reGildRanger := gildedRanger + 1
  212.  
  213. ;
  214. -- Look & Feel --------------------------------------------------------------------------
  215.  
  216. ; true or false
  217. global showSplashTexts := true ; Note that some splash texts will always be shown
  218. global showProgressBar := true
  219. global playNotificationSounds := true
  220. global playWarningSounds := true
  221.  
  222. ; Splash text window position
  223. xSplash := A_ScreenWidth + A_ScreenWidth // 3 - wSplash // 2
  224. ySplash := A_ScreenHeight // 2
  225.  
  226. ; Progress bar position
  227. xProgressBar := 20 + A_ScreenWidth
  228. yProgressBar := 20
  229.  
  230. ; If you run with a dual/tripple monitor setup, you can move windows
  231. ; right or left by adding or subtracting A_ScreenWidth from the x-parameters.
  232.  
  233. ;
  234. -- Skill Combos -------------------------------------------------------------------------
  235.  
  236. ; Combo tester @ http://pastebin.com/YCj3UxP5
  237.  
  238. ; 1 - Clickstorm, 2 - Powersurge, 3 - Lucky Strikes, 4 - Metal Detector, 5 - Golden Clicks
  239. ; 6 - The Dark Ritual, 7 - Super Clicks, 8 - Energize, 9 - Reload
  240.  
  241. comboStart := [15*60, "8-1-2-3-4-5-7-6-9"]
  242. comboEDR := [15*60, "1-2-3-4-5-7-8-6-9", "8-9-1-2-3-4-5-7"]
  243. comboExtraLucky := [2.5*60, "8-3-7-6-5-4-2", "2", "2", "2-3-4", "2", "2"]
  244. comboGoldenLuck := [2.5*60, "6-2-3-5-8-9", "2-3-4-5-7", "2", "2", "2-3-4", "2", "2"]
  245. comboSuperLucky := [2.5*60, "6-2-3-7-8-9", "2-3-4-5-7", "2", "2", "2-3-4", "2", "2"]
  246.  
  247. speedRunStartCombo := comboStart
  248. deepRunCombo := comboSuperLucky
  249.  
  250. ; comboEDR timetable:
  251. ; 00:00 : 1-2-3-4-5-7-8-6-9
  252. ; 15:00 : 8-9-1-2-3-4-5-7
  253. ; 30:00 : repeat
  254.  
  255. ; comboSuperLucky timetable:
  256. ; 00:00 : 6-2-3-7-8-9
  257. ; 02:30 : 2-3-4-5-7
  258. ; 05:00 : 2
  259. ; 07:30 : 2
  260. ; 10:00 : 2-3-4
  261. ; 12:30 : 2
  262. ; 15:00 : 2
  263. ; 17:30 : repeat
  264.  
  265. ; -----------------------------------------------------------------------------------------
  266.  
  267. if (libVersion != minLibVersion) {
  268. showWarningSplash("The bot lib version must be " . minLibVersion . "!")
  269. ExitApp
  270. }
  271.  
  272. #Include *i ch_bot_settings.ahk
  273.  
  274. if (useConfigurationAssistant) {
  275. configurationAssistant()
  276. }
  277.  
  278. clientCheck()
  279.  
  280. ; -----------------------------------------------------------------------------------------
  281. ; -- Hotkeys (+=Shift, !=Alt, ^=Ctrl)
  282. ; -----------------------------------------------------------------------------------------
  283.  
  284. ; Show the cursor position with Alt+Middle Mouse Button
  285. !mbutton::
  286. mousegetpos, xpos, ypos
  287. msgbox,,% script,% "Cursor position: x" xpos-leftMarginOffset " y" ypos-topMarginOffset
  288. return
  289.  
  290. ; Pause/Unpause script
  291. Pause::Pause
  292. return
  293.  
  294. ; Abort speed/deep runs and auto ascensions with Alt+Pause
  295. !Pause::
  296. showSplashAlways("Aborting...")
  297. exitThread := true
  298. exitDRThread := true
  299. return
  300.  
  301. ; Quick tests:
  302. ; Ctrl+Alt+F1 should scroll down to the bottom
  303. ; Ctrl+Alt+F2 should switch to the relics tab and then back
  304.  
  305. ^!F1::
  306. scrollToBottom()
  307. return
  308.  
  309. ^!F2::
  310. switchToRelicTab()
  311. switchToCombatTab()
  312. return
  313.  
  314. ; Alt+F1 to F4 are here to test the individual parts of the full speed run loop
  315.  
  316. !F1::
  317. getClickable()
  318. return
  319.  
  320. !F2::
  321. initRun()
  322. return
  323.  
  324. !F3::
  325. switchToCombatTab()
  326. speedRun()
  327. return
  328.  
  329. !F4::
  330. ascend(autoAscend)
  331. return
  332.  
  333. ; Reload script with Alt+F5
  334. !F5::
  335. showSplashAlways("Reloading bot...", 1)
  336. Reload
  337. return
  338.  
  339. ; Speed run loop.
  340. ; Use to farm Hero Souls
  341. ^F1::
  342. mode := hybridMode ? "hybrid" : "speed"
  343. showSplashAlways("Starting " . mode . " runs...")
  344. loop
  345. {
  346. getClickable()
  347. sleep % coinPickUpDelay * 1000
  348. initRun()
  349. if (activateSkillsAtStart) {
  350. activateSkills(speedRunStartCombo[2])
  351. }
  352. speedRun()
  353. if (hybridMode) {
  354. deepRun()
  355. }
  356. ascend(autoAscend)
  357. }
  358. return
  359.  
  360. ; Deep run.
  361. ; Use (after a speed run) to get a few new gilds every now and then
  362. ^F2::
  363. deepRun()
  364. return
  365.  
  366. ^F6::
  367. reGildRanger := reGildRanger > rangers.MinIndex() ? reGildRanger-1 : reGildRanger
  368. showSplashAlways("Re-gild ranger set to " . rangers[reGildRanger])
  369. return
  370.  
  371. ^F7::
  372. reGildRanger := reGildRanger < rangers.MaxIndex() ? reGildRanger+1 : reGildRanger
  373. showSplashAlways("Re-gild ranger set to " . rangers[reGildRanger])
  374. return
  375.  
  376. ^F8::
  377. critical
  378. playNotificationSound()
  379. msgbox, 4,% script,% "Move " . reGildCount . " gilds to " . rangers[reGildRanger] . "?"
  380. ifmsgbox no
  381. return
  382. regild(reGildRanger, reGildCount) ; will pause the monster clicker if running
  383. return
  384.  
  385. +^F1::
  386. toggleFlag("autoAscend", autoAscend)
  387. return
  388.  
  389. +^F2::
  390. toggleFlag("screenShotRelics", screenShotRelics)
  391. return
  392.  
  393. +^F3::
  394. toggleFlag("playNotificationSounds", playNotificationSounds)
  395. return
  396.  
  397. +^F4::
  398. toggleFlag("playWarningSounds", playWarningSounds)
  399. return
  400.  
  401. +^F5::
  402. toggleFlag("showSplashTexts", showSplashTexts)
  403. return
  404.  
  405. +^F12::
  406. toggleFlag("debug", debug)
  407. return
  408.  
  409. ; -----------------------------------------------------------------------------------------
  410. ; -- Functions
  411. ; -----------------------------------------------------------------------------------------
  412.  
  413. configurationAssistant() {
  414. global
  415.  
  416. if (irisLevel < 145) {
  417. playWarningSound()
  418. msgbox,,% script,% "Your Iris do not fulfill the minimum level requirement of 145 or higher!"
  419. exit
  420. }
  421.  
  422. if (irisThreshold(2010)) { ; Astraea
  423. initDownClicks := [6,5,6,5,6,3]
  424. yLvlInit := 241
  425. } else if (irisThreshold(1760)) { ; Alabaster
  426. initDownClicks := [6,6,5,6,6,3]
  427. yLvlInit := 259
  428. } else if (irisThreshold(1510)) { ; Cadmia
  429. initDownClicks := [6,6,6,6,6,3]
  430. yLvlInit := 240
  431. } else if (irisThreshold(1260)) { ; Lilin
  432. initDownClicks := [6,6,6,6,6,3]
  433. yLvlInit := 285
  434. } else if (irisThreshold(1010)) { ; Banana
  435. initDownClicks := [6,7,6,7,6,3]
  436. yLvlInit := 240
  437. } else if (irisThreshold(760)) { ; Phthalo
  438. initDownClicks := [6,7,7,6,7,3]
  439. yLvlInit := 273
  440. } else if (irisThreshold(510)) { ; Terra
  441. initDownClicks := [7,7,7,7,7,3]
  442. yLvlInit := 240
  443. } else if (irisThreshold(260)) { ; Atlas
  444. initDownClicks := [7,7,7,8,7,3]
  445. yLvlInit := 273
  446. } else { ; Dread Knight
  447. initDownClicks := [7,8,7,8,7,4]
  448. yLvlInit := 257
  449. }
  450.  
  451. if (irisLevel < optimalLevel - 1001) {
  452. local levels := optimalLevel - 1001 - irisLevel
  453. playNotificationSound()
  454. msgbox,,% script,% "Your Iris is " . levels . " levels below the recommended ""optimal level - 1001"" rule."
  455. }
  456. }
  457.  
  458. irisThreshold(lvl) {
  459. global
  460. local upperThreshold := lvl + 19
  461. local lowerThreshold := lvl - 20
  462. if (irisLevel >= lowerThreshold and irisLevel < upperThreshold) {
  463. playWarningSound()
  464. msgbox,,% script,% "Threshold proximity warning! You should level up your Iris to " . upperThreshold . " or higher."
  465. }
  466. return irisLevel > lvl
  467. }
  468.  
  469. ; Level up and upgrade all heroes
  470. initRun() {
  471. global
  472.  
  473. switchToCombatTab()
  474. clickPos(xHero, yHero) ; prevent fails
  475.  
  476. upgrade(initDownClicks[1],2,,2) ; cid --> brittany
  477. upgrade(initDownClicks[2]) ; fisherman --> leon
  478. upgrade(initDownClicks[3]) ; seer --> mercedes
  479. upgrade(initDownClicks[4],,,,2) ; bobby --> king
  480. upgrade(initDownClicks[5],2,,,2) ; ice --> amenhotep
  481. upgrade(initDownClicks[6],,,2) ; beastlord --> shinatobe
  482. upgrade(0,,,,,true) ; grant & frostleaf
  483.  
  484. scrollToBottom()
  485. buyAvailableUpgrades()
  486. }
  487.  
  488. upgrade(times, cc1:=1, cc2:=1, cc3:=1, cc4:=1, skip:=false) {
  489. global
  490.  
  491. if (!skip) {
  492. ctrlClick(xLvl, yLvlInit, cc1)
  493. ctrlClick(xLvl, yLvlInit + oLvl, cc2)
  494. }
  495. ctrlClick(xLvl, yLvlInit + oLvl*2, cc3)
  496. ctrlClick(xLvl, yLvlInit + oLvl*3, cc4)
  497.  
  498. scrollDown(times)
  499. }
  500.  
  501. ; All heroes/rangers are expected to "insta-kill" everything at max speed (i.e. around
  502. ; 7 minutes per 250 levels). Only the last 2-3 minutes should slow down slightly.
  503. speedRun() {
  504. global
  505.  
  506. local stint := 0
  507. local stints := 2
  508. local tMax := 7 * 60
  509. local lMax := 250
  510. local lvlThreshold := 36 * thresholdFactor
  511. local zoneLvl := gildedRanger * lMax + lvlThreshold ; approx zone lvl where we can buy our gilded ranger @ lvl 150
  512. local lvls := zoneLvl - irisLevel ; lvl's to get there
  513. local midStintTime := 0
  514.  
  515. if (lvls > lMax) ; add a mid stint if needed
  516. {
  517. midStintTime := tMax
  518. lvls -= lMax
  519. stints += 1
  520. }
  521. local firstStintTime := ceil(lvls * tMax / lMax)
  522. local srDuration := speedRunTime * 60
  523. local totalClickDelay := ceil(srDuration / lvlUpDelay * zzz / 1000 + nextHeroDelay * stints)
  524. local lastStintTime := srDuration - firstStintTime - midStintTime - totalClickDelay
  525. local lastStintButton := gildedRanger = 9 ? 3 : 2 ; special case for Astraea
  526.  
  527. if (debug)
  528. {
  529. local nl := "`r`n"
  530. local output := ""
  531. output .= "irisLevel = " . irisLevel . nl
  532. output .= "optimalLevel = " . optimalLevel . nl
  533. output .= "speedRunTime = " . speedRunTime . nl
  534. output .= "gildedRanger = " . rangers[gildedRanger] . nl
  535. output .= "-----------------------------" . nl
  536. output .= "initDownClicks = "
  537. for i, e in initDownClicks {
  538. output .= e " "
  539. }
  540. output .= nl
  541. output .= "yLvlInit = " . yLvlInit . nl
  542. output .= "thresholdFactor = " . thresholdFactor . nl
  543. output .= "-----------------------------" . nl
  544. output .= "lvlThreshold = " . lvlThreshold . nl
  545. output .= "zoneLvl = " . zoneLvl . nl
  546. output .= "lvls = " . lvls . nl
  547. output .= "srDuration = " . formatSeconds(srDuration) . nl
  548. output .= "firstStintTime = " . formatSeconds(firstStintTime) . nl
  549. output .= "midStintTime = " . formatSeconds(midStintTime) . nl
  550. output .= "lastStintTime = " . formatSeconds(lastStintTime) . nl
  551. output .= "totalClickDelay = " . formatSeconds(totalClickDelay) . nl
  552.  
  553. clipboard := % output
  554. msgbox % output
  555. return
  556. }
  557.  
  558. showSplash("Starting speed run...")
  559.  
  560. if (irisLevel < 2 * lMax + 10) ; Iris high enough to start with a ranger?
  561. {
  562. switchToCombatTab()
  563. scrollDown(initDownClicks[1])
  564. toggleMode() ; toggle to progression mode
  565. lvlUp(firstStintTime, 0, 3, ++stint, stints) ; nope, let's bridge with Samurai
  566. scrollToBottom()
  567. } else {
  568. scrollToBottom()
  569. toggleMode() ; toggle to progression mode
  570. lvlUp(firstStintTime, 1, 1, ++stint, stints)
  571. scrollWayDown(3)
  572. }
  573. if (midStintTime) {
  574. lvlUp(midStintTime, 1, 2, ++stint, stints)
  575. scrollWayDown(2)
  576. }
  577. lvlUp(lastStintTime, 1, lastStintButton, ++stint, stints)
  578.  
  579. showSplash("Speed run completed.")
  580. }
  581.  
  582. deepRun() {
  583. global
  584.  
  585. exitDRThread := false
  586.  
  587. local drDuration := deepRunTime * 60
  588. local button := gildedRanger = 9 ? 3 : 2 ; special case for Astraea
  589. local y := yLvl + oLvl * (button - 1)
  590.  
  591. showSplash("Starting deep run...")
  592.  
  593. startMouseMonitoring()
  594. startProgress("Deep Run Progress", 0, drDuration // barUpdateDelay)
  595. monsterClickerOn()
  596.  
  597. local comboDelay := deepRunCombo[1]
  598. local comboIndex := 2
  599. local stopHuntIndex := drDuration - stopHuntThreshold * 60
  600. local t := 0
  601.  
  602. loop % drDuration
  603. {
  604. if (exitDRThread) {
  605. monsterClickerOff()
  606. stopProgress()
  607. stopMouseMonitoring()
  608. showSplashAlways("Deep run aborted!")
  609. exit
  610. }
  611. clickPos(xMonster, yMonster)
  612. if (mod(t, comboDelay) = 0) {
  613. activateSkills(deepRunCombo[comboIndex])
  614. comboIndex := comboIndex < deepRunCombo.MaxIndex() ? comboIndex+1 : 2
  615. }
  616. if (mod(t, lvlUpDelay) = 0) {
  617. ctrlClick(xLvl, y, 1, 0)
  618. }
  619. if (mod(t, clickableHuntDelay) = 0 and t < stopHuntIndex) {
  620. getClickable()
  621. }
  622. t += 1
  623. updateProgress(t // barUpdateDelay, drDuration - t)
  624. sleep 1000
  625. }
  626.  
  627. monsterClickerOff()
  628. stopProgress()
  629. stopMouseMonitoring()
  630.  
  631. showSplash("Deep run ended.")
  632. }
  633.  
  634. monsterClickerOn() {
  635. send {blind}{shift down}{f1}{shift up}
  636. }
  637.  
  638. monsterClickerPause() {
  639. send {blind}{shift down}{f2}{shift up}
  640. }
  641.  
  642. monsterClickerOff() {
  643. send {blind}{shift down}{pause}{shift up}
  644. }
  645.  
  646. lvlUp(seconds, buyUpgrades, button, stint, stints) {
  647. global
  648.  
  649. exitThread := false
  650. local y := yLvl + oLvl * (button - 1)
  651. local title := "Speed Run Progress (" . stint . "/" . stints . ")"
  652.  
  653. startMouseMonitoring()
  654. startProgress(title, 0, seconds // barUpdateDelay)
  655.  
  656. if (buyUpgrades) {
  657. ctrlClick(xLvl, y)
  658. buyAvailableUpgrades()
  659. }
  660. maxClick(xLvl, y)
  661.  
  662. local t := 0
  663.  
  664. loop % seconds
  665. {
  666. if (exitThread) {
  667. stopProgress()
  668. stopMouseMonitoring()
  669. showSplashAlways("Speed run aborted!")
  670. exit
  671. }
  672. if (mod(t, lvlUpDelay) = 0) {
  673. ctrlClick(xLvl, y)
  674. }
  675. t += 1
  676. updateProgress(t // barUpdateDelay, seconds - t)
  677. sleep 1000
  678. }
  679. stopProgress()
  680. stopMouseMonitoring()
  681. }
  682.  
  683. ascend(autoYes:=false) {
  684. global
  685. exitThread := false
  686. local extraClicks := 6
  687. local y := yAsc - extraClicks * buttonSize
  688.  
  689. if (autoYes) {
  690. showWarningSplash(autoAscendDelay . " seconds till ASCENSION! (Abort with Alt+Pause)", autoAscendDelay)
  691. if (exitThread) {
  692. showSplashAlways("Ascension aborted!")
  693. exit
  694. }
  695. } else {
  696. playWarningSound()
  697. msgbox, 4,% script,Salvage Junk Pile & Ascend?
  698. ifmsgbox no
  699. exit
  700. }
  701.  
  702. salvageJunkPile() ; must salvage junk relics before ascending
  703.  
  704. switchToCombatTab()
  705. scrollDown(ascDownClicks)
  706. sleep % zzz * 2
  707.  
  708. ; Scrolling is not an exact science, hence we click above, center and below
  709. loop % 2 * extraClicks + 1
  710. {
  711. clickPos(xAsc, y)
  712. y += buttonSize
  713. }
  714. sleep % zzz * 4
  715. clickPos(xYes, yYes)
  716. sleep % zzz * 2
  717. }
  718.  
  719. salvageJunkPile() {
  720. global
  721.  
  722. switchToRelicTab()
  723. if (autoAscend && screenShotRelics) {
  724. clickPos(xRelic, yRelic) ; focus
  725. screenShot()
  726. clickPos(xRelic+100, yRelic) ; remove focus
  727. }
  728. clickPos(xSalvageJunk, ySalvageJunk)
  729. sleep % zzz * 4
  730. clickPos(xDestroyYes, yDestroyYes)
  731. sleep % zzz * 2
  732. }
  733.  
  734. buyAvailableUpgrades() {
  735. global
  736. clickPos(xBuy, yBuy)
  737. sleep % zzz * 3
  738. }
  739.  
  740. ; Scroll down fix when at bottom and scroll bar don't update correctly
  741. scrollWayDown(clickCount:=1) {
  742. global
  743. scrollUp()
  744. scrollDown(clickCount + 1)
  745. sleep % nextHeroDelay * 1000
  746. }
  747.  
  748. regild(ranger, gildCount) {
  749. global
  750. monsterClickerPause()
  751. switchToCombatTab()
  752. scrollToBottom()
  753.  
  754. clickPos(xGilded, yGilded)
  755. sleep % zzz * 2
  756.  
  757. ControlSend,, {shift down}, % winName
  758. clickPos(rangerPositions[ranger].x, rangerPositions[ranger].y, gildCount)
  759. sleep % 1000 * gildCount/100*5
  760. ControlSend,, {shift up}, % winName
  761.  
  762. clickPos(xGildedClose, yGildedClose)
  763. sleep % zzz * 2
  764. }
  765.  
  766. ; Toggle between farm and progression modes
  767. toggleMode() {
  768. global
  769. ControlSend,, {a down}{a up}, % winName
  770. sleep % zzz
  771. }
  772.  
  773. activateSkills(skills) {
  774. global
  775. clickPos(xHero, yHero) ; prevent fails
  776. loop,parse,skills,-
  777. {
  778. ControlSend,,% A_LoopField, % winName
  779. sleep 100
  780. }
  781. sleep 1000
  782. }
  783.  
  784. startMouseMonitoring() {
  785. setTimer, checkMousePosition, 250
  786. }
  787.  
  788. stopMouseMonitoring() {
  789. setTimer, checkMousePosition, off
  790. }
  791.  
  792. ; -----------------------------------------------------------------------------------------
  793. ; -- Subroutines
  794. ; -----------------------------------------------------------------------------------------
  795.  
  796. checkMousePosition:
  797. MouseGetPos,,, window
  798. if (window = WinExist(winName)) {
  799. WinActivate
  800. MouseGetPos, x, y
  801.  
  802. xL := getAdjustedX(xSafetyZoneL)
  803. xR := getAdjustedX(xSafetyZoneR)
  804. yT := getAdjustedY(ySafetyZoneT)
  805. yB := getAdjustedY(ySafetyZoneB)
  806.  
  807. if (x > xL && x < xR && y > yT && y < yB) {
  808. playNotificationSound()
  809. msgbox,,% script,Click safety pause engaged. Continue?
  810. }
  811. }
  812. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement