ID:146611
 
Code:
mob
verb
attack()
for(src in get_step(usr,usr.dir))
if(src.key)
yes = 1
damage = src.defense / (src.defense / 2) * usr.strength + rand(1,usr.strength)
src << "[usr] starts a battle with you!"
oview(1) << "[usr] begins to battle with [src]!"
src << "[usr] does [damage] damage to you!"
usr << "You do [damage] to [src]!"
src.health -= damage
sleep(10)
if(src.health <= 0)
usr << "You killed [src]."
oview(1) << "[src] got killed [usr.names]!"
src.loc = locate(lastx,lasty,lastz)
if(!src.key)
yes = 1
attacking = 1
damage = src.defense / (src.defense / 2) * usr.strength + rand(1,usr.strength)
src << "[usr] starts a battle with you!"
oview(1) << "[usr] begins to battle with [src]!"
src << "[usr] does [damage] damage to you!"
usr << "You do [damage] to [src]!"
src.health -= damage
sleep(10)
Retaliate()
if(src.health <= 0)
src.health = src.maxHealth
usr << "You killed [src]."
src.loc = locate(1,1,1) //somewhere
attacking = 0




proc
Retaliate()
while(usr in get_step(src,src.dir))
yes = 1
retaliate = usr.defense / (usr.defense / 2) * src.strength + rand(1,src.strength)
usr << "[src.name] does [retaliate] to you!"
usr.health -= retaliate
sleep(20)
if(usr.health <= 0 || usr.health <= -1)
usr.health = 0
usr << "You have been killed by [src.name]."
oview(1) << "[usr] got killed [src.name]!"
usr.loc = locate(1,1,1)
attacking = 0


Problem description:Now the problem here is that everytime I attack, it lags, and same for the npc that is retaliating. So when it lags, I die like 4 times and the same for the npc. Why does this happen. Not to mention, I only want it so that the npcs have the 'Retaliate' proc, therefore I am trying to declare that if they do not have a key, they retaliate but if they do, they dont retaliate.

Actually, with my code up there, how would I make it so that after each attack, there is a delay. I'm trying to make it after each attack, stop for 2 seconds and attack again. As you can see, my attempt with the sleep(10) there has failed -.-.