OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Mandoble on 05 Jan 2008, 03:58:32

Title: Formation leader
Post by: Mandoble on 05 Jan 2008, 03:58:32
Is there any way to change on purpose the default formation leader of an existing group without FSM or making a unit to get into a vehicle?
Title: Re: Formation leader
Post by: Wolfrug on 05 Jan 2008, 11:25:18
Edit: I probably need to read your post better. What exactly do you mean? If you mean -leader- (i.e., squad leader) then it's just a matter of reorganizing who's joining who (units group1 Join grpMember2), but if you're wondering about the new ArmA command formationLeader (http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=f#569) then the below is pertinent. Note however they won't be permanent formationleaders since they generally won't have an AI of their own, but you -can- use it to activate other scripts and such. In my RUG DSAI I use the formationLeader command to activate one kind of voice. :)

2,3,4 go to THAT BUSH at 6 o'clock!

-> Makes 2 the FormationLeader of 2, 3 & 4.

4, Attack that TANK at 12 o'clock!

-> Makes 4 his own formation leader. Also works for AI-engage.

Etc etc. Basically any action in which the squad leader orders the units to break off from the formation will cause the formationLeader to change. :) Including getting into a vehicle, using the "Take cover" option and many more. Flanking, advancing and staying back does not AFAIK change formationleader.

How so?

Wolfrug out.
Title: Re: Formation leader
Post by: Mandoble on 05 Jan 2008, 12:08:37
This is how I try to change it, and it fails:
Code: [Select]
[] spawn
{
   while {true} do
   {
      if (!isNull new_leader) then
      {     
         grp1 selectLeader new_leader;
         new_leader setFormationTask "LEADER";
         {if (_x != new_leader) then {_x doFollow new_leader}} forEach units grp1;
         new_leader = objNull;
      };
      sleep 2;
   };
};

The leader is changed correctly, but the "old" formation leader remains the same. The resulting formation once the new leader commands the men to return to formation is quite weird, for example, a column where the leader is the last one in the row  ???

EDIT:
attached is a small example mission, everything is done in the init.sqf