Warsheep

[Guide] Custom Vehicle Spawn (Air/Ground/Water)

113 posts in this topic

5 minutes ago, GooseApocalypse said:

Any way to get vehicles to spawn on main roads only as the vehicles are spawning on trails and blowing up from time to time?

Take a look at how Exile does this for spawn zone vehicles.

Share this post


Link to post
Share on other sites

Does anyone know whether this is still working properly?  I have had it on my main and test Tanoa servers for a very long time.  Recently, I turned vehicle markers on and noticed that the spawns didn't look right.  I went to my server.rpt and there are no error messages but nor are there any messages that Warsheep's system engaged at all.  No Warsheep vehicle spawn messages in the server.rpt at all.  I compared the vehicle spawn section in exile_server_config\config.cpp, and both the overwrites\ExileServer_world_spawnSpawnZoneVehicles.sqf and  exile_overwrites\ExileServer_world_spawnVehicles.sqf to both this OP and my last working server files (I keep multiple versions of my main and test servers).   All compare exactly - line-for-line and character-for-character.  Does anyone know if the two overwrite files changed in the base 1.0.3 code?  Could one of the recent CBA_A3 or CUP mod updates have affected it?

Edited by Bob_the_K

Share this post


Link to post
Share on other sites
Advertisement
7 hours ago, Bob_the_K said:

Does anyone know whether this is still working properly?  I have had it on my main and test Tanoa servers for a very long time.  Recently, I turned vehicle markers on and noticed that the spawns didn't look right.  I went to my server.rpt and there are no error messages but nor are there any messages that Warsheep's system engaged at all.  No Warsheep vehicle spawn messages in the server.rpt at all.  I compared the vehicle spawn section in exile_server_config\config.cpp, and both the overwrites\ExileServer_world_spawnSpawnZoneVehicles.sqf and  exile_overwrites\ExileServer_world_spawnVehicles.sqf to both this OP and my last working server files (I keep multiple versions of my main and test servers).   All compare exactly - line-for-line and character-for-character.  Does anyone know if the two overwrite files changed in the base 1.0.3 code?  Could one of the recent CBA_A3 or CUP mod updates have affected it?

I was gonna look into this tomorrow, possibly update if it needs to be.

Share this post


Link to post
Share on other sites

I did extract the two files from the server PBO (the two world-spawn files) and compared today's to the ones I had when this was working.   There's no change whatsoever to the files.  They are the same now as when this script was working on a previous server build.  So I'm thinking that points to some other mod/addon impacting it.  The two I mentioned are the first that come to mind, especially since both have been upgraded since the last time this was working properly.

Edit:  I have verified that the two world-spawn files in my overwrites folder are indeed being called.  I wonder if some function that Warsheep used was deprecated with one of the last Arma updates.  But then I'd expect some sort of error.  I'm digging into those two files to see what variables are being passed and/or set to see if I can figure out what's broken.  

 

Edited by Bob_the_K

Share this post


Link to post
Share on other sites

Anyone still using this?  I've been using it for quite a while and love it especially for Tanoa since it spawns in boats along the shore - particularly useful since Tanoa is a collection of islands.

I've been rebuilding my server from the ground up since the Arma 3 1.76 update.  Part of my rebuild includes full conversion to 64 bit, including database.   I'm at the point that  I just added this back in.  It works except for one thing.   Now, most of the vehicles blow up as I approach them.  It never did that before.   I do notice that the vehicles "bounce" a little as I'm approaching and believe that is what causes them to explode.  I suspect it may have to do with how simulations are now handled.   Anyone have any ideas on how to fix this?

Share this post


Link to post
Share on other sites
On 12.11.2016 at 1:49 AM, KlownGT said:

Hey guys, I know Warsheep doesn't plan on explaining the update to noobs, but anyone one else willing? I've added the lines into each area, basically following the original files format in terms of placement, but all of my vehicles are spawning with no fuel what so ever.

My  ExileServer_world_spawnVehicles

  Reveal hidden contents

/**
 * ExileServer_world_spawnVehicles
 * edited by Warsheep(GER)
 * Exile Mod
 * www.exilemod.com
 * © 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/.
 */
 
