mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-13 17:14:47 +01:00
21b4095dfd
Upstream 04/17/2026 fixes https://github.com/Bubberstation/Bubberstation/issues/5549 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com> Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com> Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com> Co-authored-by: rageguy505 <54517726+rageguy505@users.noreply.github.com> Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Co-authored-by: Aliceee2ch <160794176+Aliceee2ch@users.noreply.github.com> Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com> Co-authored-by: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com> Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com> Co-authored-by: Maxipat <108554989+Maxipat112@users.noreply.github.com> Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: SimplyLogan <47579821+loganuk@users.noreply.github.com> Co-authored-by: loganuk <fakeemail123@aol.com> Co-authored-by: Leland Kemble <70413276+lelandkemble@users.noreply.github.com> Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com> Co-authored-by: Roxy <75404941+TealSeer@users.noreply.github.com> Co-authored-by: Lucy <lucy@absolucy.moe> Co-authored-by: siliconOpossum <138069572+siliconOpossum@users.noreply.github.com> Co-authored-by: Isratosh <Isratosh@hotmail.com> Co-authored-by: TheRyeGuyWhoWillNowDie <70169560+TheRyeGuyWhoWillNowDie@users.noreply.github.com> Co-authored-by: Neocloudy <88008002+Neocloudy@users.noreply.github.com> Co-authored-by: Alexander V. <volas@ya.ru> Co-authored-by: ElGitificador <168473461+ElGitificador@users.noreply.github.com> Co-authored-by: Twaticus <46540570+Twaticus@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> Co-authored-by: Cameron Lennox <killer65311@gmail.com> Co-authored-by: Tim <timothymtorres@gmail.com> Co-authored-by: Iamgoofball <iamgoofball@gmail.com> Co-authored-by: Layzu666 <121319428+Layzu666@users.noreply.github.com> Co-authored-by: Arturlang <24881678+Arturlang@users.noreply.github.com> Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com> Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com> Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Co-authored-by: John F. Kennedy <54908920+MacaroniCritter@users.noreply.github.com> Co-authored-by: Cursor <102828457+theselfish@users.noreply.github.com> Co-authored-by: Josh <josh.adam.powell@gmail.com> Co-authored-by: Josh Powell <josh.powell@softwire.com> Co-authored-by: Yobrocharlie <Charliemiller5617@gmail.com> Co-authored-by: Hardly3D <66234359+Hardly3D@users.noreply.github.com> Co-authored-by: shayoki <96078776+shayoki@users.noreply.github.com> Co-authored-by: LT3 <83487515+lessthnthree@users.noreply.github.com>
118 lines
3.1 KiB
Plaintext
118 lines
3.1 KiB
Plaintext
/obj/item/assembly/health
|
|
name = "health sensor"
|
|
desc = "Used for scanning and monitoring health."
|
|
icon_state = "health"
|
|
custom_materials = list(/datum/material/iron=SMALL_MATERIAL_AMOUNT*8, /datum/material/glass=SMALL_MATERIAL_AMOUNT * 2)
|
|
assembly_behavior = ASSEMBLY_TOGGLEABLE_INPUT
|
|
maptext_width = 64
|
|
maptext_y = 24
|
|
|
|
var/scanning = FALSE
|
|
var/health_scan
|
|
var/health_target = HEALTH_THRESHOLD_CRIT
|
|
|
|
/obj/item/assembly/health/examine(mob/user)
|
|
. = ..()
|
|
. += "[src.scanning ? "The sensor is on and you can see [health_scan] displayed on the screen" : "The sensor is off"]."
|
|
|
|
/obj/item/assembly/health/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change)
|
|
. = ..()
|
|
if(isliving(old_loc))
|
|
UnregisterSignal(old_loc, COMSIG_LIVING_HEALTH_UPDATE)
|
|
maptext = null
|
|
if(isliving(loc))
|
|
RegisterSignal(loc, COMSIG_LIVING_HEALTH_UPDATE, PROC_REF(on_health_changed))
|
|
on_health_changed(loc)
|
|
|
|
/obj/item/assembly/health/activate()
|
|
if(!..())
|
|
return FALSE//Cooldown check
|
|
toggle_scan()
|
|
return TRUE
|
|
|
|
/obj/item/assembly/health/toggle_secure()
|
|
secured = !secured
|
|
if(secured && scanning)
|
|
START_PROCESSING(SSobj, src)
|
|
else
|
|
scanning = FALSE
|
|
STOP_PROCESSING(SSobj, src)
|
|
update_appearance()
|
|
return secured
|
|
|
|
/obj/item/assembly/health/process()
|
|
//not ready yet
|
|
if(!scanning || !secured)
|
|
return
|
|
|
|
//look for a mob in either our location or in the connected holder
|
|
var/atom/object = src
|
|
if(connected?.holder)
|
|
object = connected.holder
|
|
while(!ismob(object))
|
|
object = object.loc
|
|
if(isnull(object)) //we went too far
|
|
return
|
|
|
|
//only do the pulse if we are within alarm thresholds
|
|
var/mob/living/target_mob = object
|
|
health_scan = target_mob.health
|
|
if(health_scan > health_target)
|
|
return
|
|
|
|
//do the pulse & the scan
|
|
pulse()
|
|
audible_message(span_infoplain("[icon2html(src, hearers(src))] *beep* *beep* *beep*"))
|
|
playsound(src, 'sound/machines/beep/triple_beep.ogg', ASSEMBLY_BEEP_VOLUME, TRUE)
|
|
toggle_scan()
|
|
|
|
/obj/item/assembly/health/proc/toggle_scan()
|
|
if(!secured)
|
|
return 0
|
|
scanning = !scanning
|
|
if(scanning)
|
|
START_PROCESSING(SSobj, src)
|
|
else
|
|
STOP_PROCESSING(SSobj, src)
|
|
return
|
|
|
|
/obj/item/assembly/health/proc/toggle_target()
|
|
if(health_target == HEALTH_THRESHOLD_CRIT)
|
|
health_target = HEALTH_THRESHOLD_DEAD
|
|
else
|
|
health_target = HEALTH_THRESHOLD_CRIT
|
|
return
|
|
|
|
/obj/item/assembly/health/proc/on_health_changed(mob/living/source)
|
|
SIGNAL_HANDLER
|
|
maptext = MAPTEXT("HP: [round((source.health / source.maxHealth) * 100)]%")
|
|
|
|
/obj/item/assembly/health/ui_status(mob/user, datum/ui_state/state)
|
|
return is_secured(user) ? ..() : UI_CLOSE
|
|
|
|
/obj/item/assembly/health/ui_interact(mob/user, datum/tgui/ui)
|
|
ui = SStgui.try_update_ui(user, src, ui)
|
|
if(!ui)
|
|
ui = new(user, src, "HealthSensor", name)
|
|
ui.open()
|
|
|
|
/obj/item/assembly/health/ui_data(mob/user)
|
|
var/list/data = list()
|
|
data["health"] = health_scan
|
|
data["scanning"] = scanning
|
|
data["target"] = health_target
|
|
return data
|
|
|
|
/obj/item/assembly/health/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
|
. = ..()
|
|
if(.)
|
|
return .
|
|
|
|
switch(action)
|
|
if("scanning")
|
|
toggle_scan()
|
|
return TRUE
|
|
if("target")
|
|
toggle_target()
|
|
return TRUE
|