ACE3/addons/aircraft/functions/fnc_initEjectAction.sqf

49 lines
1.3 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
/*
* Author: Dystopian
* Add Eject action to vehicle if needed.
*
* Arguments:
* 0: Vehicle <OBJECT>
*
* Return Value:
* None
*
* Example:
* [cursorObject] call ace_aircraft_fnc_initEjectAction
*
* Public: No
*/
params ["_vehicle"];
if (unitIsUAV _vehicle) exitWith {};
private _config = configOf _vehicle;
private _addAction = false;
if (0 == getNumber (_config >> "driverCanEject")) then {
TRACE_2("eject action",typeOf _vehicle,"driver");
_vehicle setVariable [QGVAR(ejectAction_driver_[]), true];
_addAction = true;
};
{
{
_x params ["", "_role", "", "_turretPath"];
if (0 == getNumber (([_config, _turretPath] call CBA_fnc_getTurret) >> "canEject")) then {
TRACE_2("eject action",typeOf _vehicle,_turretPath);
_vehicle setVariable [format [QGVAR(ejectAction_%1_%2), _role, _turretPath], true];
_addAction = true;
};
} forEach fullCrew [_vehicle, _x, true];
} forEach ["gunner", "commander", "turret"];
if (!_addAction) exitWith {};
GVAR(ejectActionParams) params ["_params", "_text", "_picture"];
private _actionID = _vehicle addAction _params;
_vehicle setUserActionText [_actionID, _text, "", _picture];
_vehicle setVariable [QGVAR(ejectAction), _actionID];