Sleeper Changes

This commit is contained in:
Fox-McCloud
2016-07-16 01:31:34 -04:00
parent 532e917e78
commit a1341f02af
14 changed files with 235 additions and 368 deletions

View File

@@ -1,275 +1,23 @@
#define ADDICTION_SPEEDUP_TIME 1500 // 2.5 minutes
/////////////////////////////////////////
// SLEEPER CONSOLE
/////////////////////////////////////////
/obj/machinery/sleep_console
name = "Sleeper Console"
icon = 'icons/obj/Cryogenic2.dmi'
icon_state = "console"
var/obj/machinery/sleeper/connected = null
var/ui_title = "Sleeper"
anchored = 1 //About time someone fixed this.
density = 1
var/orient = "LEFT"
dir = 8
idle_power_usage = 250
active_power_usage = 500
interact_offline = 1
/obj/machinery/sleep_console/power_change()
if(stat & BROKEN)
icon_state = "console-p"
else if(powered() && !panel_open)
icon_state = initial(icon_state)
stat &= ~NOPOWER
else
spawn(rand(0, 15))
src.icon_state = "console-p"
stat |= NOPOWER
/obj/machinery/sleep_console/New()
..()
component_parts = list()
component_parts += new /obj/item/weapon/circuitboard/sleep_console(null)
component_parts += new /obj/item/weapon/stock_parts/console_screen(null)
component_parts += new /obj/item/weapon/stock_parts/console_screen(null)
component_parts += new /obj/item/stack/cable_coil(null, 2)
RefreshParts()
findsleeper()
/obj/machinery/sleep_console/RefreshParts()
/obj/machinery/sleep_console/process()
/obj/machinery/sleep_console/ex_act(severity)
switch(severity)
if(1.0)
//SN src = null
qdel(src)
return
if(2.0)
if(prob(50))
//SN src = null
qdel(src)
return
else
return
/obj/machinery/sleep_console/proc/findsleeper()
var/obj/machinery/sleeper/sleepernew = null
// Loop through every direction
for(dir in list(NORTH,EAST,SOUTH,WEST))
// Try to find a scanner in that direction
var/temp = locate(/obj/machinery/sleeper, get_step(src, dir))
if(!isnull(temp))
sleepernew = temp
src.connected = sleepernew
return
/obj/machinery/sleeper/attack_animal(var/mob/living/simple_animal/M)//Stop putting hostile mobs in things guise
if(M.environment_smash)
M.do_attack_animation(src)
visible_message("<span class='danger'>[M.name] smashes [src] apart!</span>")
go_out()
qdel(src)
return
/obj/machinery/sleep_console/attackby(var/obj/item/weapon/G as obj, var/mob/user as mob, params)
if(istype(G, /obj/item/weapon/screwdriver))
default_deconstruction_screwdriver(user, "console-p", "console", G)
return
if(istype(G, /obj/item/weapon/wrench))
if(panel_open)
to_chat(user, "<span class='notice'>Close the maintenance panel first.</span>")
return
if(dir == 4)
orient = "LEFT"
dir = 8
else
orient = "RIGHT"
dir = 4
playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1)
if(exchange_parts(user, G))
return
default_deconstruction_crowbar(G)
/obj/machinery/sleep_console/attack_ai(mob/user as mob)
return attack_hand(user)
/obj/machinery/sleep_console/attack_ghost(mob/user as mob)
return attack_hand(user)
/obj/machinery/sleep_console/attack_hand(mob/user as mob)
if(stat & (NOPOWER|BROKEN))
return
if(panel_open)
to_chat(user, "<span class='notice'>Close the maintenance panel first.</span>")
return
if(!src.connected)
findsleeper()
if(src.connected)
ui_interact(user)
/obj/machinery/sleep_console/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
var/data[0]
var/mob/living/carbon/human/occupant = connected.occupant
data["hasOccupant"] = occupant ? 1 : 0
var/occupantData[0]
var/crisis = 0
if(occupant)
occupantData["name"] = occupant.name
occupantData["stat"] = occupant.stat
occupantData["health"] = occupant.health
occupantData["maxHealth"] = occupant.maxHealth
occupantData["minHealth"] = config.health_threshold_dead
occupantData["bruteLoss"] = occupant.getBruteLoss()
occupantData["oxyLoss"] = occupant.getOxyLoss()
occupantData["toxLoss"] = occupant.getToxLoss()
occupantData["fireLoss"] = occupant.getFireLoss()
occupantData["paralysis"] = occupant.paralysis
occupantData["hasBlood"] = 0
occupantData["bodyTemperature"] = occupant.bodytemperature
occupantData["maxTemp"] = 1000 // If you get a burning vox armalis into the sleeper, congratulations
// Because we can put simple_animals in here, we need to do something tricky to get things working nice
occupantData["temperatureSuitability"] = 0 // 0 is the baseline
if(ishuman(occupant) && occupant.species)
// I wanna do something where the bar gets bluer as the temperature gets lower
// For now, I'll just use the standard format for the temperature status
var/datum/species/sp = occupant.species
if(occupant.bodytemperature < sp.cold_level_3)
occupantData["temperatureSuitability"] = -3
else if(occupant.bodytemperature < sp.cold_level_2)
occupantData["temperatureSuitability"] = -2
else if(occupant.bodytemperature < sp.cold_level_1)
occupantData["temperatureSuitability"] = -1
else if(occupant.bodytemperature > sp.heat_level_3)
occupantData["temperatureSuitability"] = 3
else if(occupant.bodytemperature > sp.heat_level_2)
occupantData["temperatureSuitability"] = 2
else if(occupant.bodytemperature > sp.heat_level_1)
occupantData["temperatureSuitability"] = 1
else if(istype(occupant, /mob/living/simple_animal))
var/mob/living/simple_animal/silly = occupant
if(silly.bodytemperature < silly.minbodytemp)
occupantData["temperatureSuitability"] = -3
else if(silly.bodytemperature > silly.maxbodytemp)
occupantData["temperatureSuitability"] = 3
// Blast you, imperial measurement system
occupantData["btCelsius"] = occupant.bodytemperature - T0C
occupantData["btFaren"] = ((occupant.bodytemperature - T0C) * (9.0/5.0))+ 32
crisis = (occupant.health < connected.min_health)
// I'm not sure WHY you'd want to put a simple_animal in a sleeper, but precedent is precedent
// Runtime is aptly named, isn't she?
if(ishuman(occupant) && occupant.vessel && !(occupant.species && occupant.species.flags & NO_BLOOD))
var/blood_type = occupant.get_blood_name()
occupantData["pulse"] = occupant.get_pulse(GETPULSE_TOOL)
occupantData["hasBlood"] = 1
occupantData["bloodLevel"] = round(occupant.vessel.get_reagent_amount(blood_type))
occupantData["bloodMax"] = occupant.max_blood
occupantData["bloodPercent"] = round(100*(occupant.vessel.get_reagent_amount(blood_type)/occupant.max_blood), 0.01)
data["occupant"] = occupantData
data["maxchem"] = connected.max_chem
data["minhealth"] = connected.min_health
data["dialysis"] = connected.filtering
if(connected.beaker)
data["isBeakerLoaded"] = 1
if(connected.beaker.reagents)
data["beakerFreeSpace"] = round(connected.beaker.reagents.maximum_volume - connected.beaker.reagents.total_volume)
else
data["beakerFreeSpace"] = 0
var/chemicals[0]
for(var/re in connected.injection_chems)
var/datum/reagent/temp = chemical_reagents_list[re]
if(temp)
var/reagent_amount = 0
var/pretty_amount
var/injectable = occupant ? 1 : 0
var/overdosing = 0
var/caution = 0 // To make things clear that you're coming close to an overdose
if(crisis && !(temp.id in connected.emergency_chems))
injectable = 0
if(occupant && occupant.reagents)
reagent_amount = occupant.reagents.get_reagent_amount(temp.id)
// If they're mashing the highest concentration, they get one warning
if(temp.overdose_threshold && reagent_amount + 10 > temp.overdose_threshold)
caution = 1
if(temp.id in occupant.reagents.overdose_list())
overdosing = 1
// Because I don't know how to do this on the nano side
pretty_amount = round(reagent_amount, 0.05)
chemicals.Add(list(list("title" = temp.name, "id" = temp.id, "commands" = list("chemical" = temp.id), "occ_amount" = reagent_amount, "pretty_amount" = pretty_amount, "injectable" = injectable, "overdosing" = overdosing, "od_warning" = caution)))
data["chemicals"] = chemicals
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
if(!ui)
ui = new(user, src, ui_key, "sleeper.tmpl", ui_title, 550, 655)
ui.set_initial_data(data)
ui.open()
ui.set_auto_update(1)
/obj/machinery/sleep_console/Topic(href, href_list)
if(!connected | usr == connected.occupant)
return 0
if(..())
return 1
if(panel_open)
to_chat(usr, "<span class='notice'>Close the maintenance panel first.</span>")
return 0
if((usr.contents.Find(src) || ((get_dist(src, usr) <= 1) && istype(src.loc, /turf))) || (istype(usr, /mob/living/silicon/ai)))
if(href_list["chemical"])
if(src.connected)
if(src.connected.occupant)
if(src.connected.occupant.stat == DEAD)
to_chat(usr, "<span class='danger'>This person has no life for to preserve anymore. Take them to a department capable of reanimating them.</span>")
else if(src.connected.occupant.health > src.connected.min_health || (href_list["chemical"] in connected.emergency_chems))
src.connected.inject_chemical(usr,href_list["chemical"],text2num(href_list["amount"]))
else
to_chat(usr, "<span class='danger'>This person is not in good enough condition for sleepers to be effective! Use another means of treatment, such as cryogenics!</span>")
if(href_list["removebeaker"])
src.connected.remove_beaker()
if(href_list["togglefilter"])
src.connected.toggle_filter()
if(href_list["ejectify"])
src.connected.eject()
src.add_fingerprint(usr)
return 1
/////////////////////////////////////////
// THE SLEEPER ITSELF
/////////////////////////////////////////
/////////////
// SLEEPER //
////////////
/obj/machinery/sleeper
name = "Sleeper"
icon = 'icons/obj/Cryogenic2.dmi'
icon_state = "sleeper-open"
var/base_icon = "sleeper"
density = 1
anchored = 1
dir = 8
var/orient = "LEFT" // "RIGHT" changes the dir suffix to "-r"
var/mob/living/carbon/human/occupant = null
var/possible_chems = list(list("epinephrine", "ether", "salbutamol", "styptic_powder"),
list("epinephrine", "ether", "salbutamol", "styptic_powder", "oculine"),
list("epinephrine", "ether", "salbutamol", "styptic_powder", "oculine", "charcoal", "mutadone", "mannitol"),
list("epinephrine", "ether", "salbutamol", "styptic_powder", "oculine", "charcoal", "mutadone", "mannitol", "pen_acid", "omnizine"))
var/possible_chems = list(list("epinephrine", "ether", "salbutamol", "styptic_powder", "silver_sulfadiazine"),
list("epinephrine", "ether", "salbutamol", "styptic_powder", "silver_sulfadiazine", "oculine"),
list("epinephrine", "ether", "salbutamol", "styptic_powder", "silver_sulfadiazine", "oculine", "charcoal", "mutadone", "mannitol"),
list("epinephrine", "ether", "salbutamol", "styptic_powder", "silver_sulfadiazine", "oculine", "charcoal", "mutadone", "mannitol", "pen_acid", "omnizine"))
var/emergency_chems = list("epinephrine") // Desnowflaking
var/amounts = list(5, 10)
var/obj/item/weapon/reagent_containers/glass/beaker = null
@@ -278,6 +26,7 @@
var/initial_bin_rating = 1
var/min_health = -25
var/injection_chems = list()
var/controls_inside = FALSE
idle_power_usage = 1250
active_power_usage = 2500
@@ -369,6 +118,154 @@
return
/obj/machinery/sleeper/attack_ai(mob/user)
return attack_hand(user)
/obj/machinery/sleeper/attack_ghost(mob/user)
return attack_hand(user)
/obj/machinery/sleeper/attack_hand(mob/user)
if(stat & (NOPOWER|BROKEN))
return
if(panel_open)
to_chat(user, "<span class='notice'>Close the maintenance panel first.</span>")
return
ui_interact(user)
/obj/machinery/sleeper/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1)
var/data[0]
data["hasOccupant"] = occupant ? 1 : 0
var/occupantData[0]
var/crisis = 0
if(occupant)
occupantData["name"] = occupant.name
occupantData["stat"] = occupant.stat
occupantData["health"] = occupant.health
occupantData["maxHealth"] = occupant.maxHealth
occupantData["minHealth"] = config.health_threshold_dead
occupantData["bruteLoss"] = occupant.getBruteLoss()
occupantData["oxyLoss"] = occupant.getOxyLoss()
occupantData["toxLoss"] = occupant.getToxLoss()
occupantData["fireLoss"] = occupant.getFireLoss()
occupantData["paralysis"] = occupant.paralysis
occupantData["hasBlood"] = 0
occupantData["bodyTemperature"] = occupant.bodytemperature
occupantData["maxTemp"] = 1000 // If you get a burning vox armalis into the sleeper, congratulations
// Because we can put simple_animals in here, we need to do something tricky to get things working nice
occupantData["temperatureSuitability"] = 0 // 0 is the baseline
if(ishuman(occupant) && occupant.species)
// I wanna do something where the bar gets bluer as the temperature gets lower
// For now, I'll just use the standard format for the temperature status
var/datum/species/sp = occupant.species
if(occupant.bodytemperature < sp.cold_level_3)
occupantData["temperatureSuitability"] = -3
else if(occupant.bodytemperature < sp.cold_level_2)
occupantData["temperatureSuitability"] = -2
else if(occupant.bodytemperature < sp.cold_level_1)
occupantData["temperatureSuitability"] = -1
else if(occupant.bodytemperature > sp.heat_level_3)
occupantData["temperatureSuitability"] = 3
else if(occupant.bodytemperature > sp.heat_level_2)
occupantData["temperatureSuitability"] = 2
else if(occupant.bodytemperature > sp.heat_level_1)
occupantData["temperatureSuitability"] = 1
else if(istype(occupant, /mob/living/simple_animal))
var/mob/living/simple_animal/silly = occupant
if(silly.bodytemperature < silly.minbodytemp)
occupantData["temperatureSuitability"] = -3
else if(silly.bodytemperature > silly.maxbodytemp)
occupantData["temperatureSuitability"] = 3
// Blast you, imperial measurement system
occupantData["btCelsius"] = occupant.bodytemperature - T0C
occupantData["btFaren"] = ((occupant.bodytemperature - T0C) * (9.0/5.0))+ 32
crisis = (occupant.health < min_health)
// I'm not sure WHY you'd want to put a simple_animal in a sleeper, but precedent is precedent
// Runtime is aptly named, isn't she?
if(ishuman(occupant) && occupant.vessel && !(occupant.species && occupant.species.flags & NO_BLOOD))
var/blood_type = occupant.get_blood_name()
occupantData["pulse"] = occupant.get_pulse(GETPULSE_TOOL)
occupantData["hasBlood"] = 1
occupantData["bloodLevel"] = round(occupant.vessel.get_reagent_amount(blood_type))
occupantData["bloodMax"] = occupant.max_blood
occupantData["bloodPercent"] = round(100*(occupant.vessel.get_reagent_amount(blood_type)/occupant.max_blood), 0.01)
data["occupant"] = occupantData
data["maxchem"] = max_chem
data["minhealth"] = min_health
data["dialysis"] = filtering
if(beaker)
data["isBeakerLoaded"] = 1
if(beaker.reagents)
data["beakerFreeSpace"] = round(beaker.reagents.maximum_volume - beaker.reagents.total_volume)
else
data["beakerFreeSpace"] = 0
var/chemicals[0]
for(var/re in injection_chems)
var/datum/reagent/temp = chemical_reagents_list[re]
if(temp)
var/reagent_amount = 0
var/pretty_amount
var/injectable = occupant ? 1 : 0
var/overdosing = 0
var/caution = 0 // To make things clear that you're coming close to an overdose
if(crisis && !(temp.id in emergency_chems))
injectable = 0
if(occupant && occupant.reagents)
reagent_amount = occupant.reagents.get_reagent_amount(temp.id)
// If they're mashing the highest concentration, they get one warning
if(temp.overdose_threshold && reagent_amount + 10 > temp.overdose_threshold)
caution = 1
if(temp.id in occupant.reagents.overdose_list())
overdosing = 1
// Because I don't know how to do this on the nano side
pretty_amount = round(reagent_amount, 0.05)
chemicals.Add(list(list("title" = temp.name, "id" = temp.id, "commands" = list("chemical" = temp.id), "occ_amount" = reagent_amount, "pretty_amount" = pretty_amount, "injectable" = injectable, "overdosing" = overdosing, "od_warning" = caution)))
data["chemicals"] = chemicals
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
if(!ui)
ui = new(user, src, ui_key, "sleeper.tmpl", "Sleeper", 550, 770)
ui.set_initial_data(data)
ui.open()
ui.set_auto_update(1)
/obj/machinery/sleeper/Topic(href, href_list)
if(!controls_inside && usr == occupant)
return 0
if(..())
return 1
if(panel_open)
to_chat(usr, "<span class='notice'>Close the maintenance panel first.</span>")
return 0
if((usr.contents.Find(src) || ((get_dist(src, usr) <= 1) && istype(src.loc, /turf))) || (istype(usr, /mob/living/silicon/ai)))
if(href_list["chemical"])
if(occupant)
if(occupant.stat == DEAD)
to_chat(usr, "<span class='danger'>This person has no life for to preserve anymore. Take them to a department capable of reanimating them.</span>")
else if(occupant.health > min_health || (href_list["chemical"] in emergency_chems))
inject_chemical(usr,href_list["chemical"],text2num(href_list["amount"]))
else
to_chat(usr, "<span class='danger'>This person is not in good enough condition for sleepers to be effective! Use another means of treatment, such as cryogenics!</span>")
if(href_list["removebeaker"])
remove_beaker()
if(href_list["togglefilter"])
toggle_filter()
if(href_list["ejectify"])
eject()
src.add_fingerprint(usr)
return 1
/obj/machinery/sleeper/blob_act()
if(prob(75))
var/atom/movable/A = occupant
@@ -398,7 +295,7 @@
if(src.occupant)
to_chat(user, "<span class='notice'>The maintenance panel is locked.</span>")
return
default_deconstruction_screwdriver(user, "sleeper-o", "sleeper-open", G)
default_deconstruction_screwdriver(user, "[base_icon]-o", "[base_icon]-open", G)
return
if(istype(G, /obj/item/weapon/wrench))
@@ -451,7 +348,7 @@
M.client.eye = src
M.forceMove(src)
src.occupant = M
src.icon_state = "sleeper"
src.icon_state = "[base_icon]"
to_chat(M, "<span class='boldnotice'>You feel cool air surround you. You go numb as your senses turn inward.</span>")
src.add_fingerprint(user)
@@ -528,7 +425,7 @@
occupant.client.perspective = MOB_PERSPECTIVE
occupant.forceMove(loc)
occupant = null
icon_state = "sleeper-open"
icon_state = "[base_icon]-open"
// eject trash the occupant dropped
for(var/atom/movable/A in contents - component_parts - list(beaker))
A.forceMove(loc)
@@ -559,7 +456,7 @@
set src in oview(1)
if(usr.stat != 0)
return
src.icon_state = "sleeper-open"
src.icon_state = "[base_icon]-open"
src.go_out()
add_fingerprint(usr)
return
@@ -626,7 +523,7 @@
L.client.eye = src
L.forceMove(src)
src.occupant = L
src.icon_state = "sleeper"
src.icon_state = "[base_icon]"
to_chat(L, "<span class='boldnotice'>You feel cool air surround you. You go numb as your senses turn inward.</span>")
src.add_fingerprint(user)
if(user.pulling == L)
@@ -665,7 +562,7 @@
usr.client.eye = src
usr.forceMove(src)
src.occupant = usr
src.icon_state = "sleeper"
src.icon_state = "[base_icon]"
for(var/obj/O in src)
qdel(O)
@@ -673,4 +570,11 @@
return
return
/obj/machinery/sleeper/syndie
icon_state = "sleeper_s-open"
base_icon = "sleeper_s"
controls_inside = TRUE
light_color = LIGHT_COLOR_DARKRED
#undef ADDICTION_SPEEDUP_TIME

