Guide to adding new content to CDDA for first time modders

Adding new vehicles

New vehicles can also be added in JSON. This is relatively straightforward, but nevertheless tricky to get correct.

Vehicles are stored in the files in data/json/vehicles/ . The JSON is mostly documented at https://github.com/CleverRaven/Cataclysm-DDA/blob/master/doc/VEHICLES_JSON.md so this is just highlights.

The JSON looks like this:

  {
    "id": "quad_bike",
    "type": "vehicle",
    "name": "Quad Bike",
    "blueprint": [
      [ "O O" ],
      [ "=#>" ],
      [ "O O" ]
    ],
    "parts": [
      { "x": 0, "y": 0, "parts": [ "frame_vertical_2", "saddle", "controls", "controls_electronic", "horn_car" ] },
      { "x": 1, "y": 0, "parts": [ "frame_cover","engine_vtwin", "alternator_motorbike", "battery_motorbike", "headlight", { "part": "tank_small", "fuel": "gasoline" }, "plating_steel" ] },
      { "x": -1, "y": 0, "parts": [ "frame_horizontal", "muffler", "trunk" ] },
      { "x": 1, "y": 1, "parts": [ "frame_horizontal", "wheel_motorbike_steerable" ] },
      { "x": 1, "y": -1, "parts": [ "frame_horizontal", "wheel_motorbike_steerable" ] },
      { "x": -1, "y": -1, "parts": [ "frame_horizontal", "wheel_motorbike" ] },
      { "x": -1, "y": 1, "parts": [ "frame_horizontal", "wheel_motorbike" ] }
    ],
    "items": [ { "x": -1, "y": 0, "chance": 10, "items": [ "helmet_motor" ] } ]
  }

The important bit is the "parts" list. Each object in the parts list consists of an X, Y co-ordinate pair and a list of vehicle_parts in the "parts" value. The X value increases to the right, the Y value increases to the bottom, and vehicle is assuming to be facing due east. Yes, I know the vehicle interaction menu has the vehicle facing due north, it’s completely confusing.

Each object in the main “parts” list is installed before the next object, and each vehicle_part in each object’s “parts” list is installed in left to right order. The game’s engine actually builds the vehicle, one part at a time, and will fail to load if you attempt an illegal installation. So you have to be sure that all your parts lists start with a frame, and that each frame after the first frame has a frame adjacent to it. Engines have to be installed before alternators, seats before seat belts, turret mounts before turret weapons, and so on.

There’s also an "items" list at the very end, which is a collection of item_groups that controls what items might randomly spawn with the vehicle.

Spawning Vehicles

New vehicles need to be added to a vehicle group in order to spawn in the game. The vehicle groups are stored in data/json/road_vehicles.json, data/json/vehicle_groups.json, and in the various location’s mapgen files in data/json/mapgen/ .

road_vehicles.json is really complicated, but vehicle_groups.json is just lists of vehicles and the weighted spawn chance.

1 Like