diff --git a/code/__DEFINES/atmospherics.dm b/code/__DEFINES/atmospherics.dm index 8762a06221b..5ded1c469c8 100644 --- a/code/__DEFINES/atmospherics.dm +++ b/code/__DEFINES/atmospherics.dm @@ -298,3 +298,6 @@ GLOBAL_LIST_INIT(pipe_paint_colors, list( "violet" = rgb(64,0,128), "yellow" = rgb(255,198,0) )) + +#define MIASMA_CORPSE_MOLES 0.02 +#define MIASMA_GIBS_MOLES 0.005 diff --git a/code/datums/components/rot.dm b/code/datums/components/rot.dm new file mode 100644 index 00000000000..12fa99cdd5c --- /dev/null +++ b/code/datums/components/rot.dm @@ -0,0 +1,60 @@ +/datum/component/rot + var/amount = 1 + +/datum/component/rot/Initialize(new_amount) + if(!isatom(parent)) + return COMPONENT_INCOMPATIBLE + + if(new_amount) + amount = new_amount + + START_PROCESSING(SSprocessing, src) + +/datum/component/rot/process() + var/atom/A = parent + + var/turf/open/T = get_turf(A) + if(!istype(T)) + return + + var/datum/gas_mixture/air = T.return_air() + var/list/cached_gases = air.gases + + ASSERT_GAS(/datum/gas/miasma, air) + cached_gases[/datum/gas/miasma][MOLES] += amount + T.air_update_turf() + +/datum/component/rot/corpse + amount = MIASMA_CORPSE_MOLES + +/datum/component/rot/corpse/Initialize() + if(!ishuman(parent)) + return COMPONENT_INCOMPATIBLE + . = ..() + +/datum/component/rot/corpse/process() + var/mob/living/carbon/human/H = parent + if(H.stat != DEAD) + qdel(src) + return + + // Wait a bit before decaying + if(world.time - H.timeofdeath < 2 MINUTES) + return + + // Properly stored corpses shouldn't create miasma + if(istype(H.loc, /obj/structure/closet/crate/coffin)|| istype(H.loc, /obj/structure/closet/body_bag) || istype(H.loc, /obj/structure/bodycontainer)) + return + + // No decay if formaldehyde in corpse or when the corpse is charred + if(H.reagents.has_reagent("formaldehyde", 15) || H.has_trait(TRAIT_HUSK)) + return + + // Also no decay if corpse chilled or not organic/undead + if(H.bodytemperature <= T0C-10 || (!(MOB_ORGANIC in H.mob_biotypes) && !(MOB_UNDEAD in H.mob_biotypes))) + return + + ..() + +/datum/component/rot/gibs + amount = MIASMA_GIBS_MOLES diff --git a/code/game/objects/effects/decals/cleanable/humans.dm b/code/game/objects/effects/decals/cleanable/humans.dm index cdbba71c930..802a5bca4a3 100644 --- a/code/game/objects/effects/decals/cleanable/humans.dm +++ b/code/game/objects/effects/decals/cleanable/humans.dm @@ -54,9 +54,20 @@ random_icon_states = list("gib1", "gib2", "gib3", "gib4", "gib5", "gib6") mergeable_decal = FALSE + var/already_rotting = FALSE + /obj/effect/decal/cleanable/blood/gibs/Initialize(mapload, list/datum/disease/diseases) . = ..() reagents.add_reagent("liquidgibs", 5) + if(already_rotting) + start_rotting(rename=FALSE) + else + addtimer(CALLBACK(src, .proc/start_rotting), 2 MINUTES) + +/obj/effect/decal/cleanable/blood/gibs/proc/start_rotting(rename=TRUE) + name = "rotting [initial(name)]" + desc += " It smells terrible." + AddComponent(/datum/component/rot/gibs) /obj/effect/decal/cleanable/blood/gibs/ex_act(severity, target) return @@ -108,6 +119,7 @@ name = "old rotting gibs" desc = "Space Jesus, why didn't anyone clean this up? It smells terrible." bloodiness = 0 + already_rotting = TRUE /obj/effect/decal/cleanable/blood/gibs/old/Initialize(mapload, list/datum/disease/diseases) . = ..() diff --git a/code/modules/mob/living/carbon/life.dm b/code/modules/mob/living/carbon/life.dm index c5046329189..3285e1ac63c 100644 --- a/code/modules/mob/living/carbon/life.dm +++ b/code/modules/mob/living/carbon/life.dm @@ -33,7 +33,7 @@ if(stat == DEAD) stop_sound_channel(CHANNEL_HEARTBEAT) - rot() + LoadComponent(/datum/component/rot/corpse) //Updates the number of stored chemicals for powers handle_changeling() @@ -303,38 +303,6 @@ if(!.) return FALSE //to differentiate between no internals and active, but empty internals -// Make corpses rot, emitting miasma -/mob/living/carbon/proc/rot() - // Properly stored corpses shouldn't create miasma - if(istype(loc, /obj/structure/closet/crate/coffin)|| istype(loc, /obj/structure/closet/body_bag) || istype(loc, /obj/structure/bodycontainer)) - return - - // No decay if formaldehyde in corpse or when the corpse is charred - if(reagents.has_reagent("formaldehyde", 15) || has_trait(TRAIT_HUSK)) - return - - // Also no decay if corpse chilled or not organic/undead - if(bodytemperature <= T0C-10 || (!(MOB_ORGANIC in mob_biotypes) && !(MOB_UNDEAD in mob_biotypes))) - return - - // Wait a bit before decaying - if(world.time - timeofdeath < 1200) - return - - var/deceasedturf = get_turf(src) - - // Closed turfs don't have any air in them, so no gas building up - if(!istype(deceasedturf,/turf/open)) - return - - var/turf/open/miasma_turf = deceasedturf - - var/list/cached_gases = miasma_turf.air.gases - - ASSERT_GAS(/datum/gas/miasma, miasma_turf.air) - cached_gases[/datum/gas/miasma][MOLES] += 0.02 - miasma_turf.air_update_turf() - /mob/living/carbon/proc/handle_blood() return diff --git a/tgstation.dme b/tgstation.dme index e35878932c9..556b1a96c89 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -358,6 +358,7 @@ #include "code\datums\components\radioactive.dm" #include "code\datums\components\remote_materials.dm" #include "code\datums\components\riding.dm" +#include "code\datums\components\rot.dm" #include "code\datums\components\rotation.dm" #include "code\datums\components\signal_redirect.dm" #include "code\datums\components\slippery.dm"