[1.8.6.1] - How to spawn more vehicles?

KrisiS

Member
I have an issue where only a handful of vehicles are spawning on a fresh database install.
How can I up the amount of vehicles spawning?

Also, how can I add custom vehicle spawn points?

The database is different than I remember it being on 1.8.6.1
database.jpg


Thanks for any help :)
 
oh yeah ,.. i tried all day to setup a 1861 dayz testing server before i realized it woudnt interface with my old database schema.

will have to lookwhen i get home, but it looks like the old database where we have spawn points and they are selected randomly .. i would say step one is to open the editor and place vehicles where you want them to spawn, save the mission ( you will need a center,group,unit to save) and then i have a php script and vps where we can automatically insert them into your database ... assuming you have a hundred or more ...
 
I didnt look closely at the spawn function, just guessing from the tables and what they contain. I would say to add spawns you create a "location" in vehicle_locations that contains the "id" of the vehicle_spawns classname and information.
So this is a spawn location which will spawn a vehicle of ID 12
MySQL_Workbench_2016-02-13_15-27-50.png

And from vehicle_spawns table here is ID #12
MySQL_Workbench_2016-02-13_15-29-35.png


So if we want MORE of that type of vehicle, increase MaxNum which will spawn as long as total is less than MaxVehicles defined. One issue is there is only 144 locations so until those vehicles are moved by players, no more than 144 will spawn. So go into the editor, make a couple hundred locations and we can insert them into the database using php script.


