Project Zomboid

Project Zomboid

Driving Cars Mod
Gray 11 Dec, 2016 @ 8:55am
Edit Car Spawn Rate and more
I want to lower the spawn rate of all cars significantly. So I looked into the media>lua>server folder and saw this code:
DriveCarsCMAX = 2000; -- default
function SetCarSpawnRate()
in the CarsLoading.lua (after I opened it with editor).
Is there a way to decrease the spawn rate in general, or do I have to change the value for every single vehicle?
I also want to edit the car speed, namely the acceleration and maximum speed.
And last but not least, the loot. Since I think editing and refining that would be too much work, I'd like to turn it off completely and limit it to the car key.
Last edited by Gray; 11 Dec, 2016 @ 8:56am
< >
Showing 1-2 of 2 comments
moumix 22 Oct, 2017 @ 11:04am 
That's a lot of questions, but as I've basically done that for myself, I can help :D

LOWER CAR SPAWN:
In the "mods\Drive Cars\media\lua\server" folder, open the "CarsLoading.lua" file.

In there, find this:

function SetCarSpawnRate() if (ZomboidGlobals.OtherLootModifier == 4) then --abundant DriveCarsCMAX = 200; elseif (ZomboidGlobals.OtherLootModifier == 2.0) then DriveCarsCMAX = 1200; elseif (ZomboidGlobals.OtherLootModifier == 1.0) then DriveCarsCMAX = 2000; elseif (ZomboidGlobals.OtherLootModifier == 0.6) then DriveCarsCMAX = 3200; elseif (ZomboidGlobals.OtherLootModifier == 0.2) then --very rare DriveCarsCMAX = 4200; end end

Each line beginning with "DriveCarsCMAX =" is linked to your "Other Loot" rarity setting for your game. As per the comments, the first one is "Abundant", and the last one is "Very rare". The number for "DriveCarsCMAX" is the chance that a car appears on each road/concrete tile, higher is rarer. In the example above, in "Abundant", each tile has a 1/200 chance to spawn a car. In "Very rare", it's 1/4200 chance to spawn a car.

Adjust to your preference. :)


EDIT CAR SPEED
In the "mods\Drive Cars\media\lua\client" folder, open the "DriveCars.lua" file.

In there, you'll have to modify the numbers in those 2 functions ("getAcc" is the acceleration, and "getTopSpeed" is the top speed). The last number after the "else" is the default for any car not listed above (0.032 for acceleration and 0.50 for top speed):

function getAcc(CarType) if(CarType == "Firetruck") then return 0.026; elseif(CarType == "MArmor") then return 0.028; elseif(CarType == "MTruck") then return 0.028; elseif(CarType == "MJeep") then return 0.030; elseif(CarType == "Jeep2") then return 0.030; elseif(CarType == "Hummer") then return 0.030; elseif(CarType == "Jeep") then return 0.030; elseif(CarType == "PCar") then return 0.034; elseif(CarType == "Van") then return 0.028; elseif(CarType == "Pickup") then return 0.030; elseif(CarType == "Ambulance") then return 0.028; elseif(CarType == "SportsCar") then return 0.038; elseif(CarType == "Plane") then return 0.008; else return 0.032; end end function getTopSpeed(CarType) if(CarType == "Firetruck") then return 0.66; elseif(CarType == "Ambulance") then return 0.66; elseif(CarType == "MArmor") then return 0.58; elseif(CarType == "MTruck") then return 0.58; elseif(CarType == "PCar") then return 0.58; elseif(CarType == "Beetle") then return 0.42; elseif(CarType == "Tank") then return 0.14; elseif(CarType == "MJeep") then return 0.58; elseif(CarType == "SportsCar") then return 0.72; elseif(CarType == "Plane") then return 0.80; else return 0.50; end end


MODIFY/DISABLE LOOT IN CARS
That's gonna be a lot of work, but here is how to do it:

In the same file as the car spawn rate ("CarsLoading.lua" in "mods\Drive Cars\media\lua\server" folder), you'll find, almost at the beginning, a long long list of loot for each car (broken and non broken version). Each car's loot table will look like this:

SuburbsDistributions["FiretruckBROKEN"] = { rolls = 5, items = { "Base.CorpseMale", 2, "Base.CorpseFemale", 2, "Base.Map", 4, "Base.Wallet", 2, "Base.PetrolCan", 8, "Base.WaterBottleEmpty", 2, "Base.Tissue", 2, "Base.BaseballBat", 2, "Base.WaterBottleFull", 2, "Base.Schoolbag", 2, "Base.Screwdriver", 2, "Base.Shotgun", 2, "Base.Scissors", 2, "Base.Pen", 2, "Base.Pencil", 2, "Base.Pop", 2, "Base.Rope", 10, "Base.HuntingRifle", 2, "Base.Duffelbag", 2, "Base.EmptyPetrolCan", 2, "Base.Tarp", 4, "Base.Hammer", 4, "Base.TinnedBeans", 2, "Base.BucketWaterFull", 20, "Base.CannedPotato2", 2, "Base.CannedTomato2", 2, "Base.Crowbar", 10, "Base.223Bullets", 2, "Base.308Bullets", 2, "Base.Bullets9mm", 2, "Base.Axe", 12, "Base.BaseballBat", 1, }, fillRand = 5, };

rolls=5 is the number of times to roll an item on this table. This is increased/decreased by the loot rarity setting in your game.

fillRand=5 is the chance that a roll will give an item (I think). I think it means 1/5 chance to get an item. Higher is rarer chance, lower is better chance, and 0 means it's always going to give an item for each roll.

"Base.XXX", Y is the item type, and the "weight" for this item. Basically, add all the weights together, and each item has a Y/TOTALWEIGHT chance to be picked with each roll. Higher means the item is more likely to appear, lower is rarer.

Just modify those lines for each car, to only leave the loot you want. If you want no loot at all in the cars, except the key (which is created in another part of the code), then just delete all the lines between

SuburbsDistributions["FiretruckBROKEN"] = {

and

DriveCarsCMAX = 2000; -- default
(Don't delete that last line though).


Hope this helped! :)
Dabados 19 Feb, 2018 @ 9:24am 
big help:cherrypie::pillow:
< >
Showing 1-2 of 2 comments
Per page: 1530 50