Module:Skills/Gathering: Difference between revisions

added minlevel check to p.canItemBeStolen
(added level to the output from getThievingSourcesForItem)
(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
break
minLevel = 1
end
end
end
end
--Then check each NPC to see if they drop the item
--Then check area unique drops
if not result then
local areaNPCs = {}
for i, npc in pairs(SkillData.Thieving.NPCs) do
for i, area in pairs(SkillData.Thieving.Areas) do
for j, drop in pairs(npc.lootTable) do
for j, drop in pairs(area.uniqueDrops) do
if drop[1] == itemID then
if drop.itemID == itemID then
result = true
result = true
for k, npcID in pairs(area.npcs) do
areaNPCs[npcID] = drop.qty
end
end
end
if npc.uniqueDrop ~= nil and npc.uniqueDrop.itemID == itemID then
result = true
end
if result  then
break
end
end
end
end
end
end
--Then check area unique drops
--Then check each NPC to see if they drop the item
if not result then
for i, npc in pairs(SkillData.Thieving.NPCs) do
for i, area in pairs(SkillData.Thieving.Areas) do
for j, drop in pairs(npc.lootTable) do
for j, drop in pairs(area.uniqueDrops) do
if drop[1] == itemID then
if drop.itemID == itemID then
result = true
result = true
if npc.level < minLevel then
break
minLevel = npc.level
end
end
end
end
end
if result then
break
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