DMS_Exile/@ExileServer/addons/a3_dms/scripts/fn_SpawnAIGroup.sqf
eraser1 78aa0f8667 Say bye-bye to the pre-packed PBO ;)
#### November 14, 2015 (8:30 PM CST-America):
* **NEW CONFIG VALUES:**

DMS_AllowStaticReinforcements
DMS_MarkerText_ShowAICount_Static
DMS_PredefinedMissionLocations_WEIGHTED
DMS_AIKill_DistanceBonusMinDistance
DMS_AIKill_DistanceBonusCoefficient
* You can now manually disable Static Mission AI reinforcements using
"DMS_AllowStaticReinforcements"
* You can now choose whether or not to show AI count for map markers for
both Static and Dynamic missions separately.
* DMS will now check to see if the config.sqf didn't load properly, and
for the presence of RyanZombies.
* You can now make predefined locations weighted.
* Some optimization + code clarity.
* Added ```taviana_config.sqf``` (identical to ```tavi_config.sqf```)
for the latest version of Taviana.
* **saltflats mission**:
* The AI will now initially spawn randomly across the compound. This
should help with the issue of some AI spawning outside of the compound.
* Added more static guns: 4 around the flagpole (5 meters north, south,
east, and west). One on top of the tower in each corner, and another on
the top of the concrete water tower.
* When an AI group is offloaded to a client and he gets out of range AND
no other viable client is found, the AI locality should now revert to
the server (it used to just stay with the original client).
* Added extra measures to prevent the creation of 2 markers with the
same name.
* fn_FillCrate.sqf:
* Fixed the issue where DMS would complain about incorrect parameters
when using custom code to generate loot.
* DMS now has debug logging to tell you exactly what it spawns in the
crate when using a crate case or custom code.
* "DMS_PredefinedMissionLocations" itself will now be shuffled when
finding a position. This should make the generated positions even more
random.
* Added new Group Reinforcement Types: "armed_vehicle_replace" and
"static_gunner"
* Potentially resolved the issue with launchers not being deleted from
AI bodies when they're killed sometimes.
* **fn_PlayerAwardOnAIKill.sqf**: Created a separate function to handle
poptabs/respect of a player when he/she kills an AI.
* Added a "distance bonus" for respect when killing AI.
* Added logging for player rewards on AI kills.
* DMS now lets Exile's body cleanup handle dead AIs.
* Fixed the issue where DMS would spawn static missions even when
"DMS_StaticMission" is set to false.
* fn_SetAILocality.sqf now returns true/false if it does/doesn't find an
owner.
* New function "fn_SpawnAIGroup_MultiPos.sqf". Almost identical to
SpawnAIGroup, except it spawns each AI along a list of locations.
* **Removed the pre-packed PBO. Too many people were having issues with
their PBO tool removing the prefix and repacking it would result in DMS
not working.**
2015-11-14 20:08:41 -06:00

111 lines
2.8 KiB
Plaintext

/*
DMS_fnc_SpawnAIGroup
Created by eraser1
Based off of WAI
Usage:
[
_pos, // Position of AI
_count, // Number of AI
_difficulty, // AI Difficulty: "random","hardcore","difficult","moderate", or "easy"
_class, // AI Class: "random","assault","MG","sniper" or "unarmed" OR [_class,_launcherType]
_side // Only "bandit" is supported atm
] call DMS_fnc_SpawnAIGroup;
Returns AI Group
*/
private ["_OK", "_pos", "_count", "_difficulty", "_class", "_group", "_side", "_launcherType", "_launcher", "_unit", "_rocket"];
_OK = params
[
["_pos","_pos ERROR",[[]],[3]],
["_count","_count ERROR",[0]],
["_difficulty","_difficulty ERROR",[""]],
["_class","_class ERROR",[""]],
["_side","_side ERROR",[""]]
];
if (!_OK) exitWith
{
diag_log format ["DMS ERROR :: Calling DMS_SpawnAIGroup with invalid parameters: %1",_this];
grpNull
};
if (_count < 1) exitWith
{
diag_log format ["DMS ERROR :: Calling DMS_SpawnAIGroup with less than 1 _count! _this: %1",_this];
grpNull
};
if (DMS_DEBUG) then
{
(format["SpawnAIGroup :: Spawning %1 %2 %3 AI at %4 with %5 difficulty.",_count,_class,_side,_pos,_difficulty]) call DMS_fnc_DebugLog;
};
// if soldier have AT/AA weapons
if (typeName _class == "ARRAY") then
{
_launcherType = _class select 1;
_class = _class select 0;
};
_group = createGroup (missionNamespace getVariable [format ["DMS_%1Side",_side],EAST]);
_group setVariable ["DMS_LockLocality",nil];
_group setVariable ["DMS_SpawnedGroup",true];
_group setVariable ["DMS_Group_Side", _side];
for "_i" from 1 to _count do
{
_unit = [_group,_pos,_class,_difficulty,_side,"Soldier"] call DMS_fnc_SpawnAISoldier;
};
// An AI will definitely spawn with a launcher if you define type
if ((!isNil "_launcherType") || {DMS_ai_use_launchers && {DMS_ai_launchers_per_group>0}}) then
{
if (isNil "_launcherType") then
{
_launcherType = "AT";
};
_units = units _group;
for "_i" from 0 to (((DMS_ai_launchers_per_group min _count)-1) max 0) do
{
if ((random 100)<DMS_ai_use_launchers_chance) then
{
_unit = _units select _i;
_launcher = ((missionNamespace getVariable [format ["DMS_AI_wep_launchers_%1",_launcherType],["launch_NLAW_F"]]) call BIS_fnc_selectRandom);
removeBackpackGlobal _unit;
_unit addBackpack "B_Carryall_mcamo";
_rocket = _launcher call DMS_fnc_selectMagazine;
[_unit, _launcher, DMS_AI_launcher_ammo_count,_rocket] call BIS_fnc_addWeapon;
_unit setVariable ["DMS_AI_Launcher",_launcher];
if (DMS_DEBUG) then
{
(format["SpawnAIGroup :: Giving %1 a %2 launcher with %3 %4 rockets",_unit,_launcher,DMS_AI_launcher_ammo_count,_rocket]) call DMS_fnc_DebugLog;
};
};
};
};
_group selectLeader ((units _group) select 0);
_group setFormation "WEDGE";
[_group,_pos,_difficulty,"COMBAT"] call DMS_fnc_SetGroupBehavior;
diag_log format ["DMS_SpawnAIGroup :: Spawned %1 AI at %2.",_count,_pos];
_group