ID:262787
 
Code:
client
Center()
if(usr.targetmarker<>"")
if(usr.targetmarker in oview(10))
usr.Enterfight(usr.targetmarker)
else
world<<"Not in oview."
else
world<<"No target."

mob/proc
Enterfight(mob/M)
if(istype(M,/mob/Player/))
src<<"You enter a fight with [M]!"
spawn() BeginBattle(M)
..()
BeginBattle(mob/M)
if(istype(M,/mob/Player/))
for(M in oview(src.cansee))
var/damage = src.str+rand(1,4)-M.def
// var/Critical = rand(1,100)
if(damage<=0)
damage = 0
M.Hp-=damage
src<<"You hit [M] for [damage] after [src.waitattack] time!"
if(M.Hp<=0)
deathcheck(M)
src<<"You killed [M]!"
else
spawn(src.waitattack)BeginBattle(M)

..()

mob/Player
var
waitattack = 12
Monster
Hp = 19
icon = 'Monster.dmi'
icon_state = "theif"
New()
walk_rand(src,10)
..()


Problem description:

It doesn't wait for the waitattack, which is 12. It usually goes through the whole thing around 19-22 times, but sometimes it only does it twice. Then I have to hit center each time I want to attack.
Bump.
Your deathcheck() proc is backwards. In that proc, src should always be the victim, and the argument should be the killer. Instead of calling deathcheck(M), you need to be calling M.deathcheck(src). Swap vars within deathcheck() accordingly.

Lummox JR
In response to Lummox JR
Okay, but that doesn't fix the problem with it attacking 20 times in 1 second
In response to Dead_Demon
Do you even look at your own coding... Ofcourse it attacks 20 freakin times you made it so they get to keep attacking as long as they have HP