private["_randomizeFuel","_fuel","_randomizeAmmo","_ammo","_worldName","_worldSize","_middle","_quarter","_threeQuarter","_southwestPos","_southPos","_southeastPos","_westPos","_middlPos","_eastPos","_northwestPos","_northPos","_northeastPos","_groundVehicleAmount","_waterVehicleAmount","_airVehicleAmount","_vehicleAmount","_vehicleCount","_errorCount","_ground","_groundVehicleCount","_groundVehicleClassNames","_groundDebugMarkers","_groundDebugMarker","_groundSpawnRadiusRoad","_groundDamageChance","_groundMaximumDamage","_water","_waterVehicleCount","_waterVehicleClassNames","_waterDebugMarkers","_waterDebugMarker","_waterSpawnRadiusCoast","_waterDamageChance","_waterMaximumDamage","_air","_airVehicleCount","_airVehicleClassNames","_airDebugMarkers","_airDebugMarker","_airSpawnRadiusAirField","_airDamageChance","_airMaximumDamage","_mapPos","_spawnedPositions","_airportPositions"];

_debugLog                    = getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "vehicleDebugLog");

_worldName                     = worldName;
_worldSize                    = worldSize;
_middle                        = worldSize / 2;
_quarter                    = worldSize / 4;
_threeQuarter                = _quarter * 3;

_southwestPos                = [_quarter,_quarter,0];
_southPos                    = [_middle,_quarter,0];
_southeastPos                = [_threeQuarter,_quarter,0];
_westPos                    = [_quarter,_middle,0];
_middlPos                    = [_middle,_middle,0];
_eastPos                    = [_threeQuarter,_middle,0];
_northwestPos                = [_quarter,_threeQuarter,0];
_northPos                    = [_middle,_threeQuarter,0];
_northeastPos                = [_threeQuarter,_threeQuarter,0];

_groundVehicleAmount            = getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "groundVehicleAmount");
_waterVehicleAmount                = getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "waterVehicleAmount");
_airVehicleAmount                = getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "airVehicleAmount");
_vehicleAmount                    = _groundVehicleAmount + _waterVehicleAmount + _airVehicleAmount;
_vehicleCount                    = 0;
_errorCount                        = 0;

_randomizeFuel                 = ((getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "randomizeFuel")) isEqualTo 1);
_fuel                         = (getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "fuel"));
_randomizeAmmo                 = ((getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "randomizeAmmo")) isEqualTo 1);
_ammo                         = (getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "ammo"));

if(_vehicleAmount isEqualTo 0)exitWith{
    if(_debugLog >= 1) then {
        format ["||WARSHEEP||Spawning Dynamic Vehicles Disabled."] call ExileServer_util_log;
    };
};

if(_groundVehicleAmount isEqualTo 0) then {
    _ground                     = 0;
    if(_debugLog >= 1) then {                    
        format ["||WARSHEEP||Spawning Dynamic Ground Vehicles Disabled."] call ExileServer_util_log;
    };
}else{ 
    _ground                     = 1;
    _groundVehicleCount            = 0;
    _groundVehicleClassNames    = getArray (configFile >> "CfgSettings" >> "VehicleSpawn" >> "ground");
    _groundDebugMarkers            = ((getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "groundDebugMarkers")) isEqualTo 1);
    _groundSpawnRadiusRoad        = getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "groundSpawnRadius");
    _groundDamageChance            = getNumber (configFile >> "CfgSettings" >> "VehicleSpawn" >> "groundDamageChance");
    _groundMaximumDamage        = getNumber (configFile >> "CfgSettings" >> "VehicleSpawn" >> "groundMaximumDamage");
};

if(_waterVehicleAmount isEqualTo 0) then {
    _water                         = 0;
    if(_debugLog >= 1) then {
        format ["||WARSHEEP||Spawning Dynamic Water Vehicles Disabled."] call ExileServer_util_log;
    };
}else{ 
    _water                         = 1;
    _waterVehicleCount            = 0;
    _waterVehicleClassNames        = getArray (configFile >> "CfgSettings" >> "VehicleSpawn" >> "water");
    _waterDebugMarkers            = ((getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "waterDebugMarkers")) isEqualTo 1);
    _waterSpawnRadiusCoast        = getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "waterSpawnRadius");
    _waterDamageChance            = getNumber (configFile >> "CfgSettings" >> "VehicleSpawn" >> "waterDamageChance");
    _waterMaximumDamage            = getNumber (configFile >> "CfgSettings" >> "VehicleSpawn" >> "waterMaximumDamage");
};

