Advertisement
Guest User

server_carAN2.sqf

a guest
Jun 1st, 2013
778
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.63 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 = "hilux1_civil_2_covered";
  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["CARDROP: Starting spawn logic for animated AN2 Carepackage drops - written by Grafzahl, modded by fofinho [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 = "AN2_DZ";
  51.  
  52. //Random-Startpositions, Adjust this for other Maps then Chernarus
  53. _heliStart = [[6993.7007,173.05298,300],[1623.715,218.18848,300]] call BIS_fnc_selectRandom;
  54.  
  55.  
  56. _crashName = getText (configFile >> "CfgVehicles" >> _heliModel >> "displayName");
  57.  
  58. diag_log(format["CARDROP: %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 100;
  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 civilian;
  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 = [[4495.56,7601.14], [3985.08,8360.66], [3374.86,8048.15], [616,811,8318.86], [2777.43,8114.92], [6795.64,7271.39], [7807.35,6560.44], [8290.61,5934.69], [8290.61,5934.69], [8329,5150.43], [5570.28,6703.41], [4202.54,6843.45], [4081.19,5942.29], [3875.53,5044.26], [5467.5,5785.49], [5292.21,5279.04], [5518.68,5020.6], [5127,4608.67], [2284.61,4870.5], [2247.89,3777.36], [2459.01,3437.4], [3088.65,3028.54], [5045.92,3429.64], [6386.93,3229.54], [7683.39,3267.47], [8386.07,2474.11], [8653.95,2219.55], [8306.53,2163.7], [8067.11,1977.19], [7687.68,2312.87], [7266.68,1763.59], [6901,1245.19], [6558.8,875.422]] call BIS_fnc_selectRandom;
  102.  
  103. _unsorted = _unsorted + [_preWaypointPos];
  104.  
  105. };
  106.  
  107.  
  108.  
  109.  
  110. _sorted = [];
  111. _pos = [800,2400];
  112.  
  113. {
  114. _closest = _unsorted select 0;
  115. {if ((_x distance _pos) <= (_closest distance _pos)) then {_closest = _x}} forEach _unsorted;
  116.  
  117. _sorted = _sorted + [_closest];
  118.  
  119. _helper = [];
  120. _i=0;
  121. while {!([_helper, _closest] call BIS_fnc_areEqual)} do {
  122. _helper = _unsorted select _i;
  123. _i=_i+1;
  124. };
  125.  
  126. _unsorted set [(_i-1),"delete_me"];
  127. _unsorted = _unsorted - ["delete_me"];
  128. } forEach _unsorted;
  129.  
  130. diag_log(format["CARDROP: %1 started flying from %2 to first waypoint NOW!(TIME:%3)", _crashName, str(_heliStart), round(time)]);
  131.  
  132.  
  133.  
  134. for "_x" from 0 to ((count _sorted)-1) do {
  135.  
  136.  
  137. //_preWaypointPos = [_spawnMarker,0,8000,10,0,1000,0,_blacklist] call BIS_fnc_findSafePos;
  138. diag_log(format["CARDROP: Adding DROPWaypoint #%1 on %2", (_x+1),str(_sorted select _x)]);
  139. _wp = _aigroup addWaypoint [(_sorted select _x), 0];
  140. _wp setWaypointType "MOVE";
  141. _wp setWaypointBehaviour "CARELESS";
  142.  
  143.  
  144. waituntil {(_crashwreck distance (_sorted select _x)) <= 250 || not alive _crashwreck || (getPosATL _crashwreck select 2) < 5 || (damage _crashwreck) >= _crashDamage};
  145.  
  146. diag_log(format["CARDROP IS AT DROPWAYPOINT #%1 on %2", (_x+1),str(getpos _crashwreck)]);
  147. sleep 2;
  148. nul = [_chutetype, _boxtype, _helistart, _crashwreck, _randomizedLoot, _guaranteedLoot] spawn server_cardrop;
  149.  
  150. if (not alive _crashwreck || (damage _crashwreck) >= _crashDamage || (getPosATL _crashwreck select 2) < 5 ) exitWith {diag_log(format["DROPPED 1 LAST CAR WHILE GETTING SHOT DOWN #%1 on %2", _x,str(getpos _crashwreck)]); };
  151.  
  152. };
  153.  
  154.  
  155. _wp2 = _aigroup addWaypoint [_heliStart, 0];
  156. _wp2 setWaypointType "MOVE";
  157. _wp2 setWaypointBehaviour "CARELESS";
  158. diag_log(format["CARDROP IS AT END WAYPOINT on %1",str(_heliStart)]);
  159. waituntil {(_crashwreck distance _heliStart) <= 1000 || not alive _crashwreck || (getPosATL _crashwreck select 2) < 5 || (damage _crashwreck) >= _crashDamage};
  160.  
  161. sleep 5;
  162.  
  163. //Clean Up the Crashsite
  164. deletevehicle _crashwreck;
  165. deletevehicle _helipilot;
  166. diag_log(format["CARDROP DELETED"]);
  167.  
  168.  
  169.  
  170. _endTime = time - _startTime;
  171. diag_log(format["CARDROP: %2 Cardrops completed! Runtime: %1 Seconds", round(_endTime), _preWaypoints]);
  172.  
  173.  
  174. };
  175.  
  176.  
  177. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement