Ammo required before adding weapons

This commit is contained in:
IT07 2016-05-26 15:51:55 +02:00
parent b6d40ea551
commit 95cb4a806e

View File

@ -7,6 +7,9 @@
Params: Params:
_this: ARRAY _this: ARRAY
_this select 0: OBJECT - unit to give ammo to _this select 0: OBJECT - unit to give ammo to
_this select 1: STRING - primaryWeapon classname
_this select 2: STRING - secondaryWeapon classname
_this select 3: STRING - handGunWeapon classname
Returns: Returns:
BOOLEAN - true if successful BOOLEAN - true if successful
@ -18,28 +21,29 @@ if (_this isEqualType []) then
{ {
private ["_unit"]; private ["_unit"];
_unit = param [0, objNull, [objNull]]; _unit = param [0, objNull, [objNull]];
_classPrimary = param [1, "", [""]];
_classSecondary = param [2, "", [""]];
_classHandgun = param [3, "", [""]];
if not isNull _unit then if not isNull _unit then
{ {
if local _unit then if local _unit then
{ {
if not(primaryWeapon _unit isEqualTo "") then if not(_classPrimary isEqualTo "") then
{ {
private ["_weapon","_mag","_magMass","_vestMass","_itemMass"]; private ["_mag"];
_weapon = primaryWeapon _unit; _mag = selectRandom (getArray (configFile >> "CfgWeapons" >> _classPrimary >> "magazines"));
_mag = selectRandom (getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines"));
for "_m" from 1 to 5 do for "_m" from 1 to 5 do
{ {
if not(_unit canAdd _mag) exitWith {}; if not(_unit canAdd _mag) exitWith {};
_unit addItem _mag; _unit addItem _mag;
}; };
}; };
if not (secondaryWeapon _unit isEqualTo "") then if not (_classSecondary isEqualTo "") then
{ {
if not(backPack _unit isEqualTo "") then if not(backPack _unit isEqualTo "") then
{ {
private ["_weapon","_mag","_magMass"]; private ["_mag"];
_weapon = secondaryWeapon _unit; _mag = selectRandom (getArray (configFile >> "CfgWeapons" >> _classSecondary >> "magazines"));
_mag = selectRandom (getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines"));
for "_m" from 1 to 3 do for "_m" from 1 to 3 do
{ {
if not(_unit canAdd _mag) exitWith {}; if not(_unit canAdd _mag) exitWith {};
@ -47,11 +51,10 @@ if (_this isEqualType []) then
}; };
}; };
}; };
if not (handGunWeapon _unit isEqualTo "") then if not (_classHandgun isEqualTo "") then
{ {
private ["_weapon","_mag","_magMass","_uniformMass"]; private ["_mag"];
_weapon = handGunWeapon _unit; _mag = selectRandom (getArray (configFile >> "CfgWeapons" >> _classHandgun >> "magazines"));
_mag = selectRandom (getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines"));
for "_m" from 1 to 4 do for "_m" from 1 to 4 do
{ {
if not(_unit canAdd _mag) exitWith {}; if not(_unit canAdd _mag) exitWith {};