if(_airVehicleAmount isEqualTo 0) then {
    _air                         = 0;
    if(_debugLog >= 1) then {
        format ["||WARSHEEP||Spawning Dynamic Air Vehicles Disabled."] call ExileServer_util_log;
    };
}else{ 
    _air                         = 1;
    _airVehicleCount            = 0;
    _airVehicleClassNames        = getArray (configFile >> "CfgSettings" >> "VehicleSpawn" >> "air");
    _airDebugMarkers            = ((getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "airDebugMarkers")) isEqualTo 1);
    _airSpawnRadiusAirField        = getNumber(configFile >> "CfgSettings" >> "VehicleSpawn" >> "airSpawnRadius");
    _airDamageChance            = getNumber (configFile >> "CfgSettings" >> "VehicleSpawn" >> "airDamageChance");
    _airMaximumDamage            = getNumber (configFile >> "CfgSettings" >> "VehicleSpawn" >> "airMaximumDamage");
};

_mapPos                     = [_southwestPos,_middlPos,_southPos,_middlPos,_southeastPos,_middlPos,_westPos,_middlPos,_eastPos,_middlPos,_northwestPos,_middlPos,_northPos,_middlPos,_northeastPos,_middlPos];
_spawnedPositions             = [];
_airportPositions             = call ExileClient_util_world_getAllAirportPositions;

