4,951
edits
Falterfire (talk | contribs) (added level to the output from getThievingSourcesForItem) |
Falterfire (talk | contribs) (added minlevel check to p.canItemBeStolen) |
||
Line 570: | Line 570: | ||
function p.canItemBeStolen(itemID) | function p.canItemBeStolen(itemID) | ||
local result = false | local result = false | ||
local minLevel = 99 | |||
--First, check if this is a rare item | --First, check if this is a rare item | ||
for i, drop in pairs(SkillData.Thieving.RareItems) do | for i, drop in pairs(SkillData.Thieving.RareItems) do | ||
if drop.itemID == itemID then | if drop.itemID == itemID then | ||
result = true | result = true | ||
minLevel = 1 | |||
end | end | ||
end | end | ||
--Then check | --Then check area unique drops | ||
local areaNPCs = {} | |||
for i, area in pairs(SkillData.Thieving.Areas) do | |||
for j, drop in pairs(area.uniqueDrops) do | |||
if drop.itemID == itemID then | |||
result = true | |||
for k, npcID in pairs(area.npcs) do | |||
areaNPCs[npcID] = drop.qty | |||
end | end | ||
end | end | ||
end | end | ||
end | end | ||
--Then check | --Then check each NPC to see if they drop the item | ||
for i, npc in pairs(SkillData.Thieving.NPCs) do | |||
for j, drop in pairs(npc.lootTable) do | |||
if drop[1] == itemID then | |||
result = true | |||
if npc.level < minLevel then | |||
minLevel = npc.level | |||
end | end | ||
end | end | ||
end | |||
if | |||
if npc.uniqueDrop ~= nil and npc.uniqueDrop.itemID == itemID then | |||
result = true | |||
if npc.level < minLevel then | |||
minLevel = npc.level | |||
end | |||
end | |||
if areaNPCs[npc.id] ~= nil then | |||
if npc.level < minLevel then | |||
minLevel = npc.level | |||
end | end | ||
end | end | ||
end | end | ||
return result | return result, minLevel | ||
end | end | ||