Merge pull request #17 from shellspeed1/stasisbed

Adds basic stasis beds.
This commit is contained in:
quotefox
2019-09-28 23:11:06 +01:00
committed by GitHub
20 changed files with 304 additions and 70 deletions
+1
View File
@@ -72,6 +72,7 @@
#define STATUS_EFFECT_ICHORIAL_STAIN /datum/status_effect/ichorial_stain //Prevents a servant from being revived by vitality matrices for one minute.
#define STATUS_EFFECT_STASIS /datum/status_effect/incapacitating/stasis //Halts biological functions like bleeding, chemical processing, blood regeneration, walking, etc
/////////////
// NEUTRAL //
/////////////
+5
View File
@@ -20,6 +20,11 @@
/proc/SQLtime(timevar)
return time2text(timevar || world.timeofday, "YYYY-MM-DD hh:mm:ss")
/proc/station_time(display_only = FALSE, wtime=world.time)
return ((((wtime - SSticker.round_start_time) * SSticker.station_time_rate_multiplier) + SSticker.gametime_offset) % 864000) - (display_only? GLOB.timezoneOffset : 0)
/proc/station_time_timestamp(format = "hh:mm:ss", wtime)
return time2text(station_time(TRUE, wtime), format)
GLOBAL_VAR_INIT(midnight_rollovers, 0)
GLOBAL_VAR_INIT(rollovercheck_last_timeofday, 0)
+33 -14
View File
@@ -5,11 +5,13 @@ SUBSYSTEM_DEF(vis_overlays)
init_order = INIT_ORDER_VIS
var/list/vis_overlay_cache
var/list/unique_vis_overlays
var/list/currentrun
var/datum/callback/rotate_cb
/datum/controller/subsystem/vis_overlays/Initialize()
vis_overlay_cache = list()
unique_vis_overlays = list()
rotate_cb = CALLBACK(src, .proc/rotate_vis_overlay)
return ..()
@@ -31,20 +33,23 @@ SUBSYSTEM_DEF(vis_overlays)
return
//the "thing" var can be anything with vis_contents which includes images
/datum/controller/subsystem/vis_overlays/proc/add_vis_overlay(atom/movable/thing, icon, iconstate, layer, plane, dir, alpha=255)
. = "[icon]|[iconstate]|[layer]|[plane]|[dir]|[alpha]"
var/obj/effect/overlay/vis/overlay = vis_overlay_cache[.]
if(!overlay)
overlay = new
overlay.icon = icon
overlay.icon_state = iconstate
overlay.layer = layer
overlay.plane = plane
overlay.dir = dir
overlay.alpha = alpha
vis_overlay_cache[.] = overlay
/datum/controller/subsystem/vis_overlays/proc/add_vis_overlay(atom/movable/thing, icon, iconstate, layer, plane, dir, alpha = 255, add_appearance_flags = NONE, unique = FALSE)
var/obj/effect/overlay/vis/overlay
if(!unique)
. = "[icon]|[iconstate]|[layer]|[plane]|[dir]|[alpha]|[add_appearance_flags]"
overlay = vis_overlay_cache[.]
if(!overlay)
overlay = _create_new_vis_overlay(icon, iconstate, layer, plane, dir, alpha, add_appearance_flags)
vis_overlay_cache[.] = overlay
else
overlay.unused = 0
else
overlay.unused = 0
overlay = _create_new_vis_overlay(icon, iconstate, layer, plane, dir, alpha, add_appearance_flags)
overlay.cache_expiration = -1
var/cache_id = "\ref[overlay]@{[world.time]}"
unique_vis_overlays += overlay
vis_overlay_cache[cache_id] = overlay
. = overlay
thing.vis_contents += overlay
if(!isatom(thing)) // Automatic rotation is not supported on non atoms
@@ -56,6 +61,17 @@ SUBSYSTEM_DEF(vis_overlays)
else
thing.managed_vis_overlays += overlay
/datum/controller/subsystem/vis_overlays/proc/_create_new_vis_overlay(icon, iconstate, layer, plane, dir, alpha, add_appearance_flags)
var/obj/effect/overlay/vis/overlay = new
overlay.icon = icon
overlay.icon_state = iconstate
overlay.layer = layer
overlay.plane = plane
overlay.dir = dir
overlay.alpha = alpha
overlay.appearance_flags |= add_appearance_flags
return overlay
/datum/controller/subsystem/vis_overlays/proc/remove_vis_overlay(atom/movable/thing, list/overlays)
thing.vis_contents -= overlays
if(!isatom(thing))
@@ -68,8 +84,11 @@ SUBSYSTEM_DEF(vis_overlays)
/datum/controller/subsystem/vis_overlays/proc/rotate_vis_overlay(atom/thing, old_dir, new_dir)
var/rotation = dir2angle(old_dir) - dir2angle(new_dir)
var/list/overlays_to_remove = list()
for(var/i in thing.managed_vis_overlays)
for(var/i in thing.managed_vis_overlays - unique_vis_overlays)
var/obj/effect/overlay/vis/overlay = i
add_vis_overlay(thing, overlay.icon, overlay.icon_state, overlay.layer, overlay.plane, turn(overlay.dir, rotation))
overlays_to_remove += overlay
for(var/i in thing.managed_vis_overlays & unique_vis_overlays)
var/obj/effect/overlay/vis/overlay = i
overlay.dir = turn(overlay.dir, rotation)
remove_vis_overlay(thing, overlays_to_remove)
+38
View File
@@ -80,6 +80,44 @@
desc = "You've fallen asleep. Wait a bit and you should wake up. Unless you don't, considering how helpless you are."
icon_state = "asleep"
//STASIS
/datum/status_effect/incapacitating/stasis
id = "stasis"
duration = -1
tick_interval = 10
alert_type = /obj/screen/alert/status_effect/stasis
var/last_dead_time
/datum/status_effect/incapacitating/stasis/proc/update_time_of_death()
if(last_dead_time)
var/delta = world.time - last_dead_time
var/new_timeofdeath = owner.timeofdeath + delta
owner.timeofdeath = new_timeofdeath
owner.tod = station_time_timestamp(wtime=new_timeofdeath)
last_dead_time = null
if(owner.stat == DEAD)
last_dead_time = world.time
/datum/status_effect/incapacitating/stasis/on_creation(mob/living/new_owner, set_duration, updating_canmove)
. = ..()
update_time_of_death()
/datum/status_effect/incapacitating/stasis/tick()
update_time_of_death()
/datum/status_effect/incapacitating/stasis/on_remove()
update_time_of_death()
return ..()
/datum/status_effect/incapacitating/stasis/be_replaced()
update_time_of_death()
return ..()
/obj/screen/alert/status_effect/stasis
name = "Stasis"
desc = "Your biological functions have halted. You could live forever this way, but it's pretty boring."
icon_state = "stasis"
//OTHER DEBUFFS
/datum/status_effect/his_wrath //does minor damage over time unless holding His Grace
id = "his_wrath"
+4 -1
View File
@@ -179,12 +179,15 @@ Class Procs:
L.update_canmove()
occupant = null
/obj/machinery/proc/can_be_occupant(atom/movable/am)
return occupant_typecache ? is_type_in_typecache(am, occupant_typecache) : isliving(am)
/obj/machinery/proc/close_machine(atom/movable/target = null)
state_open = FALSE
density = TRUE
if(!target)
for(var/am in loc)
if (!(occupant_typecache ? is_type_in_typecache(am, occupant_typecache) : isliving(am)))
if (!(can_be_occupant(am)))
continue
var/atom/movable/AM = am
if(AM.has_buckled_mobs())
+137
View File
@@ -0,0 +1,137 @@
#define STASIS_TOGGLE_COOLDOWN 50
/obj/machinery/stasis
name = "Lifeform Stasis Unit"
desc = "A not so comfortable looking bed with some nozzles at the top and bottom. It will keep someone in stasis."
icon = 'icons/obj/machines/stasis.dmi'
icon_state = "stasis"
density = FALSE
can_buckle = TRUE
buckle_lying = 90
circuit = /obj/item/circuitboard/machine/stasis
idle_power_usage = 40
active_power_usage = 340
var/stasis_enabled = TRUE
var/last_stasis_sound = FALSE
var/stasis_can_toggle = 0
var/mattress_state = "stasis_on"
var/obj/effect/overlay/vis/mattress_on
/obj/machinery/stasis/examine(mob/user)
..()
var/turn_on_or_off = stasis_enabled ? "turn off" : "turn on"
to_chat(user, "<span class='notice'>Alt-click to [turn_on_or_off] the machine.</span>")
/obj/machinery/stasis/proc/play_power_sound()
var/_running = stasis_running()
if(last_stasis_sound != _running)
var/sound_freq = rand(5120, 8800)
if(_running)
playsound(src, 'sound/machines/synth_yes.ogg', 50, TRUE, frequency = sound_freq)
else
playsound(src, 'sound/machines/synth_no.ogg', 50, TRUE, frequency = sound_freq)
last_stasis_sound = _running
/obj/machinery/stasis/AltClick(mob/user)
if(world.time >= stasis_can_toggle && user.canUseTopic(src))
stasis_enabled = !stasis_enabled
stasis_can_toggle = world.time + STASIS_TOGGLE_COOLDOWN
playsound(src, 'sound/machines/click.ogg', 60, TRUE)
play_power_sound()
update_icon()
/obj/machinery/stasis/Exited(atom/movable/AM, atom/newloc)
if(AM == occupant)
var/mob/living/L = AM
if(L.IsInStasis())
thaw_them(L)
. = ..()
/obj/machinery/stasis/proc/stasis_running()
return stasis_enabled && is_operational()
/obj/machinery/stasis/update_icon()
. = ..()
var/_running = stasis_running()
var/list/overlays_to_remove = managed_vis_overlays
if(mattress_state)
if(!mattress_on || !managed_vis_overlays)
mattress_on = SSvis_overlays.add_vis_overlay(src, icon, mattress_state, layer, plane, dir, alpha = 0, unique = TRUE)
if(mattress_on.alpha ? !_running : _running) //check the inverse of _running compared to truthy alpha, to see if they differ
var/new_alpha = _running ? 255 : 0
var/easing_direction = _running ? EASE_OUT : EASE_IN
animate(mattress_on, alpha = new_alpha, time = 50, easing = CUBIC_EASING|easing_direction)
overlays_to_remove = managed_vis_overlays - mattress_on
SSvis_overlays.remove_vis_overlay(src, overlays_to_remove)
if(occupant)
SSvis_overlays.add_vis_overlay(src, 'icons/obj/machines/stasis.dmi', "tubes", LYING_MOB_LAYER + 0.1, plane, dir) //using vis_overlays instead of normal overlays for mouse_opacity here
if(stat & BROKEN)
icon_state = "stasis_broken"
return
if(panel_open || stat & MAINT)
icon_state = "stasis_maintenance"
return
icon_state = "stasis"
/obj/machinery/stasis/obj_break(damage_flag)
. = ..()
play_power_sound()
update_icon()
/obj/machinery/stasis/power_change()
. = ..()
play_power_sound()
update_icon()
/obj/machinery/stasis/proc/chill_out(mob/living/target)
if(target != occupant)
return
var/freq = rand(24750, 26550)
playsound(src, 'sound/effects/spray.ogg', 5, TRUE, 2, frequency = freq)
target.SetStasis(TRUE)
target.ExtinguishMob()
use_power = ACTIVE_POWER_USE
/obj/machinery/stasis/proc/thaw_them(mob/living/target)
target.SetStasis(FALSE)
if(target == occupant)
use_power = IDLE_POWER_USE
/obj/machinery/stasis/post_buckle_mob(mob/living/L)
if(!can_be_occupant(L))
return
occupant = L
if(stasis_running())
chill_out(L)
update_icon()
/obj/machinery/stasis/post_unbuckle_mob(mob/living/L)
thaw_them(L)
if(L == occupant)
occupant = null
update_icon()
/obj/machinery/stasis/process()
if( !( occupant && isliving(occupant)) )
use_power = IDLE_POWER_USE
return
var/mob/living/L_occupant = occupant
if(stasis_running())
if(!L_occupant.IsInStasis())
chill_out(L_occupant)
else if(L_occupant.IsInStasis())
thaw_them(L_occupant)
/obj/machinery/stasis/screwdriver_act(mob/living/user, obj/item/I)
. = default_deconstruction_screwdriver(user, "stasis_maintenance", "stasis", I)
update_icon()
/obj/machinery/stasis/crowbar_act(mob/living/user, obj/item/I)
return default_deconstruction_crowbar(I)
#undef STASIS_TOGGLE_COOLDOWN
@@ -7,6 +7,14 @@
/obj/item/stack/cable_coil = 1,
/obj/item/stack/sheet/glass = 2)
/obj/item/circuitboard/machine/stasis
name = "Lifeform Stasis Unit (Machine Board)"
build_path = /obj/machinery/stasis
req_components = list(
/obj/item/stack/cable_coil = 3,
/obj/item/stock_parts/manipulator = 1,
/obj/item/stock_parts/capacitor = 1)
/obj/item/circuitboard/machine/vr_sleeper
name = "VR Sleeper (Machine Board)"
build_path = /obj/machinery/vr_sleeper
@@ -4,7 +4,7 @@
set invisibility = 0
if (notransform)
return
if(..()) //not dead
if(..() && !IsInStasis()) //not dead and not in stasis
// GROW!
if(amount_grown < max_grown)
amount_grown++
+10 -9
View File
@@ -28,21 +28,22 @@
if (QDELETED(src))
return 0
if(.) //not dead
handle_active_genes()
if(!IsInStasis())
if(.) //not dead
handle_active_genes()
if(stat != DEAD)
//heart attack stuff
handle_heart()
if(stat != DEAD)
//heart attack stuff
handle_heart()
if(stat != DEAD)
//Stuff jammed in your limbs hurts
handle_embedded_objects()
if(stat != DEAD)
//Stuff jammed in your limbs hurts
handle_embedded_objects()
dna.species.spec_life(src) // for mutantraces
//Update our name based on whether our face is obscured/disfigured
name = get_visible_name()
dna.species.spec_life(src) // for mutantraces
if(stat != DEAD)
return 1
+17 -16
View File
@@ -9,28 +9,29 @@
stamdamageoverlaytemp = 0
update_damage_hud()
if(stat != DEAD) //Reagent processing needs to come before breathing, to prevent edge cases.
handle_organs()
if(!IsInStasis())
if(stat != DEAD) //Reagent processing needs to come before breathing, to prevent edge cases.
handle_organs()
. = ..()
. = ..()
if (QDELETED(src))
return
if (QDELETED(src))
return
if(.) //not dead
handle_blood()
if(.) //not dead
handle_blood()
if(stat != DEAD)
var/bprv = handle_bodyparts()
if(bprv & BODYPART_LIFE_UPDATE_HEALTH)
updatehealth()
update_stamina()
if(stat != DEAD)
var/bprv = handle_bodyparts()
if(bprv & BODYPART_LIFE_UPDATE_HEALTH)
updatehealth()
update_stamina()
if(stat != DEAD)
handle_brain_damage()
if(stat != DEAD)
handle_brain_damage()
if(stat != DEAD)
handle_liver()
if(stat != DEAD)
handle_liver()
if(stat == DEAD)
stop_sound_channel(CHANNEL_HEARTBEAT)
@@ -9,7 +9,7 @@
if (notransform)
return
if(..())
if(..() && !IsInStasis())
if(!client)
if(stat == CONSCIOUS)
+27 -25
View File
@@ -33,43 +33,45 @@
return
if(!loc)
return
var/datum/gas_mixture/environment = loc.return_air()
if(!IsInStasis())
if(stat != DEAD)
//Mutations and radiation
handle_mutations_and_radiation()
if(stat != DEAD)
//Mutations and radiation
handle_mutations_and_radiation()
if(stat != DEAD)
//Breathing, if applicable
handle_breathing(times_fired)
if(stat != DEAD)
//Breathing, if applicable
handle_breathing(times_fired)
handle_diseases()// DEAD check is in the proc itself; we want it to spread even if the mob is dead, but to handle its disease-y properties only if you're not.
handle_diseases()// DEAD check is in the proc itself; we want it to spread even if the mob is dead, but to handle its disease-y properties only if you're not.
if (QDELETED(src)) // diseases can qdel the mob via transformations
return
if (QDELETED(src)) // diseases can qdel the mob via transformations
return
if(stat != DEAD)
//Random events (vomiting etc)
handle_random_events()
if(stat != DEAD)
//Random events (vomiting etc)
handle_random_events()
//Handle temperature/pressure differences between body and environment
var/datum/gas_mixture/environment = loc.return_air()
if(environment)
handle_environment(environment)
//Handle temperature/pressure differences between body and environment
if(environment)
handle_environment(environment)
//stuff in the stomach
handle_stomach()
handle_gravity()
if(stat != DEAD)
handle_traits() // eye, ear, brain damages
handle_status_effects() //all special effects, stun, knockdown, jitteryness, hallucination, sleeping, etc
handle_fire()
//stuff in the stomach
handle_stomach()
handle_gravity()
if(machine)
machine.check_eye(src)
if(stat != DEAD)
handle_traits() // eye, ear, brain damages
if(stat != DEAD)
handle_status_effects() //all special effects, stun, knockdown, jitteryness, hallucination, sleeping, etc
if(stat != DEAD)
return 1
+4 -2
View File
@@ -339,7 +339,7 @@
death()
/mob/living/incapacitated(ignore_restraints, ignore_grab)
/mob/living/incapacitated(ignore_restraints, ignore_grab, ignore_stasis)
if(stat || IsUnconscious() || IsStun() || IsKnockdown() || recoveringstam || (!ignore_restraints && restrained(ignore_grab))) // CIT CHANGE - adds recoveringstam check here
return TRUE
@@ -603,7 +603,7 @@
..(pressure_difference, direction, pressure_resistance_prob_delta)
/mob/living/can_resist()
return !((next_move > world.time) || incapacitated(ignore_restraints = TRUE))
return !((next_move > world.time) || incapacitated(ignore_restraints = TRUE, ignore_stasis= TRUE))
/mob/living/verb/resist()
set name = "Resist"
@@ -1011,6 +1011,8 @@
var/has_legs = get_num_legs()
var/has_arms = get_num_arms()
var/ignore_legs = get_leg_ignore()
var/in_stasis = IsInStasis()
var/canmove = !buckled && (pulledby) && !chokehold && !IsFrozen() && !in_stasis && (has_arms || ignore_legs || has_legs)
var/pinned = resting && pulledby && pulledby.grab_state >= GRAB_AGGRESSIVE // Cit change - adds pinning for aggressive-grabbing people on the ground
if(ko || move_and_fall || IsStun() || chokehold) // Cit change - makes resting not force you to drop everything
drop_all_held_items()
+8
View File
@@ -138,6 +138,14 @@
priority_absorb_key["stuns_absorbed"] += amount
return TRUE
/////////////////////////////////// STASIS ///////////////////////////////////
/mob/living/proc/IsInStasis()
. = has_status_effect(STATUS_EFFECT_STASIS)
/mob/living/proc/SetStasis(apply, updating = TRUE)
. = apply ? apply_status_effect(STATUS_EFFECT_STASIS, null, updating) : remove_status_effect(STATUS_EFFECT_STASIS)
/////////////////////////////////// DISABILITIES ////////////////////////////////////
/mob/living/proc/add_quirk(quirk, spawn_effects) //separate proc due to the way these ones are handled
@@ -2,6 +2,14 @@
///MEDICAL Boards//
///////////////////
/datum/design/board/stasis
name = "Machine Design (Lifeform Stasis Unit)"
desc = "The circuit board for a stasis unit."
id = "stasis"
build_path = /obj/item/circuitboard/machine/stasis
category = list("Medical Machinery")
departmental_flags = DEPARTMENTAL_FLAG_MEDICAL
/datum/design/board/limbgrower
name = "Machine Design (Limb Grower Board)"
desc = "The circuit board for a limb grower."
+1 -1
View File
@@ -508,7 +508,7 @@
display_name = "Cryostasis Technology"
description = "Smart freezing of objects to preserve them!"
prereq_ids = list("adv_engi", "biotech")
design_ids = list("splitbeaker", "noreactsyringe", "cryotube", "cryo_Grenade")
design_ids = list("splitbeaker", "noreactsyringe", "cryotube", "cryo_Grenade", "stasis")
research_costs = list(TECHWEB_POINT_TYPE_GENERIC = 2000)
export_price = 4000
Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 758 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 758 B

+1
View File
@@ -605,6 +605,7 @@
#include "code\game\machinery\Sleeper.dm"
#include "code\game\machinery\slotmachine.dm"
#include "code\game\machinery\spaceheater.dm"
#include "code\game\machinery\stasis.dm"
#include "code\game\machinery\status_display.dm"
#include "code\game\machinery\suit_storage_unit.dm"
#include "code\game\machinery\syndicatebeacon.dm"