Merge pull request #9882 from FestiveBall/Fersi
[READY] Allows addition of reagents to sleepers for injection and detection of failed organs (minor GUI tweak.)
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
density = FALSE
|
||||
state_open = TRUE
|
||||
circuit = /obj/item/circuitboard/machine/sleeper
|
||||
req_access = list(ACCESS_CMO) //Used for reagent deletion and addition of non medicines
|
||||
var/efficiency = 1
|
||||
var/min_health = -25
|
||||
var/list/available_chems
|
||||
@@ -28,9 +29,28 @@
|
||||
|
||||
/obj/machinery/sleeper/Initialize()
|
||||
. = ..()
|
||||
create_reagents(500, NO_REACT)
|
||||
occupant_typecache = GLOB.typecache_living
|
||||
update_icon()
|
||||
reset_chem_buttons()
|
||||
RefreshParts()
|
||||
add_inital_chems()
|
||||
|
||||
/obj/machinery/sleeper/Destroy()
|
||||
var/obj/item/reagent_containers/sleeper_buffer/buffer = new /obj/item/reagent_containers/sleeper_buffer(loc)
|
||||
buffer.volume = reagents.maximum_volume
|
||||
buffer.reagents.maximum_volume = reagents.maximum_volume
|
||||
reagents.trans_to(buffer.reagents, reagents.total_volume)
|
||||
..()
|
||||
|
||||
/obj/machinery/sleeper/proc/add_inital_chems()
|
||||
for(var/i in available_chems)
|
||||
var/datum/reagent/R = reagents.has_reagent(i)
|
||||
if(!R)
|
||||
reagents.add_reagent(i, (20))
|
||||
continue
|
||||
if(R.volume < 20)
|
||||
reagents.add_reagent(i, (20 - R.volume))
|
||||
|
||||
/obj/machinery/sleeper/RefreshParts()
|
||||
var/E
|
||||
@@ -47,6 +67,11 @@
|
||||
available_chems |= possible_chems[i]
|
||||
reset_chem_buttons()
|
||||
|
||||
//Total container size 500 - 2000u
|
||||
if(reagents)
|
||||
reagents.maximum_volume = (500*E)
|
||||
|
||||
|
||||
/obj/machinery/sleeper/update_icon()
|
||||
icon_state = initial(icon_state)
|
||||
if(state_open)
|
||||
@@ -81,7 +106,42 @@
|
||||
if (. & EMP_PROTECT_SELF)
|
||||
return
|
||||
if(is_operational() && occupant)
|
||||
var/datum/reagent/R = pick(reagents.reagent_list)
|
||||
inject_chem(R.id, occupant)
|
||||
open_machine()
|
||||
//Is this too much?
|
||||
if(severity == EMP_HEAVY)
|
||||
var/chem = pick(available_chems)
|
||||
available_chems -= chem
|
||||
available_chems += get_random_reagent_id()
|
||||
reset_chem_buttons()
|
||||
|
||||
/obj/machinery/sleeper/attackby(obj/item/I, mob/user, params)
|
||||
if(istype(I, /obj/item/reagent_containers/sleeper_buffer))
|
||||
var/obj/item/reagent_containers/sleeper_buffer/SB = I
|
||||
if((SB.reagents.total_volume + reagents.total_volume) < reagents.maximum_volume)
|
||||
SB.reagents.trans_to(reagents, SB.reagents.total_volume)
|
||||
visible_message("[user] places the [SB] into the [src].")
|
||||
qdel(SB)
|
||||
return
|
||||
else
|
||||
SB.reagents.trans_to(reagents, SB.reagents.total_volume)
|
||||
visible_message("[user] adds as much as they can to the [src] from the [SB].")
|
||||
return
|
||||
if(istype(I, /obj/item/reagent_containers))
|
||||
var/obj/item/reagent_containers/RC = I
|
||||
if(RC.reagents.total_volume == 0)
|
||||
to_chat(user, "<span class='notice'>The [I] is empty!</span>")
|
||||
for(var/datum/reagent/R in RC.reagents.reagent_list)
|
||||
if((obj_flags & EMAGGED) || (allowed(usr)))
|
||||
break
|
||||
if(!istype(R, /datum/reagent/medicine))
|
||||
visible_message("The [src] gives out a hearty boop and rejects the [I]. The Sleeper's screen flashes with a pompous \"Medicines only, please.\"")
|
||||
return
|
||||
RC.reagents.trans_to(reagents, 1000)
|
||||
visible_message("[user] adds as much as they can to the [src] from the [I].")
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/sleeper/MouseDrop_T(mob/target, mob/user)
|
||||
if(user.stat || user.lying || !Adjacent(user) || !user.Adjacent(target) || !iscarbon(target) || !user.IsAdvancedToolUser())
|
||||
@@ -141,18 +201,24 @@
|
||||
|
||||
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "sleeper", name, 375, 550, master_ui, state)
|
||||
ui = new(user, src, ui_key, "sleeper", name, 550, 700, master_ui, state)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/sleeper/ui_data()
|
||||
var/list/data = list()
|
||||
data["occupied"] = occupant ? 1 : 0
|
||||
data["open"] = state_open
|
||||
data["efficiency"] = efficiency
|
||||
data["current_vol"] = reagents.total_volume
|
||||
data["tot_capacity"] = reagents.maximum_volume
|
||||
|
||||
data["chems"] = list()
|
||||
for(var/chem in available_chems)
|
||||
var/datum/reagent/R = GLOB.chemical_reagents_list[chem]
|
||||
data["chems"] += list(list("name" = R.name, "id" = R.id, "allowed" = chem_allowed(chem)))
|
||||
var/datum/reagent/R = reagents.has_reagent(chem)
|
||||
R = GLOB.chemical_reagents_list[chem]
|
||||
data["synthchems"] += list(list("name" = R.name, "id" = R.id, "synth_allowed" = synth_allowed(chem)))
|
||||
for(var/datum/reagent/R in reagents.reagent_list)
|
||||
data["chems"] += list(list("name" = R.name, "id" = R.id, "vol" = R.volume, "purity" = R.purity, "allowed" = chem_allowed(R.id)))
|
||||
|
||||
data["occupant"] = list()
|
||||
var/mob/living/mob_occupant = occupant
|
||||
@@ -184,8 +250,15 @@
|
||||
if(mob_occupant.reagents && mob_occupant.reagents.reagent_list.len)
|
||||
for(var/datum/reagent/R in mob_occupant.reagents.reagent_list)
|
||||
data["occupant"]["reagents"] += list(list("name" = R.name, "volume" = R.volume))
|
||||
data["occupant"]["failing_organs"] = list()
|
||||
var/mob/living/carbon/C = mob_occupant
|
||||
if(C)
|
||||
for(var/obj/item/organ/Or in C.getFailingOrgans())
|
||||
if(istype(Or, /obj/item/organ/brain))
|
||||
continue
|
||||
data["occupant"]["failing_organs"] += list(list("name" = Or.name))
|
||||
|
||||
if(mob_occupant.has_dna()) // Blood-stuff is mostly a copy-paste from the healthscanner.
|
||||
var/mob/living/carbon/C = mob_occupant
|
||||
var/blood_id = C.get_blood_id()
|
||||
if(blood_id)
|
||||
data["occupant"]["blood"] = list() // We can start populating this list.
|
||||
@@ -196,7 +269,7 @@
|
||||
blood_type = R.name
|
||||
else
|
||||
blood_type = blood_id
|
||||
data["occupant"]["blood"]["maxBloodVolume"] = BLOOD_VOLUME_NORMAL
|
||||
data["occupant"]["blood"]["maxBloodVolume"] = (BLOOD_VOLUME_NORMAL*C.blood_ratio)
|
||||
data["occupant"]["blood"]["currentBloodVolume"] = C.blood_volume
|
||||
data["occupant"]["blood"]["dangerBloodVolume"] = BLOOD_VOLUME_SAFE
|
||||
data["occupant"]["blood"]["bloodType"] = blood_type
|
||||
@@ -216,24 +289,49 @@
|
||||
. = TRUE
|
||||
if("inject")
|
||||
var/chem = params["chem"]
|
||||
var/amount = text2num(params["volume"])
|
||||
if(!is_operational() || !mob_occupant)
|
||||
return
|
||||
if(mob_occupant.health < min_health && chem != "epinephrine")
|
||||
return
|
||||
if(inject_chem(chem, usr))
|
||||
if(inject_chem(chem, usr, amount))
|
||||
. = TRUE
|
||||
if(scrambled_chems && prob(5))
|
||||
to_chat(usr, "<span class='warning'>Chemical system re-route detected, results may not be as expected!</span>")
|
||||
if("synth")
|
||||
var/chem = params["chem"]
|
||||
if(!is_operational())
|
||||
return
|
||||
reagents.add_reagent(chem_buttons[chem], 10) //other_purity = 0.75 for when the mechanics are in
|
||||
if("purge")
|
||||
var/chem = params["chem"]
|
||||
if(allowed(usr))
|
||||
if(!is_operational())
|
||||
return
|
||||
reagents.remove_reagent(chem, 10)
|
||||
return
|
||||
if(chem in available_chems)
|
||||
if(!is_operational())
|
||||
return
|
||||
/*var/datum/reagent/R = reagents.has_reagent(chem) //For when purity effects are in
|
||||
if(R.purity < 0.8)*/
|
||||
reagents.remove_reagent(chem, 10)
|
||||
else
|
||||
visible_message("<span class='warning'>Access Denied.</span>")
|
||||
playsound(src, 'sound/machines/terminal_prompt_deny.ogg', 50, 0)
|
||||
|
||||
|
||||
/obj/machinery/sleeper/emag_act(mob/user)
|
||||
. = ..()
|
||||
obj_flags |= EMAGGED
|
||||
scramble_chem_buttons()
|
||||
to_chat(user, "<span class='warning'>You scramble the sleeper's user interface!</span>")
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/sleeper/proc/inject_chem(chem, mob/user)
|
||||
if((chem in available_chems) && chem_allowed(chem))
|
||||
occupant.reagents.add_reagent(chem_buttons[chem], 10) //emag effect kicks in here so that the "intended" chem is used for all checks, for extra FUUU
|
||||
//trans to
|
||||
/obj/machinery/sleeper/proc/inject_chem(chem, mob/user, volume = 10)
|
||||
if(chem_allowed(chem))
|
||||
reagents.trans_id_to(occupant, chem, volume)//emag effect kicks in here so that the "intended" chem is used for all checks, for extra FUUU
|
||||
if(user)
|
||||
log_combat(user, occupant, "injected [chem] into", addition = "via [src]")
|
||||
return TRUE
|
||||
@@ -246,6 +344,14 @@
|
||||
var/occ_health = mob_occupant.health > min_health || chem == "epinephrine"
|
||||
return amount && occ_health
|
||||
|
||||
/obj/machinery/sleeper/proc/synth_allowed(chem)
|
||||
var/datum/reagent/R = reagents.has_reagent(chem)
|
||||
if(!R)
|
||||
return TRUE
|
||||
if(R.volume < 50)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
/obj/machinery/sleeper/proc/reset_chem_buttons()
|
||||
scrambled_chems = FALSE
|
||||
LAZYINITLIST(chem_buttons)
|
||||
|
||||
@@ -991,4 +991,4 @@
|
||||
/obj/item/stack/sheet/glass = 2,
|
||||
/obj/item/stock_parts/capacitor = 1,
|
||||
/obj/item/stack/cable_coil = 5,
|
||||
/obj/item/reagent_containers/glass/beaker = 6) //So it can hold lots of chems
|
||||
/obj/item/reagent_containers/glass/beaker = 6) //So it can hold lots of chems
|
||||
|
||||
@@ -157,6 +157,11 @@
|
||||
O.applyOrganDamage(amount, maximum)
|
||||
O.onDamage(amount, maximum)
|
||||
|
||||
/mob/living/carbon/proc/getFailingOrgans()
|
||||
.=list()
|
||||
for(var/obj/item/organ/O in internal_organs)
|
||||
if(O.organ_flags & ORGAN_FAILING)
|
||||
.+=O
|
||||
|
||||
////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
//Created if a sleeper is deconstructed, to contain the reagents within it.
|
||||
/obj/item/reagent_containers/sleeper_buffer
|
||||
name = "Sleeper buffer container"
|
||||
desc = "A closed container for insertion in the Medical Sleepers."
|
||||
icon_state = "sleeper_buffer"
|
||||
volume = 500
|
||||
reagent_flags = NO_REACT
|
||||
spillable = TRUE
|
||||
resistance_flags = ACID_PROOF
|
||||
amount_per_transfer_from_this = 0
|
||||
possible_transfer_amounts = list(0)
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 54 KiB |
@@ -2623,6 +2623,7 @@
|
||||
#include "code\modules\reagents\reagent_containers\patch.dm"
|
||||
#include "code\modules\reagents\reagent_containers\pill.dm"
|
||||
#include "code\modules\reagents\reagent_containers\rags.dm"
|
||||
#include "code\modules\reagents\reagent_containers\sleeper_buffer.dm"
|
||||
#include "code\modules\reagents\reagent_containers\spray.dm"
|
||||
#include "code\modules\reagents\reagent_containers\syringes.dm"
|
||||
#include "code\modules\recycling\conveyor2.dm"
|
||||
|
||||
File diff suppressed because one or more lines are too long
+3
-3
File diff suppressed because one or more lines are too long
@@ -32,6 +32,12 @@ section
|
||||
@extend $cell
|
||||
width: 100%
|
||||
|
||||
.compressedcell
|
||||
@extend $cell
|
||||
&:not(:first-child)
|
||||
text-align: center
|
||||
padding-top: 0px
|
||||
|
||||
.cell
|
||||
@extend $cell
|
||||
&:not(:first-child)
|
||||
@@ -41,4 +47,3 @@ section
|
||||
width: 75px
|
||||
&:not(:last-child)
|
||||
padding-right: 4px
|
||||
|
||||
@@ -31,6 +31,13 @@
|
||||
<ui-section label='Brain'>
|
||||
<span class='{{data.occupant.brainLoss ? "bad" : "good"}}'>{{data.occupant.brainLoss ? "Abnormal" : "Healthy"}}</span>
|
||||
</ui-section>
|
||||
{{#if data.occupant.failing_organs}}
|
||||
<ui-section label='Failing Organs'>
|
||||
{{#each data.occupant.failing_organs}}
|
||||
<span class='bad'> {{name}} </span>
|
||||
{{/each}}
|
||||
</ui-section>
|
||||
{{/if}}
|
||||
<ui-section label='Bloodstream'>
|
||||
{{#each adata.occupant.reagents}}
|
||||
<span class='highlight' intro-outro='fade'>{{Math.fixed(volume, 1)}} units of {{name}}</span><br/>
|
||||
@@ -44,9 +51,89 @@
|
||||
<ui-section label='Door'>
|
||||
<ui-button icon='{{data.open ? "unlock" : "lock"}}' action='door'>{{data.open ? "Open" : "Closed"}}</ui-button>
|
||||
</ui-section>
|
||||
<ui-section label='Inject'>
|
||||
{{#each data.chems}}
|
||||
<ui-button icon='flask' state='{{data.occupied && allowed ? null : "disabled"}}' action='inject' params='{"chem": "{{id}}"}'>{{name}}</ui-button><br/>
|
||||
|
||||
<ui-section label='Synthesize'>
|
||||
{{#each data.synthchems}}
|
||||
<ui-button grid state='{{synth_allowed ? null : "disabled"}}' action='synth' params='{"chem": "{{id}}"}'>{{name}}</ui-button>
|
||||
{{/each}}
|
||||
</ui-section>
|
||||
|
||||
<ui-section label='Inject'>
|
||||
<div class="display tabular">
|
||||
<section class="candystripe">
|
||||
<section class="compressedcell">
|
||||
Name
|
||||
</section>
|
||||
|
||||
<section class="compressedcell">
|
||||
Volume
|
||||
</section>
|
||||
|
||||
{{#if data.efficiency >= 4}}
|
||||
<section class="compressedcell">
|
||||
<span>Purity</span>
|
||||
</section>
|
||||
{{/if}}
|
||||
|
||||
{{#if data.efficiency >= 3}}
|
||||
<section class="compressedcell">
|
||||
</section>
|
||||
{{/if}}
|
||||
|
||||
{{#if data.efficiency >= 2}}
|
||||
<section class="compressedcell">
|
||||
</section>
|
||||
{{/if}}
|
||||
|
||||
<section class="compressedcell">
|
||||
</section>
|
||||
|
||||
<section class="compressedcell">
|
||||
</section>
|
||||
|
||||
</section>
|
||||
{{#each data.chems}}
|
||||
<section class="candystripe">
|
||||
<section class="compressedcell">
|
||||
<span><b>{{name}}</b></span>
|
||||
</section>
|
||||
|
||||
<section class="compressedcell" align='center'>
|
||||
<span>{{vol}}u</span>
|
||||
</section>
|
||||
|
||||
{{#if data.efficiency >= 4}}
|
||||
<section class="compressedcell" align='center'>
|
||||
<span>{{purity}}</span>
|
||||
</section>
|
||||
{{/if}}
|
||||
|
||||
{{#if data.efficiency >= 3}}
|
||||
<section class="compressedcell">
|
||||
<ui-button state='{{data.occupied && allowed ? null : "disabled"}}' action='inject' params='{"chem": "{{id}}", "volume": 1}'>1</ui-button>
|
||||
</section>
|
||||
{{/if}}
|
||||
|
||||
{{#if adata.efficiency >= 2}}
|
||||
<section class="compressedcell">
|
||||
<ui-button state='{{data.occupied && allowed ? null : "disabled"}}' action='inject' params='{"chem": "{{id}}", "volume": 5}'>5</ui-button>
|
||||
</section>
|
||||
{{/if}}
|
||||
|
||||
<section class="compressedcell">
|
||||
<ui-button state='{{data.occupied && allowed ? null : "disabled"}}' action='inject' params='{"chem": "{{id}}", "volume": 10}'>10</ui-button>
|
||||
</section>
|
||||
|
||||
<section class="compressedcell">
|
||||
<ui-button action='purge' params='{"chem": "{{id}}"}'>Purge</ui-button><br/>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
{{/each}}
|
||||
</div>
|
||||
</ui-section>
|
||||
<ui-section label='Capacity'>
|
||||
<ui-bar min=0 max='{{data.tot_capacity}}' value='{{data.current_vol}}'
|
||||
state='{{data.current_vol}}'>{{data.current_vol}}</ui-bar>
|
||||
</ui-section>
|
||||
</ui-display>
|
||||
|
||||
Reference in New Issue
Block a user