|
Post by crowface28 on May 14, 2021 19:41:49 GMT
--[[ Fully automated harvesting script. Needs to be customized for your uses.
MoveEx() - gets you to a spot reliably. dropoff() - casts Gate to get you to your dropoff spot and back and NOT mess up the current "rail" of harvesting defend() - if attacked, it'll move away, make pets attack, and spam fireball. Once done, it'll move back and equip hatchet again. Customize how you need it. doTree() - harvests tree, uses prospect tool, and watches for mobs. Will move on after backpack weight stops increasing. X, Y and Z decimal separator must be a comma and values must be sent as strings e.g. doTree("420,0", "420,1", "420,2") ]]--
gateToHouseKey = 30 -- key to cast gate to dropoff location dropoffBoxId = 12345 attackSpellKey = 11
function Equip(item) -- stole this from utils.lua FindItem(item) local tool_id = FINDITEM[1].ID local cont_id = FINDITEM[1].CNTID if tool_id == nil or tool_id == "N/A" then print(item .. " not found!") return end if tostring(cont_id) == tostring(CHARID) then print(item .. " already equipped!") return end print("Equipping " .. item) ContextMenu(tool_id, "Equip") end
function round(num, numDecimalPlaces) local mult = 10^(numDecimalPlaces or 0) return math.floor(num * mult + 0.5) / mult end
function MoveEx(x,y,z) -- starts you moving towards coordinates and waits until you're there before continuing print("moving to: "..x..","..z.."...") count = 0 newX = CHARPOSX newZ = CHARPOSZ repeat count = count + 1 if (x > newX) and (x - newX > 10) then newX = newX + 5 elseif (x < newX) and (newX - x > 10) then newX = newX - 5 else newX = x end if (z > newZ) and (z - newZ > 10) then newZ = newZ + 5 elseif (z < newZ) and (newZ - z > 10) then newZ = newZ - 5 else newZ = z end Move(newX,y,newZ) sleep(1000) until (round(CHARPOSX, 1) == round(x, 1) and round(CHARPOSZ, 1) == round(z, 1)) or count > 40 print("arrived at location...") end
function dropoff() print('dropping off...') panel = "notFound" repeat Macro(gateToHouseKey) -- this is casting gate from a hotkey to my house sleep(4000) FindPanel("Moongate") if FINDPANEL then panel = "found" end until panel == "found" panelId = FINDPANEL[1].ID ClickButton(FINDPANEL[1].ID, "0") -- "0" is the confirmation to travel button sleep(3000) FindItem("Logs",tonumber(BACKPACKID)) -- finds all logs in my backpack if FINDITEM then for item in FINDITEM do Drag(item.ID) Dropc(dropoffBoxId) -- and drops them in a chest at my house sleep(500) end end FindItem("Kindling",tonumber(BACKPACKID)) -- moves kindling if FINDITEM then Drag(FINDITEM[1].ID) Dropc(dropoffBoxId) sleep(500) end FindItem("Apple",tonumber(BACKPACKID)) -- and apples if FINDITEM then Drag(FINDITEM[1].ID) Dropc(dropoffBoxId) sleep(500) end FindItem("Portal") -- and travels back through the moongate UseSelected(FINDITEM[1].ID) sleep(1000) FindPanel("Moongate") ClickButton(FINDPANEL[1].ID, "0") sleep(3000) Equip("Hatchet") -- don't forget to re-equip your hatchet! end function defend() if HEALTH < 70 then Macro(1) sleep(1500) TargetSelf() end while MONSTERSNEARBY == true do -- if a monster is within maybe 5 units, local x = CHARPOSX local y = CHARPOSY local z = CHARPOSZ mId = NEARBYMONSTERS[1].ID Move(x-7,y,z) -- run away a bit sleep(1000) Say('all follow me') -- get your pets with you sleep(1000) Say('all kill') TargetDynamic(mId) -- make the pets attack mob (stupid boglings!) for i=1,10 do Macro(attackSpellKey) -- fireball on my hotbar sleep(500) TargetDynamic(mId) end print('mob hopefully dead') Equip("hatchet") -- re-equip yourself! MoveEx(x,y,z) FindPermanent("Tree") -- and re-engage the tree Macro(28) sleep(500) TargetPermanent(FINDPERMANENT[1].ID) end end
function doTree(x,y,z) Equip("Hatchet") MoveEx(x,y,z) FindPermanent("Tree") -- find all trees closestId = FINDPERMANENT[1].ID -- finds the closest one print('At spot with x/z: ' .. x .. ',' .. z) Macro(28) -- the 'q' key sleep(500) TargetPermanent(closestId) print('whacking tree') sleep(1000) repeat FindPermanent("tree") defend() -- checks for nearby monsters and defends FindItem("prospector", BACKPACKID) if FINDITEM then prospectId = FINDITEM[1].ID UseSelected(prospectId) -- uses prospecting tool from pack on tree TargetPermanent(closestId) end sleep(4000) until FINDPERMANENT[1].TREESTATE == 1 -- will move to next tree if, within 4 seconds-ish, weight didn't change (as in the tree is gone) if CHARWEIGHT > 300 then -- getting full, dropoff time! dropoff() end end
while true do Macro(33) sleep(4000) doTree(555.771, 44.61951, 333.8499) doTree(666.771, 54.61951, 222.8499) ... end
|
|