SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -----SETTINGS--------------------------------------------------------------
  2. --POTIONS--
  3. local ManaID = 268 --- Which mana potions are you using?
  4. local MinMana = 300 --- How many mana potions until you leave the hunt.
  5. local MaxMana = 1600 --- How many mana potions you begin the hunt with.
  6. local ManaPrice = 50 --- What is the price of your selected mana potions?
  7. local HealthID = 23375 --- Which health potions are you using?
  8. local MinHealth = 100 --- How many health potions until you leave the hunt.
  9. local MaxHealth = 360 --- How many health potions you begin the hunt with.
  10. local HealthPrice = 310 --- What is the price of your selected mana potions?
  11. local AmmoID = 16141 --- Wchich ammo are you using?
  12. local MinAmmo = 100 --- How many ammo until you leave the hunt.
  13. local MaxAmmo = 400 --- How many ammo you begin the hunt with.
  14. local AmmoPrice = 100 --- What is the price of your selected ammo?
  15.  
  16. --CAP--
  17. local MinCap = 1 --- Leaves spawn when character reaches this cap.
  18.  
  19.  
  20. -- Backpack Configuration:
  21.  
  22. local LootBP = "Grey Backpack"
  23. local GoldBP = "Yellow Backpack"
  24.  
  25. -- Spawn Options
  26.  
  27. local HuntMiddle = false
  28.  
  29. -- These are the flask IDs, not worth changing since it will sell all flasks regardless of type.
  30. local FlaskID = 283
  31. local FlaskIDA = 284
  32. local FlaskIDB = 285
  33.  
  34. -- local GoldBP = 5801 --- Item ID of your gold backpack.
  35.  
  36. registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
  37.  
  38. function onWalkerSelectLabel(labelName)
  39.     if (labelName == "Checker") then
  40.         -- Check Supplies, Hunt or Leave
  41.         Walker.ConditionalGoto((Self.ItemCount(ManaID) <= MinMana) or (Self.Cap() < MinCap) or (Self.ItemCount(HealthID) <= MinHealth) or (Self.ItemCount(AmmoID) <= MinAmmo), "Leave", "BeginHunt")
  42.  
  43.     elseif (labelName == "Start") then
  44.         Walker.ConditionalGoto((Self.Position().z == 11), "BeginHunt", "ReachDepot")
  45.    
  46.     elseif (labelName == "DepositGold") then
  47.         -- Deposit Gold, check balance.
  48.         Walker.Stop()
  49.         Self.SayToNpc({"hi", "deposit all", "yes"}, 100)
  50.  
  51.         local withdrawManas = math.max(MaxMana - Self.ItemCount(ManaID), 0)*ManaPrice
  52.         local withdrawHealths = math.max(MaxHealth - Self.ItemCount(HealthID), 0)*HealthPrice
  53.         local withdrawAmmo = math.max(MaxAmmo - Self.ItemCount(AmmoID), 0)*AmmoPrice
  54.         local total = math.abs(withdrawManas + withdrawHealths + withdrawAmmo)
  55.  
  56.         if total >= 1 then
  57.             Self.SayToNpc({"withdraw " .. total, "yes", "balance"}, 100)
  58.         end
  59.         Walker.Start()
  60.  
  61.     elseif (labelName == "DepositItems") then
  62.         -- Deposit Items
  63.         Walker.Stop()
  64.         Self.ReachDepot(5)
  65.         Self.DepositItems({268, 1}, {6499, 1}, {5889, 1}, {5887, 1}, {11457, 1}, {3724, 1}, {5877, 1}, {3061, 1})
  66.         Self.DepositItems({7367, 0}, {3371, 0}, {2958, 0}, {7399, 0}, {3332, 0}, {3416, 0}, {3554, 0}, {3369, 0}, {7452, 0}, {9056, 0}, {7421, 0} )
  67.         Walker.Start()
  68.  
  69.     elseif (labelName == "BuyManas") then
  70.         -- Buy Mana Potions
  71.         Walker.Stop()
  72.         if (Self.ItemCount(ManaID) < MaxMana) or (Self.ItemCount(HealthID) < MaxHealth) then
  73.             print("Buying manas or healths")
  74.             Self.SayToNpc({"hi", "flasks"}, 100)
  75.             while (Self.ItemCount(FlaskID) >= 1) or (Self.ItemCount(FlaskIDA) >= 1) or (Self.ItemCount(FlaskIDB) >= 1) do
  76.                 Self.SayToNpc("yes", 100)
  77.             end
  78.             wait(2000)
  79.             Self.SayToNpc("trade", 100)
  80.             wait(2000)
  81.             while (Self.ItemCount(ManaID) < MaxMana) do
  82.                 Self.ShopBuyItemsUpTo(ManaID, MaxMana)
  83.                 wait(500,800)
  84.             end
  85.             if (Self.ItemCount(HealthID) < MaxHealth) then
  86.                 Self.ShopBuyItemsUpTo(HealthID, MaxHealth)
  87.                 wait(500)
  88.             end
  89.             wait(200, 500)
  90.         end
  91.         Walker.Start()
  92.  
  93.     elseif (labelName == "CheckGoneUp") then
  94.         -- Check we're on floor 3
  95.         Walker.ConditionalGoto((Self.Position().z == 7), "OpenSouth", "Leave")
  96.  
  97.     elseif (labelName == "CheckGoneDown") then
  98.         -- Check we're on floor 7
  99.         Walker.ConditionalGoto((Self.Position().z == 11), "AmDown", "EnterResp")
  100.      
  101.     elseif (labelName == "BuySpears") then
  102.             --------------------------------- TODO -------------------------
  103.         Walker.Stop()
  104.         Self.SayToNpc({"hi", "trade"}, 100)
  105.         -- Buy spears, make sure Self.ItemCount returns items in hands.
  106.         while (Self.ItemCount(AmmoID) < MaxAmmo) do
  107.             Self.ShopBuyItemsUpTo(AmmoID, MaxAmmo)
  108.             wait(500,800)
  109.         end
  110.         Walker.Start()
  111.  
  112.         elseif (labelName == "Check1") then
  113.         setWalkerEnabled(false)
  114.     if (Self.Cap() > MinCap and Self.ItemCount(ManaID) > MinMana) and (Self.ItemCount(HealthID) > MinHealth) and (Self.Stamina() > 840) then
  115.                 print("**Expienie Wznowione !**")
  116.                             setWalkerEnabled(true)
  117.         else
  118.             gotoLabel("Refill")
  119.                 print("**Wracam Do Miasta !**")
  120.             setWalkerEnabled(true)
  121.                 end
  122.    
  123.     elseif (labelName == "ResetBps") then
  124.         -- Reset Backpacks
  125.         Walker.Stop()
  126.         Self.CloseContainers()
  127.         Self.OpenMainBackpack(true):OpenChildren({LootBP, true}, {GoldBP, true})
  128.         Container.GetFirst():Minimize()
  129.         Walker.Start()
  130.  
  131.     elseif (labelName == "OpenNorth") then
  132.         Walker.Stop()
  133.         Self.UseItemFromGround(Self.Position().x, Self.Position().y - 1, Self.Position().z)
  134.         Walker.Start()
  135.  
  136.     elseif (labelName == "OpenSouth") then
  137.         Walker.Stop()
  138.         Self.UseItemFromGround(Self.Position().x, Self.Position().y + 1, Self.Position().z)
  139.         Walker.Start()
  140.  
  141.     elseif (labelName == "MiddleSpawn") then
  142.         Walker.Stop()
  143.         Walker.ConditionalGoto(HuntMiddle, "MiddleGo", "MiddleDone")
  144.         Walker.Start()
  145.     end
  146.    
  147. end
  148.  
  149. Self.ReachDepot = function (tries)
  150.     local tries = tries or 3
  151.     Walker.Stop()
  152.     local DepotIDs = {3497, 3498, 3499, 3500}
  153.     local DepotPos = {}
  154.     for i = 1, #DepotIDs do
  155.         local dps = Map.GetUseItems(DepotIDs[i])
  156.         for j = 1, #dps do
  157.             table.insert(DepotPos, dps[j])
  158.         end
  159.     end
  160.     local function gotoDepot()
  161.         local pos = Self.Position()
  162.         print("Depots found: " .. tostring(#DepotPos))
  163.         for i = 1, #DepotPos do
  164.             location = DepotPos[i]
  165.             Self.UseItemFromGround(location.x, location.y, location.z)
  166.             wait(1000, 2000)
  167.             if Self.DistanceFromPosition(pos.x, pos.y, pos.z) >= 1 then
  168.                 wait(5000, 6000)
  169.                 if Self.DistanceFromPosition(location.x, location.y, location.z) == 1 then
  170.                     Walker.Start()
  171.                     return true
  172.                 end
  173.             else
  174.                 print("Something is blocking the path. Trying next depot.")
  175.             end
  176.         end
  177.         return false
  178.     end
  179.    
  180.     repeat
  181.         reachedDP = gotoDepot()
  182.         if reachedDP then
  183.             return true
  184.         end
  185.         tries = tries - 1
  186.         sleep(100)
  187.         print("Attempt to reach depot was unsuccessfull. " .. tries .. " tries left.")
  188.     until tries <= 0
  189.  
  190.     return false
  191. end
  192.  
  193. Map.GetUseItems = function (id)
  194.     if type(id) == "string" then
  195.         id = Item.GetID(id)
  196.     end
  197.     local pos = Self.Position()
  198.     local store = {}
  199.     for x = -7, 7 do
  200.         for y = -5, 5 do
  201.             if Map.GetTopUseItem(pos.x + x, pos.y + y, pos.z).id == id then
  202.                 itemPos = {x = pos.x + x, y = pos.y + y, z = pos.z}
  203.                 table.insert(store, itemPos)
  204.             end
  205.         end
  206.     end
  207.     return store
  208. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top