Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 76 additions & 52 deletions code/__DEFINES/rendering/atom_hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,91 @@
// note: if you add more HUDs, even for non-human atoms, make sure to use unique numbers for the defines!
// /datum/atom_hud expects these to be unique
// these need to be strings in order to make them associative lists
#define HEALTH_HUD "1" // dead, alive, sick, health status
#define STATUS_HUD "2" // a simple line rounding the mob's number health
#define ID_HUD "3" // the job asigned to your ID
#define WANTED_HUD "4" // wanted, released, parroled, security status
#define IMPLOYAL_HUD "5" // loyality implant
#define IMPCHEM_HUD "6" // chemical implant
#define IMPTRACK_HUD "7" // tracking implant
#define DIAG_STAT_HUD "8" // Silicon/Mech/Circuit Status
#define DIAG_HUD "9" // Silicon health bar
#define DIAG_BATT_HUD "10"// Borg/Mech/Circutry power meter
#define DIAG_MECH_HUD "11"// Mech health bar
#define DIAG_BOT_HUD "12"// Bot HUDs
#define DIAG_CIRCUIT_HUD "13"// Circuit assembly health bar
#define DIAG_TRACK_HUD "14"// Mech/Silicon tracking beacon, Circutry long range icon
#define DIAG_AIRLOCK_HUD "15"//Airlock shock overlay
#define DIAG_PATH_HUD "16"//Bot path indicators
#define GLAND_HUD "17"//Gland indicators for abductors
#define SENTIENT_DISEASE_HUD "18"
#define AI_DETECT_HUD "19"

/// Dead, alive, sick, health status
#define HEALTH_HUD "1"
/// A simple line rounding the mob's number health
#define STATUS_HUD "2"
/// The job asigned to your ID
#define ID_HUD "3"
/// Wanted, released, parroled, security status
#define WANTED_HUD "4"
/// Loyality implant
#define IMPLOYAL_HUD "5"
/// Chemical implant
#define IMPCHEM_HUD "6"
/// Tracking implant
#define IMPTRACK_HUD "7"
/// Silicon/Mech/Circuit Status
#define DIAG_STAT_HUD "8"
/// Silicon health bar
#define DIAG_HUD "9"
/// Borg/Mech/Circutry power meter
#define DIAG_BATT_HUD "10"
/// Mech health bar
#define DIAG_MECH_HUD "11"
/// Bot HUDs
#define DIAG_BOT_HUD "12"
/// Circuit assembly health bar
#define DIAG_CIRCUIT_HUD "13"
/// Mech/Silicon tracking beacon, Circutry long range icon
#define DIAG_TRACK_HUD "14"
/// Airlock shock overlay
#define DIAG_AIRLOCK_HUD "15"
/// Bot path indicators
#define DIAG_PATH_HUD "16"
/// Gland indicators for abductors
#define GLAND_HUD "17"
#define SENTIENT_DISEASE_HUD "18"
#define AI_DETECT_HUD "19"
#define NANITE_HUD "20"
#define DIAG_NANITE_FULL_HUD "21"
#define RAD_HUD "22" //radation alerts for medical huds
#define DIAG_LAUNCHPAD_HUD "23" //Displays launchpads' targeting reticle
//for antag huds. these are used at the /mob level
#define ANTAG_HUD "24"
/// Radation alerts for medical huds
#define RAD_HUD "22"
/// Displays launchpads' targeting reticle
#define DIAG_LAUNCHPAD_HUD "23"
/// Displays damage numbers, NOT USED BY THE ATOM TAKING DAMAGE, BUT RATHER AN EFFECT CREATED ON THEIR LOCATION
#define DAMAGE_INDICATOR_HUD "24"
/// For antag huds. these are used at the /mob level
#define ANTAG_HUD "25"

//by default everything in the hud_list of an atom is an image
//a value in hud_list with one of these will change that behavior
#define HUD_LIST_LIST 1

