2015-08-29 06:09:50 +00:00
|
|
|
/*
|
|
|
|
DMS_SpawnAIGroup
|
|
|
|
Created by eraser1
|
|
|
|
Based off of WAI
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
[
|
|
|
|
_pos, // Position of AI
|
|
|
|
_count, // Number of AI
|
|
|
|
_difficulty, // "random","hardcore","difficult","moderate", or "easy"
|
2015-08-29 19:46:07 +00:00
|
|
|
_type // "random","assault","MG","sniper" or "unarmed" OR [_type,_launcher]
|
2015-09-01 06:24:42 +00:00
|
|
|
_side // Only "bandit" is supported atm
|
2015-08-29 06:09:50 +00:00
|
|
|
] call DMS_SpawnAIGroup;
|
2015-08-29 19:46:07 +00:00
|
|
|
|
|
|
|
Returns AI Group
|
2015-08-29 06:09:50 +00:00
|
|
|
*/
|
2015-08-29 19:46:07 +00:00
|
|
|
private ["_OK", "_pos", "_count", "_difficulty", "_type", "_side", "_pos_x", "_pos_y", "_pos_z", "_launcher", "_unit", "_client"];
|
|
|
|
|
|
|
|
_OK = params
|
|
|
|
[
|
|
|
|
["_pos",[0,0,0],[[]],[3]],
|
|
|
|
["_count",0,[0]],
|
|
|
|
["_difficulty","random",[""]],
|
|
|
|
["_type","random",[""]],
|
|
|
|
["_side","bandit",[""]]
|
|
|
|
];
|
|
|
|
|
|
|
|
if (!_OK) then
|
|
|
|
{
|
|
|
|
diag_log format ["DMS ERROR :: Calling DMS_SpawnAIGroup with invalid parameters: %1",_this];
|
|
|
|
};
|
2015-08-29 06:09:50 +00:00
|
|
|
|
2015-08-29 19:46:07 +00:00
|
|
|
if (_count < 1) exitWith
|
|
|
|
{
|
|
|
|
diag_log format ["DMS ERROR :: Calling DMS_SpawnAIGroup with less than 1 _count! _this: %1",_this];
|
|
|
|
};
|
2015-08-29 06:09:50 +00:00
|
|
|
|
2015-08-29 19:46:07 +00:00
|
|
|
_pos_x = _pos select 0;
|
|
|
|
_pos_y = _pos select 1;
|
|
|
|
_pos_z = _pos select 2;
|
2015-08-29 06:09:50 +00:00
|
|
|
|
2015-08-29 19:46:07 +00:00
|
|
|
|
|
|
|
if(DMS_DEBUG) then
|
|
|
|
{
|
|
|
|
diag_log format["DMS_DEBUG SpawnAIGroup :: Spawning %1 %2 %3 AI at %4 with %5 difficulty.",_count,_type,_side,_pos,_difficulty];
|
|
|
|
};
|
2015-08-29 06:09:50 +00:00
|
|
|
|
|
|
|
// if soldier have AT/AA weapons
|
2015-08-29 19:46:07 +00:00
|
|
|
if (typeName _type == "ARRAY") then
|
|
|
|
{
|
2015-08-29 06:09:50 +00:00
|
|
|
_launcher = _type select 1;
|
2015-08-29 19:46:07 +00:00
|
|
|
_type = _type select 0;
|
2015-08-29 06:09:50 +00:00
|
|
|
};
|
|
|
|
|
2015-08-29 19:46:07 +00:00
|
|
|
// Randomize position
|
|
|
|
if(_pos_z == 0) then
|
|
|
|
{
|
|
|
|
if(round(random 1) == 1) then
|
|
|
|
{
|
2015-08-29 06:09:50 +00:00
|
|
|
_pos_x = _pos_x - (5 + random(10));
|
|
|
|
} else {
|
|
|
|
_pos_x = _pos_x + (5 + random(10));
|
|
|
|
};
|
|
|
|
|
2015-08-29 19:46:07 +00:00
|
|
|
if(round(random 1) == 1) then
|
|
|
|
{
|
2015-08-29 06:09:50 +00:00
|
|
|
_pos_y = _pos_y - (5 + random(10));
|
|
|
|
} else {
|
|
|
|
_pos_y = _pos_y + (5 + random(10));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-08-29 19:46:07 +00:00
|
|
|
|
|
|
|
_group = createGroup (missionNamespace getVariable [format ["DMS_%1Side",_side],EAST]);
|
|
|
|
|
|
|
|
for "_i" from 1 to _count do {
|
|
|
|
_unit = [_group,[_pos_x,_pos_y,_pos_z],_type,_difficulty,_side] call DMS_SpawnAISoldier;
|
2015-08-29 06:09:50 +00:00
|
|
|
};
|
|
|
|
|
2015-09-01 06:25:14 +00:00
|
|
|
// An AI will definitely spawn with a launcher if you define type
|
|
|
|
if ((!isNil "_launcher") || {DMS_ai_use_launchers && {(random 100) <= DMS_ai_use_launchers_chance}}) then
|
2015-08-29 19:46:07 +00:00
|
|
|
{
|
2015-09-01 06:24:42 +00:00
|
|
|
if (!isNil "_launcher") then
|
|
|
|
{
|
|
|
|
_launcher = "AT";
|
|
|
|
};
|
|
|
|
|
2015-08-29 19:46:07 +00:00
|
|
|
_launcher = ((missionNamespace getVariable [format ["DMS_AI_wep_launchers_%1",_launcher],["launch_NLAW_F"]]) call BIS_fnc_selectRandom);
|
|
|
|
|
2015-08-29 06:09:50 +00:00
|
|
|
_unit addBackpack "B_Carryall_mcamo";
|
2015-08-29 19:46:07 +00:00
|
|
|
|
|
|
|
[_unit, _launcher, DMS_AI_launcher_ammo_count] call BIS_fnc_addWeapon;
|
2015-08-29 06:09:50 +00:00
|
|
|
|
2015-08-29 19:46:07 +00:00
|
|
|
if(DMS_DEBUG) then
|
|
|
|
{
|
|
|
|
diag_log format["DMS_DEBUG SpawnAIGroup :: Giving %1 a %2 launcher.",_unit,_launcher];
|
|
|
|
};
|
2015-08-29 06:09:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-08-29 19:46:07 +00:00
|
|
|
_group selectLeader ((units _group) select 0);
|
|
|
|
_group setFormation "WEDGE";
|
|
|
|
|
|
|
|
|
|
|
|
if(_pos_z == 0) then
|
|
|
|
{
|
|
|
|
[_group,_pos,_difficulty] call DMS_SetGroupBehavior;
|
2015-08-29 06:09:50 +00:00
|
|
|
};
|
|
|
|
|
2015-08-29 19:46:07 +00:00
|
|
|
|
2015-08-31 21:15:35 +00:00
|
|
|
|
2015-08-29 19:46:07 +00:00
|
|
|
if (DMS_ai_offload_to_client) then
|
|
|
|
{
|
|
|
|
_client = (allPlayers call BIS_fnc_selectRandom);
|
2015-09-01 06:26:28 +00:00
|
|
|
ExileServerOwnershipSwapQueue pushBack [_group,_client];
|
2015-08-29 19:46:07 +00:00
|
|
|
if(DMS_DEBUG) then
|
|
|
|
{
|
|
|
|
diag_log format["DMS_DEBUG SpawnAIGroup :: Swapping group ownership of %1 to %2",_group,_client];
|
|
|
|
};
|
2015-08-29 06:09:50 +00:00
|
|
|
};
|
2015-08-31 21:15:35 +00:00
|
|
|
|
2015-08-29 19:46:07 +00:00
|
|
|
|
|
|
|
diag_log format ["DMS_SpawnAIGroup :: Spawned %1 AI at %2.",_count,_pos];
|
2015-08-29 06:09:50 +00:00
|
|
|
|
2015-08-29 19:46:07 +00:00
|
|
|
_group
|