Skip to content

Commit

Permalink
add: stamina bar (ss220-space#3240)
Browse files Browse the repository at this point in the history
  • Loading branch information
definitelynotspaghetti authored Sep 21, 2023
1 parent d402c1f commit 7bb697c
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 8 deletions.
1 change: 1 addition & 0 deletions code/_onclick/hud/_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
#define ui_healthdoll "EAST-1:28,CENTER-1:15"
#define ui_health "EAST-1:28,CENTER:17"
#define ui_internal "EAST-1:28,CENTER+1:19"
#define ui_stamina "EAST-1:28,CENTER-2:13"

//borgs
#define ui_borg_health "EAST-1:28,CENTER-1:15" //borgs have the health display where humans have the pressure damage indicator.
Expand Down
1 change: 1 addition & 0 deletions code/_onclick/hud/hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
mymob.healths = null
mymob.healthdoll = null
mymob.pullin = null
mymob.stamina_bar = null

//clear the rest of our reload_fullscreen
lingchemdisplay = null
Expand Down
3 changes: 3 additions & 0 deletions code/_onclick/hud/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@
mymob.pullin.screen_loc = ui_pull_resist
static_inventory += mymob.pullin

mymob.stamina_bar = new /obj/screen/stamina_bar()
infodisplay += mymob.stamina_bar

lingchemdisplay = new /obj/screen/ling/chems()
infodisplay += lingchemdisplay

Expand Down
5 changes: 5 additions & 0 deletions code/_onclick/hud/screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,11 @@
icon_state = "health0"
screen_loc = ui_health

/obj/screen/stamina_bar
name = "stamina"
icon_state = "stamina0"
screen_loc = ui_stamina

/obj/screen/healths/alien
icon = 'icons/mob/screen_alien.dmi'
screen_loc = ui_alien_health
Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/living/carbon/human/death.dm
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
// We're alive again, so re-build the entire healthdoll
healthdoll.cached_healthdoll_overlays.Cut()
update_health_hud()
update_stamina_hud()
// Update healthdoll
if(dna.species)
dna.species.update_sight(src)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1968,7 +1968,7 @@ Eyes need to have significantly high darksight to shine unless the mob has the X
span_danger("A sense of dread washes over you as you suddenly dim dark."))

/mob/living/carbon/human/proc/get_perceived_trauma(shock_reduction)
return min(health, maxHealth - getStaminaLoss()) + shock_reduction
return min(health, maxHealth) + shock_reduction

/mob/living/carbon/human/WakeUp(updating = TRUE)
if(dna.species.spec_WakeUp(src))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@
update_stamina()
if(staminaloss)
setStaminaLoss(0, FALSE)
update_health_hud()
update_stamina_hud()

// Keep SSD people asleep
if(player_logged)
Expand Down
8 changes: 4 additions & 4 deletions code/modules/mob/living/damage_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@
/mob/living/proc/adjustStaminaLoss(amount, updating_health = TRUE)
if(status_flags & GODMODE)
staminaloss = 0
update_health_hud()
update_stamina_hud()
update_stamina()
return FALSE
var/old_stamloss = staminaloss
Expand All @@ -326,14 +326,14 @@
if(amount > 0)
stam_regen_start_time = world.time + (STAMINA_REGEN_BLOCK_TIME * stam_regen_start_modifier)
if(updating_health)
update_health_hud()
update_stamina_hud()
update_stamina()


/mob/living/proc/setStaminaLoss(amount, updating_health = TRUE)
if(status_flags & GODMODE)
staminaloss = 0
update_health_hud()
update_stamina_hud()
update_stamina()
return FALSE
var/old_stamloss = staminaloss
Expand All @@ -346,7 +346,7 @@
if(amount > 0)
stam_regen_start_time = world.time + STAMINA_REGEN_BLOCK_TIME
if(updating_health)
update_health_hud()
update_stamina_hud()
update_stamina()


Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/living/death.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@

update_damage_hud()
update_health_hud()
update_stamina_hud()
med_hud_set_health()
med_hud_set_status()
if(!gibbed && !QDELETED(src))
Expand Down
26 changes: 26 additions & 0 deletions code/modules/mob/living/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,32 @@
else
clear_fullscreen("brute")

/mob/living/update_stamina_hud(shown_stamina_amount)
if(!client)
return

if(stamina_bar)
if(stat != DEAD)
. = TRUE
if(shown_stamina_amount == null)
shown_stamina_amount = staminaloss
if(shown_stamina_amount >= maxHealth)
stamina_bar.icon_state = "stamina6"
else if(shown_stamina_amount > maxHealth * 0.8)
stamina_bar.icon_state = "stamina5"
else if(shown_stamina_amount > maxHealth * 0.6)
stamina_bar.icon_state = "stamina4"
else if(shown_stamina_amount > maxHealth * 0.4)
stamina_bar.icon_state = "stamina3"
else if(shown_stamina_amount > maxHealth * 0.2)
stamina_bar.icon_state = "stamina2"
else if(shown_stamina_amount > 0)
stamina_bar.icon_state = "stamina1"
else
stamina_bar.icon_state = "stamina0"
else
stamina_bar.icon_state = "stamina6"

/mob/living/simple_animal/update_health_hud()
if(!client)
return
Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@
med_hud_set_health()
med_hud_set_status()
update_health_hud()
update_stamina_hud()
update_damage_hud()
if(should_log)
log_debug("[src] update_stat([reason][status_flags & GODMODE ? ", GODMODE" : ""])")
Expand Down
3 changes: 2 additions & 1 deletion code/modules/mob/mob_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
var/obj/screen/m_select = null
var/obj/screen/healths = null
var/obj/screen/throw_icon = null
var/obj/screen/stamina_bar = null

/*A bunch of this stuff really needs to go under their own defines instead of being globally attached to mob.
A variable should only be globally attached to turfs/objects/whatever, when it is in fact needed as such.
The current method unnecessarily clusters up the variable list, especially for humans (although rearranging won't really clean it up a lot but the difference will be noticable for other mobs).
I'll make some notes on where certain variable defines should probably go.
Changing this around would probably require a good look-over the pre-existing code.
Changing this around would probably require a good look-over the pre-existing code. :resident_sleeper:
*/
var/obj/screen/leap_icon = null
var/obj/screen/healthdoll/healthdoll = null
Expand Down
3 changes: 3 additions & 0 deletions code/modules/mob/update_status.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,8 @@
/mob/proc/update_health_hud()
return

/mob/proc/update_stamina_hud()
return

/mob/proc/update_canmove()
return 1
2 changes: 1 addition & 1 deletion code/modules/reagents/chemistry/holder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@
M.update_stat("reagent metabolism")
if(update_flags & STATUS_UPDATE_STAMINA)
M.update_stamina()
M.update_health_hud()
M.update_stamina_hud()
if(update_flags & STATUS_UPDATE_BLIND)
M.update_blind_effects()
if(update_flags & STATUS_UPDATE_NEARSIGHTED)
Expand Down
Binary file modified icons/mob/screen_gen.dmi
Binary file not shown.

0 comments on commit 7bb697c

Please sign in to comment.