Michael Cullen

Fixed Vehicle Spawns

8 posts in this topic

I discovered yesterday that the default vehicle spawn script has a couple of bugs in it. It's not too much of a problem with island maps, but on maps with land in the debug area, it's a bit of a nightmare; vehicles end up spawning outside of the map, needlessly eating performance and just generally looking extremely messy :P

So, I fixed it up. Replace your ExileServer_world_spawnVehicles.sqf with the following code.

/**
 * ExileServer_world_spawnVehicles
 *
 * Exile Mod
 * exile.majormittens.co.uk
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 *
 * Fixed by Michael Cullen, no rights reserved.
 */
 
private["_mapsizeX","_mapsizeY","_gridSize","_gridVehicles","_gridHalf","_vehicleCount","_debugMarkers","_vehicleClassNames","_maximumDamage","_damageChance","_xSize","_ySize","_position","_spawned","_spawnedPositions","_positionReal","_spawnControl","_vehicleClassName","_vehicle","_hitpointsData","_hitpoints","_debugMarker"];

_mapsizeX = worldSize;
_mapsizeY = worldSize;
_gridSize = getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "vehiclesGridSize");
_gridVehicles = getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "vehiclesGridAmount");
format ["Spawning Dynamic Vehicles. GridSize: %1 Vehs/Grid: %2",_gridSize,_gridVehicles] call ExileServer_util_log;
_gridHalf = _gridSize / 2;
_vehicleCount = 0;
_debugMarkers = ((getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "vehiclesDebugMarkers")) isEqualTo 1);
_vehicleClassNames = getArray (configFile >> "CfgSettings" >> "VehicleSpawn" >> "ground");
_maximumDamage = getNumber (configFile >> "CfgSettings" >> "VehicleSpawn" >> "maximumDamage");
_damageChance = getNumber (configFile >> "CfgSettings" >> "VehicleSpawn" >> "damageChance");

for "_xSize" from _gridHalf to (_mapsizeX - _gridHalf) step _gridSize do
{
	for "_ySize" from _gridHalf to (_mapsizeY - _gridHalf) step _gridSize do
	{
		_position = [_xSize,_ySize];
		_spawned = 0;
		_spawnedPositions = [];
		while {_spawned < _gridVehicles} do 
		{
			_positionReal = [_position, 25, _gridHalf, 5, 0 , 1 , 0 , _spawnedPositions] call BIS_fnc_findSafePos;
			if(count _positionReal isEqualTo 3)exitWith{};
			_spawnControl = [[(_positionReal select 0) - 50, (_positionReal select 1) + 50],[(_positionReal select 0) + 50,(_positionReal select 1) - 50]];
			_spawnedPositions pushBack _spawnControl;
			_positionReal pushBack 0;
			_vehicleClassName = selectRandom _vehicleClassNames;
			_vehicle = [_vehicleClassName, _positionReal, random 360, true] call ExileServer_object_vehicle_createNonPersistentVehicle;
			_hitpointsData = getAllHitPointsDamage _vehicle;
			if !(_hitpointsData isEqualTo []) then 
			{
				_hitpoints = _hitpointsData select 0;
				{
				    if ((random 100) < _damageChance) then
				    {
				        _vehicle setHitPointDamage [_x, random _maximumDamage];
				    };
				}
				forEach _hitpoints;
			};
			if (_debugMarkers) then
			{
				_debugMarker = createMarker ["vehicleMarker#"+str _vehicleCount, _positionReal];
				_debugMarker setMarkerColor "ColorOrange";
				_debugMarker setMarkerType "mil_dot_noShadow";
			};
			_spawned = _spawned + 1;
			_vehicleCount = _vehicleCount + 1;
		};
	};
};
format ["Dynamic vehicles spawned. Count : %1",_vehicleCount] call ExileServer_util_log;
true

 

  • Like 2

Share this post


Link to post
Share on other sites
On 9/10/2016 at 6:35 PM, Michael Cullen said:

I discovered yesterday that the default vehicle spawn script has a couple of bugs in it. It's not too much of a problem with island maps, but on maps with land in the debug area, it's a bit of a nightmare; vehicles end up spawning outside of the map, needlessly eating performance and just generally looking extremely messy :P

So, I fixed it up. Replace your ExileServer_world_spawnVehicles.sqf with the following code.


/**
 * ExileServer_world_spawnVehicles
 *
 * Exile Mod
 * exile.majormittens.co.uk
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 *
 * Fixed by Michael Cullen, no rights reserved.
 */
 
private["_mapsizeX","_mapsizeY","_gridSize","_gridVehicles","_gridHalf","_vehicleCount","_debugMarkers","_vehicleClassNames","_maximumDamage","_damageChance","_xSize","_ySize","_position","_spawned","_spawnedPositions","_positionReal","_spawnControl","_vehicleClassName","_vehicle","_hitpointsData","_hitpoints","_debugMarker"];

