Advertisement
everezt

Untitled

Jun 21st, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.14 KB | None | 0 0
  1. -- Lootmacro by everest
  2. -- Version: 0.005
  3. -- Release date: 19/06/2018
  4.  
  5. -- If the stuff will be looted to custom bag or your main backpack
  6. local lootToCustomBag = true
  7.  
  8. -- If loot is set to false, it will print the result out instead as a sysmessage
  9. -- Will "magic" items be looted
  10. local lootMagic = false
  11.  
  12. -- Will custom items be looted
  13. local lootCustom = true
  14.  
  15. -- Will custom by name be looted
  16. local lootCustomByName = true
  17.  
  18. -- Always cut corpse before looting
  19. local cutCorpse = false
  20.  
  21. -- Settings "magic" itemtypes, add item types you'd like to be check
  22. -- if they have word "magic" in them
  23. lootedCorpses= {}
  24. itemTypes = {}
  25. itemTypes["magic"] = {5398,5434,5903,5422,
  26.                      5399,7933,7939,7935,
  27.                      8095,7937,5435,5431,
  28.                      5397,8189,5437,8097,
  29.                      5441,8059,9919,3997,
  30.                      5091,3780}
  31.  
  32. -- Loot type settings, just add itemtypes you'd like to be looted
  33. -- 3821 gold
  34. -- 3965 blood vials
  35. -- 3968 daemon bones
  36. -- 3977 obsidian
  37. -- 3982 serpent scales
  38. -- 3964 blood spawns
  39. -- etc,etc
  40. itemTypes["custom"] = {3821,3965,3968,3977,
  41.                       3982,3964,2545}
  42.  
  43. -- Loot if name matches, add part of item name like "onyx"
  44. itemTypes["customByName"] = {"Minotaur Bones",
  45.                             "Phoenix Bones",
  46.                             "Thunderbird Bones",
  47.                             "Frostwing Bones",
  48.                             "Giant Bones"}
  49.  
  50. -- Exclude that customByName item if it has this keyword in it
  51. itemTypes["exclude"] = {"Poison",
  52.                        "Electric"}
  53.  
  54.  
  55.  
  56. -- Macro, do not touch if you don't know what you're doing
  57. -- Macro, do not touch if you don't know what you're doing
  58. -- Macro, do not touch if you don't know what you're doing
  59. function WaitFor(query, timeout)
  60.     timeout = getticks() + timeout
  61.     while dostring("return "..query) == false do
  62.         wait(100)
  63.         if getticks() >= timeout then
  64.             printf("WaitFor: '%s' timed out (%d)", query, timeout)
  65.             return true
  66.         end
  67.     end
  68. end
  69.  
  70.  
  71. function WaitForTarget(timeout)
  72.     WaitFor("not UO.TargCurs", timeout or 10000)
  73. end
  74.  
  75. function Target(msg)
  76. if msg ~= nil then
  77.    UO.SysMessage(msg)
  78. end
  79. UO.TargCurs = true
  80. WaitForTarget()
  81. end
  82.  
  83. function randomWait()
  84.     return math.random(800,1200)
  85. end
  86.  
  87. local lootBag = UO.BackpackID
  88.  
  89. if lootToCustomBag then
  90.     Target("Target lootbag!")
  91.     lootBag = UO.LTargetID
  92. end
  93.  
  94. function loot(nID, nStack)
  95.     UO.Drag(nID, nStack)
  96.     wait(randomWait())
  97.     UO.DropC(lootBag)
  98.     wait(10)
  99. end
  100.  
  101.  
  102. function scanThroughContainer(contID)
  103.  
  104.         if cutCorpse then
  105.            UO.LTargetID = contID
  106.            UO.Macro(1,0,".use dagger")
  107.            WaitFor("UO.TargCurs", 3000)
  108.            UO.Macro(22,0)
  109.            wait(300)              
  110.         end
  111.  
  112.     local containerID = contID
  113.  
  114.     local nCount = UO.ScanItems(true)
  115.  
  116.     for i=1,nCount do
  117.    
  118.         local nID,nType,nKind,nContID,nX,nY,nZ,nStack,nRep,nCol = UO.GetItem(i)
  119.        
  120.         if nContID == containerID then     
  121.            -- let's check if corpse contains cloth types
  122.            for i=0,#itemTypes["magic"] do
  123.                if nType == itemTypes["magic"][i] then
  124.                   -- we have type match, now let's check if it's magic
  125.                   local name, info = UO.Property(nID)
  126.                  
  127.                   if string.match(name, "Magic") then
  128.                      -- it's magical
  129.                      if lootMagic then
  130.                         loot(nID, nStack)
  131.                      else
  132.                          UO.SysMessage("Found: "..name)
  133.                      end
  134.                   end
  135.                                
  136.                end
  137.            end
  138.            
  139.            -- let's check custom item types
  140.            for i=1,#itemTypes["custom"] do
  141.                if nType == itemTypes["custom"][i] then
  142.                    -- we have a custom item match                  
  143.                    if lootCustom then
  144.                       loot(nID, nStack)
  145.                    else
  146.                        local name, info = UO.Property(nID)
  147.                        UO.SysMessage("Found: "..name)
  148.                    end
  149.                    
  150.                end
  151.            end
  152.            
  153.            if #itemTypes["customByName"] > 0 then          
  154.               for i=1,#itemTypes["customByName"] do
  155.              
  156.                   local name, info = UO.Property(nID)
  157.                  
  158.                   if string.match(name, itemTypes["customByName"][i]) then
  159.                      -- we have name match
  160.                      -- check for excludes
  161.                      local excludeThis = false
  162.                      for j=1, #itemTypes["exclude"] do
  163.                          if string.match(name, itemTypes["exclude"][j]) then
  164.                             excludeThis = true
  165.                             break
  166.                          end
  167.                      end
  168.                                          if lootCustomByName and excludeThis == false then
  169.                         loot(nID, nStack)
  170.                      else
  171.                         local name, info = UO.Property(nID)
  172.                         UO.SysMessage("Found: "..name)
  173.                      end                
  174.                   end
  175.                  
  176.               end
  177.            end
  178.            
  179.         end
  180.     end
  181.     table.insert(lootedCorpses, contID)
  182.     UO.SysMessage("Looting done!")
  183.    
  184. end
  185.  
  186.  
  187.  
  188. while true do
  189.      local alreadyLooted = false
  190.      
  191.      if UO.ContType == 8198 and UO.ContSizeX == 144 and UO.ContSizeY == 212 and UO.ContName == "container gump" then
  192.      
  193.         local cID = UO.ContID
  194.        
  195.         for i=1,#lootedCorpses do
  196.             if cID == lootedCorpses[i] then
  197.                alreadyLooted = true
  198.             end
  199.         end
  200.        
  201.         if alreadyLooted == false then
  202.            scanThroughContainer(cID)
  203.         end
  204.      end
  205.      
  206. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement