diff --git a/code/game/machinery/OpTable.dm b/code/game/machinery/OpTable.dm index 5696892ddc..ccf3f69529 100644 --- a/code/game/machinery/OpTable.dm +++ b/code/game/machinery/OpTable.dm @@ -9,6 +9,7 @@ idle_power_usage = 1 active_power_usage = 5 surgery_odds = 100 + throwpass = 1 var/mob/living/carbon/human/victim = null var/strapped = 0.0 var/obj/machinery/computer/operating/computer = null diff --git a/code/game/machinery/oxygen_pump.dm b/code/game/machinery/oxygen_pump.dm new file mode 100644 index 0000000000..7039f9445a --- /dev/null +++ b/code/game/machinery/oxygen_pump.dm @@ -0,0 +1,243 @@ +#define TANK_MAX_RELEASE_PRESSURE (3*ONE_ATMOSPHERE) +#define TANK_DEFAULT_RELEASE_PRESSURE ONE_ATMOSPHERE + +/obj/machinery/oxygen_pump + name = "emergency oxygen pump" + icon = 'icons/obj/walllocker.dmi' + desc = "A wall mounted oxygen pump with a retractable face mask that you can pull over your face in case of emergencies." + icon_state = "oxygen_tank" + + anchored = TRUE + + var/obj/item/weapon/tank/tank + var/mob/living/carbon/breather + var/obj/item/clothing/mask/breath/contained + + var/spawn_type = /obj/item/weapon/tank/emergency/oxygen/engi + var/mask_type = /obj/item/clothing/mask/breath/emergency + var/icon_state_open = "oxygen_tank_open" + var/icon_state_closed = "oxygen_tank" + + power_channel = ENVIRON + idle_power_usage = 10 + active_power_usage = 120 // No idea what the realistic amount would be. + +/obj/machinery/oxygen_pump/initialize() + . = ..() + tank = new spawn_type (src) + contained = new mask_type (src) + +/obj/machinery/oxygen_pump/Destroy() + if(breather) + breather.internal = null + if(breather.internals) + breather.internals.icon_state = "internal0" + if(tank) + qdel(tank) + if(breather) + breather.remove_from_mob(contained) + src.visible_message("The mask rapidly retracts just before /the [src] is destroyed!") + qdel(contained) + contained = null + breather = null + return ..() + +/obj/machinery/oxygen_pump/MouseDrop(var/mob/living/carbon/human/target, src_location, over_location) + ..() + if(istype(target) && CanMouseDrop(target)) + if(!can_apply_to_target(target, usr)) // There is no point in attempting to apply a mask if it's impossible. + return + usr.visible_message("\The [usr] begins placing the mask onto [target]..") + if(!do_mob(usr, target, 25) || !can_apply_to_target(target, usr)) + return + // place mask and add fingerprints + usr.visible_message("\The [usr] has placed \the mask on [target]'s mouth.") + attach_mask(target) + src.add_fingerprint(usr) + +/obj/machinery/oxygen_pump/attack_hand(mob/user as mob) + if((stat & MAINT) && tank) + user.visible_message("\The [user] removes \the [tank] from \the [src].", "You remove \the [tank] from \the [src].") + user.put_in_hands(tank) + src.add_fingerprint(user) + tank.add_fingerprint(user) + tank = null + return + if (!tank) + to_chat(user, "There is no tank in \the [src]!") + return + if(breather) + if(tank) + tank.forceMove(src) + breather.remove_from_mob(contained) + contained.forceMove(src) + src.visible_message("\The [user] makes \The [contained] rapidly retracts back into \the [src]!") + if(breather.internals) + breather.internals.icon_state = "internal0" + breather = null + use_power = 1 + +/obj/machinery/oxygen_pump/attack_ai(mob/user as mob) + ui_interact(user) + +/obj/machinery/oxygen_pump/proc/attach_mask(var/mob/living/carbon/C) + if(C && istype(C)) + contained.forceMove(get_turf(C)) + C.equip_to_slot(contained, slot_wear_mask) + if(tank) + tank.forceMove(C) + breather = C + spawn(1) + if(!breather.internal && tank) + breather.internal = tank + if(breather.internals) + breather.internals.icon_state = "internal1" + use_power = 2 + +/obj/machinery/oxygen_pump/proc/can_apply_to_target(var/mob/living/carbon/human/target, mob/user as mob) + if(!user) + user = target + // Check target validity + if(!target.organs_by_name[BP_HEAD]) + to_chat(user, "\The [target] doesn't have a head.") + return + if(!target.check_has_mouth()) + to_chat(user, "\The [target] doesn't have a mouth.") + return + if(target.wear_mask && target != breather) + to_chat(user, "\The [target] is already wearing a mask.") + return + if(target.head && (target.head.body_parts_covered & FACE)) + to_chat(user, "Remove their [target.head] first.") + return + if(!tank) + to_chat(user, "There is no tank in \the [src].") + return + if(stat & MAINT) + to_chat(user, "Please close \the maintenance hatch first.") + return + if(!Adjacent(target)) + to_chat(user, "Please stay close to \the [src].") + return + //when there is a breather: + if(breather && target != breather) + to_chat(user, "\The pump is already in use.") + return + //Checking if breather is still valid + if(target == breather && target.wear_mask != contained) + to_chat(user, "\The [target] is not using the supplied mask.") + return + return 1 + +/obj/machinery/oxygen_pump/attackby(obj/item/weapon/W as obj, mob/user as mob) + if(istype(W,/obj/item/weapon/screwdriver)) + stat ^= MAINT + user.visible_message("\The [user] [stat & MAINT ? "opens" : "closes"] \the [src].", "You [stat & MAINT ? "open" : "close"] \the [src].") + if(stat & MAINT) + icon_state = icon_state_open + if(!stat) + icon_state = icon_state_closed + //TO-DO: Open icon + if(istype(W, /obj/item/weapon/tank) && (stat & MAINT)) + if(tank) + to_chat(user, "\The [src] already has a tank installed!") + else + user.drop_item() + W.forceMove(src) + tank = W + user.visible_message("\The [user] installs \the [tank] into \the [src].", "You install \the [tank] into \the [src].") + src.add_fingerprint(user) + if(istype(W, /obj/item/weapon/tank) && !stat) + to_chat(user, "Please open the maintenance hatch first.") + +/obj/machinery/oxygen_pump/examine(var/mob/user) + . = ..() + if(tank) + to_chat(user, "The meter shows [round(tank.air_contents.return_pressure())]") + else + to_chat(user, "It is missing a tank!") + + +/obj/machinery/oxygen_pump/process() + if(breather) + if(!can_apply_to_target(breather)) + if(tank) + tank.forceMove(src) + breather.remove_from_mob(contained) + contained.forceMove(src) + src.visible_message("\The [contained] rapidly retracts back into \the [src]!") + breather = null + use_power = 1 + else if(!breather.internal && tank) + breather.internal = tank + if(breather.internals) + breather.internals.icon_state = "internal0" + +//Create rightclick to view tank settings +/obj/machinery/oxygen_pump/verb/settings() + set src in oview(1) + set category = "Object" + set name = "Show Tank Settings" + ui_interact(usr) + +//GUI Tank Setup +/obj/machinery/oxygen_pump/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1) + var/data[0] + if(!tank) + to_chat(usr, "It is missing a tank!") + data["tankPressure"] = 0 + data["releasePressure"] = 0 + data["defaultReleasePressure"] = 0 + data["maxReleasePressure"] = 0 + data["maskConnected"] = 0 + data["tankInstalled"] = 0 + // this is the data which will be sent to the ui + if(tank) + data["tankPressure"] = round(tank.air_contents.return_pressure() ? tank.air_contents.return_pressure() : 0) + data["releasePressure"] = round(tank.distribute_pressure ? tank.distribute_pressure : 0) + data["defaultReleasePressure"] = round(TANK_DEFAULT_RELEASE_PRESSURE) + data["maxReleasePressure"] = round(TANK_MAX_RELEASE_PRESSURE) + data["maskConnected"] = 0 + data["tankInstalled"] = 1 + + if(!breather) + data["maskConnected"] = 0 + if(breather) + data["maskConnected"] = 1 + + + // update the ui if it exists, returns null if no ui is passed/found + ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open) + if (!ui) + // the ui does not exist, so we'll create a new() one + // for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm + ui = new(user, src, ui_key, "Oxygen_pump.tmpl", "Tank", 500, 300) + // when the ui is first opened this is the data it will use + ui.set_initial_data(data) + // open the new ui window + ui.open() + // auto update every Master Controller tick + ui.set_auto_update(1) + +/obj/machinery/oxygen_pump/Topic(href, href_list) + if(..()) + return 1 + + if (href_list["dist_p"]) + if (href_list["dist_p"] == "reset") + tank.distribute_pressure = TANK_DEFAULT_RELEASE_PRESSURE + else if (href_list["dist_p"] == "max") + tank.distribute_pressure = TANK_MAX_RELEASE_PRESSURE + else + var/cp = text2num(href_list["dist_p"]) + tank.distribute_pressure += cp + tank.distribute_pressure = min(max(round(tank.distribute_pressure), 0), TANK_MAX_RELEASE_PRESSURE) + return 1 + +/obj/machinery/oxygen_pump/anesthetic + name = "anesthetic pump" + spawn_type = /obj/item/weapon/tank/anesthetic + icon_state = "anesthetic_tank" + icon_state_closed = "anesthetic_tank" + icon_state_open = "anesthetic_tank_open" + mask_type = /obj/item/clothing/mask/breath/anesthetic diff --git a/code/modules/clothing/masks/breath.dm b/code/modules/clothing/masks/breath.dm index 48d24bb8c2..ea3e6c7cf4 100644 --- a/code/modules/clothing/masks/breath.dm +++ b/code/modules/clothing/masks/breath.dm @@ -45,3 +45,17 @@ icon_state = "medical" item_state_slots = list(slot_r_hand_str = "medical", slot_l_hand_str = "medical") permeability_coefficient = 0.01 + +/obj/item/clothing/mask/breath/emergency + desc = "A close-fitting mask that is used by the wallmounted emergency oxygen pump." + name = "emergency mask" + icon_state = "breath" + item_state = "breath" + permeability_coefficient = 0.50 + +/obj/item/clothing/mask/breath/anesthetic + desc = "A close-fitting sterile mask that is used by the anesthetic wallmounted pump." + name = "anesthetic mask" + icon_state = "medical" + item_state = "medical" + permeability_coefficient = 0.01 diff --git a/icons/obj/walllocker.dmi b/icons/obj/walllocker.dmi index 8d43670829..d4d5ced3d2 100644 Binary files a/icons/obj/walllocker.dmi and b/icons/obj/walllocker.dmi differ diff --git a/nano/templates/Oxygen_pump.tmpl b/nano/templates/Oxygen_pump.tmpl new file mode 100644 index 0000000000..9fff202658 --- /dev/null +++ b/nano/templates/Oxygen_pump.tmpl @@ -0,0 +1,42 @@ +{{if data.maskConnected}} +
This pump is connected to a person.
+{{else}} +
This pump is NOT connected to a person.
+{{/if}} + +{{if data.tankInstalled}} +
+
+ Tank Pressure: +
+
+ {{:helper.displayBar(data.tankPressure, 0, 1013, (data.tankPressure > 200) ? 'good' : ((data.tankPressure > 100) ? 'average' : 'bad'))}} +
+ {{:data.tankPressure}} kPa +
+
+
+ +
 
