a3_vemf_reloaded/exile_vemf_reloaded/fn/fn_giveWeaponItems.sqf

65 lines
2.4 KiB
Plaintext
Raw Normal View History

2016-06-02 21:18:09 +00:00
/*
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
*/
2016-07-02 14:24:53 +00:00
private ["_r","_p","_w","_a","_bin"];
_u = param [0,objNull,[objNull]];
if not (isNull _u) then
2016-06-02 21:18:09 +00:00
{
2016-07-02 14:24:53 +00:00
_p = [1,0,1,0,1,1,1,1,0,0,1,1,1];
_w = primaryWeapon _u;
if ((selectRandom _p) isEqualTo 1) then
{ // Select random scope
_a = getArray (configFile >> "CfgWeapons" >> _w >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems");
if (("allowTWS" call VEMFr_fnc_config) isEqualTo 0) then
{
_bin = [];
{
if (((toLower _x) find "tws") > -1) then
2016-06-02 21:18:09 +00:00
{
2016-07-02 14:24:53 +00:00
_bin pushBack _x;
};
} forEach _a;
{
_a deleteAt (_a find _x);
} forEach _bin;
2016-06-02 21:18:09 +00:00
};
2016-07-02 14:24:53 +00:00
_u addPrimaryWeaponItem (selectRandom _a);
};
if ((selectRandom _p) isEqualTo 1) then
{ // Select random muzzle
_u addPrimaryWeaponItem (selectRandom (getArray (configFile >> "CfgWeapons" >> _w >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems")));
};
if ((selectRandom _p) isEqualTo 1) then
{ // Select random pointer
_u addPrimaryWeaponItem (selectRandom (getArray (configFile >> "CfgWeapons" >> _w >> "WeaponSlotsInfo" >> "PointerSlot" >> "compatibleItems")));
};
if ((selectRandom _p) isEqualTo 1) then
{ // Select random bipod
_u addPrimaryWeaponItem (selectRandom (getArray (configFile >> "CfgWeapons" >> _w >> "WeaponSlotsInfo" >> "UnderbarrelSlot" >> "compatibleItems")));
};
2016-06-02 21:18:09 +00:00
2016-07-02 14:24:53 +00:00
// handgunWeapon items
_w = handgunWeapon _u;
_p = [1,0,1,0,0,1,0,0,0,0,1,1,1];
if ((selectRandom _p) isEqualTo 1) then
{ // Select random scope
_u addHandgunItem (selectRandom (getArray (configFile >> "CfgWeapons" >> _w >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems")));
};
if ((selectRandom _p) isEqualTo 1) then
{ // Select random muzzle
_u addHandgunItem (selectRandom (getArray (configFile >> "CfgWeapons" >> _w >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems")));
2016-06-02 21:18:09 +00:00
};
2016-07-02 14:24:53 +00:00
_r = true;
2016-06-02 21:18:09 +00:00
};
2016-07-02 14:24:53 +00:00
_r