How does loot really work?

Users who are viewing this thread

dantw said:
it looks like you are saying that having 10 heroes would be the equivolent to having 30 normal soldiers in my party.
Yes, this is what I'm saying.  :smile:

dantw said:
Let's say you win a battle and it calculates that you and your army get's 50 items of loot and 20 items go to your army.
That's an incorrect interpretation.
There is only 1 value scripts calculate - YOUR loot probability - which is then used by the engine to loot every single defeated soldier.
How exactly the engine uses it is a mystery.
Everything I've learned about it (which is very little) I described in this thread in my first message where I explain how loot works.
 
Leonion said:
noosers said:
So where´s the definition of 10 shares for the PC and 3 for the NPC?

player_loot_share (for the player) and hero_loot_share (for companions) are defined in header_parties in module system.
In .txt files variables just turn into numbers, so we get the following:
2133 2 1224979098644774912 10
1650 2 1224979098644774913 648518346341351424
6 3 1224979098644774914 1 1224979098644774913
1652 3 1224979098644774915 648518346341351424 1224979098644774914
4 0
2147485155 1 1224979098644774915
1653 3 1224979098644774916 648518346341351424 1224979098644774914
2105 2 1224979098644774912 1224979098644774916
5 0
2105 2 1224979098644774912 3
3 0
3 0
2133 2 72057594037927936 1224979098644774912

P.S. Your interpretation is not entirely correct.
The game first assigns a player's share to the num_player_party_shares variable.
Then it starts "picking" every companion (the word "companion" means "any troop that accompanies a player character (or a lord or simply other members of a party if a party does not have a leader)" in the scripts, while who we call "companions" are generally referred to as "heroes") one by one and do the following:
- Is it not a hero? Alright, then let's add a total stack size to the num_player_party_shares variable.
- Oh, is it not not a hero? Let's try "else_try" then and add +3 to the num_player_party_shares variable.

Thanks!

I tried changing these, and the hero_loot_share appears to work properly, but the part of the code you bolded for player_loot_share is almost certainly something else. Instead of affecting the player's share, it's just a general divider for loot - setting it higher than 10 decreases overall loot and setting it lower increases loot. I tested this both with a medium army and with only the player character. In the latter tests, setting it to 1 moderately improves item loot and multiplies looted denars by almost 10. Setting it to 400 vastly decreases loot and cuts looted denars to about 1/40th.

Do you have any idea what's going on? This is the only "10" in that part of the file, and the player's share seems to be 10 based on the tests. Did the code that uses those variables get changed in a patch? Am I missing something obvious? :???:


EDIT:

Okay, I went back and read the thread again, more closely. You post on the first page revealed what I got wrong, I understood it this time. The game doesn't use the player's share to determine how much to give to the player out of the total loot, it just uses the shares thing as a divider in the total loot calculating formula. So no way to increase the player's share without screwing up loot calculations. All I can do is set the hero and soldier shares to 0.

I'll go test which of the two "1"s in calculate_main_party_shares is the soldier share and also if fractional shares work, then edit again with the results to hopefully help anyone else who runs across this.

EDIT 2:

Fractions don't work, trying to use them results in looting bugging out, with no loot screen appearing and negative denars looted. So no easy way to set hero and troop shares to very low values compared to the player.

Oh, well. I'm not bothered about not giving them loot, they get plenty of regular pay. Plus, we only ever get a fraction of the enemy's equipment anyway. We can RP it as the soldiers getting the rest, and when it's just the player, that 1 person can't carry away everything, so the most damaged items get left behind for the scavengers.

As for eliminating troop shares, I looked at the code Leonion gave at the top of page 2, and it looks like there's no multiplier for their shares, it's just the number of troops getting added straight to the party share. So I changed it so that the game adds "0" instead of ":stack_size" to ":num_player_party_shares". In "scripts.txt", it's this part of "calculate_main_party_shares":

2105 2 1224979098644774912 1224979098644774916 5 0 2105 2 1224979098644774912

Replace that coloured number with 0 and troops will no longer affect loot.
 
Thanks for showing how the scripts file works! If there is a more complete description somewhere I'd love to know about it! Do you know the number for the mathematical operation sqrt?

This has been an issue that's bugged me for a while so with the information you provided I made stab at a fractional fix.
This seems to work so I figured I'd share it as my first post.

I added two new operations near the end of the script.
After "3 0 3 0" and before "2133 2"
"2107 2 1224979098644774912 2 2108 2 1224979098644774912 3"  This multiplies the total party share by 2 and then divides by 3.
I also had to change the "13" at the start of the script to a 15

Code:
calculate_main_party_shares -1
 15 2133 2 1224979098644774912 10 1650 2 1224979098644774913 648518346341351424 6 3 1224979098644774914 1 1224979098644774913 1652 3 1224979098644774915 648518346341351424 1224979098644774914 4 0 2147485155 1 1224979098644774915 1653 3 1224979098644774916 648518346341351424 1224979098644774914 2105 2 1224979098644774912 1224979098644774916 5 0 2105 2 1224979098644774912 3 3 0 3 0 2107 2 1224979098644774912 2 2108 2 1224979098644774912 3 2133 2 72057594037927936 1224979098644774912
 
I couldn't find a val_sqrt, only store_sqrt. That one is 2125.

It's probably best to download the module system if you want to make more complicated changes. A bit of work setting it up will pay off in much easier modding.
 
Leonion said:
The more expensive an item is, the lower the chance to loot it. An item that has a price of 10000 denars will have a roughly 7 times smaller probability to be looted than an item that's worth 10 denars.

I'm looking over the looting code but can't seem to figure out where this formula is dictated (using Floris Dev Suite base). Any assistance would be helpful, as for my mod the economics have been adjusted so that high end items are far more expensive than in native (in an attempt to encourage their acquisition via looting, instead). I believe however that this has had the unintended consequence of making them all but impossible to actually show up in the loot lists, as even at 10 loot my current test char is pulling next to nothing of high value. I had always assumed that an item's loot chance hinged on their abundance value but from what you've said this isn't the case, which is very unfortunate. Thanks!
 
You will not find this formula in the module system.
It's an engine thing which only became known after tests.

If you want to adjust looting to work with higher prices, you need to increase loot probability value which is provided to troop_loot_troop operation in party_calculate_loot script.
 
Back
Top Bottom