Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] [MODULAR] Anesthetic mask will give an error message when placed via mapping #638

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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" = (
Expand Down
1 change: 0 additions & 1 deletion _maps/shuttles/skyrat/emergency_skyrat.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
1 change: 0 additions & 1 deletion _maps/shuttles/skyrat/whiteship_blueshift.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -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" = (
Expand Down
53 changes: 38 additions & 15 deletions modular_skyrat/modules/medical/code/anesthetic_machine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -170,25 +174,44 @@
. = ..()
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 ..()

/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
Expand Down
Loading