ID:857844
 
Code:
mob/Player/proc
DamageIcon()
if((src.HP)<=(src.MaxHP)*0.1)
icon='monster.dmi'
icon_state="Green_Monster"


Problem description:

I am trying to make it to when the Player's HP is 10% of their MaxHP it will change the mob's icon.
but i tested this out and nothing happened. Any ideas?
if(src.HP/src.maxHP <= 0.1)

Of course, if you want it to be exactly 10%, change <= to ==
because (src.HP) = 1 if the source's HP is a nonzero value.

You're not getting the actual HP value, you're getting whether or not HP is nonzero, because of the extra parenthesis (Which are unnecessary, and in this case not functioning)

(src.HP) = 1
and (src.MaxHP) = 1
This is assuming that both values are non-zero values.

Try
if(src.HP <= src.MaxHP*0.1)
//or
if(src.HP/src.maxHP*10 <= 0.1)


In response to Ill Im
Ill Im wrote:
You're not getting the actual HP value, you're getting whether or not HP is nonzero, because of the extra parenthesis
Incorrect. Completely.

@Calus:
a/b<=c is the same as a<=b*c, so I don't think that's the problem.

@OP:
Is DamageIcon() being called at the right time?
mob/Player
icon='Sword.dmi'
icon_state="player"
Login()
if(src.LoadProc())
else
loc=locate(/turf/start)
proc/DamageIcon()
while(src.HP<=src.MaxHP*0.1)
icon='monster.dmi'
icon_state="Green_Monster"




I tried adding it to the original mob code to see if that would help but it didn't. How do I make sure if it is being called at the right time? Sorry im a newb i starte like a couple of days ago.