Advertisement
Guest User

Untitled

a guest
Jul 6th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. //_chutetype, _boxtype, _helistart, _crashwreck
  2. private ["_chutetype","_boxtype","_helistart","_crashwreck","_randomizedLoot","_guaranteedLoot","_chute","_box","_num","_weights","_index","_itemType","_lootRadius","_lootPos","_pos","_bam","_i","_nearby","_smoke","_itemTypes","_cntWeights","_lootTable","_playerName","_null","_message2","_markername","_check"];
  3.  
  4. _chutetype = _this select 0;
  5. _boxtype = _this select 1;
  6. _helistart = _this select 2;
  7. _crashwreck = _this select 3;
  8. _randomizedLoot = _this select 4;
  9. _guaranteedLoot = _this select 5;
  10.  
  11. _lootRadius = 1;
  12. _lootTable = ["HeliCrash","MilitarySpecial","Military"] call BIS_fnc_selectRandom;
  13.  
  14. _chute = createVehicle [_chutetype,_helistart,[],0,"CAN_COLLIDE"];
  15. _chute setVariable["Sarge",1];
  16. _chute setPos [(getpos _crashwreck select 0), (getPos _crashwreck select 1), (getPos _crashwreck select 2)-10];
  17.  
  18. _box = createVehicle [_boxtype,_helistart,[],0,"CAN_COLLIDE"];
  19. _box setVariable["Sarge",1];
  20. _box setPos [(getpos _crashwreck select 0), (getPos _crashwreck select 1), (getPos _crashwreck select 2)-10];
  21.  
  22. _box attachto [_chute, [0, 0, 0]];
  23.  
  24. _i = 0;
  25.  
  26.  
  27. while {_i < 45} do {
  28. scopeName "loop1";
  29. if (((getPos _box) select 2) < 1) then {breakOut "loop1"};
  30.  
  31. sleep 1;
  32. _i=_i+1;
  33. };
  34.  
  35.  
  36. switch (true) do {
  37. case not (alive _box): {detach _box;_box setpos [(getpos _box select 0), (getpos _box select 1), 0];};
  38. case alive _box: {detach _box;_box setpos [(getpos _box select 0), (getpos _box select 1), 0];_bam = _boxtype createVehicle [(getpos _box select 0),(getpos _box select 1),(getpos _box select 2)+0];deletevehicle _box;};
  39. };
  40. _bam setVariable["Sarge",1];
  41. deletevehicle _chute;
  42.  
  43. sleep 2;
  44.  
  45. _pos = [getpos _bam select 0, getpos _bam select 1,0];
  46.  
  47. //Map Marker
  48. _null = createMarker ["MarkerDrop",_pos];
  49. "MarkerDrop" setMarkerText "Air Drop";
  50. "MarkerDrop" setMarkerType "mil_dot";
  51. "MarkerDrop" setMarkerColor "ColorRed";
  52. //Map Marker
  53.  
  54.  
  55. /*
  56. // add _check and _markername to private at top
  57. _check = true;
  58. while {_check} do {
  59. _random = round(random 1000);
  60. _markername = format["MarkerDrop%1",_random]; //creates random marker name
  61. if (getMarkerColor _markername == "")then {
  62. _null = createMarker [_markername,_pos];
  63. _markername setMarkerText "Air Drop";
  64. _markername setMarkerType "mil_dot";
  65. _markername setMarkerColor "ColorRed";
  66. _check = false;
  67. //Map Marker2
  68. };
  69. };
  70. */
  71.  
  72. _smoke = createVehicle ["SmokeShellred",_pos,[],0,"CAN_COLLIDE"];
  73. _smoke setVariable["Sarge",1];
  74.  
  75.  
  76.  
  77. //Wait until player is near, wait 90 seconds and delete marker/box.
  78. waitUntil{
  79. sleep 1;
  80. (({isPlayer _x && _x distance _pos <= 5} count playableUnits > 0));
  81. };
  82.  
  83.  
  84. //_message2 = format[" %1 is at the carepackage!",_playerName];
  85. _message2 = format[" A player is looting the carepackage!",_playerName];
  86. [nil,nil,rTitleText,_message2, "PLAIN",6] call RE;
  87.  
  88. sleep 5;
  89. deleteMarker "MarkerDrop";
  90.  
  91. _num = (round(random _randomizedLoot)) + _guaranteedLoot;
  92.  
  93.  
  94. _itemTypes = [] + getArray (configFile >> "CfgBuildingLoot" >> _lootTable >> "lootType");
  95. _index = dayz_CBLBase find _lootTable;
  96. _weights = dayz_CBLChances select _index;
  97. _cntWeights = count _weights;
  98.  
  99. //Creating the Lootpiles outside of the _crashModel
  100. for "_x" from 1 to _num do {
  101. //Create loot
  102. _index = floor(random _cntWeights);
  103. _index = _weights select _index;
  104. _itemType = _itemTypes select _index;
  105.  
  106.  
  107. //Let the Loot spawn in a non-perfect circle around _crashModel
  108. _lootPos = [_pos, ((random 2) + (sizeOf(_boxtype) * _lootRadius)), random 360] call BIS_fnc_relPos;
  109. [_itemType select 0, _itemType select 1, _lootPos, 0] call spawn_loot;
  110.  
  111. diag_log(format["CAREPACKAGE: Loot spawn at '%1' with loot %2", _lootPos, _itemType]);
  112.  
  113. // ReammoBox is preferred parent class here, as WeaponHolder wouldn't match MedBox0 and other such items.
  114. _nearby = _pos nearObjects ["ReammoBox", (sizeOf(_boxtype)+3)];
  115. {
  116. _x setVariable ["permaLoot",true];
  117. } forEach _nearBy;
  118. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement