Advertisement
Cavitt

Alternative Looter

Apr 27th, 2012
2,478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.98 KB | None | 0 0
  1. --[[ ADD ITEMS TO LOOT LIST BELOW, BE SURE TO SEPARATE EACH ITEM WITH A COMMA ]]--
  2. --[[ VALID INPUT IS ID OR {ID, CONTAINER} ]]--
  3.  
  4. local itemList = {
  5.     3031,
  6.     {3577, 0}
  7. }
  8.  
  9. --[[ DO NOT EDIT BELOW ]]--
  10.  
  11. function getOpenBackpacks()
  12.     local count = 0
  13.     local bp = Container:GetFirst()
  14.     while bp:isOpen() do
  15.         count = count + 1
  16.         bp = bp:GetNext()
  17.     end
  18.     return count
  19. end
  20.  
  21. function watchTarget()
  22.     local Target = Creature.GetByID(Self.TargetID())
  23.     local pos = {}
  24.     if Target:isAlive() then
  25.         while Target:isAlive() do
  26.             pos = Target:Position()
  27.             sleep(50)
  28.         end
  29.         return pos
  30.     end
  31. end
  32.  
  33. function openCorpse(position, bpcount)
  34.     setBotEnabled(false)
  35.     local tries = 0
  36.     repeat
  37.         Self.UseItemFromGround(position.x, position.y, position.z)
  38.         wait(700, 1100)
  39.         local Corpse = Container.GetFromIndex(bpcount)
  40.         wait(700, 1100)
  41.     until Corpse:isOpen() or tries == 5
  42. end
  43.  
  44. function lootItems(items, bpcount)
  45.     local Corpse = Container.GetFromIndex(bpcount - 1)
  46.     for x = 1, #items do
  47.         for y = 0, Corpse:ItemCount() do
  48.             local item = Corpse:GetItemData(y)
  49.             if type(items[x]) == "table" then
  50.                 if item.id == items[x][1] then
  51.                     Corpse:MoveItemToContainer(y, items[x][2], 0)
  52.                     wait(500, 1000)
  53.                     lootItems(items, bpcount)
  54.                 end
  55.             else
  56.                 if item.id == items[x] then
  57.                     Corpse:MoveItemToContainer(y, 0, 0)
  58.                     wait(500, 1000)
  59.                     lootItems(items, bpcount)
  60.                 end
  61.             end
  62.         end
  63.     end
  64.     setTargetingEnabled(true)
  65.     setWalkerEnabled(true)
  66. end
  67.  
  68. while true do
  69.     local position = watchTarget()
  70.     if  position ~= nil then
  71.         openCorpse(position, getOpenBackpacks())        
  72.         lootItems(itemList, getOpenBackpacks())
  73.     end
  74.     sleep(50)
  75. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement