Hey guys. I am doing a xml based loot table system for my framework im making . I am trying to do weighted loot drops using these tables.
I basically have a list of items correctly loading and spawning in the crates except i beleive i am not doing truly weighted loot. Each item has a % chance between 0 and 100 which transtaltes to a max loot weight selectable by the user. Assume the max weight is 10,000 for now. so weight 0 = 0% and 10000 = 100%.
//Get references to random items
foreach (int item in lootBucket)
{
LootItem rollItem = selectedTable.GetItem(item);
int finalWeight = GetRandomWeight(3);
Debug.Log("Rolling for " + rollItem.itemId + ", item weight = " + rollItem.weight + ", roll = " + finalWeight);
if (finalWeight < rollItem.weight - weightOffset)
{
finalLoot.Add(rollItem);
numberLeft--;
}
}
This works out whether or not the random Weight is less than the weight of that of the object. if it is it gets spawned. But i am under the assumption that truly weighted loot uses the sum of all weights in the list of loot. How would this be applied to my method?
↧