ACE3/addons/respawn/functions/fnc_restoreGear.sqf

152 lines
3.3 KiB
Plaintext
Raw Normal View History

2015-01-12 09:07:03 +00:00
/*
Name: ACE_Respawn_fnc_removeBody
Author(s):
bux578
Description:
Restores previously saved gear
Parameters:
0: OBJECT - unit
1: ARRAY<STRING> - Array containing all gear
Returns:
VOID
2015-01-12 09:07:03 +00:00
*/
#include "script_component.hpp"
2015-01-12 09:07:03 +00:00
private ["_unit", "_allGear", "_headgear", "_goggles", "_uniform", "_uniformitems", "_vest", "_vestitems", "_backpack", "_backpackitems", "_primaryweapon", "_primaryweaponitems", "_primaryweaponmagazine", "_handgunweapon", "_handgunweaponitems", "_handgunweaponmagazine", "_assigneditems", "_binocular"];
_unit = _this select 0;
_allGear = _this select 1;
// remove all starting gear of a player
removeAllWeapons _unit;
removeGoggles _unit;
removeHeadgear _unit;
removeVest _unit;
removeUniform _unit;
removeAllAssignedItems _unit;
clearAllItemsFromBackpack _unit;
removeBackpack _unit;
_headgear = _allGear select 0;
_goggles = _allGear select 1;
_uniform = _allGear select 2;
_uniformitems = _allGear select 3;
_vest = _allGear select 4;
_vestitems = _allGear select 5;
_backpack = _allGear select 6;
_backpackitems = _allGear select 7;
_primaryweapon = _allGear select 8;
_primaryweaponitems = _allGear select 9;
_primaryweaponmagazine = _allGear select 10;
_secondaryweapon = _allGear select 11;
_secondaryweaponitems = _allGear select 12;
_secondaryweaponmagazine = _allGear select 13;
_handgunweapon = _allGear select 14;
_handgunweaponitems = _allGear select 15;
_handgunweaponmagazine = _allGear select 16;
_assigneditems = _allGear select 17;
_binocular = _allGear select 18;
// start restoring the items
if (_headgear != "") then {
2015-01-13 14:28:03 +00:00
_unit addHeadgear _headgear;
2015-01-12 09:07:03 +00:00
};
if (_uniform != "") then {
2015-01-13 14:28:03 +00:00
_unit forceAddUniform _uniform;
2015-01-12 09:07:03 +00:00
};
if (_vest != "") then {
2015-01-13 14:28:03 +00:00
_unit addVest _vest;
2015-01-12 09:07:03 +00:00
};
if (_goggles != "") then {
2015-01-13 14:28:03 +00:00
_unit addGoggles _goggles;
2015-01-12 09:07:03 +00:00
};
{
2015-01-13 14:28:03 +00:00
_unit addItemToUniform _x;
2015-01-12 09:07:03 +00:00
}forEach _uniformitems;
{
2015-01-13 14:28:03 +00:00
_unit addItemToVest _x;
2015-01-12 09:07:03 +00:00
}forEach _vestitems;
if(format["%1", _backpack] != "") then {
2015-01-13 14:28:03 +00:00
_unit addBackpack _backpack;
_backpa = unitBackpack _unit;
clearMagazineCargoGlobal _backpa;
clearWeaponCargoGlobal _backpa;
clearItemCargoGlobal _backpa;
{
_unit addItemToBackpack _x;
} forEach _backpackitems;
2015-01-12 09:07:03 +00:00
};
// primaryWeapon
if (_primaryweapon != "") then {
2015-01-13 14:28:03 +00:00
{
_unit addMagazine _x;
} forEach _primaryweaponmagazine;
2015-01-12 09:07:03 +00:00
2015-01-13 14:28:03 +00:00
_unit addWeapon _primaryweapon;
2015-01-12 09:07:03 +00:00
2015-01-13 14:28:03 +00:00
{
if (_x != "") then {
_unit addPrimaryWeaponItem _x;
};
} forEach _primaryweaponitems;
2015-01-12 09:07:03 +00:00
};
// secondaryWeapon
if (_secondaryweapon != "") then {
2015-01-13 14:28:03 +00:00
{
_unit addMagazine _x;
} forEach _secondaryweaponmagazine;
2015-01-12 09:07:03 +00:00
2015-01-13 14:28:03 +00:00
_unit addWeapon _secondaryweapon;
2015-01-12 09:07:03 +00:00
2015-01-13 14:28:03 +00:00
{
if (_x != "") then {
_unit addSecondaryWeaponItem _x;
};
} forEach _secondaryweaponitems;
2015-01-12 09:07:03 +00:00
};
// handgun
if (_handgunweapon != "") then {
2015-01-13 14:28:03 +00:00
{
_unit addMagazine _x;
} forEach _handgunweaponmagazine;
2015-01-12 09:07:03 +00:00
2015-01-13 14:28:03 +00:00
_unit addWeapon _handgunweapon;
2015-01-12 09:07:03 +00:00
2015-01-13 14:28:03 +00:00
{
if (_x != "") then {
_unit addHandgunItem _x;
};
} forEach _handgunweaponitems;
2015-01-12 09:07:03 +00:00
};
_assignedItems = _assignedItems - [_binocular];
// items
{_unit linkItem _x} forEach _assignedItems;
_unit addWeapon _binocular;
if ("Laserdesignator" in assignedItems _unit) then {
2015-01-13 14:28:03 +00:00
_unit selectWeapon "Laserdesignator";
if (currentMagazine _unit == "") then {_unit addMagazine "Laserbatteries";};
2015-01-12 09:07:03 +00:00
};