mob
Click()
if(src.client)
return
if(src.NPC)
walk_to(usr,src)
else
walk_to(usr,src)
usr.dir = src.dir
sleep(10)
usr.Attack(src)
mob
proc
Attack(mob/M)
while(M in oview(1))
var/D = (usr.Strength + rand(0,3)) - (M.Defence + rand(0,3))
M.Health -= D
world<< "[M] was hit for [D] damage!"
M.Attack(usr)
sleep(20)
Problem description:
Everything else work but enemy doesn't attack back... why is it and how could i make it so they do.
Please note that doing a battle this way may also hit the built-in recursion limit for world.loop_checks, I'm not sure. There are better ways to go about a turn-based system, though, so I wouldn't use the method you're using for an actual project. Unless it's like, a simple MUD or something, but even then I'd refine it so that it doesn't use recursion. Also, it is good practice not to call usr in procs unless you absolutely know what you're doing with it.