mob
proc
ExcessCheck()
if (usr.HP > usr.maxHP)
if (usr.mana > usr.maxmana)
usr.mana = usr.maxmana
usr.HP = usr.maxHP
else
usr.HP = usr.maxHP
if (usr.HP <= usr.maxHP)
if (usr.mana > usr.maxmana)
usr.mana = usr.maxmana
obj
item
Food
icon = 'pub.dmi'
icon_state = "food"
verb
Eat()
usr.HP += 5
usr.mana += 3
alert("your HP has been healed by 5 points and your mana by 3 points.")
del(src)
sleep(1)
usr.ExcessCheck()
Problem description:
That's part of the code of a game I'm helping to code. ExcessCheck proc tries to reset the HP and Mana if they're higher than the limit after using a heal item. But it still goes higher than the max amount it should, and I have no idea of how to fix it.
Second, the whole proc is just buggered up. All you need is:
Third, the proc is never called because the line del(src) stops the verb.
Fourth, you should just be using a setter function for variables that you want to be capped, and then use that all the time. IE:
That way, you can never forget to cap the variable.