//data HUD (medhud, sechud) defines
//Don't forget to update human/New() if you change these!
#define DATA_HUD_SECURITY_BASIC 1
#define DATA_HUD_SECURITY_ADVANCED 2
#define DATA_HUD_MEDICAL_BASIC 3
#define DATA_HUD_MEDICAL_ADVANCED 4
#define DATA_HUD_DIAGNOSTIC_BASIC 5
#define DATA_HUD_DIAGNOSTIC_ADVANCED 6
#define DATA_HUD_ABDUCTOR 7
#define DATA_HUD_SENTIENT_DISEASE 8
#define DATA_HUD_AI_DETECT 9
#define DATA_HUD_SECURITY_BASIC 1
#define DATA_HUD_SECURITY_ADVANCED 2
#define DATA_HUD_MEDICAL_BASIC 3
#define DATA_HUD_MEDICAL_ADVANCED 4
#define DATA_HUD_DIAGNOSTIC_BASIC 5
#define DATA_HUD_DIAGNOSTIC_ADVANCED 6
#define DATA_HUD_ABDUCTOR 7
#define DATA_HUD_DAMAGE_INDICATOR 8
#define DATA_HUD_SENTIENT_DISEASE 9
#define DATA_HUD_AI_DETECT 10

//antag HUD defines
#define ANTAG_HUD_CULT 10
#define ANTAG_HUD_REV 11
#define ANTAG_HUD_OPS 12
#define ANTAG_HUD_WIZ 13
#define ANTAG_HUD_SHADOW 14
#define ANTAG_HUD_TRAITOR 15
#define ANTAG_HUD_NINJA 16
#define ANTAG_HUD_CHANGELING 17
#define ANTAG_HUD_ABDUCTOR 18
#define ANTAG_HUD_DEVIL 19
#define ANTAG_HUD_SINTOUCHED 20
#define ANTAG_HUD_SOULLESS 21
#define ANTAG_HUD_CLOCKWORK 22
#define ANTAG_HUD_BROTHER 23
#define ANTAG_HUD_BLOODSUCKER 24
#define ANTAG_HUD_FUGITIVE 25
#define ANTAG_HUD_HERETIC 26
#define ANTAG_HUD_SPACECOP 27
#define ANTAG_HUD_GANGSTER 28
#define ANTAG_HUD_CULT 11
#define ANTAG_HUD_REV 12
#define ANTAG_HUD_OPS 13
#define ANTAG_HUD_WIZ 14
#define ANTAG_HUD_SHADOW 15
#define ANTAG_HUD_TRAITOR 16
#define ANTAG_HUD_NINJA 17
#define ANTAG_HUD_CHANGELING 18
#define ANTAG_HUD_ABDUCTOR 19
#define ANTAG_HUD_DEVIL 20
#define ANTAG_HUD_SINTOUCHED 21
#define ANTAG_HUD_SOULLESS 22
#define ANTAG_HUD_CLOCKWORK 23
#define ANTAG_HUD_BROTHER 24
#define ANTAG_HUD_BLOODSUCKER 25
#define ANTAG_HUD_FUGITIVE 26
#define ANTAG_HUD_HERETIC 27
#define ANTAG_HUD_SPACECOP 28
#define ANTAG_HUD_GANGSTER 29

