Advertisement
nvp777

Untitled

Apr 23rd, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.89 KB | None | 0 0
  1. -----SETTINGS--------------------------------------------------------------
  2. --POTIONS--
  3. local ManaID = 268 --- Which mana potions are you using?
  4. local MinMana = 1 --- How many mana potions until you leave the hunt.
  5. local MaxMana = 3 --- 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 = 600 --- 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 = 1500 --- How many ammo you begin the hunt with.
  14. local AmmoPrice = 20 --- What is the price of your selected ammo?
  15.  
  16. --CAP--
  17. local MinCap = 1 --- Leaves spawn when character reaches this cap.
  18.  
  19. -- Backpack Configuration:
  20.  
  21. local MainBp  = "backpack" ----- Main Backpack
  22. local GoldBp  = "brocade backpack" ---- Backpack to put gold in
  23. local LootBp  = "yellow backpack" ---- Loot Bp
  24. local PotionBp  = "camouflage backpack" ---- Potion Bp
  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}, {7367, 0}, {3371, 0}, {2958, 0}, {7399, 0}, {3332, 0}, {3416, 0}, {3554, 0}, {3369, 0}, {7452, 0}, {9056, 0}, {7421, 0})
  66.         Walker.Start()
  67.  
  68.     elseif (labelName == "BuyManas") then
  69.         -- Buy Mana Potions
  70.         Walker.Stop()
  71.         if (Self.ItemCount(ManaID) < MaxMana) or (Self.ItemCount(HealthID) < MaxHealth) then
  72.             print("Buying manas or healths")
  73.             Self.SayToNpc({"hi", "flasks"}, 100)
  74.             while (Self.ItemCount(FlaskID) >= 1) or (Self.ItemCount(FlaskIDA) >= 1) or (Self.ItemCount(FlaskIDB) >= 1) do
  75.                 Self.SayToNpc("yes", 100)
  76.             end
  77.             wait(2000)
  78.             Self.SayToNpc("trade", 100)
  79.             wait(2000)
  80.             while (Self.ItemCount(ManaID) < MaxMana) do
  81.                 Self.ShopBuyItemsUpTo(ManaID, MaxMana)
  82.                 wait(500,800)
  83.             end
  84.             if (Self.ItemCount(HealthID) < MaxHealth) then
  85.                 Self.ShopBuyItemsUpTo(HealthID, MaxHealth)
  86.                 wait(500)
  87.             end
  88.             wait(200, 500)
  89.         end
  90.         Walker.Start()
  91.  
  92.     elseif (labelName == "CheckGoneUp") then
  93.         -- Check we're on floor 3
  94.         Walker.ConditionalGoto((Self.Position().z == 7), "OpenSouth", "Leave")
  95.  
  96.     elseif (labelName == "CheckGoneDown") then
  97.         -- Check we're on floor 7
  98.         Walker.ConditionalGoto((Self.Position().z == 11), "AmDown", "EnterResp")
  99.      
  100.     elseif (labelName == "BuySpears") then
  101.             --------------------------------- TODO -------------------------
  102.         Walker.Stop()
  103.         Self.SayToNpc({"hi", "trade"}, 100)
  104.         -- Buy spears, make sure Self.ItemCount returns items in hands.
  105.         while (Self.ItemCount(AmmoID) < MaxAmmo) do
  106.             Self.ShopBuyItemsUpTo(AmmoID, MaxAmmo)
  107.             wait(500,800)
  108.         end
  109.         Walker.Start()
  110.  
  111.         elseif (labelName == "Check1") then
  112.         setWalkerEnabled(false)            
  113.         setTargetingEnabled(true)
  114.     if (Self.Cap() > MinCap and Self.ItemCount(ManaID) > MinMana) and (Self.ItemCount(HealthID) > MinHealth) and (Self.ItemCount(AmmoID) > MinAmmo) and (Self.Stamina() > 840) then
  115.                 print("**Expienie Wznowione !**")
  116.                             setWalkerEnabled(true)
  117.         else
  118.                 setTargetingEnabled(false)
  119.             gotoLabel("Refill")
  120.                 print("**Wracam Do Miasta !**")
  121.             setWalkerEnabled(true)    
  122.                 end
  123.    
  124.     elseif (labelName == "ResetBps") then
  125.         -- Reset Backpacks
  126.         Walker.Stop()
  127.         Self.CloseContainers()
  128.         Self.OpenMainBackpack(true):OpenChildren({LootBp, true}, {GoldBp, true}, {PotionBp, true})
  129.         Container.GetFirst():Minimize()
  130.         Walker.Start()
  131.  
  132.     elseif (labelName == "OpenNorth") then
  133.         Walker.Stop()
  134.         Self.UseItemFromGround(Self.Position().x, Self.Position().y - 1, Self.Position().z)
  135.         Walker.Start()
  136.  
  137.     elseif (labelName == "OpenSouth") then
  138.         Walker.Stop()
  139.         Self.UseItemFromGround(Self.Position().x, Self.Position().y + 1, Self.Position().z)
  140.         Walker.Start()
  141.  
  142.     elseif (labelName == "MiddleSpawn") then
  143.         Walker.Stop()
  144.         Walker.ConditionalGoto(HuntMiddle, "MiddleGo", "MiddleDone")
  145.         Walker.Start()
  146.     end
  147.    
  148. end
  149.  
  150. Self.ReachDepot = function (tries)
  151.     local tries = tries or 3
  152.     Walker.Stop()
  153.     local DepotIDs = {3497, 3498, 3499, 3500}
  154.     local DepotPos = {}
  155.     for i = 1, #DepotIDs do
  156.         local dps = Map.GetUseItems(DepotIDs[i])
  157.         for j = 1, #dps do
  158.             table.insert(DepotPos, dps[j])
  159.         end
  160.     end
  161.     local function gotoDepot()
  162.         local pos = Self.Position()
  163.         print("Depots found: " .. tostring(#DepotPos))
  164.         for i = 1, #DepotPos do
  165.             location = DepotPos[i]
  166.             Self.UseItemFromGround(location.x, location.y, location.z)
  167.             wait(1000, 2000)
  168.             if Self.DistanceFromPosition(pos.x, pos.y, pos.z) >= 1 then
  169.                 wait(5000, 6000)
  170.                 if Self.DistanceFromPosition(location.x, location.y, location.z) == 1 then
  171.                     Walker.Start()
  172.                     return true
  173.                 end
  174.             else
  175.                 print("Something is blocking the path. Trying next depot.")
  176.             end
  177.         end
  178.         return false
  179.     end
  180.    
  181.     repeat
  182.         reachedDP = gotoDepot()
  183.         if reachedDP then
  184.             return true
  185.         end
  186.         tries = tries - 1
  187.         sleep(100)
  188.         print("Attempt to reach depot was unsuccessfull. " .. tries .. " tries left.")
  189.     until tries <= 0
  190.  
  191.     return false
  192. end
  193.  
  194. Map.GetUseItems = function (id)
  195.     if type(id) == "string" then
  196.         id = Item.GetID(id)
  197.     end
  198.     local pos = Self.Position()
  199.     local store = {}
  200.     for x = -7, 7 do
  201.         for y = -5, 5 do
  202.             if Map.GetTopUseItem(pos.x + x, pos.y + y, pos.z).id == id then
  203.                 itemPos = {x = pos.x + x, y = pos.y + y, z = pos.z}
  204.                 table.insert(store, itemPos)
  205.             end
  206.         end
  207.     end
  208.     return store
  209. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement