Jump to content
Sign in to follow this  
BEAKSBY

How do I keep my Helicopters in Formation?

Recommended Posts

What I've tried below is not working?

I don't think formations for soldiers works on helicopters?

switch(side player)do
{
   case WEST:{_planeType = "B_Heli_Light_01_armed_F"};
   case EAST:{_planeType = "O_Heli_Light_02_F"};
};
_grp = createGroup (side player);

for "_i" from   0 to 2  do {
   sleep .1;
   _spos = [(getPosATL player select 0) - (sin _planeDirection) * _planeDistance, (getPosATL player select 1) - (cos _planeDirection) * _planeDistance , 50];    
   if (_i == 1) then {
       _plane1Pos = [_spos, _planeSpread,_planeDirection -90] call bis_fnc_relpos;
       _plane1Pos set [2,_flyHeight];
       _spos = _plane1Pos;
   };
   if (_i == 2) then {
       _plane1Pos = [_spos, _planeSpread,_planeDirection +90] call bis_fnc_relpos;
       _plane1Pos set [2,_flyHeight];
       _spos = _plane1Pos;    
   };    
    _spos set [2,_flyHeight];
_plane = createVehicle [_planeType, _spos, [], 0, "FLY"];

   //_grp setSpeedMode "FULL"; 
   _plane setDir _planeDirection;
   _plane flyInHeight _flyHeight;    
/* 
// PRESET VELOCITY
   _vel = velocity _plane;
   _plane setVelocity [
       (_vel select 0) + (sin _planeDirection * _speed), 
       (_vel select 1) + (cos _planeDirection * _speed), 
       (_vel select 2)
   ];
*/
//    if (side player == WEST) then {_plane setAmmo ["missiles_DAR", 0];
//	} else { _plane setAmmo ["missiles_DAGR", 0]};
   _plane allowDamage _allowDamage; 
   _plane setSkill 1; 

   // MAY HAVE TO REMOVE CREW FIRST
   {deletevehicle _x} foreach (crew _plane); 
   _crew = [_plane,_grp] call bis_fnc_spawncrew;
   //_grp setFormation "LINE"; 
   _planeArray = _planeArray + [_plane]; 
   _plane sideChat "Air Cav on it's way!"; 
};

   hint format["%1 %2", _planeArray select 1, _planeArray select 2];

// PLANES ATTACK TARGETS
_myNearestEnemy = player findNearestEnemy player;
_heliAttackTime = time;
_grp setFormation "LINE"; 

while {(time - _heliAttackTime) < 120} do {

// KEEP ALL THE SAME ALTITUDE 
{_x flyInHeight _flyHeight} forEach _planeArray;	

// GET PLANE TO KEEP FLIGHT DISATNCE AND POSITION WITH MIDDLE PLANE
{
	_middlePlane = _planeArray select 0;
	if (((_middlePlane distance _x) > (_planeSpread +2)) or ((_middlePlane distance _x) < (_planeSpread -2))) then {
				if (_x == _planeArray select 1) then {_sidePlaneDirection = -90} else {_sidePlaneDirection = 90};
				_x setPosATL [getPosATL _middlePlane, _planeSpread, getDir _middlePlane + _sidePlaneDirection] call bis_fnc_relpos;
				//_x setDir getDir _middlePlane;
		};
} forEach [_planeArray select 1, _planeArray select 2];

  hint format ["%1 \n %2 \n formation: %3", (_planeArray select 0) distance (_planeArray select 1), (_planeArray select 0) distance (_planeArray select 2),  formation _grp];

//_grp setFormation "LINE"; 

if (alive _myNearestEnemy) then {
	{	
		_x doTarget _myNearestEnemy;
		_x doFire _myNearestEnemy;
		//_x addeventhandler  ["fired",{(_this select 0) sideChat format ["assignedTarget : %1 ", assignedTarget (_this select 0)]}];
	}forEach _planeArray;
} else {_myNearestEnemy = player findNearestEnemy player};	
sleep .5;	
};

Share this post


Link to post
Share on other sites

You could do that with bis_fnc_unitCapture and unitPlay, but you would have to record the movement with yourself piloting. Also, depending on the number of helicopters, it might make your mission laggy. I recently made a script to stop unitPlay mid-animation: http://forums.bistudio.com/showthread.php?183623-Is-there-any-way-to-prematurely-stop-unitPlay-without-killing-the-animated-unit if you would like that functionality.

Share this post


Link to post
Share on other sites

forget about using unitplay with formations... as you will record different flights and never will be as accurate as you need.

If you want formation attacks like it could be done in a CoD cutscene. The only way I know is to use attachTo, while updating dir and vector of the escort choppers constantly to match the leader, and it will be tacky, as it is on CoD....

Share this post


Link to post
Share on other sites

If you use barbolani's method, make sure to have the helicopters initialize as flying (formation: flying, elevation: >0) so the engine is on and the rotors spin.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×