ID:170285
 
mob/proc/MonsterAttack(mob/M)
var/damage = 5
sleep(20)
damage += rand(1,10)
M<< "[src] attacks you for [damage] damage!"
M.hp -= damage
M.Update()
M.DeathCheck(src)
sleep(10)
if(istype(M,/mob/NPC/Monster))
M.MonsterAttack(src)
else
M.Attack(src)
..()



Now when the battle starts it works perfectly however the problem that exists is that when i die the battle does not end. How do i stop the monster from continuing to call the MonsterAttack() proc?

~>Jiskuha
Make a death var, and set it if something dies, and do something like:
<DM<if(src.dead||M.dead)
return</DM>
In response to Hell Ramen
Thanks Ramen.

~>Jiskuha
Jiskuha wrote:
Now when the battle starts it works perfectly however the problem that exists is that when i die the battle does not end. How do i stop the monster from continuing to call the MonsterAttack() proc?

Simple: Don't make MonsterAttack() call another attack proc. You have one proc calling the other ad infinitum. That's not the way to do it.

The correct way to manage a battle is to have a single proc call the attack procs in turn. I.e., it'd have the monster attack the player, the player attack the monster, and so on until one of them is dead.

Of course, I also wonder why you have separate Attack() and MonsterAttack() procs, since you don't need them. The monster should in general be able to use any general proc that would be used for a player, and vice-versa, just as you should be using the same DeathCheck() for both. If need be you can always override the proc's behavior.

Lummox JR