setupVehicles
Definition
-- @/lua/ge/extensions/gameplay/parking.lua:614
local function setupVehicles(amount, options) -- spawns and prepares simple parked vehicles
options = options or {}
if not options.ignoreDelete then
deleteVehicles() -- clear current parked vehicles
end
if not sites then
loadSites()
end
amount = amount or -1
if amount == -1 then
amount = settings.getValue("trafficParkedAmount")
if amount == 0 then -- auto amount
amount = clamp(gameplay_traffic.getIdealSpawnAmount(nil, true), 4, 16)
end
end
local group
if type(options.vehGroup) == "table" then
group = options.vehGroup
else
local params = {filters = {}}
params.allConfigs = true
params.filters.Type = {propparked = 1}
local region = getLevelRegion()
if region then
params.filters.Region = {[region] = 1, default = 1}
end
params.minPop = 0
group = core_multiSpawn.createGroup(amount, params)
end
if amount <= 0 or not group or not group[1] then
if amount <= 0 then
log("I", logTag, "Parked vehicle amount to spawn is zero, now ignoring parked cars")
else
log("I", logTag, "Parked vehicle group is empty!")
end
return false
end
local transforms
local psList = getRandomParkingSpots(options.pos, nil, nil, amount, {checkVehicles = true})
if psList[1] then
if psList[amount] then
transforms = {}
for _, ps in ipairs(psList) do
table.insert(transforms, {pos = ps.ps.pos, rot = ps.ps.rot})
end
end
else
if not options.ignoreParkingSpots then
log("I", logTag, "No parking spots found, now ignoring parked cars")
return false
end
end
core_multiSpawn.spawnGroup(group, amount, {name = "autoParking", mode = "roadBehind", gap = 50, customTransforms = transforms, instant = not worldLoaded,
ignoreAdjust = not worldLoaded, randomPaints = true})
return true
end
Callers
@/lua/ge/extensions/gameplay/traffic.lua
if settings.getValue('trafficParkedVehicles') then
spawnProcess.parkingSetup = gameplay_parking.setupVehicles() -- setup parked cars first, if applicable
else
@/lua/ge/extensions/freeroam/freeroam.lua
if loadParkedVehicles then
gameplay_parking.setupVehicles(parkedVehiclesAmount)
end
log('I', logTag, string.format('Now spawning parked vehicles only for freeroam mode (%s parked vehicles)', parkedVehiclesAmount))
gameplay_parking.setupVehicles(parkedVehiclesAmount)
end
@/lua/ge/extensions/career/modules/playerDriving.lua
-- if this would wait until player vehicle active, then the loading screen would fade out early...
gameplay_parking.setupVehicles(restrict and testTrafficAmounts.parkedCars or parkedAmount)
gameplay_traffic.setupTraffic(restrict and testTrafficAmounts.traffic + extraAmount or amount + extraAmount, 0, {policeAmount = policeAmount, simpleVehs = true, autoLoadFromFile = true})
@/lua/ge/extensions/tech/techCore.lua
gameplay_parking.setupVehicles(parkedAmount)
gameplay_traffic.setupTraffic(maxAmount, policeRatio)
@/lua/ge/extensions/editor/trafficDebug.lua
if parkingAmountChange[0] > 0 then
gameplay_parking.setupVehicles(parkingAmountChange[0], {ignoreDelete = true, ignoreParkingSpots = true})
elseif parkingAmountChange[0] < 0 then
@/lua/ge/extensions/core/multiSpawn.lua
local function setupVehicles(amount, shuffle, spawnMode, spawnGap) -- DEPRECATED, please use function spawnGroup instead
log('W', logTag, 'This function is deprecated, please use function: spawnGroup')
@/lua/ge/extensions/gameplay/missions/missionManager.lua
step.validParking = gameplay_parking.setupVehicles(trafficSetup.parkedAmount)
step.validTraffic = gameplay_traffic.setupTraffic(trafficSetup.amount, 0, options)