Jump to content
Sign in to follow this  
Micha73

Can AI handle moving in a steerable parachute?

Recommended Posts

Hi all,

 

Another question: When any AI unit does a parachute jump, they just seem to hold their position and not be able to move anywhere. Any group commands such as "Move to" or "Form up/Rejoin Formation" don't have any effect other than the AI reporting in the negative.

 

That's a bit sad, because it prevents the AI from doing proper HAHO (high altitude, high opening) jumps. Is it really only possible to do this as a player? Or is there any way to get them to move somewhere (equivalent to players using WASD keys)?

 

Cheers,

 

M.

Share this post


Link to post
Share on other sites

It can be done.  I've used an edited script of mando_chute.

Easiest way to show implemented is to download @Beerkan Simple ParaDrop Script (latest version).

Replace eject.sqf with the following code.  I have only edited a bit and added the edited mando_chute (all credits to Beerkan & Mandoble) for demonstration:

Spoiler

/*
    Filename: Simple ParaDrop Script v0.99d eject.sqf
    Author: Beerkan
   
    Description:
     A Simple Paradrop Script
    Parameter(s):
    0: VEHICLE  - vehicle that will be doing the paradrop (object)
    1: ALTITUDE - (optional) the altitude where the group will open their parachute (number)
    2: CARGOITEM - (optional) the item or ammocrate you wish to paradrop with the paras
   
   Working Example without Cargo
   0 = [UH80, 100] execVM "eject.sqf"

   Working Example with Supply Crate
   0 = [UH80,150,"B_supplyCrate_F"] execVM "eject.sqf"

   Working example with Prowler Vehicle
   0 = [UH80,150,"B_T_LSV_01_armed_F"] execVM "eject.sqf"

*/ 

if (!isServer) exitWith {};
params [["_vehicle",objnull],["_chuteheight",100],["_item",nil]];
private ["_paras","_landZone","_crew","_dir"];
//_vehicle = _this select 0;
//_chuteheight = if ( count _this > 1 ) then { _this select 1 } else { 100 };// Height to auto-open chute.
//_item = if ( count _this > 2 ) then {_this select 2} else {nil};// Cargo to drop, or nothing if not selected.
_paras = [];
_landZone = getMarkerPos "mk_land";
_crew = crew _vehicle;
{
	private _iscrew = assignedVehicleRole _x;
	if(count _iscrew > 0) then
	{
		if((_iscrew select 0) == "Cargo") then
		{
			_paras pushback _x
		};
	};
} foreach _crew;

//_vehtype = typeof _vehicle;

 //HintSilent composeText [parsetext format["<t size='1'  font='Zeppelin33' shadow = '2' align='left' color='#f0e68c'>Para Units found = <t color='#ff0000'>%1",count _paras]];//Debug

_vehicle allowDamage false;
_dir = direction _vehicle;

/*
//Animate Vehicle Doors to open

If (typeof _vehicle in ["B_Heli_Transport_01_F","B_Heli_Transport_01_camo_F"," B_CTRG_Heli_Transport_01_tropic_F","B_CTRG_Heli_Transport_01_sand_F"]) then
 {_vehicle animateDoor ['door_R',1];_vehicle animateDoor ['door_L',1]};

If (typeof _vehicle in ["I_Heli_Transport_02_F"]) then {_vehicle animateDoor ["CargoRamp_Open",1]};

If (typeof _vehicle in ["B_T_VTOL_01_infantry_F","B_T_VTOL_01_vehicle_F","B_T_VTOL_01_armed_F","B_T_VTOL_01_infantry_blue_F","B_T_VTOL_01_infantry_olive_F","B_T_VTOL_01_vehicle_blue_F","B_T_VTOL_01_armed_blue_F","B_T_VTOL_01_armed_olive_F"]) then {_vehicle animateDoor ["Door_1_source",1]};

If (typeof _vehicle in
["RHS_UH60M_MEV","RHS_UH60M_d"]) then {_vehicle animateDoor ["DoorLB",1];_vehicle animateDoor ["DoorRB",1]};

If (typeof _vehicle in
["B_Heli_Transport_03_F","B_Heli_Transport_03_unarmed_F","B_Heli_Transport_03_black_F","B_Heli_Transport_03_unarmed_green_F"])
then {_vehicle animateDoor ["door_rear_source", 1, false]};
*/

sleep 2;

ParaLandSafe =
{
    params ["_unit","_chuteheight","_landZone"];
    
    (vehicle _unit) allowDamage false;
    if (isPlayer _unit) then {[_unit,_chuteheight] spawn OpenChute};//Set AutoOpen Chute if unit is a player
	[_unit, _landZone, 20] spawn p42_mando_chute;
    waitUntil { isTouchingGround _unit || (position _unit select 2) < 1 };
    _unit action ["eject", vehicle _unit];
    sleep 1;
    _unit setUnitLoadout (_unit getVariable ["Saved_Loadout",[]]);// Reload Saved Loadout
    _unit allowdamage true;// Now you can take damage.
};

OpenChute =
{
    params ["_paraUnit", "_chuteheight"];
    
    waitUntil {(visiblePosition _paraUnit select 2) <= _chuteheight};
    If (vehicle _paraUnit IsEqualto _paraUnit ) then {_paraUnit action ["openParachute", _paraUnit]};//Check if chute is open, if not open it.
};

