Ads keep us online. Without them, we wouldn't exist. We don't have paywalls or sell mods - we never will. But every month we have large bills and running ads is our only way to cover them. Please consider unblocking us. Thank you from GameBanana <3

func_vehicle - A Tutorial for Counter-Strike 1.6.

For Counter-Strike and Sven Co-op

This tutorial is now mirrored on!

1. Requisites

  • Game configuration file that supports vehicle entities such as this one
  • Understanding of 3D space and dimensions

2. Creating an origin for the vehicle

The game considers the front of the vehicle to face the negative X-axis in the editor, and therefore should be created with this in mind. You can change the in-game orientation of your vehicle later. The axes should be visible as red, blue, and green lines, where Z is up in the editor.

Create a brush textured with ORIGIN at the exact center of your vehicle on the X and Y-axes. This will let you properly determine the length and width of the vehicle's collision box. You can use the brush selection handles as a reference for where the center of your vehicle is. The brush doesn't have to be centered on the Z-axis.

3. Creating the vehicle entity

You must select all the brushes of your vehicle, including the ORIGIN brush, and assign them to a func_vehicle entity:

The vehicle controls need to target this entity, so set a unique name.
Name of the path_track entity the vehicle will spawn at in-game.
The dimension of the vehicle, in units, on the X-axis.
The dimension of the vehicle, in units, on the Y-axis.
This defines how many units the bottom of the ORIGIN brush is above ground. This is useful if your vehicle has wheels, is a boat, or a helicopter. While making the origin touch the ground and setting this to 0 will work, it is not an ideal solution due to the way vehicles collide with the world.
This defines how many degrees the vehicle tilts when turning. This is good for motorcycles.
Damage dealt to players who get run over or otherwise block the movement of the vehicle.
The speed of the vehicle, in units per second.
The velocity of the vehicle as soon as the level loads in-game. The vehicle will immediately decelerate to a stop.
The type of sound the engine. This must be an integer ranging from 1 to 7. You can find the vehicle sounds in ../cstrike/sound/plats/
The volume of the engine. This must be an integer ranging from 1 to 10.

4. Creating tracks for the vehicle

You must create two of these entities. The first path_track serves as a spawning point for the vehicle and therefore must be targeted by it. The first path_track must also target the second path_track. The second one must, in turn, target the first. The front of the vehicle will face the second path_track in-game.

4.1. Sven Co-op

Unlike in Counter-Strike, the second path_track used to change the vehicle's orientation should not target the first one, or else the vehicle flips on the wrong axis entirely.

5. Creating vehicle controls

Create a brush wherever you want and assign it to a func_vehiclecontrols entity. Make the vehicle controls target the vehicle and you will be able to drive it with E.

6. Sven Co-op scripting

The current version of Sven Co-op has a func_vehicle_custom Angelscript in ../svencoop/scripts/maps/. You must include it in your own map's script for it to work. Copy the following code and save it with the .as file extension to /svencoop/scripts/maps/.
#include "func_vehicle_custom"

void MapInit()
     VehicleMapInit( true, true );

If you create your own folder to organize your scripts, you can try the following to go up a directory instead:
#include "../func_vehicle_custom"

You must also create a configuration file for your map to run the script. Copy the following cvar and save it with the .cfg file extension to ../svencoop/maps/. The config file should have the same filename as your map.
map_script yourscript