Guest User

Testing Mac vesion of Clicker Heroes Sikuli script edition

a guest
Aug 15th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 64.50 KB | None | 0 0
  1. #This script was made by Evildeliverance. Message me on Reddit if you need help.
  2. #Credit to Reddit user Dewarim for introducing me to this tool with his Fish autoclicker.
  3. #---
  4. #The core (original script): Version 2.0 by evildeliverance
  5. #
  6. #New Features Edition by TheWhiteAvatar - Version 5
  7. #Added Midas start, laptop resolutions support, short active mode before ascension, and some additional fixes
  8. #New in version 5:
  9. # - the core of the script changed to version 2.0 Final (released by evildeliverance)
  10. # - optimization: Midas start get canceled if a clickable suddenly appears (the script uses a clickable instead)
  11. #------
  12. #Midas start always takes around 3 minutes before instakilling will start after ascension.
  13. #But Midas start has a lot more HS gain efficiency during speed runs than waiting for a clickable,
  14. #because often while waiting for a clickable you will stop instakilling for 5, 10, 15 or even 20 minutes.
  15. #
  16. #To enable Midas start just set Settings.MidasStart to True and set Settings.WaitForFishBeforeAscending to False
  17. #
  18. #To enable usage of active skills for 90 seconds before ascension for more efficiency
  19. #(assuming you can instakill with all skills activated if used after you stop instakilling in your speed run),
  20. #set Settings.ActivateAllSkillsWithEnergizedLuckyStrikesBeforeAscension to True
  21. #------
  22.  
  23. #Feel free to modify this script to suit your needs but if you redistribute it, please leave my name up here somewhere.
  24. #Scroll down to line 175 for the beginning of the script. Read that portion then come back to the top and read the rest.
  25.  
  26. #These variables are meant to be edited by you to tweak the performance of the script.
  27.  
  28. #True and False are CASE SENSITIVE
  29.  
  30. Settings.CheckForAscend = True #Set to False if you do not want the script to ascend for you.
  31. Settings.AscendNextLevelClicks = 12 #Set this lower if the script advances through levels too fast during ascension. Set it higher if it is too slow.
  32. Settings.WaitForMoney = 0 #Set this higher if the script attempts to purchase things it can't afford during ascend
  33.  
  34. #!!!!Increase the value of the next variable if you ascend too fast or if you do not have Iris.
  35. Settings.TimeToLookForMovementBeforeAscending = 2 #this is the number of seconds you must remain on a level before the script will decide you are leveling too slowly and you should ascend. Make it higher or lower if it ascends too early or too late.
  36.  
  37. Settings.StartGildedSearchFromBottom = True #Change this to false if your preferred gilded hero is towards the top of the list.
  38. Settings.IHaveIris = True
  39.  
  40. Settings.NoGildedHeroesAvailable = True #Set this to False if no gilded heroes are purchasable at the beginning of an ascension.
  41. Settings.IHaveMoreThanTwoGildedHeroes = True #If this is true, we will periodically scroll to the bottom and look for a lower gilded hero. These heroes must all be in a row for this to work!
  42.  
  43. Settings.BuyAllHeroesFaster = True #Remove the mouse delay while going through and purchasing all heroes for their skills. Set to False if it tries to buy them faster than the money is coming in.
  44. Settings.EDR = True #EDR after ascending?
  45. Settings.TurnProgressionBackOn = 0 #Number of minutes inbetween making sure progression mode is on. Good for deep runs. 0 for do not check.
  46.  
  47. Settings.EDR_ER = False #EDR then ER then EDR then ER etc
  48. Settings.StopOnGoodRelic = False #Set this true to find +4 or +5% primal relics.
  49. Settings.SomeHeroesGetSkipped = False #Turn this on only if some heroes get leveled 0 times.
  50.  
  51. Settings.WaitForFishBeforeAscending = False #Set this True if Iris is a high level (if set False it will use Midas start)
  52.  
  53. #Settings added by TheWhiteAvatar
  54. #------
  55.  
  56. Settings.MidasStart = True #Uses Midas start after ascension.
  57. #Will work if set True and if Settings.WaitForFishBeforeAscending from above is set to False
  58.  
  59. Settings.ActivateAllSkillsWithEnergizedLuckyStrikesBeforeAscension = True #For more efficiency go active for 90 secods before ascension
  60.  
  61. Settings.ActivatePowersurgeAndMetalDetectorInAdditionToEDR = True #After ascension with EDR combo (EDR would break Idle mode anyways)
  62.  
  63. Settings.TryToSpeedUpMidasStart = True #Instakilling after ascension will start around 30 seconds faster than without this option
  64. #It also will cause EDR combo to delay a bit more after ascension so it wouldn't slow you down at all when used because you'd be stronger already
  65.  
  66. #-------------------
  67. #Deep Run Mode instead of ascending after a speed run (beta, and probably won't be finished anyways)
  68. #This setting functionality wasn't tested properly yet. You may use it on your own risk!
  69. #If you'd want to add some fast autoclicking, you'll need to use any separate autoclicking program,
  70. #but try not to set it to more than 30 clicks per second.
  71. #This was tested without autocliking, just with automatic using skills from time to time, so it might not support fast autoclicking at all.
  72. #It would stay in a deep run mode until you ascend manually (before it you should stop the script and change this setting back to False)
  73. Settings.DeepRunInsteadOfAscension = False #Goes on a deep run with skills usage, if True and if Settings.CheckForAscend was set to True
  74.  
  75. #---
  76. Settings.AlternativeFrostLeafSearch = False #It's slower.
  77. #Set it True only if the script for some reason can't identify when to stop buying 200 levels of each hero after ascension.
  78.  
  79.  
  80. #------------------------
  81. #------------------------
  82. #These variables should be left alone. They are initialized here with their correct starting values and will change on their own.
  83. Settings.Times=0
  84. Settings.GildedHeroBelowFrostleafUpgradesPurchased = True#Don't change this.
  85. Settings.MoveMouseDelay = 0.5
  86.  
  87. Settings.AscendStartTime = int(time.time())
  88. Settings.EDRTime = int(time.time()) - 500
  89. Settings.AscendRequirementsMet = False
  90. Settings.ProgressionLastVerified = int(time.time())
  91. Settings.EDR_ER_State = "NONE"
  92.  
  93. Settings.AdditionalBuyAllUpgrades = 12
  94. Settings.IfQuickMidasStartHappened = False
  95. Settings.EDRDelayValueIfQuickMidasStartHappened = 10
  96. Settings.EDRDelayCounterIfQuickMidasStartHappened = 0
  97. Settings.DeepRunStartPositionTemporary = Env.getMouseLocation()
  98.  
  99. if (Settings.WaitForFishBeforeAscending == True):
  100. Settings.MidasStart = False
  101.  
  102. from guide import *#Not currently used but it can do some nice highlighting stuff I might use later so it is still here.
  103. import java.awt.Robot as JRobot#JRobot is used for identifying the color of a pixel.
  104. myRobot = JRobot()
  105.  
  106. def FindAndClick(Picture, ModifierVar = 0, CheckStart = True): #Function to find an image and click it. ModifierVar is for Ctrl+Clicking and such. CheckStart tests if the mouse moved.
  107. if exists(Picture,0) and (StartPosition == Env.getMouseLocation() or CheckStart == False):
  108. click( getLastMatch(), ModifierVar)
  109. if Settings.DeepRunInsteadOfAscension == False:
  110. hover(Location(StartPosition))
  111. else:
  112. hover(Location(Settings.DeepRunStartPositionTemporary))
  113. return True
  114. else:
  115. return False
  116.  
  117. def goClick(ClickLocation, ModifierVar = 0, CheckStart = True):#checks if the mouse has moved, if it has not, clicks the location specified
  118. if StartPosition == Env.getMouseLocation() or CheckStart == False:
  119. #Region(ClickLocation.getX()-2,ClickLocation.getY()-2,4,4).highlight(5)
  120. click( ClickLocation, ModifierVar)
  121. hover(Location(StartPosition))
  122. return True
  123. else:
  124. return False
  125.  
  126. def FindAndClickAll(Picture):#This function clicks every occurance of an image on the screen.
  127. try:
  128. FA = findAll(Picture)
  129. for i in FA:
  130. click( i)
  131. hover(Location(StartPosition))
  132. return True
  133. except:
  134. return False
  135.  
  136. def TryToFind(Picture): #This function just checks to see if an image is on screen at all. Added this so I could modify the delay globally without needing to find and replace all.
  137. if exists(Picture,0):
  138. return True
  139. else:
  140. return False
  141.  
  142. def CollectCoins():
  143. StoreSpeed = Settings.MoveMouseDelay
  144. Settings.MoveMouseDelay = .5
  145.  
  146. ShowTheGameBottomForSmallScreenResolutions()
  147.  
  148. if exists(Pattern("1434493975401.png").targetOffset(-315,-187),0):
  149. hover(getLastMatch())
  150. wait(.1)
  151. hover(Pattern("1434493975401.png").targetOffset(329,-180))
  152.  
  153. hover(Location(StartPosition))
  154. wait(.5)
  155. Settings.MoveMouseDelay = StoreSpeed
  156. ShowTheGameTopForSmallScreenResolutions()
  157.  
  158. def ShowTheGameTopForSmallScreenResolutions():
  159. if not exists(Pattern("1432967930862.png").similar(0.85),0):
  160. spd = Settings.MoveMouseDelay
  161.  
  162. if exists(Pattern("shop-button.png").similar(0.90),0):
  163. Settings.MoveMouseDelay = 0
  164. FindAndClick(Pattern("shop-button.png").similar(0.90).targetOffset(-898,-6))
  165. else:
  166. ShowTheGameBottomForSmallScreenResolutions()
  167. Settings.MoveMouseDelay = 0
  168. FindAndClick(Pattern("shop-button.png").similar(0.90).targetOffset(-898,-6))
  169.  
  170. Settings.MoveMouseDelay = spd
  171.  
  172. i=0
  173. while i < 2:
  174. i = i + 1
  175. if exists(Pattern("1432967930862.png").similar(0.85),0):
  176. i = 2
  177. else:
  178. if exists(Pattern("shop-button.png").similar(0.90),0):
  179. wheel(Pattern("shop-button.png").similar(0.90).targetOffset(-898,-6),WHEEL_UP,1)
  180. if exists(Pattern("scroll-bar.png").similar(0.95),0):
  181. FindAndClick(Pattern("scroll-bar.png").similar(0.95).targetOffset(1,24))
  182. else:
  183. if exists(Pattern("1432970628554.png").similar(0.90),0):
  184. wheel(Pattern("1432960811209.png").targetOffset(-70,-2),WHEEL_UP,1)
  185. if exists(Pattern("scroll-bar.png").similar(0.95),0):
  186. FindAndClick(Pattern("scroll-bar.png").similar(0.95).targetOffset(1,24))
  187.  
  188. def ShowTheGameBottomForSmallScreenResolutions():
  189. if not exists(Pattern("shop-button.png").similar(0.90),0):
  190. if exists(Pattern("1432970628554.png").similar(0.90),0):
  191. FindAndClick(Pattern("1432960811209.png").targetOffset(-70,-2))
  192. i=0
  193. while i < 2:
  194. i = i + 1
  195. if exists(Pattern("shop-button.png").similar(0.90),0):
  196. i = 2
  197. else:
  198. if exists(Pattern("1432970628554.png").similar(0.90),0):
  199. wheel(Pattern("1432960811209.png").targetOffset(-70,-2),WHEEL_DOWN,1)
  200.  
  201. def Clicker_Heroes():#The Clicker Heroes Automation function.
  202.  
  203. ShowTheGameTopForSmallScreenResolutions()
  204.  
  205. if exists(Pattern("1432970628554.png").similar(0.90),0) and exists(Pattern("1434935522523.png").similar(0.90),0):#Clicker Heroes is on screen
  206. if exists(Pattern("1433101398754.png").similar(0.90),0):
  207. popError("Low quality mode detected. Please click the button for high quality mode for the script to function properly")
  208. wait(10)
  209.  
  210. # keyDown(Key_Z) #Unused for now. I was going to use this to upgrade heroes in increments of 25 but Sikuli OCR is not up to par yet.
  211. if exists(Pattern("1434935407800.png").targetOffset(0,112),0):
  212. print "Relic found at: " + str(int(int(time.time() - Settings.AscendStartTime)/60)) + " Minutes and " + str(int(int(time.time() - Settings.AscendStartTime)-(int(int(time.time() - Settings.AscendStartTime)/60)*60))) + " Seconds"
  213. FindAndClick(Pattern("1434935407800.png").targetOffset(-3,118))
  214. wait(1)
  215. FindAndClick(Pattern("1434935593790.png").similar(0.90).targetOffset(3,-2))
  216.  
  217.  
  218. if Settings.EDR == True and Settings.IfQuickMidasStartHappened == True:
  219. if Settings.EDRDelayCounterIfQuickMidasStartHappened > 0:
  220. Settings.EDRDelayCounterIfQuickMidasStartHappened = Settings.EDRDelayCounterIfQuickMidasStartHappened - 1
  221. else:
  222. Settings.IfQuickMidasStartHappened = False
  223. Settings.EDRDelayCounterIfQuickMidasStartHappened = 0
  224. ShowTheGameTopForSmallScreenResolutions()
  225. ShowTheGameBottomForSmallScreenResolutions()
  226. Settings.MoveMouseDelay = .5
  227. EDR()
  228.  
  229.  
  230. if exists(Pattern("1433042803072.png").similar(0.95),0) and StartPosition == Env.getMouseLocation():#The user has manually ascended. Start the 'I just ascended' loop.
  231. AscendLoop()
  232. else:
  233. if exists("1432960442630.png",0):
  234. if Settings.AscendRequirementsMet == True:
  235. Settings.AscendRequirementsMet = False
  236.  
  237. print 'Can see a clickable. Initiate ascending:'
  238. print time.localtime(time.time())
  239.  
  240. Ascend()
  241. else:
  242. FindAndClick("1432960442630.png")
  243. if StartPosition == Env.getMouseLocation():
  244. if exists(Pattern("1432972961822.png").similar(0.95).targetOffset(41,16),0):#The left edge of a gilded hero
  245. if Settings.IHaveMoreThanTwoGildedHeroes:
  246. BuyStrongestGildedHero()#End-Game players will need to utilize multiple gilded heroes in order to reach their hero of choice more quickly.
  247.  
  248. if Settings.AdditionalBuyAllUpgrades < 1:
  249. Settings.AdditionalBuyAllUpgrades = 12
  250. hover(Location(StartPosition))#Move the mouse back to the original position.
  251. wait(1)
  252. FindAndClick("1432960811209.png")
  253. wheel("1432960811209.png",WHEEL_UP,2) #Scroll up
  254. wheel("1432960811209.png",WHEEL_DOWN,30)
  255. FindAndClick(Pattern("1432961206728.png").similar(0.90),0,False)
  256. ShowTheGameTopForSmallScreenResolutions()
  257. else:
  258. Settings.AdditionalBuyAllUpgrades = Settings.AdditionalBuyAllUpgrades - 1;
  259.  
  260. hover(Location(StartPosition))#Move the mouse back to the original position.
  261. else:
  262. p = getLastMatch().getTarget()#Targets the blue portion of a button. The target may need to be adjusted in the future.
  263. if myRobot.getPixelColor(p.x, p.y).getBlue() > 200:#If the pixel is blue, the button is clickable
  264. if Settings.NoGildedHeroesAvailable == False:#The pixel is blue but we have not yet detected that it is clickable below.
  265. goClick(getLastMatch().getTarget(),KEY_META)
  266. else:
  267. goClick(getLastMatch().getTarget(),KEY_META)
  268. Settings.NoGildedHeroesAvailable = False
  269. wheel(Pattern("1432960811209.png").targetOffset(2,0),WHEEL_UP,1)
  270. wheel("1432960811209.png",WHEEL_DOWN,5)
  271. ShowTheGameTopForSmallScreenResolutions()
  272. hover(Location(StartPosition))
  273. Settings.GildedHeroBelowFrostleafUpgradesPurchased = False
  274. else:#The pixel is not blue
  275. if Settings.NoGildedHeroesAvailable == True:#We have never clicked the gilded hero and we can't yet
  276. BuyBottom2Heroes()
  277. else:#There are no gilded heroes on screen.
  278. if Settings.NoGildedHeroesAvailable == True:
  279. BuyBottom2Heroes()
  280. else:
  281. PositionCH()
  282.  
  283. ShowTheGameTopForSmallScreenResolutions()
  284. Settings.Times=Settings.Times + 1#The following operations could cause a delay so only run them every 4 times the Clicker_Heroes function runs.
  285. if Settings.Times > 3 and StartPosition == Env.getMouseLocation():
  286. Settings.Times = 0
  287. if Settings.TurnProgressionBackOn > 0:
  288. if int(time.time()) > (Settings.ProgressionLastVerified + (Settings.TurnProgressionBackOn * 60)):
  289. Settings.ProgressionLastVerified = int(time.time())
  290. FindAndClick(Pattern("1432961136172.png").similar(0.90),0,False)
  291. if Settings.EDR_ER == True:
  292. if TryToFind(Pattern("1434520013436.png").similar(0.95)):
  293. if Settings.EDR_ER_State == "ER":
  294. if TryToFind(Pattern("1433037474843.png").similar(0.90)):
  295. FindAndClick(Pattern("1434520013436.png").similar(0.95),0,False)
  296. FindAndClick(Pattern("1433037474843.png").similar(0.90),0,False)
  297. Settings.EDR_ER_State = "EDR"
  298. else:
  299. if TryToFind(Pattern("1432961445894.png").similar(0.90)):
  300. EDR()
  301.  
  302. if Settings.NoGildedHeroesAvailable == True:
  303. wheel("1432960811209.png",WHEEL_UP,2)
  304. wait(0.5)
  305. wheel("1432960811209.png",WHEEL_DOWN,20)
  306. hover(Location(StartPosition))#Move the mouse back to the original position.
  307. FindAndClick(Pattern("1432961206728.png").similar(0.90),0,False)
  308. ShowTheGameTopForSmallScreenResolutions()
  309. else:#Don't ascend if we have never seen a gilded hero.
  310. if Settings.GildedHeroBelowFrostleafUpgradesPurchased == False:
  311. if Settings.IHaveMoreThanTwoGildedHeroes == False:
  312. if exists(Pattern("1432972961822.png").similar(0.95).targetOffset(-6,-8),0):
  313. SearchRegion = Region(getLastMatch().getX(),getLastMatch().getY(),460,110)
  314. SearchRegion.highlight(5)
  315. if SearchRegion.exists(Pattern("1433059287778.png").exact(),0):
  316. Settings.GildedHeroBelowFrostleafUpgradesPurchased = True
  317. else:
  318. if FindAndClick(Pattern("1432961206728.png").similar(0.90),0,False) == False:
  319. FindAndClick("1432960811209.png")
  320. wheel("1432960811209.png",WHEEL_UP,20) #Scroll to the top of the heroes list.
  321. wait(1)
  322. wheel("1432960811209.png",WHEEL_DOWN,30)
  323. FindAndClick(Pattern("1432961206728.png").similar(0.90),0,False)
  324. ShowTheGameTopForSmallScreenResolutions()
  325. PositionCH(True)
  326. else:
  327. PositionCH()
  328. else:
  329. try:
  330. wait(2)
  331. FindAndClick("1432960811209.png")
  332. wheel("1432960811209.png",WHEEL_UP,20) #Scroll to the top of the heroes list.
  333. wait(1)
  334. wheel("1432960811209.png",WHEEL_DOWN,30)
  335. FindAndClick(Pattern("1432961206728.png").similar(0.90),0,False)
  336. ShowTheGameTopForSmallScreenResolutions()
  337. except:
  338. return True
  339. else:#We have located a gilded hero and all it's upgrades have been purchased
  340. if Settings.CheckForAscend == True and Settings.EDRTime < int(time.time()):#If the global variable is set to true, check if the current level changes. Ascend when it stays the same for 4 seconds.
  341. if exists(Pattern("1432967930862.png").similar(0.85),0):
  342. MovementRegion = Region(getLastMatch().getX(),getLastMatch().getY(),200,50)#This is the region on my screen where the current level image is.
  343. #MovementRegion.highlight(4)#Turn this on to see where the region is located.
  344. Settings.somethingChanged = False
  345. MovementRegion.onChange(20,ChangeHandler)#Tells the observer to check the defined region for a change. Calls the ChangeHandler function if a change occurs
  346. #The ChangeHandler function only performs one action. It sets the variable Settings.somethingChanged = True
  347. MovementRegion.observe(Settings.TimeToLookForMovementBeforeAscending)#Activates the observer which calls the ChangeHandler function. Observer stays active for 4 seconds.
  348. #4 seconds seems to work well for me but you can tweak this to suit your needs if you find you Ascend too quickly/slowly.
  349.  
  350. if Settings.somethingChanged == False: #If somethingChanged remains false, Nothing changed for the defined time. Time to Ascend!
  351. if Settings.WaitForFishBeforeAscending == True:
  352. Settings.AscendRequirementsMet = True
  353.  
  354. print 'Ready for ascending:'
  355. print time.localtime(time.time())
  356.  
  357. else:
  358. Ascend()
  359.  
  360. # keyUp(Key_Z)
  361. return True #the clicker heroes logo is on screen
  362. else:
  363. return False#the clicker heroes logo is not on screen
  364.  
  365. def BuyStrongestGildedHero(TimesToClick = 1):
  366. ShowTheGameTopForSmallScreenResolutions()
  367. if exists(Pattern("1432972961822.png").similar(0.95).targetOffset(41,16)):#As long as a single 'Buy this hero' button is on the screen, Find all occurances of it.
  368. #try:
  369. if True:
  370. FA = findAll(Pattern("1432972961822.png").similar(0.95).targetOffset(41,16))
  371. LowestY=0
  372. SecondLowestY=0
  373. LowestFound = getLastMatch()
  374. AbsoluteLowestY = 0
  375. AbsoluteLowest = getLastMatch()
  376. SecondLowest = LowestFound
  377. StrongestIsNotPurchasable = False
  378. for i in FA:
  379. if LowestY < i.getY():
  380. p = i.getTarget()
  381. SearchRegion = Region(p.x - 5,p.y - 10,125,60)
  382.  
  383. if SearchRegion.exists(Pattern("1433201935503.png").similar(0.95),0):#Check if the lowest gilded hero found has a clickable hire button
  384. #p = i.getTarget()
  385. if myRobot.getPixelColor(i.getTarget().x, i.getTarget().y).getBlue() > 200:#If the pixel is blue, the button is clickable
  386. SecondLowestY = LowestY
  387. LowestY = i.getY()
  388. SecondLowest = LowestFound
  389. LowestFound = i
  390. else:
  391. Settings.GildedHeroBelowFrostleafUpgradesPurchased = False
  392. StrongestIsNotPurchasable = True
  393. else:
  394. p = i.getTarget()
  395. if myRobot.getPixelColor(p.x, p.y).getBlue() > 200:#If the pixel is blue, the button is clickable
  396. SecondLowestY = LowestY
  397. LowestY = i.getY()
  398. SecondLowest = LowestFound
  399. LowestFound = i
  400. else:
  401. if SecondLowestY < i.getY():
  402. p = i.getTarget()
  403. if myRobot.getPixelColor(p.x, p.y).getBlue() > 200:#If the pixel is blue, the button is clickable
  404. SecondLowestY = i.getY()
  405. SecondLowest = i
  406. if AbsoluteLowestY < i.getY():
  407. AbsoluteLowestY = i.getY()
  408. AbsoluteLowest = i
  409.  
  410. if StrongestIsNotPurchasable:
  411. #Click the two above it.
  412. if LowestY > 0:
  413. i=0
  414. while i < TimesToClick:
  415. click(LowestFound,KEY_META)#Click the bottom purchasable gilded buy hero button.
  416. i = i + 1
  417.  
  418. Settings.NoGildedHeroesAvailable = False
  419.  
  420. if SecondLowestY > 0:
  421. click(SecondLowest,KEY_META)#Click the second lowest purchasable gilded buy hero button.
  422. if Settings.DeepRunInsteadOfAscension == False:
  423. hover(Location(StartPosition))#Move the mouse back to the original position.
  424. else:
  425. hover(Location(Settings.DeepRunStartPositionTemporary))
  426. else:
  427. p = AbsoluteLowest.getTarget()
  428. if myRobot.getPixelColor(p.x, p.y).getBlue() > 200:#If the pixel is blue, the button is clickable
  429. Settings.NoGildedHeroesAvailable = False
  430. i=0
  431. while i < TimesToClick:
  432. click(AbsoluteLowest,KEY_META)#Click the bottom purchasable gilded buy hero button 3 times.
  433. i=i+1
  434.  
  435. click(AbsoluteLowest,KEY_META)
  436.  
  437. if Settings.AdditionalBuyAllUpgrades == (Settings.AdditionalBuyAllUpgrades - 2):
  438. click(AbsoluteLowest,KEY_META)
  439.  
  440. if Settings.DeepRunInsteadOfAscension == False:
  441. hover(Location(StartPosition))#Move the mouse back to the original position.
  442. else:
  443. hover(Location(Settings.DeepRunStartPositionTemporary))
  444. SearchRegion = Region(AbsoluteLowest.getTarget().x,AbsoluteLowest.getTarget().y,470,80)
  445. if SearchRegion.exists(Pattern("1433830152654.png").similar(0.90),0) or SearchRegion.exists(Pattern("1435270411325.png").similar(0.90),0):#The strongest found hero does not have all his upgrades yet.
  446. Settings.GildedHeroBelowFrostleafUpgradesPurchased = True
  447. else:
  448. Settings.GildedHeroBelowFrostleafUpgradesPurchased = False
  449. return True
  450. # except:
  451. #
  452. # popError("Error while trying to buy strongest hero!")
  453. # return False
  454. else:
  455. ShowTheGameBottomForSmallScreenResolutions()
  456. BuyBottom2Heroes()
  457.  
  458.  
  459. def ChangeHandler(event):
  460. Settings.somethingChanged = True
  461. event.Region.stopObserver()
  462.  
  463. def PositionCH(BottomUp = False): #Scrolls down until a gilded hero is on screen
  464. ShowTheGameTopForSmallScreenResolutions()
  465. if StartPosition == Env.getMouseLocation():
  466. if Settings.StartGildedSearchFromBottom == False:
  467. wheel(Pattern("1432960811209.png").targetOffset(-70,-2),WHEEL_UP,20)#Scroll web browser to top of page
  468. FindAndClick("1432960811209.png")
  469. wheel("1432960811209.png",WHEEL_UP,20) #Scroll to the top of the heroes list.
  470. else:
  471. FindAndClick("1432960811209.png")
  472. wheel("1432960811209.png",WHEEL_DOWN,20) #Scroll to the top of the heroes list.
  473. Settings.NoGildedHeroesAvailable = False
  474. i=0
  475. while i < 20:
  476. if TryToFind(Pattern("1432972961822.png").similar(0.95)) == False:
  477. if Settings.StartGildedSearchFromBottom == False:
  478. if exists(Pattern("1432961206728.png").similar(0.90),0):
  479. i=19
  480. ShowTheGameTopForSmallScreenResolutions()
  481. if i > 0:
  482. if exists("1432960811209.png"):
  483. wheel("1432960811209.png",WHEEL_DOWN,1)
  484. else:
  485. if exists(Pattern("top-scroll.png").similar(0.85).targetOffset(-18,1)):
  486. wheel(Pattern("top-scroll.png").similar(0.85).targetOffset(-18,1),WHEEL_DOWN,1)
  487. else:
  488. if exists(Pattern("bottom-scroll.png").similar(0.85).targetOffset(-18,-1)):
  489. wheel(Pattern("bottom-scroll.png").similar(0.85).targetOffset(-18,-1),WHEEL_DOWN,1)
  490. else:
  491. if exists(Pattern("1433200321414.png").similar(0.95),0):
  492. i=19
  493. ShowTheGameTopForSmallScreenResolutions()
  494. if i > 0:
  495. if exists("1432960811209.png"):
  496. wheel("1432960811209.png",WHEEL_UP,1)
  497. else:
  498. if exists(Pattern("top-scroll.png").similar(0.85).targetOffset(-18,1)):
  499. wheel(Pattern("top-scroll.png").similar(0.85).targetOffset(-18,1),WHEEL_UP,1)
  500. else:
  501. if exists(Pattern("bottom-scroll.png").similar(0.85).targetOffset(-18,-1)):
  502. wheel(Pattern("bottom-scroll.png").similar(0.85).targetOffset(-18,-1),WHEEL_UP,1)
  503. wait(.5)
  504. i=i+1
  505. if i > 20:#No gilded heroes are available. Upgrade bottom hero instead.
  506. Settings.NoGildedHeroesAvailable = True
  507. Settings.GildedHeroBelowFrostleafUpgradesPurchased = False
  508. else:
  509. i=20
  510. ShowTheGameTopForSmallScreenResolutions()
  511. hover(Location(StartPosition))#Move the mouse back to the original position.
  512. if exists(Pattern("1432972961822.png").similar(0.95).targetOffset(41,16),0):#The left edge of a gilded hero
  513. #If we make it here, we have successfully located a gilded hero. This will make ther script click it a bunch of times without running through the main loop.
  514. #The purpose being to get up to speed more quickly before we start executing the 'Should we ascend' check.
  515. p = getLastMatch().getTarget()#Targets the blue portion of a button. The target may need to be adjusted in the future.
  516. i=0
  517. while myRobot.getPixelColor(p.x, p.y).getBlue() > 200 and i<20:#If the pixel is blue, the button is clickable
  518. goClick(getLastMatch().getTarget(),KEY_META)
  519. hover(Location(StartPosition))#Move the mouse back to the original position.
  520. wait(.1)
  521. i=i+1
  522. else:#No gilded heroes found. If we started from the bottom, go back to the bottom.
  523. if Settings.StartGildedSearchFromBottom:
  524. wheel("1432960811209.png",WHEEL_DOWN,30) #Scroll to the top of the heroes list.
  525. ShowTheGameTopForSmallScreenResolutions()
  526. Settings.NoGildedHeroesAvailable = True
  527. hover(Location(StartPosition))#Move the mouse back to the original position.
  528.  
  529. def BuyBottom2Heroes():#As the name says, This function buys the lowest 2 heroes on the screen at the moment.
  530. if exists(Pattern("1432963303747.png").similar(0.65)):#As long as a single 'Buy this hero' button is on the screen, Find all occurances of it.
  531. try:
  532. FA = findAll(Pattern("1432963303747.png").similar(0.65).targetOffset(0,7))
  533. LowestY=0
  534. LowestFound = getLastMatch()
  535. SecondLowest = LowestFound
  536. for i in FA:#Go through each occurance of the 'Buy this hero' button on screen and identify the lowest and second lowest.
  537. if LowestY < i.getY():
  538. LowestY = i.getY()
  539. SecondLowest = LowestFound
  540. LowestFound = i
  541. click(LowestFound,KEY_META)#Click the bottom buy hero button. Sometimes this screws up and clicks one that is greyed out which is why we have the next line as a backup.
  542. click(SecondLowest,KEY_META)#Click the second lowest buy hero button.
  543. if Settings.DeepRunInsteadOfAscension == False:
  544. hover(Location(StartPosition))#Move the mouse back to the original position.
  545. else:
  546. hover(Location(Settings.DeepRunStartPositionTemporary))
  547. return True
  548. except:
  549. return False
  550.  
  551. def BuyAllHeroes200Times(ScrollSpeed = 2):
  552. MouseSpeed = Settings.MoveMouseDelay
  553. if Settings.BuyAllHeroesFaster == True:
  554. Settings.MoveMouseDelay = 0
  555. if Settings.MidasStart == True:
  556. Settings.MoveMouseDelay = 0
  557. #AscendLoopBool = True
  558. #while AscendLoopBool == True:
  559. ShowTheGameTopForSmallScreenResolutions()
  560. wheel(Pattern("1432960811209.png").targetOffset(-70,-2),WHEEL_UP,20)#Scroll web browser to top of page
  561. wheel("1432960811209.png",WHEEL_UP,20)#Scroll to the top of the heroes list.
  562. for i in range(0,7):#Perform the following 8 times:
  563. if exists(Pattern("1432963303747.png").similar(0.65)):#As long as one 'Buy hero' button is on screen at this time,
  564. FA = findAll(Pattern("1432963303747.png").similar(0.65).targetOffset(1,4))#Find all the 'Buy Hero' buttons and ctrl+click each one of them twice.
  565. for j in FA:
  566. click(j,KEY_META)
  567. click(j,KEY_META)
  568. if Settings.MidasStart == True and Settings.TryToSpeedUpMidasStart == True:
  569. if Settings.IfQuickMidasStartHappened == False:
  570. if exists(Pattern("midas-golden-clicks-skills.png").similar(0.95).targetOffset(70,-1),0):
  571. QuickMidasStart()
  572. Settings.MoveMouseDelay = MouseSpeed
  573. if Settings.BuyAllHeroesFaster == True:
  574. Settings.MoveMouseDelay = 0
  575. if exists("1432960811209.png"):
  576. wheel("1432960811209.png",WHEEL_DOWN,ScrollSpeed)#Scroll down 2 times and repeat.
  577. else:
  578. if exists(Pattern("top-scroll.png").similar(0.85).targetOffset(-18,1)):
  579. wheel(Pattern("top-scroll.png").similar(0.85).targetOffset(-18,1),WHEEL_DOWN,ScrollSpeed)#Scroll down 2 times and repeat.
  580. else:
  581. if exists(Pattern("bottom-scroll.png").similar(0.85).targetOffset(-18,-1)):
  582. wheel(Pattern("bottom-scroll.png").similar(0.85).targetOffset(-18,-1),WHEEL_DOWN,ScrollSpeed)#Scroll down 2 times and repeat.
  583.  
  584. wait(Settings.WaitForMoney + .01)
  585. Settings.MoveMouseDelay = MouseSpeed
  586.  
  587. def LookForSkippedHeroes():
  588. try:
  589. ShowTheGameTopForSmallScreenResolutions()
  590. wheel("1432960811209.png",WHEEL_UP,20)#Scroll to the top of the heroes list.
  591. wheel("1432960811209.png",WHEEL_DOWN,1)
  592. for i in range(0,8):#Perform the following 9 times:
  593. if exists(Pattern("1432963303747.png").similar(0.65)):#As long as one 'Buy hero' button is on screen at this time,
  594. FA = findAll(Pattern("1432963303747.png").similar(0.65).targetOffset(-47,3))#Find all the 'Buy Hero' buttons and ctrl+click each one of them twice.
  595. for j in FA:
  596. p = j.getTarget()
  597. SearchRegion = Region(p.x - 5,p.y - 10,125,60)
  598. if SearchRegion.exists(Pattern("1433201935503.png").similar(0.95),0):#Check if the lowest gilded hero found has a clickable hire button
  599. click(j,KEY_META)
  600. click(j,KEY_META)
  601. if exists(Pattern("1432961206728.png").similar(0.90),0):
  602. FindAndClick(Pattern("1432961206728.png").similar(0.95),0,False)
  603. i=20
  604.  
  605. if exists("1432960811209.png"):
  606. wheel("1432960811209.png",WHEEL_DOWN,2)#Scroll down 2 times and repeat.
  607. else:
  608. if exists(Pattern("top-scroll.png").similar(0.85).targetOffset(-18,1)):
  609. wheel(Pattern("top-scroll.png").similar(0.85).targetOffset(-18,1),WHEEL_DOWN,2)#Scroll down 2 times and repeat.
  610. else:
  611. if exists(Pattern("bottom-scroll.png").similar(0.85).targetOffset(-18,-1)):
  612. wheel(Pattern("bottom-scroll.png").similar(0.85).targetOffset(-18,-1),WHEEL_DOWN,2)#Scroll down 2 times and repeat.
  613. return True
  614. except:
  615. return False
  616.  
  617. def Ascend():#Our Ascension automation routine
  618. Settings.IfQuickMidasStartHappened = False
  619. ShowTheGameTopForSmallScreenResolutions()
  620. if Settings.ActivateAllSkillsWithEnergizedLuckyStrikesBeforeAscension == True and Settings.DeepRunInsteadOfAscension == False:
  621. ShowTheGameBottomForSmallScreenResolutions()
  622. if exists(Pattern("1432970424925.png").targetOffset(-238,-2),0):
  623. click(getLastMatch(),0)
  624. else:
  625. if exists(Pattern("1432961136172.png").similar(0.90).targetOffset(-238,-1),0):
  626. click(getLastMatch(),0)
  627. else:
  628. click(Location(1273, 631),0)
  629. FindAndClick(Pattern("skill-lucky-strikes.png").similar(0.90).targetOffset(0,52),0,False) #Target Offset changed for Metal Detector
  630. FindAndClick(Pattern("skill-gold-clicks.png").similar(0.90),0,False)
  631. FindAndClick(Pattern("skill-energize.png").similar(0.95),0,False)
  632. FindAndClick(Pattern("skill-lucky-strikes.png").similar(0.90),0,False)
  633. FindAndClick(Pattern("skill-powersurge.png").similar(0.90).targetOffset(0,-52),0,False) #Target Offset changed for Clickstorm
  634. FindAndClick(Pattern("skill-powersurge.png").similar(0.90),0,False)
  635. FindAndClick(Pattern("skill-super-clicks.png").similar(0.90),0,False)
  636.  
  637. if exists(Pattern("top-scroll.png").similar(0.85).targetOffset(-18,1)):
  638. wheel(Pattern("top-scroll.png").similar(0.85).targetOffset(-18,1),WHEEL_DOWN,2)
  639. else:
  640. if exists(Pattern("bottom-scroll.png").similar(0.85).targetOffset(-18,-1)):
  641. wheel(Pattern("bottom-scroll.png").similar(0.85).targetOffset(-18,-1),WHEEL_DOWN,2)
  642.  
  643. if exists(Pattern("top-scroll.png").similar(0.85).targetOffset(-18,1)):
  644. wheel(Pattern("top-scroll.png").similar(0.85).targetOffset(-18,1),WHEEL_UP,1)
  645. else:
  646. if exists(Pattern("bottom-scroll.png").similar(0.85).targetOffset(-18,-1)):
  647. wheel(Pattern("bottom-scroll.png").similar(0.85).targetOffset(-18,-1),WHEEL_UP,1)
  648. hover(Location(StartPosition))#Move the mouse back to the original position.
  649. BuyStrongestGildedHero(4)
  650. hover(Location(StartPosition))#Move the mouse back to the original position.
  651. for i in range(0,10):
  652. wait(3)
  653. FindAndClick(Pattern("skill-energize.png").similar(0.95),0,False)
  654. FindAndClick(Pattern("skill-lucky-strikes.png").similar(0.90),0,False)
  655. FindAndClick(Pattern("skill-super-clicks.png").similar(0.90),0,False)
  656. BuyStrongestGildedHero(2)
  657. hover(Location(StartPosition))#Move the mouse back to the original position.
  658.  
  659. ShowTheGameTopForSmallScreenResolutions()
  660.  
  661. if Settings.DeepRunInsteadOfAscension == False:
  662. FindAndClick(Pattern("1437791962292.png").similar(0.95),0,False)
  663.  
  664. if exists(Pattern("1436958313642.png").similar(0.95).targetOffset(32,-4),0):
  665. p = getLastMatch().getTarget()
  666. print "Relic Color: " + str(myRobot.getPixelColor(p.x, p.y))
  667. hover(getLastMatch())
  668. if Settings.StopOnGoodRelic == True:
  669. if TryToFind(Pattern("1438407556096.png").exact()) or TryToFind(Pattern("1438407852229.png").exact()):
  670. print "Found a relic that matches the search criteria!"
  671. StopTheScript()#This function does not exist and will cause an error when it reaches this line
  672. hover(Location(StartPosition))
  673.  
  674. wait(4)
  675. if TryToFind(Pattern("1434944566569.png").exact()):
  676. FindAndClick(Pattern("1434944566569.png").exact(),0,False)
  677. wait(3)
  678. FindAndClick(Pattern("1434944650961.png").exact(),0,False)
  679. wait(.5)
  680. FindAndClick(Pattern("1434944701134.png").similar(0.95),0,False)
  681. wait(1)
  682. if exists("1432960811209.png",0):
  683. wheel("1432960811209.png",WHEEL_DOWN,5)#Scroll down 8 times so Amenhotep is on screen
  684. else:
  685. if exists(Pattern("top-scroll.png").similar(0.85).targetOffset(-18,1)):
  686. wheel(Pattern("top-scroll.png").similar(0.85).targetOffset(-18,1),WHEEL_DOWN,5)
  687. wait(1)
  688. if FindAndClick("1432960838309.png",0,False):#Click the ascend button.
  689. wait(3)
  690. FindAndClick(Pattern("1432960908494.png").similar(0.95),0,False) #Clicks yes to Ascend now.
  691. wait(3)
  692. AscendLoop() #Calls the AscendLoop function which performs all of the 'I just ascended' actions.
  693. else:#Sometimes after scrolling down the ascend button is not on screen so we scroll down a little more and try again.
  694. TryAgain=0
  695. while TryAgain <10:
  696. TryAgain = TryAgain + 1
  697. if exists("1432960811209.png",0):
  698. wheel("1432960811209.png",WHEEL_DOWN,1)
  699. else:
  700. if exists(Pattern("top-scroll.png").similar(0.85).targetOffset(-18,1)):
  701. wheel(Pattern("top-scroll.png").similar(0.85).targetOffset(-18,1),WHEEL_DOWN,1)
  702. else:
  703. if exists(Pattern("bottom-scroll.png").similar(0.85).targetOffset(-18,-1)):
  704. wheel(Pattern("bottom-scroll.png").similar(0.85).targetOffset(-18,-1),WHEEL_DOWN,1)
  705. wait(1)
  706. if FindAndClick(Pattern("1432960838309.png").similar(0.80),0,False):
  707. TryAgain=20
  708. wait(1)
  709. FindAndClick(Pattern("1432960908494.png").similar(0.95),0,False)
  710. AscendLoop()
  711. if TryAgain == 10:
  712. BuyAllHeroes200Times(1)
  713. else:
  714. DeepRunMode()
  715.  
  716.  
  717. def AscendLoop():#This Function performs all of the 'I just ascended' Actions.
  718. print "Ascended in: " + str(int(int(time.time() - Settings.AscendStartTime)/60)) + " Minutes and " + str(int(int(time.time() - Settings.AscendStartTime)-(int(int(time.time() - Settings.AscendStartTime)/60)*60))) + " Seconds"
  719. Settings.AscendStartTime = time.time()
  720. ShowTheGameTopForSmallScreenResolutions()
  721. #1.It will Go to Level 19, and click the monster 8 times
  722. #2.scroll to the bottom of the heroes list and ctrl+click the bottom two heroes.
  723. #3.It will then Click the 'Advance 2 levels' image 8 times.
  724. #4.It will repeat steps 2 and 3 until all of frostleaf's upgrades are available. If you hit level 114 before this happens, it turns on 'Progression Mode'
  725. #5.Scroll through the list of heroes ctrl+clicking each one at least 2 times. This should ensure at least 200 levels each. Often more but this doesn't effect anything.
  726. #6.Click the 'Buy Available Upgrades' button and activate an energized dark ritual.
  727. #7.Resumes normal operation.
  728. Settings.MoveMouseDelay = 0 #Clicking has a default delay of .5 seconds. This removes that so this part goes faster.
  729.  
  730. Settings.IfQuickMidasStartHappened = False
  731.  
  732. if Settings.WaitForFishBeforeAscending == True and exists("1432960442630.png",0):
  733. FindAndClick("1432960442630.png",0,False)
  734. wait(1)
  735. CollectCoins()
  736. wait(1)
  737. FindAndClick(Pattern("1432961136172.png").similar(0.90),0,False)#Enable progression mode now.
  738. Settings.IfQuickMidasStartHappened = True
  739. Settings.EDRDelayCounterIfQuickMidasStartHappened = Settings.EDRDelayValueIfQuickMidasStartHappened
  740. else:
  741. if Settings.MidasStart == True and exists("1432960442630.png",0):
  742. FindAndClick("1432960442630.png",0,False)
  743. wait(1)
  744. CollectCoins()
  745. wait(2)
  746. FindAndClick(Pattern("1432961136172.png").similar(0.90),0,False)#Enable progression mode now.
  747. Settings.IfQuickMidasStartHappened = True
  748. Settings.EDRDelayCounterIfQuickMidasStartHappened = Settings.EDRDelayValueIfQuickMidasStartHappened
  749.  
  750. if Settings.IHaveIris == False:
  751. FindAndClick(Pattern("1432961136172.png").similar(0.90),0,False)#Enable progression mode now.
  752. else:
  753. if Settings.IfQuickMidasStartHappened == False:
  754. for i in range(0,9):#Perform the following action 10 times:
  755. FindAndClick(Pattern("1432965832101.png").similar(0.90).targetOffset(-59,-1),0,False)#Click on the 'Advance 2 levels' button. The point we are clicking is to the left of this button.
  756.  
  757.  
  758. if Settings.IfQuickMidasStartHappened == False:
  759. #for i in range(0,20):#Click on the monster 21 times to get a good initial base of money.
  760. if exists(Pattern("1432970424925.png").targetOffset(-180,-2),0):#clicks a ways to the left of this button which should be over the monster.
  761. click(getLastMatch(),0)
  762. else:
  763. if exists(Pattern("1432961136172.png").similar(0.90).targetOffset(-107,-1),0):
  764. click(getLastMatch(),0)
  765. else:
  766. click(Location(1273, 631),0)
  767. for i in range(0, 18):
  768. mouseDown(Button.LEFT)
  769. mouseUp()
  770.  
  771. AscendLoopBool = True
  772.  
  773. if Settings.IfQuickMidasStartHappened == True:
  774. AscendLoopBool = False
  775.  
  776. Loopcount = 0
  777. FoundFrostLeaf = False
  778. while AscendLoopBool == True:
  779. if Settings.AlternativeFrostLeafSearch == False:
  780. ShowTheGameTopForSmallScreenResolutions()
  781. wheel("1432960811209.png",WHEEL_DOWN,15)
  782. else:
  783. if FoundFrostLeaf == False:
  784. ShowTheGameTopForSmallScreenResolutions()
  785. wheel("1432960811209.png",WHEEL_UP,1)
  786. wheel("1432960811209.png",WHEEL_DOWN,4)
  787. try:
  788. if FoundFrostLeaf == False:
  789. if exists(Pattern("1432963303747.png").similar(0.65)):#As long as a single 'Buy this hero' button is on the screen, Find all occurances of it.
  790. FA = findAll(Pattern("1432963303747.png").similar(0.65).targetOffset(0,7))
  791. LowestY=0
  792. LowestFound = getLastMatch()
  793. SecondLowest = LowestFound
  794. for i in FA:#Go through each occurance of the 'Buy this hero' button on screen and identify the lowest and second lowest.
  795. if LowestY < i.getY():
  796. LowestY = i.getY()
  797. SecondLowest = LowestFound
  798. LowestFound = i
  799. click(LowestFound,KEY_META)#Click the bottom buy hero button. Sometimes this screws up and clicks one that is greyed out which is why we have the next line as a backup.
  800. click(LowestFound,KEY_META)#Click the bottom buy hero button. Sometimes this screws up and clicks one that is greyed out which is why we have the next line as a backup.
  801. click(SecondLowest,KEY_META)#Click the second lowest buy hero button.
  802. click(SecondLowest,KEY_META)#Click the second lowest buy hero button.
  803. hover(Location(StartPosition))#Move the mouse back to the original position.
  804. else:
  805. FindAndClick("1432960442630.png")
  806. else:
  807. if exists(Pattern("1432963303747.png").similar(0.65)):#As long as a single 'Buy this hero' button is on the screen, Find all occurances of it.
  808. FA = findAll(Pattern("1432963303747.png").similar(0.65).targetOffset(0,7))
  809. for j in FA:#Go through each occurance of the 'Buy this hero' button on screen and identify the lowest and second lowest.
  810. click(j,KEY_META)
  811. hover(Location(StartPosition))#Move the mouse back to the original position.
  812. else:
  813. FindAndClick("1432960442630.png")
  814. except:
  815. wait(1)
  816. if exists("1433044030019.png"):#Once FrostLeaf's entire skill set is available, we are probably advanced enough to move on.
  817. AscendLoopBool = False
  818. FoundFrostLeaf = False
  819. FindAndClick(Pattern("1432961136172.png").similar(0.90),0,False)#Enable progression mode now.
  820. else:
  821. if Settings.AlternativeFrostLeafSearch == True and FoundFrostLeaf == False:
  822. if exists(Pattern("frostleaf.png").similar(0.95)) or exists(Pattern("frostleaf-gilded.png").similar(0.95)):
  823. FoundFrostLeaf = True
  824. if Settings.IHaveIris == True and AscendLoopBool == True:
  825. ShowTheGameTopForSmallScreenResolutions()
  826. for i in range(0,Settings.AscendNextLevelClicks): #Click the 'Advance 2 levels' button Settings.AscendNextLevelClicks times. This variable is set at the top of the script
  827. FindAndClick(Pattern("1432965832101.png").similar(0.90).targetOffset(-59,-1),0,False)#ClickAdvance 2 levels button location
  828.  
  829. if Loopcount > 10:
  830. FindAndClick("1432960442630.png")
  831.  
  832. if Settings.MidasStart == True and exists("1432960442630.png",0):
  833. FindAndClick("1432960442630.png",0,False)
  834. wait(1)
  835. CollectCoins()
  836. wait(2)
  837. AscendLoopBool = False
  838. FindAndClick(Pattern("1432961136172.png").similar(0.90),0,False)#Enable progression mode now.
  839. Settings.IfQuickMidasStartHappened = True
  840. Settings.EDRDelayCounterIfQuickMidasStartHappened = Settings.EDRDelayValueIfQuickMidasStartHappened
  841.  
  842. # wait(Settings.WaitForMoney)
  843. Loopcount = Loopcount + 1
  844.  
  845. BuyAllHeroes200Times()
  846. ShowTheGameTopForSmallScreenResolutions()
  847. wheel("1432960811209.png",WHEEL_DOWN,15) #Scroll to the bottom of the heroes list.
  848. wait(1)
  849. FindAndClick(Pattern("1432961136172.png").similar(0.90),0,False)#If for some reason progression mode is off, Enable progression mode now.
  850. if FindAndClick(Pattern("1432961206728.png").similar(0.90),0,False) == False:#Click 'Buy available upgrades'! This should complete your ascension and we can resume normal operation
  851. #We must have not seen the button. Lets try to fix this.
  852. ShowTheGameTopForSmallScreenResolutions()
  853. wheel("1432960811209.png",WHEEL_UP,2)
  854. wait(.5)
  855. wheel("1432960811209.png",WHEEL_DOWN,15)
  856. wait(.5)
  857. FindAndClick(Pattern("1432961206728.png").similar(0.95),0,False)
  858. wait(1)
  859.  
  860. if Settings.SomeHeroesGetSkipped == True or TryToFind(Pattern("1438450514368.png").exact()):
  861. LookForSkippedHeroes()
  862. wait(5)
  863. ShowTheGameTopForSmallScreenResolutions()
  864. BuyStrongestGildedHero(10)
  865. else:
  866. ShowTheGameTopForSmallScreenResolutions()
  867. BuyStrongestGildedHero(10)
  868.  
  869. Settings.MoveMouseDelay = .5 #Set the MouseMoveDelay back to the default. The delay is usually useful.
  870.  
  871. #At this point in the progression, we are doing enough damage that even with the 1 minute non-idle, we still level at maximum speed.
  872. ShowTheGameTopForSmallScreenResolutions()
  873. ShowTheGameBottomForSmallScreenResolutions()
  874.  
  875. wait(1)
  876. Settings.MoveMouseDelay = .5
  877. if Settings.MidasStart == True and exists("1432960442630.png",0):
  878. FindAndClick("1432960442630.png")
  879. wait(1)
  880. CollectCoins()
  881. wait(2)
  882. FindAndClick(Pattern("1432961136172.png").similar(0.90),0,False)#Enable progression mode now.
  883. else:
  884. if Settings.MidasStart == True and Settings.WaitForFishBeforeAscending == False:
  885. if Settings.IfQuickMidasStartHappened == False:
  886. #Midas start
  887. Settings.MoveMouseDelay = 0.2
  888. if exists(Pattern("1432970424925.png").targetOffset(-180,-2),0):#clicks a ways to the left of this button which should be over the monster.
  889. click(getLastMatch(),0)
  890. else:
  891. if exists(Pattern("1432961136172.png").similar(0.90).targetOffset(-107,-1),0):
  892. click(getLastMatch(),0)
  893. else:
  894. click(Location(1273, 631),0)
  895. FindAndClick(Pattern("skill-powersurge.png").similar(0.90),0,False)
  896. FindAndClick(Pattern("skill-lucky-strikes.png").similar(0.90).targetOffset(0,52),0,False) #Target Offset changed for Metal Detector
  897. FindAndClick(Pattern("skill-lucky-strikes.png").similar(0.90),0,False)
  898. FindAndClick(Pattern("skill-gold-clicks.png").similar(0.90),0,False)
  899. Settings.MoveMouseDelay = 0
  900. wait(1)
  901. #for i in range(0,19):#Click on the monster 20 times to get money with Golden Clicks
  902. if exists(Pattern("1432970424925.png").targetOffset(-180,-2),0):#clicks a ways to the left of this button which should be over the monster.
  903. click(getLastMatch(),0)
  904. else:
  905. if exists(Pattern("1432961136172.png").similar(0.90).targetOffset(-107,-1),0):
  906. click(getLastMatch(),0)
  907. else:
  908. click(Location(1273, 631),0)
  909. for i in range(0, 18):
  910. mouseDown(Button.LEFT)
  911. mouseUp()
  912. wait(4)
  913.  
  914. if Settings.EDR == True and Settings.IfQuickMidasStartHappened == False:
  915. EDR()
  916.  
  917. Settings.EDRTime = int(time.time()) + 120
  918.  
  919. if Settings.MidasStart == True and Settings.WaitForFishBeforeAscending == False:
  920. ShowTheGameTopForSmallScreenResolutions()
  921. Settings.MoveMouseDelay = 0
  922. wait(1)
  923. wheel("1432960811209.png",WHEEL_UP,2)
  924. wait(.5)
  925. wheel("1432960811209.png",WHEEL_DOWN,15)
  926. wait(.5)
  927. BuyBottom2Heroes()
  928. BuyBottom2Heroes()
  929. BuyBottom2Heroes()
  930. if FindAndClick(Pattern("1432961206728.png").similar(0.90),0,False) == False:#Click 'Buy available upgrades'! This should complete your ascension and we can resume normal operation
  931. #We must have not seen the button. Lets try to fix this.
  932. ShowTheGameTopForSmallScreenResolutions()
  933. wheel("1432960811209.png",WHEEL_UP,2)
  934. wait(.5)
  935. wheel("1432960811209.png",WHEEL_DOWN,15)
  936. wait(.5)
  937. FindAndClick(Pattern("1432961206728.png").similar(0.95),0,False)
  938. else:
  939. Settings.MoveMouseDelay = 0
  940. wait(1)
  941. ShowTheGameTopForSmallScreenResolutions()
  942. wheel("1432960811209.png",WHEEL_UP,2)
  943. wait(.5)
  944. wheel("1432960811209.png",WHEEL_DOWN,15)
  945. wait(.5)
  946. BuyBottom2Heroes()
  947. if FindAndClick(Pattern("1432961206728.png").similar(0.90),0,False) == False:#Click 'Buy available upgrades'! This should complete your ascension and we can resume normal operation
  948. #We must have not seen the button. Lets try to fix this.
  949. ShowTheGameTopForSmallScreenResolutions()
  950. wheel("1432960811209.png",WHEEL_UP,2)
  951. wait(.5)
  952. wheel("1432960811209.png",WHEEL_DOWN,15)
  953. wait(.5)
  954. FindAndClick(Pattern("1432961206728.png").similar(0.95),0,False)
  955.  
  956. Settings.MoveMouseDelay = .5
  957.  
  958. def EDR():
  959. if Settings.ActivatePowersurgeAndMetalDetectorInAdditionToEDR == True and Settings.EDR_ER_State == "NONE":
  960. FindAndClick(Pattern("skill-powersurge.png").similar(0.90),0,False)
  961. FindAndClick(Pattern("skill-lucky-strikes.png").similar(0.90).targetOffset(0,52),0,False) #Target Offset changed for Metal Detector
  962. FindAndClick(Pattern("1434520013436.png").similar(0.95),0,False)#Purchase an energized dark ritual once.
  963. FindAndClick(Pattern("1432961445894.png").similar(0.90),0,False)
  964. FindAndClick(Pattern("1433037474843.png").similar(0.90),0,False)
  965. Settings.EDR_ER_State = "ER"
  966.  
  967. def QuickMidasStart(): #Experimental. Currently it's not used. (If possible, it would speed up Midas start that happens if Settings.MidasStart = True)
  968. Settings.IfQuickMidasStartHappened = True
  969. Settings.EDRDelayCounterIfQuickMidasStartHappened = Settings.EDRDelayValueIfQuickMidasStartHappened
  970. Settings.MoveMouseDelay = 0.2
  971. if exists(Pattern("1432970424925.png").targetOffset(-180,-2),0):#clicks a ways to the left of this button which should be over the monster.
  972. click(getLastMatch(),0)
  973. else:
  974. if exists(Pattern("1432961136172.png").similar(0.90).targetOffset(-107,-1),0):
  975. click(getLastMatch(),0)
  976. else:
  977. click(Location(1273, 631),0)
  978. if exists(Pattern("midas-golden-clicks-skills.png").targetOffset(70,-1),0) and Settings.MidasStart == True:
  979. FindAndClick(Pattern("midas-golden-clicks-skills.png").targetOffset(70,-1),0,False)
  980. wait(1)
  981. FindAndClick(Pattern("skill-gold-clicks.png").similar(0.90),0,False)
  982. Settings.MoveMouseDelay = 0
  983. wait(1)
  984. #for i in range(0,19):#Click on the monster 20 times to get money with Golden Clicks
  985. if exists(Pattern("1432970424925.png").targetOffset(-180,-2),0):#clicks a ways to the left of this button which should be over the monster.
  986. click(getLastMatch(),0)
  987. else:
  988. if exists(Pattern("1432961136172.png").similar(0.90).targetOffset(-107,-1),0):
  989. click(getLastMatch(),0)
  990. else:
  991. click(Location(1273, 631),0)
  992. for i in range(0, 18):
  993. mouseDown(Button.LEFT)
  994. mouseUp()
  995. wait(4)
  996.  
  997. def DeepRunMode(): #(Beta) Deep Run Mode - Not tested properly yet.
  998. ShowTheGameBottomForSmallScreenResolutions()
  999.  
  1000. if exists(Pattern("1432970424925.png").targetOffset(-248,-2),0):
  1001. click(getLastMatch(),0)
  1002. else:
  1003. if exists(Pattern("1432961136172.png").similar(0.90).targetOffset(-248,-1),0):
  1004. click(getLastMatch(),0)
  1005. else:
  1006. click(Location(1273, 631),0)
  1007.  
  1008. Settings.DeepRunStartPositionTemporary = getLastMatch().getTarget()
  1009.  
  1010. Settings.MoveMouseDelay = 0
  1011.  
  1012. iii = 26
  1013. sss = 25
  1014. while iii > 0:
  1015. if iii > sss:
  1016. iii = 1
  1017.  
  1018. if exists(Pattern("1432970424925.png").targetOffset(-248,-2),0):
  1019. click(getLastMatch(),0)
  1020. else:
  1021. if exists(Pattern("1432961136172.png").similar(0.90).targetOffset(-248,-1),0):
  1022. click(getLastMatch(),0)
  1023. else:
  1024. click(Location(1273, 631),0)
  1025.  
  1026. wheel(Location(Settings.DeepRunStartPositionTemporary),WHEEL_DOWN,10)
  1027. BuyStrongestGildedHero(2)
  1028.  
  1029. if exists(Pattern("1432970424925.png").targetOffset(-248,-2),0):
  1030. click(getLastMatch(),0)
  1031. else:
  1032. if exists(Pattern("1432961136172.png").similar(0.90).targetOffset(-248,-1),0):
  1033. click(getLastMatch(),0)
  1034. else:
  1035. click(Location(1273, 631),0)
  1036.  
  1037. FindAndClick(Pattern("skill-lucky-strikes.png").similar(0.90).targetOffset(0,52),0,False) #Target Offset changed for Metal Detector
  1038.  
  1039. if exists(Pattern("skill-gold-clicks.png").similar(0.90),0) and exists(Pattern("1433037474843.png").similar(0.90),0):
  1040. FindAndClick(Pattern("skill-gold-clicks.png").similar(0.90),0,False)
  1041. FindAndClick(Pattern("1433037474843.png").similar(0.90),0,False)
  1042. else:
  1043. if exists(Pattern("skill-gold-clicks.png").similar(0.90),0):
  1044. FindAndClick(Pattern("skill-gold-clicks.png").similar(0.90),0,False)
  1045.  
  1046. if exists(Pattern("1432970424925.png").targetOffset(-248,-2),0):
  1047. click(getLastMatch(),0)
  1048. else:
  1049. if exists(Pattern("1432961136172.png").similar(0.90).targetOffset(-248,-1),0):
  1050. click(getLastMatch(),0)
  1051. else:
  1052. click(Location(1273, 631),0)
  1053.  
  1054. FindAndClick(Pattern("skill-super-clicks.png").similar(0.90),0,False)
  1055. FindAndClick(Pattern("skill-powersurge.png").similar(0.90).targetOffset(0,-52),0,False) #Target Offset changed for Clickstorm
  1056.  
  1057. if exists(Pattern("1432970424925.png").targetOffset(-248,-2),0):
  1058. click(getLastMatch(),0)
  1059. else:
  1060. if exists(Pattern("1432961136172.png").similar(0.90).targetOffset(-248,-1),0):
  1061. click(getLastMatch(),0)
  1062. else:
  1063. click(Location(1273, 631),0)
  1064.  
  1065. if exists(Pattern("skill-energize.png").similar(0.95),0) and exists(Pattern("skill-lucky-strikes.png").similar(0.90),0):
  1066. FindAndClick(Pattern("skill-energize.png").similar(0.95),0,False)
  1067. FindAndClick(Pattern("skill-lucky-strikes.png").similar(0.90),0,False)
  1068. else:
  1069. if exists(Pattern("skill-lucky-strikes.png").similar(0.90),0):
  1070. FindAndClick(Pattern("skill-lucky-strikes.png").similar(0.90),0,False)
  1071.  
  1072. if exists(Pattern("1432970424925.png").targetOffset(-248,-2),0):
  1073. click(getLastMatch(),0)
  1074. else:
  1075. if exists(Pattern("1432961136172.png").similar(0.90).targetOffset(-248,-1),0):
  1076. click(getLastMatch(),0)
  1077. else:
  1078. click(Location(1273, 631),0)
  1079.  
  1080.  
  1081. FindAndClick(Pattern("skill-powersurge.png").similar(0.90),0,False)
  1082. FindAndClick(Pattern("1432961445894.png").similar(0.90),0,False)
  1083.  
  1084. if exists(Pattern("1432970424925.png").targetOffset(-248,-2),0):
  1085. click(getLastMatch(),0)
  1086. else:
  1087. if exists(Pattern("1432961136172.png").similar(0.90).targetOffset(-248,-1),0):
  1088. click(getLastMatch(),0)
  1089. else:
  1090. click(Location(1273, 631),0)
  1091. else:
  1092. iii = iii + 1
  1093. wheel(Location(Settings.DeepRunStartPositionTemporary),WHEEL_DOWN,10)
  1094. BuyStrongestGildedHero(2)
  1095. if exists(Pattern("1432970424925.png").targetOffset(-248,-2),0):
  1096. click(getLastMatch(),0)
  1097. else:
  1098. if exists(Pattern("1432961136172.png").similar(0.90).targetOffset(-248,-1),0):
  1099. click(getLastMatch(),0)
  1100. else:
  1101. click(Location(1273, 631),0)
  1102. FindAndClick("1432960442630.png",0,False)
  1103. wait(0.5)
  1104.  
  1105. def Throne_Rush():#Throne rush automation, because why not.
  1106. if exists("1434101319534.png",0):#Throne Rush is on screen
  1107. FindAndClick(Pattern("ThroneRush.Sand.png").similar(0.80).targetOffset(-5,-3))
  1108. Settings.MoveMouseDelay = 0
  1109. if TryToFind(Pattern("1433045147103.png").similar(0.98)) == False:
  1110. FindAndClickAll(Pattern("ThroneRush.Gold.png").targetOffset(6,-4))
  1111. if TryToFind(Pattern("ThroneRush.FoodBar.png").similar(0.95)) == False:#Make sure the food capacity bar is not full. Need to add this for gold once my gold is full.
  1112. FindAndClickAll(Pattern("ThroneRush.Food.png").similar(0.80))
  1113. Settings.MoveMouseDelay = .5
  1114. wait(5)
  1115. return True
  1116. else:
  1117. return False
  1118.  
  1119. while True:#This is the main loop of the application.
  1120. StartPosition = Env.getMouseLocation() #This variable is set to detect if you are actively moving the mouse.
  1121. Settings.DeepRunStartPositionTemporary = StartPosition
  1122. if Clicker_Heroes() == False: #This calls the Clicker_Heroes function which returns False if clicker heroes is not present on the screen.
  1123. Throne_Rush() #This is an example of using a single script to automate multiple games. I intend to have it automatically change tabs soon.
  1124.  
  1125. EndPosition = Env.getMouseLocation()
  1126. while StartPosition != EndPosition:#Here we check if the mouse moved at all while the scripts were running. If it has, enter a side loop until the mouse stops moving for 2 seconds.
  1127. Settings.Times = 0 #Custom global variable. Becomes important later.
  1128. StartPosition = Env.getMouseLocation()
  1129. wait(2)
  1130. EndPosition = Env.getMouseLocation()
Advertisement
Add Comment
Please, Sign In to add comment