Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #cs ----------------------------------------------------------------------------
- AutoIt Version: 3.3.0.0
- Author:
- Script Function: Being awesome.
- Help: Displays quick-help guide.
- Eat: Eats mealSize apples from selected tree, then dumps the cores.
- Bark: Picks bark indefinitely from an apple tree.
- Build: Builds a furniture item repeatedly, eating when hungry.
- Perma: Picks some bark, eats some apples, and repeats indefinitely.
- Clay: Gathers clay from a clay pond and crafts selected item. Stops eventually
- if keeping items is turned on, otherwise drops them and continues indefinitely.
- Configure: Sets the parameters. Giving a nonsense configuration will cancel the
- rest of it (without changing previously set values).
- haltToggle: Whether or not the macro is going to stop at the beginning of the
- loop or not. This can be used to finish bark gathering without ending
- the script, allowing the user to still use the eat macro to eat many
- apples quickly, if he were to continue playing.
- quit: Exits the script entirely.
- Notes:
- The game window needs to be at the top-left corner of your screen, where it
- appears by default.
- Be right up against the gathering spot, to prevent screen movement when
- clicking the item.
- Do not have your inventory open when pressing the hotkey.
- You need LUMBERJACKING for these to work right now, because otherwise it's like,
- meh.
- You may not have partial columns of free inventory space -- fill them up with
- other stuff. These columns must also be left-most, so you'll want your stuff,
- if you're carrying any, to be full columns all the way on the right.
- Also, don't minimize your character bar at the bottom.
- F5 doesn't do anything because it's used to reload web pages and gets in the
- way during furniture.
- Changing hotkeys doesn't change what the help box says, so it can be misleading.
- --
- EXTENDED TUTORIAL FOR BUILD MODE. BUILD MODE IS SET ON LOOM BY DEFAULT,
- AND CANNOT BE CHANGED BY THE USER. This is advanced mode stuff, and
- editing it is not currently very newb-friendly.
- You must edit it manually for now.
- This only works on apple trees. You still need lumberjacking.
- How to Add an Item
- Edit it into the branch-crafts array. There are two possible ones right now,
- to make it easy to see examples. The first block in brackets is a loom (path b -> t -> l) and
- the second is a wicker basket (path b -> o -> w). The loom takes 15 sticks
- while the basket takes 9 (to allow destruction of it with a button-click).
- It takes 135000 milliseconds (135 seconds) to build all the sticks in the loom
- and 10000 milliseconds (10 seconds, but I guessed the build time so it's not
- accurate.
- Each loom uses 3 apples worth of hunger while a basket uses .2 apples worth
- (guessing on the basket hunger, again). Fractions ARE supported (will make five
- baskets and then eat one apple).
- The build button for the loom is 335 pixels from the top of the screen, and the one
- for the wicker basket is
- Branchpath is the item you want to build, relative to the branchcrafts array.
- 0 is the first element, which is the bracket block that represents a loom. 1 would
- be a wicker basket. If you add another item to the end of the array, your branchpath
- would be 2, and if you put it in front, your branchpath would be 0 (and then loom would
- be at position 1 if you wanted to build looms).
- How to Build
- 1. Find tree with some clear space to place a furniture item.
- 2. Place a partially-constructed item (same item as the one you want to make) as close
- to it as possible. Drop a branch in it or something so the post doesn't go away.
- 3. Walk (left-click) between the tree and your construction (by clicking on the
- construction post). Walk back and forth a few times, trying to click in the same
- place each time.
- 4. THIS IS THE MOST IMPORTANT STEP SO DON'T FUCK IT UP.
- If the view moves (as in, the tree and the post move to a different pixel
- location on your screen), then destroy the construction and make it somewhere
- closer or at a better angle or whatever, and go back to step 2.
- 5. Once you have a build post and an apple tree and can walk between the two
- without changing your view, hit F4 or whatever your hotkey of choice is to
- start the building macro.
- NOTE: If you deselect the autoit button, you will have to alt-tab to select it again
- or drag it somewhere you can see it and the target at the same time, or whatever. Do
- not use your mouse to click the OK button, because then it'll think the OK button
- was the place the tree or build site.
- 6. Place your mouse over where on the tree you were clicking, then hit enter.
- 7. Place your mouse over where on the build site you were clicking, and then
- hit enter.
- 8. THIS IS THE WEIRD PART. Now you should see a "starting now" message - DO NOT CLICK
- IT!!!!!. Instead, deconstruct the build post you put down.
- 9. Hit OK on the "starting now" button.
- 10. That's it.
- --
- HOW TO CHANGE HOTKEYS
- #ce ----------------------------------------------------------------------------
- #include <Math.au3>
- HotKeySet("{F1}", "help")
- HotKeySet("{F2}", "bark")
- HotKeySet("{F3}", "pause")
- HotKeySet("{F4}", "build")
- HotKeySet("{F6}", "configure")
- HotKeySet("{F7}", "haltToggle")
- HotKeySet("{F8}", "quit")
- #cs
- NEWBIE GUIDE FOR HOTKEY SETTING
- Possible user functions are: eat, bark, build, perma, clay
- Functions you shouldn't remove from the hotkey list are: help, configure, haltToggle, quit
- Pretend this is WoW and this is your skill bar, above. Right now, you have F1 - F8,
- and your skills are "help, eat, bark, etc", down the list. If you want to change your
- equipped skills, change the text on the right to the function you want. Skill descriptions
- are above in the comments, and also in the code.
- All the skills you know are below, as functions. Except for the utility functions, because
- that's like breathing, and you don't want to fuck with your breathing unless you know what
- you're doing.
- Useful macros are help, eat, configure, pause, haltToggle, and quit. Everything else is
- like, whatever, so feel free to mix and match (you probably shouldn't take off quit)
- It's possible to make F9-F11 hotkeys as well, but not always F12 (reserved by Windows), but
- you don't need that many anyways.
- #ce
- ; NOT configuration specs, must be hard-edited if at all
- 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
- Dim Const $branchCrafts[2][7] = [["t", "l", 15, 135000, 3.5, 335], ["o", "w", 9, 25000, .4, 200]]
- ; branchCrafts is hotkey path (after b), number of sticks, time constructing, apples to eat per item constructed, and
- ; y-coordinate of the center of the "build" button.
- $branchPath = 0 ; which stickcraft to make
- Dim Const $perm[2] = [1, 1] ; ratio of bark pieces gathered to apples eaten
- $mudDelay = 3000 ; time to get one piece of clay
- $appleDelay = 1000 ; time to get one apple
- $barkDelay = 500 ; time to get one piece of bark
- $branchDelay = 575 ; time to get one stick
- $invDelay = 400 ; time for inventory to load
- $actDelay = 70 ; time between generic actions
- $walkDelay = 2000 ; time moving to and from build site
- $stop = false ; stops the loop
- $override = -1 ;
- $count = -1
- $loadTime = 350 ;
- $pause = false;
- ; These are configuration specs and can be changed.
- $mealSize = 5 ; number of apples to eat at once
- $mudPath = 2 ; which mudcraft to make
- $drop = true ; drops crafted mud
- $invWidth = 4 ; number of free inventory columns
- $buy = true ;
- while True
- wait()
- WEnd
- Func help()
- $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.")
- $temp = String($temp & @CRLF & "Halt is " & $stop)
- MsgBox (0, "Help", $temp)
- EndFunc
- Func eat($override = -1)
- if ($override = -1) Then
- MsgBox (0, "Eating", "Eating now. Please place your mouse cursor over an apple tree.")
- WinActivate( "Haven and Hearth" )
- EndIf
- $pos = mouseGetPos()
- $x = $pos[0]
- $y = $pos[1]
- if $override <> -1 then
- $num = $override - 1
- else
- $num = $mealSize - 1
- endif
- ; grabs the number of apples
- for $i = 0 to $num
- if slowCheck() Then
- Return
- endIf
- mouseClick ( "right", $x, $y )
- sleep ($loadTime)
- mouseClick ( "right", $x + 40, $y)
- Sleep ($appleDelay + 50)
- Next
- ; opens inventory
- send ("{TAB}")
- sleep($invDelay)
- ; eats apples (and drops cores)
- for $i = 0 to ($num)
- if slowCheck() Then
- Return
- endIf
- $tx = 140 + mod($i, $invWidth) * 30
- $ty = 165 + floor($i/$invWidth) * 30
- mouseClick ( "right", $tx, $ty)
- sleep ($loadTime)
- mouseClick ( "right", $tx, $ty - 75)
- sleep ($actDelay)
- send( "{CTRLDOWN}" )
- mouseClick ( "left", $tx, $ty )
- sleep ($actDelay)
- send( "{CTRLUP}" )
- Next
- ; closes inventory
- send ("{TAB}")
- sleep($invDelay)
- mouseMove ($x, $y)
- EndFunc
- Func bark($count = -1)
- if ($count = -1) Then
- MsgBox (0, "Bark", "Gathering bark. Please place your mouse cursor over an apple tree.")
- WinActivate( "Haven and Hearth" )
- EndIf
- $pos = mouseGetPos()
- $x = $pos[0]
- $y = $pos[1]
- while $count <> 0
- if slowCheck() Then
- Return
- endIf
- ; gets bark
- mouseClick ( "right", $x, $y )
- sleep ($loadTime)
- mouseClick ( "right", $x + 75, $y)
- sleep ($barkDelay + 50)
- if $count > 0 then
- $count -= 1
- endif
- WEnd
- mouseMove ($x, $y)
- EndFunc
- Func perma()
- MsgBox (0, "Perma", "Starting long-term macro. Please place your mouse cursor over an apple tree.")
- WinActivate( "Haven and Hearth" )
- $pos = mouseGetPos()
- $x = $pos[0]
- $y = $pos[1]
- $count = 10
- While True
- if $count = 0 Then
- buy()
- $count = 10
- EndIf
- bark($perm[0])
- clear($perm[1])
- eat($perm[1])
- $count -= 1
- WEnd
- mouseMove ($x, $y)
- EndFunc
- Func clay()
- MsgBox (0, "Clay", "Crafting with clay. Please place your cursor over a clay pond.")
- WinActivate( "Haven and Hearth" )
- $pos = mouseGetPos()
- $x = $pos[0]
- $y = $pos[1]
- $numCreated = 0
- send ("{ESC}")
- sleep($actDelay)
- send ("{ESC}")
- sleep($actDelay)
- send ("c")
- sleep($actDelay)
- send ("m")
- sleep($actDelay)
- send ($mudCrafts[$mudPath][0])
- ; send ( "cm" & $mudCrafts[$mudPath][0] ) ; too fast?
- sleep($actDelay)
- $count = 100
- while true
- if slowCheck() Then
- Return
- endIf
- if $count = 0 Then
- buy()
- $count = 100
- EndIf
- ; Gathers clay
- mouseClick ("right", $x, $y)
- sleep ($loadTime)
- mouseClick ("right", $x, $y - 75)
- Sleep (($mudDelay * $mudCrafts[$mudPath][1]) +200)
- if slowCheck() Then
- Return
- endIf
- ; Crafts item
- mouseClick ("left", 635, 605)
- sleep ($mudCrafts[$mudPath][2])
- if slowCheck() Then
- Return
- endIf
- ; Drops item if drop is on
- if $drop Then
- send ("{TAB}")
- sleep ($invDelay)
- send ("{CTRLDOWN}")
- mouseClick ( "left", 140, 165)
- sleep ($actDelay)
- send( "{CTRLUP}" )
- send ("{TAB}")
- sleep ($invDelay)
- else
- $numCreated += 1
- endif
- ; Finishes if out of space
- if ($numCreated + $mudCrafts[$mudPath][1]) > (4 * $invWidth) then
- Return
- endif
- $count -= 1
- WEnd
- mouseMove ($x, $y)
- EndFunc
- Func build()
- MsgBox (0, "Part 1", "Crafting furniture. Please place your cursor over an appropriate apple tree.")
- WinActivate( "Haven and Hearth" )
- $hungerTracker = 0
- $pos = mouseGetPos()
- $treex = $pos[0]
- $treey = $pos[1]
- MsgBox (0, "Part 2", "Crafting furniture Please place your cursor over an APPROPRIATE build location.")
- WinActivate ( "Haven and Hearth" )
- $pos = mouseGetPos()
- $buildx = $pos[0]
- $buildy = $pos[1]
- $numBranches = _Min( $branchCrafts[$branchPath][2], $invWidth * 4)
- MsgBox (0, "Ready", "Deconstruct your build site if it is present, then hit okay.")
- WinActivate ( "Haven and Hearth" )
- $count = 10
- while true
- if slowCheck() Then
- Return
- endIf
- if $count = 0 Then
- buy()
- $count = 10
- EndIf
- ; gets branches
- mouseClick ( "left", $treex, $treey)
- sleep ($walkDelay)
- mouseClick ( "right", $treex, $treey)
- sleep ($loadTime)
- mouseClick ( "right", $treex + 50, $treey - 55)
- sleep ($branchDelay * $numBranches + 50)
- if slowCheck() Then
- Return
- EndIf
- ; makes build site
- send("{ESC}")
- sleep ($actDelay)
- send("{ESC}")
- sleep ($actDelay)
- send ("b")
- sleep ($actDelay)
- send ($branchCrafts[$branchPath][0])
- sleep ($actDelay)
- send ($branchCrafts[$branchPath][1])
- sleep ($actDelay)
- mouseClick ( "left", $buildx, $buildy)
- sleep ($actDelay)
- if slowCheck() Then
- Return
- EndIf
- ; shift-clicks the branches
- send ("{TAB}")
- sleep ($invDelay)
- send ("{SHIFTDOWN}")
- sleep ($actDelay)
- invClick($numBranches)
- send ("{SHIFTUP}")
- sleep ($actDelay)
- send ("{TAB}")
- sleep ($invDelay)
- ; builds
- mouseClick ( "left", 410, $branchCrafts[$branchPath][5])
- sleep ($branchCrafts[$branchPath][3])
- if slowCheck() Then
- Return
- endIf
- ; destroys
- mouseClick ( "left", 350, $branchCrafts[$branchPath][5])
- sleep ($actDelay)
- mouseClick( "left", $treex, $treey)
- sleep ($walkDelay)
- mouseMove ($treex, $treey)
- ; eats if necessary
- $hungerTracker += $branchCrafts[$branchPath][4]
- if $hungerTracker >= 1 Then
- eat(floor($hungerTracker))
- $hungerTracker -= floor($hungerTracker)
- endif
- $count -= 1
- WEnd
- EndFunc
- Func configure()
- $num = InputBox ( "Meal size", "How many apples do you want to eat at once?", $mealSize)
- if @error <> 0 or not StringIsInt($num) Then
- MsgBox (0, "AutoIt", "Invalid count")
- return
- endif
- $num = Number($num)
- $mealSize = $num
- MsgBox ( 0, "Meal Size", "Your meal size is " & $num)
- $t1 = String("What clay item do you want to make?" & @CRLF & "1. jar" & @CRLF & "2. mug")
- $t1 = String($t1 & @CRLF & "3. tea pot" & @CRLF & "4. treeplanter's pot")
- $temp = InputBox ( "Clay Item", $t1, $mudPath + 1)
- if @error <> 0 or not StringIsInt ($temp) then
- MsgBox (0, "AutoIt", "Invalid hotkey")
- return
- endif
- $mudPath = mod((Number($temp) - 1), 4)
- $temp = InputBox ( "Drop Clay Item?", "Do you want to drop them? y/n", "y")
- if @error <> 0 or (not StringInStr ( "yn", $temp) and StringLen ($temp) = 1) then
- MsgBox (0, "AutoIt", "Invalid hotkey")
- return
- endif
- if stringCompare($temp, "y") = 0 then
- $drop = true
- else
- $drop = false
- endif
- MsgBox ( 0, "Drop items", "You are making hotkey " & $mudCrafts[$mudPath][0] & " and your drop value is: " & $drop)
- $temp = InputBox ( "Inventory Width?", "How many empty columns do you have in your inventory?", $invWidth)
- if @error <> 0 or not StringIsInt($temp) Then
- MsgBox (0, "AutoIt", "Invalid number")
- return
- endif
- $temp = Number($temp)
- $invWidth = $temp
- MsgBox ( 0, "Free space", "Your number of free columns is " & $invWidth)
- $temp = InputBox ( "Save Character", "Do you want to save your character regularly? y/n", "n")
- if @error <> 0 or (not StringInStr ( "yn", $temp) and StringLen ($temp) = 1) then
- MsgBox (0, "AutoIt", "Invalid hotkey")
- return
- endif
- if stringCompare($temp, "y") = 0 then
- $buy = true
- else
- $buy = false
- endif
- MsgBox ( 0, "Buy", "Your buy toggle is: " & $buy)
- EndFunc
- Func haltToggle()
- msgBox( 0, "Halt", "Halt toggled to " & not $stop)
- $stop = not $stop
- EndFunc
- Func pause()
- $pause = true
- EndFunc
- Func quit()
- Exit(0)
- EndFunc
- ; Utility functions~
- Func clear($num)
- ; stores the old positions
- $pos = mouseGetPos()
- $x = $pos[0]
- $y = $pos[1]
- ; drops $num items from inventory (only uses specified cols)
- if $num > ($invWidth*4) Then
- $num = $invWidth*4
- EndIf
- send("{TAB}")
- sleep($invDelay)
- send ("{CTRLDOWN}")
- invClick($num)
- send ("{CTRLUP}")
- send("{TAB}")
- sleep($invDelay)
- mouseMove($x, $y)
- EndFunc
- ; leftclicks first $num items in inventory (does not open inventory)
- Func invClick($num)
- for $i = 0 to ($num - 1)
- if slowCheck() then
- return
- endif
- $tx = 140 + mod($i, $invWidth) * 30
- $ty = 165 + floor($i/$invWidth) * 30
- mouseClick ( "left", $tx, $ty )
- sleep ($actDelay)
- Next
- endFunc
- ; waits for user input
- Func wait()
- while true
- sleep (100)
- wend
- endFunc
- Func slowCheck()
- if $stop then
- return true
- endif
- if $pause Then
- MsgBox (0, "Paused", "Pausing. Hit OK to resume, F7 to end function at the next opportunity, or F8 to exit the script.")
- $pause = false
- WinActivate ( "Haven and Hearth")
- return false
- EndIf
- EndFunc
- Func buy()
- if $buy Then
- mouseClick( "left", 460, 470)
- sleep (500)
- mouseClick( "left", 425, 290)
- sleep ($actDelay)
- mouseClick ( "left", 460, 470)
- sleep (500)
- EndIf
- EndFunc
Add Comment
Please, Sign In to add comment