Here is the spawn vehicles function for analysis.
Check Declare MaxVehicles for increasing spawned amount.
Code:
CREATE DEFINER=`dayz`@`localhost` PROCEDURE `pSpawnVehicles`(IN `i` int)
BEGIN
    #---------------------------------------------------------------
    #Change this to affect the maximum number of vehicles on the server.
    DECLARE MaxVehicles INT DEFAULT 80;
  
    #Change this to affect the radius that is checked for existing vehicles when spawning.
    #If set to 0 or negative vehicles will always spawn despite blocking vehicles.
    DECLARE SearchRadius DOUBLE DEFAULT 10;
    #---------------------------------------------------------------
  
    DECLARE ServerInstance INT DEFAULT i;
    DECLARE MaxNumSpawn INT DEFAULT MaxVehicles - countVehicles(ServerInstance);
  
    DROP TEMPORARY TABLE IF EXISTS temp_objects;
    CREATE TEMPORARY TABLE temp_objects AS
    (
        SELECT    CONVERT(SUBSTRING(SUBSTRING_INDEX(@ws, ",", 2), LENGTH(SUBSTRING_INDEX(@ws, ",", 1)) + 2), DECIMAL(10, 5)) AS X,
                CONVERT(SUBSTRING(SUBSTRING_INDEX(@ws, ",", 3), LENGTH(SUBSTRING_INDEX(@ws, ",", 2)) + 2), DECIMAL(10, 5)) AS Y
        FROM object_data
        WHERE CharacterID = 0
            AND Instance = ServerInstance
            AND (@ws := Worldspace) IS NOT NULL
            AND (@ws := REPLACE(@ws, "[", "")) IS NOT NULL
            AND (@ws := REPLACE(@ws, "]", "")) IS NOT NULL
    );
  
    DROP TEMPORARY TABLE IF EXISTS temp_locations;
    CREATE TEMPORARY TABLE temp_locations AS
    (
        SELECT vehicle_locations.ID, temp2.Worldspace
        FROM
        (
            SELECT Worldspace
            FROM
            (
                SELECT    Worldspace,
                        CONVERT(SUBSTRING(SUBSTRING_INDEX(@ws, ",", 2), LENGTH(SUBSTRING_INDEX(@ws, ",", 1)) + 2), DECIMAL(10, 5)) AS X,
                        CONVERT(SUBSTRING(SUBSTRING_INDEX(@ws, ",", 3), LENGTH(SUBSTRING_INDEX(@ws, ",", 2)) + 2), DECIMAL(10, 5)) AS Y
                FROM (SELECT Worldspace FROM vehicle_locations GROUP BY Worldspace) AS temp
                WHERE (@ws := Worldspace) IS NOT NULL
                    AND (@ws := REPLACE(@ws, "[", "")) IS NOT NULL
                    AND (@ws := REPLACE(@ws, "]", "")) IS NOT NULL
            ) AS temp1
            WHERE
            (
                @distance :=
                (
                    SELECT MIN(SQRT((temp_objects.X - temp1.X) * (temp_objects.X - temp1.X) + (temp_objects.Y - temp1.Y) * (temp_objects.Y - temp1.Y)))
                    FROM temp_objects
                )
            ) IS NULL OR @distance > SearchRadius
        ) AS temp2
        JOIN vehicle_locations
            ON vehicle_locations.Worldspace = temp2.Worldspace
    );
  
    DROP TEMPORARY TABLE IF EXISTS temp_spawns;
    CREATE TEMPORARY TABLE temp_spawns AS
    (
        SELECT temp.ID, Classname, Worldspace, Chance, MinFuel, MaxFuel, MinDamage, MaxDamage
        FROM
        (
            SELECT *
            FROM vehicle_spawns
            WHERE (@numSpawnable := getNumSpawnable(ServerInstance, ID)) IS NOT NULL
                AND @numSpawnable > 0
            ORDER BY RAND()
        ) AS temp
        JOIN temp_locations
            ON temp_locations.ID = temp.Location
        ORDER BY RAND()
    );
  
    SET @numSpawned = 0;
    WHILE (@numSpawned < MaxNumSpawn AND (SELECT COUNT(*) FROM temp_spawns) > 0) DO
        SET @spawnid = (SELECT ID FROM temp_spawns LIMIT 1);
        SET @chance = (SELECT Chance FROM temp_spawns LIMIT 1);
        SET @numSpawnable = getNumSpawnable(ServerInstance, @spawnid);
        IF (@numSpawnable > 0 AND RAND() < @chance) THEN
            SET @worldspace = (SELECT Worldspace FROM temp_spawns LIMIT 1);
            INSERT INTO object_data (ObjectUID, Classname, Instance, CharacterID, Worldspace, Inventory, Hitpoints, Fuel, Damage, Datestamp)
            SELECT generateUID(ServerInstance), Classname, ServerInstance, 0, Worldspace,
                randomizeVehicleInventory(Classname),
                randomizeVehicleHitpoints(Classname),
                MinFuel + RAND() * (MaxFuel - MinFuel),
                MinDamage + RAND() * (MaxDamage - MinDamage),
                SYSDATE()
            FROM temp_spawns
            LIMIT 1;
          
            DELETE FROM temp_spawns WHERE Worldspace = @worldspace;
          
            SET @numSpawned = @numSpawned + 1;
        END IF;
      
        SET @numSpawnable = @numSpawnable - 1;
      
        IF (@numSpawnable < 1) THEN
            DELETE FROM temp_spawns WHERE ID = @spawnid;
        END IF;
    END WHILE;
  
    SELECT CONCAT(@numSpawned, " vehicles spawned.");
END
 
I much prefer this method of spawning vehicles. I detest the Epoch random vehicles (Delpi added DB spawns to his epoch I think).
So these Procedures could be inserted into an epoch db, copy the vehicle tables and have actual spawned vehicles where they are supposed to be .. military vehicles near military, bicycles and motorcycles in yards, planes on the runways ...
Both Dayz 1.8.6.1 and Epoch store vehicles in the object_data tables which are identical so .. Yeah, I am going to put this into my Overpoch server.
 
Nice one man, I won't get a chance to try this until tomorrow!
Thank you so much for sharing mate, you're a STAR !!! :)
 
