mmmyum

0.43a

Apr 26th, 2013
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 17.84 KB | None | 0 0
  1. /////     /////     /////     /////     /////     /////     /////     /////     /////
  2. /////////////////////////////////////////////////////////////////////////////////////
  3. ///////////////mmmyum's random animated air raid dayz////////////////////////////////
  4. /////////////////////////////////////////////////////////////////////////////////////
  5. //    README
  6. // change setup to suit your needs
  7. // read further comments if you'd like to customize further
  8. //
  9. //special thanks to arma scripters maxjoiner and darkxess from armaholic, and the opendayz community!//
  10. //
  11. //mmmyum
  12. //
  13. ///////////////////////////////////////////////////INITIALIZE
  14.  
  15. private ["_preWaypointPos","_spawnMarker","_spawnRadius","_x","_wp","_espl","_sound","_duration","_aispawncoords","_aispawn","_rndSel","_loc","_city","_z","_xx","_y","_coords","_target","_posdebug","_heliModel","_heliStart","_safetyPoint","_bomberName","_positionLand","_startTime","_bomber","_landingzone2","_aigroup2","_helipilot2","_wp2","_pos","_siren","_pos1","_bombardStart","_bombardDone","_wp3","_posBomb","_repeat","_break","_choice","_rmodyn","_preWaypoints","_sounddist","_ray","_xypossir","_pos2","_targetpos","_pos2cnt","_seconds","_dblsecs","_playNum","_poswhistl","_sirenB","_citySwing","_wpT","_citySwing2","_wpT2","_wpLand"];
  16. _loc = ["BalottaAirstrip",1.5,4829.9868,2450.1104];
  17. _city = "BalottaAirstrip";
  18. _xx = 4829.9868;
  19. _y = 2450.1104;
  20. _z = 1.5;
  21. _coords = [_xx,_y,_z];
  22. diag_log format ["RANDOM WORLDSPACE: Initializing defaults... %1 | %2 %3 %4|",_city,_xx,_y,_z];
  23. sleep 1;
  24. ////////////////////////////////////////////////////SETUP SETUP SETUP//SETUP SETUP SETUP//SETUP SETUP SETUP//SETUP SETUP SETUP//SETUP SETUP SETUP
  25. _repeat = 30;                             //times to repeat
  26. _break = 300;                             //time to break between attacks, in seconds
  27. _choice = 1;                              //type of bombing 1 light, 2 medium, 3 heavy
  28. _duration = 60;                           //how long the bombing should last - really how many bombs are dropped assuming 1 per cycle
  29. _rmodyn = true;                              //1 if you have rmod, 0 if you don't (mv22 mi24 vs uh1h and mi17)
  30. _preWaypoints = 0;                        //untested, add waypoints before arriving at location.
  31. _sounddist = 1500;                        //distance sounds are audible at
  32. _ray = 120;                               //ray of bombing
  33. _seconds = _duration; // time bombing dont change me
  34. _dblsecs = _seconds * 2;
  35. ////////////////////////////////////////////////////END SETUP//END SETUP//END SETUP//END SETUP//END SETUP//END SETUP//END SETUP//END SETUP
  36. //selector
  37. While {_repeat > 1} do {
  38. _duration = 60;                           //how long the bombing should last - really how many bombs are dropped assuming 1 per cycle
  39. _rndSel=floor(random 49); //select random number 0-49, then set loc based on the case number//change locations if you'd like, format ["name",z,x,y]
  40. _loc=
  41. switch (_rndSel) do {
  42. case 0: {["BalottaAirstrip",1.5,4829.9868,2450.1104]};
  43. case 1: {["Berenzino",1.5,12954.624,9783.1533]};
  44. case 2: {["Bereznio2",1.5,12043.963,9091.3477]};
  45. case 3: {["BlackMountain",1.5,10276.416,12049.6640]};
  46. case 4: {["Bor",1.5,3320.1643,3938.3496]};
  47. case 5: {["Cherno",1.5,6743.8853,2581.1865]};
  48. case 6: {["DevilsCastle",1.5,6891.9189,11438.73]};
  49. case 7: {["DonsCamp",1.5,7788.2856,12613.048]};
  50. case 8: {["Drozhino",1.5,3442.2849,4955.7129]};
  51. case 9: {["Dubrovka",1.5,10445.011,9868.9912]};
  52. case 10: {["Electro",1.5,10480.69,2217.8027]};
  53. case 11: {["Factory",1.5,13060.078,7094.0596]};
  54. case 12: {["Gorka",1.5,9659.084,8795.334]};
  55. case 13: {["Grishno",1.5,5979.6953,10343.341]};
  56. case 14: {["Guglovo",1.5,8517.8682,6676.3276]};
  57. case 15: {["Gvozdno",1.5,8614.4316,11868.967]};
  58. case 16: {["Kabanino",1.5,5318.8369,8602.6328]};
  59. case 17: {["Kamyshovo",1.5,12127.406,3496.2185]};
  60. case 18: {["Khelm",1.5,12290.833,10904.328]};
  61. case 19: {["Komarovo",1.5,3654.0908,2475.9468]};
  62. case 20: {["Kozlovka",1.5,4483.6777,4616.1675]};
  63. case 21: {["Krastonav",1.5,11212.624,12256.609]};
  64. case 22: {["Lopatino",1.5,2780.3135,10018.82]};
  65. case 23: {["Moglievka",1.5,7544.5845,5148.7822]};
  66. case 24: {["Msta",1.5,11275.323,5495.4053]};
  67. case 25: {["Myshkino",1.5,2019.2487,7327.7178]};
  68. case 26: {["Nadezhdino",1.5,5846.4434,4706.708]};
  69. case 27: {["NEAF",1.5,12073.906,12724.305]};
  70. case 28: {["Nizhnoye",1.5,13002.393,8285.8574]};
  71. case 29: {["NovySobor",1.5,7074.4854,7683.4883]};
  72. case 30: {["NWAF",1.5,4480.0781,10375.544]};
  73. case 31: {["Orlovets",1.5,12146.174,7266.5801]};
  74. case 32: {["Pavlovo",1.5,1693.9392,3845.0657]};
  75. case 33: {["Petrovka",1.5,5014.1143,12493.039]};
  76. case 34: {["Pogorevka",1.5,4473.5957,6411.3198]};
  77. case 35: {["Polana",1.5,10753.393,8132.6606]};
  78. case 36: {["Prigorodki",1.5,7976.5557,3299.5386]};
  79. case 37: {["Pulkovo",1.5,4915.0903,5605.6401]};
  80. case 38: {["Pusta",1.5,9156.2549,3897.7598]};
  81. case 39: {["Pustoshka",1.5,3072.9629,7945.4404]};
  82. case 40: {["Rogovo",1.5,4808.0024,6805.0518]};
  83. case 41: {["Shakhovka",1.5,9654.5244,6555.2583]};
  84. case 42: {["Solnichny",1.5,13454.279,6233.647]};
  85. case 43: {["Soosnovka",1.5,2528.7561,6354.9839]};
  86. case 44: {["Staroye",1.5,10140.659,5434.4302]};
  87. case 45: {["StarySobor",1.5,6143.6167,7721.5176]};
  88. case 46: {["Tulga",1.5,12803.296,4450.7466]};
  89. case 47: {["Vybor",1.5,3815.0635,8865.0938]};
  90. case 48: {["Vyshnoye",1.5,6590.3159,6029.1128]};
  91. case 49: {["Zelenogorsk",1.5,2758.7144,5304.3457]};
  92. };
  93. _city = _loc select 0;
  94. _z = _loc select 1;
  95. _xx = _loc select 2;
  96. _y = _loc select 3;
  97. _coords = [_xx,_y,_z]; ////////////////////////////////////////////////does this need spaces?
  98. diag_log format ["RANDOM WORLDSPACE: %1 | %2",_city,_coords];
  99. sleep 1;
  100. diag_log format ["RANDOM WORLDSPACE SELECTED: %1 | City: %2 | Coords: %3  %4 |||Try %5",_rndSel,_city,_xx,_y,_repeat];
  101. //_repeat = _repeat - 1;/////////////////////////////////////////not sure why this was here
  102. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  103. //above  ---- the worldpace is selected, coordinates stored in _coords = [_xx,_y,_z]/////////////////////////////////////////////////////////
  104. //below  ---- chopper is created, flies to waypoint _coords while sirens play, hangs around till bombs are done flies off and is deleted/////////////
  105. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  106. //CREATE TARGET///////////////
  107. _loc = createVehicle ["HeliHEmpty", _coords,[], 0, "NONE"];
  108. _target = createVehicle ["HeliHEmpty",position _loc,[], 0, "NONE"];  
  109. _posdebug = position _target;
  110. diag_log format ["AIRRAID: SEL: %1 | TARGET: %2 | SHOULD MATCH APPROX",_posdebug,_coords];
  111. /////above is the target to bomb
  112. sleep 2;
  113.     //Random Heli-Type
  114.     if (_rmodyn) then {
  115.         _heliModel = ["Mi24_D","MV22"] call BIS_fnc_selectRandom;
  116.     } else {
  117.         _heliModel = ["UH1H_DZ","Mi17_DZ"] call BIS_fnc_selectRandom;
  118.     };
  119.     //_heliModel = "UH1H_DZ";
  120.     //Random-Startpositions, Adjust this for other Maps then Chernarus //////////////////////////////mmmyum - change me to where you want heli to start, ie over carrier?
  121.     _heliStart = [[6993.7007,173.05298,300],[1623.715,218.18848,300]] call BIS_fnc_selectRandom;
  122.  
  123.     //A Backup Waypoint, if not Chernarus, set some Coordinates far up in the north (behind all possible Crashsites)////again, change to whereever you would like
  124.     _safetyPoint = [7492.6675, 15263.042];
  125.  
  126.     _bomberName = getText (configFile >> "CfgVehicles" >> _heliModel >> "displayName");
  127.  
  128.     diag_log(format["AIRRAID: BOMBER: %1 | Lift Off at %2 | with Backup WP %3",_bomberName,str(_heliStart),str(_safetyPoint)]);
  129.     diag_log(format["AIRRAID: BOMBER: %1 | TYPE: %2 |",_bomberName,_heliModel]);
  130.        
  131.     _positionLand = [position _target,0,200,5,0,2000,0] call BIS_fnc_findSafePos; //set chopper destination
  132.  
  133.     diag_log(format["AIRRAID: BOMBER: %1 started flying from %2 to %3 NOW!(TIME:%4|)", _bomberName,  str(_heliStart), str(_positionLand), round(time)]);
  134.  
  135.         //Spawn the AI-Heli flying in the air
  136.         _startTime = time;
  137.         _bomber = createVehicle [_heliModel,_heliStart, [], 0, "FLY"];
  138.  
  139.         //Make sure its not destroyed by the Hacker-Killing-Cleanup (Thanks to Sarge for the hint)
  140.         _bomber setVariable["Sarge",1,true];                //I'm unsure what do to here, so I'm leaving it
  141.  
  142.         _bomber engineOn true;
  143.         _bomber flyInHeight 350;
  144.         _bomber forceSpeed 250;
  145.         //_bomber setspeedmode "LIMITED";
  146.  
  147.         //Create an Invisibile Landingpad at the Crashside-Coordinates
  148.         _landingzone2 = createVehicle ["HeliHEmpty", [_positionLand select 0, _positionLand select 1,0], [], 0, "CAN_COLLIDE"]; //_targets x,y
  149.         _landingzone2 setVariable["Sarge",1];
  150.         diag_log(format["AIRRAID: BOMBER: LANDINGZONE: %1 | BOMBER POS: %2 | POS LAND: %3",str(getPosATL _landingzone2),str(getPosATL _bomber),str(_positionLand)]);
  151.  
  152.         //Only a Woman could crash a Heli this way...
  153.         _aigroup2 = creategroup civilian;
  154.         _helipilot2 = _aigroup2 createUnit ["SurvivorW2_DZ",getPos _bomber,[],0,"FORM"];
  155.         _helipilot2 moveindriver _bomber;
  156.         _helipilot2 assignAsDriver _bomber;
  157.        
  158.  
  159.         sleep 0.5;
  160.  
  161.         if(_preWaypoints > 0) then {
  162.             for "_x" from 1 to _preWaypoints do {
  163.                     _preWaypointPos = [getMarkerPos _spawnMarker,0,_spawnRadius,10,0,2000,0] call BIS_fnc_findSafePos;
  164.                 };
  165.                 diag_log(format["AIRRAID: BOMBER: Adding Pre-POC-Waypoint #%1 on %2", _x,str(_preWaypointPos)]);
  166.                 _wp = _aigroup2 addWaypoint [_preWaypointPos, 0];
  167.                 _wp setWaypointType "MOVE";
  168.                 //_wp setWaypointBehaviour "CARELESS";
  169.             };
  170.  
  171.         _wp2 = _aigroup2 addWaypoint [position _target, 0];
  172.         _wp2 setWaypointType "MOVE";
  173.         //_wp2 setWaypointBehaviour "CARELESS";
  174.  
  175.         //Get some more Speed when close to the Crashpoint and go on even if Heli died or hit the ground
  176.         waituntil {(_bomber distance _positionLand) <= 2500};
  177.             _bomber flyInHeight 300;
  178.             _bomber forceSpeed 260;
  179.             _bomber setspeedmode "NORMAL";
  180. ///////////////////////////////////////////////////////////////////START SIRENS/////////////////////////////////////////////////////
  181.                 _xypossir = position _target;
  182.                 diag_log format ["AIRRAID: INCOMING ATTACK: Sounding Siren at: %1 %2 | Repeat: %3| Type: %4 | Duration: %5",_xypossir,_wp2,_repeat,_choice,_duration];
  183.                 _pos = position _target;
  184.                 diag_log format ["AIRRAID: POS: %1 | TARGET: %2 | SHOULD MATCH",_pos,_coords];
  185.                
  186.                 _siren = createVehicle ["HeliHEmpty",position _target,[], 0, "NONE"];                      //create siren
  187.                 _sirenB = createVehicle ["HeliHEmpty",position _target,[], 0, "NONE"];
  188.  
  189.                 _pos1 = position _siren;
  190.                 diag_log format ["AIRRAID: SIREN: %1 | TARGET: %2 | SHOULD MATCH APPROX",_pos1,_coords];
  191.                 diag_log(format["AIRRAID: BOMBER: %1 is at %2!, ", _bomberName, str(getPosATL _bomber)]);
  192.                 [nil,_siren,rSAY,['eve', 3500]] call RE;
  193.                 [nil,_sirenB,rSAY,['puk', 3500]] call RE;
  194.                
  195.                 ////////////////////////////////////////////////////////Sound the alarm
  196.                     _playNum = 15;
  197.                     while {_playNum > 0} do {
  198.                        
  199.                             //_siren say ["nam",_sounddist];  
  200.                             //_siren1S = [objNull, _siren, rSAY, ["nam", 2500]] call RE;
  201.                             //[objNull, _siren, rSAY, ["nam", 2500]] call RE;
  202.                             [nil,_siren,rSAY,['nam', 3500]] call RE;
  203.                             //_nul = [nil, _siren, rSAY, ["nam", 2500]] call RE; // This is a RPC sound call for the sound
  204.                        
  205.                     sleep 10;
  206.                     diag_log(format["AIRRAID: Playing Siren TRY 1 NO FOREACH at %1 | Siren Nam 2500",str(getPosATL _siren)]);
  207.                     _playNum = _playNum - 1;
  208.                     };
  209.                     [nil,_siren,rSAY,['eve', 3500]] call RE;
  210.                     sleep 1;
  211.                     [nil,_sirenB,rSAY,['puk', 3500]] call RE;
  212.                     sleep 10;
  213.                     /////////////Sound alarm try 2 with foreach
  214.                     _playNum = 15;
  215.                     while {_playNum > 0} do {
  216.                         {
  217.                             //_siren say ["nam",_sounddist];  
  218.                             //_siren1S = [objNull, _siren, rSAY, ["nam", 2500]] call RE;
  219.                             //[objNull, _siren, rSAY, ["nam", 2500]] call RE;
  220.                             [nil,_siren,rSAY,['nam', 3500]] call RE;
  221.                             //_nul = [nil, _siren, rSAY, ["nam", 2500]] call RE; // This is a RPC sound call for the sound
  222.                         } foreach playableUnits;
  223.                        
  224.                     sleep 11;
  225.                     diag_log(format["AIRRAID: Playing Siren TRY 2 FOREACH at %1 | Siren Nam 2500",str(getPosATL _siren)]);
  226.                     _playNum = _playNum - 1;
  227.                     };
  228. //////////////////////////////////////////////////////////end siren loops - TODO - add short siren below for each step
  229.            
  230.         //waituntil {(_bomber distance _positionLand) <= 1500};
  231.             _bomber flyInHeight 350;
  232.             _bomber forceSpeed 180;
  233.             _bomber setspeedmode "NORMAL";
  234.             diag_log(format["AIRRAID: BOMBER: %1 is at %2!, ", _bomberName, str(getPosATL _bomber)]);
  235.             [nil,_siren,rSAY,['eve', 3500]] call RE;
  236.             sleep 20;
  237.             [nil,_sirenB,rSAY,['puk', 3500]] call RE;
  238.            
  239.         //waituntil {(_bomber distance _positionLand) <= 700};
  240.             _bomber flyInHeight 360;
  241.             _bomber forceSpeed 120;
  242.             _bomber setspeedmode "NORMAL";
  243.             //new
  244.             _citySwing = [position _bomber,15,35,3,0,2000,0] call BIS_fnc_findSafePos; //set chopper cycle move back and forth over city
  245.             _wpT = _aigroup2 addWaypoint [_citySwing, 0];
  246.             _wpT setWaypointType "MOVE";
  247.             _citySwing2 = [position _target,15,25,3,0,2000,0] call BIS_fnc_findSafePos; //set chopper cycle move back and forth over city
  248.             _wpT2 = _aigroup2 addWaypoint [_citySwing2, 0];
  249.             _wpT2 setWaypointType "MOVE";
  250.             //end new
  251.             _bombardStart = true; //set var so we know to start bombing (heli is in position)
  252.             diag_log(format["AIRRAID: BOMBER: %1 Bombing Initialize: arrived at %2!, ", _bomberName, str(getPosATL _bomber)]);
  253.            
  254. ///////////////////////////////////////////////////START BOMBING////////////////////////////////////////////////////////////////////
  255. diag_log format ["AIRRAID: Bombing Area: %1",_xypossir];
  256.  
  257. //bomb while _duration > 1
  258. _pos2 = [getPosATL _siren];
  259. [nil,_sirenB,rSAY,['puk', 3500]] call RE;
  260. [nil,_siren,rSAY,['nam', 3500]] call RE;
  261. While {_duration > 1} do {
  262. _sound = createVehicle ["HeliHEmpty",position _target,[], _ray, "NONE"];
  263. [nil,_sound,rSAY,['mortar1', 3500]] call RE;
  264. //_sound say ["mortar1",3500];
  265. _pos2 set [_seconds, getPosATL _sound];
  266. sleep 2;
  267. If (_choice == 1) then {
  268. _espl = createVehicle ["SH_105_HE",position _sound,[], 0, "NONE"];
  269. };
  270. If (_choice == 2) then {
  271. _espl = createVehicle ["SH_125_HE",position _sound,[], 0, "NONE"];
  272. };
  273. If (_choice == 3) then {
  274. _espl = createVehicle ["BO_GBU12_LGB",position _sound,[], 0, "NONE"];
  275. };
  276. _pos2 = [_dblsecs,getPosATL _espl];
  277. _poswhistl = getPosATL _sound;
  278. _targetpos = getPosATL _target;
  279. _pos2cnt = count _pos2;
  280. diag_log format ["AIRRAID: BOMB: %1 | TARGET: %2 | SHOULD MATCH APPROX ||| debug arraycount %3 | number %4 | sound %5",str(_pos2),_targetpos,_pos2cnt,_duration,_poswhistl];
  281. _duration = _duration - 1;
  282. deletevehicle _sound;
  283. }; // Close while loop. loop while _duration >1
  284. _bombardDone = true; //set done bombing
  285. ///////////////////////////////////////////////////END SIRENS AND BOMBING, HELI LOWER TO GROUND, (SPAWN AIs), FLY AWAY//////////////////////////////////////////////////////////////
  286.            
  287.         waituntil {_bombardDone}; ///////////////////hover over town until town is bombed to shit
  288.            
  289.             _wpLand = _aigroup2 addWaypoint [position _target, 0];
  290.             _wpLand setWaypointType "MOVE";
  291.             sleep 3;
  292.             _bomber flyInHeight 15;
  293.             _bomber forceSpeed 140;
  294.             _bomber setspeedmode "NORMAL";
  295.             sleep 10;
  296.             diag_log(format["AIRRAID: BOMBER: %1 has Completed Bombing at %2!, ", _bomberName, str(getPosATL _bomber)]);
  297.             if (_repeat > 25) then {
  298.             _aispawncoords = position _bomber;
  299.             sleep 15;
  300.             diag_log(format["AIRRAID: BOMBER: AISPAWN: %1 ",_aispawncoords]);
  301.             _aispawn = [[_aispawncoords select 0,_aispawncoords select 1,0],5000,20,6] execVM "units\add_unit_server.sqf"; //whole map waypoints//mmmyum//spawn ais (probably shouldn't run this every time)////
  302.             };
  303.         //Giving the crashed Heli some time to leave
  304.         sleep 15;
  305.            
  306.         //Adding a last Waypoint up in the North, to send bomber away after completion. Chane this location (_safetypoint) to where you want the AI to seem to originate from
  307.         _wp3 = _aigroup2 addWaypoint [_safetyPoint, 0];
  308.         _wp3 setWaypointType "MOVE";
  309.         _wp3 setWaypointBehaviour "CARELESS";
  310.  
  311.         //Get position of the helis
  312.         _posBomb = [getpos _bomber select 0, getpos _bomber select 1,0];
  313.         sleep 2;
  314.         _bomber forceSpeed 200;
  315.         _bomber flyInHeight 300;
  316.         _bomber setspeedmode "NORMAL";
  317.         diag_log(format["AIRRAID: BOMBER: %1 Leaving Area %2!, ", _bomberName, str(getPosATL _bomber)]);
  318.        
  319. //////////////////////////////////////////////////////////CLEAN UP//CLEAN UP//CLEAN UP//
  320.         sleep 15;
  321.         waituntil {(_bomber distance _safetyPoint) <= 2000};
  322.             //_bomber set damage 1;
  323.             //_bomber set fuel 0;
  324.             _bomber setspeedmode "NORMAL";
  325.             sleep 3;
  326.             deletevehicle _bomber;
  327.             deletevehicle _landingzone2;
  328.             deletevehicle _helipilot2;
  329.             _repeat = _repeat - 1;
  330.             deletevehicle _siren;
  331.             deletevehicle _loc;
  332.             deletevehicle _target;
  333.             diag_log format ["AIRRAID: Going down for sleep: Repeat:%1 | Sleep:%2",_repeat,_break];
  334.             sleep _break;    
  335. }; //close while loop. loop -  while _repeat > 1
  336. exit
  337.  
  338. ///////////////////////////////////////////TO DO
  339. //
  340. //bombs start to drop from chopper pos as it hits city borders
  341. //                                 chopper hovers at ground level for ~10 s while troops hop out
  342. //nuke options (this is still a ways off)
  343. //random siren sound selection per rotation (option)
  344. //                                redistribute siren sounds to make a nicer pattern (ie calmest plays first, then more stressful as chopper approaches, super stressful when bombs are about to start)
  345. //make chopper killable to stop event (add exception where loop exits if chopper is destroyed)
  346. //error handling if chopper is accidentally killed
  347. //           3 waypoints surrounding city so chopper flies around while bombing
  348. //                                enable rmodyn to select different heli models (selectable if you have rmod or not to include more helis)
  349. //clean up excess debug diag_logs
  350. //clean up extra variables and make efficient
  351. //clean up formatting, comment up, so it's all clear to everyone
Advertisement
Add Comment
Please, Sign In to add comment