Advertisement
nvp777

Untitled

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