Advertisement
JohnO1985

Untitled

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