5 const int VR_SETUP = 1; // (BOTH) setup vehicle data
6 .bool(entity) vr_setup;
7 const int VR_THINK = 2; // (SERVER) logic to run every frame
8 .bool(entity) vr_think;
9 const int VR_DEATH = 3; // (SERVER) called when vehicle dies
10 .bool(entity) vr_death;
11 const int VR_PRECACHE = 4; // (BOTH) precaches models/sounds used by this vehicle
12 .bool(entity) vr_precache;
13 const int VR_ENTER = 5; // (SERVER) called when a player enters this vehicle
14 .bool(entity) vr_enter;
15 const int VR_SPAWN = 6; // (SERVER) called when the vehicle re-spawns
16 .bool(entity) vr_spawn;
17 const int VR_IMPACT = 7; // (SERVER) called when a vehicle hits something
18 .bool(entity) vr_impact;
19 const int VR_HUD = 8; // (CLIENT) logic to run every frame
22 // vehicle spawn flags (need them here for common registrations)
23 const int VHF_ISVEHICLE = 2; /// Indicates vehicle
24 const int VHF_HASSHIELD = 4; /// Vehicle has shileding
25 const int VHF_SHIELDREGEN = 8; /// Vehicles shield regenerates
26 const int VHF_HEALTHREGEN = 16; /// Vehicles health regenerates
27 const int VHF_ENERGYREGEN = 32; /// Vehicles energy regenerates
28 const int VHF_DEATHEJECT = 64; /// Vehicle ejects pilot upon fatal damage
29 const int VHF_MOVE_GROUND = 128; /// Vehicle moves on gound
30 const int VHF_MOVE_HOVER = 256; /// Vehicle hover close to gound
31 const int VHF_MOVE_FLY = 512; /// Vehicle is airborn
32 const int VHF_DMGSHAKE = 1024; /// Add random velocity each frame if health < 50%
33 const int VHF_DMGROLL = 2048; /// Add random angles each frame if health < 50%
34 const int VHF_DMGHEADROLL = 4096; /// Add random head angles each frame if health < 50%
35 const int VHF_MULTISLOT = 8192; /// Vehicle has multiple player slots
36 const int VHF_PLAYERSLOT = 16384; /// This ent is a player slot on a multi-person vehicle
39 entity get_vehicleinfo(int id);
44 // other useful macros
45 #define _VEH_ACTION(veh, mrequest) veh.vehicle_func(veh, mrequest)
46 #define VEH_ACTION(veh, mrequest) _VEH_ACTION(get_vehicleinfo(veh), mrequest)
47 #define VEH_NAME(veh) (get_vehicleinfo(veh)).vehicle_name
49 bool v_new(entity, int);
51 CLASS(Vehicle, Object)
52 ATTRIB(Vehicle, vehicleid, int, 0)
54 ATTRIB(Vehicle, m_icon, string, string_null)
56 ATTRIB(Vehicle, netname, string, "")
57 /** human readable name */
58 ATTRIB(Vehicle, vehicle_name, string, "Vehicle")
60 ATTRIB(Vehicle, vehicle_func, bool(Vehicle, int), v_new)
61 /** full name of model */
62 ATTRIB(Vehicle, model, string, "")
63 /** currently a copy of the model */
64 ATTRIB(Vehicle, mdl, string, "")
65 /** full name of tur_head model */
66 ATTRIB(Vehicle, head_model, string, "")
68 ATTRIB(Vehicle, hud_model, string, "")
69 /** tur_head model tag */
70 ATTRIB(Vehicle, tag_head, string, string_null)
72 ATTRIB(Vehicle, tag_hud, string, string_null)
73 /** cockpit model tag */
74 ATTRIB(Vehicle, tag_view, string, string_null)
75 /** player physics mod */
76 ATTRIB(Vehicle, PlayerPhysplug, int(), func_null)
78 ATTRIB(Vehicle, spawnflags, int, 0)
79 /** vehicle hitbox size */
80 ATTRIB(Vehicle, mins, vector, '-0 -0 -0')
81 /** vehicle hitbox size */
82 ATTRIB(Vehicle, maxs, vector, '0 0 0')
85 bool v_new(Vehicle this, int req)
87 if (req == VR_SETUP) return this.vr_setup ? this.vr_setup(this) : false;
88 if (req == VR_THINK) return this.vr_think ? this.vr_think(this) : false;
89 if (req == VR_DEATH) return this.vr_death ? this.vr_death(this) : false;
90 if (req == VR_PRECACHE) return this.vr_precache ? this.vr_precache(this) : false;
91 if (req == VR_ENTER) return this.vr_enter ? this.vr_enter(this) : false;
92 if (req == VR_SPAWN) return this.vr_spawn ? this.vr_spawn(this) : false;
93 if (req == VR_IMPACT) return this.vr_impact ? this.vr_impact(this) : false;
94 if (req == VR_HUD) return this.vr_hud ? this.vr_hud(this) : false;