Anonymous

Module:Items/SourceTables: Difference between revisions

From Melvor Idle
_getItemLootSourceTable: Add fraction alongside percentage for chance stat (Attempt 2)
(_getItemLootSourceTable: Add fraction alongside percentage for chance stat)
(_getItemLootSourceTable: Add fraction alongside percentage for chance stat (Attempt 2))
(One intermediate revision by the same user not shown)
Line 588: Line 588:
           qty = loot[3]
           qty = loot[3]
         end
         end
      end
      if monster.lootChance ~= nil then
        wt = wt * monster.lootChance / 100
       end
       end
     end
     end
     if wt > 0 then
    local lootChance = monster.lootChance ~= nil and monster.lootChance or 100
     if wt > 0 and lootChance > 0 then
      local sourceTxt = nil
      local typeTxt = nil
       --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})
         sourceTxt = Icons.Icon({dung.name, type='dungeon', notext=true})
         table.insert(dropRows, {source = sourceTxt, type = '[[Dungeon]]', minqty = minqty, qty = qty, weight = wt, totalWeight = totalWt})
         typeTxt = '[[Dungeon]]'
       else
       else
         local sourceTxt = Icons.Icon({monster.name, type='monster'})
         sourceTxt = Icons.Icon({monster.name, type='monster'})
         table.insert(dropRows, {source = sourceTxt, type = '[[Monster]]', minqty = minqty, qty = qty, weight = wt, totalWeight = totalWt})
         typeTxt = '[[Monster]]'
       end
       end
      table.insert(dropRows, {source = sourceTxt, type = typeTxt, minqty = minqty, qty = qty, weight = wt * lootChance, totalWeight = totalWt * 100})
     end
     end
   end
   end
Line 608: Line 609:
   --Special exception for the Fire/Infernal Cape and first two lore books as bonus dungeon drops
   --Special exception for the Fire/Infernal Cape and first two lore books as bonus dungeon drops
   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, weight = 1, totalWeight = 1})
     table.insert(dropRows, {source=sourceTxt, type='[[Dungeon]]', minqty=1, qty=1, weight = 1, totalWeight = 1})
   end
   end
Line 650: Line 651:
       if wt > 0 then
       if wt > 0 then
         -- There is a constant 75% chance of gaining an item per successful steal attempt
         -- There is a constant 75% chance of gaining an item per successful steal attempt
        wt = wt * 0.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, weight = wt, totalWeight = totalWt})
         table.insert(dropRows, {source = sourceTxt, type = thiefType, minqty = 1, qty = qty, weight = wt * 75, totalWeight = totalWt * 100})
       end
       end
     end
     end