daily pastebin goal
44%
SHARE
TWEET

Untitled

a guest Jan 16th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * ExileServer_world_spawnVehicles
  3.  *
  4.  * Exile Mod
  5.  * www.exilemod.com
  6.  * © 2015 Exile Mod Team
  7.  *
  8.  * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
  9.  * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
  10.  *
  11.  * Fixed by Michael Cullen, no rights reserved.
  12.  */
  13.  
  14. private["_mapsizeX","_mapsizeY","_gridSize","_gridVehicles","_gridHalf","_vehicleCount","_debugMarkers","_vehicleClassNames","_maximumDamage","_damageChance","_xSize","_ySize","_position","_spawned","_spawnedPositions","_positionReal","_spawnControl","_vehicleClassName","_vehicle","_hitpointsData","_hitpoints","_debugMarker""_vehicleItemsAllowed","_allowedItems","_maximumItemsPerVehicle","_itemsAdded","_itemsPerVehicle","_itemAdd","_cargoType"];
  15.  
  16. _mapsizeX = worldSize;
  17. _mapsizeY = worldSize;
  18. _gridSize = getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "vehiclesGridSize");
  19. _gridVehicles = getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "vehiclesGridAmount");
  20. format ["Spawning Dynamic Vehicles. GridSize: %1 Vehs/Grid: %2",_gridSize,_gridVehicles] call ExileServer_util_log;
  21. _gridHalf = _gridSize / 2;
  22. _vehicleCount = 0;
  23. _debugMarkers = ((getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "vehiclesDebugMarkers")) isEqualTo 1);
  24. _vehicleClassNames = getArray (configFile >> "CfgSettings" >> "VehicleSpawn" >> "ground");
  25. _maximumDamage = getNumber (configFile >> "CfgSettings" >> "VehicleSpawn" >> "maximumDamage");
  26. _damageChance = getNumber (configFile >> "CfgSettings" >> "VehicleSpawn" >> "damageChance");
  27.  
  28. _vehicleItemsAllowed = getNumber (missionConfigFile >> "SpawnVehicleItems" >> "WorldVehicles" >> "vehicleItemsAllowed");
  29. _allowedItems = getArray (missionConfigFile >> "SpawnVehicleItems" >> "WorldVehicles" >> "allowedItems");
  30. _maximumItemsPerVehicle = getNumber (missionConfigFile >> "SpawnVehicleItems" >> "WorldVehicles" >> "maximumItemsPerVehicle");
  31. _maximumItemsPerVehicle = _maximumItemsPerVehicle +1;
  32.  
  33. for "_xSize" from _gridHalf to (_mapsizeX - _gridHalf) step _gridSize do
  34. {
  35.     for "_ySize" from _gridHalf to (_mapsizeY - _gridHalf) step _gridSize do
  36.     {
  37.         _position = [_xSize,_ySize];
  38.         _spawned = 0;
  39.         _spawnedPositions = [];
  40.         while {_spawned < _gridVehicles} do
  41.         {
  42.             _positionReal = [_position, 25, _gridHalf, 5, 0 , 1 , 0 , _spawnedPositions] call BIS_fnc_findSafePos;
  43.             if(count _positionReal isEqualTo 3)exitWith{};
  44.             _spawnControl = [[(_positionReal select 0) - 50, (_positionReal select 1) + 50],[(_positionReal select 0) + 50,(_positionReal select 1) - 50]];
  45.             _spawnedPositions pushBack _spawnControl;
  46.             _positionReal pushBack 0;
  47.             _vehicleClassName = selectRandom _vehicleClassNames;
  48.             _vehicle = [_vehicleClassName, _positionReal, random 360, true] call ExileServer_object_vehicle_createNonPersistentVehicle;
  49.             _hitpointsData = getAllHitPointsDamage _vehicle;
  50.            
  51.             if !(_hitpointsData isEqualTo []) then
  52.             {
  53.                 _hitpoints = _hitpointsData select 0;
  54.                 {
  55.                     if ((random 100) < _damageChance) then
  56.                     {
  57.                         _vehicle setHitPointDamage [_x, random _maximumDamage];
  58.                     };
  59.                 }
  60.                 forEach _hitpoints;
  61.             };
  62.             if (_debugMarkers) then
  63.             {
  64.                 _debugMarker = createMarker ["vehicleMarker#"+str _vehicleCount, _positionReal];
  65.                 _debugMarker setMarkerColor "ColorOrange";
  66.                 _debugMarker setMarkerType "mil_dot_noShadow";
  67.             };
  68.     if (_vehicleItemsAllowed isEqualTo 1) then {
  69.         _itemsAdded = 0;
  70.         _itemsPerVehicle = floor (random _maximumItemsPerVehicle);
  71.     while{_itemsAdded < _itemsPerVehicle} do {
  72.           _itemAdd = _allowedItems select (floor (random (count _allowedItems)));
  73.           _cargoType = _itemAdd call ExileClient_util_cargo_getType;
  74.     switch (_cargoType) do {
  75.         case 1: { _vehicle addMagazineAmmoCargo [_itemAdd, 1, 1]; };
  76.         case 2: { _vehicle addWeaponCargoGlobal [_itemAdd, 1]; };
  77.         case 3: { _vehicle addBackpackCargoGlobal [_itemAdd, 1]; };
  78.         default { _vehicle addItemCargoGlobal [_itemAdd, 1, 1]; };
  79.         };
  80.           _itemsAdded = _itemsAdded + 1;
  81.       };
  82.     }; 
  83.             _spawned = _spawned + 1;
  84.             _vehicleCount = _vehicleCount + 1;
  85.         };
  86.     };
  87. };
  88. format ["Dynamic vehicles spawned. Count : %1",_vehicleCount] call ExileServer_util_log;
  89. true
RAW Paste Data
Top