Files
Bubberstation/code/modules/wiremod/components/atom/health_state.dm
SmArtKar 96b8a39008 Circuit health analyzer/state components now work on targets inside lockers (#85649)
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request

Makes circuit health analyzer/scanner components check distance to
target turf instead of target itself similarly to (most) other
components. (There are exceptions, presumably due to balancing?
concerns, but this feels like it should not have been one)

This doesn't feel intentional so I marked it as a fix, given that BCIs
stopping being able to scan their occupant is rather nonsensical

## Why It's Good For The Game

Currently BCIs with health analyzer components stop working if the owner
goes into a locker which is pretty stupid. Most components also only
check for turf distance, and while this could theoretically be used to
pinpoint someone's hiding spot there are far better ways to do so with
circuits

## Changelog

<!-- If your PR modifies aspects of the game that can be concretely
observed by players or admins you should add a changelog. If your change
does NOT meet this description, remove this section. Be sure to properly
mark your PRs to prevent unnecessary GBP loss. You can read up on GBP
and its effects on PRs in the tgstation guides for contributors. Please
note that maintainers freely reserve the right to remove and add tags
should they deem it appropriate. You can attempt to finagle the system
all you want, but it's best to shoot for clear communication right off
the bat. -->

🆑
fix: Circuit health analyzer/state components now work on targets inside
lockers
/🆑

<!-- Both 🆑's are required for the changelog to work! You can put
your name to the right of the first 🆑 if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
2024-08-14 12:37:52 +02:00

58 lines
1.7 KiB
Plaintext

/**
* # Compare Health State Component
*
* Returns true when state matches entity.
*/
/obj/item/circuit_component/compare/health_state
display_name = "Compare Health State"
desc = "A component that compares the health state of an organism, and returns true or false."
category = "Entity"
/// The input port
var/datum/port/input/input_port
/// Compare state option
var/datum/port/input/option/state_option
var/max_range = 5
/obj/item/circuit_component/compare/health_state/get_ui_notices()
. = ..()
. += create_ui_notice("Maximum Range: [max_range] tiles", "orange", "info")
/obj/item/circuit_component/compare/health_state/populate_options()
input_port = add_input_port("Organism", PORT_TYPE_ATOM)
var/static/component_options = list(
"Alive",
"Asleep",
"Critical",
"Unconscious",
"Deceased",
)
state_option = add_option_port("Comparison Option", component_options)
/obj/item/circuit_component/compare/health_state/do_comparisons()
var/mob/living/organism = input_port.value
var/turf/current_turf = get_location()
var/turf/target_location = get_turf(organism)
if(!istype(organism) || current_turf.z != target_location.z || get_dist(current_turf, target_location) > max_range)
return FALSE
var/current_option = state_option.value
var/state = organism.stat
switch(current_option)
if("Alive")
return state != DEAD
if("Asleep")
return !!organism.IsSleeping() && !organism.IsUnconscious()
if("Critical")
return state == SOFT_CRIT || state == HARD_CRIT
if("Unconscious")
return state == UNCONSCIOUS || state == HARD_CRIT || !!organism.IsUnconscious()
if("Deceased")
return state == DEAD
//Unknown state, something fucked up really bad - just return false
return FALSE