ACE3/addons/aircraft/functions/fnc_initEjectAction.sqf
PabstMirror e8693c8db9
Various - Use configOf command for faster lookup (#8100)
* configOf

* replace some use of CBA_fnc_getObjectConfig
2021-02-18 12:58:08 -06:00

49 lines
1.3 KiB
Plaintext

#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];