Advertisement
omegakoolkidrocker

Dragonvale Plant Farming AHK Script

May 11th, 2024
1,477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Autohotkey 3.62 KB | Software | 0 0
  1. break := false
  2.  
  3. PlantFarming(file, dataFile) {
  4.     global break
  5.     Click 809 652 ; Select Breeding Cave
  6.     Sleep 550
  7.     Click 699 875 ; Select Retry
  8.     Sleep 360
  9.     Click 899 869 ; Confirm Breed
  10.     Sleep 4000
  11.     WaitForColour(0xFF1111, 945, 430, file, dataFile, wait:=25, lookForColour:=true, waitMessage:="Beginning Wait", foundMessage:="Heart", recordData:=true)
  12.     Click 955 552 ; Click on Cave
  13.     Sleep 450
  14.     Click 939 825 ; Place in Nursery
  15.     Sleep 500
  16.     Click 1098 437 ; Click on Nursery
  17.     Sleep 2500
  18. ; change coords depending on egg slot
  19. ; No Donation Board - 1: (,), 2: (,), 3: (278,826), 4: (257,846), 5: (80,846), 6:(,)
  20. ; Donation Board - 1: (,), 2: (475,826), 3: (433,849), 4: (400,865), 5: (238,867), 6:(,)
  21.     WaitForColour(0x22BB11, 80, 846, file, dataFile, wait:=25, lookForColour:=false, waitMessage:="Beginning Egg Wait", foundMessage:="Egg")
  22. ; change first number depending on which nursery slot egg goes into (numbered from right)
  23. ; No Donation Board - 1: 721, 2: 523, 3: 366, 4: 336, 5: 152, 6:
  24. ; Donation Board - 1: , 2: 555, 3: 507, 4: 471, 5: 302, 6:
  25.     Click 152 904 ; Click on Egg
  26.     Sleep 350
  27.     Click 1199 645 ; Click Sell
  28.     Sleep 360
  29.     Click 789 843 ; Click Yes
  30.     Sleep 360
  31. }
  32.  
  33. WaitForColour(colour, X, Y, file, dataFile, wait:=50, lookForColour:=true, waitMessage:="Beginning Wait", foundMessage:="", recordData:=false) {
  34.     counter := 0
  35.     loops := 0
  36.     file.write(A_Hour ":" A_Min ":" A_Sec " : " waitMessage "`n")
  37.     if (lookForColour)
  38.     {
  39.         Loop {
  40.             PixelGetColor, cRGB, %X%, %Y%, RGB
  41.             if (cRGB = colour) ; might need to update this if the heart isn't detected
  42.             {
  43.                 file.write(A_Hour ":" A_Min ":" A_Sec " : " foundMessage " Found after " counter " loops (" counter * wait " milliseconds) `n")
  44.                 if (recordData)
  45.                 {
  46.                     dataFile.write(counter "," A_Hour ":" A_Min ":" A_Sec "`n")
  47.                 }
  48.                 Break
  49.             }
  50.             Sleep %wait%
  51.         }
  52.     } else {
  53.         Loop {
  54.             PixelGetColor, cRGB, %X%, %Y%, RGB
  55.             file.write(A_Hour ":" A_Min ":" A_Sec " : " cRGB " at 945, 430`n")
  56.             if (cRGB != colour)
  57.             {
  58.                 file.write(A_Hour ":" A_Min ":" A_Sec " : " foundMessage " Found after " counter " loops (" counter * wait " milliseconds) `n")
  59.                 if (recordData)
  60.                 {
  61.                     dataFile.write(counter "," A_Hour ":" A_Min ":" A_Sec "`n")
  62.                 }
  63.                 Break
  64.             }
  65.             counter := counter + 1
  66.             Sleep %wait%
  67.         }
  68.     }
  69.     return
  70. }
  71.  
  72. +x::
  73. MouseGetPos, PosX, PosY
  74. PixelGetColor, cRGB , %PosX%, %PosY%,RGB
  75. MsgBox, %cRGB% "`n" %PosX% ", " %PosY%
  76. return
  77.  
  78. +p::
  79. break := false
  80. startTime := A_TickCount
  81. filename := "D:\mouse-click\log-file-" A_DD "-" A_MM ".txt"
  82. file := FileOpen(filename,"a")
  83. dataFile := FileOpen("D:\mouse-click\plant-farm-data-" A_DD "-" A_MM ".csv","a")
  84. file.write(A_Hour ":" A_Min ":" A_Sec " : Starting Cycle at " startTime "`n")
  85. count := 0
  86. Loop {
  87.     count := count + 1
  88.     file.write(A_Hour ":" A_Min ":" A_Sec " : Starting Run " count "`n")
  89.     dataFile.write(count ",")
  90.     PlantFarming(file, dataFile)
  91.     tempEndTime := A_TickCount
  92.     tempDuration := (tempEndTime - startTime) / 1000
  93.     tempAverage := count * 10800 / tempDuration ; Gives average value per hour
  94.     file.write(A_Hour ":" A_Min ":" A_Sec " : Average Rate: " tempAverage " EC/hr`n")
  95.     if break
  96.         Break
  97. }
  98. endTime := A_TickCount
  99. duration := (endTime - startTime) / 1000
  100. average := count * 10800 / duration ; Gives average value per hour
  101. file.write(A_Hour ":" A_Min ":" A_Sec " : Finishing Cycle`n")
  102. file.write(A_Hour ":" A_Min ":" A_Sec " : Ran " count " times in " duration " seconds`n")
  103. file.write(A_Hour ":" A_Min ":" A_Sec " : Average Rate: " average " EC/hr`n")
  104. file.close()
  105. dataFile.close()
  106. return
  107.  
  108. +o::
  109.     file.write(A_Hour ":" A_Min ":" A_Sec " : Break Detected`n")
  110.     break := true
  111. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement