DMS_Exile/@ExileServer/addons/a3_dms/scripts/fn_SpawnAIVehicle.sqf
eraser1 70fae7bc44 Merry Xmas :D
* **NEW CONFIG VALUES:**

DMS_SpawnFlareOnReinforcements
DMS_MissionMarkerWinDot_Type
DMS_MissionMarkerLoseDot_Type
DMS_EnableBoxMoving
DMS_BasesToImportOnServerStart
DMS_AI_Classname
DMS_AI_AimCoef_easy
DMS_AI_AimCoef_moderate
DMS_AI_AimCoef_difficult
DMS_AI_AimCoef_hardcore
DMS_AI_EnableStamina_easy
DMS_AI_EnableStamina_moderate
DMS_AI_EnableStamina_difficult
DMS_AI_EnableStamina_hardcore
DMS_AI_destroyStaticWeapon
DMS_AI_destroyStaticWeapon_chance
DMS_ai_SupportedRandomClasses
DMS_random_non_assault_AI
DMS_random_non_MG_AI
DMS_random_non_sniper_AI
* Please check out the new config values in config.sqf to see what they
do :)
* Fixed issue with "thieves" mission (and DMS-spawned persistent
vehicles in general). Big thank you to [JamieKG from Eternal
Gamer](http://eternal-gamer.com/) and Torndeco.
* **New static mission: "slums"**
* Credit for the base goes to [William from Refugees of the
Fallen](http://refugeesofthefallen.enjin.com/)
* Spawns 2 crates at 2 different locations from a list of 5 locations.
* No AI vehicles, only infantry (introduces Close Quarters Combat)
* Added to Altis by default.
* Static bases can now be imported on server startup instead of mission
spawns. Enabled by default for saltflats and slums.
* Increased "DMS_MissionTimeoutResetRange" from 1000 to 1500.
* Removed the Navid from config (MG AI and box weapons).
* Edited panthera3_config to reduce SpawnZoneNear and TraderZoneNear
blacklists.
* Edited "blackhawkdown" and "donthasslethehoff" missions to use a
slightly different heli wreck classname.
* Increased marker circle diameter for saltflats mission to 750 meters.
* Moved "DMS_Version" variable assignment to pre-init.
* Moved Map Center and Map Radius assignments to post-init.
* Added support for 2 new optional parameters: _onMonitorStart and
_onMonitorEnd, run before and after the Mission Monitor checks the
mission, but AFTER "Mission Success State" is checked.
* Mines should now be deleted when a mission fails.
* Script optimizations for almost all functions using new command(s)
introduced in ArmA v1.54, as well as improved technique(s).
* "ExileServer_system_garbageCollector_deleteObject" is now used to
actually delete items by DMS_fnc_CleanUp.
* AI and vehicle cleanup should now be completely handled by Exile.
* Added support for mARMA logging.
* **You can now disable the movement/lifting of loot crates after the
mission is complete using "DMS_EnableBoxMoving".**
* Added some debug code to DMS_fnc_FindSafePos and
DMS_fnc_IsValidPosition (commented out by default)
* New group reinforcement type "increasing_difficulty".
* DMS_fnc_IsNearWater now checks for invalid parameter(s).
* DMS_fnc_PlayerAwardOnAIKill now checks for roadkill values AFTER
unit-defined respect/tabs.
* You can now define different marker types for mission
completion/failure using "DMS_MissionMarkerWinDot_Type" and
"DMS_MissionMarkerLoseDot_Type" respectively.
* "DMS_fnc_SetGroupBehavior" can now take a unit as parameter as well.
It will also now return true if behavior was changed, false otherwise.
* "DMS_fnc_SpawnAIGroup" and "DMS_fnc_SpawnAIGroup_MultiPos" now
supports the definition of custom gear sets.
* Improved function documentation for "DMS_fnc_SpawnAIGroup",
"DMS_fnc_SpawnAIGroup_MultiPos", and "DMS_fnc_SpawnAISoldier".
* "DMS_fnc_SpawnAISoldier" now supports multiple different random AI
class presets. This means that you can define a certain "random" class
preset, but have it select from a specially defined list that excludes
classes that you don't want.
* Added default values to certain "missionNameSpace getVariable"s in
DMS_fnc_SpawnAISoldier to prevent script errors in the event of invalid
definitions.
* Slight logic tweak/fix to DMS_fnc_TargetsKilled (it shouldn't throw
errors when there aren't any).
2015-12-24 13:45:20 -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"];
if !(params
[
["_positions",[],[[]],[1,2]],
["_group",grpNull,[grpNull]],
["_class","random",[""]],
["_difficulty","static",[""]],
["_side","bandit",[""]]
])
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...
if !(_positions params
[
["_spawnPos",[],[[]],[2,3]]
])
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