Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.83 KB | None | 0 0
  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. -- Here I'm gonna get the item ids, leave this as it is.
  30.  
  31. local ManaID = Item.GetID(ManaName)
  32. local HealthID = Item.GetID(HealthName)
  33. local AmmoID = Item.GetID(AmmoName)
  34.  
  35. -- These are the flask IDs, not worth changing since it will sell all flasks regardless of type.
  36. local FlaskID = 283
  37. local FlaskIDA = 284
  38. local FlaskIDB = 285
  39.  
  40. -- local GoldBP = 5801 --- Item ID of your gold backpack.
  41.  
  42. registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
  43.  
  44. function onWalkerSelectLabel(labelName)
  45.     if (labelName == "Checker") then
  46.         -- Check Supplies, Hunt or Leave
  47.         Walker.ConditionalGoto((Self.ItemCount(ManaID) <= MinMana) or (Self.Cap() < MinCap) or (Self.ItemCount(HealthID) <= MinHealth) or (Self.ItemCount(AmmoID) <= MinAmmo), "Leave", "BeginHunt")
  48.  
  49.     elseif (labelName == "Start") then
  50.         Walker.ConditionalGoto((Self.Position().z == 11), "BeginHunt", "ReachDepot")
  51.    
  52.     elseif (labelName == "DepositGold") then
  53.         -- Deposit Gold, check balance.
  54.         Walker.Stop()
  55.         Self.SayToNpc({"hi", "deposit all", "yes"}, 100)
  56.  
  57.         local withdrawManas = math.max(BuyMana - Self.ItemCount(ManaID), 0)*ManaPrice
  58.         local withdrawHealths = math.max(BuyHealth - Self.ItemCount(HealthID), 0)*HealthPrice
  59.         local withdrawAmmo = math.max(BuyAmmo - Self.ItemCount(AmmoID), 0)*AmmoPrice
  60.         local total = math.abs(withdrawManas + withdrawHealths + withdrawAmmo)
  61.  
  62.         if total >= 1 then
  63.             Self.SayToNpc({"withdraw " .. total, "yes", "balance"}, 100)
  64.         end
  65.         Walker.Start()
  66.  
  67.     elseif (labelName == "DepositItems") then
  68.         -- Deposit Items
  69.         Walker.Stop()
  70.         Self.ReachDepot(5)
  71.         Self.DepositItems({268, 1}, {6499, 1}, {5889, 1}, {5887, 1}, {11457, 1}, {3724, 1}, {5877, 1}, {3061, 1})
  72.         Self.DepositItems({7367, 0}, {3371, 0}, {2958, 0}, {7399, 0}, {3332, 0}, {3416, 0}, {3554, 0}, {3369, 0}, {7452, 0}, {9056, 0}, {7421, 0} )
  73.         Walker.Start()
  74.  
  75.     elseif (labelName == "BuyManas") then
  76.         -- Buy Mana Potions
  77.         Walker.Stop()
  78.         if (Self.ItemCount(ManaID) < BuyMana) or (Self.ItemCount(HealthID) < BuyHealth) then
  79.             print("Buying manas or healths")
  80.             Self.SayToNpc({"hi", "flasks"}, 100)
  81.             while (Self.ItemCount(FlaskID) >= 1) or (Self.ItemCount(FlaskIDA) >= 1) or (Self.ItemCount(FlaskIDB) >= 1) do
  82.                 Self.SayToNpc("yes", 100)
  83.             end
  84.             wait(2000)
  85.             Self.SayToNpc("trade", 100)
  86.             wait(2000)
  87.             while (Self.ItemCount(ManaID) < BuyMana) do
  88.                 Self.ShopBuyItemsUpTo(ManaID, BuyMana)
  89.                 wait(500,800)
  90.             end
  91.             if (Self.ItemCount(HealthID) < BuyHealth) then
  92.                 Self.ShopBuyItemsUpTo(HealthID, BuyHealth)
  93.                 wait(500)
  94.             end
  95.             wait(200, 500)
  96.         end
  97.         Walker.Start()
  98.  
  99.     elseif (labelName == "CheckGoneUp") then
  100.         -- Check we're on floor 3
  101.         Walker.ConditionalGoto((Self.Position().z == 7), "OpenSouth", "Leave")
  102.  
  103.     elseif (labelName == "CheckGoneDown") then
  104.         -- Check we're on floor 7
  105.         Walker.ConditionalGoto((Self.Position().z == 11), "AmDown", "EnterResp")
  106.      
  107.     elseif (labelName == "BuySpears") then
  108.             --------------------------------- TODO -------------------------
  109.         Walker.Stop()
  110.         Self.SayToNpc({"hi", "trade"}, 100)
  111.         -- Buy spears, make sure Self.ItemCount returns items in hands.
  112.         while (Self.ItemCount(AmmoID) < BuyAmmo) do
  113.             Self.ShopBuyItemsUpTo(AmmoID, BuyAmmo)
  114.             wait(500,800)
  115.         end
  116.         Walker.Start()
  117.  
  118.         elseif (labelName == "Check1") then
  119.         setWalkerEnabled(false)
  120.     if (Self.Cap() > MinCap and Self.ItemCount(ManaID) > MinMana) and (Self.ItemCount(HealthID) > MinHealth) and (Self.Stamina() > 840) then
  121.                 print("**Expienie Wznowione !**")
  122.                             setWalkerEnabled(true)
  123.         else
  124.             gotoLabel("Refill")
  125.                 print("**Wracam Do Miasta !**")
  126.             setWalkerEnabled(true)
  127.                 end
  128.    
  129.     elseif (labelName == "ResetBps") then
  130.         -- Reset Backpacks
  131.         Walker.Stop()
  132.         Self.CloseContainers()
  133.         Self.OpenMainBackpack(true):OpenChildren({LootBP, true}, {GoldBP, true})
  134.         Container.GetFirst():Minimize()
  135.         Walker.Start()
  136.  
  137.     elseif (labelName == "OpenNorth") then
  138.         Walker.Stop()
  139.         Self.UseItemFromGround(Self.Position().x, Self.Position().y - 1, Self.Position().z)
  140.         Walker.Start()
  141.  
  142.     elseif (labelName == "OpenSouth") then
  143.         Walker.Stop()
  144.         Self.UseItemFromGround(Self.Position().x, Self.Position().y + 1, Self.Position().z)
  145.         Walker.Start()
  146.  
  147.     elseif (labelName == "MiddleSpawn") then
  148.         Walker.Stop()
  149.         Walker.ConditionalGoto(HuntMiddle, "MiddleGo", "MiddleDone")
  150.         Walker.Start()
  151.     end
  152.    
  153. end
  154.  
  155. Self.ReachDepot = function (tries)
  156.     local tries = tries or 3
  157.     Walker.Stop()
  158.     local DepotIDs = {3497, 3498, 3499, 3500}
  159.     local DepotPos = {}
  160.     for i = 1, #DepotIDs do
  161.         local dps = Map.GetUseItems(DepotIDs[i])
  162.         for j = 1, #dps do
  163.             table.insert(DepotPos, dps[j])
  164.         end
  165.     end
  166.     local function gotoDepot()
  167.         local pos = Self.Position()
  168.         print("Depots found: " .. tostring(#DepotPos))
  169.         for i = 1, #DepotPos do
  170.             location = DepotPos[i]
  171.             Self.UseItemFromGround(location.x, location.y, location.z)
  172.             wait(1000, 2000)
  173.             if Self.DistanceFromPosition(pos.x, pos.y, pos.z) >= 1 then
  174.                 wait(5000, 6000)
  175.                 if Self.DistanceFromPosition(location.x, location.y, location.z) == 1 then
  176.                     Walker.Start()
  177.                     return true
  178.                 end
  179.             else
  180.                 print("Something is blocking the path. Trying next depot.")
  181.             end
  182.         end
  183.         return false
  184.     end
  185.    
  186.     repeat
  187.         reachedDP = gotoDepot()
  188.         if reachedDP then
  189.             return true
  190.         end
  191.         tries = tries - 1
  192.         sleep(100)
  193.         print("Attempt to reach depot was unsuccessfull. " .. tries .. " tries left.")
  194.     until tries <= 0
  195.  
  196.     return false
  197. end
  198.  
  199. Map.GetUseItems = function (id)
  200.     if type(id) == "string" then
  201.         id = Item.GetID(id)
  202.     end
  203.     local pos = Self.Position()
  204.     local store = {}
  205.     for x = -7, 7 do
  206.         for y = -5, 5 do
  207.             if Map.GetTopUseItem(pos.x + x, pos.y + y, pos.z).id == id then
  208.                 itemPos = {x = pos.x + x, y = pos.y + y, z = pos.z}
  209.                 table.insert(store, itemPos)
  210.             end
  211.         end
  212.     end
  213.     return store
  214. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement