Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.11 KB | None | 0 0
  1. if (!isServer)exitWith{};
  2.  
  3.  
  4.  
  5. private ["_vehpos","_aitype","_aicsskill","_ainum","_skillarray","_position","_skill","_wpRadius","_xpos","_ypos","_unitGroup","_aiskin","_weapon","_magazine","_wppos1","_wppos2","_wppos3","_wppos4","_wp1","_wp2","_wp3","_wp4","_wpfin","_unitArrayName","_unitMissionCount","_patrol","_pilot","_gunner"];
  6.  
  7. _position = _this select 0;
  8. _wpRadius = _this select 1;
  9. _skill = _this select 2;
  10. _aitype = _this select 3;
  11.  
  12. _xpos = _position select 0;
  13. _ypos = _position select 1;
  14.  
  15. //diag_log text format ["[DZMS_Patrol]: AI Pos:%1 / AI SkillLev:%2",_position,_skill];
  16. if (count _this > 4) then {
  17. _mission = _this select 4;
  18. } else {
  19. _mission = nil;
  20. };
  21.  
  22. _skillarray = ["aimingAccuracy","aimingShake","aimingSpeed","endurance","spotDistance","spotTime","courage","reloadSpeed","commanding","general"];
  23. //Lets set the skills
  24. call {
  25. if(_skill == "easy") exitWith { _aicsskill = ai_skill_easy; };
  26. if(_skill == "medium") exitWith { _aicsskill = ai_skill_medium; };
  27. if(_skill == "hard") exitWith { _aicsskill = ai_skill_hard; };
  28. if(_skill == "extreme") exitWith { _aicsskill = ai_skill_extreme; };
  29. if(_skill == "random") exitWith { _aicsskill = ai_skill_random call BIS_fnc_selectRandom; };
  30. _aicsskill = ai_skill_random call BIS_fnc_selectRandom;
  31. };
  32.  
  33. if(_aitype == "Hero") then {
  34. _unitGroup = createGroup RESISTANCE;
  35. } else {
  36. _unitGroup = createGroup EAST;
  37. };
  38.  
  39. //diag_log text format ["[DZMS_Patrol]: Create the Driver"];
  40.  
  41. _aiskin = ai_bandit_skin call BIS_fnc_selectRandom;
  42.  
  43.  
  44. _pilot = _unitGroup createUnit [_aiskin, [0,0,0], [], 1, "NONE"];
  45. [_pilot] joinSilent _unitGroup;
  46.  
  47. call {
  48. if (_aitype == "hero") exitWith { _pilot setVariable ["Hero",true,true]; };
  49. if (_aitype == "bandit") exitWith { _pilot setVariable ["Bandit",true,true]; };
  50. if (_aitype == "special") exitWith { _pilot setVariable ["Special",true,true]; };
  51. };
  52. //Add the behaviour
  53. _pilot enableAI "TARGET";
  54. _pilot enableAI "AUTOTARGET";
  55. _pilot enableAI "MOVE";
  56. _pilot enableAI "ANIM";
  57. _pilot enableAI "FSM";
  58. _pilot setCombatMode "RED";
  59. _pilot setBehaviour "COMBAT";
  60.  
  61. //Remove the items he spawns with by default
  62. removeAllWeapons _pilot;
  63. removeAllItems _pilot;
  64.  
  65. //Now we need to figure out their loadout, and assign it
  66.  
  67. //Get the weapon array based on skill
  68. //_weaponArray = [_skill] call DZMSGetWeapon;
  69.  
  70. //_weapon = _weaponArray select 0;
  71. //_magazine = _weaponArray select 1;
  72.  
  73. //Get the gear array
  74. //_aigearArray = [DZMSGear0,DZMSGear1,DZMSGear2,DZMSGear3,DZMSGear4,DZMSGear5];
  75. //_aigear = _aigearArray call BIS_fnc_selectRandom;
  76. //_gearmagazines = _aigear select 0;
  77. //_geartools = _aigear select 1;
  78.  
  79. _pilot addweapon "Makarov_DZ";
  80. _pilot addmagazine "8Rnd_9x18_Makarov";
  81. _pilot addmagazine "8Rnd_9x18_Makarov";
  82.  
  83. //Gear the AI backpack
  84. //_aipack = DZMSPacklist call BIS_fnc_selectRandom;
  85.  
  86. //Lets add it to the Unit
  87. //for "_i" from 1 to 3 do {
  88. // _pilot addMagazine _magazine;
  89. //};
  90. //_pilot addWeapon _weapon;
  91. //_pilot selectWeapon _weapon;
  92.  
  93. //_pilot addBackpack _aipack;
  94.  
  95.  
  96. //{
  97. // _pilot addMagazine _x
  98. //} forEach _gearmagazines;
  99.  
  100. //{
  101. // _pilot addWeapon _x
  102. //} forEach _geartools;
  103.  
  104.  
  105.  
  106. //diag_log text format ["[DZMS_Patrol]: Create Gunner"];
  107.  
  108. _aiskin = ai_bandit_skin call BIS_fnc_selectRandom;
  109. _gunner = _unitGroup createUnit [_aiskin, [0,0,0], [], 1, "NONE"];
  110. [_gunner] joinSilent _unitGroup;
  111.  
  112. call {
  113. if (_aitype == "hero") exitWith { _gunner setVariable ["Hero",true,true]; };
  114. if (_aitype == "bandit") exitWith { _gunner setVariable ["Bandit",true,true]; };
  115. if (_aitype == "special") exitWith { _gunner setVariable ["Special",true,true]; };
  116. };
  117.  
  118. //Add the behaviour
  119. _gunner enableAI "TARGET";
  120. _gunner enableAI "AUTOTARGET";
  121. _gunner enableAI "MOVE";
  122. _gunner enableAI "ANIM";
  123. _gunner enableAI "FSM";
  124. _gunner setCombatMode "RED";
  125. _gunner setBehaviour "COMBAT";
  126.  
  127. //Remove the items he spawns with by default
  128. removeAllWeapons _gunner;
  129. removeAllItems _gunner;
  130.  
  131. //Now we need to figure out their loadout, and assign it
  132.  
  133. //Get the weapon array based on skill
  134. //_weaponArray = [_skill] call DZMSGetWeapon;
  135.  
  136. //_weapon = _weaponArray select 0;
  137. //_magazine = _weaponArray select 1;
  138.  
  139.  
  140. //Get the gear array
  141. //_aigearArray = [DZMSGear0,DZMSGear1,DZMSGear2,DZMSGear3,DZMSGear4,DZMSGear5];
  142. //_aigear = _aigearArray call BIS_fnc_selectRandom;
  143. //_gearmagazines = _aigear select 0;
  144. //_geartools = _aigear select 1;
  145.  
  146. _gunner addweapon "Makarov_DZ";
  147. _gunner addmagazine "8Rnd_9x18_Makarov";
  148. _gunner addmagazine "8Rnd_9x18_Makarov";
  149.  
  150. //Gear the AI backpack
  151. //_aipack = DZMSPacklist call BIS_fnc_selectRandom;
  152.  
  153. //Lets add it to the Unit
  154. //for "_i" from 1 to 3 do {
  155. // _gunner addMagazine _magazine;
  156. //};
  157. //_gunner addWeapon _weapon;
  158. //_gunner selectWeapon _weapon;
  159.  
  160. //_gunner addBackpack _aipack;
  161.  
  162. //if (DZMSUseNVG) then {
  163. // _gunner addWeapon "NVGoggles";
  164. //};
  165.  
  166. //{
  167. // _gunner addMagazine _x
  168. //} forEach _gearmagazines;
  169.  
  170. //{
  171. // _gunner addWeapon _x
  172. //} forEach _geartools;
  173.  
  174.  
  175.  
  176.  
  177. //_aicsskill = DZMSSkills1;
  178.  
  179.  
  180. //{_gunner setSkill [(_x select 0),(_x select 1)]} forEach _aicsskill;
  181. //{_pilot setSkill [(_x select 0),(_x select 1)]} forEach _aicsskill;
  182. {
  183. _gunner setSkill [(_x select 0),(_x select 1)];
  184. } count _aicsskill;
  185.  
  186. ai_vehicle_units = (ai_vehicle_units + 1);
  187.  
  188. {
  189. _pilot setSkill [_x,1]
  190. } count _skillarray;
  191.  
  192. ai_vehicle_units = (ai_vehicle_units + 1);
  193.  
  194. //Lets prepare the unit for cleanup
  195. _pilot addEventHandler ["Killed",{[_this select 0, _this select 1, "vehicle"] call on_kill;}];
  196.  
  197. _gunner addEventHandler ["Killed",{[_this select 0, _this select 1, "vehicle"] call on_kill;}];
  198.  
  199.  
  200.  
  201. //diag_log text format ["[DZMS_Patrol]: Create the Vehicle"];
  202.  
  203.  
  204.  
  205. _patrol = ["patrol"] call DZMSGetVeh;
  206. HC_VehicleResult = nil;
  207. _vehpos = [(_position select 0) + _wpRadius,(_position select 1) + _wpRadius, 0];
  208. HC_RequestVehicle = [_patrol,_vehpos,0,"NONE"];
  209. publicVariableServer "HC_RequestVehicle";
  210. waitUntil {uisleep 0.5; !isNil "HC_VehicleResult"};
  211. _patrol = HC_VehicleResult;
  212. //[_patrol] call DZMSSetupVehicle;
  213. _patrol setFuel 1;
  214. _patrol engineOn true;
  215. _patrol setVehicleAmmo 1;
  216. _patrol allowCrewInImmobile true;
  217.  
  218. //dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_patrol];
  219.  
  220. _pilot assignAsDriver _patrol;
  221. _pilot moveInDriver _patrol;
  222. _gunner assignAsGunner _patrol;
  223. _gunner moveInTurret [_patrol,[0]];
  224.  
  225. //diag_log text format ["[DZMS_Patrol]: Spawn the Patrol Group"];
  226. //[_patrol] spawn veh_monitor;
  227. if (!isNil "_mission") then {
  228. _patrol setVariable ["missionclean","vehicle"];
  229. _patrol setVariable ["mission",_mission];
  230. // The line below adds the ai vehicle to be monitored in missionwinorfail
  231. ((wai_mission_data select _mission) select 4) set [count ((wai_mission_data select _mission) select 4), _patrol]; // added for vehicle monitor
  232. {
  233. _ainum = (wai_mission_data select _mission) select 0;
  234. wai_mission_data select _mission set [0, (_ainum + 1)];
  235. _x setVariable ["mission",_mission];
  236. } count (crew _patrol);
  237. } else {
  238. [_patrol] spawn vehicle_monitor; // use the standalone vehicle monitor if variable _mission is nil.
  239. };
  240.  
  241.  
  242.  
  243.  
  244.  
  245. _unitGroup allowFleeing 0;
  246. _unitGroup setBehaviour "AWARE";
  247. // These are 4 waypoints in a NorthSEW around the center
  248. _wppos1 = [_xpos, _ypos+50, 0];
  249. _wppos2 = [_xpos+50, _ypos, 0];
  250. _wppos3 = [_xpos, _ypos-50, 0];
  251. _wppos4 = [_xpos-50, _ypos, 0];
  252.  
  253.  
  254. //diag_log text format ["[DZMS_Patrol]: Add Waypoints"];
  255.  
  256. // We add the 4 waypoints
  257. _wp1 = _unitGroup addWaypoint [_wppos1, _wpRadius];
  258. _wp1 setWaypointType "MOVE";
  259. _wp2 = _unitGroup addWaypoint [_wppos2, _wpRadius];
  260. _wp2 setWaypointType "MOVE";
  261. _wp3 = _unitGroup addWaypoint [_wppos3, _wpRadius];
  262. _wp3 setWaypointType "MOVE";
  263. _wp4 = _unitGroup addWaypoint [_wppos4, _wpRadius];
  264. _wp4 setWaypointType "MOVE";
  265.  
  266.  
  267. // Then we add a center waypoint that tells them to visit the rest
  268. _wpfin = _unitGroup addWaypoint [[_xpos,_ypos, 0], _wpRadius];
  269. _wpfin setWaypointType "CYCLE";
  270. _wpfin setWaypointCompletionRadius 150;
  271.  
  272.  
  273. //diag_log text format ["[DZMS_Patrol]: Finished the Patrol Create"];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement