diff --git a/code/game/machinery/OpTable.dm b/code/game/machinery/OpTable.dm
index 7f74df70595..6a918a1e363 100644
--- a/code/game/machinery/OpTable.dm
+++ b/code/game/machinery/OpTable.dm
@@ -20,8 +20,8 @@
/obj/machinery/optable/Initialize(mapload)
. = ..()
- for(dir in list(NORTH,EAST,SOUTH,WEST))
- computer = locate(/obj/machinery/computer/operating, get_step(src, dir))
+ for(var/direction in list(NORTH,EAST,SOUTH,WEST))
+ computer = locate(/obj/machinery/computer/operating, get_step(src, direction))
if(computer)
computer.table = src
break
@@ -37,13 +37,6 @@
. = ..()
. += "Click-drag someone to the table to place them on top of the table."
-/obj/machinery/optable/attack_hulk(mob/living/carbon/human/user, does_attack_animation = FALSE)
- if(user.a_intent == INTENT_HARM)
- ..(user, TRUE)
- visible_message("[user] destroys [src]!")
- qdel(src)
- return TRUE
-
/obj/machinery/optable/CanPass(atom/movable/mover, turf/target, height=0)
if(height == 0)
return TRUE
@@ -57,75 +50,54 @@
return FALSE
/obj/machinery/optable/MouseDrop_T(atom/movable/O, mob/user)
- if(!ishuman(user) && !isrobot(user)) //Only Humanoids and Cyborgs can put things on this table
- return
- if(!check_table()) //If the Operating Table is occupied, you cannot put someone else on it
- return
- if(user.buckled || user.incapacitated()) //Is the person trying to use the table incapacitated or restrained?
- return
- if(!ismob(O) || !iscarbon(O)) //Only Mobs and Carbons can go on this table (no syptic patches please)
- return
- if(!user_buckle_mob(O, user, check_loc = FALSE))
- return
- take_patient(O, user)
- return TRUE
+ return take_patient(O, user)
-/**
- * Updates the `patient` var to be the mob occupying the table
- */
+/// Updates `patient` to be a carbon mob occupying the table, and returns it
/obj/machinery/optable/proc/update_patient()
- var/mob/living/carbon/C = locate(/mob/living/carbon, loc)
- if(C && IS_HORIZONTAL(C))
- patient = C
- else
- patient = null
+ if(patient in buckled_mobs)
+ return patient // Current patient is still here, no need to look
+
+ patient = null
+
+ if(length(buckled_mobs))
+ for(var/mob/living/carbon/C in buckled_mobs)
+ patient = C
+
+ if(length(injected_reagents))
+ to_chat(C, "You feel a series of tiny pricks!")
+
+ break
+
if(!no_icon_updates)
- if(C && C.pulse)
+ if(patient && patient.pulse)
icon_state = "table2-active"
else
icon_state = "table2-idle"
-/obj/machinery/optable/Crossed(atom/movable/AM, oldloc)
- . = ..()
- if(iscarbon(AM) && LAZYLEN(injected_reagents))
- to_chat(AM, "You feel a series of tiny pricks!")
+ return patient
+
+/obj/machinery/optable/proc/take_patient(mob/living/carbon/new_patient, mob/living/carbon/user)
+ if((!ishuman(user) && !isrobot(user)) || !istype(new_patient))
+ return
+ if(update_patient())
+ to_chat(usr, "The table is already occupied!")
+ return
+
+ // Attempt to settle the patient in
+ if(!user_buckle_mob(new_patient, user, check_loc = FALSE))
+ return // User is incapacitated, patient is already buckled to something else, etc.
+
+ update_patient()
+ return TRUE
/obj/machinery/optable/process()
update_patient()
- if(LAZYLEN(injected_reagents))
- for(var/mob/living/carbon/C in get_turf(src))
- if(C.stat == DEAD)
- continue
- var/datum/reagents/R = C.reagents
- for(var/chemical in injected_reagents)
- R.check_and_add(chemical,reagent_target_amount,inject_amount)
-/obj/machinery/optable/proc/take_patient(mob/living/carbon/new_patient, mob/living/carbon/user)
- if(new_patient == user)
- user.visible_message("[user] climbs on [src].","You climb on [src].")
- else
- visible_message("[new_patient] has been laid on [src] by [user].")
- if(new_patient.s_active) //Close the container opened
- new_patient.s_active.close(new_patient)
- add_fingerprint(user)
- update_patient()
-
-/obj/machinery/optable/verb/climb_on()
- set name = "Climb On Table"
- set category = "Object"
- set src in oview(1)
- if(usr.stat || !iscarbon(usr) || usr.restrained() || !check_table())
+ if(!length(injected_reagents) || !patient || patient.stat == DEAD)
return
- take_patient(usr, usr)
-/obj/machinery/optable/attackby(obj/item/I, mob/living/carbon/user, params)
- if(istype(I, /obj/item/grab))
- var/obj/item/grab/G = I
- if(iscarbon(G.affecting))
- take_patient(G.affecting, user)
- qdel(G)
- else
- return ..()
+ for(var/chemical in injected_reagents)
+ patient.reagents.check_and_add(chemical, reagent_target_amount, inject_amount)
/obj/machinery/optable/wrench_act(mob/user, obj/item/I)
. = TRUE
@@ -135,11 +107,3 @@
to_chat(user, "You deconstruct the table.")
new /obj/item/stack/sheet/plasteel(loc, 5)
qdel(src)
-
-/obj/machinery/optable/proc/check_table()
- update_patient()
- if(patient != null)
- to_chat(usr, "The table is already occupied!")
- return FALSE
- else
- return TRUE