Advertisement
Guest User

autoharvest 0.1

a guest
Jul 2nd, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.12 KB | None | 0 0
  1. #InstallMouseHook
  2. /*
  3. a simple bot for Anti-Idle: The Game
  4. In it's current state will harvest & replant the Free tree then send you into the battle arena
  5. And nudge the mouse to keep you from AFK'ing
  6.  
  7. It / can / be reconfigured to plant different trees from the basic garden & send you into different areas.
  8. Quite ambitious and low quality. mostly works tho
  9.  
  10.  
  11. ; toDo:
  12. ::STUDY:: Implement Coordinates / Click recording for user made sequences from previous script
  13. ::STUDY:: GUI
  14. ::STUDY:: Convert coordinates to object
  15. ::CODE:: Create 'TogMouseLast'
  16. ::FEATURE:: Add Battery, Manual & Doom antSprayers behaviours in Misc.
  17. ::FEATURE::
  18. ::CODE:: Pause without resetting counters
  19. ::FEATURE:: Change Starting point offset whilst script is running / paused ^
  20. ::CODE:: Enhance MyHome
  21. ::INFO:: Create more splashText
  22. */
  23.  
  24.  
  25. CoordMode, Mouse, Screen
  26. CoordMode, Tooltip, Mouse
  27. MSGBODY = [F1] Toggles help message [Esc] will terminate this script `nTo activate:`n1. Go to the garden`n2. [Alt]+[LeftClick] on the top left corner above the text saying "Garden"`n(That will get the base value to offset button locations from.)`n3. [ALT]+[RightClick] Will activate
  28.  
  29. msgbox,,FreeTreeBot,%MSGBODY%
  30. Busy := 0
  31. Harvested := 0
  32. TogRB := 0
  33. Timeout=50
  34. MenuClicKDelay := 500
  35.  
  36. S := 1000
  37. M := S * 60
  38. H := M * 60
  39. D := H * 24
  40.  
  41. NudgeInterval := 3 * S ;How often to nudge the mouse ( ms )
  42. TreeHarvest := 30000
  43. TreeLifeSpan := 5 * M
  44.  
  45. ReplantEvery := floor(TreeLifeSpan / TreeHarvest)
  46.  
  47. Numpad1::Harvested++
  48. Numpad2::Tooltip, % Harvested A_SPACE abs((TreeLifeSpan ) / S - ( Harvested * (TreeHarvest / S )))
  49. Numpad3::Tooltip, % NudgeInterval / 100
  50. ;----------------------------
  51. ;Input
  52. Return
  53.  
  54. MyHome:
  55. BlockInput,MouseMove
  56. MovArena() ; MovArena() MovFishing() MovMarket()
  57. BlockInput,MouseMoveOff
  58. Return
  59.  
  60.  
  61. ; SORT THIS SHIT OUT M8
  62. Busy := If GetKeyState(LButton,T) | GetKeyState(RButton,T) ? 1 : 0
  63. ; Busy := 1
  64. ; } else {
  65. ; Busy := 0
  66. ; }
  67.  
  68.  
  69. ;Busy := If GetKeyState(LButton,T) or GetKeyState(RButton,T) {
  70. ; Busy := 1
  71. ; } else {
  72. ; Busy := 0
  73. ; }
  74.  
  75.  
  76. ;----------------------------
  77. !LButton:: ;set starting position
  78. Gosub DefineButtons
  79. return
  80. ;----------------------------
  81. !RButton::
  82. If (TogRB=1) {
  83. send {RButton}
  84. } else {
  85. BlockInput,MouseMove
  86. TogRB := 1
  87. MovFreeTree()
  88. MovPlantAll()
  89. Gosub MyHome
  90. BlockInput,MouseMoveOff
  91. Goto QuickStartRoutine
  92. }
  93. return
  94. ;----------------------------
  95. Routine:
  96. SetTimer, Routine, Off
  97. SetTimer, StayAlive, Off
  98. If (Harvested >= ( ReplantEvery-1 ) ) {
  99. Harvested := 0
  100. Gosub Replant
  101. } else {
  102. Gosub harvest
  103. }
  104. QuickStartRoutine:
  105. SetTimer, StayAlive, 100
  106. SetTimer, Routine, % TreeHarvest+100
  107. Return
  108. ;----------------------------
  109. harvest: ;Can be simplified with TogMouseLast
  110. Global Busy := 1
  111. Global Harvested += 1
  112. splashThis(100,50,"You've Harvested %Harvested% Times.")
  113.  
  114. BlockInput,MouseMove
  115. MouseGetPos, x, y, ,Init
  116. mousemove AutoHarvestX,AutoHarvestY
  117. sleep 200
  118. click
  119. MouseMove x,y
  120. BlockInput,MouseMoveOff
  121. Global Busy := 0
  122. return
  123. ;----------------------------
  124. Replant:
  125. Global Busy := 1
  126. BlockInput,MouseMove
  127. MovAutoHarvest()
  128. MovGarden()
  129. MovFreeTree()
  130. MovDestroyAll()
  131. MovPlantAll()
  132. Completed += 1
  133. BlockInput,MouseMoveOff
  134. Gosub MyHome
  135. SplashThis(300,25,"You've completed %Completed% Harvests.")
  136. Global Busy := 0
  137. return
  138. ; Movement related ----------------------------
  139. MovFreeTree(){
  140. mousemove,xFreeTree,yFreeTree
  141. sleep MenuClicKDelay
  142. click
  143. }
  144. MovPlantAll(){
  145. mousemove,PlantAllX,PlantAllY
  146. sleep MenuClicKDelay
  147. click
  148. }
  149. MovAutoHarvest(){
  150. mousemove,AutoHarvestX,AutoHarvestY
  151. sleep MenuClicKDelay
  152. click
  153. }
  154. MovDestroyAll(){
  155. sleep MenuClicKDelay
  156. mousemove,DestroyAllX,DestroyAllY
  157. sleep MenuClicKDelay
  158. send +{click}
  159. sleep MenuClicKDelay
  160. }
  161. MovMenu(){
  162. mousemove,MenuX,MenuY
  163. sleep 200
  164. }
  165. MovGarden() {
  166. MovMenu()
  167. mousemove,GardenX - MenuX,GardenY - MenuY,,R
  168. sleep MenuClicKDelay
  169. click
  170. }
  171. MovArena() {
  172. MovMenu()
  173. mousemove,ArenaX - MenuX, ArenaY - MenuY,,R
  174. sleep MenuClicKDelay
  175. click
  176. }
  177. MovMarket() {
  178. MovMenu()
  179. mousemove,MarketX - MenuX,MarketY - MenuY,,R
  180. sleep MenuClicKDelay
  181. click
  182. }
  183. MovFishing() {
  184. MovMenu()
  185. mousemove,FishingX - MenuX,FishingY - MenuY,,R
  186. sleep MenuClicKDelay
  187. click
  188. }
  189. ;----------------------------
  190. DefineButtons:
  191. MouseGetPos, x, y, ,Init
  192. Global xCorner := x
  193. Global yCorner := y
  194. Global xFreeTree := xCorner + 25
  195. Global yFreeTree := yCorner + 325
  196. Global PlantAllX := xCorner + 335
  197. Global PlantAllY := yCorner + 330
  198. Global DestroyAllX := xCorner + 435
  199. Global DestroyAllY := yCorner + 330
  200. Global AutoHarvestX := xCorner + 40
  201. Global AutoHarvestY := yCorner + 480
  202. Global MenuX := xCorner + 450
  203. Global MenuY := yCorner + 10
  204. Global GardenX := xCorner + 450
  205. Global GardenY := yCorner + 65
  206. Global ArenaX := xCorner + 450
  207. Global ArenaY := yCorner + 90
  208. Global MarketX := xCorner + 450
  209. Global MarketY := yCorner + 235
  210. Global FishingX := xCorner + 450
  211. Global FishingY := yCorner + 290
  212. return
  213. ; Stay Alive - butchered from a previous script i wrote. ------------------------------------------------
  214. TogMisc:
  215. Active := !Active
  216. Activate:
  217. if !Active {
  218. SetTimer, StayAlive, Off ;
  219. } else {
  220. SetTimer, StayAlive, 100
  221. }
  222. return
  223. ;----------------------------
  224. CheckPos: ;Called by StayAlive when conditions are met.
  225. if(xCorner=xCurrent) & (yCorner=yCurrent) {
  226. Dance(1) ;To be replaced with "Is within the coordinates"
  227. } else {
  228. MouseMove,xCorner,yCorner
  229. Dance(9)
  230. MouseMove,xCurrent,yCurrent
  231. GoSub StayAlive
  232. }
  233. return
  234. ;----------------------------
  235. StayAlive: ;Tracks movement on a timer from TogMisc
  236. ; Not sure how it works if it sleeps same interval as it's called, Hope it doesn't leak memory
  237. MouseGetPos,xCheck,yCheck
  238. sleep 100
  239. mousegetpos, xCurrent, yCurrent
  240. Tooltip, % Busy
  241. ; ToolTip, % MovChk A_SPACE MovAccum A_SPACE TimeOut A_SPACE Busy
  242. MovChk := abs(xCheck-xCurrent + yCheck-yCurrent)
  243. MovAccum += MovChk > 0 && MovAccum < 25 ? 1 : 0
  244. MovAccum -= MovChk < 1 && MovAccum > 0 ? 1 : 0
  245. Timeout -= Timeout > 0 && MovAccum = 0 ? 1 : 0
  246.  
  247. if (MovAccum<1) && (Timeout=0) && (Busy=0){
  248. Timeout := round( NudgeInterval / 100 )
  249. sum++
  250. GoSub CheckPos
  251. }
  252. return
  253. ;----------------------------
  254. Dance(SPD) { ;Callde by CheckPos
  255. BlockInput,MouseMove
  256. MouseMove,-5,0,100*SPD,R
  257. MouseMove,10,0,100*SPD,R
  258. MouseMove,-5,0,100*SPD,R
  259. BlockInput,MouseMoveOff
  260. }
  261. return
  262. ;----------------------------
  263. SplashThis(W=0,L=0,String="") {
  264. If (SplashTextOn) {
  265. SplashTextOff
  266. SplashTextOn,W,L,, % String
  267. setTimer splashOff, 2000
  268. Return
  269. } Else {
  270. SplashTextOn,W,L,, % String
  271. setTimer splashOff, 2000
  272. Return
  273. }
  274. splashOff:
  275. setTimer splashOff, Off
  276. ; tooltip, You weren't supposed to see this ;Shows up if triggered, debugging
  277. SplashTextOff
  278. Return
  279. }
  280. ;----------------------------
  281. F1::
  282. TogHelp := !TogHelp
  283. If !TogHelp {
  284. SplashTextOff
  285. } else {
  286. SplashTextOn,450,120,"Free Tree Bot" for Anti-Idle: The Game,%MSGBODY%
  287. }
  288. Return
  289. ;----------------------------
  290. ^esc::
  291. reload
  292. Return
  293. esc::
  294. IF (TogHelp=1) {
  295. TogHelp := 0
  296. SplashTextOff
  297. } else {
  298. toolTip Terminating script
  299. sleep 1000
  300. ExitApp
  301. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement