2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2017-12-02 17:02:16 +00:00
|
|
|
/*
|
2023-08-17 10:02:17 +00:00
|
|
|
* Author: joko, Jonas, kymckay
|
2017-12-02 17:02:16 +00:00
|
|
|
* Cache reserve parachute on player unit when their inventory changes and add it when they open their parachute
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [player] call ace_parachute_fnc_handleReserve
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_unit"];
|
2022-03-09 03:41:21 +00:00
|
|
|
private _backpack = backpackContainer _unit;
|
2017-12-02 17:02:16 +00:00
|
|
|
|
|
|
|
if (
|
2022-03-09 03:41:21 +00:00
|
|
|
isNull _backpack &&
|
2017-12-02 17:02:16 +00:00
|
|
|
{(vehicle _unit) isKindOf "ParachuteBase"} &&
|
|
|
|
{GETVAR(_unit,GVAR(hasReserve),false)}
|
|
|
|
) then {
|
|
|
|
// Case where unit has just opened parachute and reserve should be added
|
2017-12-30 13:38:45 +00:00
|
|
|
_unit addBackpackGlobal GETVAR(_unit,GVAR(backpackClass),"ACE_NonSteerableReserveParachute");
|
2017-12-02 17:02:16 +00:00
|
|
|
SETVAR(vehicle _unit,GVAR(canCut),true); // Mark the parachute cuttable since reserve is present
|
|
|
|
} else {
|
|
|
|
// Case where inventory has changed otherwise (including when reserve is added)
|
2022-03-09 03:41:21 +00:00
|
|
|
private _backpackCfg = configOf _backpack;
|
2017-12-02 17:02:16 +00:00
|
|
|
private _hasReserve = getNumber (_backpackCfg >> "ace_hasReserveParachute") == 1;
|
|
|
|
|
|
|
|
// Cache reserve parachute state and class when backpack changes
|
|
|
|
SETVAR(_unit,GVAR(hasReserve),_hasReserve);
|
|
|
|
if (_hasReserve) then {
|
|
|
|
SETVAR(_unit,GVAR(backpackClass),getText (_backpackCfg >> "ace_reserveParachute"));
|
|
|
|
} else {
|
|
|
|
SETVAR(_unit,GVAR(backpackClass),"");
|
|
|
|
};
|
|
|
|
};
|