Module:Skills/Gathering: Difference between revisions

adding weights to p.getThievingSourcesForItem. Removing p.canItemBeStolen because it's not needed right now
(fixed drop chance for normal loot)
(adding weights to p.getThievingSourcesForItem. Removing p.canItemBeStolen because it's not needed right now)
Line 566: Line 566:
return result
return result
end
function p.canItemBeStolen(itemID)
local result = false
local minLevel = 99
--First, check if this is a rare item
for i, drop in pairs(SkillData.Thieving.RareItems) do
if drop.itemID == itemID then
result = true
minLevel = 1
end
end
--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
--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
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
return result, minLevel
end
end


Line 653: Line 601:
end
end
if dropWt > 0 then
if dropWt > 0 then
table.insert(resultArray, {npc = npc.name, minQty = 1, maxQty = dropQty, chance = dropWt / totalWt * thievingNormalLootChance, level = npc.level})
table.insert(resultArray, {npc = npc.name, minQty = 1, maxQty = dropQty, wt = dropWt * thievingNormalLootChance, totalWt = totalWt * 100, level = npc.level})
end
end
--Chance of -1 on unique drops is to indicate variable chance
--Chance of -1 on unique drops is to indicate variable chance
if npc.uniqueDrop ~= nil and npc.uniqueDrop.itemID == itemID then
if npc.uniqueDrop ~= nil and npc.uniqueDrop.itemID == itemID then
table.insert(resultArray, {npc = npc.name, minQty = npc.uniqueDrop.qty, maxQty = npc.uniqueDrop.qty, chance = -1, level = npc.level})
table.insert(resultArray, {npc = npc.name, minQty = npc.uniqueDrop.qty, maxQty = npc.uniqueDrop.qty, wt = -1, totalWt = -1, level = npc.level})
end
end
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, level = npc.level})
table.insert(resultArray, {npc = npc.name, minQty = areaNPCs[npc.id], maxQty = areaNPCs[npc.id], wt = thievingAreaLootChance, totalWt = 100, level = npc.level})
end
end
end
end
Line 668: Line 616:
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
table.insert(resultArray, {npc = 'all', minQty = 1, maxQty = 1, chance = drop.chance, level = 1})
table.insert(resultArray, {npc = 'all', minQty = 1, maxQty = 1, wt = drop.chance, totalWt = 100, level = 1})
end
end
end
end