The paint distribution system is used to generate a realistic distribution of paint colors among traffic vehicles. In the future, this system is planned to be also used for the various random vehicle spawning systems in career mode, such as race opponents and dealership inventory.
In the main info.json
file of vehicles that are meant to be used for traffic, we add some new properties:
"defaultRandomPaintProbability": 1,
"defaultRandomMultiPaintProbability": 1,
"randomPaintDistribution":{
"white":5,
"silver":4,
"gray":1,
"black":4,
"Old White":4,
"Pearl Black":4,
"Old Black":4,
"Metallic Blue":4,
"Dark Blue":3,
"Blue Silver":3,
"Teal":3,
},
"randomMultiPaintDistribution":{
"team_offroad_colors":10,
"rennspecht_green_colors":1,
},
This adds weights to the random paint selection function used for traffic cars. defaultRandomPaintProbability
is the default weight applied to each available paint. Then in the randomPaintDistribution
list, certain paints have their weights overwritten in order to make them more or less likely to spawn in traffic. The same concept applies to defaultRandomMultiPaintProbability
and randomMultiPaintDistribution
.
Individual configurations can use the same properties. They will overwrite the ones declared in the main info.json file. New paint weights can be added, and individual existing ones can be replaced, but other weights will be inherited from the main info.json file. For example, you can make a single configuration 10 times more likely to spawn in a certain color by overwriting the weight for this color in its info file.
Additionally, configuration info files can use a new ignoreModelRandomPaintDistribution
property. If set to true, this will replace the whole randomPaintDistribution
list for this specific configuration. You can use it to restrict certain colors from being used on certain configurations. There is an equivalent ignoreModelRandomMultiPaintDistribution
option for multi-paint setup
as well.
Manually verifying weighted paint distribution can be troublesome, so a console command is available for automated testing:
core_vehiclePaints.testRandomPaint('model', 'config', #samples)
The parameters are the vehicle’s internal model name, its config name (can be set to nil to test all the configs on the vehicle), and the number of samples to test. The console will emulate spawning the set amount of vehicles/configs (without actually physically spawning them) and list the repeating paints. Each one will be listed with number spawned, percentage, type (paint or multi-paint setup), and the paint names used on all three color palettes.
Example 1: 1000 paints for simple_traffic model
core_vehiclePaints.testRandomPaint(‘simple_traffic’, nil, 1000)
Example 2: 1000 paints for simple_traffic model with the van_delivery config
core_vehiclePaints.testRandomPaint(‘simple_traffic’, ‘van_delivery’, 1000)
Was this article helpful?