|Abstract Coding series Discuss your thoughts - Help us develop the articles or ideas you want|
Levels & XP | Optimization | Procedural Textures | Sights & Sniperrifles | Special effects | Vehicles | Threads | Save Game Files | Night Vision | Non-offensive Weapons | Dynamic Weapon Spawns | Dynamic Weapon Spawns (Advanced)
This article is a stub. You can help by adding to it.
This article is meant to give an in-depth analysis of the vehicles in Source and to provide the necessary information to create and modify source vehicles.
- 1 In General
- 2 Vehicles Specifics
- 3 Player Interaction
- 4 Vehicles Components
- 5 Additional Help
- 6 External links
All vehicles, including the airboat, inherit from the same base classes:
At the end of the day, the typical source vehicle is made up of 3 parts:
- The main vehicle, inheriting from CPropVehicleDriveable.
- The "Server" Vehicle, inheriting from CBaseServerVehicle.
- The vehicle physics, CFourWheelVehiclePhysics.
This entity doesn't handle passengers or passengers entry, since the code the player used to ride vehicles needs a IServerVehicle. That's why there is a member pointer on a CFourWheelsServerVehicle stored in the instance.
This class's primary purpose is to handle passenger entry, and sound state, along with acting as a proxy between the Driveable Vehicle, and the physic vehicle. It uses data structures named operating, control, and vehicle params, to share information between the driveable and physics classes. Its other purpose is to trigger the loading of the vehicle script data on its creation, along with the creation of the physics vehicle object.
This class isn't an entity, it's mostly a wrapper between the driveable and server vehicle entities and the vehicle physics controller (IPhysicsVehicleController). It transmits data from the IPhysicsVehicleController object (that's in the physics DLL) through the
GetVehicleOperatingParams() method. It also transmits to the IPhysicsVehicleController the data in the control params (
This object is responsible for loading and parsing the physics vehicle data, through the
bool ParseVehicleScript( const char *pScriptName, solid_t &solid, vehicleparams_t &vehicle ) method.
Vehicle Data Structures
To do: Info on the data structures used to transmit physic data and controls data back and forth between the physic DLL and the server DLL. See "..\src\public\vphysics\vehicles.h" and "..\src\game\server\vehicle_sounds.h"
Vehicles types values
#define VEHICLE_TYPE_CAR_WHEELS (1<<0) #define VEHICLE_TYPE_CAR_RAYCAST (1<<1) #define VEHICLE_TYPE_JETSKI_RAYCAST (1<<2) #define VEHICLE_TYPE_AIRBOAT_RAYCAST (1<<3)
The Buggy and Jalopy
To do: Buggy and Jalopy specifics.
The airboat uses the same physical entity as the buggy CFourWheelVehiclePhysics. But it changes the vehicle type value to
To do: airboat specifics.
To do: describe what goes on when the player uses a vehicle.
- IClientVehicle - Client Side
- IVehicle - Vehicle Generalizations
- The Jurassic Rage coding team has released their multi-passenger vehicle code:
- Multipassenger Vehicle Abstract
- TheQuartz, creator of the Pilotable Strider Mod, has released the "Strider, Helicopter, and APC" source code:
Half-Life 2 SDK vehicles
- Some information on fixing source vehicle code for use in Multiplayer can be found here.
HL2DM vehicle fix
- A partial fix to make vehicles predicted and work in HL2DM can be found here.