diff --git a/code/game/objects/items/devices/autopsy.dm b/code/game/objects/items/devices/autopsy.dm
index 95103656f61..d609471ff33 100644
--- a/code/game/objects/items/devices/autopsy.dm
+++ b/code/game/objects/items/devices/autopsy.dm
@@ -1,3 +1,5 @@
+#define PRINT_TIMER 5 SECONDS
+
/obj/item/autopsy_scanner
name = "autopsy scanner"
desc = "Extracts information on wounds."
@@ -13,6 +15,8 @@
var/target_UID = null
var/timeofdeath = null
var/target_rank = null
+ STATIC_COOLDOWN_DECLARE(print_cooldown)
+ new_attack_chain = TRUE
/obj/item/autopsy_scanner/Destroy()
QDEL_LIST_ASSOC_VAL(wdata)
@@ -72,23 +76,39 @@
if(Adjacent(user))
. += "You can use a pen on it to quickly write a coroner's report."
-/obj/item/autopsy_scanner/attackby__legacy__attackchain(obj/item/P, mob/user)
- if(!is_pen(P))
+/obj/item/autopsy_scanner/item_interaction(mob/living/user, obj/item/used, list/modifiers)
+ if(!is_pen(used))
return ..()
+ if(!COOLDOWN_FINISHED(src, print_cooldown))
+ to_chat(user, "[src] is busy, try again in a few seconds.")
+ return ITEM_INTERACT_COMPLETE
+
var/dead_name = tgui_input_text(user, "Insert name of deceased individual", default = target_name, title = "Coroner's Report", max_length = 60)
var/rank = tgui_input_text(user, "Insert rank of deceased individual", default = target_rank, title = "Coroner's Report", max_length = 60)
var/tod = tgui_input_text(user, "Insert time of death", default = station_time_timestamp("hh:mm", timeofdeath), title = "Coroner's Report", max_length = 60)
var/cause = tgui_input_text(user, "Insert cause of death", title = "Coroner's Report", max_length = 60)
var/chems = tgui_input_text(user, "Insert any chemical traces", multiline = TRUE, title = "Coroner's Report")
var/notes = tgui_input_text(user, "Insert any relevant notes", multiline = TRUE, title = "Coroner's Report")
+
+ COOLDOWN_START(src, print_cooldown, PRINT_TIMER)
var/obj/item/paper/R = new(user.loc)
R.name = "Official Coroner's Report - [dead_name]"
R.info = "
[station_name()] - Coroner's Report
Name of Deceased: [dead_name]
Rank of Deceased: [rank]
Time of Death: [tod]
Cause of Death: [cause]
Trace Chemicals: [chems]
Additional Coroner's Notes: [notes]
Coroner's Signature: "
playsound(loc, 'sound/goonstation/machines/printer_thermal.ogg', 50, TRUE)
user.put_in_hands(R)
-/obj/item/autopsy_scanner/attack_self__legacy__attackchain(mob/user)
+ return ITEM_INTERACT_COMPLETE
+
+/obj/item/autopsy_scanner/activate_self(mob/user)
+ if(..())
+ return FINISH_ATTACK
+
+ if(!COOLDOWN_FINISHED(src, print_cooldown))
+ to_chat(user, "[src] is busy, try again in a few seconds.")
+ return
+
+ COOLDOWN_START(src, print_cooldown, PRINT_TIMER)
var/scan_data = ""
if(timeofdeath)
@@ -156,29 +176,32 @@
user.put_in_hands(P)
-/obj/item/autopsy_scanner/attack__legacy__attackchain(mob/living/carbon/human/M, mob/living/carbon/user)
- if(!istype(M))
- return
+/obj/item/autopsy_scanner/interact_with_atom(mob/living/carbon/human/target, mob/living/user, list/modifiers)
+ if(!istype(target))
+ return ..()
- if(!on_operable_surface(M))
- return
+ user.changeNext_move(CLICK_CD_MELEE) // Need this so we don't speedrun autopsies
+ if(!on_operable_surface(target))
+ return ITEM_INTERACT_COMPLETE
- if(target_UID != M.UID())
- target_UID = M.UID()
- target_name = M.name
- target_rank = M.get_assignment(if_no_id = "Unknown", if_no_job = null)
+ if(target_UID != target.UID())
+ target_UID = target.UID()
+ target_name = target.name
+ target_rank = target.get_assignment(if_no_id = "Unknown", if_no_job = null)
wdata.Cut()
chemtraces.Cut()
timeofdeath = null
to_chat(user, "A new patient has been registered. Purging data for previous patient.")
- timeofdeath = M.timeofdeath
+ timeofdeath = target.timeofdeath
- var/obj/item/organ/external/S = M.get_organ(user.zone_selected)
+ var/obj/item/organ/external/S = target.get_organ(user.zone_selected)
if(!S)
to_chat(user, "You can't scan this body part.")
- return
- M.visible_message("[user] scans the wounds on [M]'s [S.name] with [src]")
+ return ITEM_INTERACT_COMPLETE
+ target.visible_message("[user] scans the wounds on [target]'s [S.name] with [src]")
add_data(S)
- return 1
+ return ITEM_INTERACT_COMPLETE
+
+#undef PRINT_TIMER