DMS_Exile/@ExileServer/addons/a3_dms/scripts/fn_SpawnAIVehicle.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

92 lines
2.6 KiB
Plaintext

/*
DMS_fnc_SpawnAIVehicle
Created by eraser1
Usage:
[
[
_spawnPos, // The position at which the AI vehicle will spawn
_gotoPos // (OPTIONAL) The position to which the AI vehicle will drive to. If it isn't defined, _spawnPos is used
],
_group, // Group to which the AI units belongs to
_class, // Class: "random","assault","MG","sniper" or "unarmed"
_difficulty, // Difficulty: "random","static","hardcore","difficult","moderate", or "easy"
_side, // "bandit","hero", etc.
_vehClass // (OPTIONAL) String: classname of the Vehicle. Use "random" to select a random one from DMS_ArmedVehicles
] call DMS_fnc_SpawnAIVehicle;
Returns the spawned vehicle.
*/
private ["_OK", "_positions", "_veh", "_spawnPos", "_gotoPos", "_vehClass", "_driver", "_gunner", "_tmpGroup", "_group", "_class", "_difficulty", "_side"];
_OK = params
[
["_positions",[],[[]],[1,2]],
["_group",grpNull,[grpNull]],
["_class","random",[""]],
["_difficulty","static",[""]],
["_side","bandit",[""]]
];
if (!_OK) exitWith
{
diag_log format ["DMS ERROR :: Calling DMS_fnc_SpawnAIVehicle with invalid parameters: %1",_this];
};
// Using another params-exitwith structure just for _spawnPos because it's pretty important...
_OK = _positions params
[
["_spawnPos",[],[[]],[2,3]]
];
if (!_OK) exitWith
{
diag_log format ["DMS ERROR :: Calling DMS_fnc_SpawnAIVehicle with invalid _positions parameters: %1",_positions];
};
_gotoPos = if ((count _positions)>1) then {_positions param [1,_spawnPos,[[]],[2,3]]} else {_spawnPos};
_vehClass = "random";
if ((count _this)>5) then
{
_vehClass = param [5,"random",[""]];
};
if (_vehClass == "random") then
{
_vehClass = DMS_ArmedVehicles call BIS_fnc_selectRandom;
};
_tmpGroup = createGroup (missionNamespace getVariable [format ["DMS_%1Side",_side],EAST]);
_veh = createVehicle [_vehClass, _spawnPos, [], 0, "NONE"];
_veh setFuel 1;
_veh engineOn true;
_veh setDir (random 360);
_veh lock 2;
_group addVehicle _veh;
_tmpGroup addVehicle _veh;
_driver = [_tmpGroup,_spawnPos,_class,_difficulty,_side,"Vehicle"] call DMS_fnc_SpawnAISoldier;
_gunner = [_tmpGroup,_spawnPos,_class,_difficulty,_side,"Vehicle"] call DMS_fnc_SpawnAISoldier;
_driver moveInDriver _veh;
_gunner moveInGunner _veh;
_driver setVariable ["DMS_AssignedVeh",_veh];
_gunner setVariable ["DMS_AssignedVeh",_veh];
[_tmpGroup,_gotoPos,_difficulty,"AWARE"] call DMS_fnc_SetGroupBehavior;
[_driver,_gunner] joinSilent _group;
if (DMS_DEBUG) then
{
(format ["SpawnAIVehicle :: Created a %1 armed vehicle (%2) at %3 with %4 difficulty to group %5",_side,_vehClass,_spawnPos,_difficulty,_group]) call DMS_fnc_DebugLog;
};
_veh