Skip to content

Commit

Permalink
Vitals Scanner Fixes (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMelbert authored Feb 3, 2024
1 parent ab87a76 commit 59f6a60
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
11 changes: 8 additions & 3 deletions code/game/objects/items/devices/scanners/health_analyzer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@
else
return(jointext(render_list, ""))

/proc/chemscan(mob/living/user, mob/living/target)
/proc/chemscan(mob/living/user, mob/living/target, tochat = TRUE) // NON-MODULE CHANGE
if(user.incapacitated())
return

Expand Down Expand Up @@ -461,8 +461,13 @@
render_list += "<span class='alert ml-1'>Subject is extremely allergic to the following chemicals:</span>\n"
render_list += "<span class='alert ml-2'>[allergies]</span>\n"

// we handled the last <br> so we don't need handholding
to_chat(user, examine_block(jointext(render_list, "")), trailing_newline = FALSE, type = MESSAGE_TYPE_INFO)
// NON-MODULE CHANGE
if(tochat)
// we handled the last <br> so we don't need handholding
to_chat(user, examine_block(jointext(render_list, "")), trailing_newline = FALSE, type = MESSAGE_TYPE_INFO)
else
return jointext(render_list, "")
// NON-MODULE CHANGE END

/obj/item/healthanalyzer/AltClick(mob/user)
..()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
)
AddElement(/datum/element/connect_loc, loc_connections)
update_appearance(UPDATE_OVERLAYS)
register_context()

/obj/machinery/vital_floor_scanner/examine(mob/user)
. = ..()
Expand All @@ -62,6 +63,11 @@
Your results will be displayed on nearby vitals monitors. \
<b>Examine</b> the monitor for a detailed breakdown of your vitals.")

/obj/machinery/vital_floor_scanner/add_context(atom/source, list/context, obj/item/held_item, mob/user)
if(held_item?.tool_behaviour == TOOL_SCREWDRIVER)
context[SCREENTIP_CONTEXT_LMB] = "Deconstruct"
return CONTEXTUAL_SCREENTIP_SET

/obj/machinery/vital_floor_scanner/update_overlays()
. = ..()
if(!is_operational)
Expand Down Expand Up @@ -108,9 +114,9 @@
reader.set_patient(occupant)
return

/obj/machinery/vital_floor_scanner/proc/disable_vitals_nearby()
/obj/machinery/vital_floor_scanner/proc/disable_vitals_nearby(mob/leaving = occupant)
for(var/obj/machinery/computer/vitals_reader/reader in range(LINK_RANGE, src))
if(reader.patient == occupant)
if(reader.active && reader.patient == leaving)
reader.toggle_active()
return

Expand Down Expand Up @@ -146,7 +152,7 @@
scan_effect()

else if(!isnull(old_occupant))
disable_vitals_nearby()
disable_vitals_nearby(old_occupant)

/obj/machinery/vital_floor_scanner/proc/scan_effect()
var/image/scan_effect = image(
Expand All @@ -161,5 +167,13 @@
SET_PLANE_EXPLICIT(scan_effect, occupant.plane, occupant)
occupant.flick_overlay_view(scan_effect, SCAN_EFFECT_DURATION)

/obj/machinery/vital_floor_scanner/screwdriver_act(mob/living/user, obj/item/tool)
balloon_alert(user, "deconstructing...")
if(!tool.use_tool(src, user, 4 SECONDS, volume = 50))
return ITEM_INTERACT_BLOCKING

deconstruct(TRUE)
return ITEM_INTERACT_SUCCESS

#undef LINK_RANGE
#undef SCAN_EFFECT_DURATION
15 changes: 12 additions & 3 deletions maplestation_modules/code/game/objects/structures/vital_reader.dm
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@

/// Whether we perform an advanced scan on examine or not
var/advanced = FALSE
/// If TRUE, also append a chemical scan to the readout
var/chemscan = TRUE
/// Typepath to spawn when deconstructed
var/frame = /obj/item/wallframe/status_display/vitals
/// How many attempts at scanning for a patient do we try before we turn ourself off
var/max_scan_attempts = 6
/// Whether we are on or off
VAR_FINAL/active = FALSE
/// Reference to the mob that is being tracked / scanned
Expand Down Expand Up @@ -107,6 +111,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/computer/vitals_reader/advanced, 32)
It has no button to toggle it manually."
interaction_flags_atom = NONE
interaction_flags_machine = NONE
max_scan_attempts = 1

MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/computer/vitals_reader/no_hand, 32)

Expand Down Expand Up @@ -161,7 +166,8 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/computer/vitals_reader/no_hand, 32)
else if(HAS_TRAIT(user, TRAIT_DUMB) || !user.can_read(src, reading_check_flags = READING_CHECK_LITERACY, silent = TRUE))
. += span_warning("You try to comprehend the display, but it's too complex for you to understand.")
else
. += healthscan(user, patient, advanced = advanced, tochat = FALSE)
. += healthscan(user, patient, mode = /*SCANNER_CONDENSED*/FALSE, advanced = advanced, tochat = FALSE)
. += chemscan(user, patient, tochat = FALSE)

/obj/machinery/computer/vitals_reader/add_context(atom/source, list/context, obj/item/held_item, mob/user)
if(isnull(held_item) || (held_item.item_flags & SURGICAL_TOOL))
Expand All @@ -176,7 +182,10 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/computer/vitals_reader/no_hand, 32)
/obj/machinery/computer/vitals_reader/AIShiftClick(mob/user)
// Lets AIs perform healthscans on people indirectly (they can't examine)
if(is_operational && !isnull(patient))
healthscan(user, patient, advanced = advanced)
var/entire_printout = ""
entire_printout += healthscan(user, patient, mode = /*SCANNER_CONDENSED*/FALSE, advanced = advanced, tochat = FALSE)
entire_printout += chemscan(user, patient, tochat = FALSE)
to_chat(user, examine_block(entire_printout), trailing_newline = FALSE, type = MESSAGE_TYPE_INFO)

#define LOWER_BAR_OFFSET -3

Expand Down Expand Up @@ -405,7 +414,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/computer/vitals_reader/no_hand, 32)
set_patient(patient)
return

if(scan_attempts > 12)
if(scan_attempts > max_scan_attempts)
toggle_active()
return

Expand Down

0 comments on commit 59f6a60

Please sign in to comment.