mob
var
obj/HealthBar
New()
..()
HealthBar = new/obj()
HealthBar.icon = 'Healthbar.dmi'
usr.overlays += HealthBar
usr.SetHealthIconState()
mob/proc/SetHealthIconState()
var/state
switch(round(health/max_health)*100)
if(0) state = "0"
if(10) state = "10"
if(9) state = "9"
if(8) state = "8"
if(7) state = "7"
if(6) state = "6"
if(5) state = "5"
if(4) state = "4"
if(3) state = "3"
if(2) state = "2"
if(1) state = "1"
HealthBar.icon_state = state
This doesn't add anything to my overlays, any suggestions why?
looks like state is going to vary from 1 to 100, not 1 to 10. Here's a simpler version with the correct math as well: