Advertisement
Brenner650

fn_spawn_vehicles.sqf

Jan 14th, 2021
2,412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.83 KB | None | 0 0
  1. private ["_velimit","_isAir","_isShip","_position","_dir","_marker","_vehObj","_vehClass","_allowedVehiclesList","_centerMarkerPosition","_dynamicVehicleArea","_roadList"];
  2.  
  3. EPOCH_DEBUG_VEH = true;
  4.  
  5. _allowedVehiclesList = [
  6.     //Civilians
  7.     ["C_Hatchback_01_F",1],
  8.     ["C_Hatchback_01_sport_F",2],
  9.     ["C_Offroad_01_F",2],
  10.     ["C_Quadbike_01_F",5],
  11.     ["C_SUV_01_F",1],
  12.     ["C_Van_01_box_F",3],
  13.     ["C_Van_01_transport_F",3],
  14.     // Civ Boats
  15.     ["C_Boat_Civil_01_F",1],
  16.     ["C_Boat_Civil_01_police_F",2],
  17.     ["C_Boat_Civil_01_rescue_F",2],
  18.     ["C_Rubberboat",2],
  19.     // AAF
  20.     ["I_Quadbike_01_F",5],
  21.     ["I_Truck_02_covered_F",1],
  22.     ["I_Truck_02_transport_F",1],
  23.     // AAF boats
  24.     ["I_Boat_Transport_01_F",1],
  25.     // CSAT
  26.     ["O_Quadbike_01_F",5],
  27.     ["O_Truck_02_covered_F",3],
  28.     ["O_Truck_02_transport_F",3],
  29.     // CSAT Boat
  30.     ["O_Lifeboat",3],
  31.     // FIA
  32.     ["B_G_Offroad_01_F",2],
  33.     ["B_G_Quadbike_01_F",5],
  34.     ["B_G_Van_01_transport_F",4],
  35.     // FIA Boat
  36.     ["B_G_Boat_Transport_01_F",4],
  37.     //NATO
  38.     ["C_Hatchback_01_F",1],
  39.     ["C_Hatchback_01_sport_F",1],
  40.     ["C_Offroad_01_F",1],
  41.     ["C_Quadbike_01_F",5],
  42.     ["C_SUV_01_F",3],
  43.     ["C_Van_01_box_F",1],
  44.     ["C_Van_01_transport_F",4],
  45.     // NATO Boats
  46.     ["B_Boat_Transport_01_F",6],
  47.     ["B_Lifeboat",3]
  48. ];
  49.  
  50. _centerMarkerPosition = getMarkerPos "center";
  51. _dynamicVehicleArea = 5000;
  52. _roadList = _centerMarkerPosition nearRoads _dynamicVehicleArea;
  53.  
  54. {
  55.     _vehClass = _x select 0;
  56.     _velimit = _x select 1;
  57.    
  58.     for "_i" from 1 to _velimit do {
  59.    
  60.         // Find Vehicle Type to better control spawns
  61.         _isAir = _vehClass isKindOf "Air";
  62.         _isShip = _vehClass isKindOf "Ship";
  63.    
  64.         if(_isShip || _isAir) then {
  65.             if(_isShip) then {
  66.                 _position = [_centerMarkerPosition,0,_dynamicVehicleArea,10,0,4000,1] call BIS_fnc_findSafePos;
  67.                 _position = [_position,0,100,10,2,4000,0] call BIS_fnc_findSafePos;
  68.             } else {
  69.                 _position = [_centerMarkerPosition,0,_dynamicVehicleArea,10,0,1000,0] call BIS_fnc_findSafePos;
  70.             };
  71.         } else {
  72.             // Spawn near roads        
  73.             _position = _roadList call BIS_fnc_selectRandom;
  74.             _position = _position modelToWorld [0,0,0];
  75.             _position = [_position,0,10,10,0,2000,0] call BIS_fnc_findSafePos;
  76.         };
  77.  
  78.         if ((count _position) == 2) then {
  79.         //if ((count _position) == 20) then {
  80.             _dir = round(random 360);
  81.             //place vehicle
  82.             _vehObj = createVehicle [_vehClass, _position, [], 0, "CAN_COLLIDE"];
  83.             _vehObj setdir _dir;
  84.  
  85.             clearBackpackCargoGlobal  _vehObj;
  86.             clearItemCargoGlobal      _vehObj;
  87.            
  88.             _position set [2,0];
  89.            
  90.             if(surfaceIsWater _position) then {
  91.                 _vehObj setposASL _position;
  92.             } else {
  93.                 _vehObj setposATL _position;
  94.             };
  95.            
  96.             if(EPOCH_DEBUG_VEH) then {
  97.                 _marker = createMarker [str(_position) , _position];
  98.                 _marker setMarkerShape "ICON";
  99.                 _marker setMarkerType "mil_dot";
  100.                 _marker setMarkerText _vehClass;
  101.             };
  102.         };
  103.     };
  104. } forEach _allowedVehiclesList;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement