Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.78 KB | None | 0 0
  1. -----------------SCRIPT MADE BY @Froostiin----------------
  2. ---------------------MAMMOTH AND BADGER-------------------
  3. -----------------------START AT DEPOT---------------------
  4. local minCap = 30       -- Minimum capacity to keep hunting.
  5. local BPActive = false  -- Wanna hunt without loot anything? So put this false and when the script reset BP it will just open the main BP to put mana pot and rings/soft.
  6. local LootBP = "Blue Backpack"  -- Backpack that will carry loots.
  7. local GoldBP = "Brocade Backpack"       -- Backpack that will carry gold.
  8.  
  9. local Rings = true -- Wanna use any ring to hunt? If yes put true, elseif put false
  10. local BPRingDP = "Beach Backpack" -- Need to be different than all the other bps | BP where the rings are in DP
  11. local ringID = 3098 -- ID of ring
  12. local ringmin = 1 -- Minimum of rings in your bp
  13. local ringmax = 5 -- Number of rings that you will take on DP BP
  14.        
  15. local Soft = true -- Wanna use softboots auto refiller? if yes put true, if not put false
  16.  
  17. local StackDP = 0       -- Slot of BP that will be Stackable Items.
  18. local RareDP = 1        -- Slot of BP that will be Non-Stackable Items.
  19.  
  20. local mpID = 268        -- Mana Potion ID.
  21. local minMP = 25        -- If less then script will exit spawn.
  22. local buyMP = 100       -- Amount of MPs to buy.
  23. local costMP = 50       -- Potion Price.
  24.  
  25. local hpID = 266        -- Health Potion ID.
  26. local minHP = 10        -- If less then script will exit spawn.
  27. local buyHP = 20        -- Amount of HPs to buy.
  28. local costHP = 45       -- Potion Price.
  29. local brokesoft = 6530
  30. local brokesoftmin = 0
  31.  
  32.  
  33. registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
  34. print ([[
  35. Mammoth and Badger Svargrond by @Froostiin for Knights]])
  36. wait(2000)
  37. function onWalkerSelectLabel(labelName)
  38.         if (labelName == "CheckSupplies") then
  39.             if ((Self.ItemCount(mpID) > minMP) and (Self.Cap() > minCap) and (Self.ItemCount(hpID) > minHP) and (Self.ItemCount(ringID) > ringmin)) then
  40.                     if (Soft and Self.ItemCount(6530) > 0) then
  41.                         gotoLabel("RefillSoft")
  42.                     end
  43.             else
  44.                     gotoLabel("Start")
  45.             end
  46.                
  47.         elseif (labelName == "RefillSoft") then
  48.             setWalkerEnabled(false)
  49.         elseif (labelName == "DepositGold") then
  50.                 local cashMP = costMP*(buyMP-Self.ItemCount(mpID))
  51.                 local cashHP = costHP*(buyHP-Self.ItemCount(hpID))
  52.                 setWalkerEnabled(false)
  53.                 Self.SayToNpc({"hi", "deposit all", "yes"}, 65, 10)
  54.                 if (cashMP > 0) then
  55.                         Self.SayToNpc({"withdraw " .. cashMP, "yes"}, 65)
  56.                         wait(700,1000)
  57.                 end
  58.                 if (cashHP > 0) then
  59.                         Self.SayToNpc({"withdraw " .. cashHP, "yes"}, 65)
  60.                         wait(700,1000)
  61.                 end
  62.                 Self.SayToNpc({"balance", "bye"}, 65,5)
  63.                 setWalkerEnabled(true)
  64.         elseif (labelName == "DepositItems") then
  65.                 setWalkerEnabled(false)
  66.                 wait(1900,2400)
  67.                 Self.ReachDepot()
  68.                 Self.DepositItems({7432, 1}, {3443, 1}, {10307, 0}, {10321, 0}, {10299, 0}, {10296, 0}, {7381, 2})
  69.                 wait(1500,1900)
  70.                 setWalkerEnabled(true)
  71.         elseif (labelName == "BuyManas") then
  72.                 setWalkerEnabled(false)
  73.                 Self.SayToNpc({"hi"}, 65)
  74.                 wait(700,1000)
  75.                 while ((Self.ItemCount(283)+Self.ItemCount(284)+Self.ItemCount(285)) > 0) do
  76.                         Self.SayToNpc({"vials", "yes", "yes"}, 65, 10)
  77.                         wait(1200,1500)
  78.                 end
  79.                 Self.SayToNpc({"trade"}, 65)
  80.                 wait(1500,3000)
  81.                 while (Self.ItemCount(mpID) < buyMP) do
  82.                         Self.ShopBuyItemsUpTo(mpID, buyMP)
  83.                         wait(500,900)
  84.                 end
  85.                 while (Self.ItemCount(hpID) < buyHP) do
  86.                         Self.ShopBuyItemsUpTo(hpID, buyHP)
  87.                         wait(500,900)
  88.                 end
  89.                 Self.SayToNpc({"bye"}, 65)
  90.                 setWalkerEnabled(true)
  91.         elseif (labelName == "ResetBps") then
  92.                 if (BPActive) then
  93.                         local backpack1, backpack2 = Container.GetByName(LootBP), Container.GetByName(GoldBP)
  94.                         setWalkerEnabled(false)
  95.                         Self.CloseContainers()
  96.                         repeat
  97.                                 wait(900)
  98.                         until (Self.UseItemFromEquipment("backpack") > 0)
  99.                         wait (1000)
  100.                         Container.GetFirst():OpenChildren(Item.GetID(LootBP), Item.GetID(GoldBP))
  101.                         if (backpack1:isOpen() == false or backpack2:isOpen() == false) then
  102.                                 gotoLabel("ResetBps")
  103.                         end
  104.                         else
  105.                         setWalkerEnabled(false)
  106.                         Self.CloseContainers()
  107.                         Self.OpenMainBackpack(true)
  108.                 end
  109.                 setWalkerEnabled(true)
  110.         elseif (labelName == "CheckSupplies2") then
  111.                 if (Self.ItemCount(mpID) > minMP) and (Self.Cap() > minCap) and (Self.ItemCount(hpID) > minHP) and (soft and Self.ItemCount(6530) < 1) and (Rings and Self.ItemCount (ringID) > ringmin) then
  112.                         gotoLabel("Hunt")
  113.                         elseif gotoLabel("GoDP") then
  114.                 end
  115.         end
  116. end
  117.  
  118. --==## FUNCTIONS ##==--
  119.  
  120. Self.ReachDepot = function (tries)
  121.         local tries = tries or 3
  122.         Walker.Stop()
  123.         local DepotIDs = {3497, 3498, 3499, 3500}
  124.         local DepotPos = {}
  125.         for i = 1, #DepotIDs do
  126.                 local dps = Map.GetUseItems(DepotIDs[i])
  127.                 for j = 1, #dps do
  128.                         table.insert(DepotPos, dps[j])
  129.                 end
  130.         end
  131.         local function gotoDepot()
  132.                 local pos = Self.Position()
  133.                 print("Depots found: " .. tostring(#DepotPos))
  134.                 for i = 1, #DepotPos do
  135.                         location = DepotPos[i]
  136.                         Self.UseItemFromGround(location.x, location.y, location.z)
  137.                         wait(1000, 2000)
  138.                         if Self.DistanceFromPosition(pos.x, pos.y, pos.z) >= 1 then
  139.                                 wait(5000, 6000)
  140.                                 if Self.DistanceFromPosition(location.x, location.y, location.z) == 1 then
  141.                                         Walker.Start()
  142.                                         return true
  143.                                 end
  144.                         else
  145.                                 print("Something is blocking the path. Trying next depot.")
  146.                         end
  147.                 end
  148.                 return false
  149.         end
  150.        
  151.         repeat
  152.                 reachedDP = gotoDepot()
  153.                 if reachedDP then
  154.                         return true
  155.                 end
  156.                 tries = tries - 1
  157.                 sleep(100)
  158.                 print("Attempt to reach depot was unsuccessfull. " .. tries .. " tries left.")
  159.         until tries <= 0
  160.         return false
  161.        
  162. end
  163.  
  164. Map.GetUseItems = function (id)
  165.     if type(id) == "string" then
  166.         id = Item.GetID(id)
  167.     end
  168.     local pos = Self.Position()
  169.         local store = {}
  170.     for x = -7, 7 do
  171.         for y = -5, 5 do
  172.             if Map.GetTopUseItem(pos.x + x, pos.y + y, pos.z).id == id then
  173.                 itemPos = {x = pos.x + x, y = pos.y + y, z = pos.z}
  174.                                 table.insert(store, itemPos)
  175.             end
  176.         end
  177.     end
  178.     return store
  179. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement