ID:146618
 
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
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
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(!src.key && attacking == 1)
yes = 1
sleep(30)
retaliate = usr.defense / (usr.defense / 2) * src.strength + rand(1,src.strength)
usr << "[src.name] does [retaliate] to you!"
usr.health -= retaliate
while(usr in !get_step(src,src.dir))
return
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
regain_Health()


Problem description:Well, when I attack the npc with no key, it attacks back, but the problem is that it keeps on attacking even though I am not in it's get_step. The yes var is whether or not I am infront of it and the attacking variable is whether or not I am attacking it.