djr242

Untitled

Aug 16th, 2015
916
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Clicker Heroes Steam Version AutoHotkey script
  2. ; Version: 0.3
  3. ; Date: 5/28/2015
  4. ; Author: Andrux51 (http://github.com/Andrux51)
  5. ; Revision: 08/15/15 djr242
  6. ;
  7. ; This script will auto-click the Clicker Heroes game window while attempting
  8. ; to collect all "clickables" (currently Easter Eggs) including the moving one.
  9. ; Significant changes have been made to the original code.
  10. ;
  11. ; The script will attempt to use two seperate sequences for ability usage.
  12. ; There are also a couple of features to help speed leveling along.
  13. ;
  14. ; Instructions:
  15. ; - Run .ahk file
  16. ; - F1 will start progression, buying all abilities for adventurers through Phthalo if able.
  17. ;   F1 will also start the autoclicker after adventurers are bought.
  18. ; - F2 will level up adventurer in slots 1-4 to 100 and buy all abilities.
  19. ; - F3 will level up the adventurer in slot 1 only by 100 levels (does not buy abilities)
  20. ; - F4 will begin/resume the auto-clicker (no ability usage or leveling)
  21. ; - F5 will begin/resume the auto-clicker and level the 1st hero on the list
  22. ; - F6 will allow for time to buy guys/skills etc without losing combo
  23. ; - F7 will pause the auto-clicker
  24. ; - F10 will exit the script entirely
  25. ;
  26. ; Change "timing" variable to suit your needs if the script is running too fast or slow.
  27. ;
  28.  
  29. #SingleInstance force ; if script is opened again, replace instance
  30. #Persistent ; script stays in memory until ExitApp is called or script crashes
  31.  
  32. global title := "Clicker Heroes" ; we will exact match against this for steam version
  33. global msgtitle := "ClickerHerosAuto.ahk"
  34. global stop := false
  35.  
  36. ; change this value to adjust script speed (milliseconds)
  37. global timing := 100
  38. global looper := 0
  39.  
  40. ; pass in frequency to check for clickables
  41. ; higher number means more clicks on moving clickable, less often for other clickables
  42. global frequency := 200
  43.  
  44. ; F1 will start the autoleveler
  45. F1::
  46.    
  47.     frequency := 50
  48.     autoLvler(timing, frequency)
  49.     return
  50.  
  51. ; F2 will level up adventurer in slots 1-4 to 100 and buy all abilities.
  52. F2::
  53.    
  54.    l := 1
  55.     while(l < 5) {
  56.     levelSlot(l)
  57.     l++
  58.     }
  59.    return
  60.  
  61. ; F3 will level up the adventurer in slot 1 only by 100 levels (does not buy abilities)
  62. F3::
  63.  
  64.     clickHeroInSlot(1, 1)
  65.     return
  66.  
  67. ; F4 will begin/resume the auto-clicker (no ability usage or leveling)
  68. F4::
  69.     frequency := 50
  70.     autoClicker(timing, frequency, false, false)
  71.     return
  72.  
  73. ; F5 will begin/resume the auto-clicker and level the masked samurai
  74. F5::
  75.     frequency := 50
  76.     autoClicker(timing, frequency, true, true)
  77.     return
  78.  
  79. ; F6 will allow for time to buy guys/skills etc without losing combo
  80. F6::
  81.     while(!stop) {
  82.     getClickables()
  83.     sleep 9000
  84.     }
  85.     return
  86.  
  87. ; F7 will pause the auto-clicker
  88. F7::
  89.     stop := true
  90.     return
  91.  
  92. ; F10 will exit the script entirely
  93. F10::
  94.     ExitApp
  95.     return
  96.  
  97. ; pass in milliseconds to adjust click speed
  98. autoClicker(milli, p, levelup, useAbilities) {
  99.     SetWorkingDir, C:\Program Files (x86)\Steam\steamapps\common\Clicker Heroes\images    
  100.     stop := false
  101.     ControlClick,, %title%,,,, x545 y215 NA
  102.     ControlClick,, %title%,,,, x1113 y248 NA
  103.     setDefaults()
  104.  
  105.     i = 0
  106.     while(!stop) {
  107.         getSkillBonusClickable()
  108.  
  109.         if(i > p) {
  110.             getClickables()
  111.  
  112.             if(levelup) {
  113. ;find the masked samurai
  114.         loop {
  115.         xx :=0
  116.         yy :=0
  117.         sleep 500
  118.             ImageSearch,xx,yy,140,150,450,560, *TransECD68A *75 6.jpg
  119.                 if(ErrorLevel=0) {
  120.                    goto level
  121.             }
  122.                 if(ErrorLevel=1) {
  123.                ImageSearch,xx,yy,140,150,450,560, *TransFFE267 *100 56.jpg
  124.                if(ErrorLevel=0) {
  125.                 goto level
  126.                }
  127.  
  128.             DArrow()
  129.             DArrow()
  130.             DArrow()
  131.             }
  132.           }
  133.           level:
  134.             x1 := xx-70
  135.             y1 := yy+40
  136.           send {Ctrl down}
  137.           ControlClick,, %title%,,,, x%x1% y%y1% Na
  138.           send {Ctrl up}
  139.             }
  140.         if(useAbilities) {
  141.             n :=1
  142.                 if(n < 3) {
  143.            if(n=1) {
  144.             useAbilities(1)
  145.             }
  146.            else {
  147.             useAbilities(2)
  148.             n=1
  149.             }
  150.            }
  151.             }
  152.         i = 0
  153.         }
  154.  
  155.     i++
  156.     Sleep milli
  157.     }
  158.  
  159.     return
  160. }
  161.  
  162. autoLvler(milli, p) {
  163.     stop := false
  164.     SetWorkingDir, C:\Program Files (x86)\Steam\steamapps\common\Clicker Heroes\images
  165.     setDefaults()
  166. ;go to top of screen
  167.     ControlClick,, %title%,,,, x545 y215 NA
  168.  
  169. ;Just random variables used to count
  170.     i := 0
  171.     m := i + 50
  172.  
  173.     loop,26 {
  174.     loop {
  175.       xx :=0
  176.       yy :=0
  177.       sleep 3000
  178. ;search for adeventurer %i%
  179.       ImageSearch,xx,yy,140,150,450,560, *TransECD68A *75 %i%.jpg
  180.         if(ErrorLevel=0) {
  181.             goto outer
  182.         }
  183. ;search for adeventurer %m% (this is adventurer %i% after guilding)
  184.         if(ErrorLevel=1) {
  185.         ImageSearch,xx,yy,140,150,450,560, *TransFFE267 *100 %m%.jpg
  186.            if(ErrorLevel=0) {
  187.             goto outer
  188.            }
  189.         DArrow()
  190.         DArrow()
  191.         DArrow()
  192.         DArrow()
  193.         DArrow()
  194.         }
  195.     }
  196. ;after finding the desired adventurer, level him up
  197.         outer:
  198.         if(ErrorLevel=0) {
  199.             x1 := xx-70
  200.             y1 := yy+40
  201.             send {Ctrl down}
  202.         sleep 50
  203.             checkCost(x1, y1)
  204.             send {Ctrl up}
  205.         sleep 50
  206.             send {z down}
  207.         sleep 50
  208.             checkCost(x1, y1)
  209.             send {z up}
  210.         sleep 50
  211.        
  212. ;buy upgrades
  213.         x2 := 170
  214.         loop, 7 {
  215.            x2 := x2 + 34
  216.            if(a_index >2) {
  217.             if(i=19||m=69) {
  218.             goto index
  219.             }
  220.            }
  221.            checkCost(x2, y1)
  222.            Sleep 20
  223.         }
  224.        
  225.           index:
  226.           i++
  227.           m++
  228. ;moves forward levels every iteration. must have Iris up to level 50
  229.           ControlClick,, %title%,,,, x983 y44 NA
  230.           sleep 500
  231.           ControlClick,, %title%,,,, x983 y44 NA
  232.           sleep 500
  233.           ControlClick,, %title%,,,, x983 y44 NA
  234.           sleep 500
  235.           ControlClick,, %title%,,,, x983 y44 NA
  236.  
  237.         }
  238.     }
  239.     Send {F5}
  240. }
  241. checkCost(c1, c2) {
  242.     PixelSearch,,,142,c2,146,c2+15, 2B6386, 100, Fast
  243.     if(ErrorLevel=1) {
  244.     ControlClick,, %title%,,,, X%c1% Y%c2% NA
  245.     }
  246.     else {
  247.     ;send {F5}
  248.     }
  249.    return
  250. }
  251.  
  252. DArrow() {
  253.     ControlClick,, %title%,,,, x540 y623 NA
  254.     return
  255. }
  256.  
  257. UArrow() {
  258.     ControlClick,, %title%,,,, x540 y190 NA
  259.     return
  260. }
  261.  
  262. useAbilities(type) {
  263.     if(type=1) {
  264.         useAbility1()
  265.         useAbility2()
  266.         useAbility3()
  267.         useAbility9()
  268.         useAbility4()
  269.         useAbility5()
  270.     }
  271.     if(type=2) {
  272.         useAbility8()
  273.         useAbility3()
  274.         useAbility7()
  275.         useAbility6()
  276.     }
  277.     return
  278. }
  279.  
  280. useAbility1() {
  281.     ; 1. Clickstorm
  282.     ControlClick,, %title%,,,, x600 y170 NA
  283.     return
  284. }
  285. useAbility2() {
  286.     ; 2. Powersurge
  287.     ControlClick,, %title%,,,, x600 y220 NA
  288.     return
  289. }
  290. useAbility3() {
  291.     ; 3. Lucky Strikes
  292.     ControlClick,, %title%,,,, x600 y270 NA
  293.     return
  294. }
  295. useAbility4() {
  296.     ; 4. Metal Detector
  297.     ControlClick,, %title%,,,, x600 y325 NA
  298.     return
  299. }
  300. useAbility5() {
  301.     ; 5. Golden Clicks
  302.     ControlClick,, %title%,,,, x600 y375 NA
  303.     return
  304. }
  305. useAbility6() {
  306.     ; 6. Dark Ritual
  307.     ControlClick,, %title%,,,, x600 y425 NA
  308.     return
  309. }
  310. useAbility7() {
  311.     ; 7. Super Clicks
  312.     ControlClick,, %title%,,,, x600 y480 NA
  313.     return
  314. }
  315. useAbility8() {
  316.     ; 8. Energize
  317.     ControlClick,, %title%,,,, x600 y530 NA
  318.     return
  319. }
  320. useAbility9() {
  321.     ; 9. Reload
  322.     ControlClick,, %title%,,,, x600 y580 NA
  323.     return
  324. }
  325.  
  326. getSkillBonusClickable() {
  327.     ; click in a sequential area to try to catch mobile clickable
  328.     ControlClick,, %title%,,,, x770 y130 NA
  329.     ControlClick,, %title%,,,, x790 y130 NA
  330.     ControlClick,, %title%,,,, x870 y130 NA
  331.     ControlClick,, %title%,,,, x890 y130 NA
  332.     ControlClick,, %title%,,,, x970 y130 NA
  333.     ControlClick,, %title%,,,, x990 y130 NA
  334.  
  335.     return
  336. }
  337.  
  338. getClickables() {
  339.     ; clickable positions
  340.     ControlClick,, %title%,,,, x505 y460 NA
  341.     ControlClick,, %title%,,,, x730 y400 NA
  342.     ControlClick,, %title%,,,, x745 y450 NA
  343.     ControlClick,, %title%,,,, x745 y340 NA
  344.     ControlClick,, %title%,,,, x850 y480 NA
  345.     ControlClick,, %title%,,,, x990 y425 NA
  346.     ControlClick,, %title%,,,, x1030 y410 NA
  347.  
  348.     return
  349. }
  350.  
  351.  
  352. setDefaults() {
  353.     SendMode InputThenPlay
  354.     CoordMode, Mouse, Client
  355.     SetKeyDelay, 0, 0
  356.     SetMouseDelay 2 ; anything lower becomes unreliable for scrolling
  357.     SetControlDelay 2 ; anything lower becomes unreliable for scrolling
  358.     SetTitleMatchMode 3 ; window title is an exact match of the string supplied
  359.  
  360.     return
  361. }
  362.  
  363.  
  364. clickHeroInSlot(slot, times) {
  365.     if(slot = 1) {
  366.     send {Ctrl down}
  367.         ControlClick,, %title%,,, %times%, x50 y250 NA
  368.     send {Ctrl up}
  369.     }
  370.     if(slot = 2) {
  371.     send {Ctrl down}
  372.         ControlClick,, %title%,,, %times%, x50 y356 NA
  373.     send {Ctrl up}
  374.     }
  375.     if(slot = 3) {
  376.     send {Ctrl down}
  377.         ControlClick,, %title%,,, %times%, x50 y462 NA
  378.     send {Ctrl up}
  379.     }
  380.     if(slot = 4) {
  381.     send {Ctrl down}
  382.         ControlClick,, %title%,,, %times%, x50 y568 NA
  383.     send {Ctrl up}
  384.     }
  385.     return
  386. }
  387.  
  388. levelSlot(number) {
  389.     if(number = 1) {
  390.            clickHeroInSlot(1, 2)
  391.            Sleep 100
  392.     buyUpgrades(1)
  393.     }
  394.     if(number = 2) {
  395.            clickHeroInSlot(2, 2)
  396.            Sleep 100
  397.     buyUpgrades(2)
  398.     }
  399.     if(number = 3) {
  400.            clickHeroInSlot(3, 2)
  401.            Sleep 100
  402.     buyUpgrades(3)
  403.     }
  404.     if(number = 4) {
  405.            clickHeroInSlot(4, 2)
  406.            Sleep 100
  407.     buyUpgrades(4)
  408.     }
  409.  
  410.     return
  411. }
  412.  
  413. buyUpgrades(slot) {
  414.     if(slot = 1) {
  415.     ControlClick,, %title%,,,, x190 y250 NA
  416.     Sleep 5
  417.     ControlClick,, %title%,,,, x230 y250 NA
  418.     Sleep 5
  419.     ControlClick,, %title%,,,, x265 y250 NA
  420.     Sleep 5
  421.     ControlClick,, %title%,,,, x300 y250 NA
  422.     Sleep 5
  423.     ControlClick,, %title%,,,, x340 y250 NA
  424.     Sleep 5
  425.     ControlClick,, %title%,,,, x370 y250 NA
  426.     Sleep 5
  427.     ControlClick,, %title%,,,, x413 y250 NA
  428.     }
  429.     if(slot = 2) {
  430.     ControlClick,, %title%,,,, x190 y355 NA
  431.     Sleep 5
  432.     ControlClick,, %title%,,,, x230 y355 NA
  433.     Sleep 5
  434.     ControlClick,, %title%,,,, x265 y355 NA
  435.     Sleep 5
  436.     ControlClick,, %title%,,,, x300 y355 NA
  437.     Sleep 5
  438.     ControlClick,, %title%,,,, x340 y355 NA
  439.     Sleep 5
  440.     ControlClick,, %title%,,,, x370 y355 NA
  441.     Sleep 5
  442.     ControlClick,, %title%,,,, x413 y355 NA
  443.     }
  444.     if(slot = 3) {
  445.     ControlClick,, %title%,,,, x190 y465 NA
  446.     Sleep 5
  447.     ControlClick,, %title%,,,, x230 y465 NA
  448.     Sleep 5
  449.     ControlClick,, %title%,,,, x265 y465 NA
  450.     Sleep 5
  451.     ControlClick,, %title%,,,, x300 y465 NA
  452.     Sleep 5
  453.     ControlClick,, %title%,,,, x340 y465 NA
  454.     Sleep 5
  455.     ControlClick,, %title%,,,, x370 y465 NA
  456.     Sleep 5
  457.     ControlClick,, %title%,,,, x413 y465 NA
  458.     }
  459.     if(slot = 4) {
  460.     ControlClick,, %title%,,,, x190 y570 NA
  461.     Sleep 5
  462.     ControlClick,, %title%,,,, x230 y570 NA
  463.     Sleep 5
  464.     ControlClick,, %title%,,,, x265 y570 NA
  465.     Sleep 5
  466.     ControlClick,, %title%,,,, x300 y570 NA
  467.     Sleep 5
  468.     ControlClick,, %title%,,,, x340 y570 NA
  469.     Sleep 5
  470.     ControlClick,, %title%,,,, x370 y570 NA
  471.     Sleep 5
  472.     ControlClick,, %title%,,,, x413 y570 NA
  473.     }
  474.    
  475.     return
  476. }
Advertisement
Add Comment
Please, Sign In to add comment