2015-08-28 05:23:34 +00:00
|
|
|
/*
|
|
|
|
Original credit goes to WAI: https://github.com/nerdalertdk/WICKED-AI
|
|
|
|
Edited by eraser1
|
2015-08-27 07:44:23 +00:00
|
|
|
|
2015-08-28 05:23:34 +00:00
|
|
|
[
|
|
|
|
_weapons,
|
|
|
|
_tools,
|
|
|
|
_items,
|
|
|
|
_backpacks
|
|
|
|
]
|
|
|
|
Each argument can be an explicitly defined array of weapons with a number to spawn, or simply a number and weapons defined in the config.sqf are used
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
private ["_ammo","_tool","_box","_weapon","_item","_backpack","_toolCount","_itemCount","_backpackCount","_wepCount","_weps","_tools","_items","_backpacks"];
|
|
|
|
|
|
|
|
_box = _this select 0;
|
2015-08-27 07:44:23 +00:00
|
|
|
|
|
|
|
// WEAPONS
|
|
|
|
if(typeName (_this select 1) == "ARRAY") then {
|
2015-08-28 05:23:34 +00:00
|
|
|
_wepCount = (_this select 1) select 0;
|
|
|
|
_weps = (_this select 1) select 1;
|
2015-08-27 07:44:23 +00:00
|
|
|
} else {
|
2015-08-28 05:23:34 +00:00
|
|
|
_wepCount = _this select 1;
|
|
|
|
_weps = DMS_boxWeapons;
|
2015-08-27 07:44:23 +00:00
|
|
|
};
|
|
|
|
// TOOLS
|
|
|
|
if(typeName (_this select 2) == "ARRAY") then {
|
2015-08-28 05:23:34 +00:00
|
|
|
_toolCount = (_this select 2) select 0;
|
|
|
|
_tools = (_this select 2) select 1;
|
2015-08-27 07:44:23 +00:00
|
|
|
} else {
|
2015-08-28 05:23:34 +00:00
|
|
|
_toolCount = _this select 2;
|
|
|
|
_tools = DMS_boxTools;
|
2015-08-27 07:44:23 +00:00
|
|
|
};
|
|
|
|
// RANDOM
|
|
|
|
if(typeName (_this select 3) == "ARRAY") then {
|
2015-08-28 05:23:34 +00:00
|
|
|
_itemCount = (_this select 3) select 0;
|
|
|
|
_items = (_this select 3) select 1;
|
2015-08-27 07:44:23 +00:00
|
|
|
} else {
|
2015-08-28 05:23:34 +00:00
|
|
|
_itemCount = _this select 3;
|
|
|
|
_items = DMS_boxItems;
|
2015-08-27 07:44:23 +00:00
|
|
|
};
|
|
|
|
// BACKPACK
|
|
|
|
if(typeName (_this select 4) == "ARRAY") then {
|
2015-08-28 05:23:34 +00:00
|
|
|
_backpackCount = (_this select 4) select 0;
|
|
|
|
_backpacks = (_this select 4) select 1;
|
2015-08-27 07:44:23 +00:00
|
|
|
} else {
|
2015-08-28 05:23:34 +00:00
|
|
|
_backpackCount = _this select 4;
|
|
|
|
_backpacks = DMS_boxBackpacks;
|
2015-08-27 07:44:23 +00:00
|
|
|
};
|
|
|
|
|
2015-08-28 05:23:34 +00:00
|
|
|
|
2015-08-27 07:44:23 +00:00
|
|
|
if(DMS_DEBUG) then {
|
2015-08-28 05:23:34 +00:00
|
|
|
diag_log format["DMS :: Filling a dynamic crate with %1 guns, %2 tools, %3 items and %4 backpacks",_wepCount,_toolCount,_itemCount,_backpackCount];
|
2015-08-27 07:44:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-08-28 05:23:34 +00:00
|
|
|
if ((_wepCount>0) && {count _weps>0}) then {
|
2015-08-27 07:44:23 +00:00
|
|
|
|
2015-08-28 05:23:34 +00:00
|
|
|
for "_i" from 1 to _wepCount do {
|
|
|
|
_weapon = _weps call BIS_fnc_selectRandom;
|
|
|
|
_ammo = _weapon call DMS_selectMagazine;
|
|
|
|
_box addWeaponCargoGlobal _weapon;
|
|
|
|
_box addMagazineCargoGlobal [_ammo, (2 + floor(random 3))];
|
2015-08-27 07:44:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-08-28 05:23:34 +00:00
|
|
|
if ((_toolCount > 0) && {count _tools>0}) then {
|
2015-08-27 07:44:23 +00:00
|
|
|
|
2015-08-28 05:23:34 +00:00
|
|
|
for "_i" from 1 to _toolCount do {
|
|
|
|
_tool = _tools call BIS_fnc_selectRandom;
|
|
|
|
_box addItemCargoGlobal _tool;
|
2015-08-27 07:44:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-08-28 05:23:34 +00:00
|
|
|
if ((_itemCount > 0) && {count _items>0}) then {
|
2015-08-27 07:44:23 +00:00
|
|
|
|
2015-08-28 05:23:34 +00:00
|
|
|
for "_i" from 1 to _itemCount do {
|
|
|
|
_item = _items call BIS_fnc_selectRandom;
|
|
|
|
_box addItemCargoGlobal _item;
|
2015-08-27 07:44:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-08-28 05:23:34 +00:00
|
|
|
if ((_backpackCount > 0) && {count _backpacks>0}) then {
|
2015-08-27 07:44:23 +00:00
|
|
|
|
2015-08-28 05:23:34 +00:00
|
|
|
for "_i" from 1 to _backpackCount do {
|
|
|
|
_backpack = _backpacks call BIS_fnc_selectRandom;
|
|
|
|
_box addBackpackCargoGlobal _backpack;
|
2015-08-27 07:44:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-08-28 05:23:34 +00:00
|
|
|
if(DMS_RareLoot && {count DMS_RareLoot>0}) then {
|
2015-08-27 07:44:23 +00:00
|
|
|
|
2015-08-28 05:23:34 +00:00
|
|
|
if(random 100 < DMS_RareLootChance) then {
|
|
|
|
_item = DMS_RareLoot call BIS_fnc_selectRandom;
|
|
|
|
_box addItemCargoGlobal _item;
|
2015-08-27 07:44:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|