Jump to content

Loot Abundance above 500%


aaronwkelley

Recommended Posts

I looked into the game code and it would seem that the amount of loot that is spawned is limited by a min/max value specified by the count attributes of <lootcontainer> and <item> elements in loot.xml. From the brief look I took it would seem that the loot container uses the loot abundance value to generate a random number between the min and max and that's how many items are spawned, and the same thing happens for the quantity of each stackable item.

Link to comment
Share on other sites

I looked into the game code and it would seem that the amount of loot that is spawned is limited by a min/max value specified by the count attributes of <lootcontainer> and <item> elements in loot.xml. From the brief look I took it would seem that the loot container uses the loot abundance value to generate a random number between the min and max and that's how many items are spawned, and the same thing happens for the quantity of each stackable item.

 

You mean something like this?

 

actual max value = nominal max value * (loot abundance/100).

 

actual min value = nominal min value * (loot abundance/100)

 

items= random_number_between(actual min value, actual max value)

 

That would be my natural guess how it works. But it doesn't explain where the 500% limit comes from. Is there an explicit statement where loot abundance is capped at 500 ?

 

(PS: If loot abundance is then also applied to the quantity of items it would explain why people at 25% loot abundance get the impression that they get even less than 25%.)

 

Or are you saying nominal max value is never exeeded but the random number at higher loot abundance would be much more often nearer to that max value?

Link to comment
Share on other sites

You mean something like this?

 

actual max value = nominal max value * (loot abundance/100).

 

actual min value = nominal min value * (loot abundance/100)

 

items= random_number_between(actual min value, actual max value)

 

That would be my natural guess how it works. But it doesn't explain where the 500% limit comes from. Is there an explicit statement where loot abundance is capped at 500 ?

 

(PS: If loot abundance is then also applied to the quantity of items it would explain why people at 25% loot abundance get the impression that they get even less than 25%.)

 

Or are you saying nominal max value is never exeeded but the random number at higher loot abundance would be much more often nearer to that max value?

 

I gave the code another quick look. It seems loot containers more or less work like this:

Gets abundance and multiplies it by 0.01, gets a value between the min and max of the count attribute for the <lootcontainer> element and multiplies that by the abundance. This is the number of items it will spawn, but the maximum it can spawn would be the size of the container (as defined by the size attribute of the <lootcontainer> element). Once it figures out how many items to spawn, it calls a method named LootContainer.SpawnLootItemsFromList and tells it to spawn that many items, but from here on out, it uses the abundance of 1 (100%), ignoring the game setting. So loot abundance only comes into play for the amount of items spawned, nothing more, and large values are a bit meaningless. For a garbage can, for instance, the min/max is 0,2. 500% LootAbundance will spawn either 0, 5, or 10 items. This is never exact because during the spawning of the items there is the probability that nothing spawns in a slot. So yes, a higher loot abundance than 500 will have a slight effect, as 600 will spawn either 0, 6, or 12 items. As 12 is the maximum for a garbage can, the highest loot abundance value that will have an effect would be 1200, as that will spawn either 0, 12, or 12 items (0*12, 1*12, 2*12, with maximum of 12).

 

Does this make any sense? I've not spent a ton of time looking at the code and the code is rather loopy (meaning there are several loops involved here and it gets a bit hard to follow, especially when recursive), but that's the sense I got from it. I was rather surprised seeing that an abundance of 1 is hardcoded for the actual items. I wonder what it would be like if this function was prefixed in a Harmony patch to always use the game setting abundance.

Link to comment
Share on other sites

I gave the code another quick look. It seems loot containers more or less work like this:

Gets abundance and multiplies it by 0.01, gets a value between the min and max of the count attribute for the <lootcontainer> element and multiplies that by the abundance. This is the number of items it will spawn, but the maximum it can spawn would be the size of the container (as defined by the size attribute of the <lootcontainer> element). Once it figures out how many items to spawn, it calls a method named LootContainer.SpawnLootItemsFromList and tells it to spawn that many items, but from here on out, it uses the abundance of 1 (100%), ignoring the game setting. So loot abundance only comes into play for the amount of items spawned, nothing more, and large values are a bit meaningless. For a garbage can, for instance, the min/max is 0,2. 500% LootAbundance will spawn either 0, 5, or 10 items. This is never exact because during the spawning of the items there is the probability that nothing spawns in a slot. So yes, a higher loot abundance than 500 will have a slight effect, as 600 will spawn either 0, 6, or 12 items. As 12 is the maximum for a garbage can, the highest loot abundance value that will have an effect would be 1200, as that will spawn either 0, 12, or 12 items (0*12, 1*12, 2*12, with maximum of 12).

 

