ID:264930
 
Code:
mob/Monsters
proc
Agressive()
spawn(1)
while(1)
var/mob/Target = /mob
for(Target in oview(10))
if(Target.Player == 1)
Target.Health -= Damage
if(Target.Bar == 0)
Target.Bar = 1
healthBar = new(Target, 'Health Bar.dmi', 14, "Health", "Max_Health", pixel_y = -8)
spawn(1)
overlays = null
Bar = 0
Target << sound('slash.wav')
Target.Player_DeathCheck()
sleep(10)
mob/Monsters
New()
Agressive()
while(src)
var/mob/Target = /mob
var/Monster
var/Rounds = 1
for(Target in oview(10))
if(Target.Player == 1)
while(Rounds <= 8)
Monster = locate(/mob/Monsters in get_step(Target,Rounds))
if(!Monster)
walk_towards(src,get_step(Target,Rounds),5)
sleep(6)
Rounds ++
sleep(10)


Problem description:
The Aggressive process can actually do what I want it to do but for some reason it doesn't start functioning for about 10 seconds and when it does work, it has random fluctuations in completion time.

Any ideas on what's going wrong? I'm stumped.

Extra : Everything after Agressive() keeps going even though Agressive() does nothing for ages.

Double Extra : The actual timing won't be logical because I'm made most if not all 1 in order to make sure the 10 seconds it's taking isn't possible.
You've got sleep(10) inside the for(Target in oview(10)) loop inside mob/Monsters/proc/Agressive(), so it's sleeping 10 seconds every time it hits a new mob.

Everything in New() is continuing because you've spawn()'d off the loop in proc/Agressive(). This is a good thing, or the constructor would never return.
In response to Jp
I think you're confused. sleep(10) will make a 10 millisecond delay, not 10 seconds.
2 problems...
Your not spawning Agressive so it is never continuing to the loop in New.

You are not calling the parent action...(My thought is maybe you are doing this somewhere else which is conflicting with this New()?)

In response to Kyle_ZX
Kyle_ZX wrote:
I think you're confused. sleep(10) will make a 10 millisecond delay, not 10 seconds.

Actually, sleep(10) will sleep for one second or 1000 ms as each tick is 1/10 of a second.

So, because sleep(10) is in the for(), after the mob finds one target it will sleep one second before it moves onto the next mob.

Unless that is intended behavior, you should probably reduce the time in between each iteration and you should see an improvement.
In response to Kalzar
Found the issue. Problem solved. Thanks.