everything work but when he start run after a mob he stop after 2 sec and he restart run after the mob and he do the same thing when he follow me this is the code.
thanks you for all
Code:
proc
WCloneAi(GAME_MOB/owner, GAME_MOB/clone)
if(owner&&clone)
spawn()
sleep(1)
icon = 'Art/Jutsus/Water Element/Water Bunshin.dmi'
flick("form",clone)
sleep(5)
walk(clone,0)
clone.m_health = owner.m_health/2
clone.health = owner.health/2
clone.appearance = owner.appearance
clone.is_a_water_clone = 1
while(clone)
if(!owner)
del(clone)
if(followuser)
clone.icon_state = "run"
step_to(src,usr,2,0) //here where he follow the user
if(clone.Ctarget)
clone.Clonecombat() ///here if he found a target he go to the proc
followuser = FALSE
if(!clone.Ctarget)
clone.CLookForTarget() /// here if he don't found a target he will search again
followuser = TRUE
sleep(world.tick_lag)
sleep(rand(15,27))
proc
CLookForTarget() //// search target proc
if(src.targetlook == FALSE && !src.Ctarget && !src.dead)
targetlook = TRUE
for(var/GAME_MOB/mob in obounds(src,640))
if(mob && !mob.dead && !Ctarget && mob.village != src.village && !istype(mob,/STORE) && mob.level>9)
src.Ctarget = mob
targetlook = FALSE
Problem description:
sleep(rand(15,27))
Your code is telling it to sleep for about 2 seconds every iteration.
Ditch that line.
Also, you probably shouldn't be using usr like this:
You should be using owner instead of usr, as you are already storing the clone's owner, and usr is potentially unsafe.