ID:268953
![]() Jan 2 2005, 6:02 pm
|
|
Hm, How do I make hp meters that go right over the players character? I want there to be one for every mob in the world, npc , monster, everything. Thank ya.
|
Ter13 wrote:
It would also be best to change the bar whenever you take damage, something like this: src.healthbar.icon_state = "[round(src.health/src.maxhealth)]" That should do you fine. If you don't want to create 100 icon states, you could reduce it to 20, then this is your formula: round(src.health/src.maxhealth)/(100/numStates)*(100/numstates) numstates is the number of icon states you made, if it is 20, 95.1231421% health would turn out to be 95%, and 93.123719% health would be 90%. You can also make use of round()'s second argument: src.healthbar.icon_state = "[round(src.health/src.maxhealth,5)]" That would automatically round it off to the nearest 5. |
I'm also wanting to know how to do this, where would i put these 2 commands then
src.healthbar.icon_state = "[round(src.health/src.maxhealth,5)]" and round(src.health/src.maxhealth)/(100/numStates)*(100/numstates) |
That's for you to figure out. But I will give you a hint, rather than directly changing a person's HP, have an event system. When they lose some hp, call a mob procedure that does the subtraction and any events tied to it for you. those two lines should never go into the same code, as the second line was a formula, and the top line was a basic implementation.
|
It would also be best to change the bar whenever you take damage, something like this:
That should do you fine. If you don't want to create 100 icon states, you could reduce it to 20, then this is your formula:
numstates is the number of icon states you made, if it is 20, 95.1231421% health would turn out to be 95%, and 93.123719% health would be 90%.