View File

@@ -744,16 +744,6 @@ obj/item/weapon/circuitboard/rdserver
/obj/item/stack/cable_coil = 1,
/obj/item/weapon/stock_parts/console_screen = 2)
/obj/item/weapon/circuitboard/sleep_console
name = "circuit board (Sleeper Console)"
build_path = /obj/machinery/sleep_console
board_type = "machine"
origin_tech = "programming=3;biotech=2;engineering=3;materials=3"
frame_desc = "Requires 2 pieces of cable and 2 Console Screens."
req_components = list(
/obj/item/stack/cable_coil = 2,
/obj/item/weapon/stock_parts/console_screen = 2)
/obj/item/weapon/circuitboard/bodyscanner
name = "circuit board (Body Scanner)"
build_path = /obj/machinery/bodyscanner

View File

@@ -192,16 +192,6 @@
build_path = /obj/item/weapon/circuitboard/sleeper
category = list("Medical Machinery")
/datum/design/sleep_console
name = "Machine Board (Sleeper Console)"
desc = "Allows for the construction of circuit boards used to build a Sleeper Console."
id = "sleeper_console"
req_tech = list("programming" = 3, "biotech" = 2, "materials" = 3, "engineering" = 3)
build_type = IMPRINTER
materials = list(MAT_GLASS = 1000, "sacid" = 20)
build_path = /obj/item/weapon/circuitboard/sleep_console
category = list("Medical Machinery")
/datum/design/biogenerator
name = "Machine Board (Biogenerator)"
desc = "The circuit board for a Biogenerator."