Module:Skills/Gathering: Difference between revisions

added rare items to getThievingSourcesForItem and canItemBeStolen
(Corrected the area drop chance for items to reflect ability to roll each item separately. Also added getThievingSourcesForItem and canItemBeStolen for use in Items/SourceTables)
(added rare items to getThievingSourcesForItem and canItemBeStolen)
Line 570: Line 570:
function p.canItemBeStolen(itemID)
function p.canItemBeStolen(itemID)
local result = false
local result = false
--First, check each NPC to see if they drop the item
--First, check if this is a rare item
for i, npc in pairs(SkillData.Thieving.NPCs) do
for i, drop in pairs(SkillData.Thieving.RareItems) do
for j, drop in pairs(npc.lootTable) do
if drop.itemID == itemID then
if drop[1] == itemID then
result = true
break
end
end
--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 j, drop in pairs(npc.lootTable) do
if drop[1] == itemID then
result = true
end
end
if npc.uniqueDrop ~= nil and npc.uniqueDrop.itemID == itemID then
result = true
result = true
end
end
end
if result  then
if npc.uniqueDrop ~= nil and npc.uniqueDrop.itemID == itemID then
break
result = true
end
end
if result  then
break
end
end
end
end
Line 649: Line 659:
if areaNPCs[npc.id] ~= nil then
if areaNPCs[npc.id] ~= nil then
table.insert(resultArray, {npc = npc.name, minQty = areaNPCs[npc.id], maxQty = areaNPCs[npc.id], chance = thievingAreaLootChance})
table.insert(resultArray, {npc = npc.name, minQty = areaNPCs[npc.id], maxQty = areaNPCs[npc.id], chance = thievingAreaLootChance})
end
end
for i, drop in pairs(SkillData.Thieving.RareItems) do
if drop.itemID == itemID then
table.insert(resultArray, {npc = 'all', minQty = 1, maxQty = 1, chance = drop.chance})
end
end
end
end