ID:167620
 
i have a quick question. how do i get a percent of 2 numbers? IE if you have 593 hp and your max hp is 978, how would i figure out the percent of hp the character has?
Xkirby2 wrote:
i have a quick question. how do i get a percent of 2 numbers? IE if you have 593 hp and your max hp is 978, how would i figure out the percent of hp the character has?

That'd be 593/978*100. To display a percent, try this:
stat("Health", "[round(100*HP/maxHP)]%"

Lummox JR
In response to Lummox JR
well this update hud proc only works when yer hp is 3...any ideas?

mob
proc/Update(mob/M as mob)
for(var/obj/hpmeter/HPnum in M.client.screen)
HPnum.num = round(100*usr.HP/usr.MHP)
HPnum.Update()
var
obj/hpmeter/HPmeter
In response to Xkirby2
Xkirby2 wrote:
well this update hud proc only works when yer hp is 3...any ideas?

mob
> proc/Update(mob/M as mob)
> for(var/obj/hpmeter/HPnum in M.client.screen)
> HPnum.num = round(100*usr.HP/usr.MHP)
> HPnum.Update()
> var
> obj/hpmeter/HPmeter


You need to show us your hp meter's update proc. On the other hand, you should never use usr in procs. You also don't need to pass an argument if src is the only information you ever need. (Which I assume it is, since an update proc usually updates the player's hud)

~~> Unknown Person
In response to Unknown Person
Sorry, my brother isn't all that good at coding. Bare with him...He seems to think he can put usr in procs...he does it all the time...
In response to KirbyRules
He can use usr in procs (atleast with your meaning, in procs that usr shouldn't be used in), but I doubt anyone has taken the time to link him to an explination as to why he shouldn't, or explain the reason themselves.

http://byondscape.com/ascape.dmb/LummoxJR.2002-1104/