Closed vadcx closed 6 months ago
While I understand that you'd like these values to change, I don't really see a reason to change them. The hardest chance to roll is still possible thus it makes sense (for me) to keep it the way it is currently.
@Gerkiz it's not about the unlikeliness (what a word) of the probabilities themselves, but the way the code is written makes me think it wasn't intended this way.
Anyway to show what I mean, I needed to calculate the probabilities. The 1/8
number refers to the respective probability of the taken branch like random(1, 8) == 1
. The coin value = chance * (minCoin+maxCoin)/2
Therefore the expected average drop is 6.22 coins per add_loot. The "rarer" branches add virtually nothing due to their decrease of chance corresponding to increase in max value.
What I am arguing here for, either this was not the expected outcome and rarer chests should've been dropping more /or/ the roll code could be simplified.
If you want to signal to a player that this chests dropped a huge amount of coins (who looks at them anyway?) then my best suggestion is to use up more chest slots for coins (if possible) while inserting the same amount as before. Otherwise the rarer rolls, like (1,1024), will get lost in their average count and not look impressive. "Looking impressive" means a skew towards the individual number 1024. Like "Wow, I got this many coins from a single chest!
https://github.com/ComfyFactory/ComfyFactorio/blob/cd2cda7a0e7a92d76180cd41bd2692b21e140fc4/maps/mountain_fortress_v3/loot.lua#L61-L71
Public.add_loot
andPublic.add_loot_rare
The if-elseif chain likely produces unexpected chance rolls.In the end getting the (1, 512) roll is probably on the order of "never" if you calculate the entire chain (absolute probability). I would rewrite it to a flat / weighted random roll with one interval [1, 512] is rolled once and evaluated once. Then the first (1,8) roll becomes 1 to 512/8 (64) and so on.