mirror of
https://github.com/IT07/a3_vemf_reloaded.git
synced 2024-08-30 16:52:11 +00:00
81 lines
3.0 KiB
Plaintext
81 lines
3.0 KiB
Plaintext
/*
|
|
Author: IT07
|
|
|
|
Description:
|
|
Gives random weapon attachments to given unit
|
|
|
|
Params:
|
|
_this: ARRAY
|
|
_this select 0: OBJECT - unit
|
|
|
|
Returns: BOOLEAN - true if no errors occured
|
|
*/
|
|
|
|
private ["_done"];
|
|
_done = false;
|
|
if (_this isEqualType []) then
|
|
{
|
|
_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 = [];
|
|
{
|
|
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;
|
|
};
|
|
};
|
|
_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")));
|
|
};
|
|
|
|
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;
|
|
};
|
|
};
|
|
_done
|