+ +
+
+ Mask Release Pressure: +
+
+ {{:helper.displayBar(data.releasePressure, 0, data.maxReleasePressure, (data.releasePressure >= 23) ? null : ((data.releasePressure >= 17) ? 'average' : 'bad'))}} +
+ {{:helper.link('-', null, {'dist_p' : -10}, (data.releasePressure > 0) ? null : 'disabled')}} + {{:helper.link('-', null, {'dist_p' : -1}, (data.releasePressure > 0) ? null : 'disabled')}} +
 {{:data.releasePressure}} kPa 
+ {{:helper.link('+', null, {'dist_p' : 1}, (data.releasePressure < data.maxReleasePressure) ? null : 'disabled')}} + {{:helper.link('+', null, {'dist_p' : 10}, (data.releasePressure < data.maxReleasePressure) ? null : 'disabled')}} + {{:helper.link('Max', null, {'dist_p' : 'max'}, (data.releasePressure < data.maxReleasePressure) ? null : 'disabled')}} + {{:helper.link('Reset', null, {'dist_p' : 'reset'}, (data.releasePressure != data.defaultReleasePressure) ? null : 'disabled')}} +
+
+
+ +{{else}} +
This pump has no tank installed.
+{{/if}} \ No newline at end of file diff --git a/polaris.dme b/polaris.dme index e026cf9978..0021371648 100644 --- a/polaris.dme +++ b/polaris.dme @@ -614,6 +614,7 @@ #include "code\game\machinery\nuclear_bomb.dm" #include "code\game\machinery\OpTable.dm" #include "code\game\machinery\overview.dm" +#include "code\game\machinery\oxygen_pump.dm" #include "code\game\machinery\pda_multicaster.dm" #include "code\game\machinery\portable_turret.dm" #include "code\game\machinery\recharger.dm"