ID:1838463
 
(See the best response by Turboskill.)
mob
proc/Damagecheck()

if(src.life < 100)
src.overlays-=/obj/HP100
src.overlays+=/obj/HP75
if(src.life < 75)
src.overlays-=/obj/HP75
src.overlays+=/obj/HP50
if(src.life < 50)
src.overlays-=/obj/HP50
src.overlays+=/obj/HP25
if(src.life == 0 )
src.overlays-=/obj/HP25
src.overlays+=/obj/HP0
else
src.overlays+=/obj/HP100



If I hit an enemy or player, the hp bar does not change to the next overlay. Furthermore, mobs dont have a bar till first hit. Which is not such a big deal.:

</50></75></100>
It helps if you put your code indie the <dm> tags, not before. Also you should lose the <b> tags for readability.
Best response
Well. What Lummox said.

About the mobs not getting bars till the first hit thing though, that'd be because you don't appear to be adding /obj/Hp100 to the player's overlay list until you enter the DamageCheck() proc and check that a player ...doesn't have 0 life... meaning only when the player has been hit at least once (since i'm assuming you aren't calling DamageCheck() at any other time) will any overlays be added.

Ok, so i've realised why none of this is really working for you, it's simply because you have your logic quite out of whack, let me show you what i mean.
Consider this scenario:
player1.life = 100; player1 gets hit with 26 dmg; player1.life = 74; call DamageCheck() for player1
Here's a dry run-through to show you what your code would be doing at run-time in this situation
______________________________________________________________________________
if(74 < 100) => true
    [take off the 100hp bar overlay]         (there isn't one.)
    [add the 75hp bar as an overlay.]        (alright.)
if(74 < 75) => true
    [take off the 75hp bar overlay and add a 50hp bar.]   (...wait)
.
.
.
if(74 == 0) => false
    [take off the bar overlay we just added and give a 0hp bar]    (there is a '0 bar'?)
else
    [put a 100hp bar on the top whatever else is there]             (...uhm)
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
I hope with that illustration you might be able to see the issues with your code here.
Now, here is what i suggest you do to fix your approach.
  1. Think carefully about what you want to do.
  2. If you need to, write it out in structured english or 'pseudocode'
  3. Translate the logic directly to code.
One of us could just supply you with a solution, but it's probably better you give this another go first.

Hint: check out 'else if'. Also use '>' and '<' together to check that something is between two other things.
mob
proc/Damagecheck()

if(src.life < 75 && src.life > 50 && src.flag == 1)
src.overlays-=/obj/HP100
src.overlays+=/obj/HP75
src.flag = 2

else if(src.life < 50 && src.life > 25 && src.flag == 2)

src.overlays-=/obj/HP75
src.overlays+=/obj/HP50
src.flag = 3
else if(src.life < 25 && src.life > 0 && src.flag == 3)
src.overlays-=/obj/HP50
src.overlays+=/obj/HP25
else if(src.flag == 0)
src.overlays+=/obj/HP100
src.flag = 1
else


The code works now, thx for the info. My programmer of an uncle showed me that it was looping through because multiple statements were true.
I'd personally use an approach which is more visually pleasing to the end user and reflects one's actual hp more accurately. I'm sure you know that with your current setup, looking at another's(or your own) healthbar can be quite misleading.

I suggest you separate your healthbar icon into 2 sections, a background and the actual bar. I prefer to make the bar just 1 point, so that I can just generate the other 99 points via code(and caching the results), and have a perfect 100 points healthbar. Then you can just have a updateHP() proc and change it accordingly. You could call it at login and display a player's hp from the start. It's just outright a better approach than relying on a deathcheck() proc to update somebody's hp bar, which I consider to be bad practice.

This'll completely eliminate the issue you have with the hp bar not showing until you are hit (unless that is intentional).

Also, your flag's check is rather redundant.

P.S, There's no need to use "src" in the Damagecheck () proc under those circumstances, because src will always default to the caller of said proc.