Advertisement
skotracker

groundBoxes

Apr 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 18.07 KB | None | 0 0
  1. /*
  2.     File: groundBoxes.sqf
  3.     Author: =CF=Dragunov, adapted from original spawnboxes from NedFox [TZW]
  4.     Description: Custom Crates, randomly at placed ground, inside a marker which is visible (or not).
  5. */
  6.  
  7. if (!isServer) exitWith {};
  8.  
  9. uiSleep 1100;
  10.  
  11. _numberofcrates = 4; // this is the number of crates that you want to spawn //not used
  12. _world = (toLower worldName);
  13. _middle = worldSize/2;
  14. _spawnCenter    = [_middle,_middle,0];
  15. _max        = _middle - 100;
  16.  
  17. switch (toLower worldName) do
  18. {
  19.     case "tanoa":
  20.     {
  21.         _spawnCenter = [7680,7680,0];
  22.         _max = 7580;
  23.     };
  24.     case "altis":
  25.     {
  26.         _spawnCenter = [15234.2,14987.8,0];
  27.         _max = 15000;
  28.     };
  29.     case "chernarus":
  30.     {
  31.         _spawnCenter = [7652.9634, 7870.8076,0];
  32.         _max = 7500;
  33.     };
  34.     case "taviana":
  35.     {
  36.         _spawnCenter = [12800, 12800,0];
  37.         _max = 12800;
  38.     };
  39. };
  40. diag_log format['[groundBoxes] worldname: %1 Centre: %2 radius: %3',_world,_spawnCenter,_max];
  41.  
  42. _min                = 0; // minimum distance from the center position (Number) in meters
  43. _mindist            = 5; // minimum distance from the nearest object (Number) in meters, ie. spawn at least this distance away from anything within x meters..
  44. _water              = 0; // water mode (Number) 0: cannot be in water , 1: can either be in water or not , 2: must be in water
  45. _shoremode          = 0; // 0: does not have to be at a shore , 1: must be at a shore
  46. _marker             = true; // Draw a yellow circle in which the crate will be spawned randomly
  47. _markersize         = 100; // Radius of the marker in meters
  48.  
  49. private['_position'];
  50.  
  51. diag_log format['[groundBoxes] Starting @ %1',time];
  52.  
  53.  
  54. ////////////////////////////////////////////////////////////////////////////////////////////////////
  55. //Crate 1
  56. ////////////////////////////////////////////////////////////////////////////////////////////////////
  57.  
  58.     _validspot  = false;
  59.     while{!_validspot} do
  60.     {
  61.         sleep 1;
  62.         _position = [_spawnCenter,_min,_max,_mindist,_water,20000,_shoremode] call BIS_fnc_findSafePos;
  63.         _validspot  = true;
  64.  
  65.  
  66.         //Check if near another crate
  67.         // Get nearest CargoNet_01_box_F
  68.         _nearOtherCrate = (nearestObjects [_position,["CargoNet_01_box_F"],750]) select 0;
  69.         if (!isNil "_nearOtherCrate") then
  70.         {
  71.             _nearestCrate = _position distance _nearOtherCrate;
  72.             if (_nearestCrate < 750) then
  73.             {
  74.                 _validspot = false;
  75.             };
  76.         };
  77.  
  78.         //Check if near player base
  79.         // Get nearest Exile_Construction_Flag_Static
  80.         _nearBase = (nearestObjects [_position,["Exile_Construction_Flag_Static"],750]) select 0;
  81.         if (!isNil "_nearBase") then
  82.         {
  83.             _nearestBase = _position distance _nearBase;
  84.             if (_nearestBase < 750) then
  85.             {
  86.                 _validspot = false;
  87.             };
  88.         };
  89.  
  90.     };
  91.  
  92.     if (_marker) then
  93.     {
  94.         _event_marker5 = createMarker [ format ["loot_marker_%1", 5], _position];
  95.         _event_marker5 setMarkerColor "ColorYellow";
  96.         _event_marker5 setMarkerAlpha 0.65;
  97.         _event_marker5 setMarkerText "Crate1";
  98.         _event_marker5 setMarkerType "loc_Tree";
  99.         _event_marker5 setMarkerBrush "Vertical";
  100.         _event_marker5 setMarkerSize [(2), (2)];
  101.     };
  102.  
  103.     diag_log format['Spawncrate %1 : Location %2',5,_position];
  104.  
  105.     //Infantry spawns using the DMS
  106.     _AICount = 5 + (round (random 2));
  107.     _spawnPosition = [_position select 0, _position select 1, 0];
  108.     _group5 = [_spawnPosition, _AICount, "random", "random", "bandit"] call DMS_fnc_SpawnAIGroup;
  109.     _group5 setVariable ["DMS_LockLocality",nil];
  110.     _group5 setVariable ["DMS_SpawnedGroup",true];
  111.     _group5 setVariable ["DMS_Group_Side", "bandit"];
  112.  
  113.     [_group5, _spawnPosition, 100] call bis_fnc_taskPatrol;
  114.     _group5 setBehaviour "STEALTH";
  115.     _group5 setCombatMode "RED";
  116.  
  117.     diag_log text format ["[groundBoxes]: Creating crate drop zone %1 with %2 guards",_spawnPosition,_AICount];
  118.  
  119.     _box = "CargoNet_01_box_F" createvehicle _position;
  120.  
  121.     clearMagazineCargoGlobal _box;
  122.     clearWeaponCargoGlobal _box;
  123.     clearItemCargoGlobal _box;
  124.     _box setVariable ["permaLoot",true]; //stay until reset
  125.     _box allowDamage false; // Prevent boxes to explode when spawning
  126.     // Building Crate
  127.  
  128.     _box addItemCargoGlobal ["Exile_Item_DuctTape", (random 2)];
  129.     _box addItemCargoGlobal ["Exile_Item_JunkMetal", (random 8)];
  130.     _box addItemCargoGlobal ["Exile_Item_MetalPole", (random 7)];
  131.     _box addMagazineCargoGlobal ["ClaymoreDirectionalMine_Remote_Mag", (random 4)];
  132.     _box addItemCargoGlobal ["Exile_Item_WoodFloorKit", (random 20)];
  133.     _box addItemCargoGlobal ["Exile_Item_WoodPlank", (random 80)];
  134.     _box addItemCargoGlobal ["Exile_Item_WoodWallKit", (random 14)];
  135.     _box addItemCargoGlobal ["Exile_Item_InstaDoc", (random 4)];
  136.     _box addItemCargoGlobal ["Exile_Item_FortificationUpgrade", (random 8)];
  137.     _box addItemCargoGlobal ["Exile_Item_BBQSandwich_Cooked", (random 4)];
  138.     _box addItemCargoGlobal ["Exile_Item_Energydrink", (random 4)];
  139.     _box addWeaponCargoGlobal ["srifle_LRR_camo_F", (random 1)];
  140.     _box addWeaponCargoGlobal ["rhs_weap_M107", (random 2)];
  141.     _box addWeaponCargoGlobal ["arifle_SDAR_F", (random 1)];
  142.     _box addMagazineCargoGlobal ["20Rnd_556x45_UW_mag", (random 8)];
  143.     _box addMagazineCargoGlobal ["SatchelCharge_Remote_Mag", (random 6)];
  144.     _box addItemCargoGlobal ["Exile_Item_Bandage", (random 5)];
  145.     _box addMagazineCargoGlobal ["150Rnd_93x64_Mag", (random 4)];
  146.     _box addMagazineCargoGlobal ["130Rnd_338_Mag", (random 4)];
  147.     _box setVariable ["ExileMoney",10000,true]; // rod
  148.  
  149. Hint "Intel: Ground Loot Marked on map";
  150. uiSleep 30;
  151. Hint "";
  152.  
  153. ////////////////////////////////////////////////////////////////////////////////////////////////////
  154. //Crate 2
  155. ////////////////////////////////////////////////////////////////////////////////////////////////////
  156.  
  157. uiSleep 3000;
  158.  
  159.     _validspot  = false;
  160.     while{!_validspot} do
  161.     {
  162.         sleep 1;
  163.         _position = [_spawnCenter,_min,_max,_mindist,_water,20000,_shoremode] call BIS_fnc_findSafePos;
  164.         _validspot  = true;
  165.  
  166.  
  167.         //Check if near another crate
  168.         // Get nearest CargoNet_01_box_F
  169.         _nearOtherCrate = (nearestObjects [_position,["CargoNet_01_box_F"],750]) select 0;
  170.         if (!isNil "_nearOtherCrate") then
  171.         {
  172.             _nearestCrate = _position distance _nearOtherCrate;
  173.             if (_nearestCrate < 750) then
  174.             {
  175.                 _validspot = false;
  176.             };
  177.         };
  178.  
  179.         //Check if near player base
  180.         // Get nearest Exile_Construction_Flag_Static
  181.         _nearBase = (nearestObjects [_position,["Exile_Construction_Flag_Static"],750]) select 0;
  182.         if (!isNil "_nearBase") then
  183.         {
  184.             _nearestBase = _position distance _nearBase;
  185.             if (_nearestBase < 750) then
  186.             {
  187.                 _validspot = false;
  188.             };
  189.         };
  190.  
  191.     };
  192.  
  193.     if (_marker) then
  194.     {
  195.         _event_marker6 = createMarker [ format ["loot_marker_%1", 6], _position];
  196.         _event_marker6 setMarkerColor "ColorYellow";
  197.         _event_marker6 setMarkerAlpha 0.65;
  198.         _event_marker6 setMarkerText "Crate2";
  199.         _event_marker6 setMarkerType "loc_Tree";
  200.         _event_marker6 setMarkerBrush "Vertical";
  201.         _event_marker6 setMarkerSize [(2), (2)];
  202.     };
  203.  
  204.     diag_log format['Spawncrate %1 : Location %2',6,_position];
  205.  
  206.     //Infantry spawns using the DMS
  207.     _AICount = 5 + (round (random 2));
  208.     _spawnPosition = [_position select 0, _position select 1, 0];
  209.     _group6 = [_spawnPosition, _AICount, "random", "random", "bandit"] call DMS_fnc_SpawnAIGroup;
  210.     _group6 setVariable ["DMS_LockLocality",nil];
  211.     _group6 setVariable ["DMS_SpawnedGroup",true];
  212.     _group6 setVariable ["DMS_Group_Side", "bandit"];
  213.  
  214.     [_group6, _spawnPosition, 100] call bis_fnc_taskPatrol;
  215.     _group6 setBehaviour "STEALTH";
  216.     _group6 setCombatMode "RED";
  217.  
  218.     diag_log text format ["[groundBoxes]: Creating crate drop zone %1 with %2 guards",_spawnPosition,_AICount];
  219.  
  220.     _box = "CargoNet_01_box_F" createvehicle _position;
  221.  
  222.     clearMagazineCargoGlobal _box;
  223.     clearWeaponCargoGlobal _box;
  224.     clearItemCargoGlobal _box;
  225.     _box setVariable ["permaLoot",true]; //stay until reset
  226.     _box allowDamage false; // Prevent boxes to explode when spawning
  227.     // Explosive Crate
  228.  
  229.     _box addItemCargoGlobal ["Exile_Item_DuctTape", (random 2)];
  230.     _box addItemCargoGlobal ["Exile_Item_JunkMetal", (random 8)];
  231.     _box addItemCargoGlobal ["Exile_Item_MetalPole", (random 7)];
  232.     _box addMagazineCargoGlobal ["ClaymoreDirectionalMine_Remote_Mag", (random 4)];
  233.     _box addItemCargoGlobal ["Exile_Item_WoodFloorKit", (random 20)];
  234.     _box addItemCargoGlobal ["Exile_Item_WoodPlank", (random 80)];
  235.     _box addItemCargoGlobal ["Exile_Item_WoodWallKit", (random 14)];
  236.     _box addItemCargoGlobal ["Exile_Item_InstaDoc", (random 4)];
  237.     _box addItemCargoGlobal ["Exile_Item_FortificationUpgrade", (random 8)];
  238.     _box addItemCargoGlobal ["Exile_Item_BBQSandwich_Cooked", (random 4)];
  239.     _box addItemCargoGlobal ["Exile_Item_Energydrink", (random 4)];
  240.     _box addWeaponCargoGlobal ["srifle_LRR_camo_F", (random 1)];
  241.     _box addWeaponCargoGlobal ["rhs_weap_M107", (random 2)];
  242.     _box addWeaponCargoGlobal ["arifle_SDAR_F", (random 1)];
  243.     _box addMagazineCargoGlobal ["20Rnd_556x45_UW_mag", (random 8)];
  244.     _box addMagazineCargoGlobal ["SatchelCharge_Remote_Mag", (random 6)];
  245.     _box addItemCargoGlobal ["Exile_Item_Bandage", (random 5)];
  246.     _box addMagazineCargoGlobal ["150Rnd_93x64_Mag", (random 4)];
  247.     _box addMagazineCargoGlobal ["130Rnd_338_Mag", (random 4)];
  248.     _box setVariable ["ExileMoney",10000,true]; // rod
  249.  
  250. Hint "Intel: Ground Loot Marked on map";
  251. uiSleep 30;
  252. Hint "";
  253.  
  254. ////////////////////////////////////////////////////////////////////////////////////////////////////
  255. //Crate 3
  256. ////////////////////////////////////////////////////////////////////////////////////////////////////
  257.  
  258. uiSleep 3000;
  259.  
  260.     _validspot  = false;
  261.     while{!_validspot} do
  262.     {
  263.         sleep 1;
  264.         _position = [_spawnCenter,_min,_max,_mindist,_water,20000,_shoremode] call BIS_fnc_findSafePos;
  265.         _validspot  = true;
  266.  
  267.  
  268.         //Check if near another crate
  269.         // Get nearest CargoNet_01_box_F
  270.         _nearOtherCrate = (nearestObjects [_position,["CargoNet_01_box_F"],750]) select 0;
  271.         if (!isNil "_nearOtherCrate") then
  272.         {
  273.             _nearestCrate = _position distance _nearOtherCrate;
  274.             if (_nearestCrate < 750) then
  275.             {
  276.                 _validspot = false;
  277.             };
  278.         };
  279.  
  280.         //Check if near player base
  281.         // Get nearest Exile_Construction_Flag_Static
  282.         _nearBase = (nearestObjects [_position,["Exile_Construction_Flag_Static"],750]) select 0;
  283.         if (!isNil "_nearBase") then
  284.         {
  285.             _nearestBase = _position distance _nearBase;
  286.             if (_nearestBase < 750) then
  287.             {
  288.                 _validspot = false;
  289.             };
  290.         };
  291.  
  292.     };
  293.  
  294.     if (_marker) then
  295.     {
  296.         _event_marker7 = createMarker [ format ["loot_marker_%1", 7], _position];
  297.         _event_marker7 setMarkerColor "ColorYellow";
  298.         _event_marker7 setMarkerAlpha 0.65;
  299.         _event_marker7 setMarkerText "Crate3";
  300.         _event_marker7 setMarkerType "loc_Tree";
  301.         _event_marker7 setMarkerBrush "Vertical";
  302.         _event_marker7 setMarkerSize [(2), (2)];
  303.     };
  304.  
  305.     diag_log format['Spawncrate %1 : Location %2',7,_position];
  306.  
  307.     //Infantry spawns using the DMS
  308.     _AICount = 5 + (round (random 2));
  309.     _spawnPosition = [_position select 0, _position select 1, 0];
  310.     _group7 = [_spawnPosition, _AICount, "random", "random", "bandit"] call DMS_fnc_SpawnAIGroup;
  311.     _group7 setVariable ["DMS_LockLocality",nil];
  312.     _group7 setVariable ["DMS_SpawnedGroup",true];
  313.     _group7 setVariable ["DMS_Group_Side", "bandit"];
  314.  
  315.     [_group7, _spawnPosition, 100] call bis_fnc_taskPatrol;
  316.     _group7 setBehaviour "STEALTH";
  317.     _group7 setCombatMode "RED";
  318.  
  319.     diag_log text format ["[groundBoxes]: Creating crate drop zone %1 with %2 guards",_spawnPosition,_AICount];
  320.  
  321.     _box = "CargoNet_01_box_F" createvehicle _position;
  322.  
  323.     clearMagazineCargoGlobal _box;
  324.     clearWeaponCargoGlobal _box;
  325.     clearItemCargoGlobal _box;
  326.     _box setVariable ["permaLoot",true]; //stay until reset
  327.     _box allowDamage false; // Prevent boxes to explode when spawning
  328.     //
  329.  
  330.     _box addItemCargoGlobal ["Exile_Item_DuctTape", (random 2)];
  331.     _box addItemCargoGlobal ["Exile_Item_JunkMetal", (random 8)];
  332.     _box addItemCargoGlobal ["Exile_Item_MetalPole", (random 7)];
  333.     _box addMagazineCargoGlobal ["ClaymoreDirectionalMine_Remote_Mag", (random 4)];
  334.     _box addItemCargoGlobal ["Exile_Item_WoodFloorKit", (random 20)];
  335.     _box addItemCargoGlobal ["Exile_Item_WoodPlank", (random 80)];
  336.     _box addItemCargoGlobal ["Exile_Item_WoodWallKit", (random 14)];
  337.     _box addItemCargoGlobal ["Exile_Item_InstaDoc", (random 4)];
  338.     _box addItemCargoGlobal ["Exile_Item_FortificationUpgrade", (random 8)];
  339.     _box addItemCargoGlobal ["Exile_Item_BBQSandwich_Cooked", (random 4)];
  340.     _box addItemCargoGlobal ["Exile_Item_Energydrink", (random 4)];
  341.     _box addWeaponCargoGlobal ["srifle_LRR_camo_F", (random 1)];
  342.     _box addWeaponCargoGlobal ["rhs_weap_M107", (random 2)];
  343.     _box addWeaponCargoGlobal ["arifle_SDAR_F", (random 1)];
  344.     _box addMagazineCargoGlobal ["20Rnd_556x45_UW_mag", (random 8)];
  345.     _box addMagazineCargoGlobal ["SatchelCharge_Remote_Mag", (random 6)];
  346.     _box addItemCargoGlobal ["Exile_Item_Bandage", (random 5)];
  347.     _box addMagazineCargoGlobal ["150Rnd_93x64_Mag", (random 4)];
  348.     _box addMagazineCargoGlobal ["130Rnd_338_Mag", (random 4)];
  349.     _box setVariable ["ExileMoney",10000,true]; // rod
  350.  
  351. Hint "Intel: Ground Loot Marked on map";
  352. uiSleep 30;
  353. Hint "";
  354.  
  355. ////////////////////////////////////////////////////////////////////////////////////////////////////
  356. //Crate 4
  357. ////////////////////////////////////////////////////////////////////////////////////////////////////
  358.  
  359. uiSleep 3000;
  360.  
  361.     _validspot  = false;
  362.     while{!_validspot} do
  363.     {
  364.         sleep 1;
  365.         _position = [_spawnCenter,_min,_max,_mindist,_water,2000,_shoremode] call BIS_fnc_findSafePos;
  366.         _validspot  = true;
  367.  
  368.  
  369.         //Check if near another crate
  370.         // Get nearest CargoNet_01_box_F
  371.         _nearOtherCrate = (nearestObjects [_position,["CargoNet_01_box_F"],750]) select 0;
  372.         if (!isNil "_nearOtherCrate") then
  373.         {
  374.             _nearestCrate = _position distance _nearOtherCrate;
  375.             if (_nearestCrate < 750) then
  376.             {
  377.                 _validspot = false;
  378.             };
  379.         };
  380.  
  381.         //Check if near player base
  382.         // Get nearest Exile_Construction_Flag_Static
  383.         _nearBase = (nearestObjects [_position,["Exile_Construction_Flag_Static"],750]) select 0;
  384.         if (!isNil "_nearBase") then
  385.         {
  386.             _nearestBase = _position distance _nearBase;
  387.             if (_nearestBase < 750) then
  388.             {
  389.                 _validspot = false;
  390.             };
  391.         };
  392.  
  393.     };
  394.  
  395.     if (_marker) then           //testing the name without box number
  396.     {
  397.         _event_marker8 = createMarker [ format ["loot_marker_%1", 8], _position];
  398.         _event_marker8 setMarkerColor "ColorYellow";
  399.         _event_marker8 setMarkerAlpha 0.65;
  400.         _event_marker8 setMarkerText "Crate4";
  401.         _event_marker8 setMarkerType "loc_Tree";
  402.         _event_marker8 setMarkerBrush "Vertical";
  403.         _event_marker8 setMarkerSize [(2), (2)];
  404.     };
  405.  
  406.     diag_log format['Spawncrate %1 : Location %2',8,_position];
  407.  
  408.     //Infantry spawns using the DMS
  409.     _AICount = 5 + (round (random 2));
  410.     _spawnPosition = [_position select 0, _position select 1, 0];
  411.     _group8 = [_spawnPosition, _AICount, "random", "random", "bandit"] call DMS_fnc_SpawnAIGroup;
  412.     _group8 setVariable ["DMS_LockLocality",nil];
  413.     _group8 setVariable ["DMS_SpawnedGroup",true];
  414.     _group8 setVariable ["DMS_Group_Side", "bandit"];
  415.  
  416.     [_group8, _spawnPosition, 100] call bis_fnc_taskPatrol;
  417.     _group8 setBehaviour "STEALTH";
  418.     _group8 setCombatMode "RED";
  419.  
  420.     diag_log text format ["[groundBoxes]: Creating crate drop zone %1 with %2 guards",_spawnPosition,_AICount];
  421.  
  422.     _box = "CargoNet_01_box_F" createvehicle _position;
  423.  
  424.     clearMagazineCargoGlobal _box;
  425.     clearWeaponCargoGlobal _box;
  426.     clearItemCargoGlobal _box;
  427.     _box setVariable ["permaLoot",true]; //stay until reset
  428.     _box allowDamage false; // Prevent boxes to explode when spawning
  429.  
  430.     _box addItemCargoGlobal ["Exile_Item_DuctTape", (random 2)];
  431.     _box addItemCargoGlobal ["Exile_Item_JunkMetal", (random 8)];
  432.     _box addItemCargoGlobal ["Exile_Item_MetalPole", (random 7)];
  433.     _box addMagazineCargoGlobal ["ClaymoreDirectionalMine_Remote_Mag", (random 4)];
  434.     _box addItemCargoGlobal ["Exile_Item_WoodFloorKit", (random 20)];
  435.     _box addItemCargoGlobal ["Exile_Item_WoodPlank", (random 80)];
  436.     _box addItemCargoGlobal ["Exile_Item_WoodWallKit", (random 14)];
  437.     _box addItemCargoGlobal ["Exile_Item_InstaDoc", (random 4)];
  438.     _box addItemCargoGlobal ["Exile_Item_FortificationUpgrade", (random 8)];
  439.     _box addItemCargoGlobal ["Exile_Item_BBQSandwich_Cooked", (random 4)];
  440.     _box addItemCargoGlobal ["Exile_Item_Energydrink", (random 4)];
  441.     _box addWeaponCargoGlobal ["srifle_LRR_camo_F", (random 1)];
  442.     _box addWeaponCargoGlobal ["rhs_weap_M107", (random 2)];
  443.     _box addWeaponCargoGlobal ["arifle_SDAR_F", (random 1)];
  444.     _box addMagazineCargoGlobal ["20Rnd_556x45_UW_mag", (random 8)];
  445.     _box addMagazineCargoGlobal ["SatchelCharge_Remote_Mag", (random 6)];
  446.     _box addItemCargoGlobal ["Exile_Item_Bandage", (random 5)];
  447.     _box addMagazineCargoGlobal ["150Rnd_93x64_Mag", (random 4)];
  448.     _box addMagazineCargoGlobal ["130Rnd_338_Mag", (random 4)];
  449.     _box setVariable ["ExileMoney",10000,true]; // rod
  450.  
  451. Hint "Intel: Ground Loot Marked on map";
  452. uiSleep 30;
  453. Hint "";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement