4,951
edits
Falterfire (talk | contribs) No edit summary |
Falterfire (talk | contribs) (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) |
||
Line 477: | Line 477: | ||
local areaTxt = '===Possible Area Unique Drops===' | local areaTxt = '===Possible Area Unique Drops===' | ||
areaTxt = areaTxt..'\r\nAny Area Unique Drop is equally likely to be obtained after a successful pickpocket. ' | areaTxt = areaTxt..'\r\nAny Area Unique Drop is equally likely to be obtained after a successful pickpocket. ' | ||
areaTxt = areaTxt..'\r\nEach Area Unique Drop is rolled for separately, so it is possible to receive multiple Area Unique Drops from a single action. ' | |||
areaTxt = areaTxt..'The chance of receiving an Area Unique drop is tripled if the 95% Thieving Mastery Pool checkpoint is active.' | areaTxt = areaTxt..'The chance of receiving an Area Unique drop is tripled if the 95% Thieving Mastery Pool checkpoint is active.' | ||
Line 484: | Line 485: | ||
areaTxt = areaTxt..'!!Price!!colspan="2"|Chance' | areaTxt = areaTxt..'!!Price!!colspan="2"|Chance' | ||
local dropCount = Shared.tableCount(area.uniqueDrops) | local dropCount = Shared.tableCount(area.uniqueDrops) | ||
local dropLines = {} | local dropLines = {} | ||
for i, drop in pairs(area.uniqueDrops) do | for i, drop in pairs(area.uniqueDrops) do | ||
Line 491: | Line 491: | ||
lineTxt = lineTxt..'\r\n|-\r\n|'..Icons.Icon({thisItem.name, type='item'}) | lineTxt = lineTxt..'\r\n|-\r\n|'..Icons.Icon({thisItem.name, type='item'}) | ||
lineTxt = lineTxt..'||'..drop.qty..'||data-sort-value="'..thisItem.sellsFor..'"|'..Icons.GP(thisItem.sellsFor) | lineTxt = lineTxt..'||'..drop.qty..'||data-sort-value="'..thisItem.sellsFor..'"|'..Icons.GP(thisItem.sellsFor) | ||
lineTxt = lineTxt..'||style="text-align:right"|'.. | lineTxt = lineTxt..'||style="text-align:right"|'..thievingAreaLootChance | ||
lineTxt = lineTxt..'||'..Shared.round( | lineTxt = lineTxt..'||'..Shared.round(thievingAreaLootChance, 2, 2)..'%' | ||
dropLines[thisItem.name] = lineTxt | dropLines[thisItem.name] = lineTxt | ||
end | end | ||
Line 566: | Line 566: | ||
return result | return result | ||
end | |||
function p.canItemBeStolen(itemID) | |||
local result = false | |||
--First, 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 | |||
end | |||
end | |||
if npc.uniqueDrop ~= nil and npc.uniqueDrop.itemID == itemID then | |||
result = true | |||
end | |||
if result then | |||
break | |||
end | |||
end | |||
--Then check area unique drops | |||
if not result then | |||
for i, area in pairs(SkillData.Thieving.Areas) do | |||
for j, drop in pairs(area.uniqueDrops) do | |||
if drop.itemID == itemID then | |||
result = true | |||
break | |||
end | |||
end | |||
if result then | |||
break | |||
end | |||
end | |||
end | |||
return result | |||
end | |||
function p.getThievingSourcesForItem(itemID) | |||
local resultArray = {} | |||
local areaNPCs = {} | |||
--First check area unique drops | |||
--If an area drops the item, add all the NPC ids to the list so we can add them later | |||
if not result then | |||
for i, area in pairs(SkillData.Thieving.Areas) do | |||
for j, drop in pairs(area.uniqueDrops) do | |||
if drop.itemID == itemID then | |||
for k, npcID in pairs(area.npcs) do | |||
areaNPCs[npcID] = drop.qty | |||
end | |||
break | |||
end | |||
end | |||
end | |||
end | |||
--Now go through and get drop chances on each NPC if needed | |||
for i, npc in pairs(SkillData.Thieving.NPCs) do | |||
local totalWt = 0 | |||
local dropWt = 0 | |||
local dropQty = 0 | |||
for j, drop in pairs(npc.lootTable) do | |||
totalWt = totalWt + drop[2] | |||
if drop[1] == itemID then | |||
dropWt = drop[2] | |||
dropQty = drop[3] | |||
end | |||
end | |||
if dropWt > 0 then | |||
table.insert(resultArray, {npc = npc.name, minQty = 1, maxQty = dropQty, chance = dropWt / totalWt * 100}) | |||
end | |||
--Chance of -1 on unique drops is to indicate variable chance | |||
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}) | |||
end | |||
if areaNPCs[npc.id] ~= nil then | |||
table.insert(resultArray, {npc = npc.name, minQty = areaNPCs[npc.id], maxQty = areaNPCs[npc.id], chance = thievingAreaLootChance}) | |||
end | |||
end | |||
return resultArray | |||
end | end | ||
return p | return p |