Advertisement
Guest User

Untitled

a guest
Feb 15th, 2016
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  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.  
  12. private["_mapsizeX","_mapsizeY","_gridSize","_gridVehicles","_gridSizeOffset","_vehicleCount","_debugMarkers","_vehicleClassNames","_maximumDamage","_damageChance","_xSize","_workingXSize","_ySize","_workingYSize","_position","_spawned","_spawnedPositions","_positionReal","_spawnControl","_vehicleClassName","_vehicle","_hitpoints","_debugMarker"];
  13. _mapsizeX = worldSize;
  14. _mapsizeY = worldSize;
  15. _gridSize = getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "vehiclesGridSize");
  16. _gridVehicles = getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "vehiclesGridAmount");
  17. format ["Spawning Dynamic Vehicles. GridSize: %1 Vehs/Grid : %2",_gridSize,_gridVehicles] call ExileServer_util_log;
  18. _gridSizeOffset = _gridSize % 2;
  19. _vehicleCount = 0;
  20. _debugMarkers = ((getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "vehiclesDebugMarkers")) isEqualTo 1);
  21. _vehicleClassNames = getArray (configFile >> "CfgSettings" >> "VehicleSpawn" >> "ground");
  22. _maximumDamage = getNumber (configFile >> "CfgSettings" >> "VehicleSpawn" >> "maximumDamage");
  23. _damageChance = getNumber (configFile >> "CfgSettings" >> "VehicleSpawn" >> "damageChance");
  24. for "_xSize" from 0 to _mapsizeX step _gridSize do
  25. {
  26. _workingXSize = _xSize + _gridSizeOffset;
  27. for "_ySize" from 0 to _mapsizeY step _gridSize do
  28. {
  29. _workingYSize = _ySize + _gridSizeOffset;
  30. _position = [_workingXSize,_workingYSize];
  31. _spawned = 0;
  32. _spawnedPositions = [];
  33. while {_spawned < _gridVehicles} do
  34. {
  35. _positionReal = [_position, 25, _gridSize, 5, 0 , 1 , 0 , _spawnedPositions] call BIS_fnc_findSafePos;
  36. if(count _positionReal isEqualTo 3)exitWith{};
  37. _spawnControl = [[(_positionReal select 0) - 50, (_positionReal select 1) + 50],[(_positionReal select 0) + 50,(_positionReal select 1) - 50]];
  38. _spawnedPositions pushBack _spawnControl;
  39. _positionReal pushBack 0;
  40. _vehicleClassName = _vehicleClassNames select (floor (random (count _vehicleClassNames)));
  41. _vehicle = [_vehicleClassName, _positionReal, random 360, true] call ExileServer_object_vehicle_createNonPersistentVehicle;
  42. _hitpoints = (getAllHitPointsDamage _vehicle) select 0;
  43. {
  44. if ((random 100) < _damageChance) then
  45. {
  46. _vehicle setHitPointDamage [_x, random _maximumDamage];
  47. };
  48. }
  49. forEach _hitpoints;
  50. if (_debugMarkers) then
  51. {
  52. _debugMarker = createMarker ["vehicleMarker#"+str _vehicleCount, _positionReal];
  53. _debugMarker setMarkerColor "ColorOrange";
  54. _debugMarker setMarkerType "mil_dot_noShadow";
  55. };
  56. _spawned = _spawned + 1;
  57. _vehicleCount = _vehicleCount + 1;
  58. };
  59. };
  60. };
  61. format ["Dynamic vehicles spawned. Count : %1",_vehicleCount] call ExileServer_util_log;
  62. true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement