Merge branch 'master' into Mario/vaporizer_damage
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / all.qh
1 #ifndef VEHICLES_ALL_H
2 #define VEHICLES_ALL_H
3
4 #if defined(SVQC)
5         #include "sv_vehicles.qh"
6 #elif defined(CSQC)
7         #include "cl_vehicles.qh"
8 #endif
9
10
11 // vehicle requests
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
20
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
36
37 // functions:
38 entity get_vehicleinfo(float id);
39
40 // fields:
41 .entity tur_head;
42
43
44 // other useful macros
45 #define VEH_ACTION(vehicletype,mrequest) (get_vehicleinfo(vehicletype)).vehicle_func(mrequest)
46 #define VEH_NAME(vehicletype) (get_vehicleinfo(vehicletype)).vehicle_name
47
48 // =====================
49 //  Vehicle Registration
50 // =====================
51
52 void RegisterVehicles();
53 const int VEH_MAXCOUNT = 24;
54 entity vehicle_info[VEH_MAXCOUNT], vehicle_info_first, vehicle_info_last;
55 int VEH_COUNT;
56 const int VEH_FIRST = 1;
57 #define VEH_LAST (VEH_FIRST + VEH_COUNT - 1)
58 /** If you register a new vehicle, make sure to add it to all.inc */
59 #define REGISTER_VEHICLE(id, class) REGISTER(RegisterVehicles, VEH, vehicle_info, VEH_COUNT, id, vehicleid, NEW(class))
60 #include "vehicle.qh"
61 #define REGISTER_VEHICLE_SIMPLE(id, vehicleflags, min_s, max_s, modelname, headmodelname, hudmodelname, headtag, hudtag, viewtag, shortname, vname) \
62     REGISTER_VEHICLE(id, Vehicle) {         \
63         this.netname = shortname;           \
64         this.vehicle_name = vname;          \
65         this.mdl = modelname;               \
66         this.spawnflags = vehicleflags;     \
67         this.mins = min_s;                  \
68         this.maxs = max_s;                  \
69         this.model = modelname;             \
70         this.head_model = headmodelname;    \
71         this.hud_model = hudmodelname;      \
72         this.tag_head = headtag;            \
73         this.tag_hud = hudtag;              \
74         this.tag_view = viewtag;            \
75     }                                       \
76     REGISTER_INIT(VEH, id)
77 REGISTER_REGISTRY(RegisterVehicles)
78
79 REGISTER_VEHICLE(NULL, Vehicle);
80
81 #include "all.inc"
82
83 #endif