ACE3/addons/respawn/functions/fnc_restoreGear.sqf

49 lines
1.2 KiB
Plaintext
Raw Normal View History

2015-01-12 09:07:03 +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:
* [ACE_Player, stored_allGear, active_weapon_muzzle_and_mode] call ace_respawn_fnc_restoreGear
2015-09-26 14:26:41 +00:00
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_allGear", "_activeWeaponAndMuzzle"];
2015-01-12 09:07:03 +00:00
// restore all gear
[_unit, _allGear, true, true] call EFUNC(common,setAllGear);
// restore the last active weapon, muzzle and weaponMode
2015-09-26 14:45:39 +00:00
_activeWeaponAndMuzzle params ["_activeWeapon", "_activeMuzzle", "_activeWeaponMode"];
2015-09-03 16:17:53 +00:00
2015-09-26 14:26:41 +00:00
if (
(_activeMuzzle != "") &&
{_activeMuzzle != _activeWeapon} &&
{_activeMuzzle in getArray (configfile >> "CfgWeapons" >> _activeWeapon >> "muzzles")}
) then {
_unit selectWeapon _activeMuzzle;
} else {
2015-09-26 14:26:41 +00:00
if (_activeWeapon != "") then {
_unit selectWeapon _activeWeapon;
};
};
2015-09-26 14:26:41 +00:00
if (currentWeapon _unit != "") then {
local _index = 0;
2015-09-26 14:26:41 +00:00
while {
_index < 100 && {currentWeaponMode _unit != _activeWeaponMode}
} do {
_unit action ["SwitchWeapon", _unit, _unit, _index];
_index = _index + 1;
};
2015-01-12 09:07:03 +00:00
};