Untitled

 avatar
unknown
plain_text
5 months ago
2.1 kB
2
Indexable
if (!isServer) exitWith {};
params ["_vehicle", ["_delay", -1, [0]], ["_parachuteType", "rhs_d6_Parachute", ["string"]]];
private ["_paras", "_crew", "_dir"];


_paras = [];
_crew = crew _vehicle;

// Calculate ejection delay based on speed if no custom value was provided
if (_delay isEqualTo -1) then {
	_delay = (1 / (((speed _vehicle) max 55) / 150));
};

{
	_isCrew = assignedVehicleRole _x;
	if (count _isCrew > 0) then {
		if ((_isCrew select 0) == "Cargo") then {
			_paras pushBack _x;
		};
	};
} forEach _crew;

_vehicle allowDamage false;
_dir = direction _vehicle;

ParaLandSafe = {
	params ["_unit", "_parachuteType"];

	(vehicle _unit) allowDamage false;

	private _type = getText (configFile >> "cfgVehicles" >> backpack _unit >> "ParachuteClass");
	if (!(_type isKindOf "ParachuteBase")) then {
		private _para = createVehicle [_parachuteType, getPosATL _unit, [], 0, "NONE"];
		_para setPosASL (getPosASLVisual _unit);
		[_para, [vectorDirVisual _unit, vectorUpVisual _unit]] remoteExecCall ["setVectorDirAndUp", _unit, true];
		[_unit, _para] remoteExecCall ["moveInDriver", _unit, true];
		// [_unit, _para] remoteExecCall ["assignAsDriver", _unit, true];
		_unit assignAsDriver _para;

		[_unit] allowGetIn true;
		[[_unit], true] remoteExecCall ["orderGetIn", _unit, true];
	};

	waitUntil {
		isTouchingGround _unit || (position _unit select 2) < 1
	};
	_unit action ["eject", vehicle _unit];
	sleep 1;
	_unit setUnitLoadout (_unit getVariable ["Saved_Loadout", []]);
	_unit allowDamage true;
};

{
	_x setVariable ["Saved_Loadout", getUnitLoadout _x];
	removeBackpack _x;
	_x disableCollisionWith _vehicle;
	_x allowDamage false;
	_x disableAI "MOVE";
	[_x] remoteExecCall ["unassignVehicle", _x, true];
	moveOut _x;
	[_x, _dir + 90] remoteExecCall ["setDir", _x, true];
	[_x, [0, 0, -5]] remoteExecCall ["setVelocity", _x, true];
	[_x, _parachuteType] spawn ParaLandSafe;

	sleep _delay;

	_x enableAI "MOVE";
} forEach _paras;

_vehicle allowDamage true;

{
	(group _x) leaveVehicle _vehicle;
	_x enableCollisionWith _vehicle;
} forEach _paras;

Editor is loading...
Leave a Comment