This is the GoldSrc func_vehicle and func_vehicle_custom for CS1.6 and Sven Coop. This tutorial is written by seedee and mirrored and adapted by The303.
The front of your vehicle is always the X-axis in the editor and therefore should be created facing the X-axis, but 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.
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.
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 this entity in-game.
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.
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.
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/.
If you create your own folder to organize your scripts, you can try the following to go up a directory instead:
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.