_mapsizeX = worldSize;
_mapsizeY = worldSize;
_gridSize = getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "vehiclesGridSize");
_gridVehicles = getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "vehiclesGridAmount");
format ["Spawning Dynamic Vehicles. GridSize: %1 Vehs/Grid: %2",_gridSize,_gridVehicles] call ExileServer_util_log;
_gridHalf = _gridSize / 2;
_vehicleCount = 0;
_debugMarkers = ((getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "vehiclesDebugMarkers")) isEqualTo 1);
_vehicleClassNames = getArray (configFile >> "CfgSettings" >> "VehicleSpawn" >> "ground");
_maximumDamage = getNumber (configFile >> "CfgSettings" >> "VehicleSpawn" >> "maximumDamage");
_damageChance = getNumber (configFile >> "CfgSettings" >> "VehicleSpawn" >> "damageChance");

for "_xSize" from _gridHalf to (_mapsizeX - _gridHalf) step _gridSize do
{
	for "_ySize" from _gridHalf to (_mapsizeY - _gridHalf) step _gridSize do
	{
		_position = [_xSize,_ySize];
		_spawned = 0;
		_spawnedPositions = [];
		while {_spawned < _gridVehicles} do 
		{
			_positionReal = [_position, 25, _gridHalf, 5, 0 , 1 , 0 , _spawnedPositions] call BIS_fnc_findSafePos;
			if(count _positionReal isEqualTo 3)exitWith{};
			_spawnControl = [[(_positionReal select 0) - 50, (_positionReal select 1) + 50],[(_positionReal select 0) + 50,(_positionReal select 1) - 50]];
			_spawnedPositions pushBack _spawnControl;
			_positionReal pushBack 0;
			_vehicleClassName = selectRandom _vehicleClassNames;
			_vehicle = [_vehicleClassName, _positionReal, random 360, true] call ExileServer_object_vehicle_createNonPersistentVehicle;
			_hitpointsData = getAllHitPointsDamage _vehicle;
			if !(_hitpointsData isEqualTo []) then 
			{
				_hitpoints = _hitpointsData select 0;
				{
				    if ((random 100) < _damageChance) then
				    {
				        _vehicle setHitPointDamage [_x, random _maximumDamage];
				    };
				}
				forEach _hitpoints;
			};
			if (_debugMarkers) then
			{
				_debugMarker = createMarker ["vehicleMarker#"+str _vehicleCount, _positionReal];
				_debugMarker setMarkerColor "ColorOrange";
				_debugMarker setMarkerType "mil_dot_noShadow";
			};
			_spawned = _spawned + 1;
			_vehicleCount = _vehicleCount + 1;
		};
	};
};
format ["Dynamic vehicles spawned. Count : %1",_vehicleCount] call ExileServer_util_log;
true

 

Hello.

If I wanted to add more vehicles (eg. M900, Hemit Transport etc) and increase nr of spawn vehicles on the map, would I do that in here? or elsewhere?

Thank you in advance.

Share this post


Link to post
Share on other sites
Advertisement
On 10.9.2016 at 6:35 PM, Michael Cullen said:

I discovered yesterday that the default vehicle spawn script has a couple of bugs in it. It's not too much of a problem with island maps, but on maps with land in the debug area, it's a bit of a nightmare; vehicles end up spawning outside of the map, needlessly eating performance and just generally looking extremely messy :P

So, I fixed it up. Replace your ExileServer_world_spawnVehicles.sqf with the following code.


/**
 * ExileServer_world_spawnVehicles
 *
 * Exile Mod
 * exile.majormittens.co.uk
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 *
 * Fixed by Michael Cullen, no rights reserved.
 */
 
private["_mapsizeX","_mapsizeY","_gridSize","_gridVehicles","_gridHalf","_vehicleCount","_debugMarkers","_vehicleClassNames","_maximumDamage","_damageChance","_xSize","_ySize","_position","_spawned","_spawnedPositions","_positionReal","_spawnControl","_vehicleClassName","_vehicle","_hitpointsData","_hitpoints","_debugMarker"];

_mapsizeX = worldSize;
_mapsizeY = worldSize;
_gridSize = getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "vehiclesGridSize");
_gridVehicles = getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "vehiclesGridAmount");
format ["Spawning Dynamic Vehicles. GridSize: %1 Vehs/Grid: %2",_gridSize,_gridVehicles] call ExileServer_util_log;
_gridHalf = _gridSize / 2;
_vehicleCount = 0;
_debugMarkers = ((getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "vehiclesDebugMarkers")) isEqualTo 1);
_vehicleClassNames = getArray (configFile >> "CfgSettings" >> "VehicleSpawn" >> "ground");
_maximumDamage = getNumber (configFile >> "CfgSettings" >> "VehicleSpawn" >> "maximumDamage");
_damageChance = getNumber (configFile >> "CfgSettings" >> "VehicleSpawn" >> "damageChance");

