ID:159547
 
        Login()
..()
density=0
world << "<b>[name]</b> has joined. (Faction: [Faction_Check()]) (Team: [Team_Check()])"
spawn
while(src)
var/X
var/Y
for(var/NPC/soldier/P in s_group)
if(P.leader) continue
if(X>4)
Y++
X=0
for(var/NPC/soldier/R in s_group) if(R.leader)
walk_to(P,locate(R.x+X,R.y-Y,R.z),0,R.speed)
sleep(01)


Well, I spent a few hours trying to come up a way for units to walk in formations. This is all I've come up with.

I know there are ways it could be better, especially since there tends to be "gaps" in the formations instead of forming straight lines.

So, how?
Did you look into animate_movements - SYNC_STEPS?

I don't know if it would help or not.

ts

You have a worthless loop. You should realize that it won't do anything.

Can you please explain to us what kind of formation are you trying to achive?
It sort of occurred to me in my sleep. While it depends a bunch on what formations and pathfinding. You would certainly want to store the path information and then call a smaller function for the actual movement so they all leave at the same time.

For starts, you could try calling spawn(10) right before your walk_to which should improve things. If you want more realistic movement, replace the static 10 with a rand(10,12).

for(var/NPC/soldier/R in s_group)   
if(R.leader)
spawn(10)
walk_to(P,locate(R.x+X,R.y-Y,R.z),0,R.speed)