I want to make it so when the player hits the attack verb, the player attacks, sleep(5), then the player keeps attacking untill the monster is dead, or the player dies. I also want to make a calm() verb so the player can stop attacking when he/she presses it.
mob
verb/attack(mob/M as mob in oview(1))
if (M.dead == 0)
if (M.HP >= 0)
flick("malefight",src)
usr << "You attack [M]!"
oview() << "[usr] attacks [M]!"
var/damage = rand(strength)
usr << "[damage] damage!"
M.HP -= damage
M.DeathCheck()
I tried this, but it doen't seem to work. It comes up with an error that says: Cannot read null.dead , then it stops attacking
mob
verb/attack(mob/M as mob in oview(1))
if (M.dead == 0)
if (M.HP >= 0)
flick("malefight",src)
usr << "You attack [M]!"
oview() << "[usr] attacks [M]!"
var/damage = rand(strength)
usr << "[damage] damage!"
M.HP -= damage
M.DeathCheck()
attack() //right here I try to make the loop
In this example, basicly he just attacks once with success, but when it tries to loop, it just says an error.
Also, I'd advise looking into spawn() to take care of your sleeping in between attacks - it will not only wait like you want it to, but it will avoid any possible infinite loops. See the reference for more info...
<font size="-2">how was that, Lexy?</font>