Skip to content

Commit

Permalink
[MIRROR] Reworks morgue trays. Freezers and morgue trays now have the…
Browse files Browse the repository at this point in the history
…ir own internal air. Organs no longer take damage when below freezing temperatures. [MDB IGNORE] (#1097)

* Reworks morgue trays. Freezers and morgue trays now have their own internal air. Organs no longer take damage when below freezing temperatures.

* Move the SR Edit to can_defib_client

---------

Co-authored-by: SkyratBot <[email protected]>
Co-authored-by: Watermelon914 <[email protected]>
Co-authored-by: SomeRandomOwl <[email protected]>
  • Loading branch information
4 people authored Dec 13, 2023
1 parent 2314062 commit 66099f6
Show file tree
Hide file tree
Showing 8 changed files with 210 additions and 103 deletions.
37 changes: 0 additions & 37 deletions code/__HELPERS/game.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,6 @@
return null
return format_text ? format_text(checked_area.name) : checked_area.name

/** toggle_organ_decay
* inputs: first_object (object to start with)
* outputs:
* description: A pseudo-recursive loop based off of the recursive mob check, this check looks for any organs held
* within 'first_object', toggling their frozen flag. This check excludes items held within other safe organ
* storage units, so that only the lowest level of container dictates whether we do or don't decompose
*/
/proc/toggle_organ_decay(atom/first_object)

var/list/processing_list = list(first_object)
var/list/processed_list = list()
var/index = 1
var/obj/item/organ/found_organ

while(index <= length(processing_list))

var/atom/object_to_check = processing_list[index]

if(isorgan(object_to_check))
found_organ = object_to_check
found_organ.organ_flags ^= ORGAN_FROZEN

else if(iscarbon(object_to_check))
var/mob/living/carbon/mob_to_check = object_to_check
for(var/organ in mob_to_check.organs)
found_organ = organ
found_organ.organ_flags ^= ORGAN_FROZEN

for(var/atom/contained_to_check in object_to_check) //objects held within other objects are added to the processing list, unless that object is something that can hold organs safely
if(!processed_list[contained_to_check] && !istype(contained_to_check, /obj/structure/closet/crate/freezer) && !istype(contained_to_check, /obj/structure/closet/secure_closet/freezer))
processing_list+= contained_to_check

index++
processed_list[object_to_check] = object_to_check

return

///Tries to move an atom to an adjacent turf, return TRUE if successful
/proc/try_move_adjacent(atom/movable/atom_to_move, trydir)
var/turf/atom_turf = get_turf(atom_to_move)
Expand Down
2 changes: 1 addition & 1 deletion code/game/data_huds.dm
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Medical HUD! Basic mode needs suit sensors on.
if(HAS_TRAIT(src, TRAIT_XENO_HOST))
holder.icon_state = "hudxeno"
else if(stat == DEAD || (HAS_TRAIT(src, TRAIT_FAKEDEATH)))
if((key || get_ghost(FALSE, FALSE)) && (can_defib() & DEFIB_REVIVABLE_STATES)) // SKYRAT EDIT : OG : if((key || get_ghost(FALSE, TRUE)) && (can_defib() & DEFIB_REVIVABLE_STATES))
if(can_defib_client())
holder.icon_state = "huddefib"
else
holder.icon_state = "huddead"
Expand Down
46 changes: 43 additions & 3 deletions code/game/objects/structures/crates_lockers/closets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ GLOBAL_LIST_EMPTY(roundstart_station_closets)
var/secure = FALSE
var/can_install_electronics = TRUE

var/is_maploaded = FALSE

var/contents_initialized = FALSE
/// is this closet locked by an exclusive id, i.e. your own personal locker
var/datum/weakref/id_card = null
Expand All @@ -84,6 +86,14 @@ GLOBAL_LIST_EMPTY(roundstart_station_closets)
/// access types for card reader
var/list/access_choices = TRUE

/// Whether this closet is sealed or not. If sealed, it'll have its own internal air
var/sealed = FALSE

/// Internal gas for this closet.
var/datum/gas_mixture/internal_air
/// Volume of the internal air
var/air_volume = TANK_STANDARD_VOLUME * 3

/datum/armor/structure_closet
melee = 20
bullet = 10
Expand Down Expand Up @@ -129,8 +139,9 @@ GLOBAL_LIST_EMPTY(roundstart_station_closets)
add_to_roundstart_list()

// if closed, any item at the crate's loc is put in the contents
if (mapload && !opened)
. = INITIALIZE_HINT_LATELOAD
if (mapload)
is_maploaded = TRUE
. = INITIALIZE_HINT_LATELOAD

populate_contents_immediate()
var/static/list/loc_connections = list(
Expand All @@ -148,9 +159,23 @@ GLOBAL_LIST_EMPTY(roundstart_station_closets)

/obj/structure/closet/LateInitialize()
. = ..()
if(!opened)
if(!opened && is_maploaded)
take_contents()

if(sealed)
var/datum/gas_mixture/external_air = loc.return_air()
if(external_air && is_maploaded)
internal_air = external_air.copy()
else
internal_air = new()
START_PROCESSING(SSobj, src)

/obj/structure/closet/return_air()
if(sealed)
return internal_air
else
return ..()

//USE THIS TO FILL IT, NOT INITIALIZE OR NEW
/obj/structure/closet/proc/PopulateContents()
SEND_SIGNAL(src, COMSIG_CLOSET_POPULATE_CONTENTS)
Expand All @@ -162,10 +187,25 @@ GLOBAL_LIST_EMPTY(roundstart_station_closets)

/obj/structure/closet/Destroy()
id_card = null
QDEL_NULL(internal_air)
QDEL_NULL(door_obj)
GLOB.roundstart_station_closets -= src
return ..()

/obj/structure/closet/process(seconds_per_tick)
if(!sealed)
return PROCESS_KILL
process_internal_air(seconds_per_tick)

/obj/structure/closet/proc/process_internal_air(seconds_per_tick)
if(opened)
var/datum/gas_mixture/current_exposed_air = loc.return_air()
if(!current_exposed_air)
return
if(current_exposed_air.equalize(internal_air))
var/turf/location = get_turf(src)
location.air_update_turf()

/obj/structure/closet/update_appearance(updates=ALL)
. = ..()
if(opened || broken || !secure)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@
/// If FALSE, we will protect the first person in the freezer from an explosion / nuclear blast.
var/jones = FALSE
paint_jobs = null

/obj/structure/closet/secure_closet/freezer/before_open(mob/living/user, force)
. = ..()
if(!.)
return FALSE

toggle_organ_decay(src)
return TRUE

/obj/structure/closet/secure_closet/freezer/after_close(mob/living/user)
. = ..()
toggle_organ_decay(src)

/obj/structure/closet/secure_closet/freezer/Destroy()
toggle_organ_decay(src)
return ..()

/obj/structure/closet/secure_closet/freezer/Initialize(mapload)
. = ..()
toggle_organ_decay(src)
sealed = TRUE

/// The rate at which the internal air mixture cools
var/cooling_rate_per_second = 4
/// Minimum temperature of the internal air mixture
var/minimum_temperature = T0C - 60

/obj/structure/closet/secure_closet/freezer/process_internal_air(seconds_per_tick)
if(opened)
var/datum/gas_mixture/current_exposed_air = loc.return_air()
if(!current_exposed_air)
return
// The internal air won't cool down the external air when the freezer is opened.
internal_air.temperature = max(current_exposed_air.temperature, internal_air.temperature)
return ..()
else
if(internal_air.temperature <= minimum_temperature)
return
var/temperature_decrease_this_tick = min(cooling_rate_per_second * seconds_per_tick, internal_air.temperature - minimum_temperature)
internal_air.temperature -= temperature_decrease_this_tick

/obj/structure/closet/secure_closet/freezer/ex_act()
if(jones)
Expand Down
35 changes: 19 additions & 16 deletions code/game/objects/structures/crates_lockers/crates.dm
Original file line number Diff line number Diff line change
Expand Up @@ -229,22 +229,25 @@
icon_state = "freezer"
base_icon_state = "freezer"
paint_jobs = null

/obj/structure/closet/crate/freezer/before_open(mob/living/user, force)
. = ..()
if(!.)
return FALSE

toggle_organ_decay(src)
return TRUE

/obj/structure/closet/crate/freezer/after_close(mob/living/user)
. = ..()
toggle_organ_decay(src)

/obj/structure/closet/crate/freezer/Destroy()
toggle_organ_decay(src)
return ..()
sealed = TRUE
/// The rate at which the internal air mixture cools
var/cooling_rate_per_second = 4
/// Minimum temperature of the internal air mixture
var/minimum_temperature = T0C - 60

/obj/structure/closet/crate/freezer/process_internal_air(seconds_per_tick)
if(opened)
var/datum/gas_mixture/current_exposed_air = loc.return_air()
if(!current_exposed_air)
return
// The internal air won't cool down the external air when the freezer is opened.
internal_air.temperature = max(current_exposed_air.temperature, internal_air.temperature)
return ..()
else
if(internal_air.temperature <= minimum_temperature)
return
var/temperature_decrease_this_tick = min(cooling_rate_per_second * seconds_per_tick, internal_air.temperature - minimum_temperature)
internal_air.temperature -= temperature_decrease_this_tick

/obj/structure/closet/crate/freezer/blood
name = "blood freezer"
Expand Down
Loading

0 comments on commit 66099f6

Please sign in to comment.