5 #include "sv_vehicles.qh"
7 #include "cl_vehicles.qh"
12 const int VR_SETUP = 1; // (BOTH) setup vehicle data
13 const int VR_THINK = 2; // (SERVER) logic to run every frame
14 const int VR_DEATH = 3; // (SERVER) called when vehicle dies
15 const int VR_PRECACHE = 4; // (BOTH) precaches models/sounds used by this vehicle
16 const int VR_ENTER = 5; // (SERVER) called when a player enters this vehicle
17 const int VR_SPAWN = 6; // (SERVER) called when the vehicle re-spawns
18 const int VR_IMPACT = 7; // (SERVER) called when a vehicle hits something
19 const int VR_HUD = 8; // (CLIENT) logic to run every frame
21 // vehicle spawn flags (need them here for common registrations)
22 const int VHF_ISVEHICLE = 2; /// Indicates vehicle
23 const int VHF_HASSHIELD = 4; /// Vehicle has shileding
24 const int VHF_SHIELDREGEN = 8; /// Vehicles shield regenerates
25 const int VHF_HEALTHREGEN = 16; /// Vehicles health regenerates
26 const int VHF_ENERGYREGEN = 32; /// Vehicles energy regenerates
27 const int VHF_DEATHEJECT = 64; /// Vehicle ejects pilot upon fatal damage
28 const int VHF_MOVE_GROUND = 128; /// Vehicle moves on gound
29 const int VHF_MOVE_HOVER = 256; /// Vehicle hover close to gound
30 const int VHF_MOVE_FLY = 512; /// Vehicle is airborn
31 const int VHF_DMGSHAKE = 1024; /// Add random velocity each frame if health < 50%
32 const int VHF_DMGROLL = 2048; /// Add random angles each frame if health < 50%
33 const int VHF_DMGHEADROLL = 4096; /// Add random head angles each frame if health < 50%
34 const int VHF_MULTISLOT = 8192; /// Vehicle has multiple player slots
35 const int VHF_PLAYERSLOT = 16384; /// This ent is a player slot on a multi-person vehicle
38 entity get_vehicleinfo(float id);
44 // entity properties of vehicleinfo:
45 .int vehicleid; // VEH_...
46 .string netname; // short name
47 .string vehicle_name; // human readable name
48 .int(int) vehicle_func; // v_...
49 .string mdl; // currently a copy of the model
50 .string model; // full name of model
51 .string head_model; // full name of tur_head model
52 .string hud_model; // cockpit model
53 .string tag_head; // tur_head model tag
54 .string tag_hud; // hud model tag
55 .string tag_view; // cockpit model tag
56 .int() PlayerPhysplug; // player physics mod
58 .vector mins, maxs; // vehicle hitbox size
60 // other useful macros
61 #define VEH_ACTION(vehicletype,mrequest) (get_vehicleinfo(vehicletype)).vehicle_func(mrequest)
62 #define VEH_NAME(vehicletype) (get_vehicleinfo(vehicletype)).vehicle_name
64 // =====================
65 // Vehicle Registration
66 // =====================
68 void RegisterVehicles();
69 const int VEH_MAXCOUNT = 24;
70 entity vehicle_info[VEH_MAXCOUNT], vehicle_info_first, vehicle_info_last;
72 const int VEH_FIRST = 1;
73 #define VEH_LAST (VEH_FIRST + VEH_COUNT - 1)
74 /** If you register a new vehicle, make sure to add it to all.inc */
75 #define REGISTER_VEHICLE(id, class) REGISTER(RegisterVehicles, vehicle_info, vehicle_info, VEH_COUNT, id, m_id, NEW(class))
77 #define REGISTER_VEHICLE_SIMPLE(id,func,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname) \
80 REGISTER_VEHICLE(id, Vehicle) { \
81 VEH_##id = VEH_LAST; \
82 register_vehicle(this,VEH_##id,func,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname); \
84 REGISTER_INIT(vehicle_info, id)
85 REGISTER_REGISTRY(RegisterVehicles)
87 void register_vehicle(entity e, int id, int(int) func, float vehicleflags, vector min_s, vector max_s, string modelname, string headmodelname, string hudmodelname, string headtag, string hudtag, string viewtag, string shortname, string vname);
88 void register_vehicles_done();
92 ACCUMULATE_FUNCTION(RegisterVehicles, register_vehicles_done);