Jump to content
avibird 1

How to add a parachute for playable units when they jump out or a air vehicle gets shot down.

Recommended Posts

This for a CO mission with playable/switchable unts.  Back in the tha day with OFP units would automatically deploy a parachute if jumping out of a plane or helicopter. When playing with AI units it's a pain in the ass or almost impossible to try get parachutes on each of the AI while you're vehicle is being shot down. I was trying fooling around with some code to get a parachute on any playable unit that is jumping out of a vehicle in the air. 

 

Playable units  moveInDriver (createVehicle ["Steerable_Parachute_F", (position unit ), [], 0, "CAN_COLLIDE"]);

 

I was thinking of calling the code in a gamelogic rather than a radio trigger due to the the time it may take once your be vehicle is going down. 

Avibird 

 

Share this post


Link to post
Share on other sites

If you just want to put a backpack with a parachute on the unit at the time when it falls to the ground, then it's pretty simple:

{
	removeBackpack _x;
	_x addBackpack "B_parachute";
} forEach playableUnits;

A parachute is added to the AI unit in the same way.


I can share my version of parachuting the whole group.
All known bugs when exiting a helicopter in the air in this script have already been fixed. The helicopter will not land on the ground and will not hover in the air.
 

Spoiler

/*
    Filename: Simple ParaDrop Script v0.99d eject.sqf
    Author: Beerkan 
	Revision: Ibragim

    Description:
    A Simple Paradrop Script which will eject ALL assigned units (except crew) from a vehicle
    add a parachute and when landed will respawn their original backpacks.

    Parameter(s):
    0: VEHICLE  - vehicle that will be doing the paradrop (object)
    1: ALTITUDE - the altitude where the group & Cargo Item (if used) will open their parachute (number)    
	3: PARAS - the units to drop.
	
    Working Example
    0 = 
		[
			_vehicleToParadropFrom, 
			selectMax [40, ((position _vehicleToParadropFrom select 2) * 0.66)], 
			nil, 
			_unitsToParadrop
		] execVM "eject.sqf"

*/

if (!isServer) exitWith {};
private ["_paras","_vehicle","_item"];

_vehicle = _this select 0;
_paras = [];
_crew = crew _vehicle;
_paras = _this select 3;
_chuteheight = _this select 1;// Height to auto-open chute
_item = _this select 2;// Cargo to drop, or nothing if not selected.
_vehicle allowDamage false;
_dir = direction _vehicle;


if (player in _paras) then 
	{
		_paras = [player] + (_paras - [player]);
	};


[_paras, _vehicle] call 
	{
		params ["_paras", "_vehicle"];
		
			{
				_x hideObjectGlobal true;
				_x setUnitFreefallHeight _chuteheight;				
				_x disableCollisionWith _vehicle;
				_x allowDamage false; 
				unassignVehicle _x; 
				_x moveOut _vehicle;
				_x attachTo [_vehicle, [0, -10, -8]];
			} forEach _paras;
	};

ParaLandSafe =
	{
		private ["_unit"];
		_unit = _this select 0;
		_chuteheight = _this select 1;
		(vehicle _unit) allowDamage false;
		[_unit,_chuteheight] spawn AddParachute;//Set AutoOpen Chute if unit is a player
		waitUntil { sleep 0.2; isTouchingGround _unit || (position _unit select 2) < 1 };
		_unit action ["eject", vehicle _unit];
		_unit setUnitFreefallHeight -1;
		sleep 1;
		_unit setUnitLoadout (_unit getVariable ["Saved_Loadout",[]]);// Reload Saved Loadout
		_unit allowdamage true;// Now you can take damage.
	};

AddParachute =
	{
		private ["_paraUnit"];
		_paraUnit = _this select 0;
		_chuteheight = _this select 1;
		waitUntil { sleep 0.2; (position _paraUnit select 2) < _chuteheight};
		//_paraUnit addBackPack "B_parachute";// Add parachute
		if (vehicle _paraUnit IsEqualto _paraUnit ) then {_paraUnit action ["openParachute", _paraUnit]};//Check if players chute is open, if not open it.
	};


_dummy = createVehicle ["C_Soldier_VR_F", position player vectorAdd [0,0, 2000], [], 0, "CAN_COLLIDE"];
_dummy disableAI "ALL";
_dummy allowDamage false;
_dummy setCaptive true;
_dummy enableSimulation false;
_dummy hideObject true;

	{
		_loadOut = getUnitLoadout _x;
		
		if (getText (configFile >> "CfgVehicles" >> (_loadOut select 5 select 0 ) >> "backpackSimulation") in ["ParachuteSteerable"]) then 
			{
				_loadOut set [5, ""];
			};
		
		_x setVariable ["Saved_Loadout", _loadOut];// Save Loadout
		
		if !(getText (configFile >> "CfgVehicles" >> backpack _x >> "backpackSimulation") in ["ParachuteSteerable"]) then 
			{
				_parachuteBag = (((everyBackpack _vehicle)) select {getText (configFile >> "CfgVehicles" >> typeOf _x >> "backpackSimulation") in ["ParachuteSteerable"]}) select 0;
				
				removeBackpack _x;
				
				_x addBackpack typeOf _parachuteBag;
				_dummy action ["TakeBag", _parachuteBag];
			};
		
		//
		//_x disableCollisionWith _vehicle;// Sometimes units take damage when being ejected.
		//_x allowdamage false;// Good Old Arma, they still can take damage on Vehcile exit.
		[_x] allowGetIn false;		
		//moveout _x;
		//_x action ["eject", _vehicle];
		//unassignvehicle _x;
		[_x] allowGetIn false;
		
		detach _x;
		
		
		_x hideObjectGlobal false;
		
		_x setDir (_dir + 90);// Exit the chopper at right angles.
		_x setvelocity [0,0,-5];// Add a bit of gravity to move unit away from _vehicle
		sleep 0.5;//space the Para's out a bit so they're not all bunched up.
		[_x,_chuteheight] spawn ParaLandSafe;
	} forEach _paras;

//(_paras select 0) leaveVehicle _vehicle;
_paras allowGetIn true;

/*if (!isNil ("_item")) then
	{
		_CargoDrop = _item createVehicle getpos _vehicle;
		_CargoDrop allowDamage false;
		_CargoDrop disableCollisionWith _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;
		waitUntil {(position _item select 2) <= _chuteheight};
		[objnull, _CargoDrop] call BIS_fnc_curatorobjectedited;
		_CargoDrop addaction ["<t color = '#00FF00'>Open Virtual Arsenal</t>",{["Open",true] call BIS_fnc_arsenal;}];
	};*/

_vehicle allowDamage true;
	{
		_x enableCollisionWith _vehicle;
	} forEach _paras;

sleep 2;
	
deleteVehicle _dummy;

 

 

Make sure that the helicopter pilot is not in the group that parachutes out of him.

  • Like 1

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

×