Home   Help Search Login Register  

Author Topic: [REQ] how to get a group to spread out  (Read 1855 times)

0 Members and 1 Guest are viewing this topic.

Offline twisted

  • Members
  • *
  • I'm a llama!
[REQ] how to get a group to spread out
« on: 23 Apr 2009, 17:57:24 »
Hi.

i cannot find any command that makes a group spread out.

So it seems i am going to have to make a script that takes each unit and then gets them to move x distance away from each other.
 
problem is my geomoetry skills are very rusty and i cannot think of how to keep the guys spread out when  they start moving.

any insight or help you can give will be appreciated.

Offline Ext3rmin4tor

  • Members
  • *
Re: [REQ] how to get a group to spread out
« Reply #1 on: 23 Apr 2009, 18:53:40 »
The "Take Cover" command does that, everyone will run to get a cover and thus spread out
How can you shoot women and children?
Easy! Ya' just don't lead'em so much! Ain't war hell?!!

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: [REQ] how to get a group to spread out
« Reply #2 on: 23 Apr 2009, 20:02:45 »
Sadly, mission editors can't access many of the commands the player can (such as take cover, flank right, advance, scan horizon etc). This is a real pity, since they could really boost the editor's choices when it comes to a lot of things...

Scripts are the way.

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline twisted

  • Members
  • *
  • I'm a llama!
Re: [REQ] how to get a group to spread out
« Reply #3 on: 24 Apr 2009, 20:00:50 »


Scripts are the way.



yes. not sure how to implement.

for a general spread out i can get guys to find a random spot 10m away from each of themselves and run there - how to do the math of find a random point on a circle 10m radius and move there though? preferably keep the move not towards enemy as well but that's a far lesser point.

also not sure how i'd make them spread out though while keeping the same general formation.

Offline Trexian

  • Members
  • *
Re: [REQ] how to get a group to spread out
« Reply #4 on: 24 Apr 2009, 20:42:24 »
The formation would be tricky.

My initial thought would be to start with the position of the leader, get the direction he's looking (might be unreliable) or the atan2 of the leader to the nearTargets, then figure 90 degrees off from that direction for the "line." 

Easiest way, I think, would be to get the total number of units in the group, then loop for each one moving the moveTo position another 10m away from the leader in the direction of the line.

Otherwise, I think you'd have to get the direction of each unit from the leader, figure out left side or right side of  the line, and then do a loop in each direction.  Once you get the direction to the enemy, loop for each unit figuring out the atan2 from the leader.  If the direction is "left" then add to a leftArray, opposite for a rightArray.  Then count the units in the arrays, and loops in each direction.

Sorry if this doesn't make sense. :)
Sic semper tyrannosauro.

Offline Denisko-Redisko

  • Members
  • *
Re: [REQ] how to get a group to spread out
« Reply #5 on: 25 Apr 2009, 14:48:20 »
Guys, is the "Take Cover" command is not what you need?
On this point, You can look formation.fsm:
Code: [Select]
_hideFrom = _this getHideFrom _enemy;
_objectWhereHide = _this findCover [position _this, _hideFrom, 20];
And then, one must remember that the soldiers are constantly controlled by a finite-state-machine.
And may well happen that your script will issue orders contrary to the orders of the machine.
And you should write your fsm, but it is not easy.
« Last Edit: 25 Apr 2009, 15:26:43 by Denisko-Redisko »
sorry for my english