mob/Player/proc
Hunger(mob/M)
M/var/HT = M.Hunger
if spawn(100) //I tried sleep(100) but it had errors
HT += 1
if (M.Hunger == 100)
usr << "You begin feeling weak from hunger."
M.Health -= 1
else if (M.Hunger == 50)
usr << "You feel hungry."
else return
Problem description:I'm trying to make it so every 100 ticks I become a little more hungry, and when my Hunger reaches 100% i start losing health and have to eat. This is the first proc I ever tried to do by myself.
- You don't need a mob/M argument for the Hunger() proc, because src is the mob it's working with; M is redundant.
- M/var/HT isn't correct syntax.
- The if statement needs parentheses, and if(spawn()) isn't valid. If what you're trying to do is call this proc just once to start a hunger loop going, this isn't the right way to go about it.
- HT is a local var, so the Hunger var itself is never actually changed.
- usr has no business in a proc.
- When you make the player lose health, you're not doing a death check.
I believe you need something more like this: