ID:270939
 
Okay.

The HP bar is just 32x32

I want it to be like this.

If you have under 12% of your HP it goes to icon_state 12%

If you have under 24% of your HP it goes to icon_state 24%

If you have under 36% of your HP it goes to icon_state 36%

If you have under 48% of your HP it goes to icon_state 48%

If you have under 60% of your HP it goes to icon_state 60%

If you have under 72% of your HP it goes to icon_state 72%

If you have under 84% of your HP it goes to icon_state 84%

If you have under 96% of your HP it goes to icon_state 96%

If you have under 100% of your HP it goes to icon_state 100%

How would I go about doing that?
Make like a bar for each one that you want and what not, and when it lowers just make it flick the icon state,or somthing like that never really tried.
~Grand~
In response to KillerGrand
I guess make a proc that updates your hp bar everytime you lose or gain hp.
In response to KirbyAllStar
I agree.

...right... anyways, KG was right to a degree... and if you searched for HP demoes, I bet you would've found something close to whaat you're looking for.

According to your post, I will assume you want the specified amount.

Step 1: Create those icon_states of the % (but no adding % sign :O well, if you want to, go ahead but make sure you modify your code accordingly.

Step 2: Make a HP HUD
HUD
parent_type=/obj
layer=10 //so it doesn't get hidden by other stuff
HP
screen_loc="NORTH,WEST" //shows up on the top left
icon='HP HUD.dmi'
icon_state="100" //default icon state


Step 3: Make a procedure to update the HP HUD
mob/proc/Update()
if(!client) return //if the person isn't a player, the rest will not happen
var/HUD/HP
H
P
for(P in client.screen){H=P;break} //If there's one HP HUD already existing in the client.screen, it'll refer to it
if(!H) //If there's no existing HP HUD in the client.screen
H=new //creates a new instance
client.screen+=H //adds it to the client
H.icon_state="[(hp/mhp)?=1 ? 100 : ((hp/mhp)-((hp/mhp)%12))]" // the ? thing is like a compact if statement: Test? If_True_do_this : If_False_do_this
//((hp/mhp*100)-((hp/mhp*100)%12)) --> ((75/100*100) - ((75/100*100)%12) ->
// 75 - (75%12) (% here is the modulus.. remainder after the Y is divided into X properly [x%y] ->
// 75 - 3 [75%12 = 3 (72 divides into 12 perfectly)]
// icon state is now 72


Step 3: Call Update() proc when ever damage is taken. General procedure for taking health is recommanded

- GhostAnime
In response to GhostAnime
GA, What if he wants it in the statpanel? Then he would have to make it like statpanel like correct? Which would be diffrent then the HUD.

~Grand~
In response to KillerGrand
Well, if he wanted it in the hub, he would have to have an object made none-the-less for the icon to appear.. but placing the proc in the statpanel would be something he should avoid as why would anyone want unneccessary lag if the value doesn't change often?

Meaning just a LITTLE tweak is needed >_>

- GhostAnime