if(_debugLog >= 1) then {
    format ["||WARSHEEP||Spawning Dynamic Vehicles. Config loaded!"] call ExileServer_util_log;
};
while {_vehicleCount < _vehicleAmount} do {
    if (_ground isEqualTo 1) then {
        if (_groundVehicleCount < _groundVehicleAmount) then {
            _pos = selectRandom _mapPos;
            _vehiclePosition = [_pos, _middle] call ExileClient_util_world_findRoadPosition;
            _positionReal = [_vehiclePosition, 1, _groundSpawnRadiusRoad, 2, 0 , 0 , 0 , _spawnedPositions] call BIS_fnc_findSafePos;
            if(count _positionReal isEqualTo 3 ) then {
                _groundVehicleAmount = _groundVehicleAmount - 1;
                _vehicleAmount = _vehicleAmount - 1;
                _errorCount = _errorCount + 1;
                _spawnControl = [[(_positionReal select 0) - 50, (_positionReal select 1) + 50],[(_positionReal select 0) + 50,(_positionReal select 1) - 50]];
                _spawnedPositions pushBack _spawnControl;
                if(_debugLog isEqualTo 1) then {
                    format ["||WARSHEEP||%1 Error Position",_positionReal] call ExileServer_util_log;
                };
            }else{
                _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 _groundVehicleClassNames;
                _vehicle = [_vehicleClassName, _positionReal, random 360, true] call ExileServer_object_vehicle_createNonPersistentVehicle;
                if(_debugLog isEqualTo 1) then {
                    format ["||WARSHEEP||%1 Spawned",_vehicleClassName] call ExileServer_util_log;
                };
                _hitpointsData = getAllHitPointsDamage _vehicle;
                if !(_hitpointsData isEqualTo []) then {
                    _hitpoints = _hitpointsData select 0;{
                        if ((random 100) < _groundDamageChance) then{
                            _vehicle setHitPointDamage [_x, random _groundMaximumDamage];
                        };
                    }forEach _hitpoints;
                };
            if (_randomizeFuel) then {
                _vehicle setFuel (random _fuel);
                } else {
                _vehicle setFuel _fuel;
                };
            if (_randomizeAmmo) then 
                {
                _vehicle setVehicleAmmo (random _ammo);
                } else {
                _vehicle setVehicleAmmo _ammo;
                };
                if (_groundDebugMarkers) then{
                    _groundDebugMarker = createMarker ["vehicleMarkerGround#"+str _groundVehicleCount, _positionReal];
                    _groundDebugMarker setMarkerColor "ColorGreen";
                    _groundDebugMarker setMarkerType "mil_dot_noShadow";
                };
                _groundVehicleCount = _groundVehicleCount + 1;
                _vehicleCount = _vehicleCount + 1;
            };
        }else{
            _ground = 0;
        };
    };
    
    if (_water isEqualTo 1) then {
        if (_waterVehicleCount < _waterVehicleAmount) then {
            _pos = selectRandom _mapPos;
            _vehiclePosition = [_pos, 1, _middle, 2, 1, 0, 1, _spawnedPositions] call BIS_fnc_findSafePos;
            _posSafe = _vehiclePosition call ExileClient_util_world_findCoastPosition;
            _positionReal = [_posSafe, 1, _waterSpawnRadiusCoast, 1, 2 , 0 , 0 , _spawnedPositions] call BIS_fnc_findSafePos;
            if(count _positionReal isEqualTo 3 ) then {
                _waterVehicleAmount = _waterVehicleAmount - 1;
                _vehicleAmount = _vehicleAmount - 1;
                _errorCount = _errorCount + 1;
                _spawnControl = [[(_positionReal select 0) - 50, (_positionReal select 1) + 50],[(_positionReal select 0) + 50,(_positionReal select 1) - 50]];
                _spawnedPositions pushBack _spawnControl;
                if(_debugLog isEqualTo 1) then {
                    format ["||WARSHEEP||%1 Error Position",_positionReal] call ExileServer_util_log;
                };
            }else{
                _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 _waterVehicleClassNames;
                _vehicle = [_vehicleClassName, _positionReal, random 360, true] call ExileServer_object_vehicle_createNonPersistentVehicle;
                if(_debugLog isEqualTo 1) then {
                    format ["||WARSHEEP||%1 Spawned",_vehicleClassName] call ExileServer_util_log;
                };
                _hitpointsData = getAllHitPointsDamage _vehicle;
                if !(_hitpointsData isEqualTo []) then {
                    _hitpoints = _hitpointsData select 0;{
                        if ((random 100) < _waterDamageChance) then{
                            _vehicle setHitPointDamage [_x, random _waterMaximumDamage];
                        };
                    }forEach _hitpoints;
                };
            if (_randomizeFuel) then {
                _vehicle setFuel (random _fuel);
                } else {
                _vehicle setFuel _fuel;
                };
            if (_randomizeAmmo) then 
                {
                _vehicle setVehicleAmmo (random _ammo);
                } else {
                _vehicle setVehicleAmmo _ammo;
                };
                if (_waterDebugMarkers) then{
                    _waterDebugMarker = createMarker ["vehicleMarkerWater#"+str _waterVehicleCount, _positionReal];
                    _waterDebugMarker setMarkerColor "ColorBlue";
                    _waterDebugMarker setMarkerType "mil_dot_noShadow";
                };
                _waterVehicleCount = _waterVehicleCount + 1;
                _vehicleCount = _vehicleCount + 1;
            };
        }else{
            _water = 0;
        };
    };
    
    if (_air isEqualTo 1) then {
        if (_airVehicleCount < _airVehicleAmount) then {
            _pos = selectRandom _airportPositions;
            _vehiclePosition = [_pos, 750] call ExileClient_util_world_findRoadPosition;
            _positionReal = [_vehiclePosition, 1, _airSpawnRadiusAirField, 7, 0 , 0 , 0 , _spawnedPositions] call BIS_fnc_findSafePos;
            if(count _positionReal isEqualTo 3 ) then {
                _airVehicleAmount = _airVehicleAmount - 1;
                _vehicleAmount = _vehicleAmount - 1;
                _errorCount = _errorCount + 1;    
                _spawnControl = [[(_positionReal select 0) - 50, (_positionReal select 1) + 50],[(_positionReal select 0) + 50,(_positionReal select 1) - 50]];
                _spawnedPositions pushBack _spawnControl;
                if(_debugLog isEqualTo 1) then {
                    format ["||WARSHEEP||%1 Error Position",_positionReal] call ExileServer_util_log;
                };
            }else{
                _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 _airVehicleClassNames;
                _vehicle = [_vehicleClassName, _positionReal, random 360, true] call ExileServer_object_vehicle_createNonPersistentVehicle;
                if(_debugLog isEqualTo 1) then {
                    format ["||WARSHEEP||%1 Spawned",_vehicleClassName] call ExileServer_util_log;
                };
                _hitpointsData = getAllHitPointsDamage _vehicle;
                if !(_hitpointsData isEqualTo []) then {
                    _hitpoints = _hitpointsData select 0;{
                        if ((random 100) < _airDamageChance) then{
                            _vehicle setHitPointDamage [_x, random _airMaximumDamage];
                        };
                    }forEach _hitpoints;
                };
            if (_randomizeFuel) then {
                _vehicle setFuel (random _fuel);
                } else {
                _vehicle setFuel _fuel;
                };
            if (_randomizeAmmo) then 
                {
                _vehicle setVehicleAmmo (random _ammo);
                } else {
                _vehicle setVehicleAmmo _ammo;
                };
                if (_airDebugMarkers) then{
                    _airDebugMarker = createMarker ["vehicleMarkerAir#"+str _airVehicleCount, _positionReal];
                    _airDebugMarker setMarkerColor "ColorBlack";
                    _airDebugMarker setMarkerType "mil_dot_noShadow";
                };
                _airVehicleCount = _airVehicleCount + 1;
                _vehicleCount = _vehicleCount + 1;
            };
        }else{
            _air = 0;
        };
    };
};
if (_errorCount > 0)then {
    if(_debugLog >= 1) then {
        format ["||WARSHEEP||Dynamic Vehicles Error. Count : %1",_errorCount] call ExileServer_util_log;
    };
};
if (_groundVehicleAmount > 0) then {
    if(_debugLog >= 1) then {
        format ["||WARSHEEP||Dynamic Ground Vehicles Spawned. Count : %1/%2",_groundVehicleCount,_groundVehicleAmount] call ExileServer_util_log;
    };
};
if (_waterVehicleAmount > 0) then {
    if(_debugLog >= 1) then {
        format ["||WARSHEEP||Dynamic Water Vehicles Spawned. Count : %1/%2",_waterVehicleCount,_waterVehicleAmount] call ExileServer_util_log;
    };
};
if (_airVehicleAmount > 0) then {
    if(_debugLog >= 1) then {
        format ["||WARSHEEP||Dynamic Air Vehicles Spawned. Count : %1/%2",_airVehicleCount,_airVehicleAmount] call ExileServer_util_log;
    };
};
if(_debugLog >= 1) then {
        format ["||WARSHEEP||Dynamic Vehicles Spawned. Count : %1/%2",_vehicleCount,_vehicleAmount] call ExileServer_util_log;
};

