Darth_Rogue

Untitled

Oct 5th, 2015
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. /**
  2. * Exile Mod
  3. * www.exilemod.com
  4. * © 2015 Exile Mod Team
  5. *
  6. * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
  7. * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
  8. */
  9.  
  10. private["_mapsizeX","_mapsizeY","_gridSize","_gridVehicles","_gridSizeOffset","_vehicleCount","_debugMarkers","_vehicleClassNames","_maximumDamage","_damageChance","_xSize","_workingXSize","_ySize","_workingYSize","_position","_spawned","_spawnedPositions","_positionReal","_spawnControl","_vehicleClassName","_vehicle","_hitpoints","_debugMarker"];
  11. _mapsizeX = worldSize;
  12. _mapsizeY = worldSize;
  13. _gridSize = getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "vehiclesGridSize");
  14. _gridVehicles = getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "vehiclesGridAmount");
  15. format ["Spawning Dynamic Vehicles. GridSize: %1 Vehs/Grid : %2",_gridSize,_gridVehicles] call ExileServer_util_log;
  16. _gridSizeOffset = _gridSize % 2;
  17. _vehicleCount = 0;
  18. _debugMarkers = ((getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "vehiclesDebugMarkers")) isEqualTo 1);
  19. _vehicleClassNames = getArray (configFile >> "CfgSettings" >> "VehicleSpawn" >> "ground");
  20. _maximumDamage = getNumber (configFile >> "CfgSettings" >> "VehicleSpawn" >> "maximumDamage");
  21. _damageChance = getNumber (configFile >> "CfgSettings" >> "VehicleSpawn" >> "damageChance");
  22. for "_xSize" from 0 to _mapsizeX step _gridSize do
  23. {
  24. _workingXSize = _xSize + _gridSizeOffset;
  25. for "_ySize" from 0 to _mapsizeY step _gridSize do
  26. {
  27. _workingYSize = _ySize + _gridSizeOffset;
  28. _position = [_workingXSize,_workingYSize];
  29. _spawned = 0;
  30. _spawnedPositions = [];
  31. while {_spawned < _gridVehicles} do
  32. {
  33. //change for esseker vehicle grid spawn issues
  34. _positionReal = [[6000,6000], 25, 6000, 5, 0 , 4000 , 0 , _spawnedPositions] call BIS_fnc_findSafePos;
  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 = _vehicleClassName call ExileClient_util_vehicle_getHitPoints;
  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