ID:262364
 
Code:
mob/monster
proc/MonLife()
while(src)
sleep(15)
if(src.hostile)
for(var/mob/M in oview())
if(M.client)
step_towards(src, M)
for(var/mob/M in get_step(src, src.dir))
if(M.client)
src.Attack(M)
if(src.wander)
step_rand(src)


Problem description:
The wandering part is fine. But when it is "hostile" it jumps around three spaces. How do I fix that?
I'm not sure, but I think this is what you're looking for.
mob/monster
proc/MonLife()
while(src)
sleep(15)
if(src.hostile)
for(var/mob/M in oview())
if(M.client)
step_towards(src, M)
break

for(var/mob/M in get_step(src, src.dir))
if(M.client)
src.Attack(M)
else if(src.wander)
step_rand(src)

Tell me if this fixes it.

RD
It's because it loops through all players with a client in view, and then steps towards all of them. That means that it steps as many times as there are clients in view. You want to stick a break in the middle of that loop. Or get the monster to 'target' a specific mob, so that it always steps towards the same mob, assuming that it's the closest. Although I suppose a system in whic hit just steps towardsthe closest mob is good, smart players will team up and the just move back and forth whilst unleashing ranged attacks on the monster. The poor dear won't know where to go. It'd be something like this:

P - Player
@ - Monster


P @ P

Steps towards closest one.

P @ P

Player moves away

P @ P

Step towards closest

P @ P

You get the drill. Basically, the players play ping-pong with the monster, and it gets very confused.
In response to Rurouni Dragon
I don't think that's the problem. i'll try. But I'm testing it by myself, with no other clients in view or even in the world.
In response to Dark Weasel
In case you didn't catch it, the key features I was using were break and the else if rather than if

RD