Thanks in advance, this is driving me nuts!

 

*Edit*

Removed the randomize fuel and ammo options, everything spawns full. Good To Go now!

/**
        * Array of blacklisted Positions
        * not included now
        **/
        blackList[] =
        {};

when u can read then u see NOT INCLUDED NOW , this was planed but i never worked on it.

to the spawn bug for exploding vehicles i can only say thats i used the exile side "safe" spawn script

 call ExileServer_object_vehicle_createNonPersistentVehicle

i only change the way to find the locations, so its a exile/bohemia side bug .

Share this post


Link to post
Share on other sites

@Warsheep , first of all thank you for your great Work. This runs fine on my Server. 

I also read the part of smaller maps, i use Malden,... but at server - restart some Vehicles are exploding... can you tell me the setup for Malden ? Sorry for my bad english. Pls dont misunderstand me, it really works fine and i tried to figuere it out, but dont find it. Best Regards my friend.

Share this post


Link to post
Share on other sites
14 hours ago, skittie said:

@Warsheep , first of all thank you for your great Work. This runs fine on my Server. 

I also read the part of smaller maps, i use Malden,... but at server - restart some Vehicles are exploding... can you tell me the setup for Malden ? Sorry for my bad english. Pls dont misunderstand me, it really works fine and i tried to figuere it out, but dont find it. Best Regards my friend.

 

On 19.11.2017 at 0:00 AM, Warsheep said:

to the spawn bug for exploding vehicles i can only say thats i used the exile side "safe" spawn script


 call ExileServer_object_vehicle_createNonPersistentVehicle

i only change the way to find the locations, so its a exile/bohemia side bug .

 

Edited by Warsheep

Share this post


Link to post
Share on other sites
2 hours ago, skittie said:

but the green dots are not removable for me... =/

You implemented that?

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

 

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.