for "_xSize" from _gridHalf to (_mapsizeX - _gridHalf) step _gridSize do
{
	for "_ySize" from _gridHalf to (_mapsizeY - _gridHalf) step _gridSize do
	{
		_position = [_xSize,_ySize];
		_spawned = 0;
		_spawnedPositions = [];
		while {_spawned < _gridVehicles} do 
		{
			_positionReal = [_position, 25, _gridHalf, 5, 0 , 1 , 0 , _spawnedPositions] call BIS_fnc_findSafePos;
			if(count _positionReal isEqualTo 3)exitWith{};
			_spawnControl = [[(_positionReal select 0) - 50, (_positionReal select 1) + 50],[(_positionReal select 0) + 50,(_positionReal select 1) - 50]];
			_spawnedPositions pushBack _spawnControl;
			_positionReal pushBack 0;
			_vehicleClassName = selectRandom _vehicleClassNames;
			_vehicle = [_vehicleClassName, _positionReal, random 360, true] call ExileServer_object_vehicle_createNonPersistentVehicle;
			_hitpointsData = getAllHitPointsDamage _vehicle;
			if !(_hitpointsData isEqualTo []) then 
			{
				_hitpoints = _hitpointsData select 0;
				{
				    if ((random 100) < _damageChance) then
				    {
				        _vehicle setHitPointDamage [_x, random _maximumDamage];
				    };
				}
				forEach _hitpoints;
			};
			if (_debugMarkers) then
			{
				_debugMarker = createMarker ["vehicleMarker#"+str _vehicleCount, _positionReal];
				_debugMarker setMarkerColor "ColorOrange";
				_debugMarker setMarkerType "mil_dot_noShadow";
			};
			_spawned = _spawned + 1;
			_vehicleCount = _vehicleCount + 1;
		};
	};
};
format ["Dynamic vehicles spawned. Count : %1",_vehicleCount] call ExileServer_util_log;
true

 

Thanks this works Great for Takistan Map!.     

 

On 20.9.2016 at 11:36 AM, SpeedBirdNam said:

Hello.

If I wanted to add more vehicles (eg. M900, Hemit Transport etc) and increase nr of spawn vehicles on the map, would I do that in here? or elsewhere?

Thank you in advance.

Go in the Exileserver config and search for Vehicles spawn.  you can edit this 

Share this post


Link to post
Share on other sites
On 20.9.2016 at 11:36 AM, SpeedBirdNam said:

Hello.

If I wanted to add more vehicles (eg. M900, Hemit Transport etc) and increase nr of spawn vehicles on the map, would I do that in here? or elsewhere?

Thank you in advance.

