ID:751397
 
(See the best response by DarkCampainger.)
Code:
AI()
while(src)
if(!Combat())
Walk()
Get_target()
for(var/mob/Minion/M in oview(5,src))
if(M.Side!=src.Side)
src.target=M
return 1
return 0

Combat()
if(!src.target) if(!Get_target()) return 0
if(get_dist(src,src.target)<=1)
src.dir=get_dir(src,src.target)
src.Attack()
sleep(5)
return 1
else
if(!step_to(src,src.target)) Dodge()
sleep(5)
return 1
Attack()
for(var/mob/M in get_step(src,src.dir))
if(M!=src)
var/Damage=max(0,src.Str-M.Def)
if(src.client)src<<"You hit [M] for [Damage] damage!"
M.TakeDamage(Damage,src)


Problem description:
I am making a simple AI routine. Combat and Movement. Movement is destination based. So NPCs move from destination to destination. I am using step_towards proc because the destination is too far away for step_to proc to handle. I had to write my own Dodge system as step_towards doesnt handle obstacles and its working pretty well.

My first question is, is there any better way to do this? (long distance travel)

My second point. I tried to implement a combat system (code at the top). But the NPCs seem to have trouble working together at larger numbers. They position themselves wrong and get stuck even though i am using step_to proc! I even tried to use my Dodge() proc as a possible solution, but it didn't help.

So my second question is: Can you see an obvious mistake in my logic, or did I approach this problem by a wrong way?

Thank you for your replies. All help is appreciated!
This is just a pet peeve of mine, but have you tried using step_towards() as opposed to step_to()? It generally works smoother for me and it might fix some of the pathing issues you have.
Best response
For your first issue, you want pathfinding. I've always used Deadron's library, but you may want to check out some of the more recent ones, too.

Your second issue is likely your Get_target() process. You need to un-indent that return 0 by one tab. As it is, if the first minion it finds is on its same side, it gives up immediately (so when they fight together, they're more likely to find one another and give up).
Wow thanks. I see the logic problem now. It would take me ages to figure that out.

As for the library I will check it out and see if I can grasp it's use. Thank you.

Edit: I implemented the library and its doing miracles at close combat :)