Skip to content

Commit 93cbd7c

Browse files
committed
Make random subset supplypacks use expected price instead of raw sum
1 parent 4ef0253 commit 93cbd7c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

code/datums/supplypacks/supplypack.dm

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@ var/global/list/cargoprices = list()
1919
. = ..() // make sure children are set up
2020
if(is_category())
2121
return // don't do any of this for categories
22+
var/total_contained = 0
23+
for(var/entry in contains)
24+
total_contained += max(1, contains[entry])
2225
if(!num_contained)
23-
for(var/entry in contains)
24-
num_contained += max(1, contains[entry])
26+
num_contained = total_contained
2527
if(isnull(cost))
2628
cost = 0
2729
for(var/entry in contains)
2830
cost += atom_info_repository.get_combined_worth_for(entry) * max(1, contains[entry])
31+
cost *= num_contained / total_contained // if you get a random selection, it costs the expected value rather than the total worth. gambling!
2932
cost += containertype ? atom_info_repository.get_single_worth_for(containertype) : 0
3033
cost = max(1, NONUNIT_CEILING((cost * WORTH_TO_SUPPLY_POINTS_CONSTANT * SSsupply.price_markup), WORTH_TO_SUPPLY_POINTS_ROUND_CONSTANT))
3134
global.cargoprices[name] = cost

0 commit comments

Comments
 (0)