JohnO1985

Untitled

Jan 7th, 2016
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.64 KB | None | 0 0
  1. /** DYNAMIC AIR PATROL EVENT by JohnO **/
  2.  
  3. diag_log "[UNREST] Ambient air patrol engaged";
  4.  
  5. if (!isServer) exitWith{};
  6.  
  7. private ["_possiblePosStart","_fixedStart","_fixedStartLoc","_markerWaypointOne","_markerWaypointTwo","_markerWaypointThree","_markerWayPointFour","_wayPointOne","_wayPointTwo","_wayPointThree","_wayPointFour","_mk","_pos","_interceptor","_interceptorAircraft"];
  8.  
  9.  
  10. /************************************************************************************************/
  11. /** Random location settings ********************************************************************/
  12. /************************************************************************************************/
  13.  
  14. _spawnCenter = [15834.2,15787.8,0] ; //Center of your map -- this is Altis
  15. _min = 50; // minimum distance from the center position (Number) in meters
  16. _max = 5000; // maximum distance from the center position (Number) in meters
  17. _mindist = 20; // minimum distance from the nearest object (Number) in meters, ie. create waypoint this distance away from anything within x meters..
  18. _water = 0; // water mode 0: cannot be in water , 1: can either be in water or not , 2: must be in water
  19. _shoremode = 0; // 0: does not have to be at a shore , 1: must be at a shore
  20.  
  21. /************************************************************************************************/
  22. /** DEBUG MARKER ********************************************************************************/
  23. /************************************************************************************************/
  24.  
  25. _debug = false; // Will create a marker that will follow the trader.
  26.  
  27. /************************************************************************************************/
  28. /** If using fixed locations or waypoints *******************************************************/
  29. /************************************************************************************************/
  30.  
  31. _fixedStart = false; //If true trader will spawn at fixed location
  32. _fixedStartLoc = getMarkerPos "yourmarker"; //If _fixedStart is true, create a marker and put the marker name here
  33.  
  34. _useMarkerWaypoints = false; //If true, will use set markers instead of random positions - If true populate "yourmarker" with the marker names created
  35.  
  36. _markerWaypointOne = getMarkerPos "waypoint1"; //Create a marker and name it waypoint1
  37. _markerWaypointTwo = getMarkerPos "waypoint2"; //Create a marker and name it waypoint2
  38. _markerWaypointThree = getMarkerPos "waypoint3"; //Create a marker and name it waypoint3
  39. _markerWayPointFour = getMarkerPos "waypoint4"; //Create a marker and name it waypoint4
  40.  
  41. /************************************************************************************************/
  42.  
  43. if (_useMarkerWaypoints) then
  44. {
  45. _wayPointOne = getPos _markerWaypointOne;
  46. _wayPointTwo = getPos _markerWaypointTwo;
  47. _wayPointThree = getPos _markerWaypointThree;
  48. _wayPointFour = getPos _markerWayPointFour;
  49. }
  50. else
  51. {
  52. _wayPointOne = [_spawnCenter,_min,_max,_mindist,_water,5,_shoremode] call BIS_fnc_findSafePos;
  53. _wayPointTwo = [_spawnCenter,_min,_max,_mindist,_water,5,_shoremode] call BIS_fnc_findSafePos;
  54. _wayPointThree = [_spawnCenter,_min,_max,_mindist,_water,5,_shoremode] call BIS_fnc_findSafePos;
  55. _wayPointFour = [_spawnCenter,_min,_max,_mindist,_water,5,_shoremode] call BIS_fnc_findSafePos;
  56. };
  57.  
  58. if (_fixedStart) then
  59. {
  60. _possiblePosStart = getPos _fixedStartLoc;
  61. }
  62. else
  63. {
  64. _possiblePosStart = [_spawnCenter,_min,_max,_mindist,_water,5,_shoremode] call BIS_fnc_findSafePos;
  65. };
  66.  
  67. // LOOT
  68.  
  69. _amountOfWeapons = 5+floor(random 5);
  70. _amountOfItems = 7+floor(random 5);
  71.  
  72. // Starting position for the interceptor and rescue chopper.
  73.  
  74. _rescueStartPos = [[82,8096,0],[150,203,0],[7754,289,0],[7893,7747,0]];
  75. _startPos = _rescueStartPos call BIS_fnc_selectRandom;
  76.  
  77. _lootWeapons =
  78. [
  79. "arifle_MXM_Black_F",
  80. "arifle_MXM_F",
  81. "srifle_DMR_01_F",
  82. "srifle_DMR_02_camo_F",
  83. "srifle_DMR_02_F",
  84. "srifle_DMR_02_sniper_F",
  85. "srifle_DMR_03_F",
  86. "srifle_DMR_03_khaki_F",
  87. "srifle_DMR_03_multicam_F",
  88. "srifle_DMR_03_tan_F",
  89. "srifle_DMR_03_woodland_F",
  90. "srifle_DMR_04_F",
  91. "srifle_DMR_04_Tan_F",
  92. "srifle_DMR_05_blk_F",
  93. "srifle_DMR_05_hex_F",
  94. "srifle_DMR_05_tan_f",
  95. "srifle_DMR_06_camo_F",
  96. "srifle_DMR_06_olive_F",
  97. "srifle_EBR_F",
  98. "srifle_GM6_camo_F",
  99. "srifle_GM6_F",
  100. "srifle_LRR_camo_F",
  101. "srifle_LRR_F",
  102.  
  103. "arifle_MX_SW_Black_F",
  104. "arifle_MX_SW_F",
  105. "LMG_Mk200_F",
  106. "MMG_01_hex_F",
  107. "MMG_01_tan_F",
  108. "MMG_02_camo_F",
  109. "MMG_02_black_F",
  110. "MMG_02_sand_F",
  111. "LMG_Zafir_F",
  112.  
  113. "arifle_Katiba_C_F",
  114. "arifle_Katiba_F",
  115. "arifle_Katiba_GL_F",
  116. "arifle_Mk20_F",
  117. "arifle_Mk20_GL_F",
  118. "arifle_Mk20_GL_plain_F",
  119. "arifle_Mk20_plain_F",
  120. "arifle_Mk20C_F",
  121. "arifle_Mk20C_plain_F",
  122. "arifle_MX_Black_F",
  123. "arifle_MX_F",
  124. "arifle_MX_GL_Black_F",
  125. "arifle_MX_GL_F",
  126. "arifle_MXC_Black_F",
  127. "arifle_MXC_F",
  128. "arifle_SDAR_F",
  129. "arifle_TRG20_F",
  130. "arifle_TRG21_F",
  131. "arifle_TRG21_GL_F"
  132. ];
  133.  
  134. _lootItems =
  135. [
  136. "HandGrenade",
  137. "MiniGrenade",
  138. "B_IR_Grenade",
  139. "O_IR_Grenade",
  140. "I_IR_Grenade",
  141. "1Rnd_HE_Grenade_shell",
  142. "3Rnd_HE_Grenade_shell",
  143. "APERSBoundingMine_Range_Mag",
  144. "APERSMine_Range_Mag",
  145. "APERSTripMine_Wire_Mag",
  146. "ClaymoreDirectionalMine_Remote_Mag",
  147. "DemoCharge_Remote_Mag",
  148. "IEDLandBig_Remote_Mag",
  149. "IEDLandSmall_Remote_Mag",
  150. "IEDUrbanBig_Remote_Mag",
  151. "IEDUrbanSmall_Remote_Mag",
  152. "SatchelCharge_Remote_Mag",
  153. "SLAMDirectionalMine_Wire_Mag",
  154.  
  155. "B_AssaultPack_blk",
  156. "B_AssaultPack_cbr",
  157. "B_AssaultPack_dgtl",
  158. "B_AssaultPack_khk",
  159. "B_AssaultPack_mcamo",
  160. "B_AssaultPack_rgr",
  161. "B_AssaultPack_sgg",
  162. "B_FieldPack_blk",
  163. "B_FieldPack_cbr",
  164. "B_FieldPack_ocamo",
  165. "B_FieldPack_oucamo",
  166. "B_TacticalPack_blk",
  167. "B_TacticalPack_rgr",
  168. "B_TacticalPack_ocamo",
  169. "B_TacticalPack_mcamo",
  170. "B_TacticalPack_oli",
  171. "B_Kitbag_cbr",
  172. "B_Kitbag_mcamo",
  173. "B_Kitbag_sgg",
  174. "B_Carryall_cbr",
  175. "B_Carryall_khk",
  176. "B_Carryall_mcamo",
  177. "B_Carryall_ocamo",
  178. "B_Carryall_oli",
  179. "B_Carryall_oucamo",
  180. "B_Bergen_blk",
  181. "B_Bergen_mcamo",
  182. "B_Bergen_rgr",
  183. "B_Bergen_sgg",
  184. "B_HuntingBackpack",
  185. "B_OutdoorPack_blk",
  186. "B_OutdoorPack_blu",
  187.  
  188. "Rangefinder",
  189. "NVGoggles",
  190. "NVGoggles_INDEP",
  191. "NVGoggles_OPFOR",
  192.  
  193. "Exile_Item_InstaDoc",
  194. "Exile_Item_Vishpirin",
  195. "Exile_Item_Bandage"
  196. ];
  197.  
  198.  
  199.  
  200. // Randomize the start time of the script
  201.  
  202. if (_debug) then
  203. {
  204.  
  205. }
  206. else
  207. {
  208. _delay = round random 1800 + (floor 3600);
  209. uiSleep _delay;
  210. };
  211.  
  212. _side = createCenter EAST;
  213. _airCraft = [_startPos, EAST, ["B_Plane_CAS_01_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;
  214. _airCraftSelection = nearestObjects [_startPos, ["air"], 100];
  215.  
  216. _airCraftLead = _airCraftSelection select 0;
  217.  
  218. _titlePatrol = "WARNING";
  219. _messagePatrol = "A NATO A10 Strike aircraft has been seen patrolling the Island";
  220.  
  221. for "_i" from 1 to 3 do
  222. {
  223. ["systemChatRequest", [format ["%1: %2",_titlePatrol,_messagePatrol]]] call ExileServer_system_network_send_broadcast;
  224. };
  225.  
  226. if (_debug) then
  227. {
  228. [_airCraftLead] spawn
  229. {
  230. _planes = _this select 0;
  231. _pos = position _planes;
  232. _mk = createMarker ["AirCraftLocation",_pos];
  233. while {true} do
  234. {
  235. _pos = position _planes;
  236. "AirCraftLocation" setMarkerType "mil_warning";
  237. "AirCraftLocation" setMarkerText "Planes";
  238. _mk setMarkerPos _pos;
  239. uiSleep 1;
  240. };
  241. };
  242. };
  243.  
  244. diag_log "UNREST Aircraft Patrol created";
  245.  
  246. _airCraft setCombatMode "BLUE";
  247.  
  248. {
  249. _x disableAI "AUTOTARGET";
  250. _x disableAI "TARGET";
  251. _x disableAI "SUPPRESSION";
  252.  
  253. } forEach units _airCraft;
  254.  
  255. _wp1 = _airCraft addWaypoint [_wayPointOne, 0];
  256. _wp1 setWaypointType "MOVE";
  257. _wp1 setWaypointBehaviour "CARELESS";
  258. _wp1 setWaypointspeed "NORMAL";
  259.  
  260. _wp2 = _airCraft addWaypoint [_wayPointTwo, 0];
  261. _wp2 setWaypointType "MOVE";
  262. _wp2 setWaypointBehaviour "CARELESS";
  263. _wp2 setWaypointspeed "NORMAL";
  264.  
  265. _wp3 = _airCraft addWaypoint [_wayPointThree, 0];
  266. _wp3 setWaypointType "MOVE";
  267. _wp3 setWaypointBehaviour "CARELESS";
  268. _wp3 setWaypointspeed "NORMAL";
  269.  
  270. _wp4 = _airCraft addWaypoint [_wayPointFour, 0];
  271. _wp4 setWaypointType "MOVE";
  272. _wp4 setWaypointBehaviour "CARELESS";
  273. _wp4 setWaypointspeed "NORMAL";
  274.  
  275. _wp5 = _airCraft addWaypoint [_wayPointOne, 0];
  276. _wp5 setWaypointType "CYCLE";
  277. _wp5 setWaypointBehaviour "CARELESS";
  278. _wp5 setWaypointspeed "NORMAL";
  279.  
  280. if (_debug) then
  281. {
  282. uiSleep 120;
  283. }
  284. else
  285. {
  286.  
  287. uiSleep 600;
  288. };
  289. _chanceForIntercept = random 1;
  290.  
  291. if (_chanceForIntercept >= 0.5) then {intercept = true;} else {intercept = false;};
  292.  
  293. if (intercept) then
  294. {
  295. diag_log "UNREST Intercept aircraft despatched";
  296. _interceptor = createGroup resistance;
  297.  
  298. _interceptorStartPos = _rescueStartPos call BIS_fnc_selectRandom;
  299.  
  300. [_interceptorStartPos, 180,"I_Plane_Fighter_03_AA_F", _interceptor] call BIS_fnc_spawnVehicle;
  301. _interceptorSelection = nearestObjects [_interceptorStartPos, ["air"], 100];
  302.  
  303. _interceptorAircraft = _interceptorSelection select 0;
  304.  
  305. _interceptor setCombatMode "RED";
  306.  
  307. _waypoints = [_WayPointFour,_wayPointThree,_wayPointTwo,_wayPointOne];
  308. {
  309. _intWP = _interceptor addWaypoint [_x, 0];
  310. _intWP setWaypointType "MOVE";
  311. _intWP setWaypointBehaviour "SAFE";
  312. _intWP setWaypointspeed "FULL";
  313. } forEach _waypoints;
  314.  
  315. if (_debug) then
  316. {
  317. [_interceptorAircraft] spawn
  318. {
  319. _plane2 = _this select 0;
  320. _pos2 = position _plane2;
  321. _mk1 = createMarker ["Y",_pos2];
  322. while {true} do
  323. {
  324. _pos2 = position _plane2;
  325. "Y" setMarkerType "mil_warning";
  326. "Y" setMarkerText "Inter";
  327. _mk1 setMarkerPos _pos2;
  328. };
  329. };
  330. };
  331.  
  332. if (_debug) then
  333. {
  334. uiSleep 60;
  335. }
  336. else
  337. {
  338. uiSleep 360; // Give the interceptor 5 minutes to down the enemy Jet
  339. };
  340.  
  341. if (alive _airCraftLead) then
  342. {
  343. _airCraftLead setDamage 1;
  344. };
  345. }
  346. else
  347. {
  348. if (_debug) then
  349. {
  350. uiSleep 120;
  351. _airCraftLead setDamage 1;
  352. }
  353. else
  354. {
  355. uiSleep 600;
  356. _airCraftLead setDamage 1;
  357. };
  358. };
  359.  
  360. waituntil {(getPos _airCraftLead select 2) < 5};
  361. sleep 10;
  362. _isWater = surfaceIsWater position _airCraftLead;
  363.  
  364. if (!_isWater) then
  365. {
  366. diag_log "UNREST Aircraft Patrol -- Crash sequence initiated";
  367.  
  368. _titleQRF = "WARNING";
  369. _messageQRF = "A NATO Quick reaction force has been despatched to secure the crash site";
  370.  
  371. for "_i" from 1 to 3 do
  372. {
  373. ["systemChatRequest", [format ["%1: %2",_titleQRF,_messageQRF]]] call ExileServer_system_network_send_broadcast;
  374. };
  375.  
  376. _landPos = position _airCraftLead;
  377.  
  378. _helipad = "Land_HelipadEmpty_F" createVehicle _landPos;
  379. sleep 1;
  380. deleteVehicle _airCraftLead;
  381.  
  382. _crash = createVehicle ["Plane_Fighter_03_wreck_F",_landPos,[], 0, "can_collide"];
  383. _crash setPos [position _crash select 0,position _crash select 1, 0.1];
  384. _crash setVectorUp surfaceNormal position _crash;
  385. _smoke = createVehicle ["test_EmptyObjectForFireBig",position _crash,[], 0, "can_collide"];
  386. _smoke attachTo [_crash, [0.5, -2, 1] ];
  387.  
  388. if (intercept) then
  389. {
  390.  
  391. while {(count (waypoints _interceptor)) > 0} do
  392. {
  393. deleteWaypoint ((waypoints _interceptor) select 0);
  394. };
  395.  
  396. diag_log "UNREST Interceptor -- Remaining offensive waypoints deleted";
  397.  
  398. _interceptorExitPos = _rescueStartPos call BIS_fnc_selectRandom;
  399.  
  400. _intExitWP = _interceptor addWaypoint [_interceptorExitPos, 0];
  401. _intExitWP setWaypointType "MOVE";
  402. _intExitWP setWaypointBehaviour "CARELESS";
  403. _intExitWP setWaypointspeed "NORMAL";
  404.  
  405. _interceptor setCombatMode "BLUE";
  406.  
  407. {
  408. _x disableAI "AUTOTARGET";
  409. _x disableAI "TARGET";
  410. _x disableAI "SUPPRESSION";
  411.  
  412. } forEach units _interceptor;
  413.  
  414. diag_log "UNREST Interceptor Aircraft dismiss order initiated";
  415. };
  416.  
  417. _rescueCrew = createGroup EAST;
  418.  
  419. [_startPos, 180,"B_Heli_Transport_01_camo_F", _rescueCrew] call BIS_fnc_spawnVehicle;
  420. _rescueSelection = nearestObjects [_startPos, ["air"], 100];
  421. _chopper = _rescueSelection select 0;
  422.  
  423. if (_debug) then
  424. {
  425. [_chopper] spawn
  426. {
  427. _chopper1 = _this select 0;
  428. _pos3 = position _chopper1;
  429. _mk2 = createMarker ["E",_pos3];
  430. while {true} do
  431. {
  432. _pos3 = position _chopper1;
  433. "E" setMarkerType "mil_warning";
  434. "E" setMarkerText "rescue";
  435. _mk2 setMarkerPos _pos3;
  436. };
  437. };
  438. };
  439.  
  440. diag_log "UNREST Rescue HELO Despatched";
  441.  
  442. _rescueCrew setCombatMode "BLUE";
  443.  
  444. _altWP = [_spawnCenter,_min,_max,_mindist,_water,5,_shoremode] call BIS_fnc_findSafePos;
  445.  
  446. _rescueAltWP1 = _rescueCrew addWaypoint [_altWP, 0];
  447. _rescueAltWP1 setWaypointType "MOVE";
  448. _rescueAltWP1 setWaypointBehaviour "CARELESS";
  449. _rescueAltWP1 setWaypointspeed "NORMAL";
  450.  
  451. _rescueAltWP2 = _rescueCrew addWaypoint [_landPos, 0];
  452. _rescueAltWP2 setWaypointType "GETOUT";
  453. _rescueAltWP2 setWaypointBehaviour "CARELESS";
  454. _rescueAltWP2 setWaypointspeed "NORMAL";
  455.  
  456. if (_debug) then
  457. {
  458.  
  459. _waypointCount = waypoints _rescueCrew;
  460. diag_log format ["Current Waypoints:%1",_waypointCount];
  461. uiSleep 5;
  462. _checkWaypoint = currentWaypoint _rescueCrew;
  463. diag_log format ["Waypoint Index:%1",_checkWaypoint];
  464. uiSleep 5;
  465. _currentWaypointAmount = count _waypointCount;
  466. diag_log format ["Waypoints Remaining:%1",_currentWaypointAmount];
  467. };
  468.  
  469. // Add weapons to the chopper
  470.  
  471. clearMagazineCargoGlobal _chopper;
  472. clearWeaponCargoGlobal _chopper;
  473. clearItemCargoGlobal _chopper;
  474. clearBackpackCargoGlobal _chopper;
  475.  
  476. for "_i" from 1 to _amountOfWeapons do
  477. {
  478. _weapon = _lootWeapons call BIS_fnc_selectRandom;
  479. _chopper addWeaponCargoGlobal [_weapon,1];
  480.  
  481. _magazines = getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines");
  482. _chopper addMagazineCargoGlobal [(_magazines select 0),round random 8];
  483. };
  484.  
  485. for "_i" from 1 to _amountOfItems do
  486. {
  487. _items = _lootItems call BIS_fnc_selectRandom;
  488. _chopper addMagazineCargoGlobal [_items,1];
  489.  
  490. };
  491.  
  492. waituntil {(getPos _chopper select 2) < 1};
  493.  
  494. diag_log "Rescue chopper reached destination";
  495.  
  496. _rescueCrew setCombatMode "RED";
  497. _rescueCrew allowFleeing 0;
  498. _rescueWP2 = _rescueCrew addWaypoint [_landPos, 0];
  499. _rescueWP2 setWaypointType "GETOUT";
  500. _rescueWP2 setWaypointBehaviour "CARELESS";
  501. _rescueWP2 setWaypointspeed "NORMAL";
  502.  
  503. [_rescueCrew, _crash, 50] call bis_fnc_taskPatrol;
  504.  
  505. _aiUnits = ["O_recon_medic_F", "O_Soldier_lite_F","O_Soldier_GL_F","O_Soldier_A_F","O_Soldier_lite_F"];
  506.  
  507. _HeliAiUnits = [position _crash, EAST, _aiUnits,[],[],[],[],[],180] call BIS_fnc_spawnGroup;
  508. //Add waypoint for the AI
  509. _HeliCrashGroupLeader = leader _HeliAiUnits;
  510. _HeliCrashUnitsGroup = group _HeliCrashGroupLeader;
  511.  
  512. {
  513. removeBackpackGlobal _x;
  514. removeAllWeapons _x;
  515. _curWeapon = _lootWeapons call BIS_fnc_selectRandom;
  516. [_x,_curWeapon, 5] call BIS_fnc_addWeapon;
  517. } forEach units _HeliAiUnits;
  518.  
  519. _HeliAIUnits allowFleeing 0;
  520.  
  521. _HeliCrashUnitsGroup addWaypoint [position _crash, 0];
  522. [_HeliCrashUnitsGroup, 0] setWaypointType "GUARD";
  523. [_HeliCrashUnitsGroup, 0] setWaypointBehaviour "AWARE";
  524. }
  525. else
  526. {
  527. diag_log "AIRCRAFT crashed in water -- Terminating rescue sequence";
  528.  
  529. if (intercept) then
  530. {
  531.  
  532. while {(count (waypoints _interceptor)) > 0} do
  533. {
  534. deleteWaypoint ((waypoints _interceptor) select 0);
  535. };
  536.  
  537. diag_log "UNREST Interceptor -- Remaining offensive waypoints deleted";
  538.  
  539. _interceptorExitPos = _rescueStartPos call BIS_fnc_selectRandom;
  540.  
  541. _intExitWP = _interceptor addWaypoint [_interceptorExitPos, 0];
  542. _intExitWP setWaypointType "MOVE";
  543. _intExitWP setWaypointBehaviour "CARELESS";
  544. _intExitWP setWaypointspeed "NORMAL";
  545.  
  546. _interceptor setCombatMode "BLUE";
  547.  
  548. {
  549. _x disableAI "AUTOTARGET";
  550. _x disableAI "TARGET";
  551. _x disableAI "SUPPRESSION";
  552.  
  553. } forEach units _interceptor;
  554.  
  555. diag_log "UNREST Interceptor Aircraft dismiss order initiated";
  556. };
  557. };
  558.  
  559. uiSleep 1800;
  560.  
  561. if (intercept) then
  562. {
  563. deleteVehicle _interceptorAircraft;
  564. };
Advertisement
Add Comment
Please, Sign In to add comment