getIdealSpawnAmount
Definition
-- @/lua/ge/extensions/gameplay/traffic.lua:67
local function getIdealSpawnAmount(amount, ignoreAdjust) -- gets the ideal amount of vehicles to spawn based on current world state
-- this could be improved
if not amount or amount < 0 then
amount = getAmountFromSettings()
end
local vehCount = 0
if not ignoreAdjust then
for _, veh in ipairs(getAllVehiclesByType()) do
if veh.isParked ~= 'true' and veh:getActive() then
vehCount = vehCount + 1
end
end
end
return amount - vehCount
end
Callers
@/lua/ge/extensions/career/modules/playerDriving.lua
if amount == 0 then -- auto amount
amount = gameplay_traffic.getIdealSpawnAmount()
end
if parkedAmount == 0 then -- auto amount
parkedAmount = clamp(gameplay_traffic.getIdealSpawnAmount(nil, true), 4, 20)
end
@/lua/ge/extensions/gameplay/traffic.lua
local amountFromSettings = getAmountFromSettings()
amount = getIdealSpawnAmount(amountFromSettings) -- maxAmount automatically accounts for currently spawned non-traffic vehicles
policeAmount = options.policeAmount or math.ceil(amount * policeRatio)
if options.autoAdjustAmount then
amount = getIdealSpawnAmount(amount) -- adjust for amount of existing active vehicles
end
@/lua/ge/extensions/flowgraph/nodes/gameplay/traffic/trafficSpawnGroup.lua
if newQuantity == 0 then newQuantity = -1 end
quantity = gameplay_traffic.getIdealSpawnAmount(newQuantity)
end
@/lua/ge/extensions/gameplay/parking.lua
if amount == 0 then -- auto amount
amount = clamp(gameplay_traffic.getIdealSpawnAmount(nil, true), 4, 16)
end