a3_vemf_reloaded/exile_vemf_reloaded/fn/fn_loadInv.sqf

214 lines
6.3 KiB
Plaintext
Raw Normal View History

2016-06-02 21:18:09 +00:00
/*
2016-07-02 14:24:53 +00:00
Author: IT07
2016-06-02 21:18:09 +00:00
Description:
2016-07-02 14:24:53 +00:00
gives inventory to given units
2016-06-02 21:18:09 +00:00
Param:
_this: ARRAY
_this select 0: ARRAY - units to load inventory for
_this select 1: STRING - must be in missionList
_this select 2: SCALAR - inventory mode
Returns:
BOOLEAN - true if nothing failed
*/
2016-07-02 14:24:53 +00:00
private ["_r","_this0","_this1","_this2"];
params [
["_this0", [], [[]]],
["_this1", "", [""]],
["_this2", 0, [0]]
];
if ((_this1 in ("missionList" call VEMFr_fnc_config)) OR (_this1 isEqualTo "Static")) then
2016-06-02 21:18:09 +00:00
{
2016-07-02 14:24:53 +00:00
scopeName "this";
if (_this2 isEqualTo 0) then // "Militia"
2016-06-02 21:18:09 +00:00
{
2016-07-02 14:24:53 +00:00
private ["_s","_unifs","_headG","_vests","_packs","_lnchers","_rfles","_pstls","_ls"];
// Define settings
_s = [["aiGear"],["aiUniforms","aiHeadGear","aiVests","aiBackpacks","aiLaunchers","aiRifles","aiPistols"]] call VEMFr_fnc_config;
_s params ["_unifs","_headG","_vests","_packs","_lnchers","_rfles","_pstls"];
{
private ["_xx","_g","_a","_pw","_hw"];
_xx = _x;
// Strip it
removeAllWeapons _xx;
removeAllItems _xx;
if ("removeAllAssignedItems" call VEMFr_fnc_config isEqualTo 1) then
{
removeAllAssignedItems _xx;
};
removeVest _xx;
removeBackpack _xx;
removeGoggles _xx;
removeHeadGear _xx;
if (count _unifs > 0) then
{
removeUniform _xx;
_g = selectRandom _unifs;
_xx forceAddUniform _g; // Give the poor naked guy some clothing :)
};
if (_this1 isEqualTo "BaseAttack") then
{
_xx addBackpack "B_Parachute";
};
_g = selectRandom _headG;
_xx addHeadGear _g;
_g = selectRandom _vests;
_xx addVest _g;
_ls = [[_this1],["allowLaunchers","hasLauncherChance"]] call VEMFr_fnc_config;
if ((_ls select 0) isEqualTo 1) then
{
private ["_lc"];
_lc = _ls select 1;
if ((_lc isEqualTo 100) OR ((ceil random (100 / _lc) isEqualTo (ceil random (100 / _lc))))) then
2016-06-02 21:18:09 +00:00
{
2016-07-02 14:24:53 +00:00
if not(_this1 isEqualTo "BaseAttack") then
2016-06-02 21:18:09 +00:00
{
2016-07-02 14:24:53 +00:00
_g = selectRandom _packs;
_xx addBackpack _g;
2016-06-02 21:18:09 +00:00
};
2016-07-02 14:24:53 +00:00
_g = selectRandom _lnchers;
private ["_a"];
_a = getArray (configFile >> "cfgWeapons" >> _g >> "magazines");
if (count _a > 2) then
2016-06-02 21:18:09 +00:00
{
2016-07-02 14:24:53 +00:00
_a resize 2;
2016-06-02 21:18:09 +00:00
};
2016-07-02 14:24:53 +00:00
for "_i" from 0 to (2 + (round random 1)) do
{
_xx addMagazine (selectRandom _a);
};
_xx addWeapon _g;
};
};
2016-06-02 21:18:09 +00:00
2016-07-02 14:24:53 +00:00
// Select a random weapon
_pw = selectRandom _rfles;
_hw = selectRandom _pstls;
// Give this guy some ammo
_g = [_xx, _pw, "", _hw] call VEMFr_fnc_giveAmmo;
if (isNil "_g") then
{
["fn_loadInv", 0, format["FAILED to give ammo to AI: %1", _xx]] ExecVM "exile_vemf_reloaded\sqf\log.sqf";
};
_xx addWeapon _pw;
_xx selectWeapon _pw;
_xx addWeapon _hw;
// Give this guy some weaponItems
_g = [_xx] call VEMFr_fnc_giveWeaponItems;
if not _g then
{
["fn_loadInv", 0, format["FAILED to giveWeaponItems to %1", _xx]] ExecVM "exile_vemf_reloaded\sqf\log.sqf";
};
} forEach _this0;
_r = true;
breakOut "this";
};
2016-06-02 21:18:09 +00:00
2016-07-02 14:24:53 +00:00
if (_this2 isEqualTo 1) then // Regular police
{
private ["_s","_headG","_vests","_unifs","_rfles","_pstls","_packs"];
_s = [["policeConfig"],["headGear","vests","uniforms","rifles","pistols","backpacks"]] call VEMFr_fnc_config;
_s params ["_headG","_vests","_unifs","_rfles","_pstls","_packs"];
{
private ["_xx","_g","_pw","_hw"];
_xx = _x;
// Strip it
removeAllWeapons _xx;
removeAllItems _xx;
if ("removeAllAssignedItems" call VEMFr_fnc_config isEqualTo 1) then
{
removeAllAssignedItems _xx;
};
removeUniform _xx;
removeVest _xx;
removeBackpack _xx;
removeGoggles _xx;
removeHeadGear _xx;
_g = selectRandom _headG;
_xx addHeadGear _g;
_g = selectRandom _vests;
_xx addVest _g;
_g = selectRandom _unifs;
_xx forceAddUniform _g;
2016-06-02 21:18:09 +00:00
2016-07-02 14:24:53 +00:00
_pw = selectRandom _rfles;
_hw = selectRandom _pstls;
// Give this guy some ammo
_g = [_xx, _pw, "", _hw] call VEMFr_fnc_giveAmmo;
if (isNil "_g") then
{
["fn_loadInv", 0, format["FAILED to give ammo to AI: %1", _xx]] ExecVM "exile_vemf_reloaded\sqf\log.sqf";
};
_xx addWeapon _pw;
_xx selectWeapon _pw;
_xx addWeapon _hw;
if not(_this1 isEqualTo "BaseAttack") then
{
_xx addBackPack (selectRandom _packs);
} else
{
_xx addBackpack "B_Parachute";
};
// Give this guy some weaponItems
_g = [_xx] call VEMFr_fnc_giveWeaponItems;
if (isNil "_g") then
{
["fn_loadInv", 0, format["FAILED to giveWeaponItems to %1", _xx]] ExecVM "exile_vemf_reloaded\sqf\log.sqf";
};
} forEach _this0;
_r = true;
breakOut "this";
2016-06-02 21:18:09 +00:00
};
2016-07-02 14:24:53 +00:00
if (_this2 isEqualTo 2) then // S.W.A.T.
{
private ["_s","_rfles","_pstls"];
_s = [["policeConfig"],["rifles","pistols"]] call VEMFr_fnc_config;
_s params ["_rfles","_pstls"];
{
private ["_xx","_g","_pw","_hw"];
_xx = _x;
// Strip it
if ("removeAllAssignedItems" call VEMFr_fnc_config isEqualTo 1) then { removeAllAssignedItems _xx };
removeAllItems _xx;
removeAllWeapons _xx;
removeBackpack _xx;
removeGoggles _xx;
removeHeadGear _xx;
removeUniform _xx;
removeVest _xx;
_xx addHeadGear "H_HelmetB_light_black";
_xx addGoggles "G_Balaclava_blk";
_xx addVest "V_PlateCarrier2_blk";
_xx forceAddUniform "Exile_Uniform_ExileCustoms";
_pw = selectRandom _rfles;
_hw = selectRandom _pstls;
// Give this guy some ammo
_g = [_xx, _pw, "", _hw] call VEMFr_fnc_giveAmmo;
if (isNil "_g") then
{
["fn_loadInv", 0, format["FAILED to give ammo to AI: %1", _xx]] ExecVM "exile_vemf_reloaded\sqf\log.sqf";
};
_xx addWeapon _pw;
_xx selectWeapon _pw;
_xx addWeapon _hw;
if (_this1 isEqualTo "BaseAttack") then { _xx addBackpack "B_Parachute" };
// Give this guy some weaponItems
_g = [_xx] call VEMFr_fnc_giveWeaponItems;
if (isNil "_g") then
{
["fn_loadInv", 0, format["FAILED to giveWeaponItems to %1", _xx]] ExecVM "exile_vemf_reloaded\sqf\log.sqf";
};
} forEach _this0;
_r = true;
};
};
_r