From f8b4cd611ec83a6ba90c89971fbdcf211bc377e0 Mon Sep 17 00:00:00 2001 From: CHOMPStation2 <58959929+CHOMPStation2@users.noreply.github.com> Date: Thu, 29 Feb 2024 06:20:05 -0700 Subject: [PATCH] [MIRROR] Smart Storage Tweaks (#7835) Co-authored-by: Killian <49700375+KillianKirilenko@users.noreply.github.com> Co-authored-by: CHOMPStation2 --- code/modules/persistence/storage/smartfridge.dm | 13 ++++++++++--- code/modules/persistence/storage/storage.dm | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/code/modules/persistence/storage/smartfridge.dm b/code/modules/persistence/storage/smartfridge.dm index ef7b643ceb..addb37ed16 100644 --- a/code/modules/persistence/storage/smartfridge.dm +++ b/code/modules/persistence/storage/smartfridge.dm @@ -25,12 +25,17 @@ store_per_type = TRUE target_type = /obj/machinery/smartfridge/sheets + var/min_retained = 75 //minimum percentage of current stock for retention + var/max_retained = 80 //maximum percentage of current stock for retention var/stacks_go_missing = FALSE // Variable rate depletion of stacks inter-round + var/minimum_storage_reserve = FALSE // ...but still try to maintain a minimum reserve? /datum/persistent/storage/smartfridge/sheet_storage/lossy name = "sheet storage lossy" - max_storage = 250 + min_storage = 20 //if the amount is at or below this, don't cull + max_storage = 500 //if the amount is above this, cull it to this amount THEN do math stacks_go_missing = TRUE + minimum_storage_reserve = TRUE /datum/persistent/storage/smartfridge/sheet_storage/variable_max name = "variable max storage" @@ -65,8 +70,10 @@ // Delete some stacks if we want if(stacks_go_missing) - var/fuzzy = rand(55,65)*0.01 // loss of 35-45% with rounding down - count = round(count*fuzzy) + var/fuzzy = rand(min_retained,max_retained)*0.01 // loss of 35-45% with rounding down + if(!minimum_storage_reserve || (count > min_storage && minimum_storage_reserve)) + count = round(count*fuzzy) + if(count <= 0) continue diff --git a/code/modules/persistence/storage/storage.dm b/code/modules/persistence/storage/storage.dm index a1b16e39b1..d430ee8cda 100644 --- a/code/modules/persistence/storage/storage.dm +++ b/code/modules/persistence/storage/storage.dm @@ -9,6 +9,7 @@ entry_decay_weight = 0 // // // // + var/min_storage = 0 var/max_storage = 0 var/store_per_type = FALSE // If true, will store up to max_storage for each type stored var/target_type = null // Path of the thing that this expects to put stuff into