2015-08-29 06:09:50 +00:00
|
|
|
/*
|
2015-09-05 03:40:00 +00:00
|
|
|
DMS_fnc_SpawnAISoldier
|
2015-08-29 06:09:50 +00:00
|
|
|
Created by eraser1
|
|
|
|
Based off of WAI
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
[
|
|
|
|
_group, // Group the AI will belong to
|
|
|
|
_pos, // Position of AI
|
2015-09-10 02:05:46 +00:00
|
|
|
_class, // Classname: "random","assault","MG","sniper" or "unarmed"
|
|
|
|
_difficulty, // Difficulty: "random","static","hardcore","difficult","moderate", or "easy"
|
2015-08-29 06:09:50 +00:00
|
|
|
_side, // "bandit","hero", etc.
|
2015-09-10 02:05:46 +00:00
|
|
|
_type, // Type of AI: "soldier","static","vehicle","heli", etc.
|
|
|
|
_customGearSet // OPTIONAL: Manually defined AI gear.
|
Major UI Improvements, Fixes, Improved readme
* **NEW CONFIG VALUES**:
|DMS_Show_Kill_Poptabs_Notification|
|DMS_Show_Kill_Respect_Notification|
|DMS_dynamicText_Duration|
|DMS_dynamicText_FadeTime|
|DMS_dynamicText_Title_Size|
|DMS_dynamicText_Title_Font|
|DMS_dynamicText_Message_Color|
|DMS_dynamicText_Message_Size|
|DMS_dynamicText_Message_Font|
|DMS_standardHint_Title_Size|
|DMS_standardHint_Title_Font|
|DMS_standardHint_Message_Color|
|DMS_standardHint_Message_Size|
|DMS_standardHint_Message_Font|
|DMS_textTiles_Duration|
|DMS_textTiles_FadeTime|
|DMS_textTiles_Title_Size|
|DMS_textTiles_Title_Font|
|DMS_textTiles_Message_Color|
|DMS_textTiles_Message_Size|
|DMS_textTiles_Message_Font|
* "DMS_PlayerNotificationTypes" has been adjusted to include
"systemChatRequest" and the brand new "textTilesRequest". **NOTE:** Due
to the way "text tiles" work, a player can only have one on his screen
at a time. As a result, if another text tile is created while the
mission message is up, the message will immediately disappear to display
the new text tile. Currently, the "Frag Messages" (the ones that say
"Player Kill +100") use text tiles. I don't think it should be a major
issue (especially if you use "systemChatRequest", so the player can just
scroll up), but if I get reports of it being stupid, I will default to
"dynamicTextRequest", which should also look pretty damn nice.
* These changes should make it much easier for people to use DMS
notification functions for other purposes.
* Fixed AI waypoints - the AI should now properly circle the objective
at the proper radius.
* Tweaked "DMS_AI_WP_Radius_moderate" and "DMS_AI_WP_Radius_difficult"
(reduced the radii). Due to the AI pathing fix.
* Fixed a couple typos in "DMS_fnc_SpawnAISoldier". "_customGearSet"
should work now (although I'm fairly certain nobody uses it since nobody
ever complained :P )
* Improved "DMS_fnc_SpawnNonPersistentVehicle"; Vehicles should no
longer spawn jumbled up in most cases (like cardealer). Also, it's
updated to the latest Exile methods to ensure that vehicles have no
nightvision/thermal if configured to do so in Exile configs. Also added
the "MPKilled" EH used by Exile for non-persistent (persistent vehicles
already had it).
* You can now choose whether or not you want to display the poptabs or
respect kill messages when killing an AI with
"DMS_Show_Kill_Poptabs_Notification" and
"DMS_Show_Kill_Respect_Notification". Both are enabled by default.
* Fixed typos in the "OnKilled" EH (didn't really affect anything)
* Fixed cases when "currentMuzzle" would return a number. Thanks to
[azmodii](https://github.com/azmodii) for the reminder.
* Optimized the "AI share info" function in "OnKilled"
2015-10-09 00:16:48 +00:00
|
|
|
] call DMS_fnc_SpawnAISoldier;
|
2015-08-29 06:09:50 +00:00
|
|
|
|
2015-08-29 17:40:38 +00:00
|
|
|
Usage for _customGearSet:
|
2015-08-29 06:09:50 +00:00
|
|
|
[
|
|
|
|
_weapon, // String | EG: "LMG_Zafir_F"
|
|
|
|
_weaponAttachments, // Array of strings | EG: ["optic_dms","bipod_03_F_blk"]
|
|
|
|
_magazines, // Array of arrays | EG: [["150Rnd_762x54_Box",2],["16Rnd_9x21_Mag",3]]
|
|
|
|
_pistol, // String | EG: "hgun_Pistol_heavy_01_snds_F"
|
|
|
|
_pistolAttachments, // Array of strings | EG: ["optic_MRD","muzzle_snds_acp"]
|
|
|
|
_items, // Array of strings | EG: ["Rangefinder","ItemGPS","Exile_Item_InstaDoc"]
|
2015-09-10 02:05:46 +00:00
|
|
|
_launcher, // String | EG: "launch_RPG32_F"
|
2015-08-29 06:09:50 +00:00
|
|
|
_helmet, // String | EG: "H_HelmetLeaderO_ocamo"
|
|
|
|
_uniform, // String | EG: "U_O_GhillieSuit"
|
|
|
|
_vest, // String | EG: "V_PlateCarrierGL_blk"
|
|
|
|
_backpack // String | EG: "B_Carryall_oli"
|
|
|
|
]
|
2015-08-29 19:46:07 +00:00
|
|
|
|
|
|
|
Returns AI Unit
|
2015-08-29 06:09:50 +00:00
|
|
|
*/
|
2015-08-29 17:40:38 +00:00
|
|
|
|
Major UI Improvements, Fixes, Improved readme
* **NEW CONFIG VALUES**:
|DMS_Show_Kill_Poptabs_Notification|
|DMS_Show_Kill_Respect_Notification|
|DMS_dynamicText_Duration|
|DMS_dynamicText_FadeTime|
|DMS_dynamicText_Title_Size|
|DMS_dynamicText_Title_Font|
|DMS_dynamicText_Message_Color|
|DMS_dynamicText_Message_Size|
|DMS_dynamicText_Message_Font|
|DMS_standardHint_Title_Size|
|DMS_standardHint_Title_Font|
|DMS_standardHint_Message_Color|
|DMS_standardHint_Message_Size|
|DMS_standardHint_Message_Font|
|DMS_textTiles_Duration|
|DMS_textTiles_FadeTime|
|DMS_textTiles_Title_Size|
|DMS_textTiles_Title_Font|
|DMS_textTiles_Message_Color|
|DMS_textTiles_Message_Size|
|DMS_textTiles_Message_Font|
* "DMS_PlayerNotificationTypes" has been adjusted to include
"systemChatRequest" and the brand new "textTilesRequest". **NOTE:** Due
to the way "text tiles" work, a player can only have one on his screen
at a time. As a result, if another text tile is created while the
mission message is up, the message will immediately disappear to display
the new text tile. Currently, the "Frag Messages" (the ones that say
"Player Kill +100") use text tiles. I don't think it should be a major
issue (especially if you use "systemChatRequest", so the player can just
scroll up), but if I get reports of it being stupid, I will default to
"dynamicTextRequest", which should also look pretty damn nice.
* These changes should make it much easier for people to use DMS
notification functions for other purposes.
* Fixed AI waypoints - the AI should now properly circle the objective
at the proper radius.
* Tweaked "DMS_AI_WP_Radius_moderate" and "DMS_AI_WP_Radius_difficult"
(reduced the radii). Due to the AI pathing fix.
* Fixed a couple typos in "DMS_fnc_SpawnAISoldier". "_customGearSet"
should work now (although I'm fairly certain nobody uses it since nobody
ever complained :P )
* Improved "DMS_fnc_SpawnNonPersistentVehicle"; Vehicles should no
longer spawn jumbled up in most cases (like cardealer). Also, it's
updated to the latest Exile methods to ensure that vehicles have no
nightvision/thermal if configured to do so in Exile configs. Also added
the "MPKilled" EH used by Exile for non-persistent (persistent vehicles
already had it).
* You can now choose whether or not you want to display the poptabs or
respect kill messages when killing an AI with
"DMS_Show_Kill_Poptabs_Notification" and
"DMS_Show_Kill_Respect_Notification". Both are enabled by default.
* Fixed typos in the "OnKilled" EH (didn't really affect anything)
* Fixed cases when "currentMuzzle" would return a number. Thanks to
[azmodii](https://github.com/azmodii) for the reminder.
* Optimized the "AI share info" function in "OnKilled"
2015-10-09 00:16:48 +00:00
|
|
|
private ["_OK", "_useCustomGear", "_unarmed", "_class", "_type", "_unit", "_side", "_nighttime", "_weapon", "_muzzle", "_suppressor", "_pistols", "_pistol", "_customGearSet", "_helmet", "_uniform", "_vest", "_backpack", "_launcher", "_magazines", "_weaponAttachments", "_pistolAttachments", "_items", "_difficulty", "_skillArray"];
|
2015-08-29 06:09:50 +00:00
|
|
|
|
|
|
|
_OK = params
|
|
|
|
[
|
2015-08-29 18:30:26 +00:00
|
|
|
["_group",grpNull,[grpNull]],
|
2015-08-29 06:09:50 +00:00
|
|
|
["_pos",[0,0,0],[[]],[3]],
|
2015-09-10 02:05:46 +00:00
|
|
|
["_class","random",[""]],
|
2015-08-29 06:09:50 +00:00
|
|
|
["_difficulty","random",[""]],
|
2015-09-10 02:05:46 +00:00
|
|
|
["_side","bandit",[""]],
|
|
|
|
["_type","soldier",[""]]
|
2015-08-29 06:09:50 +00:00
|
|
|
];
|
2015-09-10 02:05:46 +00:00
|
|
|
|
2015-08-29 06:09:50 +00:00
|
|
|
_useCustomGear = false;
|
|
|
|
_unarmed = false;
|
|
|
|
|
|
|
|
if (!_OK) then
|
|
|
|
{
|
|
|
|
diag_log format ["DMS ERROR :: DMS_SpawnAISoldier called with invalid parameters: %1",_this];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-10 02:05:46 +00:00
|
|
|
if ((_class == "custom") && {((count _this)>6)}) then
|
2015-08-29 06:09:50 +00:00
|
|
|
{
|
Major UI Improvements, Fixes, Improved readme
* **NEW CONFIG VALUES**:
|DMS_Show_Kill_Poptabs_Notification|
|DMS_Show_Kill_Respect_Notification|
|DMS_dynamicText_Duration|
|DMS_dynamicText_FadeTime|
|DMS_dynamicText_Title_Size|
|DMS_dynamicText_Title_Font|
|DMS_dynamicText_Message_Color|
|DMS_dynamicText_Message_Size|
|DMS_dynamicText_Message_Font|
|DMS_standardHint_Title_Size|
|DMS_standardHint_Title_Font|
|DMS_standardHint_Message_Color|
|DMS_standardHint_Message_Size|
|DMS_standardHint_Message_Font|
|DMS_textTiles_Duration|
|DMS_textTiles_FadeTime|
|DMS_textTiles_Title_Size|
|DMS_textTiles_Title_Font|
|DMS_textTiles_Message_Color|
|DMS_textTiles_Message_Size|
|DMS_textTiles_Message_Font|
* "DMS_PlayerNotificationTypes" has been adjusted to include
"systemChatRequest" and the brand new "textTilesRequest". **NOTE:** Due
to the way "text tiles" work, a player can only have one on his screen
at a time. As a result, if another text tile is created while the
mission message is up, the message will immediately disappear to display
the new text tile. Currently, the "Frag Messages" (the ones that say
"Player Kill +100") use text tiles. I don't think it should be a major
issue (especially if you use "systemChatRequest", so the player can just
scroll up), but if I get reports of it being stupid, I will default to
"dynamicTextRequest", which should also look pretty damn nice.
* These changes should make it much easier for people to use DMS
notification functions for other purposes.
* Fixed AI waypoints - the AI should now properly circle the objective
at the proper radius.
* Tweaked "DMS_AI_WP_Radius_moderate" and "DMS_AI_WP_Radius_difficult"
(reduced the radii). Due to the AI pathing fix.
* Fixed a couple typos in "DMS_fnc_SpawnAISoldier". "_customGearSet"
should work now (although I'm fairly certain nobody uses it since nobody
ever complained :P )
* Improved "DMS_fnc_SpawnNonPersistentVehicle"; Vehicles should no
longer spawn jumbled up in most cases (like cardealer). Also, it's
updated to the latest Exile methods to ensure that vehicles have no
nightvision/thermal if configured to do so in Exile configs. Also added
the "MPKilled" EH used by Exile for non-persistent (persistent vehicles
already had it).
* You can now choose whether or not you want to display the poptabs or
respect kill messages when killing an AI with
"DMS_Show_Kill_Poptabs_Notification" and
"DMS_Show_Kill_Respect_Notification". Both are enabled by default.
* Fixed typos in the "OnKilled" EH (didn't really affect anything)
* Fixed cases when "currentMuzzle" would return a number. Thanks to
[azmodii](https://github.com/azmodii) for the reminder.
* Optimized the "AI share info" function in "OnKilled"
2015-10-09 00:16:48 +00:00
|
|
|
_customGearSet = _this select 5;
|
2015-08-29 06:09:50 +00:00
|
|
|
_useCustomGear = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-08-30 00:33:32 +00:00
|
|
|
if(_difficulty == "random") then
|
2015-08-29 17:40:38 +00:00
|
|
|
{
|
|
|
|
_difficulty = DMS_ai_skill_random call BIS_fnc_selectRandom;
|
|
|
|
};
|
|
|
|
|
2015-08-29 06:09:50 +00:00
|
|
|
//Create unit
|
|
|
|
_unit = _group createUnit ["O_recon_F", _pos, [], 0,"FORM"];
|
|
|
|
_unit allowFleeing 0;
|
|
|
|
[_unit] joinSilent _group;
|
|
|
|
|
|
|
|
// Remove existing gear
|
|
|
|
removeAllWeapons _unit;
|
|
|
|
removeAllItems _unit;
|
|
|
|
removeAllAssignedItems _unit;
|
|
|
|
removeUniform _unit;
|
|
|
|
removeVest _unit;
|
|
|
|
removeBackpack _unit;
|
|
|
|
removeHeadgear _unit;
|
|
|
|
removeGoggles _unit;
|
|
|
|
|
|
|
|
// Give default items
|
|
|
|
if !(DMS_ai_default_items isEqualTo []) then
|
|
|
|
{
|
2015-09-05 03:59:27 +00:00
|
|
|
{
|
|
|
|
// "Why doesn't linkItem work with any of these? Because fuck you, that's why" - BIS
|
|
|
|
if (_x in ["Binocular","Rangefinder","Laserdesignator","Laserdesignator_02","Laserdesignator_03"]) then
|
|
|
|
{
|
|
|
|
_unit addWeapon _x;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_unit linkItem _x;
|
|
|
|
};
|
|
|
|
} forEach DMS_ai_default_items;
|
2015-08-29 06:09:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-09-10 02:05:46 +00:00
|
|
|
switch (toLower _class) do
|
2015-08-29 06:09:50 +00:00
|
|
|
{
|
2015-09-10 02:05:46 +00:00
|
|
|
case "random" : {_class = DMS_random_AI call BIS_fnc_selectRandom;};
|
|
|
|
case "unarmed" : {_class = "assault";_unarmed = true;};
|
2015-08-29 06:09:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Unit name
|
Finally another update... warming up
* NEW CONFIG VALUE: DMS_SpawnMinefieldForEveryMission
* You can now force-spawn an AT mine minefield on every mission with the
above config. These mines will only blow up on Tanks, APCs, and MRAPs
(Ifrits, Hunters, Striders).
* ALL MISSIONS HAVE BEEN EDITED TO MATCH THE NEW STANDARD FOR
DMS_fnc_AddMissionToMonitor. **If you have made any custom missions or
modified any of the current mission scripts, make sure you merge your
changes**!
* Adjusted the placement of the armed car in "bandits" mission. It
should no longer spawn right on the crate.
* Marker and message names for the "foodtransport" mission have been
adjusted.
* Added the AI vehicle to the "mercbase" mission.
* Removed some RPT spam...
* Standardize ATL for DMS_fnc_importFromM3E_Convert
* When revealing a player to AI, the reveal amount will be reduced if
the player has a suppressor.
* DMS_fnc_SetGroupBehavior will now remove all previous waypoints from
the AI group.
* Improved logging message for DMS_fnc_SpawnMinefield. Also, the mine
warning signs should be on a random offset (instead of always spawning
at 0, 90, 180, and 270 degrees)
2015-10-01 02:29:33 +00:00
|
|
|
_unit setName format["[DMS_%3Unit_%1%2]",_class,floor(random 1000),toUpper _side];
|
2015-08-29 06:09:50 +00:00
|
|
|
|
|
|
|
if (!_useCustomGear) then
|
|
|
|
{
|
2015-09-10 02:05:46 +00:00
|
|
|
if !(_class in DMS_ai_SupportedClasses) exitWith
|
2015-08-29 06:09:50 +00:00
|
|
|
{
|
2015-09-10 02:05:46 +00:00
|
|
|
diag_log format ["DMS ERROR :: DMS_SpawnAISoldier called with unsupported _class: %1 | _this: %2",_class,_this];
|
2015-09-05 03:59:27 +00:00
|
|
|
};
|
|
|
|
|
2015-08-29 06:09:50 +00:00
|
|
|
|
2015-08-30 01:30:56 +00:00
|
|
|
// Equipment (Stuff that goes in the toolbelt slots)
|
2015-09-05 03:59:27 +00:00
|
|
|
{
|
|
|
|
if (_x in ["Binocular","Rangefinder","Laserdesignator","Laserdesignator_02","Laserdesignator_03"]) then
|
|
|
|
{
|
|
|
|
_unit addWeapon _x;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_unit linkItem _x;
|
|
|
|
};
|
2015-09-10 02:05:46 +00:00
|
|
|
} forEach (missionNamespace getVariable [format ["DMS_%1_equipment",_class],[]]);
|
2015-09-05 03:59:27 +00:00
|
|
|
|
2015-08-30 01:30:56 +00:00
|
|
|
|
|
|
|
// Items (Loot stuff that goes in uniform/vest/backpack)
|
2015-09-10 02:05:46 +00:00
|
|
|
{_unit addItem _x;} forEach (missionNamespace getVariable [format ["DMS_%1_items",_class],[]]);
|
2015-08-30 01:30:56 +00:00
|
|
|
|
2015-08-29 06:09:50 +00:00
|
|
|
|
|
|
|
// Clothes
|
2015-09-10 02:05:46 +00:00
|
|
|
_unit addHeadgear ((missionNamespace getVariable [format ["DMS_%1_helmets",_class],[]]) call BIS_fnc_selectRandom);
|
|
|
|
_unit forceAddUniform ((missionNamespace getVariable [format ["DMS_%1_clothes",_class],[]]) call BIS_fnc_selectRandom);
|
|
|
|
_unit addVest ((missionNamespace getVariable [format ["DMS_%1_vests",_class],[]]) call BIS_fnc_selectRandom);
|
|
|
|
_unit addBackpack ((missionNamespace getVariable [format ["DMS_%1_backpacks",_class],[]]) call BIS_fnc_selectRandom);
|
2015-08-29 06:09:50 +00:00
|
|
|
|
|
|
|
// Make AI effective at night
|
|
|
|
_nighttime = (sunOrMoon != 1);
|
|
|
|
if (_nighttime) then
|
|
|
|
{
|
|
|
|
_unit linkItem "NVGoggles";
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!_unarmed) then
|
|
|
|
{
|
2015-09-10 02:05:46 +00:00
|
|
|
_weapon = (missionNamespace getVariable [format ["DMS_%1_weps",_class],[]]) call BIS_fnc_selectRandom;
|
2015-09-01 23:22:41 +00:00
|
|
|
[_unit, _weapon, 6 + floor(random 3)] call BIS_fnc_addWeapon;
|
2015-08-29 06:09:50 +00:00
|
|
|
_unit selectWeapon _weapon;
|
|
|
|
|
|
|
|
|
2015-09-10 02:05:46 +00:00
|
|
|
if((random 100) <= (missionNamespace getVariable [format["DMS_%1_optic_chance",_class],0])) then
|
2015-08-29 06:09:50 +00:00
|
|
|
{
|
2015-09-10 02:05:46 +00:00
|
|
|
_unit addPrimaryWeaponItem ((missionNamespace getVariable [format ["DMS_%1_optics",_class],[]]) call BIS_fnc_selectRandom);
|
2015-08-29 06:09:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (_nighttime && {(random 100) <= DMS_ai_nighttime_accessory_chance}) then
|
|
|
|
{
|
|
|
|
_unit addPrimaryWeaponItem (["acc_pointer_IR","acc_flashlight"] call BIS_fnc_selectRandom);
|
|
|
|
};
|
|
|
|
|
2015-09-10 02:05:46 +00:00
|
|
|
if((random 100) <= (missionNamespace getVariable [format["DMS_%1_bipod_chance",_class],0])) then
|
2015-08-29 06:09:50 +00:00
|
|
|
{
|
|
|
|
_unit addPrimaryWeaponItem (DMS_ai_BipodList call BIS_fnc_selectRandom);
|
|
|
|
};
|
|
|
|
|
2015-09-10 02:05:46 +00:00
|
|
|
if((random 100) <= (missionNamespace getVariable [format["DMS_%1_suppressor_chance",_class],0])) then
|
2015-08-29 06:09:50 +00:00
|
|
|
{
|
2015-09-05 03:40:00 +00:00
|
|
|
_suppressor = _weapon call DMS_fnc_FindSuppressor;
|
2015-08-29 06:09:50 +00:00
|
|
|
if(_suppressor != "") then
|
|
|
|
{
|
|
|
|
_unit addPrimaryWeaponItem _suppressor;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// In case spawn position is water
|
|
|
|
if (DMS_ai_enable_water_equipment && {surfaceIsWater _pos}) then
|
|
|
|
{
|
|
|
|
removeHeadgear _unit;
|
|
|
|
removeAllWeapons _unit;
|
|
|
|
_unit forceAddUniform "U_O_Wetsuit";
|
|
|
|
_unit addVest "V_RebreatherIA";
|
|
|
|
_unit addGoggles "G_Diving";
|
2015-08-29 19:46:07 +00:00
|
|
|
[_unit, "arifle_SDAR_F", 4 + floor(random 3), "20Rnd_556x45_UW_mag"] call BIS_fnc_addWeapon;
|
2015-08-29 06:09:50 +00:00
|
|
|
};
|
|
|
|
|
2015-09-10 02:05:46 +00:00
|
|
|
_pistols = missionNamespace getVariable [format ["DMS_%1_pistols",_class],[]];
|
2015-08-29 06:09:50 +00:00
|
|
|
if !(_pistols isEqualTo []) then
|
|
|
|
{
|
|
|
|
_pistol = _pistols call BIS_fnc_selectRandom;
|
2015-08-29 19:46:07 +00:00
|
|
|
[_unit, _pistol, 2 + floor(random 2)] call BIS_fnc_addWeapon;
|
2015-08-29 06:09:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Infinite Ammo
|
2015-09-01 23:22:41 +00:00
|
|
|
// This will NOT work if AI unit is offloaded to client
|
2015-09-17 03:37:17 +00:00
|
|
|
_unit addeventhandler ["Fired", {(vehicle (_this select 0)) setvehicleammo 1;}];
|
2015-08-29 06:09:50 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-08-29 17:40:38 +00:00
|
|
|
_OK = _customGearSet params
|
2015-08-29 06:09:50 +00:00
|
|
|
[
|
|
|
|
["_weapon","",[""]],
|
|
|
|
["_weaponAttachments",[],[[]]],
|
|
|
|
["_magazines",[],[[]]],
|
|
|
|
["_pistol","",[""]],
|
|
|
|
["_pistolAttachments",[],[[]]],
|
|
|
|
["_items",[],[[]]],
|
2015-09-10 02:05:46 +00:00
|
|
|
["_launcher","",[""]],
|
2015-08-29 06:09:50 +00:00
|
|
|
["_helmet","",[""]],
|
|
|
|
["_uniform","",[""]],
|
|
|
|
["_vest","",[""]],
|
|
|
|
["_backpack","",[""]]
|
|
|
|
];
|
|
|
|
|
2015-08-29 17:40:38 +00:00
|
|
|
if (!_OK) then
|
2015-08-29 06:09:50 +00:00
|
|
|
{
|
2015-08-29 17:40:38 +00:00
|
|
|
diag_log format ["DMS ERROR :: Calling DMS_SpawnAISoldier with invalid _customGearSet: %1 | _this: %2",_customGearSet,_this];
|
|
|
|
};
|
|
|
|
|
|
|
|
if (DMS_DEBUG) then
|
|
|
|
{
|
|
|
|
diag_log format ["DMS_DEBUG SpawnAISoldier :: Equipping unit %1 with _customGearSet: %2",_unit,_customGearSet];
|
2015-08-29 06:09:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Clothes
|
|
|
|
if !(_helmet isEqualTo "") then
|
|
|
|
{
|
|
|
|
_unit addHeadgear _helmet;
|
|
|
|
};
|
|
|
|
|
|
|
|
if !(_uniform isEqualTo "") then
|
|
|
|
{
|
|
|
|
_unit forceAddUniform _uniform;
|
|
|
|
};
|
|
|
|
|
|
|
|
if !(_vest isEqualTo "") then
|
|
|
|
{
|
|
|
|
_unit addVest _vest;
|
|
|
|
};
|
|
|
|
|
|
|
|
if !(_backpack isEqualTo "") then
|
|
|
|
{
|
|
|
|
_unit addBackpack _backpack;
|
|
|
|
};
|
|
|
|
|
2015-09-10 02:05:46 +00:00
|
|
|
if !(_launcher isEqualTo "") then
|
|
|
|
{
|
|
|
|
[_unit, _launcher, 0] call BIS_fnc_addWeapon;
|
|
|
|
};
|
|
|
|
|
2015-08-29 06:09:50 +00:00
|
|
|
|
|
|
|
// Add Magazines before weapon so that gun will be loaded
|
|
|
|
{
|
2015-09-04 16:45:16 +00:00
|
|
|
if ((typeName _x) == "STRING") then
|
2015-08-29 06:09:50 +00:00
|
|
|
{
|
|
|
|
_x = [_x,1];
|
|
|
|
};
|
|
|
|
_unit addMagazines _x;
|
2015-09-04 16:35:19 +00:00
|
|
|
} forEach _magazines;
|
2015-08-29 06:09:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Add gun and attachments
|
|
|
|
if !(_weapon isEqualTo "") then
|
|
|
|
{
|
2015-09-10 02:05:46 +00:00
|
|
|
[_unit, _weapon, 0] call BIS_fnc_addWeapon;
|
2015-08-29 06:09:50 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
_unit addPrimaryWeaponItem _x;
|
2015-09-04 16:35:19 +00:00
|
|
|
} forEach _weaponAttachments;
|
2015-08-29 06:09:50 +00:00
|
|
|
|
|
|
|
_unit selectWeapon _weapon;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Add pistol and attachments
|
|
|
|
if !(_pistol isEqualTo "") then
|
|
|
|
{
|
2015-09-10 02:05:46 +00:00
|
|
|
[_unit, _pistol, 0] call BIS_fnc_addWeapon;
|
2015-08-29 06:09:50 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
_unit addPrimaryWeaponItem _x;
|
2015-09-04 16:35:19 +00:00
|
|
|
} forEach _pistolAttachments;
|
2015-08-29 06:09:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Add items
|
|
|
|
{
|
|
|
|
_unit addItem _x;
|
2015-09-04 16:35:19 +00:00
|
|
|
} forEach _items;
|
2015-08-29 06:09:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
{
|
|
|
|
_unit setSkill [(_x select 0),(_x select 1)];
|
2015-09-04 16:35:19 +00:00
|
|
|
} forEach (missionNamespace getVariable [format["DMS_ai_skill_%1",_difficulty],[]]);
|
2015-08-29 06:09:50 +00:00
|
|
|
|
2015-08-29 17:40:38 +00:00
|
|
|
|
|
|
|
// Soldier killed event handler
|
2015-09-10 02:05:46 +00:00
|
|
|
_unit addMPEventHandler ["MPKilled",'if (isServer) then {[_this, '+str _side+', '+str _type+'] call DMS_fnc_OnKilled;};'];
|
|
|
|
|
|
|
|
// Remove ramming damage from players. Will not work if unit is not local (offloaded)
|
|
|
|
if (DMS_ai_disable_ramming_damage) then
|
|
|
|
{
|
|
|
|
_unit addEventHandler ["HandleDamage",
|
|
|
|
{
|
|
|
|
_dmg = _this select 2;
|
|
|
|
if (isPlayer (_this select 3) && {(_this select 4)==""}) then
|
|
|
|
{
|
|
|
|
_dmg = 0;
|
|
|
|
};
|
|
|
|
_dmg
|
|
|
|
}];
|
|
|
|
};
|
2015-08-29 06:09:50 +00:00
|
|
|
|
|
|
|
_unit enableAI "TARGET";
|
|
|
|
_unit enableAI "AUTOTARGET";
|
|
|
|
_unit enableAI "MOVE";
|
|
|
|
_unit enableAI "ANIM";
|
|
|
|
_unit enableAI "FSM";
|
|
|
|
|
2015-09-17 03:37:17 +00:00
|
|
|
if (_type=="Soldier") then
|
|
|
|
{
|
|
|
|
_unit setVariable ["DMS_AISpawnPos",_pos];
|
|
|
|
_unit setVariable ["DMS_LastAIDistanceCheck",time];
|
|
|
|
};
|
|
|
|
|
2015-08-29 17:40:38 +00:00
|
|
|
if (DMS_DEBUG) then
|
|
|
|
{
|
2015-09-10 02:05:46 +00:00
|
|
|
diag_log format ["DMS_DEBUG SpawnAISoldier :: Spawned a %1 %2 %6 AI at %3 with %4 difficulty to group %5",_class,_side,_pos,_difficulty,_group,_type];
|
2015-08-29 17:40:38 +00:00
|
|
|
};
|
|
|
|
|
2015-08-29 10:15:48 +00:00
|
|
|
_unit
|