I probably should have emphasized that the vehicle spawn function I pasted above. Has how many vehcles to spawn in total .. increase that .. its 80 right now.
 
I will actually get a chance to test this later :)

Where can I change the maxvehicles ?
 
Last edited:
In my previous post.

%25255B1.8.6.1%25255D_-_How_to_spawn_more_vehicles__Open_Day_2016-02-14_11-14-47.png


In your previous post, you posted this image.

%25255B1.8.6.1%25255D_-_How_to_spawn_more_vehicles__Open_Day_2016-02-14_11-21-08.png


So now a short video ...


Its valentines day .. all text in pink.
 
Hehe, thanks for the video :)

My pSpawnVehicles doesn't have anything like that in it.. and it's file size is nothing
Any ideas about that one ? xD
 
okay, i am going to create a blank database and add in the files as they should have been added. .. I wish I had a microphone sometimes so I could annotate these quick videos.
Anyways these are the steps I demonstrate in this video. You have to adapt the steps to whatever crappy mysql client you are using instead of mysqlworkbench. I mean, we all use MYSQL, why not use the client that Oracle created to work explicitly with a mysql server?
I create a new database.
I download the SQL files from the 1.8.6 repository from se1.dayz.nu
I create a blank database.
I open and execute the query to create a new table (just to show something that you know .. for reference)
I open and execute the procedure query to create that in the database.

Using mysqlworkbench


And here is using phpmyadmin
 
Thank you man, that is really helpful.

I get an Access Denied error because I don't have enough privileges when trying to do the same.
I'll have to leave it for now as rl is calling :)

PS: I use mysqlworkbench ;)
 
Unfortunately this server is hosted and rented as a single server. I can't give myself the permissions.
I took the first screen with heidisql, I have that too :)
 
well ... your user should have full permissions on that datsbase, if not then thats hosed up.
i hand out free servers ... do you want a mysql server?
 
Actually, you know what... I have mySQL servers with my website host....
I didn't think of using that to create one :/

I'd prefer to keep it all with the same provider :)

I think the permissions are there, I'm just not well up on SQL to work it out.
 
There are a couple of things that affect MAX VEHICLES. The first is the setting in the pSpawnVehicles. The others are MaxNum in the vehicle_groups table and MaxNum in vehicle_spawns. The final is the sheet number of spawn locations in vehicle_locations (because the spawn code looks for vehicles already there).

I can't remember how the vehicle groups are implemented - again I think its based on locations (instead of a simple foreign key relationship).
 
We got this all fixed up via email. During that time, I got the dayz 1.8.6.1 vehicle spawn system integrated with my Overcrap server so I can have vehicles spawn where I place them. I will post the howto this weekend.
 
I got mentioned above. I didn't add database spawning of vehicles for Epoch, i wrote a script that spawned them from location settings in a config file for the script. It worked very well. Only downside was having to load a new file if i wanted to change anything on the spawn setup, but if your into modding that really isn't much of a downside.
 
I didnt look closely at the spawn function, just guessing from the tables and what they contain. I would say to add spawns you create a "location" in vehicle_locations that contains the "id" of the vehicle_spawns classname and information.
So this is a spawn location which will spawn a vehicle of ID 12
MySQL_Workbench_2016-02-13_15-27-50.png

And from vehicle_spawns table here is ID #12
MySQL_Workbench_2016-02-13_15-29-35.png


[/SPOILER]

I apologize. It is an old subject. I have tried on base 1.8.9 and have understood that there was a confusion with ID in comparison with old tables. You could explain
the sir now if you are engaged in it concerning spawn vehicle?
 
There are a couple of things that affect MAX VEHICLES.
1) The setting in the pSpawnVehicles - but you can't just make it 500 because there won't be enough spawn locations.
2) MaxNum in vehicle_spawns - limits individual vehicles
3) MaxNum in the vehicle_groups table - maintains groups (like helis)
 
Back
Top