Skip to content

Commit

Permalink
Baymed 1.1: Cryogenics (and bugfixes) (#443)
Browse files Browse the repository at this point in the history
* bay cryo and other things

* fix cryo rendering

* this is honestly probably better

* features. bugfixes. unit test.

* typo

* bandage bug

* some bugs

* feature + fuck off
  • Loading branch information
Kapu1178 committed Jul 31, 2023
1 parent e38037f commit 576db08
Show file tree
Hide file tree
Showing 47 changed files with 286 additions and 405 deletions.
15 changes: 8 additions & 7 deletions _maps/map_files/MetaStation/MetaStation.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -20727,10 +20727,10 @@
/obj/effect/turf_decal/stripes/line{
dir = 9
},
/obj/machinery/atmospherics/components/unary/portables_connector/visible{
dir = 1
/obj/machinery/atmospherics/components/binary/pump{
dir = 8;
name = "Cryogenics Pump"
},
/obj/machinery/portable_atmospherics/canister/anesthetic_mix,
/turf/open/floor/iron/dark,
/area/station/medical/cryo)
"gtf" = (
Expand Down Expand Up @@ -29863,13 +29863,13 @@
/turf/open/floor/iron/dark,
/area/station/service/chapel/funeral)
"jJq" = (
/obj/machinery/atmospherics/components/unary/portables_connector/visible{
dir = 1
},
/obj/effect/turf_decal/stripes/line{
dir = 1
},
/obj/machinery/portable_atmospherics/canister/anesthetic_mix,
/obj/machinery/atmospherics/components/unary/portables_connector/visible{
dir = 8
},
/obj/machinery/portable_atmospherics/canister/oxygen/cryo,
/turf/open/floor/iron/dark,
/area/station/medical/cryo)
"jJC" = (
Expand Down Expand Up @@ -30415,6 +30415,7 @@
/obj/effect/turf_decal/trimline/blue/filled/end,
/obj/structure/cable,
/obj/structure/disposalpipe/segment,
/obj/machinery/atmospherics/pipe/smart/manifold4w/cyan/visible,
/turf/open/floor/iron/white,
/area/station/medical/cryo)
"jVJ" = (
Expand Down
7 changes: 7 additions & 0 deletions code/__DEFINES/maths.dm
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,10 @@
// )

#define GET_TRUE_DIST(a, b) (a == null || b == null) ? -1 : max(abs(a.x -b.x), abs(a.y-b.y), abs(a.z-b.z))

// A neat little helper to convert the value X, that's between imin and imax, into a value
// that's proportionally scaled and in range of omin and omax.
#define MAP(x, imin, imax, omin, omax) ((x - imin) * (omax - omin) / (imax - imin) + omin)

/// See above, but clamps the resulting value between omin and omax
#define MAPCLAMP(x, imin, imax, omin, omax) clamp(MAP(x, imin, imax, omin, omax), omin, omax)
22 changes: 22 additions & 0 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,28 @@

#define REAGENTS_EFFECT_MULTIPLIER (REAGENTS_METABOLISM / 0.4) // By defining the effect multiplier this way, it'll exactly adjust all effects according to how they originally were with the 0.4 metabolism

/// Applies a Chemical Effect with the given magnitude to the mob
#define APPLY_CHEM_EFFECT(mob, effect, magnitude) \
if(effect in mob.chem_effects) { \
mob.chem_effects[effect] += magnitude; \
} \
else { \
mob.chem_effects[effect] = magnitude; \
}

///Check chem effect presence in a mob
#define CHEM_EFFECT_MAGNITUDE(mob, effect) (mob.chem_effects[effect] || 0)

//CHEMICAL EFFECTS
/// Prevents damage from freezing. Boolean.
#define CE_CRYO "cryo"
/// Organ preservation effects like formaldehyde. Boolean.
#define CE_ORGAN_PRESERVATION "formaldehyde"
/// Mob cannot breathe. Boolean.
#define CE_RESPIRATORY_FAILURE "cantbreathe"

// Partial stasis sources
#define STASIS_CRYOGENIC_FREEZING "cryo"
// Eye protection
#define FLASH_PROTECTION_SENSITIVE -1
#define FLASH_PROTECTION_NONE 0
Expand Down
8 changes: 3 additions & 5 deletions code/__DEFINES/reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
#define REAGENT_STANDARD_PURITY 0.75

//reagent bitflags, used for altering how they works
///allows on_mob_dead() if present in a dead body
///Can process in dead mobs.
#define REAGENT_DEAD_PROCESS (1<<0)
///Do not split the chem at all during processing - ignores all purity effects
#define REAGENT_DONOTSPLIT (1<<1)
Expand All @@ -83,12 +83,10 @@
#define REAGENT_SPLITRETAINVOL (1<<4)
///Lets a given reagent be synthesized important for random reagents and things like the odysseus syringe gun(Replaces the old can_synth variable)
#define REAGENT_CAN_BE_SYNTHESIZED (1<<5)
///Allows a reagent to work on a mob regardless of stasis
#define REAGENT_IGNORE_STASIS (1<<6)
///This reagent won't be used in most randomized recipes. Meant for reagents that could be synthetized but are normally inaccessible or TOO hard to get.
#define REAGENT_NO_RANDOM_RECIPE (1<<7)
#define REAGENT_NO_RANDOM_RECIPE (1<<6)
///Does this reagent clean things?
#define REAGENT_CLEANS (1<<8)
#define REAGENT_CLEANS (1<<7)

//Chemical reaction flags, for determining reaction specialties
///Convert into impure/pure on reaction completion
Expand Down
16 changes: 15 additions & 1 deletion code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,21 @@ GLOBAL_LIST_EMPTY(species_list)

#define ISADVANCEDTOOLUSER(mob) (HAS_TRAIT(mob, TRAIT_ADVANCEDTOOLUSER) && !HAS_TRAIT(mob, TRAIT_DISCOORDINATED_TOOL_USER))

#define IS_IN_STASIS(mob) (mob.has_status_effect(/datum/status_effect/grouped/stasis))
/// If a mob is in hard or soft stasis
#define IS_IN_STASIS(mob) ((mob.stasis_level && (mob.life_ticks % mob.stasis_level)) || mob.has_status_effect(/datum/status_effect/grouped/hard_stasis))

/// If a mob is in hard stasis
#define IS_IN_HARD_STASIS(mob) (mob.has_status_effect(/datum/status_effect/grouped/hard_stasis))

/// Set a stasis level for a specific source.
#define SET_STASIS_LEVEL(mob, source, level) \
mob.stasis_level -= mob.stasis_sources[source]; \
mob.stasis_level += level;\
mob.stasis_sources[source] = level

#define UNSET_STASIS_LEVEL(mob, source) \
mob.stasis_level -= mob.stasis_sources[source];\
mob.stasis_sources -= source

/// Gets the client of the mob, allowing for mocking of the client.
/// You only need to use this if you know you're going to be mocking clients somewhere else.
Expand Down
1 change: 0 additions & 1 deletion code/_globalvars/bitfields.dm
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ DEFINE_BITFIELD(chemical_flags, list(
"REAGENT_SNEAKYNAME" = REAGENT_SNEAKYNAME,
"REAGENT_SPLITRETAINVOL" = REAGENT_SPLITRETAINVOL,
"REAGENT_CAN_BE_SYNTHESIZED" = REAGENT_CAN_BE_SYNTHESIZED,
"REAGENT_IGNORE_STASIS" = REAGENT_IGNORE_STASIS,
"REAGENT_NO_RANDOM_RECIPE" = REAGENT_NO_RANDOM_RECIPE,
"REAGENT_CLEANS" = REAGENT_CLEANS,
))
Expand Down
12 changes: 6 additions & 6 deletions code/datums/status_effects/debuffs/debuffs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@
icon_state = "asleep"

//STASIS
/datum/status_effect/grouped/stasis
/datum/status_effect/grouped/hard_stasis
id = "stasis"
duration = -1
alert_type = /atom/movable/screen/alert/status_effect/stasis
var/last_dead_time

/datum/status_effect/grouped/stasis/proc/update_time_of_death()
/datum/status_effect/grouped/hard_stasis/proc/update_time_of_death()
if(last_dead_time)
var/delta = world.time - last_dead_time
var/new_timeofdeath = owner.timeofdeath + delta
Expand All @@ -220,13 +220,13 @@
if(owner.stat == DEAD)
last_dead_time = world.time

/datum/status_effect/grouped/stasis/on_creation(mob/living/new_owner, set_duration)
/datum/status_effect/grouped/hard_stasis/on_creation(mob/living/new_owner, set_duration)
. = ..()
if(.)
update_time_of_death()
owner.reagents?.end_metabolization(owner, FALSE)

/datum/status_effect/grouped/stasis/on_apply()
/datum/status_effect/grouped/hard_stasis/on_apply()
. = ..()
if(!.)
return
Expand All @@ -239,10 +239,10 @@
var/mob/living/carbon/carbon_owner = owner
carbon_owner.update_bodypart_bleed_overlays()

/datum/status_effect/grouped/stasis/tick()
/datum/status_effect/grouped/hard_stasis/tick()
update_time_of_death()

/datum/status_effect/grouped/stasis/on_remove()
/datum/status_effect/grouped/hard_stasis/on_remove()
REMOVE_TRAIT(owner, TRAIT_IMMOBILIZED, TRAIT_STATUS_EFFECT(id))
REMOVE_TRAIT(owner, TRAIT_HANDS_BLOCKED, TRAIT_STATUS_EFFECT(id))
owner.remove_filter("stasis_status_ripple")
Expand Down
4 changes: 4 additions & 0 deletions code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,10 @@
/atom/proc/return_analyzable_air()
return null

///Return air that a contained mob will be breathing.
/atom/proc/return_breathable_air()
return return_air()

///Check if this atoms eye is still alive (probably)
/atom/proc/check_eye(mob/user)
SIGNAL_HANDLER
Expand Down
5 changes: 0 additions & 5 deletions code/game/machinery/Sleeper.dm
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,8 @@

/obj/machinery/sleeper/process()
..()
check_nap_violations()
use_power(active_power_usage)

/obj/machinery/sleeper/nap_violation(mob/violator)
open_machine()

/obj/machinery/sleeper/ui_data()
var/list/data = list()
data["occupied"] = occupant ? 1 : 0
Expand Down Expand Up @@ -217,7 +213,6 @@
return

var/mob/living/mob_occupant = occupant
check_nap_violations()
switch(action)
if("door")
if(state_open)
Expand Down
28 changes: 0 additions & 28 deletions code/game/machinery/_machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -591,34 +591,6 @@ GLOBAL_REAL_VAR(machinery_default_armor) = list()

return TRUE // If we passed all of those checks, woohoo! We can interact with this machine.

/obj/machinery/proc/check_nap_violations()
if(!SSeconomy.full_ancap)
return TRUE
if(!occupant || state_open)
return TRUE
var/mob/living/occupant_mob = occupant
var/obj/item/card/id/occupant_id = occupant_mob.get_idcard(TRUE)
if(!occupant_id)
say("[market_verb] NAP Violation: No ID card found.")
nap_violation(occupant_mob)
return FALSE
var/datum/bank_account/insurance = occupant_id.registered_account
if(!insurance)
say("[market_verb] NAP Violation: No bank account found.")
nap_violation(occupant_mob)
return FALSE
if(!insurance.adjust_money(-fair_market_price))
say("[market_verb] NAP Violation: Unable to pay.")
nap_violation(occupant_mob)
return FALSE
var/datum/bank_account/department_account = SSeconomy.department_accounts_by_id[payment_department]
if(department_account)
department_account.adjust_money(fair_market_price)
return TRUE

/obj/machinery/proc/nap_violation(mob/violator)
return

////////////////////////////////////////////////////////////////////////////////////////////

/obj/machinery/attack_hand(mob/living/user, list/modifiers)
Expand Down
17 changes: 7 additions & 10 deletions code/game/machinery/stasis.dm
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
/obj/machinery/stasis/Exited(atom/movable/gone, direction)
if(gone == occupant)
var/mob/living/L = gone
if(IS_IN_STASIS(L))
if(IS_IN_HARD_STASIS(L))
thaw_them(L)
return ..()

Expand Down Expand Up @@ -103,13 +103,13 @@
return
var/freq = rand(24750, 26550)
playsound(src, 'sound/effects/spray.ogg', 5, TRUE, 2, frequency = freq)
target.apply_status_effect(/datum/status_effect/grouped/stasis, STASIS_MACHINE_EFFECT)
target.apply_status_effect(/datum/status_effect/grouped/hard_stasis, STASIS_MACHINE_EFFECT)
ADD_TRAIT(target, TRAIT_TUMOR_SUPPRESSED, TRAIT_GENERIC)
target.extinguish_mob()
update_use_power(ACTIVE_POWER_USE)

/obj/machinery/stasis/proc/thaw_them(mob/living/target)
target.remove_status_effect(/datum/status_effect/grouped/stasis, STASIS_MACHINE_EFFECT)
target.remove_status_effect(/datum/status_effect/grouped/hard_stasis, STASIS_MACHINE_EFFECT)
REMOVE_TRAIT(target, TRAIT_TUMOR_SUPPRESSED, TRAIT_GENERIC)
if(target == occupant)
update_use_power(IDLE_POWER_USE)
Expand All @@ -118,7 +118,7 @@
if(!can_be_occupant(L))
return
set_occupant(L)
if(stasis_running() && check_nap_violations())
if(stasis_running())
chill_out(L)
update_appearance()

Expand All @@ -129,14 +129,14 @@
update_appearance()

/obj/machinery/stasis/process()
if(!(occupant && isliving(occupant) && check_nap_violations()))
if(!isliving(occupant))
update_use_power(IDLE_POWER_USE)
return
var/mob/living/L_occupant = occupant
if(stasis_running())
if(!IS_IN_STASIS(L_occupant))
if(!IS_IN_HARD_STASIS(L_occupant))
chill_out(L_occupant)
else if(IS_IN_STASIS(L_occupant))
else if(IS_IN_HARD_STASIS(L_occupant))
thaw_them(L_occupant)

/obj/machinery/stasis/screwdriver_act(mob/living/user, obj/item/I)
Expand All @@ -148,7 +148,4 @@
. = ..()
return default_deconstruction_crowbar(I) || .

/obj/machinery/stasis/nap_violation(mob/violator)
unbuckle_mob(violator, TRUE)

#undef STASIS_TOGGLE_COOLDOWN
Loading

0 comments on commit 576db08

Please sign in to comment.