Advertisement
secondcoming

waterCrates.sqf

Jun 18th, 2016
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 4.97 KB | None | 0 0
  1. /*
  2.     File: spawncrates.sqf
  3.     Author: NedFox [TZW]
  4.    
  5.     Description: Custom Crates, randomly placed around a marker which is visible (or not).
  6. */
  7.  
  8. if (!isServer) exitWith {};
  9.  
  10. _numberofcrates = 6; // this is the number of crates that you want to spawn
  11. _world = (toLower worldName);
  12.  
  13. _middle = worldSize/2;
  14. _spawnCenter    = [_middle,_middle,0];
  15. _max        = _middle - 100;
  16. switch (toLower worldName) do
  17. {
  18.     case "altis":                              
  19.     {
  20.         _spawnCenter = [15834.2,15787.8,0];
  21.         _max = 16000;
  22.     };
  23.     case "chernarus":                              
  24.     {
  25.         _spawnCenter = [7652.9634, 7870.8076,0];
  26.         _max = 7500;
  27.     }; 
  28.     case "taviana":                        
  29.     {
  30.         _spawnCenter = [12800, 12800,0];
  31.         _max = 12800;
  32.     };
  33. };
  34. diag_log format['[waterCrates] worldname: %1 Centre: %2 radius: %3',_world,_spawnCenter,_max];
  35.  
  36. _min                = 0; // minimum distance from the center position (Number) in meters
  37. _mindist            = 5; // minimum distance from the nearest object (Number) in meters, ie. spawn at least this distance away from anything within x meters..
  38. _water              = 2; // water mode (Number) 0: cannot be in water , 1: can either be in water or not , 2: must be in water
  39. _shoremode          = 0; // 0: does not have to be at a shore , 1: must be at a shore
  40. _marker                 = True; // Draw a green circle in which the crate will be spawned randomly
  41. _markersize             = 100; // Radius of the marker in meters
  42.  
  43. private['_position'];
  44.  
  45. diag_log format['[waterCrates] Starting @ %1',time];
  46.  
  47. for "_i" from 1 to _numberofcrates do
  48. {
  49.     _validspot  = false;
  50.     while{!_validspot} do
  51.     {
  52.         sleep 1;
  53.         _position = [_spawnCenter,_min,_max,_mindist,_water,2000,_shoremode] call BIS_fnc_findSafePos;
  54.         _validspot  = true;
  55.  
  56.        
  57.         //Check if near another crate
  58.         // Get nearest CargoNet_01_box_F
  59.         _nearOtherCrate = (nearestObjects [_position,["CargoNet_01_box_F"],750]) select 0; 
  60.         if (!isNil "_nearOtherCrate") then
  61.         {
  62.             _nearestCrate = _position distance _nearOtherCrate;
  63.             if (_nearestCrate < 750) then
  64.             {
  65.                 _validspot = false;
  66.             };     
  67.         };     
  68.  
  69.         //Check if near player base
  70.         // Get nearest Exile_Construction_Flag_Static
  71.         _nearBase = (nearestObjects [_position,["Exile_Construction_Flag_Static"],750]) select 0;
  72.         if (!isNil "_nearBase") then
  73.         {  
  74.             _nearestBase = _position distance _nearBase;
  75.             if (_nearestBase < 750) then
  76.             {
  77.                 _validspot = false;
  78.             }; 
  79.         };
  80.  
  81.     }; 
  82.    
  83.     if (_marker) then
  84.     {
  85.         _event_marker = createMarker [ format ["loot_marker_%1", _i], _position];
  86.         _event_marker setMarkerColor "ColorGreen";
  87.         _event_marker setMarkerAlpha 1;
  88.         _event_marker setMarkerText "Gear Crate";
  89.         _event_marker setMarkerType "loc_Tree";
  90.         _event_marker setMarkerBrush "Vertical";
  91.         _event_marker setMarkerSize [(3), (3)];
  92.     }; 
  93.  
  94.     diag_log format['Spawncrate %1 : Location %2',_i,_position];
  95.  
  96.     //Infantry spawns using the DMS
  97.     _AICount = 1 + (round (random 2)); 
  98.     _spawnPosition = [_position select 0, _position select 1, 0];
  99.     _group = [_spawnPosition, _AICount, "random", "random", "bandit"] call DMS_fnc_SpawnAIGroup;
  100.     _group setVariable ["DMS_LockLocality",nil];
  101.     _group setVariable ["DMS_SpawnedGroup",true];
  102.     _group setVariable ["DMS_Group_Side", "bandit"];
  103.    
  104.     [_group, _spawnPosition, 100] call bis_fnc_taskPatrol;
  105.     _group setBehaviour "STEALTH";
  106.     _group setCombatMode "RED";
  107.    
  108.     diag_log text format ["[waterCrates]: Creating crate drop zone %1 with %2 guards",_spawnPosition,_AICount];
  109.    
  110.     _box = "CargoNet_01_box_F" createvehicle _position;
  111.    
  112.     clearMagazineCargoGlobal _box;
  113.     clearWeaponCargoGlobal _box;
  114.     clearItemCargoGlobal _box;
  115.     _box setVariable ["permaLoot",true]; //stay until reset
  116.     _box allowDamage false; // Prevent boxes to explode when spawning
  117.  
  118.     _box addItemCargoGlobal ["Exile_Item_DuctTape", 2 + (random 2)];
  119.     _box addItemCargoGlobal ["Exile_Item_JunkMetal",  (random 8)];
  120.     _box addItemCargoGlobal ["Exile_Item_MetalPole",  (random 7)];
  121.     _box addMagazineCargoGlobal ["ClaymoreDirectionalMine_Remote_Mag", (random 2)];
  122.     _box addItemCargoGlobal ["Exile_Item_WoodFloorKit", 2 + (random 10)];
  123.     _box addItemCargoGlobal ["Exile_Item_WoodPlank", 20 + (random 10)];
  124.     _box addItemCargoGlobal ["Exile_Item_WoodWallKit",  (random 7)];
  125.     _box addItemCargoGlobal ["Exile_Item_InstaDoc", 1 + (random 2)];
  126.     _box addItemCargoGlobal ["Exile_Item_FortificationUpgrade",  (random 4)];
  127.     _box addItemCargoGlobal ["Exile_Item_BBQSandwich_Cooked", 1 + (random 4)];
  128.     _box addItemCargoGlobal ["Exile_Item_Energydrink", 1 + (random 3)];
  129.     _box addWeaponCargoGlobal ["srifle_LRR_camo_F",  (random 1)];
  130.     _box addWeaponCargoGlobal ["srifle_mas_ksvk_c", (random 1)];
  131.     _box addWeaponCargoGlobal ["srifle_mas_m107", (random 1)]; 
  132.     _box addWeaponCargoGlobal ["arifle_SDAR_F", 1 + (random 1)];
  133.     _box addMagazineCargoGlobal ["20Rnd_556x45_UW_mag",3 + (random 5)];
  134.     _box addMagazineCargoGlobal ["SatchelCharge_Remote_Mag", (random 1)];
  135.     _box addItemCargoGlobal ["Exile_Item_Bandage", 1 + (random 5)];
  136.     _box addMagazineCargoGlobal ["150Rnd_93x64_Mag", (random 2)];
  137.     _box addMagazineCargoGlobal ["130Rnd_338_Mag", (random 2)];
  138.  
  139. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement