Skip to content

Commit

Permalink
Screen warnings for fire/hunger/temp/O2/etc use throw_alert (#16443)
Browse files Browse the repository at this point in the history
  • Loading branch information
Neocloudy authored Aug 18, 2024
1 parent 24158e0 commit c185e67
Show file tree
Hide file tree
Showing 18 changed files with 207 additions and 325 deletions.
11 changes: 11 additions & 0 deletions code/__DEFINES/alerts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,14 @@

/** Mech related */
#define ALERT_MECH_DAMAGE "mech_damage"

///Actively suffocating
#define ALERT_NOT_ENOUGH_OXYGEN "not_enough_oxy"
/// On fire.
#define ALERT_FIRE "fire"
/// Holds temperature related alerts.
#define ALERT_TEMPERATURE "temp"
/// Holds pressure related alerts.
#define ALERT_PRESSURE "pressure"
/// Holds food related alerts.
#define ALERT_NUTRITION "nutrition"
8 changes: 0 additions & 8 deletions code/__DEFINES/hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,7 @@
#define ui_alert4 "EAST-1:28,CENTER+2:21"
#define ui_alert5 "EAST-1:28,CENTER+1:19"

//Upper-middle right (damage indicators)
#define ui_toxin "EAST-1:28,13:27"
#define ui_fire "EAST-1:28,12:25"
#define ui_oxygen "EAST-1:28,11:23"
#define ui_pressure "EAST-1:28,10:21"

//Middle right (status indicators)
#define ui_nutrition "EAST-1:28,5:11"
#define ui_temp "EAST-1:28,6:13"
#define UI_STAMINA "EAST-1:28,CENTER-2:13"
#define ui_health "EAST-1:28,CENTER-1:15"
#define ui_ammo1 "EAST-1:28,CENTER+1:25"
Expand Down
79 changes: 63 additions & 16 deletions code/_onclick/hud/alerts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ Override makes it so the alert is not replaced until cleared by a clear_alert wi
alerts[category] = thealert
if(client && hud_used)
hud_used.reorganize_alerts()
thealert.transform = matrix(32, 6, MATRIX_TRANSLATE)
animate(thealert, transform = matrix(), time = 2.5, easing = CUBIC_EASING)
thealert.transform = matrix(32, 0, MATRIX_TRANSLATE)
animate(thealert, transform = matrix(), time = 1 SECONDS, easing = ELASTIC_EASING)

if(thealert.timeout)
addtimer(CALLBACK(src, PROC_REF(alert_timeout), thealert, category), thealert.timeout)
Expand All @@ -87,6 +87,13 @@ Override makes it so the alert is not replaced until cleared by a clear_alert wi
client.screen -= alert
qdel(alert)

/atom/movable/screen/alert/MouseEntered(location,control,params)
if(!QDELETED(src))
openToolTip(usr, src, params, title = name, content = desc)

/atom/movable/screen/alert/MouseExited()
closeToolTip(usr)

/atom/movable/screen/alert
icon = 'icons/mob/screen_alert.dmi'
icon_state = "default"
Expand All @@ -99,18 +106,6 @@ Override makes it so the alert is not replaced until cleared by a clear_alert wi
var/override_alerts = FALSE //If it is overriding other alerts of the same type
var/mob/owner //Alert owner


/atom/movable/screen/alert/fire
name = "On Fire"
desc = "You're on fire. Stop, drop and roll to put the fire out or move to a vacuum area."
icon_state = "fire"

/atom/movable/screen/alert/fire/Click()
var/mob/living/L = usr
if(!istype(L) || usr != owner)
return
L.resist()

//GHOSTS
//TODO: expand this system to replace the pollCandidates/CheckAntagonist/"choose quickly"/etc Yes/No messages
/atom/movable/screen/alert/notify_action
Expand Down Expand Up @@ -212,7 +207,7 @@ Override makes it so the alert is not replaced until cleared by a clear_alert wi
return
var/paramslist = params2list(params)
if(paramslist["shift"]) // screen objects don't do the normal Click() stuff so we'll cheat
to_chat(usr, span_boldnotice("[name]</span> - <span class='info'>[desc]"))
to_chat(usr, examine_block("<big>[span_boldnotice(name)]</big>\n[span_info(desc)]"))
return
if(master)
return usr.client.Click(master, location, control, params)
Expand All @@ -222,7 +217,6 @@ Override makes it so the alert is not replaced until cleared by a clear_alert wi
owner = null
return ..()


//MECHS
/atom/movable/screen/alert/nocell
name = "Missing Power Cell"
Expand All @@ -243,3 +237,56 @@ Override makes it so the alert is not replaced until cleared by a clear_alert wi
name = "Mech Damaged"
desc = "Mech integrity is low."
icon_state = "low_mech_integrity"

// HUMAN WARNINGS
/atom/movable/screen/alert/fire
name = "On Fire"
desc = "You're on fire. Stop, drop and roll to put the fire out, or use a fire extinguisher."
icon_state = "fire"

/atom/movable/screen/alert/fire/Click()
. = ..()
var/mob/living/L = usr
if(!istype(L) || usr != owner)
return
L.resist()

/atom/movable/screen/alert/not_enough_oxy
name = "Choking"
desc = "You're not getting enough O2. This can be from internal damage or critical condition. Find a solution before you pass out or even die!"
icon_state = ALERT_NOT_ENOUGH_OXYGEN

/atom/movable/screen/alert/hot
name = "Too Hot"
desc = "You're flaming hot! Try to extinguish yourself, and then take Kelotane to cool you down!"
icon_state = "hot"

/atom/movable/screen/alert/cold
name = "Too Cold"
desc = "You're freezing cold! Get somewhere warmer, and layer up next time you go somewhere cold!"
icon_state = "cold"

/atom/movable/screen/alert/lowpressure
name = "Low Pressure"
desc = "The air around you is hazardously thin! Get inside as soon as possible!"
icon_state = "lowpressure"

/atom/movable/screen/alert/highpressure
name = "High Pressure"
desc = "The air around you is hazardously thick."
icon_state = "highpressure"

/atom/movable/screen/alert/hungry
name = "Hungry"
desc = "You could use a bite to eat. Movement speed reduced."
icon_state = "hungry"

/atom/movable/screen/alert/starving
name = "Starving"
desc = "You could eat a horse right now. Movement speed significantly reduced."
icon_state = "starving"

/atom/movable/screen/alert/stuffed
name = "Stuffed"
desc = "You had a bit too much to eat. Work out to lose the extra nutrition. Movement speed reduced."
icon_state = "stuffed"
10 changes: 0 additions & 10 deletions code/_onclick/hud/hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,8 @@
var/atom/movable/screen/pull_icon
var/atom/movable/screen/throw_icon
var/atom/movable/screen/rest_icon
var/atom/movable/screen/oxygen_icon
var/atom/movable/screen/pressure_icon
var/atom/movable/screen/toxin_icon
var/atom/movable/screen/healths
var/atom/movable/screen/stamina_hud/staminas
var/atom/movable/screen/fire_icon
var/atom/movable/screen/bodytemp_icon

var/atom/movable/screen/gun_setting_icon
var/atom/movable/screen/gun_item_use_icon
Expand Down Expand Up @@ -135,13 +130,8 @@
zone_sel = null
pull_icon = null
throw_icon = null
oxygen_icon = null
pressure_icon = null
toxin_icon = null
healths = null
staminas = null
fire_icon = null
bodytemp_icon = null

gun_setting_icon = null
gun_item_use_icon = null
Expand Down
21 changes: 0 additions & 21 deletions code/_onclick/hud/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -139,34 +139,13 @@
hotkeybuttons += pull_icon

if(hud_data.has_warnings)
oxygen_icon = new /atom/movable/screen/oxygen(null, src)
infodisplay += oxygen_icon

toxin_icon = new /atom/movable/screen/toxin(null, src)
infodisplay += toxin_icon

fire_icon = new /atom/movable/screen/fire(null, src)
infodisplay += fire_icon

healths = new /atom/movable/screen/healths(null, src)
infodisplay += healths

staminas = new /atom/movable/screen/stamina_hud(null, src)
infodisplay += staminas

if(hud_data.has_pressure)
pressure_icon = new /atom/movable/screen/pressure(null, src)
infodisplay += pressure_icon

if(hud_data.has_bodytemp)
bodytemp_icon = new /atom/movable/screen/bodytemp(null, src)
infodisplay += bodytemp_icon


if(hud_data.has_nutrition)
nutrition_icon = new /atom/movable/screen/nutrition(null, src)
infodisplay += nutrition_icon

rest_icon = new /atom/movable/screen/rest(null, src)
rest_icon.icon = ui_style
rest_icon.color = ui_color
Expand Down
139 changes: 0 additions & 139 deletions code/_onclick/hud/screen_objects/screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -583,145 +583,6 @@
/atom/movable/screen/drop/Click()
usr.drop_item_v()

/atom/movable/screen/bodytemp
name = "body temperature"
icon_state = "temp0"
screen_loc = ui_temp

/atom/movable/screen/bodytemp/update_icon_state()
. = ..()
if(!ishuman(hud?.mymob))
return
var/mob/living/carbon/human/human_mymob = hud.mymob
if(!human_mymob.species)
switch(human_mymob.bodytemperature) //310.055 optimal body temp
if(370 to INFINITY)
icon_state = "temp4"
if(350 to 370)
icon_state = "temp3"
if(335 to 350)
icon_state = "temp2"
if(320 to 335)
icon_state = "temp1"
if(300 to 320)
icon_state = "temp0"
if(295 to 300)
icon_state = "temp-1"
if(280 to 295)
icon_state = "temp-2"
if(260 to 280)
icon_state = "temp-3"
else
icon_state = "temp-4"
return

var/temp_step
if(human_mymob.bodytemperature >= human_mymob.species.body_temperature)
temp_step = (human_mymob.species.heat_level_1 - human_mymob.species.body_temperature) / 4

if(human_mymob.bodytemperature >= human_mymob.species.heat_level_1)
icon_state = "temp4"
else if(human_mymob.bodytemperature >= human_mymob.species.body_temperature + temp_step * 3)
icon_state = "temp3"
else if(human_mymob.bodytemperature >= human_mymob.species.body_temperature + temp_step * 2)
icon_state = "temp2"
else if(human_mymob.bodytemperature >= human_mymob.species.body_temperature + temp_step * 1)
icon_state = "temp1"
else
icon_state = "temp0"
return

if(human_mymob.bodytemperature < human_mymob.species.body_temperature)
temp_step = (human_mymob.species.body_temperature - human_mymob.species.cold_level_1)/4

if(human_mymob.bodytemperature <= human_mymob.species.cold_level_1)
icon_state = "temp-4"
else if(human_mymob.bodytemperature <= human_mymob.species.body_temperature - temp_step * 3)
icon_state = "temp-3"
else if(human_mymob.bodytemperature <= human_mymob.species.body_temperature - temp_step * 2)
icon_state = "temp-2"
else if(human_mymob.bodytemperature <= human_mymob.species.body_temperature - temp_step * 1)
icon_state = "temp-1"
else
icon_state = "temp0"

/atom/movable/screen/oxygen
name = "oxygen"
icon_state = "oxy0"
screen_loc = ui_oxygen

/atom/movable/screen/oxygen/update_icon_state()
. = ..()
if(!ishuman(hud?.mymob))
return
var/mob/living/carbon/human/human_mymob = hud.mymob
if(human_mymob.hal_screwyhud == 3 || human_mymob.oxygen_alert)
icon_state = "oxy1"
else
icon_state = "oxy0"

/atom/movable/screen/toxin
name = "toxin"
icon_state = "tox0"
screen_loc = ui_toxin

/atom/movable/screen/toxin/update_icon_state()
. = ..()
if(!ishuman(hud?.mymob))
return
var/mob/living/carbon/human/human_mymob = hud.mymob
if(human_mymob.hal_screwyhud == 4)
icon_state = "tox1"
else
icon_state = "tox0"

/atom/movable/screen/pressure
name = "pressure"
icon_state = "pressure0"
screen_loc = ui_pressure

/atom/movable/screen/pressure/update_icon_state()
. = ..()
if(!ishuman(hud?.mymob))
return
var/mob/living/carbon/human/human_mymob = hud.mymob
icon_state = "pressure[human_mymob.pressure_alert]"

/atom/movable/screen/nutrition
name = "nutrition"
icon_state = "nutrition1"
screen_loc = ui_nutrition

/atom/movable/screen/nutrition/update_icon_state()
. = ..()
if(!ishuman(hud?.mymob))
return
var/mob/living/carbon/human/human_mymob = hud.mymob
switch(human_mymob.nutrition)
if(NUTRITION_OVERFED to INFINITY)
icon_state = "nutrition0"
if(NUTRITION_HUNGRY to NUTRITION_OVERFED) //Not-hungry.
icon_state = "nutrition1" //Empty icon.
if(NUTRITION_STARVING to NUTRITION_HUNGRY)
icon_state = "nutrition3"
else
icon_state = "nutrition4"

/atom/movable/screen/fire
name = "body temperature"
icon_state = "fire0"
screen_loc = ui_fire

/atom/movable/screen/fire/update_icon_state()
. = ..()
if(!ishuman(hud?.mymob))
return
var/mob/living/carbon/human/human_mymob = hud.mymob
if(human_mymob.fire_alert)
icon_state = "fire[human_mymob.fire_alert]" //fire_alert is either 0 if no alert, 1 for cold and 2 for heat.
else
icon_state = "fire0"

/atom/movable/screen/toggle_inv
name = "toggle"
icon = 'icons/mob/screen/midnight.dmi'
Expand Down
8 changes: 3 additions & 5 deletions code/modules/mob/living/carbon/carbon_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
var/analgesic = 0
///Whether or not the mob is handcuffed
var/obj/item/restraints/handcuffs/handcuffed
///Tracks whether we can breath right now. Used for a hud icon and for message generation.
var/oxygen_alert = FALSE
var/phoron_alert = FALSE
var/fire_alert = FALSE
var/pressure_alert = FALSE

///Tracks whether our most recent breath has failed, for messages and HUD feedback.
var/breath_failing = FALSE

var/list/internal_organs = list()
///Overall drunkenness - check handle_status_effects() in life.dm for effects
Expand Down
Loading

0 comments on commit c185e67

Please sign in to comment.