Guest User

Untitled

a guest
Jul 6th, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.97 KB | None | 0 0
  1. //Animated Helicrashs for DayZ 1.7.6.1
  2. //Version 0.2
  3. //Release Date: 05. April 2013
  4. //Author: Grafzahl
  5. //Thread-URL: http://opendayz.net/threads/animated-helicrashs-0-1-release.9084/
  6.  
  7. private["_useStatic","_crashDamage","_lootRadius","_preWaypoints","_preWaypointPos","_endTime","_startTime","_heliStart","_deadBody","_exploRange","_heliModel","_lootPos","_list","_craters","_dummy","_wp2","_wp3","_landingzone","_aigroup","_wp","_helipilot","_crash","_crashwreck","_smokerand","_staticcoords","_pos","_dir","_position","_num","_config","_itemType","_itemChance","_weights","_index","_iArray","_crashModel","_lootTable","_guaranteedLoot","_randomizedLoot","_frequency","_variance","_spawnChance","_spawnMarker","_spawnRadius","_spawnFire","_permanentFire","_crashName", "_aaa", "_blacklist"];
  8.  
  9. //_crashModel = _this select 0;
  10. //_lootTable = _this select 1;
  11. _guaranteedLoot = _this select 0;
  12. _randomizedLoot = _this select 1;
  13. _frequency = _this select 2;
  14. _variance = _this select 3;
  15. _spawnChance = _this select 4;
  16. _spawnMarker = _this select 5;
  17. _spawnRadius = _this select 6;
  18. _spawnFire = _this select 7;
  19. _fadeFire = _this select 8;
  20. _randomizedWP = _this select 9;
  21. _guaranteedWP = _this select 10;
  22.  
  23. _chutetype = "ParachuteMediumEast";
  24. _boxtype = "Misc_cargo_cont_net1";
  25. _useStatic = false;
  26.  
  27.  
  28.  
  29.  
  30.  
  31. if(count _this > 11) then {
  32. _crashDamage = _this select 11;
  33. } else {
  34. _crashDamage = 1;
  35. };
  36.  
  37.  
  38. diag_log(format["PLANE: Starting spawn logic for Carepackage drops [CD:%1]", _crashDamage]);
  39.  
  40. while {true} do {
  41.  
  42. _preWaypoints = round(random _randomizedWP) + _guaranteedWP;
  43.  
  44. private["_timeAdjust","_timeToSpawn","_spawnRoll","_crash","_hasAdjustment","_newHeight","_adjustedPos"];
  45. // Allows the variance to act as +/- from the spawn frequency timer
  46. _timeAdjust = round(random(_variance * 2) - _variance);
  47. _timeToSpawn = time + _frequency + _timeAdjust;
  48.  
  49. //Random Heli-Type
  50. _heliModel = "MV22_DZ";
  51.  
  52. //Random-Startpositions, Adjust this for other Maps then Chernarus
  53. _heliStart = [[100.7007,100.05298,300],[5000.715,5000.18848,300]] call BIS_fnc_selectRandom;
  54.  
  55.  
  56. _crashName = getText (configFile >> "CfgVehicles" >> _heliModel >> "displayName");
  57.  
  58. diag_log(format["PLANE: %1%2 chance to start a %3 Carepackagedrop at %4 with %5 drop points", round(_spawnChance * 100), '%', _crashName, _timeToSpawn, _preWaypoints]);
  59.  
  60. // Apprehensive about using one giant long sleep here given server time variances over the life of the server daemon
  61. while {time < _timeToSpawn} do {
  62. sleep 5;
  63. };
  64.  
  65. _spawnRoll = random 1;
  66.  
  67. // Percentage roll
  68. if (_spawnRoll <= _spawnChance) then {
  69.  
  70. //Spawn the AI-Heli flying in the air
  71. _startTime = time;
  72. _crashwreck = createVehicle [_heliModel,_heliStart, [], 0, "FLY"];
  73.  
  74. //Make sure its not destroyed by the Hacker-Killing-Cleanup (Thanks to Sarge for the hint)
  75. _crashwreck setVariable["Sarge",1];
  76.  
  77. _crashwreck engineOn true;
  78. _crashwreck flyInHeight 120;
  79. _crashwreck forceSpeed 160;
  80. _crashwreck setspeedmode "NORMAL";
  81.  
  82. /*
  83. //Create an Invisibile Landingpad at the Crashside-Coordinates
  84. _landingzone = createVehicle ["HeliHEmpty", [_position select 0, _position select 1], [], 0, "CAN_COLLIDE"];
  85. _landingzone setVariable["Sarge",1];
  86. */
  87.  
  88. //Only a Woman could crash a Heli this way...
  89. _aigroup = creategroup east;
  90. _helipilot = _aigroup createUnit ["SurvivorW2_DZ",getPos _crashwreck,[],0,"FORM"];
  91. _helipilot moveindriver _crashwreck;
  92. _helipilot assignAsDriver _crashwreck;
  93.  
  94. sleep 0.5;
  95.  
  96.  
  97. _unsorted = [];
  98.  
  99. for "_x" from 1 to _preWaypoints do {
  100.  
  101. _preWaypointPos = [getMarkerPos "center",random 2500,random 360,false] call SHK_pos;
  102. _unsorted = _unsorted + [_preWaypointPos];
  103.  
  104. };
  105.  
  106.  
  107.  
  108.  
  109. _sorted = [];
  110. _pos = [800,2400];
  111.  
  112. {
  113. _closest = _unsorted select 0;
  114. {if ((_x distance _pos) <= (_closest distance _pos)) then {_closest = _x}} forEach _unsorted;
  115.  
  116. _sorted = _sorted + [_closest];
  117.  
  118. _helper = [];
  119. _i=0;
  120. while {!([_helper, _closest] call BIS_fnc_areEqual)} do {
  121. _helper = _unsorted select _i;
  122. _i=_i+1;
  123. };
  124.  
  125. _unsorted set [(_i-1),"delete_me"];
  126. _unsorted = _unsorted - ["delete_me"];
  127. } forEach _unsorted;
  128.  
  129. diag_log(format["PLANE: %1 started flying from %2 to first waypoint NOW!(TIME:%3)", _crashName, str(_heliStart), round(time)]);
  130.  
  131.  
  132.  
  133. for "_x" from 0 to ((count _sorted)-1) do {
  134.  
  135.  
  136. //_preWaypointPos = [_spawnMarker,0,8000,10,0,1000,0,_blacklist] call BIS_fnc_findSafePos;
  137. diag_log(format["PLANE: Adding DROPWaypoint #%1 on %2", (_x+1),str(_sorted select _x)]);
  138. _wp = _aigroup addWaypoint [(_sorted select _x), 0];
  139. _wp setWaypointType "MOVE";
  140. _wp setWaypointBehaviour "CARELESS";
  141.  
  142.  
  143. waituntil {(_crashwreck distance (_sorted select _x)) <= 250 || not alive _crashwreck || (getPosATL _crashwreck select 2) < 5 || (damage _crashwreck) >= _crashDamage};
  144.  
  145. diag_log(format["PLANE IS AT DROPWAYPOINT #%1 on %2", (_x+1),str(getpos _crashwreck)]);
  146. sleep 2;
  147. nul = [_chutetype, _boxtype, _helistart, _crashwreck, _randomizedLoot, _guaranteedLoot] spawn server_carepackagedrop;
  148.  
  149. if (not alive _crashwreck || (damage _crashwreck) >= _crashDamage || (getPosATL _crashwreck select 2) < 5 ) exitWith {diag_log(format["DROPPED 1 LAST PACKAGE WHILE GETTING SHOT DOWN #%1 on %2", _x,str(getpos _crashwreck)]); };
  150.  
  151. };
  152.  
  153.  
  154. _wp2 = _aigroup addWaypoint [_heliStart, 0];
  155. _wp2 setWaypointType "MOVE";
  156. _wp2 setWaypointBehaviour "CARELESS";
  157. diag_log(format["PLANE IS AT END WAYPOINT on %1",str(_heliStart)]);
  158. waituntil {(_crashwreck distance _heliStart) <= 1000 || not alive _crashwreck || (getPosATL _crashwreck select 2) < 5 || (damage _crashwreck) >= _crashDamage};
  159.  
  160. sleep 5;
  161.  
  162. //Clean Up the Crashsite
  163. deletevehicle _crashwreck;
  164. deletevehicle _helipilot;
  165. diag_log(format["PLANE DELETED"]);
  166.  
  167.  
  168.  
  169. _endTime = time - _startTime;
  170. diag_log(format["PLANE: %2 Carepackagedrops completed! Runtime: %1 Seconds", round(_endTime), _preWaypoints]);
  171.  
  172.  
  173. };
  174.  
  175.  
  176. };
Advertisement
Add Comment
Please, Sign In to add comment