diff --git a/code/ATMOSPHERICS/atmospherics.dm b/code/ATMOSPHERICS/atmospherics.dm index b5d4df814e..ee24252a0c 100644 --- a/code/ATMOSPHERICS/atmospherics.dm +++ b/code/ATMOSPHERICS/atmospherics.dm @@ -124,4 +124,11 @@ obj/machinery/atmospherics/proc/check_connect_types(obj/machinery/atmospherics/a /obj/machinery/atmospherics/proc/disconnect(obj/machinery/atmospherics/reference) /obj/machinery/atmospherics/update_icon() - return null \ No newline at end of file + return null + +/obj/machinery/atmospherics/proc/can_unwrench() + var/datum/gas_mixture/int_air = return_air() + var/datum/gas_mixture/env_air = loc.return_air() + if((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) + return 0 + return 1 \ No newline at end of file diff --git a/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm b/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm index fa88ef2ab2..ceb192f9b0 100644 --- a/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm +++ b/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm @@ -242,10 +242,8 @@ if (unlocked) user << "You cannot unwrench \the [src], turn it off first." return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "You cannot unwrench \the [src], it too exerted due to internal pressure." + if(!can_unwrench()) + to_chat(user, "You cannot unwrench \the [src], it too exerted due to internal pressure.") add_fingerprint(user) return 1 playsound(src, W.usesound, 50, 1) diff --git a/code/ATMOSPHERICS/components/binary_devices/pump.dm b/code/ATMOSPHERICS/components/binary_devices/pump.dm index 126c6391d4..97abccdfad 100644 --- a/code/ATMOSPHERICS/components/binary_devices/pump.dm +++ b/code/ATMOSPHERICS/components/binary_devices/pump.dm @@ -221,10 +221,8 @@ Thus, the two variables affect pump operation are set in New(): if (!(stat & NOPOWER) && use_power) user << "You cannot unwrench this [src], turn it off first." return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "You cannot unwrench this [src], it too exerted due to internal pressure." + if(!can_unwrench()) + to_chat(user, "You cannot unwrench this [src], it too exerted due to internal pressure.") add_fingerprint(user) return 1 playsound(src, W.usesound, 50, 1) diff --git a/code/ATMOSPHERICS/components/omni_devices/omni_base.dm b/code/ATMOSPHERICS/components/omni_devices/omni_base.dm index 6690c7c257..eec81b9c74 100644 --- a/code/ATMOSPHERICS/components/omni_devices/omni_base.dm +++ b/code/ATMOSPHERICS/components/omni_devices/omni_base.dm @@ -82,12 +82,8 @@ if(!istype(W, /obj/item/weapon/wrench)) return ..() - var/int_pressure = 0 - for(var/datum/omni_port/P in ports) - int_pressure += P.air.return_pressure() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_pressure - env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "You cannot unwrench \the [src], it is too exerted due to internal pressure." + if(!can_unwrench()) + to_chat(user, "You cannot unwrench \the [src], it is too exerted due to internal pressure.") add_fingerprint(user) return 1 user << "You begin to unfasten \the [src]..." @@ -100,6 +96,15 @@ new /obj/item/pipe(loc, make_from=src) qdel(src) +/obj/machinery/atmospherics/omni/can_unwrench() + var/int_pressure = 0 + for(var/datum/omni_port/P in ports) + int_pressure += P.air.return_pressure() + var/datum/gas_mixture/env_air = loc.return_air() + if((int_pressure - env_air.return_pressure()) > 2*ONE_ATMOSPHERE) + return 0 + return 1 + /obj/machinery/atmospherics/omni/attack_hand(user as mob) if(..()) return diff --git a/code/ATMOSPHERICS/components/portables_connector.dm b/code/ATMOSPHERICS/components/portables_connector.dm index c39ca8469b..885141a9fc 100644 --- a/code/ATMOSPHERICS/components/portables_connector.dm +++ b/code/ATMOSPHERICS/components/portables_connector.dm @@ -136,10 +136,8 @@ return 1 if (locate(/obj/machinery/portable_atmospherics, src.loc)) return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "You cannot unwrench \the [src], it too exerted due to internal pressure." + if(!can_unwrench()) + to_chat(user, "You cannot unwrench \the [src], it too exerted due to internal pressure.") add_fingerprint(user) return 1 playsound(src, W.usesound, 50, 1) diff --git a/code/ATMOSPHERICS/components/trinary_devices/filter.dm b/code/ATMOSPHERICS/components/trinary_devices/filter.dm index ef6a29b910..ef43efca6b 100755 --- a/code/ATMOSPHERICS/components/trinary_devices/filter.dm +++ b/code/ATMOSPHERICS/components/trinary_devices/filter.dm @@ -131,10 +131,8 @@ /obj/machinery/atmospherics/trinary/filter/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob) if (!istype(W, /obj/item/weapon/wrench)) return ..() - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "You cannot unwrench \the [src], it too exerted due to internal pressure." + if(!can_unwrench()) + to_chat(user, "You cannot unwrench \the [src], it too exerted due to internal pressure.") add_fingerprint(user) return 1 playsound(src, W.usesound, 50, 1) diff --git a/code/ATMOSPHERICS/components/trinary_devices/mixer.dm b/code/ATMOSPHERICS/components/trinary_devices/mixer.dm index f8c3e9ff67..7f1c7e1e1f 100644 --- a/code/ATMOSPHERICS/components/trinary_devices/mixer.dm +++ b/code/ATMOSPHERICS/components/trinary_devices/mixer.dm @@ -106,10 +106,8 @@ /obj/machinery/atmospherics/trinary/mixer/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob) if (!istype(W, /obj/item/weapon/wrench)) return ..() - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "You cannot unwrench \the [src], it too exerted due to internal pressure." + if(!can_unwrench()) + to_chat(user, "You cannot unwrench \the [src], it too exerted due to internal pressure.") add_fingerprint(user) return 1 playsound(src, W.usesound, 50, 1) diff --git a/code/ATMOSPHERICS/components/tvalve.dm b/code/ATMOSPHERICS/components/tvalve.dm index 81a870743e..77df0b2b75 100644 --- a/code/ATMOSPHERICS/components/tvalve.dm +++ b/code/ATMOSPHERICS/components/tvalve.dm @@ -348,10 +348,8 @@ if (istype(src, /obj/machinery/atmospherics/tvalve/digital)) user << "You cannot unwrench \the [src], it's too complicated." return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "You cannot unwrench \the [src], it too exerted due to internal pressure." + if(!can_unwrench()) + to_chat(user, "You cannot unwrench \the [src], it too exerted due to internal pressure.") add_fingerprint(user) return 1 playsound(src, W.usesound, 50, 1) diff --git a/code/ATMOSPHERICS/components/unary/heat_exchanger.dm b/code/ATMOSPHERICS/components/unary/heat_exchanger.dm index 533e84b8f9..3413aa04de 100644 --- a/code/ATMOSPHERICS/components/unary/heat_exchanger.dm +++ b/code/ATMOSPHERICS/components/unary/heat_exchanger.dm @@ -72,9 +72,7 @@ if (level==1 && isturf(T) && !T.is_plating()) user << "You must remove the plating first." return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) + if (!can_unwrench()) user << "You cannot unwrench \the [src], it is too exerted due to internal pressure." add_fingerprint(user) return 1 diff --git a/code/ATMOSPHERICS/components/unary/vent_pump.dm b/code/ATMOSPHERICS/components/unary/vent_pump.dm index b44f8768ff..1b271d1e4a 100644 --- a/code/ATMOSPHERICS/components/unary/vent_pump.dm +++ b/code/ATMOSPHERICS/components/unary/vent_pump.dm @@ -401,10 +401,8 @@ if (node && node.level==1 && isturf(T) && !T.is_plating()) user << "You must remove the plating first." return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "You cannot unwrench \the [src], it is too exerted due to internal pressure." + if(!can_unwrench()) + to_chat(user, "You cannot unwrench \the [src], it is too exerted due to internal pressure.") add_fingerprint(user) return 1 playsound(src, W.usesound, 50, 1) diff --git a/code/ATMOSPHERICS/components/unary/vent_scrubber.dm b/code/ATMOSPHERICS/components/unary/vent_scrubber.dm index 539ab2ecc8..8bb67bcc19 100644 --- a/code/ATMOSPHERICS/components/unary/vent_scrubber.dm +++ b/code/ATMOSPHERICS/components/unary/vent_scrubber.dm @@ -272,10 +272,8 @@ if (node && node.level==1 && isturf(T) && !T.is_plating()) user << "You must remove the plating first." return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "You cannot unwrench \the [src], it is too exerted due to internal pressure." + if(!can_unwrench()) + to_chat(user, "You cannot unwrench \the [src], it is too exerted due to internal pressure.") add_fingerprint(user) return 1 playsound(src, W.usesound, 50, 1) diff --git a/code/ATMOSPHERICS/components/valve.dm b/code/ATMOSPHERICS/components/valve.dm index 7fa8d60a77..85a5b3a2e0 100644 --- a/code/ATMOSPHERICS/components/valve.dm +++ b/code/ATMOSPHERICS/components/valve.dm @@ -292,10 +292,8 @@ if (istype(src, /obj/machinery/atmospherics/valve/digital) && !src.allowed(user)) user << "Access denied." return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "You cannot unwrench \the [src], it is too exerted due to internal pressure." + if(!can_unwrench()) + to_chat(user, "You cannot unwrench \the [src], it is too exerted due to internal pressure.") add_fingerprint(user) return 1 playsound(src, W.usesound, 50, 1) diff --git a/code/ATMOSPHERICS/pipes.dm b/code/ATMOSPHERICS/pipes.dm index 11a18e251c..659bcb05ad 100644 --- a/code/ATMOSPHERICS/pipes.dm +++ b/code/ATMOSPHERICS/pipes.dm @@ -82,10 +82,8 @@ if (level==1 && isturf(T) && !T.is_plating()) user << "You must remove the plating first." return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "You cannot unwrench \the [src], it is too exerted due to internal pressure." + if(!can_unwrench()) + to_chat(user, "You cannot unwrench \the [src], it is too exerted due to internal pressure.") add_fingerprint(user) return 1 playsound(src, W.usesound, 50, 1) @@ -1014,6 +1012,9 @@ if(level == 1 && !T.is_plating()) hide(1) update_icon() +/obj/machinery/atmospherics/pipe/cap/can_unwrench() + return 1 + /obj/machinery/atmospherics/pipe/cap/visible level = 2 icon_state = "cap"