ID:1150140
 
(See the best response by Kitsueki.)
Am learning bit by bit as I go, but these 2 codes problem threw me off the most.

1.When I attack and it is time to call for the knockout proc i believe my attack system wait until knockout proc is complete before it proceed with attacking again.
2.After the NPC completes the knockout proc it wont return to the AI. I tried recalling the AI proc but it still didnt work.
mob
verb
Attack()
set hidden = 1
if(Attacking) return
if(dead) return
usr.Attacking =1
usr.dir=get_dir(usr,usr.Tgt)
for(var/mob/M in get_step(src,usr.dir))
var/damage = Strength * 2
M.hp -= damage
us<<"You punch [M] for [damage] damage!"
M<<"[usr] punch you for [damage] damage!"
M.ko(src)
spawn(7)
usr.Attacking = 0

mob
proc
ko(mob/M)
if(src.hp <= 0)
src.hp=0
src << "You've have been KO by [M]! (You will be KO for 2 minutes.)"
flick("KO",src)
icon_state="Dead"
src.frozen=1
src.dead=1
sleep(175)
src << "You've have been recover."
src.icon_state = ""
src.frozen=0
src.dead=0
src.run=1
sleep(80)
src.run=0
return AI(src,M)




Are their any solution if so please response and thank you in advance.
Best response
1) if it's an issue about ko() taking too long to finish, spawn() it.
2) if you're using Attack() in AI(), you're going to end up in an infinitely recursive run of AI(), which could possibly work ok in some situations, but judging from what I see I doubt this is one.

When you run a proc, the proc it was started in will wait until that proc is finished before continuing, that's why spawn() is useful, so you aren't forced to wait.
Learn some new everyday. :) Okay the spawn works just now i gotta fix where if mob is dead it return but i can do that.

Edit: nvm your spawn() worked like magic i used it in ko call the AI proc again and it worked thanks alot