From 40f2b0f06ebb0fb70abbf5ac28c346147465fb4e Mon Sep 17 00:00:00 2001 From: Bloop <13398309+vinylspiders@users.noreply.github.com> Date: Tue, 14 Nov 2023 17:22:19 -0500 Subject: [PATCH] [MODULAR] Anesthetic mask will give an error message when placed via mapping (#24913) * Anesthetic mask will give an error message when placed via mapping It shouldn't be allowed to pass CI if it does. * Don't let them spawn outside of a machine * Update anesthetic_machine.dm * Gets rid of remaining anesthetic masks --- ...oon_underground_syndicate_base1_skyrat.dmm | 4 -- _maps/shuttles/skyrat/emergency_skyrat.dmm | 1 - _maps/shuttles/skyrat/whiteship_blueshift.dmm | 1 - .../medical/code/anesthetic_machine.dm | 53 +++++++++++++------ 4 files changed, 38 insertions(+), 21 deletions(-) diff --git a/_maps/RandomRuins/IceRuins/skyrat/icemoon_underground_syndicate_base1_skyrat.dmm b/_maps/RandomRuins/IceRuins/skyrat/icemoon_underground_syndicate_base1_skyrat.dmm index 56f6f487380..054ca30b339 100644 --- a/_maps/RandomRuins/IceRuins/skyrat/icemoon_underground_syndicate_base1_skyrat.dmm +++ b/_maps/RandomRuins/IceRuins/skyrat/icemoon_underground_syndicate_base1_skyrat.dmm @@ -2401,10 +2401,6 @@ pixel_x = -5; pixel_y = 5 }, -/obj/item/clothing/mask/breath/anesthetic{ - pixel_x = 8; - pixel_y = 5 - }, /turf/open/floor/iron/dark, /area/ruin/syndicate_lava_base/medbay) "uB" = ( diff --git a/_maps/shuttles/skyrat/emergency_skyrat.dmm b/_maps/shuttles/skyrat/emergency_skyrat.dmm index fee55c936e9..ead17d8442f 100644 --- a/_maps/shuttles/skyrat/emergency_skyrat.dmm +++ b/_maps/shuttles/skyrat/emergency_skyrat.dmm @@ -517,7 +517,6 @@ /obj/item/tank/internals/anesthetic{ pixel_y = 3 }, -/obj/item/clothing/mask/breath/anesthetic, /obj/effect/turf_decal/box/white/corners{ dir = 8 }, diff --git a/_maps/shuttles/skyrat/whiteship_blueshift.dmm b/_maps/shuttles/skyrat/whiteship_blueshift.dmm index 187ae424c11..998e435d1d5 100644 --- a/_maps/shuttles/skyrat/whiteship_blueshift.dmm +++ b/_maps/shuttles/skyrat/whiteship_blueshift.dmm @@ -3261,7 +3261,6 @@ /obj/structure/alien/weeds/node, /obj/machinery/anesthetic_machine, /obj/item/tank/internals/anesthetic, -/obj/item/clothing/mask/breath/anesthetic, /turf/open/floor/iron/white/side, /area/shuttle/abandoned/medbay) "FB" = ( diff --git a/modular_skyrat/modules/medical/code/anesthetic_machine.dm b/modular_skyrat/modules/medical/code/anesthetic_machine.dm index b7ef8f18cca..69b1bab7b70 100644 --- a/modular_skyrat/modules/medical/code/anesthetic_machine.dm +++ b/modular_skyrat/modules/medical/code/anesthetic_machine.dm @@ -27,7 +27,6 @@ /obj/machinery/anesthetic_machine/Initialize(mapload) . = ..() attached_mask = new /obj/item/clothing/mask/breath/anesthetic(src) - attached_mask.attached_machine = src update_icon() /obj/machinery/anesthetic_machine/wrench_act_secondary(mob/living/user, obj/item/tool) @@ -67,16 +66,16 @@ return FALSE visible_message(span_notice("[user] retracts [attached_mask] back into [src].")) -/obj/machinery/anesthetic_machine/attacked_by(obj/item/used_item, mob/living/user) - if(!istype(used_item, /obj/item/tank)) +/obj/machinery/anesthetic_machine/attackby(obj/item/attacking_item, mob/user, params) + if(!istype(attacking_item, /obj/item/tank)) return ..() if(attached_tank) // If there is an attached tank, remove it and drop it on the floor attached_tank.forceMove(loc) - used_item.forceMove(src) // Put new tank in, set it as attached tank - visible_message(span_notice("[user] inserts [used_item] into [src].")) - attached_tank = used_item + attacking_item.forceMove(src) // Put new tank in, set it as attached tank + visible_message(span_notice("[user] inserts [attacking_item] into [src].")) + attached_tank = attacking_item update_icon() /obj/machinery/anesthetic_machine/AltClick(mob/user) @@ -121,6 +120,11 @@ to_chat(usr, span_warning("[mask_out ? "The machine is already in use!" : "The machine has no attached tank!"]")) return FALSE + // if we somehow lost the mask, let's just make a brand new one. the wonders of technology! + if(QDELETED(attached_mask)) + attached_mask = new /obj/item/clothing/mask/breath/anesthetic(src) + update_icon() + usr.visible_message(span_warning("[usr] attemps to attach the [attached_mask] to [target]."), span_notice("You attempt to attach the [attached_mask] to [target]")) if(!do_after(usr, 5 SECONDS, target)) return @@ -159,7 +163,7 @@ attached_tank = null QDEL_NULL(attached_mask) - . = ..() + return ..() /// This a special version of the breath mask used for the anesthetic machine. /obj/item/clothing/mask/breath/anesthetic @@ -170,6 +174,21 @@ . = ..() ADD_TRAIT(src, TRAIT_NODROP, ABSTRACT_ITEM_TRAIT) + // Make sure we are not spawning outside of a machine + if(istype(loc, /obj/machinery/anesthetic_machine)) + attached_machine = WEAKREF(loc) + + var/obj/machinery/anesthetic_machine/our_machine + if(attached_machine) + our_machine = attached_machine.resolve() + + if(!our_machine) + attached_machine = null + if(mapload) + stack_trace("Abstract, undroppable item [name] spawned at ([loc]) at [AREACOORD(src)] in \the [get_area(src)]. \ + Please remove it. This item should only ever be created by the anesthetic machine.") + return INITIALIZE_HINT_QDEL + /obj/item/clothing/mask/breath/anesthetic/Destroy() attached_machine = null return ..() @@ -177,18 +196,22 @@ /obj/item/clothing/mask/breath/anesthetic/dropped(mob/user) . = ..() - if(loc != attached_machine) //If it isn't in the machine, then it retracts when dropped - to_chat(user, span_notice("[src] retracts back into the [attached_machine].")) + if(isnull(attached_machine)) + return - if(!istype(attached_machine, /obj/machinery/anesthetic_machine)) - qdel(src) - return FALSE + var/obj/machinery/anesthetic_machine/our_machine = attached_machine.resolve() + // no machine, then delete it + if(!our_machine) + attached_machine = null + qdel(src) + return - var/obj/machinery/anesthetic_machine/source_machine = attached_machine - source_machine.retract_mask() + if(loc != our_machine) //If it isn't in the machine, then it retracts when dropped + to_chat(user, span_notice("[src] retracts back into the [our_machine].")) + our_machine.retract_mask() /obj/item/clothing/mask/breath/anesthetic/adjustmask(mob/living/carbon/user) - ..() + . = ..() // Air only goes through the mask, so temporarily pause airflow if mask is getting adjusted. // Since the mask is NODROP, the only possible user is the wearer var/mob/living/carbon/carbon_target = loc