Does this make any sense? I've not spent a ton of time looking at the code and the code is rather loopy (meaning there are several loops involved here and it gets a bit hard to follow, especially when recursive), but that's the sense I got from it. I was rather surprised seeing that an abundance of 1 is hardcoded for the actual items. I wonder what it would be like if this function was prefixed in a Harmony patch to always use the game setting abundance.

 

Thanks for looking into it.

 

Hardcoding an abundance of 1 after rolling for the number of items makes absolute sense as you don't want abundance to multiply. I.e. at an abundance of 2 you would get 2 times the items in the container. If each of the items is another loot list with a count that then leads to another random roll, the abundance factor of 2 would again apply and you would get 2 * 2 = 4 times the items.

 

Are you sure the code uses integers when rolling for items? If they use fractional numbers, your first example could still result in any number of items between 0 and 10

Link to comment
Share on other sites

Hardcoding an abundance of 1 after rolling for the number of items makes absolute sense as you don't want abundance to multiply. I.e. at an abundance of 2 you would get 2 times the items in the container. If each of the items is another loot list with a count that then leads to another random roll, the abundance factor of 2 would again apply and you would get 2 * 2 = 4 times the items.

 

That's not what I mean. All of the methods that handle the spawning of loot are coded to work with abundance, but they're just given the number 1. The way abundance is used in the other methods is to control the quantity of stackable items, up to a maximum equal to the Stacknumber set in items.xml for the item, which controls how large a stack is for that item.

 

Are you sure the code uses integers when rolling for items? If they use fractional numbers, your first example could still result in any number of items between 0 and 10

My bad, again. There's a part in the code that converts the number to an integer, and I misunderstood what's going on, as it's a little confusing, but the random number is multiplied by the abundance before it's converted to an integer, and so yes, it can be other numbers in that range. There's also a chance that 1 is added to the number. I thought I'd create a little demo to show you exactly how to code works, in case you're interested. Here it is: https://jsfiddle.net/ryuyan/7n4fdbrg/

 

If you look at the code, I tried to translate the randomSpawnCount and randomRange from the game's source as closely as possible. When a loot container is opened, this code is used with the LootAbundance setting to decide how many items to try to spawn. Keep in mind, the final number should be then limited by the size of the container. As there's no container size in my demo you won't see that upper limit.

Link to comment
Share on other sites

That's not what I mean. All of the methods that handle the spawning of loot are coded to work with abundance, but they're just given the number 1. The way abundance is used in the other methods is to control the quantity of stackable items, up to a maximum equal to the Stacknumber set in items.xml for the item, which controls how large a stack is for that item.

 

 

My bad, again. There's a part in the code that converts the number to an integer, and I misunderstood what's going on, as it's a little confusing, but the random number is multiplied by the abundance before it's converted to an integer, and so yes, it can be other numbers in that range. There's also a chance that 1 is added to the number. I thought I'd create a little demo to show you exactly how to code works, in case you're interested. Here it is: https://jsfiddle.net/ryuyan/7n4fdbrg/9/

 

If you look at the code, I tried to translate the randomSpawnCount and randomRange from the game's source as closely as possible. When a loot container is opened, this code is used with the LootAbundance setting to decide how many items to try to spawn. Keep in mind, the final number should be then limited by the size of the container. As there's no container size in my demo you won't see that upper limit.

 

Thanks for the code example. Just as expected . And it does look like loot abundance above 500% should be possible. After all not all loot containers are as small as a garbage can. My guess is loot abundance might get capped to 500 when the xml is read in and the values are checked for plausibility.

Link to comment
Share on other sites

Thanks for the code example. Just as expected . And it does look like loot abundance above 500% should be possible. After all not all loot containers are as small as a garbage can.

 

You're welcome, and yes, you're right. Higher abundance should fill larger containers.

 

My guess is loot abundance might get capped to 500 when the xml is read in and the values are checked for plausibility.

I checked the code that loads the game settings (loaded from an sdf file not xml), because that was what I initially expected, but I could find no such limitation. I also tested setting it to above 500 via the console and it had the expected effect of being able to spawn more than 10 items in the garbage. I will try to test seeing it above 500 in the actual settings and load the game and see if it changes it.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...