2016-04-06 16:04:51 +00:00
|
|
|
/*
|
|
|
|
Author: IT07
|
|
|
|
|
|
|
|
Description:
|
|
|
|
Gives random weapon attachments to given unit
|
|
|
|
|
|
|
|
Params:
|
|
|
|
_this: ARRAY
|
|
|
|
_this select 0: OBJECT - unit
|
|
|
|
|
2016-04-13 20:28:31 +00:00
|
|
|
Returns: BOOLEAN - true if no errors occured
|
2016-04-06 16:04:51 +00:00
|
|
|
*/
|
|
|
|
|
2016-04-13 20:28:31 +00:00
|
|
|
private ["_done"];
|
2016-04-06 16:04:51 +00:00
|
|
|
_done = false;
|
|
|
|
if (_this isEqualType []) then
|
|
|
|
{
|
2016-04-13 20:28:31 +00:00
|
|
|
_unit = param [0, objNull, [objNull]];
|
|
|
|
if not (isNull _unit) then
|
|
|
|
{
|
|
|
|
// primaryWeapon items
|
|
|
|
private ["_randomPattern","_primaryWeapon"];
|
|
|
|
_randomPattern = [1,0,1,0,1,1,1,1,0,0,1,1,1];
|
|
|
|
_primaryWeapon = primaryWeapon _unit;
|
|
|
|
if (selectRandom _randomPattern isEqualTo 1) then
|
|
|
|
{ // Select random scope
|
|
|
|
private ["_scopes"];
|
|
|
|
_scopes = getArray (configFile >> "CfgWeapons" >> _primaryWeapon >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems");
|
|
|
|
if ([["DynamicLocationInvasion"],["allowTWS"]] call VEMFr_fnc_getSetting isEqualTo 0) then
|
|
|
|
{
|
|
|
|
private["_indexes"];
|
|
|
|
_indexes = [];
|
2016-04-06 16:04:51 +00:00
|
|
|
{
|
2016-04-13 20:28:31 +00:00
|
|
|
if not(_x find "tws" isEqualTo -1) then
|
|
|
|
{
|
|
|
|
_indexes pushBack _forEachIndex;
|
|
|
|
};
|
|
|
|
if not(_x find "TWS" isEqualTo -1) then
|
|
|
|
{
|
|
|
|
_indexes pushBack _forEachIndex;
|
|
|
|
};
|
|
|
|
} forEach _scopes;
|
|
|
|
if (count _indexes > 0) then
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_scopes deleteAt _x;
|
|
|
|
} forEach _indexes;
|
2016-04-06 16:04:51 +00:00
|
|
|
};
|
2016-04-13 20:28:31 +00:00
|
|
|
};
|
|
|
|
_unit addPrimaryWeaponItem (selectRandom _scopes);
|
|
|
|
};
|
|
|
|
if (selectRandom _randomPattern isEqualTo 1) then
|
|
|
|
{ // Select random muzzle
|
|
|
|
_unit addPrimaryWeaponItem (selectRandom (getArray (configFile >> "CfgWeapons" >> _primaryWeapon >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems")));
|
|
|
|
};
|
|
|
|
if (selectRandom _randomPattern isEqualTo 1) then
|
|
|
|
{ // Select random pointer
|
|
|
|
_unit addPrimaryWeaponItem (selectRandom (getArray (configFile >> "CfgWeapons" >> _primaryWeapon >> "WeaponSlotsInfo" >> "PointerSlot" >> "compatibleItems")));
|
|
|
|
};
|
|
|
|
if (selectRandom _randomPattern isEqualTo 1) then
|
|
|
|
{ // Select random bipod
|
|
|
|
_unit addPrimaryWeaponItem (selectRandom (getArray (configFile >> "CfgWeapons" >> _primaryWeapon >> "WeaponSlotsInfo" >> "UnderbarrelSlot" >> "compatibleItems")));
|
|
|
|
};
|
2016-04-06 16:04:51 +00:00
|
|
|
|
2016-04-13 20:28:31 +00:00
|
|
|
private ["_handgunWeapon","_randomPattern"];
|
|
|
|
// handgunWeapon items
|
|
|
|
_handgunWeapon = handgunWeapon _unit;
|
|
|
|
_randomPattern = [1,0,1,0,0,1,0,0,0,0,1,1,1];
|
|
|
|
if (selectRandom _randomPattern isEqualTo 1) then
|
|
|
|
{ // Select random scope
|
|
|
|
_unit addSecondaryWeaponItem (selectRandom (getArray (configFile >> "CfgWeapons" >> _handgunWeapon >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems")));
|
|
|
|
};
|
|
|
|
if (selectRandom _randomPattern isEqualTo 1) then
|
|
|
|
{ // Select random muzzle
|
|
|
|
_unit addSecondaryWeaponItem (selectRandom (getArray (configFile >> "CfgWeapons" >> _handgunWeapon >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems")));
|
|
|
|
};
|
|
|
|
_done = true;
|
|
|
|
};
|
2016-04-06 16:04:51 +00:00
|
|
|
};
|
|
|
|
_done
|