ACE3/addons/parachute/functions/fnc_handleReserve.sqf
GhostIsSpooky 68ed19911a
General - Change object config lookups to configOf (#8795)
* configOf lookups

* forEach, missed configOf

* revert handcuff distance change

Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>

* optimize condition

Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>

* capitalization

Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>

* use object in getVehicleIcon

Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>

* add return comment

Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>

* remove extra brackets

Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>

* add missing brackets

Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>

* add return comment pt2

Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>

* revert to cursorTarget

Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2022-03-08 21:41:21 -06:00

42 lines
1.3 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: joko, Jonas, SilentSpike
* 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"];
private _backpack = backpackContainer _unit;
if (
isNull _backpack &&
{(vehicle _unit) isKindOf "ParachuteBase"} &&
{GETVAR(_unit,GVAR(hasReserve),false)}
) then {
// Case where unit has just opened parachute and reserve should be added
_unit addBackpackGlobal GETVAR(_unit,GVAR(backpackClass),"ACE_NonSteerableReserveParachute");
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)
private _backpackCfg = configOf _backpack;
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),"");
};
};