2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-12 09:07:03 +00:00
|
|
|
/*
|
2015-10-03 23:26:38 +00:00
|
|
|
* Author: bux578, commy2
|
2015-09-26 14:26:41 +00:00
|
|
|
* Restores previously saved gear.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: All Gear based on return value of ACE_common_fnc_getAllGear <ARRAY>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2015-10-03 23:26:38 +00:00
|
|
|
* [ACE_Player, stored_allGear, active_weapon_muzzle_and_mode] call ace_respawn_fnc_restoreGear
|
2015-09-26 14:26:41 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-01-12 10:24:58 +00:00
|
|
|
|
2015-10-03 23:26:38 +00:00
|
|
|
params ["_unit", "_allGear", "_activeWeaponAndMuzzle"];
|
2017-09-10 19:42:04 +00:00
|
|
|
TRACE_3("restoreGear",_unit, count _allGear, _activeWeaponAndMuzzle);
|
2015-01-12 09:07:03 +00:00
|
|
|
|
2015-10-03 23:26:38 +00:00
|
|
|
// restore all gear
|
2016-05-14 08:49:09 +00:00
|
|
|
if (!isNil "_allGear") then {
|
2017-09-10 19:42:04 +00:00
|
|
|
_allGear params ["_primaryWeaponArray"];
|
|
|
|
if ((_primaryWeaponArray param [0, ""]) == "ACE_FakePrimaryWeapon") then {
|
|
|
|
TRACE_1("Ignoring fake gun",_primaryWeaponArray);
|
|
|
|
_allGear set [0, []];
|
|
|
|
_activeWeaponAndMuzzle = nil;
|
|
|
|
};
|
2016-05-14 08:49:09 +00:00
|
|
|
_unit setUnitLoadout _allGear;
|
|
|
|
};
|
2015-08-15 16:54:39 +00:00
|
|
|
|
|
|
|
// restore the last active weapon, muzzle and weaponMode
|
2016-05-14 08:49:09 +00:00
|
|
|
if (!isNil "_activeWeaponAndMuzzle") then {
|
|
|
|
// @todo, replace this with CBA_fnc_selectWeapon after next CBA update
|
|
|
|
_activeWeaponAndMuzzle params ["_activeWeapon", "_activeMuzzle", "_activeWeaponMode"];
|
2015-09-03 16:17:53 +00:00
|
|
|
|
2016-05-14 08:49:09 +00:00
|
|
|
if (
|
|
|
|
(_activeMuzzle != "") &&
|
|
|
|
{_activeMuzzle != _activeWeapon} &&
|
|
|
|
{_activeMuzzle in getArray (configFile >> "CfgWeapons" >> _activeWeapon >> "muzzles")}
|
|
|
|
) then {
|
|
|
|
_unit selectWeapon _activeMuzzle;
|
|
|
|
} else {
|
|
|
|
if (_activeWeapon != "") then {
|
|
|
|
_unit selectWeapon _activeWeapon;
|
|
|
|
};
|
2015-08-15 16:54:39 +00:00
|
|
|
};
|
|
|
|
|
2016-05-14 08:49:09 +00:00
|
|
|
if (currentWeapon _unit != "") then {
|
|
|
|
private _index = 0;
|
2015-09-26 14:26:41 +00:00
|
|
|
|
2016-05-14 08:49:09 +00:00
|
|
|
while {
|
2017-05-12 18:12:39 +00:00
|
|
|
_index < 299 && {currentWeaponMode _unit != _activeWeaponMode}
|
2016-05-14 08:49:09 +00:00
|
|
|
} do {
|
|
|
|
_unit action ["SwitchWeapon", _unit, _unit, _index];
|
|
|
|
_index = _index + 1;
|
|
|
|
};
|
2015-08-15 16:54:39 +00:00
|
|
|
};
|
2015-01-12 09:07:03 +00:00
|
|
|
};
|