17,097
edits
(_getItemLootSourceTable: Add fraction alongside percentage for chance stat) |
(Undo revision 44208 - Resulted in script errors) Tag: Undo |
||
Line 543: | Line 543: | ||
local result = '{| class="wikitable sortable stickyHeader"' | local result = '{| class="wikitable sortable stickyHeader"' | ||
result = result..'\r\n|- class="headerRow-0"' | result = result..'\r\n|- class="headerRow-0"' | ||
result = result..'\r\n!Source!!Source Type!!Quantity!! | result = result..'\r\n!Source!!Source Type!!Quantity!!Chance' | ||
--Set up function for adding rows | --Set up function for adding rows | ||
local buildRow = function(source, type, minqty, qty, | local buildRow = function(source, type, minqty, qty, chance) | ||
if minqty == nil then minqty = 1 end | if minqty == nil then minqty = 1 end | ||
local rowTxt = '\r\n|-' | local rowTxt = '\r\n|-' | ||
rowTxt = rowTxt..'\r\n|style="text-align: left;"|'..source | rowTxt = rowTxt..'\r\n|style ="text-align: left;"|'..source | ||
rowTxt = rowTxt..'\r\n|style="text-align: left;"|'..type | rowTxt = rowTxt..'\r\n|style ="text-align: left;"|'..type | ||
rowTxt = rowTxt..'\r\n|style="text-align: right;" data-sort-value | rowTxt = rowTxt..'\r\n|style ="text-align: right;" data-sort-value:"'..qty..'"|'..minqty | ||
if qty ~= minqty then rowTxt = rowTxt..' - '..qty end | if qty ~= minqty then rowTxt = rowTxt..' - '..qty end | ||
rowTxt = rowTxt..'\r\n|style ="text-align: right;"|'..Shared.round(chance, 2, 2)..'%' | |||
return rowTxt | return rowTxt | ||
end | end | ||
local dropRows = {} | local dropRows = {} | ||
--Alright, time to go through a few ways to get the item | --Alright, time to go through a few ways to get the item | ||
--First up: Can we kill somebody and take theirs? | --First up: Can we kill somebody and take theirs? | ||
Line 589: | Line 581: | ||
end | end | ||
end | end | ||
if monster.lootChance ~= nil | if wt > 0 then | ||
local lootChance = monster.lootChance ~= nil and monster.lootChance or 100 | |||
chance = ((wt * lootChance) / (totalWt * 100)) * 100 | |||
end | end | ||
end | end | ||
if | if chance > 0 then | ||
--If we're dealing with a boss, this is a Dungeon row instead | --If we're dealing with a boss, this is a Dungeon row instead | ||
if monster.isBoss and not Shared.contains(item.name, 'Shard') then | if monster.isBoss and not Shared.contains(item.name, 'Shard') then | ||
local dung = Areas.getMonsterAreas(i - 1)[1] | local dung = Areas.getMonsterAreas(i - 1)[1] | ||
local sourceTxt = Icons.Icon({dung.name, type="dungeon", notext=true}) | local sourceTxt = Icons.Icon({dung.name, type="dungeon", notext=true}) | ||
table.insert(dropRows, {source = sourceTxt, type = '[[Dungeon]]', minqty = minqty, qty = qty, | table.insert(dropRows, {source = sourceTxt, type = '[[Dungeon]]', minqty = minqty, qty = qty, chance = chance}) | ||
else | else | ||
local sourceTxt = Icons.Icon({monster.name, type='monster'}) | local sourceTxt = Icons.Icon({monster.name, type='monster'}) | ||
table.insert(dropRows, {source = sourceTxt, type = '[[Monster]]', minqty = minqty, qty = qty, | table.insert(dropRows, {source = sourceTxt, type = '[[Monster]]', minqty = minqty, qty = qty, chance = chance}) | ||
end | end | ||
end | end | ||
Line 609: | Line 602: | ||
if sourceOverrides['Dungeon'][item.id] ~= nil then | if sourceOverrides['Dungeon'][item.id] ~= nil then | ||
local sourceTxt = Icons.Icon({sourceOverrides['Dungeon'][item.id], type="dungeon", notext=true}) | local sourceTxt = Icons.Icon({sourceOverrides['Dungeon'][item.id], type="dungeon", notext=true}) | ||
table.insert(dropRows, {source=sourceTxt, type='[[Dungeon]]', minqty=1, qty=1, | table.insert(dropRows, {source=sourceTxt, type='[[Dungeon]]', minqty=1, qty=1, chance=100}) | ||
end | end | ||
Line 628: | Line 621: | ||
if wt > 0 then | if wt > 0 then | ||
chance = (wt / totalWt) * 100 | |||
local sourceTxt = Icons.Icon({item2.name, type='item'}) | local sourceTxt = Icons.Icon({item2.name, type='item'}) | ||
table.insert(dropRows, {source = sourceTxt, type = '[[Chest]]', minqty = 1, qty = qty, | table.insert(dropRows, {source = sourceTxt, type = '[[Chest]]', minqty = 1, qty = qty, chance = chance}) | ||
end | end | ||
end | end | ||
Line 649: | Line 643: | ||
end | end | ||
if wt > 0 then | if wt > 0 then | ||
chance = (wt / totalWt) * 75 | |||
local sourceTxt = Icons.Icon({npc.name, type='thieving'}) | local sourceTxt = Icons.Icon({npc.name, type='thieving'}) | ||
table.insert(dropRows, {source = sourceTxt, type = thiefType, minqty = 1, qty = qty, | table.insert(dropRows, {source = sourceTxt, type = thiefType, minqty = 1, qty = qty, chance = chance}) | ||
end | end | ||
end | end | ||
Line 660: | Line 653: | ||
if item.type == 'Gem' then | if item.type == 'Gem' then | ||
local mineType = Icons.Icon({'Mining', type='skill'}) | local mineType = Icons.Icon({'Mining', type='skill'}) | ||
local thisGemChance = Items.GemTable[item.name].chance | local thisGemChance = Items.GemTable[item.name].chance | ||
table.insert(dropRows, {source = '[[Mining#Gems|Gem]]', type = mineType, minqty = 1, qty = 1, chance = thisGemChance}) | |||
table.insert(dropRows, {source = '[[Mining#Gems|Gem]]', type = mineType, minqty = 1, qty = 1, | |||
local magicType = Icons.Icon({'Magic', type = 'skill'}) | local magicType = Icons.Icon({'Magic', type = 'skill'}) | ||
table.insert(dropRows, {source = Icons.Icon({"Rags to Riches I", type="spell"}), type = magicType, minqty = 1, qty = 1, | table.insert(dropRows, {source = Icons.Icon({"Rags to Riches I", type="spell"}), type = magicType, minqty = 1, qty = 1, chance = thisGemChance}) | ||
table.insert(dropRows, {source = Icons.Icon({"Rags to Riches II", type="spell"}), type = magicType, minqty = 1, qty = 1, | table.insert(dropRows, {source = Icons.Icon({"Rags to Riches II", type="spell"}), type = magicType, minqty = 1, qty = 1, chance = thisGemChance}) | ||
end | end | ||
Line 674: | Line 663: | ||
local fishSource = '[[Fishing#Special|Special]]' | local fishSource = '[[Fishing#Special|Special]]' | ||
local fishType = Icons.Icon({'Fishing', type='skill'}) | local fishType = Icons.Icon({'Fishing', type='skill'}) | ||
table.insert(dropRows, {source = fishSource, type = fishType, minqty = 1, qty = 1, | local thisChance = (item.fishingCatchWeight / Items.specialFishWt) * 100 | ||
table.insert(dropRows, {source = fishSource, type = fishType, minqty = 1, qty = 1, chance = thisChance}) | |||
end | end | ||
Line 680: | Line 670: | ||
local fishSource = '[[Fishing#Junk|Junk]]' | local fishSource = '[[Fishing#Junk|Junk]]' | ||
local fishType = Icons.Icon({'Fishing', type='skill'}) | local fishType = Icons.Icon({'Fishing', type='skill'}) | ||
table.insert(dropRows, {source = fishSource, type = fishType, minqty = 1, qty = 1, | local thisChance = 100 / Items.junkCount | ||
table.insert(dropRows, {source = fishSource, type = fishType, minqty = 1, qty = 1, chance = thisChance}) | |||
end | end | ||
--Make sure to return nothing if there are no drop sources | --Make sure to return nothing if there are no drop sources | ||
if Shared.tableCount(dropRows) == 0 then return '' end | if Shared.tableCount(dropRows) == 0 then return '' end | ||
table.sort(dropRows, function(a, b) return a. | table.sort(dropRows, function(a, b) return a.chance > b.chance end) | ||
for i, data in pairs(dropRows) do | for i, data in pairs(dropRows) do | ||
result = result..buildRow(data.source, data.type, data.minqty, data.qty, data. | result = result..buildRow(data.source, data.type, data.minqty, data.qty, data.chance) | ||
end | end | ||