Hey, it’s been a while since I last posted. I’ve was poking around the JSON, thinking of creating a mod to expand the pool of pre-set vehicles that can spawn. I think I’ve got creating new vehicle templates figured out, along with how to determine what spawns at individual buildings, but what I haven’t figured out is, how do I modify the vehicles that spawn inside cities and on highways? I’m hoping it’s something simple, since I don’t think I’m quite up for delving into major code.
Couple spots in mapgenfunctions.cpp, IIRC.
Thanks! That got me on the right track to what I was looking for; the add_road_vehicles function defined in map.cpp (and called in the aforementioned mapgenfunctions.cpp) is what I was trying to find.
…oof. Looks like doing this requires more than a simple mod. Or, rather, a mod could be done, but it wouldn’t get any new vehicles to spawn in cities or rural highways. Guess I’ll have to get a copy of the source and poke around and figure out how to do a PR.
Nioca,
Have you had any luck poking at things? I had a few ideas for some new vehicles as well, but I can see the mess you referred to in the add_road_vehicles function.
None so far. Not so much because I’m baffled by the code (from the brief glances I’ve taken at it, it doesn’t look too bad, even with my very meagre C++ skills), but because I’m still battling with Git to even get a local repository going and sync’d up with the main repository.
Ahh. If it would help, I’ve taken a look at the code and have a pretty good idea of how to improve it so that it would be much easier to add new vehicles. The spawn information could be moved to json so no one would have to modify code to get their additions to show up on the roads. I could put that in so you could focus on the new cars bit =)
Seeing as using Git locally seems to be out-of-the-question, that would help immensely.
Also, I wouldn’t mind suggestions. Right now, I’m mostly focusing on real world vehicles that aren’t represented in-game, but would likely show up. Currently have 21 blueprints drawn up for it, although I haven’t gotten much of it committed to JSON just yet (and might have to revamp some of it due to vehicle part changes). Right now, I’m looking at adding Muscle Cars, Electric Sportscars, Limousines, Standard and Luxury SUVs, Monster Trucks, Minivans, Farm Tractors, Enclosed Tractors (with Electric Variant), Riding Lawnmowers, Food Trucks, Armored Vans, Transit Buses, Sport and Touring Motorcycles, Tricycles, Cycle and Solar Rickshaws, Electric Jacks, and Motorized Shopping Carts.
(I also had ideas for Prisoner Transports, BearCat-like APCs, Prison Buses, Motor Coaches, Hardened Engineer Vehicles, Internal Security Vehicles, Classic Cars, Hotrods, Military Jeeps, and Model-Ts. However, I put those on hold for various reasons [such as no reasonable place to spawn for HEVs and ISVs, not wanting to flood the game with a bunch of police variants, and needing to lay down some framework and spawn places for antique cars].)
DDAWorld is notably bereft of SUVs and minivans. Also civilian jeeps and big diesel-powered pickup trucks.
Just a thought for the vehicularly-minded.
If you put the files somewhere I can pr them for you(assuming its complete and does work).
I’m working on an update that will move the car spawn handling to json, so the code won’t have to be changed every time a new vehicle gets added.
Nioca, or anyone else who is interested really, you can now modify the city and road vehicle spawns through json without having to modify code. Depending on what you want to add, there are two ways to do this.
If you are just adding a new vehicle into the game and you want it to randomly show up on streets like the other cars do, all you need to do is modify the vehicle_groups.json. This json file works just like the item_groups.json. It contains groups of vehicles that are randomly chosen based on weight to be placed during map generation. “city_wrecks” and “city_parked” are the groups you will want to add vehicles to in order to get them to spawn on city roads. “highway” is the group that is used for selecting vehicles to place on country roads. Just add your new vehicle to the list and give it a weight number to control how often it is created compared to others in the list.
If you want to do something a bit more complicated, you can add new types of road spawns in the road_vehicles.json. Near the bottom of that file are the “default_city” and “default_country” entries that control what kind of vehicle spawn is used for each section of road and the proababilities for it. If you want a complex road spawn (like the jack-knifed semi) you might need to create a c++ function for it. For simpler ones you should be able to use the vehicle groups and vehicle placement entries.