p42_mando_chute =
{
	/*
		mando_chute.sqf v1.1
		by Mandoble - edited by panther42 2014

		Moves a chute to the landing position

		Parameters:
		unit ejecting: a soldier.
		target position: a 2D or 3D map position.
		radius from target, max distance from target position to aim.
		Type of chute to be used (its class),"" if you dont care.

		Ex.:
		[chuteman, getMarkerPos "mk_land", 20] execVM "p42_mando_chute.sqf";
	*/

	params ["_man","_target_pos","_rad"];
	private["_chuto", "_deg_sec", "_dir", "_ang", "_posc", "_dif", "_difabs", "_turn", "_hspd", "_max_spd", "_deltatime", "_timeold", "_vx", "_vy", "_vh", "_vz", "_acc", "_cone", "_type", "_vvel", "_vdir", "_vup"];
	
	if (count _target_pos == 2) then
	{
		_target_pos append [0];
	};
	_ang = random 360;
	_target_pos = [(_target_pos select 0)+sin(_ang)*_rad,(_target_pos select 1)+cos(_ang)*_rad, 0];

	Sleep 1;
	_deg_sec = 30;
	_max_spd = 4;
	_hspd = _max_spd;
	_acc = 2;
	_vh = 0;
	_vz = -3;
	waitUntil {(vehicle _man != _man) || (!alive _man)};
	if (!alive _man) exitWith {};

	_chuto = vehicle _man;
	_timeold = time;
	_dir = getDir _chuto;
	_chuto setDir _dir;

	while {alive _man && ((visiblePosition _chuto select 2) > 5)} do
	{
		_deltatime = (time-_timeold) max 0.001;
		_timeold = time;
	   
		_posc = visiblePositionASL _chuto;
		_ang = ((_target_pos select 0) - (_posc select 0)) atan2 ((_target_pos select 1) - (_posc select 1));
		if (([_target_pos select 0, _target_pos select 1, 0] distance [_posc select 0, _posc select 1, 0]) > (visiblePosition _chuto select 2)) then
		{
			if ((_vz + 0.5*_deltatime) < -1.5) then
			{
				_vz = _vz + 0.5*_deltatime;
			};
		}
		else
		{
			if ((_vz - 0.5*_deltatime) > -3) then
			{
				_vz = _vz - 0.5*_deltatime;
			};
		};

		_dif = (_ang - _dir);
		if (_dif < 0) then {_dif = 360 + _dif;};
		if (_dif > 180) then {_dif = _dif - 360;};
		_difabs = abs(_dif);

		if (_difabs > 0.01) then
		{
			_turn = _dif/_difabs;
		}
		else
		{
			_turn = 0;
		};

		_dir = _dir + (_turn * ((_deg_sec * _deltatime) min _difabs));

		if (_vh < _hspd) then
		{
			_vh = _vh + (_acc * _deltatime);
		}
		else
		{
			if (_vh > _hspd) then
			{
				_vh = _vh - (_acc * _deltatime);  
			};
		};

		if (_difabs > 45) then
		{
			_hspd = _max_spd / 3;
		}
		else
		{
			_hspd = _max_spd;
		};

		_chuto setVectorDirAndUp [[sin _dir,cos _dir,0],[0,0,1]];
		_chuto setVelocity [sin(_dir)*_vh, cos(_dir)*_vh, _vz];
		
		Sleep 0.01;
	};
};

{
    _x setVariable ["Saved_Loadout",getUnitLoadout _x];// Save Loadout
    removeBackpack _x;
    _x disableCollisionWith _vehicle;// Sometimes units take damage when being ejected.
    _x allowdamage false;// Good Old Arma, they still can take damage on Vehcile exit.
    unassignvehicle _x;
    moveout _x;
    _x setDir (_dir + 90);// Exit the chopper at right angles.
    _x setvelocity [0,0,-5];
    sleep 0.3;//space the Para's out a bit so they're not all bunched up.
    _x addBackPack "B_parachute";// Add parachute on exit of _vehicle. AI will immediately open it, players can open it at any height above _chuteheight
	[_x,_chuteheight,_landZone] spawn ParaLandSafe;	
} forEach _paras;

if (!isNil ("_item")) then
{
	_CargoDrop = _item createVehicle getpos _vehicle;
	_CargoDrop setPos [(position _vehicle select 0) - (sin (getdir _vehicle)* 15), (position _vehicle select 1) - (cos (getdir _vehicle) * 15), (position _vehicle select 2)];
	clearMagazineCargoGlobal _CargoDrop;clearWeaponCargoGlobal _CargoDrop;clearItemCargoGlobal _CargoDrop;clearbackpackCargoGlobal _CargoDrop;
	[objnull, _CargoDrop] call BIS_fnc_curatorobjectedited;
	_CargoDrop addaction ["<t color = '#00FF00'>Open Virtual Arsenal</t>",{["Open",true] call BIS_fnc_arsenal;}];
};

_vehicle allowDamage true;

 

Open the mission in the editor.

Place a marker on the ground, near you, or wherever close so you can see, and name it mk_land.

Save the mission.

Play and observe where the AI troops steer/land.

 

You can edit/use as you see fit.  This was just a "throw together something quick" for demo purpose.

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  

×