#define ADD_HUD_TO_COOLDOWN 20 //cooldown for being shown the images for any particular data hud
/// Cooldown for being shown the images for any particular data hud
#define ADD_HUD_TO_COOLDOWN 20
1 change: 1 addition & 0 deletions code/_rendering/atom_huds/atom_hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ GLOBAL_LIST_INIT(huds, list(
DATA_HUD_DIAGNOSTIC_BASIC = new/datum/atom_hud/data/diagnostic/basic(),
DATA_HUD_DIAGNOSTIC_ADVANCED = new/datum/atom_hud/data/diagnostic/advanced(),
DATA_HUD_ABDUCTOR = new/datum/atom_hud/abductor(),
DATA_HUD_DAMAGE_INDICATOR = new/datum/atom_hud/data/damage_indicator(),
DATA_HUD_SENTIENT_DISEASE = new/datum/atom_hud/sentient_disease(),
DATA_HUD_AI_DETECT = new/datum/atom_hud/ai_detector(),
ANTAG_HUD_CULT = new/datum/atom_hud/antag(),
Expand Down
84 changes: 84 additions & 0 deletions code/_rendering/atom_huds/data_huds.dm
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
/datum/atom_hud/data/bot_path
hud_icons = list(DIAG_PATH_HUD)

/datum/atom_hud/data/damage_indicator
hud_icons = list(DAMAGE_INDICATOR_HUD)

/datum/atom_hud/abductor
hud_icons = list(GLAND_HUD)

Expand Down Expand Up @@ -521,3 +524,84 @@
holder.icon_state = "electrified"
else
holder.icon_state = ""

/*
Damage indicator handlers
*/

GLOBAL_LIST_EMPTY(tracked_damage_indicators)

/// Throws a damage indicator! This proc is non-blocking.
/mob/proc/throw_damage_indicator(damage_amount, damage_type)
set waitfor = FALSE

if(isturf(loc))
new /obj/effect/dummy/damage_indicator(loc, damage_amount, damage_type, WEAKREF(src))

/obj/effect/dummy/damage_indicator
hud_possible = list(DAMAGE_INDICATOR_HUD)
pixel_y = 16
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
var/damage_amount
var/damage_type
var/datum/weakref/damaged_atom

/obj/effect/dummy/damage_indicator/Initialize(mapload, amount, type, source)
. = ..()
if(!amount)
return INITIALIZE_HINT_QDEL

if(type && source)
LAZYADD(GLOB.tracked_damage_indicators, src)

prepare_huds()
var/datum/atom_hud/data/damage_indicator/dam_hud = GLOB.huds[DATA_HUD_DAMAGE_INDICATOR]
dam_hud.add_to_hud(src)

damage_amount = amount
damage_type = type
damaged_atom = source

for(var/obj/effect/dummy/damage_indicator/different_damage_indicator as anything in GLOB.tracked_damage_indicators)
if(different_damage_indicator == src)
continue
if(damage_type != different_damage_indicator.damage_type)
continue
var/datum/weakref/check_this = damaged_atom.resolve()
var/datum/weakref/check_other = different_damage_indicator.damaged_atom.resolve()
if(isnull(check_this) || isnull(check_other))
continue
if(check_this != check_other)
continue
if(!isnum(damage_amount) || !isnum(different_damage_indicator.damage_amount))
continue

damage_amount += different_damage_indicator.damage_amount
qdel(different_damage_indicator)

var/text_color = "<font "
switch(damage_type)
if(BRUTE)
text_color += "color = 'red'>"
if(BURN)
text_color += "color = '#FFA500'>"
if(TOX)
text_color += "color = 'green'>"
if(OXY)
text_color += "color = 'blue'>"
else
text_color += ">"

var/image/holder = hud_list[DAMAGE_INDICATOR_HUD]
holder.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA
holder.maptext = "<span class='damage_indicator'>[text_color][isnum(damage_amount) ? FLOOR(damage_amount, 0.01) : damage_amount]</font></span>"

animate(holder, pixel_x = rand(-16, 16), pixel_y = 16, time = 0.2 SECONDS, easing = SINE_EASING)
animate(pixel_y = -16, time = 0.5 SECONDS, easing = BOUNCE_EASING)
animate(alpha = 0, time = 1 SECONDS)
QDEL_IN(src, 1.7 SECONDS)

/obj/effect/dummy/damage_indicator/Destroy(force)
LAZYREMOVE(GLOB.tracked_damage_indicators, src)
remove_from_all_data_huds(src)
return ..()
2 changes: 1 addition & 1 deletion code/modules/clothing/glasses/_glasses.dm
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@
glass_colour_type = FALSE
clothing_flags = SCAN_REAGENTS
vision_flags = SEE_TURFS
var/list/hudlist = list(DATA_HUD_MEDICAL_ADVANCED, DATA_HUD_DIAGNOSTIC_ADVANCED, DATA_HUD_SECURITY_ADVANCED)
var/list/hudlist = list(DATA_HUD_MEDICAL_ADVANCED, DATA_HUD_DIAGNOSTIC_ADVANCED, DATA_HUD_SECURITY_ADVANCED, DATA_HUD_DAMAGE_INDICATOR)
var/xray = FALSE

/obj/item/clothing/glasses/debug/equipped(mob/user, slot)
Expand Down
5 changes: 3 additions & 2 deletions code/modules/mob/living/carbon/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,9 @@
else //Enough oxygen
failed_last_breath = 0
o2overloadtime = 0 //reset our counter for this too
if(health >= crit_threshold)
adjustOxyLoss(-5)
var/to_heal = clamp(-getOxyLoss(), -5, 0)
if((health >= crit_threshold) && to_heal)
adjustOxyLoss(to_heal)
oxygen_used = breath.get_moles(GAS_O2)
clear_alert("not_enough_oxy")
SEND_SIGNAL(src, COMSIG_CLEAR_MOOD_EVENT, "suffocation")
Expand Down
10 changes: 10 additions & 0 deletions code/modules/mob/living/damage_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
bruteloss = clamp((bruteloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2)
if(updating_health)
updatehealth()
throw_damage_indicator(amount, BRUTE)
return amount

/mob/living/proc/getOxyLoss()
Expand All @@ -159,6 +160,7 @@
oxyloss = clamp((oxyloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2)
if(updating_health)
updatehealth()
throw_damage_indicator(amount, OXY)
return amount

/mob/living/proc/setOxyLoss(amount, updating_health = TRUE, forced = FALSE)
Expand All @@ -167,6 +169,7 @@
oxyloss = amount
if(updating_health)
updatehealth()
throw_damage_indicator(amount, OXY)
return amount

//By default, returns toxins damage no matter what kind of tox damage the target is using.
Expand All @@ -190,11 +193,13 @@
if(HAS_TRAIT(src, TRAIT_ROBOTIC_ORGANISM))
affected_by = TOX_SYSCORRUPT
if(toxins_type != TOX_OMNI && toxins_type != affected_by)
throw_damage_indicator("IMMUNE", TOX)
return FALSE

toxloss = clamp((toxloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2)
if(updating_health)
updatehealth()
throw_damage_indicator(amount, TOX)
return amount

//Defaults to omni here because setToxLoss is used by very few things that usually want to set all types
Expand All @@ -206,11 +211,13 @@
if(HAS_TRAIT(src, TRAIT_ROBOTIC_ORGANISM))
affected_by = TOX_SYSCORRUPT
if(toxins_type != TOX_OMNI && toxins_type != affected_by)
throw_damage_indicator("IMMUNE", TOX)
return FALSE

toxloss = amount
if(updating_health)
updatehealth()
throw_damage_indicator(amount, TOX)
return amount

/mob/living/proc/getFireLoss()
Expand All @@ -223,6 +230,7 @@
fireloss = clamp((fireloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2)
if(updating_health)
updatehealth()
throw_damage_indicator(amount, BURN)
return amount

/mob/living/proc/getCloneLoss()
Expand All @@ -234,6 +242,7 @@
cloneloss = clamp((cloneloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2)
if(updating_health)
updatehealth()
throw_damage_indicator(amount, CLONE)
return amount

/mob/living/proc/setCloneLoss(amount, updating_health = TRUE, forced = FALSE)
Expand All @@ -242,6 +251,7 @@
cloneloss = amount
if(updating_health)
updatehealth()
throw_damage_indicator(amount, CLONE)
return amount

/mob/living/proc/adjustOrganLoss(slot, amount, maximum)
Expand Down
14 changes: 10 additions & 4 deletions code/modules/mob/living/silicon/pai/pai_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,22 @@
return amount

/mob/living/silicon/pai/adjustBruteLoss(amount, updating_health = TRUE, forced = FALSE, only_robotic = FALSE, only_organic = TRUE)
return take_holo_damage(amount)
. = take_holo_damage(amount)
if(.)
throw_damage_indicator(., BRUTE)

/mob/living/silicon/pai/adjustFireLoss(amount, updating_health = TRUE, forced = FALSE, only_robotic = FALSE, only_organic = TRUE)
return take_holo_damage(amount)
. = take_holo_damage(amount)
if(.)
throw_damage_indicator(., BURN)

/mob/living/silicon/pai/adjustStaminaLoss(amount, updating_health, forced = FALSE)
if(forced)
take_holo_damage(amount)
. = take_holo_damage(amount)
else
take_holo_damage(amount * 0.25)
. = take_holo_damage(amount * 0.25)
if(.)
throw_damage_indicator(., STAMINA)

/mob/living/silicon/pai/adjustOrganLoss(slot, amount, maximum = 500) //I kept this in, unlike tg
DefaultCombatKnockdown(amount * 0.2)
Expand Down
Loading