Advertisement
Cavitt

Untitled

May 1st, 2012
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.75 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.     local tries, corpseID = 0
  35.     repeat
  36.         corpseID = Self.UseItemFromGround(position.x, position.y, position.z)
  37.         wait(1000, 1200)
  38.         local Corpse = Container.GetFromIndex(bpcount)
  39.         tries = tries + 1
  40.     until Corpse:isOpen() or tries == 5
  41.     if(corpseID == 9582 or corpseID == 4037)then
  42.       print("Looting water elemental...")
  43.       wait(2000)
  44.       local used = fishWaterElemental(position)
  45.       wait(2000)
  46.       print("Tried to fish itemid: " .. used)
  47.     end
  48.     return tonumber(corpseID)
  49. end
  50.  
  51. function lootItems(items, bpcount)
  52.     local Corpse = Container.GetFromIndex(bpcount - 1)
  53.     for x = 1, #items do
  54.         for y = 0, Corpse:ItemCount() do
  55.             local item = Corpse:GetItemData(y)
  56.             if(type(items[x]) == "table")then
  57.                 if(item.id == items[x][1])then
  58.                     Corpse:MoveItemToContainer(y, items[x][2], 0)
  59.                     wait(500, 1000)
  60.                     lootItems(items, bpcount)
  61.                 end
  62.             elseif(item.id == items[x])then
  63.                 Corpse:MoveItemToContainer(y, 0, 0)
  64.                 wait(500, 1000)
  65.                 lootItems(items, bpcount)
  66.             end
  67.         end
  68.     end
  69. end
  70.  
  71. function fishWaterElemental(position)
  72.     local cont = Container.GetFirst()
  73.     while (cont:isOpen()) do
  74.         for spot = 0, cont:ItemCount() do
  75.             local item = cont:GetItemData(spot)
  76.             if(item.id == 3483)then
  77.                 local corpse = cont:UseItemWithGround(spot, position.x, position.y, position.z)
  78.                 wait(2000,2200)
  79.                 return corpse
  80.             end
  81.         end
  82.         cont = cont:GetNext()
  83.     end
  84.     return false
  85. end
  86.  
  87. while true do
  88.     local position = watchTarget()
  89.     if  position ~= nil then
  90.         setBotEnabled(false)
  91.         local corpseID = openCorpse(position, getOpenBackpacks())
  92.         if(corpseID > 0)then
  93.           lootItems(itemList, getOpenBackpacks())
  94.           print("Corpse ID: " ..corpseID)
  95.         end
  96.         setTargetingEnabled(true)
  97.         setWalkerEnabled(true)
  98.     end
  99.     sleep(50)
  100. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement