Advertisement
nvp777

Untitled

Apr 23rd, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.22 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.                             setTargetingEnabled(true)  
  118.         else
  119.                 setTargetingEnabled(false)
  120.             gotoLabel("Refill")
  121.                 print("**Wracam Do Miasta !**")
  122.             setWalkerEnabled(true)    
  123.                 end
  124.    
  125.     elseif (labelName == "TargetingOff") then
  126.         setTargetingEnabled(false) 
  127.         print("&Targeting Wylaczony !&")
  128.         wait(900, 1200)
  129.    
  130.     elseif (labelName == "TargetingOn") then
  131.         setTargetingEnabled(false) 
  132.         print("&Targeting Wlaczony !&")
  133.         wait(900, 1200)
  134.    
  135.     elseif (labelName == "ResetBps") then
  136.         -- Reset Backpacks
  137.         Walker.Stop()
  138.         Self.CloseContainers()
  139.         Self.OpenMainBackpack(true):OpenChildren({LootBp, true}, {GoldBp, true}, {PotionBp, true})
  140.         Container.GetFirst():Minimize()
  141.         Walker.Start()
  142.  
  143.     elseif (labelName == "OpenNorth") then
  144.         Walker.Stop()
  145.         Self.UseItemFromGround(Self.Position().x, Self.Position().y - 1, Self.Position().z)
  146.         Walker.Start()
  147.  
  148.     elseif (labelName == "OpenSouth") then
  149.         Walker.Stop()
  150.         Self.UseItemFromGround(Self.Position().x, Self.Position().y + 1, Self.Position().z)
  151.         Walker.Start()
  152.  
  153.     elseif (labelName == "MiddleSpawn") then
  154.         Walker.Stop()
  155.         Walker.ConditionalGoto(HuntMiddle, "MiddleGo", "MiddleDone")
  156.         Walker.Start()
  157.     end
  158.    
  159. end
  160.  
  161. Self.ReachDepot = function (tries)
  162.     local tries = tries or 3
  163.     Walker.Stop()
  164.     local DepotIDs = {3497, 3498, 3499, 3500}
  165.     local DepotPos = {}
  166.     for i = 1, #DepotIDs do
  167.         local dps = Map.GetUseItems(DepotIDs[i])
  168.         for j = 1, #dps do
  169.             table.insert(DepotPos, dps[j])
  170.         end
  171.     end
  172.     local function gotoDepot()
  173.         local pos = Self.Position()
  174.         print("Depots found: " .. tostring(#DepotPos))
  175.         for i = 1, #DepotPos do
  176.             location = DepotPos[i]
  177.             Self.UseItemFromGround(location.x, location.y, location.z)
  178.             wait(1000, 2000)
  179.             if Self.DistanceFromPosition(pos.x, pos.y, pos.z) >= 1 then
  180.                 wait(5000, 6000)
  181.                 if Self.DistanceFromPosition(location.x, location.y, location.z) == 1 then
  182.                     Walker.Start()
  183.                     return true
  184.                 end
  185.             else
  186.                 print("Something is blocking the path. Trying next depot.")
  187.             end
  188.         end
  189.         return false
  190.     end
  191.    
  192.     repeat
  193.         reachedDP = gotoDepot()
  194.         if reachedDP then
  195.             return true
  196.         end
  197.         tries = tries - 1
  198.         sleep(100)
  199.         print("Attempt to reach depot was unsuccessfull. " .. tries .. " tries left.")
  200.     until tries <= 0
  201.  
  202.     return false
  203. end
  204.  
  205. Map.GetUseItems = function (id)
  206.     if type(id) == "string" then
  207.         id = Item.GetID(id)
  208.     end
  209.     local pos = Self.Position()
  210.     local store = {}
  211.     for x = -7, 7 do
  212.         for y = -5, 5 do
  213.             if Map.GetTopUseItem(pos.x + x, pos.y + y, pos.z).id == id then
  214.                 itemPos = {x = pos.x + x, y = pos.y + y, z = pos.z}
  215.                 table.insert(store, itemPos)
  216.             end
  217.         end
  218.     end
  219.     return store
  220. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement