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_null(entity, int) { return false; }
50 bool v_new(entity, int);
52 CLASS(Vehicle, Object)
53 ATTRIB(Vehicle, vehicleid, int, 0)
55 ATTRIB(Vehicle, m_icon, string, string_null)
57 ATTRIB(Vehicle, netname, string, "")
58 /** human readable name */
59 ATTRIB(Vehicle, vehicle_name, string, "Vehicle")
61 ATTRIB(Vehicle, vehicle_func, bool(Vehicle, int), v_null)
62 /** full name of model */
63 ATTRIB(Vehicle, model, string, "")
64 /** currently a copy of the model */
65 ATTRIB(Vehicle, mdl, string, "")
66 /** full name of tur_head model */
67 ATTRIB(Vehicle, head_model, string, "")
69 ATTRIB(Vehicle, hud_model, string, "")
70 /** tur_head model tag */
71 ATTRIB(Vehicle, tag_head, string, string_null)
73 ATTRIB(Vehicle, tag_hud, string, string_null)
74 /** cockpit model tag */
75 ATTRIB(Vehicle, tag_view, string, string_null)
76 /** player physics mod */
77 ATTRIB(Vehicle, PlayerPhysplug, int(), func_null)
79 ATTRIB(Vehicle, spawnflags, int, 0)
80 /** vehicle hitbox size */
81 ATTRIB(Vehicle, mins, vector, '-0 -0 -0')
82 /** vehicle hitbox size */
83 ATTRIB(Vehicle, maxs, vector, '0 0 0')
86 bool v_new(Vehicle this, int req)
88 if (req == VR_SETUP) return this.vr_setup ? this.vr_setup(this) : false;
89 if (req == VR_THINK) return this.vr_think ? this.vr_think(this) : false;
90 if (req == VR_DEATH) return this.vr_death ? this.vr_death(this) : false;
91 if (req == VR_PRECACHE) return this.vr_precache ? this.vr_precache(this) : false;
92 if (req == VR_ENTER) return this.vr_enter ? this.vr_enter(this) : false;
93 if (req == VR_SPAWN) return this.vr_spawn ? this.vr_spawn(this) : false;
94 if (req == VR_IMPACT) return this.vr_impact ? this.vr_impact(this) : false;
95 if (req == VR_HUD) return this.vr_hud ? this.vr_hud(this) : false;