arma2-epoch-server/@DayZ_Epoch_Server/addons/dayz_server/AdminTools/ServerFunctions/aiSpawn.sqf
2022-04-21 16:15:41 +03:00

118 lines
5.8 KiB
Plaintext
Executable File

private ["_aiMag","_aiWeapon","_aiAssault","_aiMachine","_aiSniper","_aiRandomWep","_aiWepAndMag","_aiPosition","_divisor","_playerUID","_clientKey","_playerPos","_activatingPlayer","_exitReason","_aiArea","_aiCount","_unitGroup","_unit","_deadai","_killer"];
//_activatingPlayer = _this select 0;
//_params = _this select 1;
//_clientKey = _this select 2;
EAT_BanditorHero = _params select 0;
_aiArea = _params select 1;
_aiCount = _params select 2;
_divisor = _params select 3;
_aiPosition = _params select 4;
_playerPos = _params select 6;
//_playerUID = getPlayerUID _activatingPlayer;
_exitReason = [_this,"EAT_AiSpawn",_playerPos,_clientKey,_playerUID,_activatingPlayer] call server_verifySender;
if (_exitReason != "") exitWith {diag_log _exitReason};
#define AI_SKILL [["aimingAccuracy",0.60],["aimingShake",0.60],["aimingSpeed",0.60],["endurance",1.00],["spotDistance",0.60],["spotTime",0.60],["courage",1.00],["reloadSpeed",1.00],["commanding",1.00],["general",1.00]]
#define AI_ITEMS ["ItemBandage","ItemAntibiotic","ItemPainkiller","ItemAntibacterialWipe","ItemMorphine","ItemEpinephrine","FoodCanBakedBeans","FoodCanPotatoes","ItemSodaMtngreen","ItemSodaLemonade"]
#define AI_BAG ["DZ_Czech_Vest_Pouch","DZ_ALICE_Pack_EP1","DZ_TK_Assault_Pack_EP1","DZ_British_ACU","DZ_GunBag_EP1","DZ_CivilBackpack_EP1","DZ_Backpack_EP1","DZ_LargeGunBag_EP1"]
#define BANDIT_SKIN ["Ins_Soldier_GL_DZ","TK_INS_Soldier_EP1_DZ","TK_INS_Warlord_EP1_DZ","GUE_Commander_DZ","GUE_Soldier_Sniper_DZ","GUE_Soldier_MG_DZ","GUE_Soldier_Crew_DZ","GUE_Soldier_2_DZ","GUE_Soldier_CO_DZ","BanditW1_DZ","BanditW2_DZ","Bandit1_DZ","Bandit2_DZ"]
#define HERO_SKIN ["Soldier_Sniper_PMC_DZ","FR_OHara_DZ","Soldier_Bodyguard_AA12_PMC_DZ","FR_R_DZ","FR_Sapper_DZ","FR_Marksman_DZ","FR_Assault_R_DZ","UN_CDF_Soldier_Guard_EP1_DZ","UN_CDF_Soldier_EP1_DZ","BAF_Soldier_N_MTP_DZ"]
#define AI_TOOLS ["ItemKnife","ItemMap","ItemMatchbox","ItemHatchet","ItemToolbox","ItemCrowbar"]
_aiAssault = [["M16A4_ACOG_DZ","30Rnd_556x45_Stanag"],["Sa58V_RCO_EP1","30Rnd_762x39_AK47"],["SCAR_L_STD_Mk4CQT","30Rnd_556x45_Stanag"],["M8_sharpshooter","30Rnd_556x45_Stanag"],["M4A1_Holo_MFL_DZ","30Rnd_556x45_Stanag"],["SCAR_L_STD_HOLO","30Rnd_556x45_Stanag"],["M4A1_CCO_DZ","30Rnd_556x45_Stanag"],["G36C_ACOG_DZ","30Rnd_556x45_G36"],["AKM_Kobra_DZ","30Rnd_762x39_AK47"],["SA58_Holo_DZ","30Rnd_762x39_SA58"],["m8_carbine","30Rnd_556x45_Stanag"],["L85A2_CCO_FL_DZ","30Rnd_556x45_Stanag"],["AK74_GL_PSO1_DZ","30Rnd_545x39_AK"]];
_aiMachine = [["RPK74_Kobra_DZ","75Rnd_545x39_RPK"],["Mk48_CCO_DZ","100Rnd_762x51_M240"],["M249_DZ","200Rnd_556x45_M249"],["Pecheneg_DZ","100Rnd_762x54_PK"],["M240_DZ","100Rnd_762x51_M240"]];
_aiSniper = [["M14_Holo_DZ","20Rnd_762x51_DMR"],["SCAR_H_LNG_Sniper_SD","20Rnd_762x51_SB_SCAR"],["M110_NVG_EP1","20rnd_762x51_B_SCAR"],["SVD_PSO1_Gh_DZ","10Rnd_762x54_SVD"],["VSS_Vintorez","20Rnd_9x39_SP5_VSS"],["DMR_DZ","20Rnd_762x51_DMR"],["M40A3_DZ","5Rnd_762x51_M24"]];
_aiRandomWep = [_aiAssault,_aiAssault,_aiAssault,_aiSniper,_aiMachine];
_aiWepAndMag = (_aiRandomWep call BIS_fnc_selectRandom) call BIS_fnc_selectRandom;
_aiWeapon = _aiWepAndMag select 0;
_aiMag = _aiWepAndMag select 1;
EAT_unitWaypoints = {
private ["_wp","_pos_x","_pos_y","_pos_z","_unitGroup","_position","_waypoint"];
_unitGroup = _this select 0;
_position = _this select 1;
_pos_x = _position select 0;
_pos_y = _position select 1;
_pos_z = _position select 2;
_waypoint = _this select 2;
{
_wp = _unitGroup addWaypoint [_x,10];
_wp setWaypointType "MOVE";
} count [[_pos_x,(_pos_y+_waypoint),0],[(_pos_x+_waypoint),_pos_y,0],[_pos_x,(_pos_y-_waypoint),0],[(_pos_x-_waypoint),_pos_y,0]];
_wp = _unitGroup addWaypoint [[_pos_x,_pos_y,0],_waypoint];
_wp setWaypointType "CYCLE";
};
_unitGroup = createGroup EAST;
for "_x" from 1 to (_aiCount/_divisor) do {
if (EAT_BanditorHero == "Hero") then {
_unit = _unitGroup createUnit [(HERO_SKIN call BIS_fnc_selectRandom),_aiPosition,[],(_aiArea/2),"CAN COLLIDE"];
} else {
_unit = _unitGroup createUnit [(BANDIT_SKIN call BIS_fnc_selectRandom),_aiPosition,[],(_aiArea/2),"CAN COLLIDE"];
};
[_unit] joinSilent _unitGroup;
//_unit setVariable ["Bandit",true];
_unit enableAI "TARGET";
_unit enableAI "AUTOTARGET";
_unit enableAI "MOVE";
_unit enableAI "ANIM";
_unit enableAI "FSM";
_unit setCombatMode "YELLOW";
_unit setBehaviour "COMBAT";
removeAllWeapons _unit;
removeAllItems _unit;
if (sunOrMoon != 1) then {
_unit addWeapon "NVGoggles";
};
_i = 0;
_j = 0;
// Magazine count 3
for "_i" from 1 to 3 do {
_unit addMagazine _aiMag;
};
_unit addWeapon _aiWeapon;
_unit selectWeapon _aiWeapon;
_unit addBackpack (AI_BAG call BIS_fnc_selectRandom);
_unit addWeapon (AI_TOOLS call BIS_fnc_selectRandom);
for "_j" from 1 to 3 do {
_unit addMagazine (AI_ITEMS call BIS_fnc_selectRandom);
};
{
_unit setSkill [(_x select 0),(_x select 1)]
} count AI_SKILL;
_unit addEventHandler ["Killed",{
_deadai = _this select 0;
_killer = _this select 1;
_deadai setVariable ["bodyName","unknown",false];
[_deadai,_killer] spawn {
private ["_humanity","_humankills","_banditkills","_player"];
_player = _this select 1;
if (isPlayer _player) then {
_humanity = _player getVariable["humanity",0];
if (EAT_BanditorHero == "Hero") then {
_humankills = _player getVariable["humanKills",0];
_player setVariable ["humanKills",(_humankills + 1),true];
_player setVariable ["humanity",(_humanity - EAT_HumanityGainLoss),true];
} else {
_banditkills = _player getVariable ["banditKills", 0];
_player setVariable ["banditKills",(_banditkills + 1),true];
_player setVariable ["humanity",(_humanity + EAT_HumanityGainLoss),true];
};
};
uiSleep EAT_aiDeleteTimer; deleteVehicle (_this select 0);};}];
};
_unitGroup setFormation "ECH LEFT";
_unitGroup selectLeader ((units _unitGroup) select 0);
[_unitGroup, _aiPosition, _aiArea] spawn EAT_unitWaypoints;