ID:270725
 
ok I need help with this code I learned coding a month back so I dont know all of byonds features yet. am trying to get this to go after random players in world but it will go after one player in world and after that player dies it will go after another player in world. -.- ive spent to much time on trying to figure this out so mind helping me out with this.

proc/Chase(var/mob/player/M)
while(src)
soundmoan(src)
if(M in world)
for(M in world)
if(M:team=="Player")
step_to(src,M,1)
sleep(src.speed)
break
for(M in world)
if(M:team=="Player")
step_towards(src,M)
sleep(src.speed)
break
else
step_rand(src)
sleep(rand(20,50))
for(M in world)
if(M:team=="Player")
sleep(8)
break
spawn(rand(2,5))
Chase()

Oh...my.....powerful creatures somewhere....

proc/Chase(var/mob/player/M)
Because of the while(src), I am going to assume this as a mob/proc...
also, add in safety checks:
if(!M||M in world)


 if(M:team=="Player")
step_to(src,M,1)
sleep(src.speed)
break
Please try not to abuse :, you can use . perfectly

 break
for(M in world)
if(M:team=="Player")
step_towards(src,M)
sleep(src.speed)
break
1) Do not use break, let the loop continue

2) You duplicated that part so delete one off.

spawn(rand(2,5))
Chase()
Why bother breaking and recalling the same proc, just make spawn=sleep and take off the Chase line and it should be okay
PS: When pasting code, use the following tags:
hmm ok ran into a couple of bumps
In response to Dark Emrald
No use colon.
Ah ok got it working thx