mob/verb
Attack()
set hidden = 1
if(usr.Attacking) return
if(usr.frozen == 1) return
usr.Attacking=1
usr.icon_state = ""
spawn(10) if(usr) usr.Attacking=0
flick("Attack[usr.icon_state]",usr) //this can be used to make the character look like their attacking
usr.icon_state = "Combat Stance"
for(var/mob/Monster/M in get_step(usr,usr.dir)) //finds any monsters directly in front of the user
var/damage = src.Str-M.Def //a simple damage calculation
damage=max(0,damage+rand(-1,1)) //make sure damage isnt negative and varry it a little
M.HP-=damage //subtract the damage from HP
M.updateHealth()
M.DeathCheck(usr) //check if you killed the monster
mob
proc
updateHealth()
var/percent=round(HP/MaxHP*100,1)
if(percent>100) percent=100
if(percent<0) percent=0
overlays=list()
//What you need to do is update all your overlays by re-adding them so you can add the new set below... My prefered method to this is to make a different list with all the other overlays and do overlays+=P_Overlays or whever your list is called.
overlays += image('healthbar.dmi',icon_state="[percent]",pixel_x =18,pixel_y=40)
..()
proc/add_hpbars()
usr.overlays += /obj/hudMeters/health_01
src.updateHealth()
obj
hudMeters
health_01
icon='healthbar.dmi'
icon_state="0"
pixel_y=40
pixel_x=18
Problem description: Health bar does appear and does update, but on soms occasions, it suddenly dissapears.