///////////////////////////////////////////////////////////////////////
    // VEHICLE SPAWN CONFIGURATION
    ///////////////////////////////////////////////////////////////////////

    class VehicleSpawn
    {
        /**
        * Grid Size for vehicle spawning,
        * smaller the number more vehicles,
        * you get the point
        */
        vehiclesGridSize = 2200;

        /**
        * Vehicle ammount per grid
        * kinda self explanitory
        */
        vehiclesGridAmount = 2;

        /**
        * Creates global markers for vehicle spawn tweeking,
        * after you are satisfied with vehicle ammount and spread set this to 0.
        */
        vehiclesDebugMarkers = 0;

        /**
        * The server will apply random damage up to this value when spawning a vehicle.
        */
        damageChance = 20; // 20% chance for a vehicle HITPOINT to be damaged
        maximumDamage = 0.9;

        /**
         * If "randmizeFuel" is set to 1, vehicles will spawn with randomized
         * fuel. In this case, "fuel" controls the percentage of fuel that
         * can be in the vehicle at a maximum. For example, if you set this to
         * 0.5, then vehicles will spawn with something random between 0% and 50%.
         *
         * If "randomizeFuel" is set to 0, all vehicles will spawn exactly the 
         * fuel percentage defined in "fuel". For example, setting this to 0.5
         * will spawn all vehicles with 50% fuel. Setting it to 0 would spawn
         * all vehicles without fuel.
         */
        randomizeFuel = 1;
        fuel = 1;

        /**
         * Works exactly the same as the fuel setting ^
         */
        randomizeAmmo = 1;
        ammo = 1;

        // Stuff to spawn on water
        water[] = 
        {
            "Exile_Boat_MotorBoat_Police",
            "Exile_Boat_MotorBoat_Orange",
            "Exile_Boat_MotorBoat_White",
            "Exile_Boat_RubberDuck_CSAT",
            "Exile_Boat_RubberDuck_Digital",
            "Exile_Boat_RubberDuck_Orange",
            "Exile_Boat_RubberDuck_Blue",
            "Exile_Boat_RubberDuck_Black",
            "Exile_Boat_SDV_CSAT",
            "Exile_Boat_SDV_Digital",
            "Exile_Boat_SDV_Grey"
        };

        // Stuff to spawn on roads
        ground[] = 
        {
            "Exile_Bike_QuadBike_Black",
            "Exile_Bike_QuadBike_Blue",
            "Exile_Bike_QuadBike_Red",
            "Exile_Bike_QuadBike_White",
            "Exile_Bike_QuadBike_Nato",
            "Exile_Bike_QuadBike_Csat",
            "Exile_Bike_QuadBike_Fia",
            "Exile_Bike_QuadBike_Guerilla01",
            "Exile_Bike_QuadBike_Guerilla02",
            "Exile_Car_Volha_Blue",
            "Exile_Car_Volha_White",
            "Exile_Car_Lada_Green",
            "Exile_Car_Lada_Taxi",
            "Exile_Car_TowTractor_White",
            "Exile_Car_UAZ_Open_Green",
            "Exile_Car_UAZ_Green",
            "Exile_Car_LandRover_Ambulance_Desert",
            "Exile_Car_Tractor_Red",
            "Exile_Car_OldTractor_Red",
            "Exile_Car_Octavius_White"
        };

        /**
         * Enables or disables nightvision optics on ALL vehicles
         *
         * 0 = off
         * 1 = on
         */
        nightVision = 1;

        /**
         * Enables or disables thermal optics on ALL vehicles
         *
         * 0 = off
         * 1 = on
         */
        thermalVision = 0;

        /**
         * Set this to 1 to unlock vehicles on server boot if they are in safe zones
         *
         * 0 = off
         * 1 = on
         */
        unlockInSafeZonesAfterRestart = 1;    
    };
 

Share this post


Link to post
Share on other sites

what is btw the way to make it there 0 vehicles spawn on the map because i removed all the land and water vehicles in

Spoiler

// Stuff to spawn on water
        water[] = 
        {
            "Exile_Boat_MotorBoat_Police",
            "Exile_Boat_MotorBoat_Orange",
            "Exile_Boat_MotorBoat_White",
            "Exile_Boat_RubberDuck_CSAT",
            "Exile_Boat_RubberDuck_Digital",
            "Exile_Boat_RubberDuck_Orange",
            "Exile_Boat_RubberDuck_Blue",
            "Exile_Boat_RubberDuck_Black",
            "Exile_Boat_SDV_CSAT",
            "Exile_Boat_SDV_Digital",
            "Exile_Boat_SDV_Grey"
        };

        // Stuff to spawn on roads
        ground[] = 
        {
            "Exile_Bike_QuadBike_Black",
            "Exile_Bike_QuadBike_Blue",
            "Exile_Bike_QuadBike_Red",
            "Exile_Bike_QuadBike_White",
            "Exile_Bike_QuadBike_Nato",
            "Exile_Bike_QuadBike_Csat",
            "Exile_Bike_QuadBike_Fia",
            "Exile_Bike_QuadBike_Guerilla01",
            "Exile_Bike_QuadBike_Guerilla02",
            "Exile_Car_Volha_Blue",
            "Exile_Car_Volha_White",
            "Exile_Car_Lada_Green",
            "Exile_Car_Lada_Taxi",
            "Exile_Car_TowTractor_White",
            "Exile_Car_UAZ_Open_Green",
            "Exile_Car_UAZ_Green",
            "Exile_Car_LandRover_Ambulance_Desert",
            "Exile_Car_Tractor_Red",
            "Exile_Car_OldTractor_Red",
            "Exile_Car_Octavius_White"
        };

and still i get the message:

"ExileServer - Dynamic vehicles spawned. Count : 72"

in my .rpt log

Share this post


Link to post
Share on other sites

@yarpii

 /**
        * Grid Size for vehicle spawning,
        * smaller the number more vehicles,
        * you get the point
        */
        vehiclesGridSize = 2200;

        /**
        * Vehicle ammount per grid
        * kinda self explanitory
        */
        vehiclesGridAmount = 0;

 

sometime fresh eyes help have a great day 

Share this post


Link to post
Share on other sites

Mine's not spawning anything on water.   I seem to recall somewhere that while the array exists to "spawn stuff on water", there's no code that actually spawns watercraft.  Was this ever resolved?

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.