ID:171055
 
How could i make it so when you click on a player you follow them and keep attacking them until they perish(Die)? Here is what i have so far. I have the following part down but i don't know how to make them keep attacking(looping) until the player perishes. If anyone could guide me that'd be great!

client
Click(mob/M)
if(istype(M)&&M.client)
if(M in oview(5))
if(usr.enemy==null)
call(usr,/mob/proc/Target)(M)
..()

mob
proc
Target(mob/M)
if(M.attackable)
src.Attack(M)



Attack(mob/M)
step_to(src,enemy)
M.damage--



~>Jiskuha
Jiskuha wrote:
> mob
> proc
> Attack(mob/M)
> step_to(src,enemy)
> M.damage--
> if(!M.dead) // check here to see if M is dead
> spawn() src.Attack(M) // If not, attack again
>


You'll want to call Attack(M) again at the end of this, but not before checking if M is dead. I just used a made up variable called dead. You may be tracking death some other way, so alter that if() statement to fit with your own code.

~X
In response to Xooxer
Okay and say i wanted them to stop attacking after a certain ammount of hits. Would i create a var and keep adding to the variable and when it hits a certain ammount use break to stop the operation?

~>Jiskuha
In response to Jiskuha
That would work.
In response to Xooxer
Thanks for the help Xooxer i really appreciate it.

~>Jiskuha