Guest User

Untitled

a guest
Oct 23rd, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.58 KB | None | 0 0
  1. stash, cube, belt, inventory = {}, {}, {}, {}
  2. --[[ Cube Functions ]]--
  3. cube.Cows = function()
  4. Log(2, "Containers", "cube.Cows : Started", true)
  5. local tbk, leg
  6. Act1()
  7.  
  8. tbk = Ao.me.inventory:findByCode('tbk')
  9. leg = Ao.me.inventory:findByCode('leg')
  10.  
  11. TownMove.ToObject('Bank')
  12.  
  13. stash.Open()
  14. cube.ItemToCube(leg[0])
  15. for i = 0, tbk:size() - 1 do
  16. if Settings.Lock.Inventory[(tonumber(tbk[i].y..(tbk[i].x+1)))] == 0 then
  17. cube.ItemToCube(tbk[i])
  18. break
  19. end
  20. end
  21. cube.Open()
  22. cube.Transmute()
  23. Ao:ClickButton(GameButton.CloseCube, 0)
  24. Ao:ClickButton(GameButton.CloseStash, 0)
  25. Sleep(Settings.Bot.InteractDelay)
  26. Log(2, "Containers", "cube.Cows : Ended", true)
  27. end
  28.  
  29. cube.Craft = function()
  30. -- Hit Power : Sapphire
  31. -- Helm : Full Helm / Basinet / Giant Conch (Ith)
  32. -- Boots : Chain / Mesh / Boneweave (Ral)
  33. -- Gloves : Chain Gloves / Heavy Bracers / Vambraces (Ort)
  34. -- Belt : Heavy / Battle / Troll (Tal)
  35. -- Shield : Gothic / Ancient / Ward (Eth)
  36. -- Body : Field Plate / Sharktooth / Kraken Shell (Nef)
  37. -- Amulet : (Thul)
  38. -- Ring : (Amn)
  39. -- Weapon : Any Blunt (Tir)
  40. -- Blood : Ruby
  41. -- Helm : Helm / Casque / Armet (Ral)
  42. -- Boots : Light Plated / Battle / Mirrored (Eth)
  43. -- Gloves : Heavy / Sharkskin / Vampirebone (Nef)
  44. -- Belt : Belt / Mesh / Mithril Coil (Tal)
  45. -- Shield : Spiked / Barbed / Blade Barrier (Ith)
  46. -- Body : Plate Mail / Templar Coat / Hellforge Plate (Thul)
  47. -- Amulet : (Amn)
  48. -- Ring : (Sol)
  49. -- Weapon : Any Axe (Ort)
  50. -- Caster : Amethyst
  51. -- Helm : Mask / Death Mask / Demonhead Mask (Nef)
  52. -- Boots : Boots / Demonhide / Wyrmhide (Thul)
  53. -- Gloves : Leather / Demonhide / Bramble (Ort)
  54. -- Belt : Light / Sharkskin / Vampirefang (Ith)
  55. -- Shield : Small / Round / Luna (Eth)
  56. -- Body : Light Plate / Mage Plate / Archon Plate (Tal)
  57. -- Amulet : (Ral)
  58. -- Ring : (Amn)
  59. -- Weapon : Any Rod (Scepter, Wand, Staff) (Tir)
  60. -- Safety (Emerald)
  61. -- Helm : Crown / Grand Crown / Corona (Ith)
  62. -- Boots : Greaves / War Boots / Myrmidon Boots (Ort)
  63. -- Gloves : Gauntlers / War Gauntlets / Ogre Gauntlets (Ral)
  64. -- Belt : Sash / Demonhide Sash / Spiderweb Sash (Tal)
  65. -- Shield : Kite / Dragon / Monarch (Nef)
  66. -- Body : Breast Plate / Cuirass / Great Hauberk (Eth)
  67. -- Amulet : (Thul)
  68. -- Ring : (Amn)
  69. -- Weapon : Spear or Javelin (Sol)
  70. end
  71.  
  72. cube.Keys = function()
  73. Log(2, "Containers", "cube.Keys Started", true)
  74. local t = os.time(sec)
  75. local tkey = Ao.me.stash:findByCode("pk1")
  76. local hkey = Ao.me.stash:findByCode("pk2")
  77. local dkey = Ao.me.stash:findByCode("pk3")
  78.  
  79. if tkey:size() > 0 and hkey:size() > 0 and dkey:size() > 0 then
  80. stash.Open()
  81. cube.ItemToCube(tkey[0])
  82. cube.ItemToCube(hkey[0])
  83. cube.ItemToCube(dkey[0])
  84. cube.Open()
  85. cube.Transmute()
  86. Ao:ClickButton(GameButton.CloseCube, 0)
  87. Ao:ClickButton(GameButton.CloseStash, 0)
  88. Sleep(Settings.Bot.InteractDelay)
  89. else
  90. Log(2, "Containers", "cube.Keys : Not enough keys. T = "..tkey:size()..", H = "..hkey:size()..", D = "..dkey:size(), true)
  91. return false
  92. end
  93. Log(1, "Containers", "cube.Keys: t= "..os.time(sec) - t)
  94. Log(2, "Containers", "cube.Keys Done", true)
  95. t = nil
  96. return true
  97. end
  98.  
  99. cube.Organs = function()
  100. Log(2, "Containers", "cube.Organs Started", true)
  101. local t = os.time(sec)
  102. local horn = Ao.me.stash:findByCode("dhn")
  103. local eye = Ao.me.stash:findByCode("bey")
  104. local brain = Ao.me.stash:findByCode("mbr")
  105.  
  106. if horn:size() > 0 and eye:size() > 0 and brain:size() > 0 then
  107. stash.Open()
  108. cube.ItemToCube(horn[0])
  109. cube.ItemToCube(eye[0])
  110. cube.ItemToCube(brain[0])
  111. cube.Open()
  112. cube.Transmute()
  113. Ao:ClickButton(GameButton.CloseCube, 0)
  114. Ao:ClickButton(GameButton.CloseStash, 0)
  115. Sleep(Settings.Bot.InteractDelay)
  116. else
  117. Log(2, "Containers", "cube.Organs: Not enough Organs. Horn = "..horn:size().." Eye = "..eye:size().." Brain = "..brain:size())
  118. return false
  119. end
  120. Log(1, "Containers", "cube.Organs: t= "..os.time(sec) - t)
  121. Log(2, "Containers", "cube.Organs Done", true)
  122. t = nil
  123. end
  124.  
  125. cube.Essences = function()
  126. Log(2, "Containers", "cube.Essences Started", true)
  127. local t = os.time(sec)
  128. local inCube = {}
  129. local suffering = Ao.me.stash:findByCode("tes") -- Andy / Duriel
  130. local hatred = Ao.me.stash:findByCode("ceh") -- meph
  131. local terror = Ao.me.stash:findByCode("bet") -- diablo
  132. local destruction = Ao.me.stash:findByCode("fed") -- baal
  133.  
  134. repeat
  135. if suffering:size() > 0 and hatred:size() > 0 and terror:size() > 0 and destruction:size() > 0 then
  136. stash.Open()
  137. cube.ItemToCube(suffering[0])
  138. cube.ItemToCube(hatred[0])
  139. cube.ItemToCube(terror[0])
  140. cube.ItemToCube(destruction[0])
  141. cube.Open()
  142. cube.Transmute()
  143. inCube = Ao.me.cube:get()
  144. if inCube:size() > 1 then Log(3, "Containers", "More than 1 item in cube, cube.Essences failed!") return false end
  145. cube.ItemToStash(inCube[0])
  146. Ao:ClickButton(GameButton.CloseCube, 0)
  147. Ao:ClickButton(GameButton.CloseStash, 0)
  148. Sleep(Settings.Bot.InteractDelay)
  149. Log(2, "Containers", "Cubed Token of Absolution", true)
  150. end
  151.  
  152. suffering = Ao.me.stash:findByCode("tes")
  153. hatred = Ao.me.stash:findByCode("ceh")
  154. terror = Ao.me.stash:findByCode("bet")
  155. destruction = Ao.me.stash:findByCode("fed")
  156. until suffering:size() < 1 or hatred:size() < 1 or terror:size() < 1 or destruction:size() < 1
  157.  
  158. Log(1, "Containers", "cube.Essences: t= "..os.time(sec) - t)
  159. Log(2, "Containers", "cube.Essences Done", true)
  160. t = nil
  161. end
  162.  
  163. cube.Gems = function()
  164. Log(2, "Containers", "cube.Gems Started", true)
  165. local t = os.time(sec)
  166. local gems, inCube
  167.  
  168. Log(1, "Containers", "Cubing Chipped Gems")
  169. for types = 1, #Settings.Craft.Flawed do --This will search through Settings.CubeChippedGems (or not if no values), this applies to runes as well
  170. gems = Ao.me.stash:findByCode(CHIPPED[Settings.Craft.Flawed[types]]) --This is now entered by type which is referenced in Globals.lua, this applies to runes as well
  171. while (gems and gems:size() >= 3) do
  172. stash.Open()
  173. for count = 0, 2 do cube.ItemToCube(gems[count]) end
  174. cube.Open()
  175. cube.Transmute()
  176. inCube = Ao.me.cube:get()
  177. if inCube:size() > 1 then Log(3, "Containers", "More than 1 item in cube, cube.Gems failed!") return false end
  178. cube.ItemToStash(inCube[0])
  179. gems = Ao.me.stash:findByCode(CHIPPED[Settings.Craft.Flawed[types]])
  180. Ao:ClickButton(GameButton.CloseCube, 0)
  181. Ao:ClickButton(GameButton.CloseStash, 0)
  182. Sleep(Settings.Bot.InteractDelay)
  183. Log(2, "Containers", "Cubed Chipped "..Settings.Craft.Flawed[types], true)
  184. end
  185. end
  186.  
  187. Log(1, "Containers", "Cubing Flawed Gems")
  188. for types = 1, #Settings.Craft.Normal do
  189. gems = Ao.me.stash:findByCode(FLAWED[Settings.Craft.Normal[types]])
  190. while (gems and gems:size() >= 3) do
  191. stash.Open()
  192. for count = 0, 2 do cube.ItemToCube(gems[count]) end
  193. cube.Open()
  194. cube.Transmute()
  195. inCube = Ao.me.cube:get()
  196. if inCube:size() > 1 then Log(3, "Containers", "More than 1 item in cube, cube.Gems failed!") return false end
  197. cube.ItemToStash(inCube[0])
  198. gems = Ao.me.stash:findByCode(FLAWED[Settings.Craft.Normal[types]])
  199. Ao:ClickButton(GameButton.CloseCube, 0)
  200. Ao:ClickButton(GameButton.CloseStash, 0)
  201. Sleep(Settings.Bot.InteractDelay)
  202. Log(2, "Containers", "Cubed Flawed "..Settings.Craft.Normal[types], true)
  203. end
  204. end
  205.  
  206. Log(1, "Containers", "Cubing Normal Gems")
  207. for types = 1, #Settings.Craft.Flawless do
  208. gems = Ao.me.stash:findByCode(NORMAL[Settings.Craft.Flawless[types]])
  209. while (gems and gems:size() >= 3) do
  210. stash.Open()
  211. for count = 0, 2 do cube.ItemToCube(gems[count]) end
  212. cube.Open()
  213. cube.Transmute()
  214. inCube = Ao.me.cube:get()
  215. if inCube:size() > 1 then Log(3, "Containers", "More than 1 item in cube, cube.Gems failed!") return false end
  216. cube.ItemToStash(inCube[0])
  217. gems = Ao.me.stash:findByCode(NORMAL[Settings.Craft.Flawless[types]])
  218. Ao:ClickButton(GameButton.CloseCube, 0)
  219. Ao:ClickButton(GameButton.CloseStash, 0)
  220. Sleep(Settings.Bot.InteractDelay)
  221. Log(2, "Containers", "Cubed Normal "..Settings.Craft.Flawless[types], true)
  222. end
  223. end
  224.  
  225. Log(1, "Containers", "Cubing Flawless Gems")
  226. for types = 1, #Settings.Craft.Perfect do
  227. gems = Ao.me.stash:findByCode(FLAWLESS[Settings.Craft.Perfect[types]])
  228. while (gems and gems:size() >= 3) do
  229. stash.Open()
  230. for count = 0, 2 do cube.ItemToCube(gems[count]) end
  231. cube.Open()
  232. cube.Transmute()
  233. inCube = Ao.me.cube:get()
  234. if inCube:size() > 1 then Log(3, "Containers", "More than 1 item in cube, cube.Gems failed!") return false end
  235. cube.ItemToStash(inCube[0])
  236. gems = Ao.me.stash:findByCode(FLAWLESS[Settings.Craft.Perfect[types]])
  237. Ao:ClickButton(GameButton.CloseCube, 0)
  238. Ao:ClickButton(GameButton.CloseStash, 0)
  239. Sleep(Settings.Bot.InteractDelay)
  240. Log(2, "Containers", "Cubed Flawless "..Settings.Craft.Perfect[types], true)
  241. end
  242. end
  243.  
  244. Log(2, "Containers", "cube.Gems Done", true)
  245. Log(1, "Containers", "cube.Gems: t= "..os.time(sec) - t)
  246. t = nil
  247. end
  248.  
  249. cube.Runes = function()
  250. Log(2, "Containers", "cube.Runes Started", true)
  251. local t = os.time(sec)
  252. local rune, gem, countRune, inCube = 0, 0, 0, 0
  253. for getRune = 1, #Settings.Craft.Rune do
  254. rune = RUNES[Settings.Craft.Rune[getRune]] - 1
  255. if rune <= 9 then
  256. countRune = Ao.me.stash:findByCode("r0"..rune)
  257. while (countRune and countRune:size() >= 3) do
  258. stash.Open()
  259. for count = 0, 2 do cube.ItemToCube(countRune[count]) end
  260. cube.Open()
  261. cube.Transmute()
  262. inCube = Ao.me.cube:get()
  263. if inCube:size() > 1 then Log(3, "Containers", "More than 1 item in cube, cube.Runes failed!") return false end
  264. cube.ItemToStash(inCube[0])
  265. countRune = Ao.me.stash:findByCode("r0"..rune)
  266. Ao:ClickButton(GameButton.CloseCube, 0)
  267. Ao:ClickButton(GameButton.CloseStash, 0)
  268. Sleep(Settings.Bot.InteractDelay)
  269. Log(2, "Cubing", "Made "..Settings.Craft.Rune[getRune], true)
  270. end
  271. end
  272.  
  273. if rune > 9 and rune < 21 then
  274. gem = Ao.me.stash:findByCode(FORMULA[rune])
  275. countRune = Ao.me.stash:findByCode("r"..rune)
  276. while (countRune and gem and countRune:size() >= 3 and gem:size() >= 1) do
  277. stash.Open()
  278. for count = 0, 2 do
  279. cube.ItemToCube(countRune[count])
  280. if count == 0 then cube.ItemToCube(gem[count]) end
  281. end
  282. cube.Open()
  283. cube.Transmute()
  284. inCube = Ao.me.cube:get()
  285. if inCube:size() > 1 then Log(3, "Containers", "More than 1 item in cube, cube.Runes failed!") return false end
  286. cube.ItemToStash(inCube[0])
  287. gem = Ao.me.stash:findByCode(FORMULA[rune])
  288. countRune = Ao.me.stash:findByCode("r"..rune)
  289. Ao:ClickButton(GameButton.CloseCube, 0)
  290. Ao:ClickButton(GameButton.CloseStash, 0)
  291. Sleep(Settings.Bot.InteractDelay)
  292. Log(2, "Containers", "Made "..Settings.Craft.Rune[getRune], true)
  293. end
  294. end
  295.  
  296. if rune > 20 and rune < 33 then
  297. gem = Ao.me.stash:findByCode(FORMULA[rune])
  298. countRune = Ao.me.stash:findByCode("r"..rune)
  299. while (countRune and gem and countRune:size() >= 3 and gem:size() >= 1) do
  300. stash.Open()
  301. for count = 0, 1 do
  302. cube.ItemToCube(countRune[count])
  303. if count == 0 then cube.ItemToCube(gem[count]) end
  304. end
  305. cube.Open()
  306. cube.Transmute()
  307. inCube = Ao.me.cube:get()
  308. if inCube:size() > 1 then Log(3, "Containers", "More than 1 item in cube, cube.Runes failed!") return false end
  309. cube.ItemToStash(inCube[0])
  310. gem = Ao.me.stash:findByCode(FORMULA[rune])
  311. countRune = Ao.me.stash:findByCode("r"..rune)
  312. Ao:ClickButton(GameButton.CloseCube, 0)
  313. Ao:ClickButton(GameButton.CloseStash, 0)
  314. Sleep(Settings.Bot.InteractDelay)
  315. Log(2, "Containers", "Made "..Settings.Craft.Rune[getRune], true)
  316. end
  317. end
  318. end
  319. Log(2, "Containers", "cube.Runes Done", true)
  320. Log(1, "Containers", "cube.Runes: t= "..os.time(sec) - t)
  321. t = nil
  322. end
  323.  
  324. cube.RerollBaalGCs = function()
  325. Log(2, "Containers", "Checking if we can reroll some gcs...", true)
  326. local logSaid = false
  327.  
  328. local Gems = GetPGems()
  329. local BaalGCS = GetBaalGCS()
  330. local KeepGC = true
  331. local countKeptGCS = 0
  332.  
  333. while table.getn(Gems) >= 3 and table.getn(BaalGCS) > 0 and countKeptGCS < table.getn(BaalGCS) do
  334. countKeptGCS = 0
  335.  
  336. for i = 1, table.getn(BaalGCS) do
  337. if (not BaalGCS[i].flags.Identified) then -- Check if Unid and id it
  338. local ids = Ao.me.inventory:findByCode("ibk")
  339. if (ids:size() == 0) then Log(3, "Containers", "No Identify book, skipping") return end
  340.  
  341. Ao:InitWaitingPacket(GS["UseStackableItem"])
  342. Ao:UseInventoryItem(ids[0].uid, Ao.me.x, Ao.me.y)
  343. Ao:WaitForInitPacket(Settings.Bot.InteractDelay*3)
  344. Ao:InitWaitingPacket(GS["UseSpecialItem"])
  345. Ao:IdentifyItem(BaalGCS[i].uid, ids[0].uid);
  346. Ao:WaitForInitPacket(Settings.Bot.InteractDelay*3)
  347. end
  348.  
  349. if (not sellItem(BaalGCS[i])) then -- Check if it should be kept as it is
  350. KeepGC = true
  351. countKeptGCS = countKeptGCS + 1 -- Count the kept gcs so it stops if all gcs in stash are kept
  352. else
  353. KeepGC = false
  354. end
  355.  
  356. if table.getn(Gems) >= 3 and (not KeepGC) then
  357. if not logSaid then Log(2, "Containers", "Rerolling 91+ ILevel gc...", true) logSaid = true end
  358. stash.Open()
  359. cube.ItemToCube(Gems[1])
  360. cube.ItemToCube(Gems[2])
  361. cube.ItemToCube(Gems[3])
  362. cube.ItemToCube(BaalGCS[i])
  363. cube.Open()
  364. cube.Transmute()
  365.  
  366. local newGc = Ao.me.cube:findByCode("cm3")
  367. cube.ItemToStash(newGc[0])
  368. end
  369. Gems = GetPGems()
  370. Ao:ClickButton(GameButton.CloseCube, 0)
  371. Ao:ClickButton(GameButton.CloseStash, 0)
  372. Sleep(Settings.Bot.InteractDelay)
  373. end
  374.  
  375. Gems = GetPGems()
  376. BaalGCS = GetBaalGCS()
  377. end
  378. if logSaid then Log(2, "Containers", "Rerolling Baal gcs finished", true)
  379. else Log(2, "Containers", "Baal Gcs rerolling not needed, skipping.") end
  380. logSaid, Gems, BaalGCS, KeepGC, countKeptGCS = nil, nil, nil, nil, nil
  381. end
  382.  
  383. cube.Open = function()
  384. local t = os.time(sec)
  385. Ao:InitWaitingPacket(GS["UseSpecialItem"])
  386. Ao:UseInventoryItem(Ao.me.cube.uid, Ao.me.x, Ao.me.y)
  387. Ao:WaitForInitPacket(Settings.Bot.InteractDelay)
  388. t = nil
  389. end
  390.  
  391. cube.Transmute = function()
  392. local t = os.time(sec)
  393. Ao:InitWaitingPacket(GS["WorldItemAction"])
  394. Ao:ClickButton(GameButton.Transmute, 0)
  395. Ao:WaitForInitPacket(Settings.Bot.InteractDelay*2)
  396. Log(1, "Containers", "cube.Transmute: t= "..os.time(sec) - t)
  397. t = nil
  398. end
  399.  
  400. cube.ItemToCube = function(item)
  401. local t = os.time(sec)
  402. while Ao.me.cursor.uid == 0 do
  403. Log(1, "Containers", "cube.ItemToCube: Attempting to pick item ("..item.uid..")")
  404. Ao:InitWaitingPacket(GS["OwnedItemAction"])
  405. Ao:PickItemFromContainer(item.uid)
  406. Ao:WaitForInitPacket(Settings.Bot.InteractDelay*2)
  407. end
  408. Sleep(Settings.Bot.InteractDelay/10)
  409. while Ao.me.cursor.uid > 0 do
  410. Ao:InitWaitingPacket(GS["WorldItemAction"])
  411. Ao:ItemToCube(item.uid, Ao.me.cube.uid)
  412. Ao:WaitForInitPacket(Settings.Bot.InteractDelay*2)
  413. end
  414. Sleep(Settings.Bot.InteractDelay/10)
  415. Log(1, "Containers", "cube.ItemToCube: t= "..os.time(sec) - t)
  416. t = nil
  417. end
  418.  
  419. cube.ItemToStash = function(item)
  420. local t = os.time(sec)
  421. Ao:InitWaitingPacket(GS["OwnedItemAction"])
  422. while Ao.me.cursor.uid == 0 do
  423. Ao:PickItemFromContainer(item.uid)
  424. Ao:WaitForInitPacket(Settings.Bot.InteractDelay)
  425. end
  426. Sleep(Settings.Bot.InteractDelay/10)
  427. Ao:ClickButton(GameButton.CloseCube, 0)
  428. stash.Open()
  429.  
  430. local place = Ao.me.stash:findLocation(Ao.me.cursor)
  431. if (place.x ~= -1 and place.y ~= -1) then
  432. if(place.x >= 0 and place.y >= 0) then
  433. Ao:InitWaitingPacket(GS["WorldItemAction"])
  434. while Ao.me.cursor.uid ~= 0 do
  435. Ao:DropItemToContainer(Ao.me.cursor.uid, place.x, place.y, ItemContainerGC.Stash) --Is this crashing everything? We might need to move to inventory then to stash
  436. Ao:WaitForInitPacket(Settings.Bot.InteractDelay)
  437. end
  438. Sleep(Settings.Bot.InteractDelay/10)
  439. Log(1, "Containers", "cube.ItemToStash: DropItem t= "..os.time(sec) - t)
  440. else
  441. Log(3, "Containers", "ÿc1Unable to find place to put item in cursor!")
  442. Log(1, "Containers", "cube.ItemToStash: fail t= "..os.time(sec) - t)
  443. return false
  444. end
  445. end
  446. Log(1, "Containers", "cube.ItemToStash: t= "..os.time(sec) - t)
  447. t = nil
  448. end
  449.  
  450. cube.ItemToInventory = function(item)
  451. local t = os.time(sec)
  452. Ao:InitWaitingPacket(GS["OwnedItemAction"])
  453. while Ao.me.cursor.uid == 0 do
  454. Ao:PickItemFromContainer(item.uid)
  455. Ao:WaitForInitPacket(Settings.Bot.InteractDelay)
  456. end
  457. Sleep(Settings.Bot.InteractDelay/10)
  458. local place = Ao.me.inventory:findLocation(Ao.me.cursor)
  459. if (place.x ~= -1 and place.y ~= -1) then
  460. if (place.x >= 0 and place.y >= 0) then
  461. Ao:InitWaitingPacket(GS["WorldItemAction"])
  462. while Ao.me.cursor.uid ~= 0 do
  463. Ao:DropItemToContainer(Ao.me.cursor.uid, to.x, to.y, ItemContainerGC.Inventory)
  464. Ao:WaitForInitPacket(Settings.Bot.InteractDelay*3)
  465. end
  466. Sleep(Settings.Bot.InteractDelay/10)
  467. Log(1, "Containers", "cube.ItemToInventory: DropItem t= "..os.time(sec) -t)
  468. else
  469. Log(3, "Containers", "ÿc1Unable to find place to put item in cursor!")
  470. Log(1, "Containers", "cube.ItemToInventory: fail t= "..os.time(sec) - t)
  471. return false
  472. end
  473. end
  474. Log(1, "Containers", "cube.ItemToInventory: t= "..os.time(sec) - t)
  475. t = nil
  476. end
  477. --[[ End Cube Functions ]]--
  478. --[[ Stash Functions ]]--
  479. stash.Open = function()
  480. Ao:InitWaitingPacket(GS["UpdateItemUI"])
  481. Ao:UnitInteract(UnitType.GameObject, Ao.objects:FindBank())
  482. return Ao:WaitForInitPacket(Settings.Bot.InteractDelay)
  483. end
  484. --[[ End Stash Functions ]]--
  485. --[[ Belt Functions ]]--
  486. belt.ItemToInventory = function(item)
  487. local count = 0
  488. local to = Ao.me.inventory:findLocation(item)
  489. if (to ~= nil) then
  490. if (to.x < 0 or to.y < 0 or to.x > 9 or to.y > 3) then
  491. Log(3, "Containers", "ÿc1Unable to find place to put Pot into Inventory! Drinking pot")
  492. Ao:UseBeltItem(item.uid, false)
  493. Ao:Sleep(Settings.Bot.InteractDelay/3)
  494. return
  495. end
  496. end
  497.  
  498. while (Ao.me.cursor.uid == 0 and count < 5) do
  499. Ao:InitWaitingPacket(GS["WorldItemAction"])
  500. Ao:RemoveBeltItem(item.uid)
  501. Ao:WaitForInitPacket(Settings.Bot.InteractDelay*3)
  502. count = count + 1
  503. end
  504.  
  505. if (count > 4) then return end
  506.  
  507. count = 0
  508. while (Ao.me.cursor.uid ~= 0 and count < 5) do
  509. Ao:InitWaitingPacket(GS["WorldItemAction"])
  510. Ao:DropItemToContainer(Ao.me.cursor.uid, to.x, to.y, ItemContainerGC.Inventory)
  511. Ao:WaitForInitPacket(Settings.Bot.InteractDelay*3)
  512. count = count + 1
  513. end
  514. count = nil
  515. end
  516.  
  517. belt.PotCheck = function(pot)
  518. if pot == nil then
  519. Ao:Chat("pot is nil, skipping")
  520. return false
  521. end
  522.  
  523. if pot.baseItem == nil then
  524. Ao:Chat("pot.baseItem is nil, skipping")
  525. return false
  526. end
  527.  
  528. local pottype = Items:GetPotType(pot.baseItem.code)
  529. if pottype >= 3 then --not a pot!
  530. return false
  531. end
  532. local beltmap = Ao.me.belt:getBelt()
  533. if beltmap:size() >= 4* Ao.me.beltrows then
  534. return false
  535. end
  536. local maxpots = 0
  537. for i = 1, 4 do
  538. if getEnumValue(PotionType, Settings.Inventory.Belt[i]) == pottype then
  539. maxpots = maxpots + Ao.me.beltrows
  540. end
  541. end
  542. return Ao.me.belt:getPotionCount(pottype) < maxpots
  543. end
  544.  
  545. belt.ListMe = function()
  546. local beltRow
  547. Ao:Chat("ListMe")
  548. for j = 0, 3 do
  549. --Ao:Chat("j = "..j)
  550. beltRow = Ao.me.belt:getBeltRow(j)
  551. for i = 0, beltRow:size() - 1 do--, 0, -1 do
  552. Ao:Chat(Items:GetPotType(beltRow[i].baseItem.code).." == "..getEnumKey(PotionType, Items:GetPotType(beltRow[i].baseItem.code)))
  553. end
  554. end
  555. end
  556.  
  557. belt.ManagePots = function()
  558. if (belt.CleanToInv()) then -- check if the beltrows are sorted properly
  559. Log(2, "Containers", "Transferring potions back to belt.", true)
  560. end
  561.  
  562. for c = 1, 4 do
  563. local items = Ao.me.inventory:get()
  564. for i = 0, items:size() - 1 do
  565. --Ao:Chat("this is a : "..Items:GetPotType(items[i].baseItem.code).." and PotionType.Error is "..PotionType.Error)
  566. if (Items:GetPotType(items[i].baseItem.code) ~= PotionType.Error) then
  567. --Ao:Chat(Items:GetPotType(items[i].baseItem.code).." ?= ".. getEnumValue(PotionType, Settings.Inventory.Belt[c]))
  568. if (Items:GetPotType(items[i].baseItem.code) == getEnumValue(PotionType, Settings.Inventory.Belt[c])) then
  569. --Ao:Chat("PotCheck()")
  570. if (belt.PotCheck(items[i])) then
  571. --Ao:Chat("beltPotCheck")
  572. Ao:InventoryItemToBelt(items[i].uid)
  573. Sleep(Settings.Bot.InteractDelay/20)
  574. else
  575. Ao:UseInventoryItem(items[i].uid, Ao.me.x, Ao.me.y)
  576. Sleep(Settings.Bot.InteractDelay/20)
  577. end
  578. end
  579. Ao:Sleep(Settings.Bot.InteractDelay/5) -- don't sleep too much, it's annoying
  580. end
  581. end
  582. end
  583. end
  584.  
  585. belt.CleanToInv = function()
  586. local beltRow
  587. local messedUp = false
  588.  
  589. for i = 0, 3 do
  590. beltRow = Ao.me.belt:getBeltRow(i)
  591. for ii = beltRow:size()-1, 0, -1 do
  592. --Ao:Chat(Items:GetPotType(beltRow[ii].baseItem.code).." ~= "..PotionType.Error)
  593. if (Items:GetPotType(beltRow[ii].baseItem.code) ~= PotionType.Error) then
  594. --Ao:Chat(" * "..getEnumKey(PotionType, Items:GetPotType(beltRow[ii].baseItem.code)).." ~= "..Settings.Inventory.Belt[i+1])
  595. if (getEnumKey(PotionType, Items:GetPotType(beltRow[ii].baseItem.code)) ~= Settings.Inventory.Belt[i+1]) then
  596. belt.ItemToInventory(beltRow[ii])
  597. if(messedUp == false) then
  598. messedUp = true
  599. Log(2, "Containers", "Belt is messed up, moving to inventory.", true)
  600. end
  601. end
  602. end
  603. end
  604. end
  605.  
  606. return messedUp
  607. end
  608.  
  609. belt.Drink = function(potion, givemerc)
  610. local pot = Ao.me.belt:getPotion(potion)
  611.  
  612. if (pot ~= nil and pot.uid ~= 0) then
  613. if (givemerc == false) then ItemMessage("Drank ", pot)
  614. elseif (givemerc == true) then ItemMessage("Gave Merc ", pot) end
  615. Ao:UseBeltItem(pot.uid, givemerc)
  616. return true
  617. end
  618.  
  619. Log(1, "Containers", "Drink failed, Cant find pot")
  620. return false
  621. end
  622. --[[ End Belt Functions ]]--
  623. --[[ Inventory Functions ]]--
  624. inventory.GetItemsToId = function()
  625. local items = Ao.me.inventory:get()
  626. local id = {}
  627. for i = 0, items:size() - 1 do
  628. if Settings.Lock.Inventory[(tonumber(items[i].y..(items[i].x+1)))] == 0 then
  629. if not items[i].flags.Identified and identifyItem(items[i]) then
  630. table.insert(id, items[i])
  631. end
  632. end
  633. end
  634. return id
  635. end
  636. inventory.GetItemsToSell = function()
  637. local items = Ao.me.inventory:get()
  638. local sell = {}
  639. for i = 0, items:size() - 1 do
  640. if Settings.Lock.Inventory[(tonumber(items[i].y..(items[i].x+1)))] == 0 then
  641. if sellItem(items[i]) then
  642. table.insert(sell, items[i])
  643. end
  644. end
  645. end
  646. return sell
  647. end
  648. inventory.GetItemsToStash = function()
  649. local items = Ao.me.inventory:get()
  650. local stash = {}
  651. for i = 0, items:size() - 1 do
  652. if Settings.Lock.Inventory[(tonumber(items[i].y..(items[i].x+1)))] == 0 then
  653. if not sellItem(items[i]) then
  654. table.insert(stash, items[i])
  655. end
  656. end
  657. end
  658. return stash
  659. end
  660. inventory.IdentifyItem = function(item)
  661. local id = Ao.me.inventory:findByCode('ibk')
  662. if id:size() == 0 then
  663. id = Ao.me.inventory:findByCode('isc')
  664. if id:size() == 0 then
  665. return false
  666. end
  667. end
  668. Ao:InitWaitingPacket(GS["UseStackableItem"])
  669. repeat
  670. Ao:UseInventoryItem(id[0].uid, Ao.me.x, Ao.me.y)
  671. until Ao:WaitForInitPacket(Settings.Bot.InteractDelay)
  672. Ao:InitWaitingPacket(GS["UseSpecialItem"])
  673. repeat
  674. Ao:IdentifyItem(item.uid, id[0].uid)
  675. until Ao:WaitForInitPacket(Settings.Bot.InteractDelay)
  676. end
  677.  
  678.  
  679. inventory.ScrollCheck = function(scroll)
  680. if scroll.baseItem.code ~= "tsc" or scroll.baseItem.code ~= "isc" then
  681. return false
  682. end
  683. local tptome, idtome = Ao.me.inventory:findByCode("tbk"), Ao.me.inventory:findByCode("ibk")
  684. if scroll.baseItem.code == "tsc" and tptome:size() > 0 then
  685. if Ao.me.tps < 20 then
  686. return true
  687. end
  688. elseif scroll.baseItem.code == "tsc" and idtome:size() > 0 then
  689. if Ao.me.ids < 20 then
  690. return true
  691. end
  692. end
  693. return false
  694. end
  695.  
  696. inventory.AmmoCheck = function(ammo)
  697. if ammo.baseItem.code ~= "aqv" or ammo.baseItem.code ~= "cqv" then
  698. return false
  699. end
  700. --[[ Needs code to determine whether to pick arrows or bolts ]]--
  701. end
  702.  
  703. inventory.GoldCheck = function(gold)
  704. if gold.baseItem.code ~= "gld" then
  705. return false
  706. elseif gold.stats[0].Value >= Settings.Inventory.MinGoldToPick and Ao.me.gold < Ao.me.level * 10000 then
  707. return true
  708. else
  709. return false
  710. end
  711. end
  712. --[[ End Inventory Functions ]]--
  713. --[[ Body Functions ]]--
  714. -- Placeholder
  715. --[[ End Body Functions ]]--
  716. --[[ Misc Functions ]]--
  717. GetBaalGCS = function()
  718. local BaalGCS = {}
  719.  
  720. local GCS = Ao.me.stash:findByCode("cm3")
  721.  
  722. for i = 0, GCS:size() - 1 do
  723. if (GCS[i].level >= 91) then table.insert(BaalGCS,table.getn(BaalGCS) + 1,GCS[i]) end
  724. end
  725.  
  726. return BaalGCS
  727. end
  728.  
  729. GetPGems = function()
  730. local gems = {}
  731.  
  732. PGemsA = Ao.me.stash:findByCode("gpv")
  733. PGemsB = Ao.me.stash:findByCode("gpw")
  734. PGemsC = Ao.me.stash:findByCode("gpg")
  735. PGemsD = Ao.me.stash:findByCode("gpr")
  736. PGemsE = Ao.me.stash:findByCode("gpb")
  737. PGemsF = Ao.me.stash:findByCode("skz")
  738. PGemsG = Ao.me.stash:findByCode("gpy")
  739.  
  740. for i = 0, PGemsA:size() - 1 do table.insert(gems,table.getn(gems) + 1,PGemsA[i]) end
  741. for i = 0, PGemsB:size() - 1 do table.insert(gems,table.getn(gems) + 1,PGemsB[i]) end
  742. for i = 0, PGemsC:size() - 1 do table.insert(gems,table.getn(gems) + 1,PGemsC[i]) end
  743. for i = 0, PGemsD:size() - 1 do table.insert(gems,table.getn(gems) + 1,PGemsD[i]) end
  744. for i = 0, PGemsE:size() - 1 do table.insert(gems,table.getn(gems) + 1,PGemsE[i]) end
  745. for i = 0, PGemsF:size() - 1 do table.insert(gems,table.getn(gems) + 1,PGemsF[i]) end
  746. for i = 0, PGemsG:size() - 1 do table.insert(gems,table.getn(gems) + 1,PGemsG[i]) end
  747.  
  748. return gems
  749. end
  750.  
  751. GetStashContainer = function(item)
  752. local to = 0
  753.  
  754. local gotcube = Ao.me.stash:findByCode("box")
  755. if table.getn(Settings.Craft.Rune) == 0
  756. and table.getn(Settings.Craft.Flawed) == 0
  757. and table.getn(Settings.Craft.Normal) == 0
  758. and table.getn(Settings.Craft.Flawless) == 0
  759. and table.getn(Settings.Craft.Perfect) == 0
  760. and gotcube:size() == 1 then
  761. to = Ao.me.cube:findLocation(item)
  762. if to and to.x < 3 and to.y < 4 and to.x >= 0 and to.y >= 0 then
  763. return ItemContainerGC.Cube, to.x, to.y
  764. end
  765. end
  766.  
  767. to = Ao.me.stash:findLocation(item)
  768. if to and to.x < 6 and to.y < 8 and to.x >= 0 and to.y >= 0 then
  769. return ItemContainerGC.Stash, to.x, to.y
  770. end
  771.  
  772. return ItemContainerGC.Inventory, to.x, to.y
  773. end
Add Comment
Please, Sign In to add comment