JohnO1985

Untitled

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