diff --git a/code/modules/food/kitchen/smartfridge/engineering.dm b/code/modules/food/kitchen/smartfridge/engineering.dm index 22983611f03..8141ca496df 100644 --- a/code/modules/food/kitchen/smartfridge/engineering.dm +++ b/code/modules/food/kitchen/smartfridge/engineering.dm @@ -9,6 +9,9 @@ /obj/machinery/smartfridge/sheets/persistent persistent = /datum/persistent/storage/smartfridge/sheet_storage +/obj/machinery/smartfridge/sheets/persistent_lossy + persistent = /datum/persistent/storage/smartfridge/sheet_storage/lossy + /obj/machinery/smartfridge/sheets/accept_check(var/obj/item/O) return istype(O, /obj/item/stack/material) diff --git a/code/modules/food/kitchen/smartfridge/hydroponics.dm b/code/modules/food/kitchen/smartfridge/hydroponics.dm index ebf706c25ef..9b50136d796 100644 --- a/code/modules/food/kitchen/smartfridge/hydroponics.dm +++ b/code/modules/food/kitchen/smartfridge/hydroponics.dm @@ -1,5 +1,5 @@ /obj/machinery/smartfridge/produce - name = "\improper SmartFridge" + name = "\improper Smart Produce Storage" desc = "For storing all sorts of perishable foods!" icon = 'icons/obj/vending.dmi' icon_state = "fridge_food" @@ -9,6 +9,9 @@ /obj/machinery/smartfridge/produce/persistent persistent = /datum/persistent/storage/smartfridge/produce +/obj/machinery/smartfridge/produce/persistent_lossy + persistent = /datum/persistent/storage/smartfridge/produce/lossy + /obj/machinery/smartfridge/produce/accept_check(var/obj/item/O as obj) if(istype(O,/obj/item/weapon/reagent_containers/food/snacks/grown/) || istype(O,/obj/item/seeds/)) return TRUE diff --git a/code/modules/persistence/persistence.dm b/code/modules/persistence/serialize.dm similarity index 100% rename from code/modules/persistence/persistence.dm rename to code/modules/persistence/serialize.dm diff --git a/code/modules/persistence/storage/smartfridge.dm b/code/modules/persistence/storage/smartfridge.dm index 0b2eee0ca1f..74e5ead48ee 100644 --- a/code/modules/persistence/storage/smartfridge.dm +++ b/code/modules/persistence/storage/smartfridge.dm @@ -25,6 +25,13 @@ store_per_type = TRUE target_type = /obj/machinery/smartfridge/sheets + var/stacks_go_missing = FALSE // Variable rate depletion of stacks inter-round + +/datum/persistent/storage/smartfridge/sheet_storage/lossy + name = "sheet_storage_lossy" + max_storage = 250 + stacks_go_missing = TRUE + /datum/persistent/storage/smartfridge/sheet_storage/generate_items(var/list/L) . = list() for(var/obj/item/stack/material/S as anything in L) @@ -32,13 +39,34 @@ log_debug("Warning: Sheet_storage persistent datum tried to create [S]") continue - var/count = L[S] - while(count > 0) - S = new S - S.amount = min(count, S.get_max_amount()) - count -= S.get_amount() - . += S + // Skip entire stack if we hit the chance + if(prob(go_missing_chance)) + continue + var/count = L[S] + + var/obj/item/stack/material/inst = S + var/max_amount = initial(inst.max_amount) + + // Delete some stacks if we want + if(stacks_go_missing) + var/fuzzy = rand(-5,5) + switch(count / max_amount) + if(0 to 1) + count -= 10+fuzzy // 1 stack or less, lose 10 + if(1 to 10) + count -= max_amount+fuzzy // 1 to 10 stacks, lose a stack + if(10 to INFINITY) + count -= max_amount*3+fuzzy // 10+ stacks, lose 3 stacks + if(count <= 0) + qdel(inst) + continue + + while(count > 0) + inst = new S + inst.amount = min(count, max_amount) + count -= inst.get_amount() + . += inst /datum/persistent/storage/smartfridge/produce @@ -47,6 +75,10 @@ store_per_type = FALSE target_type = /obj/machinery/smartfridge/produce +/datum/persistent/storage/smartfridge/produce/lossy + name = "fruit_storage_lossy" + go_missing_chance = 12.5 // 10% loss between rounds + /datum/persistent/storage/smartfridge/produce/assemble_token(var/T) var/list/subtok = splittext(T, " ") if(subtok.len != 2) @@ -74,6 +106,8 @@ . = list() for(var/datum/stored_item/I in entry.item_records) + if(prob(go_missing_chance)) + continue if(LAZYLEN(I.instances)) var/obj/item/weapon/reagent_containers/food/snacks/grown/G = I.instances[1] if(!istype(G)) diff --git a/code/modules/persistence/storage/storage.dm b/code/modules/persistence/storage/storage.dm index 9ad9531cbc7..38674d149a6 100644 --- a/code/modules/persistence/storage/storage.dm +++ b/code/modules/persistence/storage/storage.dm @@ -1,13 +1,19 @@ /datum/persistent/storage entries_expire_at = 1 + + // Don't use these for storage persistence. If someone takes some sheets out and puts them back in mixed in with + // new sheets, how do you know the age of the stack? If you want sheets to 'decay', see go_missing_chance entries_decay_at = 0 entry_decay_weight = 0 + // // // // + tokens_per_line = PERSISTENCE_VARIABLE_TOKEN_LENGTH - 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 + var/go_missing_chance = 0 // Chance an item will fail to be spawned in from persistence and need to be restocked + /datum/persistent/storage/SetFilename() if(name) filename = "data/persistent/storage/[lowertext(using_map.name)]-[lowertext(name)].txt" @@ -26,7 +32,7 @@ return null subtok[1] = text2path(subtok[1]) - subtok[2] = text2num( subtok[2]) + subtok[2] = text2num(subtok[2]) // Ensure we've found a token describing the quantity of a path if(subtok.len != 2 || \ @@ -73,6 +79,8 @@ . = list() for(var/path in L) for(var/i in 1 to L[path]) + if(prob(go_missing_chance)) + continue var/atom/A = create_item(path) if(!QDELETED(A)) . += A diff --git a/vorestation.dme b/vorestation.dme index ee0866c3ffd..d735e41eb13 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -3287,7 +3287,7 @@ #include "code\modules\persistence\filth.dm" #include "code\modules\persistence\graffiti.dm" #include "code\modules\persistence\noticeboard.dm" -#include "code\modules\persistence\persistence.dm" +#include "code\modules\persistence\serialize.dm" #include "code\modules\persistence\datum\persistence_datum.dm" #include "code\modules\persistence\effects\filth.dm" #include "code\modules\persistence\effects\graffiti.dm"