Guest User

Team Rocket Blasting Off.au3

a guest
May 18th, 2020
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 16.66 KB | None | 0 0
  1. #cs ----------------------------------------------------------------------------
  2.  
  3.  AutoIt Version: 3.3.0.0
  4.  Author:        
  5.  
  6.  Script Function: Being awesome.
  7.  
  8. Help: Displays quick-help guide.
  9. Eat: Eats mealSize apples from selected tree, then dumps the cores.
  10. Bark: Picks bark indefinitely from an apple tree.
  11. Build: Builds a furniture item repeatedly, eating when hungry.
  12. Perma: Picks some bark, eats some apples, and repeats indefinitely.
  13. Clay: Gathers clay from a clay pond and crafts selected item. Stops eventually
  14.     if keeping items is turned on, otherwise drops them and continues indefinitely.
  15. Configure: Sets the parameters. Giving a nonsense configuration will cancel the
  16.     rest of it (without changing previously set values).
  17. haltToggle: Whether or not the macro is going to stop at the beginning of the
  18.     loop or not. This can be used to finish bark gathering without ending
  19.     the script, allowing the user to still use the eat macro to eat many
  20.     apples quickly, if he were to continue playing.
  21. quit: Exits the script entirely.
  22.  
  23. Notes:
  24.  
  25. The game window needs to be at the top-left corner of your screen, where it
  26. appears by default.
  27.  
  28. Be right up against the gathering spot, to prevent screen movement when
  29. clicking the item.
  30.  
  31. Do not have your inventory open when pressing the hotkey.
  32.  
  33. You need LUMBERJACKING for these to work right now, because otherwise it's like,
  34. meh.
  35.  
  36. You may not have partial columns of free inventory space -- fill them up with
  37. other stuff. These columns must also be left-most, so you'll want your stuff,
  38. if you're carrying any, to be full columns all the way on the right.
  39.  
  40. Also, don't minimize your character bar at the bottom.
  41.  
  42. F5 doesn't do anything because it's used to reload web pages and gets in the
  43. way during furniture.
  44.  
  45. Changing hotkeys doesn't change what the help box says, so it can be misleading.
  46.  
  47. --
  48.  
  49. EXTENDED TUTORIAL FOR BUILD MODE. BUILD MODE IS SET ON LOOM BY DEFAULT,
  50. AND CANNOT BE CHANGED BY THE USER. This is advanced mode stuff, and
  51. editing it is not currently very newb-friendly.
  52.  
  53. You must edit it manually for now.
  54.  
  55. This only works on apple trees. You still need lumberjacking.
  56.  
  57. How to Add an Item
  58. Edit it into the branch-crafts array. There are two possible ones right now,
  59. to make it easy to see examples. The first block in brackets is a loom (path b -> t -> l) and
  60. the second is a wicker basket (path b -> o -> w). The loom takes 15 sticks
  61. while the basket takes 9 (to allow destruction of it with a button-click).
  62. It takes 135000 milliseconds (135 seconds) to build all the sticks in the loom
  63. and 10000 milliseconds (10 seconds, but I guessed the build time so it's not
  64. accurate.
  65.  
  66. Each loom uses 3 apples worth of hunger while a basket uses .2 apples worth
  67. (guessing on the basket hunger, again). Fractions ARE supported (will make five
  68. baskets and then eat one apple).
  69.  
  70. The build button for the loom is 335 pixels from the top of the screen, and the one
  71. for the wicker basket is
  72.  
  73. Branchpath is the item you want to build, relative to the branchcrafts array.
  74. 0 is the first element, which is the bracket block that represents a loom. 1 would
  75. be a wicker basket. If you add another item to the end of the array, your branchpath
  76. would be 2, and if you put it in front, your branchpath would be 0 (and then loom would
  77. be at position 1 if you wanted to build looms).
  78.  
  79. How to Build
  80.  
  81. 1. Find tree with some clear space to place a furniture item.
  82. 2. Place a partially-constructed item (same item as the one you want to make) as close
  83.     to it as possible. Drop a branch in it or something so the post doesn't go away.
  84. 3. Walk (left-click) between the tree and your construction (by clicking on the
  85.     construction post). Walk back and forth a few times, trying to click in the same
  86.     place each time.
  87. 4. THIS IS THE MOST IMPORTANT STEP SO DON'T FUCK IT UP.
  88.     If the view moves (as in, the tree and the post move to a different pixel  
  89.     location on your screen), then destroy the construction and make it somewhere
  90.     closer or at a better angle or whatever, and go back to step 2.
  91.    
  92. 5. Once you have a build post and an apple tree and can walk between the two
  93.     without changing your view, hit F4 or whatever your hotkey of choice is to
  94.     start the building macro.
  95.  
  96. NOTE: If you deselect the autoit button, you will have to alt-tab to select it again
  97. or drag it somewhere you can see it and the target at the same time, or whatever. Do
  98. not use your mouse to click the OK button, because then it'll think the OK button
  99. was the place the tree or build site.
  100.  
  101. 6. Place your mouse over where on the tree you were clicking, then hit enter.
  102.  
  103. 7. Place your mouse over where on the build site you were clicking, and then
  104.     hit enter.
  105.  
  106. 8. THIS IS THE WEIRD PART. Now you should see a "starting now" message - DO NOT CLICK
  107.     IT!!!!!. Instead, deconstruct the build post you put down.
  108.    
  109. 9. Hit OK on the "starting now" button.
  110.  
  111. 10. That's it.
  112.    
  113. --
  114.  
  115. HOW TO CHANGE HOTKEYS
  116.  
  117.  
  118.  
  119. #ce ----------------------------------------------------------------------------
  120.  
  121. #include <Math.au3>
  122.  
  123. HotKeySet("{F1}", "help")
  124. HotKeySet("{F2}", "bark")
  125. HotKeySet("{F3}", "pause")
  126. HotKeySet("{F4}", "build")  
  127. HotKeySet("{F6}", "configure")
  128. HotKeySet("{F7}", "haltToggle")
  129. HotKeySet("{F8}", "quit")
  130.  
  131. #cs
  132. NEWBIE GUIDE FOR HOTKEY SETTING
  133.  
  134. Possible user functions are: eat, bark, build, perma, clay
  135. Functions you shouldn't remove from the hotkey list are: help, configure, haltToggle, quit
  136.  
  137. Pretend this is WoW and this is your skill bar, above. Right now, you have F1 - F8,
  138. and your skills are "help, eat, bark, etc", down the list. If you want to change your
  139. equipped skills, change the text on the right to the function you want. Skill descriptions
  140. are above in the comments, and also in the code.
  141.  
  142. All the skills you know are below, as functions. Except for the utility functions, because
  143. that's like breathing, and you don't want to fuck with your breathing unless you know what
  144. you're doing.
  145.  
  146. Useful macros are help, eat, configure, pause, haltToggle, and quit. Everything else is
  147. like, whatever, so feel free to mix and match (you probably shouldn't take off quit)
  148.  
  149. It's possible to make F9-F11 hotkeys as well, but not always F12 (reserved by Windows), but
  150. you don't need that many anyways.
  151. #ce
  152.  
  153. ; NOT configuration specs, must be hard-edited if at all
  154. Dim Const $mudCrafts[4][3] = [["j", 3, 3000], ["m", 2, 2000], ["t", 4, 4000], ["o", 10, 10000]] ; hotkey for the items and their cost in clay
  155. Dim Const $branchCrafts[2][7] = [["t", "l", 15, 135000, 3.5, 335], ["o", "w", 9, 25000, .4, 200]]
  156. ; branchCrafts is hotkey path (after b), number of sticks, time constructing, apples to eat per item constructed, and
  157. ; y-coordinate of the center of the "build" button.
  158. $branchPath = 0 ; which stickcraft to make
  159. Dim Const $perm[2] = [1, 1] ; ratio of bark pieces gathered to apples eaten
  160. $mudDelay = 3000 ; time to get one piece of clay
  161. $appleDelay = 1000 ; time to get one apple
  162. $barkDelay = 500 ; time to get one piece of bark
  163. $branchDelay = 575 ; time to get one stick
  164. $invDelay = 400 ; time for inventory to load
  165. $actDelay = 70 ; time between generic actions
  166. $walkDelay = 2000 ; time moving to and from build site
  167. $stop = false ; stops the loop
  168. $override = -1 ;
  169. $count = -1
  170. $loadTime = 350 ;
  171. $pause = false;
  172.  
  173. ; These are configuration specs and can be changed.
  174. $mealSize = 5 ; number of apples to eat at once
  175. $mudPath = 2 ; which mudcraft to make
  176. $drop = true ; drops crafted mud
  177. $invWidth = 4 ; number of free inventory columns
  178. $buy = true ;
  179.  
  180. while True
  181.     wait()
  182. WEnd
  183.  
  184. Func help()
  185.     $temp = String("F1 help. F2 eat. F3 pause. F4 build furniture. F5 [nothing]. F6 configure. F7 halt. F8 exit." & @CRLF & "See documentation for more details.")
  186.     $temp = String($temp & @CRLF & "Halt is " & $stop)
  187.     MsgBox (0, "Help", $temp)      
  188. EndFunc
  189.  
  190. Func eat($override = -1)
  191.     if ($override = -1) Then
  192.         MsgBox (0, "Eating", "Eating now. Please place your mouse cursor over an apple tree.")
  193.         WinActivate( "Haven and Hearth" )
  194.     EndIf
  195.    
  196.     $pos = mouseGetPos()
  197.     $x = $pos[0]
  198.     $y = $pos[1]
  199.    
  200.     if $override <> -1 then
  201.         $num = $override - 1
  202.     else
  203.         $num = $mealSize - 1
  204.     endif
  205.     ; grabs the number of apples
  206.     for $i = 0 to $num
  207.         if slowCheck() Then
  208.             Return
  209.         endIf
  210.    
  211.         mouseClick ( "right", $x, $y )
  212.         sleep ($loadTime)
  213.         mouseClick ( "right", $x + 40, $y)
  214.         Sleep ($appleDelay + 50)
  215.     Next
  216.  
  217.     ; opens inventory
  218.     send ("{TAB}")
  219.     sleep($invDelay)
  220.     ; eats apples (and drops cores)
  221.     for $i = 0 to ($num)
  222.         if slowCheck() Then
  223.             Return
  224.         endIf
  225.        
  226.         $tx = 140 + mod($i, $invWidth) * 30
  227.         $ty = 165 + floor($i/$invWidth) * 30
  228.         mouseClick ( "right", $tx, $ty)
  229.         sleep ($loadTime)
  230.         mouseClick ( "right", $tx, $ty - 75)
  231.         sleep ($actDelay)
  232.         send( "{CTRLDOWN}" )
  233.         mouseClick ( "left", $tx, $ty )
  234.         sleep ($actDelay)
  235.         send( "{CTRLUP}" )
  236.     Next
  237.    
  238.     ; closes inventory
  239.     send ("{TAB}")
  240.     sleep($invDelay)
  241.    
  242.     mouseMove ($x, $y)
  243. EndFunc
  244.  
  245. Func bark($count = -1)
  246.     if ($count = -1) Then
  247.         MsgBox (0, "Bark", "Gathering bark. Please place your mouse cursor over an apple tree.")
  248.         WinActivate( "Haven and Hearth" )
  249.     EndIf
  250.    
  251.     $pos = mouseGetPos()
  252.     $x = $pos[0]
  253.     $y = $pos[1]
  254.    
  255.     while $count <> 0
  256.         if slowCheck() Then
  257.             Return
  258.         endIf
  259.        
  260.         ; gets bark
  261.         mouseClick ( "right", $x, $y )
  262.         sleep ($loadTime)
  263.         mouseClick ( "right", $x + 75, $y)
  264.         sleep ($barkDelay + 50)
  265.        
  266.         if $count > 0 then
  267.             $count -= 1
  268.         endif
  269.        
  270.     WEnd
  271.    
  272.     mouseMove ($x, $y)
  273. EndFunc
  274.  
  275. Func perma()
  276.     MsgBox (0, "Perma", "Starting long-term macro. Please place your mouse cursor over an apple tree.")
  277.     WinActivate( "Haven and Hearth" )
  278.    
  279.     $pos = mouseGetPos()
  280.     $x = $pos[0]
  281.     $y = $pos[1]
  282.     $count = 10
  283.     While True
  284.         if $count = 0 Then
  285.             buy()
  286.             $count = 10
  287.         EndIf
  288.        
  289.         bark($perm[0])
  290.         clear($perm[1])
  291.         eat($perm[1])
  292.        
  293.         $count -= 1
  294.     WEnd
  295.     mouseMove ($x, $y)
  296. EndFunc
  297.  
  298. Func clay()
  299.     MsgBox (0, "Clay", "Crafting with clay. Please place your cursor over a clay pond.")
  300.     WinActivate( "Haven and Hearth" )
  301.    
  302.     $pos = mouseGetPos()
  303.     $x = $pos[0]
  304.     $y = $pos[1]
  305.     $numCreated = 0
  306.    
  307.     send ("{ESC}")
  308.     sleep($actDelay)
  309.     send ("{ESC}")
  310.     sleep($actDelay)
  311.     send ("c") 
  312.     sleep($actDelay)
  313.     send ("m")
  314.     sleep($actDelay)
  315.     send ($mudCrafts[$mudPath][0])
  316. ;   send ( "cm" & $mudCrafts[$mudPath][0] ) ; too fast?
  317.     sleep($actDelay)
  318.    
  319.     $count = 100
  320.     while true
  321.         if slowCheck() Then
  322.             Return
  323.         endIf
  324.        
  325.         if $count = 0 Then
  326.             buy()
  327.             $count = 100
  328.         EndIf
  329.        
  330.         ; Gathers clay
  331.         mouseClick ("right", $x, $y)
  332.         sleep ($loadTime)
  333.         mouseClick ("right", $x, $y - 75)
  334.         Sleep (($mudDelay * $mudCrafts[$mudPath][1]) +200)
  335.        
  336.         if slowCheck() Then
  337.             Return
  338.         endIf
  339.        
  340.         ; Crafts item
  341.         mouseClick ("left", 635, 605)
  342.         sleep ($mudCrafts[$mudPath][2])
  343.        
  344.         if slowCheck() Then
  345.             Return
  346.         endIf
  347.        
  348.         ; Drops item if drop is on
  349.         if $drop Then
  350.             send ("{TAB}")
  351.             sleep ($invDelay)
  352.             send ("{CTRLDOWN}")
  353.             mouseClick ( "left", 140, 165)
  354.             sleep ($actDelay)
  355.             send( "{CTRLUP}" )
  356.             send ("{TAB}")
  357.             sleep ($invDelay)
  358.         else
  359.             $numCreated += 1
  360.         endif
  361.        
  362.         ; Finishes if out of space
  363.         if ($numCreated + $mudCrafts[$mudPath][1]) > (4 * $invWidth) then
  364.             Return
  365.         endif
  366.        
  367.         $count -= 1
  368.     WEnd
  369.    
  370.     mouseMove ($x, $y)
  371. EndFunc
  372.  
  373. Func build()
  374.     MsgBox (0, "Part 1", "Crafting furniture. Please place your cursor over an appropriate apple tree.")
  375.     WinActivate( "Haven and Hearth" )
  376.    
  377.     $hungerTracker = 0
  378.    
  379.     $pos = mouseGetPos()
  380.     $treex = $pos[0]
  381.     $treey = $pos[1]
  382.    
  383.     MsgBox (0, "Part 2", "Crafting furniture Please place your cursor over an APPROPRIATE build location.")
  384.     WinActivate ( "Haven and Hearth" )
  385.     $pos = mouseGetPos()
  386.     $buildx = $pos[0]
  387.     $buildy = $pos[1]
  388.    
  389.     $numBranches = _Min( $branchCrafts[$branchPath][2], $invWidth * 4)
  390.    
  391.     MsgBox (0, "Ready", "Deconstruct your build site if it is present, then hit okay.")
  392.     WinActivate ( "Haven and Hearth" )
  393.    
  394.     $count = 10
  395.    
  396.     while true
  397.         if slowCheck() Then
  398.             Return
  399.         endIf
  400.        
  401.         if $count = 0 Then
  402.             buy()
  403.             $count = 10
  404.         EndIf
  405.        
  406.         ; gets branches
  407.         mouseClick ( "left", $treex, $treey)
  408.         sleep ($walkDelay)
  409.         mouseClick ( "right", $treex, $treey)
  410.         sleep ($loadTime)
  411.         mouseClick ( "right", $treex + 50, $treey - 55)
  412.         sleep ($branchDelay * $numBranches + 50)
  413.        
  414.         if slowCheck() Then
  415.             Return
  416.         EndIf
  417.        
  418.         ; makes build site
  419.         send("{ESC}")
  420.         sleep ($actDelay)
  421.         send("{ESC}")
  422.         sleep ($actDelay)
  423.         send ("b") 
  424.         sleep ($actDelay)
  425.         send ($branchCrafts[$branchPath][0])
  426.         sleep ($actDelay)
  427.         send ($branchCrafts[$branchPath][1])
  428.         sleep ($actDelay)
  429.        
  430.         mouseClick ( "left", $buildx, $buildy)
  431.         sleep ($actDelay)
  432.        
  433.         if slowCheck() Then
  434.             Return
  435.         EndIf
  436.        
  437.         ; shift-clicks the branches
  438.         send ("{TAB}")
  439.         sleep ($invDelay)
  440.         send ("{SHIFTDOWN}")
  441.         sleep ($actDelay)
  442.         invClick($numBranches)
  443.         send ("{SHIFTUP}")
  444.         sleep ($actDelay)
  445.         send ("{TAB}")
  446.         sleep ($invDelay)
  447.        
  448.         ; builds
  449.         mouseClick ( "left", 410, $branchCrafts[$branchPath][5])
  450.         sleep ($branchCrafts[$branchPath][3])
  451.         if slowCheck() Then
  452.             Return
  453.         endIf
  454.        
  455.         ; destroys
  456.         mouseClick ( "left", 350, $branchCrafts[$branchPath][5])
  457.         sleep ($actDelay)
  458.        
  459.         mouseClick( "left", $treex, $treey)
  460.         sleep ($walkDelay)
  461.         mouseMove ($treex, $treey)
  462.        
  463.         ; eats if necessary
  464.         $hungerTracker += $branchCrafts[$branchPath][4]
  465.         if $hungerTracker >= 1 Then
  466.             eat(floor($hungerTracker))
  467.             $hungerTracker -= floor($hungerTracker)
  468.         endif
  469.        
  470.         $count -= 1
  471.     WEnd
  472. EndFunc
  473.  
  474. Func configure()
  475.     $num = InputBox ( "Meal size", "How many apples do you want to eat at once?", $mealSize)
  476.     if @error <> 0 or not StringIsInt($num) Then
  477.         MsgBox (0, "AutoIt", "Invalid count")
  478.         return
  479.     endif
  480.     $num = Number($num)
  481.     $mealSize = $num
  482.     MsgBox ( 0, "Meal Size", "Your meal size is " & $num)
  483.    
  484.     $t1 = String("What clay item do you want to make?" & @CRLF & "1. jar" & @CRLF & "2. mug")
  485.     $t1 = String($t1 & @CRLF & "3. tea pot" & @CRLF & "4. treeplanter's pot")
  486.     $temp = InputBox ( "Clay Item", $t1, $mudPath + 1)
  487.     if @error <> 0 or not StringIsInt ($temp) then
  488.         MsgBox (0, "AutoIt", "Invalid hotkey")
  489.         return
  490.     endif
  491.     $mudPath = mod((Number($temp) - 1), 4)
  492.    
  493.     $temp = InputBox ( "Drop Clay Item?", "Do you want to drop them? y/n", "y")
  494.     if @error <> 0 or (not StringInStr ( "yn", $temp) and StringLen ($temp) = 1) then
  495.         MsgBox (0, "AutoIt", "Invalid hotkey")
  496.         return
  497.     endif
  498.    
  499.     if stringCompare($temp, "y") = 0 then
  500.         $drop = true
  501.     else
  502.         $drop = false
  503.     endif
  504.     MsgBox ( 0, "Drop items", "You are making hotkey " & $mudCrafts[$mudPath][0] & " and your drop value is: " & $drop)
  505.    
  506.     $temp = InputBox ( "Inventory Width?", "How many empty columns do you have in your inventory?", $invWidth)
  507.     if @error <> 0 or not StringIsInt($temp) Then
  508.         MsgBox (0, "AutoIt", "Invalid number")
  509.         return
  510.     endif
  511.     $temp = Number($temp)
  512.     $invWidth = $temp
  513.     MsgBox ( 0, "Free space", "Your number of free columns is " & $invWidth)
  514.    
  515.     $temp = InputBox ( "Save Character", "Do you want to save your character regularly? y/n", "n")
  516.     if @error <> 0 or (not StringInStr ( "yn", $temp) and StringLen ($temp) = 1) then
  517.         MsgBox (0, "AutoIt", "Invalid hotkey")
  518.         return
  519.     endif
  520.    
  521.     if stringCompare($temp, "y") = 0 then
  522.         $buy = true
  523.     else
  524.         $buy = false
  525.     endif
  526.     MsgBox ( 0, "Buy", "Your buy toggle is: " & $buy)
  527.    
  528. EndFunc
  529.  
  530. Func haltToggle()
  531.     msgBox( 0, "Halt", "Halt toggled to " & not $stop)
  532.     $stop = not $stop
  533. EndFunc
  534.  
  535. Func pause()
  536.     $pause = true
  537. EndFunc
  538.  
  539. Func quit()
  540.     Exit(0)
  541. EndFunc
  542.  
  543. ; Utility functions~
  544. Func clear($num)
  545.    
  546.     ; stores the old positions
  547.     $pos = mouseGetPos()
  548.     $x = $pos[0]
  549.     $y = $pos[1]
  550.    
  551.     ; drops $num items from inventory (only uses specified cols)
  552.     if $num > ($invWidth*4) Then
  553.         $num = $invWidth*4
  554.     EndIf
  555.    
  556.     send("{TAB}")
  557.     sleep($invDelay)
  558.     send ("{CTRLDOWN}")
  559.     invClick($num)
  560.     send ("{CTRLUP}")
  561.     send("{TAB}")  
  562.     sleep($invDelay)
  563.     mouseMove($x, $y)
  564.    
  565. EndFunc
  566.  
  567. ; leftclicks first $num items in inventory (does not open inventory)
  568. Func invClick($num)
  569.     for $i = 0 to ($num - 1)
  570.         if slowCheck() then
  571.             return
  572.         endif
  573.         $tx = 140 + mod($i, $invWidth) * 30
  574.         $ty = 165 + floor($i/$invWidth) * 30
  575.         mouseClick ( "left", $tx, $ty )
  576.         sleep ($actDelay)
  577.     Next
  578. endFunc
  579.  
  580. ; waits for user input
  581. Func wait()
  582.     while true
  583.         sleep (100)
  584.     wend
  585. endFunc
  586.  
  587. Func slowCheck()
  588.     if $stop then
  589.         return true
  590.     endif
  591.    
  592.     if $pause Then
  593.         MsgBox (0, "Paused", "Pausing. Hit OK to resume, F7 to end function at the next opportunity, or F8 to exit the script.")
  594.         $pause = false
  595.         WinActivate ( "Haven and Hearth")
  596.         return false
  597.     EndIf
  598. EndFunc
  599.  
  600. Func buy()
  601.     if $buy Then
  602.         mouseClick( "left", 460, 470)
  603.         sleep (500)
  604.         mouseClick( "left", 425, 290)
  605.         sleep ($actDelay)
  606.         mouseClick ( "left", 460, 470)
  607.         sleep (500)
  608.     EndIf
  609. EndFunc
Add Comment
Please, Sign In to add comment