4 #include "sv_vehicles.qh"
7 const int VR_SETUP = 1; // (BOTH) setup vehicle data
8 const int VR_THINK = 2; // (SERVER) logic to run every frame
9 const int VR_DEATH = 3; // (SERVER) called when vehicle dies
10 const int VR_PRECACHE = 4; // (BOTH) precaches models/sounds used by this vehicle
11 const int VR_ENTER = 5; // (SERVER) called when a player enters this vehicle
12 const int VR_SPAWN = 6; // (SERVER) called when the vehicle re-spawns
13 const int VR_IMPACT = 7; // (SERVER) called when a vehicle hits something
14 const int VR_HUD = 8; // (CLIENT) logic to run every frame
16 // vehicle spawn flags (need them here for common registrations)
17 const int VHF_ISVEHICLE = 2; /// Indicates vehicle
18 const int VHF_HASSHIELD = 4; /// Vehicle has shileding
19 const int VHF_SHIELDREGEN = 8; /// Vehicles shield regenerates
20 const int VHF_HEALTHREGEN = 16; /// Vehicles health regenerates
21 const int VHF_ENERGYREGEN = 32; /// Vehicles energy regenerates
22 const int VHF_DEATHEJECT = 64; /// Vehicle ejects pilot upon fatal damage
23 const int VHF_MOVE_GROUND = 128; /// Vehicle moves on gound
24 const int VHF_MOVE_HOVER = 256; /// Vehicle hover close to gound
25 const int VHF_MOVE_FLY = 512; /// Vehicle is airborn
26 const int VHF_DMGSHAKE = 1024; /// Add random velocity each frame if health < 50%
27 const int VHF_DMGROLL = 2048; /// Add random angles each frame if health < 50%
28 const int VHF_DMGHEADROLL = 4096; /// Add random head angles each frame if health < 50%
29 const int VHF_MULTISLOT = 8192; /// Vehicle has multiple player slots
30 const int VHF_PLAYERSLOT = 16384; /// This ent is a player slot on a multi-person vehicle
33 entity get_vehicleinfo(float id);
39 // entity properties of vehicleinfo:
40 .int vehicleid; // VEH_...
41 .string netname; // short name
42 .string vehicle_name; // human readable name
43 .int(int) vehicle_func; // v_...
44 .string mdl; // currently a copy of the model
45 .string model; // full name of model
46 .string head_model; // full name of tur_head model
47 .string hud_model; // cockpit model
48 .string tag_head; // tur_head model tag
49 .string tag_hud; // hud model tag
50 .string tag_view; // cockpit model tag
51 .int() PlayerPhysplug; // player physics mod
53 .vector mins, maxs; // vehicle hitbox size
55 // other useful macros
56 #define VEH_ACTION(vehicletype,mrequest) (get_vehicleinfo(vehicletype)).vehicle_func(mrequest)
57 #define VEH_NAME(vehicletype) (get_vehicleinfo(vehicletype)).vehicle_name
59 // =====================
60 // Vehicle Registration
61 // =====================
63 int v_null(int dummy);
64 void register_vehicle(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);
65 void register_vehicles_done();
67 const int VEH_MAXCOUNT = 24;
72 #define REGISTER_VEHICLE_2(id,func,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname) \
75 void RegisterVehicles_##id() \
77 VEH_LAST = (id = VEH_FIRST + VEH_COUNT); \
79 register_vehicle(id,func,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname); \
81 ACCUMULATE_FUNCTION(RegisterVehicles, RegisterVehicles_##id)
83 #define REGISTER_VEHICLE(id,func,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname) \
84 REGISTER_VEHICLE_2(VEH_##id,v_null,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname)
86 #define REGISTER_VEHICLE(id,func,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname) \
87 REGISTER_VEHICLE_2(VEH_##id,func,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname)
90 #include "unit/all.qh"
92 #undef REGISTER_VEHICLE
93 ACCUMULATE_FUNCTION(RegisterVehicles, register_vehicles_done);