ID:266436
 
I'm making a look verb but I need to know how to check if something is half like if(M.HP == half) or something

------------------------------------------------------

mob
verb/Look(mob/M in oview(7))
set category = "Commands"
set category = "Commands"
usr << "Name: [M.name]"
usr << "
Health: [M.HP]"
usr << "Strength: [M.Str]"
usr << "
Defense: [M.Def]"
if(M.HP == M.MaxHp)
usr << "He looks like he's in good condition"
if(M.HP == "10")
usr << "[M] is almost dead"
if(M.HP == "1")
usr << "[M] has seen his last sunrise"
if(M.HP == M.HP/2)
usr << "[M] is at half of his HP"
Thief jack wrote:
I'm making a look verb but I need to know how to check if something is half like if(M.HP == half) or something

------------------------------------------------------

mob
verb/Look(mob/M in oview(7))
set category = "Commands"
set category = "Commands"
usr << "Name: [M.name]"
usr << "
Health: [M.HP]"
usr << "Strength: [M.Str]"
usr << "
Defense: [M.Def]"
if(M.HP == M.MaxHp)
usr << "He looks like he's in good condition"
if(M.HP == "10")
usr << "[M] is almost dead"
if(M.HP == "1")
usr << "[M] has seen his last sunrise"
if(M.HP == half)
instead of this if(M.HP == half)
try this
if(M.HP /2=M.MaxHP)
im not sure if that works but try it
In response to Richter
Richter wrote:
Thief jack wrote:
I'm making a look verb but I need to know how to check if something is half like if(M.HP == half) or something

------------------------------------------------------

mob
verb/Look(mob/M in oview(7))
set category = "Commands"
set category = "Commands"
usr << "Name: [M.name]"
usr << "
Health: [M.HP]"
usr << "Strength: [M.Str]"
usr << "
Defense: [M.Def]"
if(M.HP == M.MaxHp)
usr << "He looks like he's in good condition"
if(M.HP == "10")
usr << "[M] is almost dead"
if(M.HP == "1")
usr << "[M] has seen his last sunrise"
if(M.HP == half)
instead of this if(M.HP == half)
try this
if(M.HP /2=M.MaxHP)
im not sure if that works but try it

if(M.HP <= M.MaxHP/2)
You need to be using >= or <= for this. If you use ==, you're checking against specific values, which isn't what you want. Also you're comparing your values to strings (in double quotes), which won't work because HP should be a number, not text. Try something like this:
if(M.HP<=2)  // very low
usr << "..."
else if(M.HP<=M.MaxHP/4) // 25% or less
usr << "..."
else if(M.HP<=M.MaxHP/2) // 50% or less
usr << "..."
else if(M.HP<=M.MaxHP*0.75) // 75% or less
usr << "..."
else // 75% - 100%
usr << "[M.name] is in good health."

Lummox JR