if(hud && !intermission)
if(hud == HUD_BUMBLEBEE_GUN)
CSQC_BUMBLE_GUN_HUD();
- else
- VEH_ACTION(hud, VR_HUD);
+ else {
+ Vehicle info = get_vehicleinfo(hud);
+ info.vr_hud(info);
+ }
cl_notice_run();
void RegisterVehicles();
const int VEH_MAXCOUNT = 24;
entity vehicle_info[VEH_MAXCOUNT], vehicle_info_first, vehicle_info_last;
+Vehicle get_vehicleinfo(int id);
int VEH_COUNT;
const int VEH_FIRST = 1;
#define VEH_LAST (VEH_FIRST + VEH_COUNT - 1)
{
AuxiliaryXhair[0].axh_image = vCROSS_BURST; // Plasma cannons
AuxiliaryXhair[1].axh_image = vCROSS_BURST; // Raygun
+ } else {
+ Vehicle info = get_vehicleinfo(hud_id);
+ info.vr_setup(info);
}
- else { VEH_ACTION(hud_id, VR_SETUP); }
}
void Vehicles_drawHUD(
antilag_clear(self);
- VEH_ACTION(self.vehicleid, VR_DEATH);
+ Vehicle info = get_vehicleinfo(self.vehicleid);
+ info.vr_death(info);
vehicles_setreturn(self);
}
}
return; // Dont do selfdamage when hitting "soft targets".
}
- if(self.play_time < time)
- VEH_ACTION(self.vehicleid, VR_IMPACT);
+ if(self.play_time < time) {
+ Vehicle info = get_vehicleinfo(self.vehicleid);
+ info.vr_impact(info);
+ }
return;
}
setself(veh);
CSQCModel_UnlinkEntity();
- VEH_ACTION(veh.vehicleid, VR_ENTER);
+ Vehicle info = get_vehicleinfo(veh.vehicleid);
+ info.vr_enter(info);
setself(this);
antilag_clear(pl);
if(self.owner)
self.owner.vehicle_weapon2mode = self.vehicle_weapon2mode;
- VEH_ACTION(self.vehicleid, VR_THINK);
+ Vehicle info = get_vehicleinfo(self.vehicleid);
+ info.vr_think(info);
CSQCMODEL_AUTOUPDATE(self);
}
vehicles_reset_colors();
- VEH_ACTION(self.vehicleid, VR_SPAWN);
+ Vehicle info = get_vehicleinfo(self.vehicleid);
+ info.vr_spawn(info);
CSQCMODEL_AUTOINIT(self);
}
if(!veh.vehicleid)
return false;
- if(!veh.tur_head) { VEH_ACTION(veh.vehicleid, VR_PRECACHE); }
+ if(!veh.tur_head) {
+ Vehicle info = get_vehicleinfo(veh.vehicleid);
+ info.vr_precache(info);
+ }
if(self.targetname && self.targetname != "")
{
self.pos2 = self.angles;
self.tur_head.team = self.team;
- VEH_ACTION(veh.vehicleid, VR_SETUP);
+ Vehicle info = get_vehicleinfo(veh.vehicleid);
+ info.vr_setup(info);
if(self.active == ACTIVE_NOT)
self.nextthink = 0; // wait until activated
#ifndef VEHICLE_H
#define VEHICLE_H
-// vehicle requests
-const int VR_SETUP = 1; // (BOTH) setup vehicle data
-.bool(entity) vr_setup;
-const int VR_THINK = 2; // (SERVER) logic to run every frame
-.bool(entity) vr_think;
-const int VR_DEATH = 3; // (SERVER) called when vehicle dies
-.bool(entity) vr_death;
-const int VR_PRECACHE = 4; // (BOTH) precaches models/sounds used by this vehicle
-.bool(entity) vr_precache;
-const int VR_ENTER = 5; // (SERVER) called when a player enters this vehicle
-.bool(entity) vr_enter;
-const int VR_SPAWN = 6; // (SERVER) called when the vehicle re-spawns
-.bool(entity) vr_spawn;
-const int VR_IMPACT = 7; // (SERVER) called when a vehicle hits something
-.bool(entity) vr_impact;
-const int VR_HUD = 8; // (CLIENT) logic to run every frame
-.bool(entity) vr_hud;
-
-// vehicle spawn flags (need them here for common registrations)
-const int VHF_ISVEHICLE = 2; /// Indicates vehicle
-const int VHF_HASSHIELD = 4; /// Vehicle has shileding
-const int VHF_SHIELDREGEN = 8; /// Vehicles shield regenerates
-const int VHF_HEALTHREGEN = 16; /// Vehicles health regenerates
-const int VHF_ENERGYREGEN = 32; /// Vehicles energy regenerates
-const int VHF_DEATHEJECT = 64; /// Vehicle ejects pilot upon fatal damage
-const int VHF_MOVE_GROUND = 128; /// Vehicle moves on gound
-const int VHF_MOVE_HOVER = 256; /// Vehicle hover close to gound
-const int VHF_MOVE_FLY = 512; /// Vehicle is airborn
-const int VHF_DMGSHAKE = 1024; /// Add random velocity each frame if health < 50%
-const int VHF_DMGROLL = 2048; /// Add random angles each frame if health < 50%
-const int VHF_DMGHEADROLL = 4096; /// Add random head angles each frame if health < 50%
-const int VHF_MULTISLOT = 8192; /// Vehicle has multiple player slots
-const int VHF_PLAYERSLOT = 16384; /// This ent is a player slot on a multi-person vehicle
-
-// functions:
-entity get_vehicleinfo(int id);
-
-// fields:
-.entity tur_head;
-
-// other useful macros
-#define _VEH_ACTION(veh, mrequest) veh.vehicle_func(veh, mrequest)
-#define VEH_ACTION(veh, mrequest) _VEH_ACTION(get_vehicleinfo(veh), mrequest)
-#define VEH_NAME(veh) (get_vehicleinfo(veh)).vehicle_name
-
-bool v_new(entity, int);
-
CLASS(Vehicle, Object)
ATTRIB(Vehicle, vehicleid, int, 0)
/** hud icon */
ATTRIB(Vehicle, netname, string, "")
/** human readable name */
ATTRIB(Vehicle, vehicle_name, string, "Vehicle")
- /** */
- ATTRIB(Vehicle, vehicle_func, bool(Vehicle, int), v_new)
/** full name of model */
ATTRIB(Vehicle, model, string, "")
/** currently a copy of the model */
ATTRIB(Vehicle, mins, vector, '-0 -0 -0')
/** vehicle hitbox size */
ATTRIB(Vehicle, maxs, vector, '0 0 0')
+
+ /** (BOTH) setup vehicle data */
+ METHOD(Vehicle, vr_setup, void(Vehicle)) { }
+ /** (SERVER) logic to run every frame */
+ METHOD(Vehicle, vr_think, void(Vehicle)) { }
+ /** (SERVER) called when vehicle dies */
+ METHOD(Vehicle, vr_death, void(Vehicle)) { }
+ /** (BOTH) precaches models/sounds used by this vehicle */
+ METHOD(Vehicle, vr_precache, void(Vehicle)) { }
+ /** (SERVER) called when a player enters this vehicle */
+ METHOD(Vehicle, vr_enter, void(Vehicle)) { }
+ /** (SERVER) called when the vehicle re-spawns */
+ METHOD(Vehicle, vr_spawn, void(Vehicle)) { }
+ /** (SERVER) called when a vehicle hits something */
+ METHOD(Vehicle, vr_impact, void(Vehicle)) { }
+ /** (CLIENT) logic to run every frame */
+ METHOD(Vehicle, vr_hud, void(Vehicle)) { }
ENDCLASS(Vehicle)
-bool v_new(Vehicle this, int req)
-{
- if (req == VR_SETUP) return this.vr_setup ? this.vr_setup(this) : false;
- if (req == VR_THINK) return this.vr_think ? this.vr_think(this) : false;
- if (req == VR_DEATH) return this.vr_death ? this.vr_death(this) : false;
- if (req == VR_PRECACHE) return this.vr_precache ? this.vr_precache(this) : false;
- if (req == VR_ENTER) return this.vr_enter ? this.vr_enter(this) : false;
- if (req == VR_SPAWN) return this.vr_spawn ? this.vr_spawn(this) : false;
- if (req == VR_IMPACT) return this.vr_impact ? this.vr_impact(this) : false;
- if (req == VR_HUD) return this.vr_hud ? this.vr_hud(this) : false;
- return false;
-}
+// vehicle spawn flags (need them here for common registrations)
+const int VHF_ISVEHICLE = 2; /// Indicates vehicle
+const int VHF_HASSHIELD = 4; /// Vehicle has shileding
+const int VHF_SHIELDREGEN = 8; /// Vehicles shield regenerates
+const int VHF_HEALTHREGEN = 16; /// Vehicles health regenerates
+const int VHF_ENERGYREGEN = 32; /// Vehicles energy regenerates
+const int VHF_DEATHEJECT = 64; /// Vehicle ejects pilot upon fatal damage
+const int VHF_MOVE_GROUND = 128; /// Vehicle moves on gound
+const int VHF_MOVE_HOVER = 256; /// Vehicle hover close to gound
+const int VHF_MOVE_FLY = 512; /// Vehicle is airborn
+const int VHF_DMGSHAKE = 1024; /// Add random velocity each frame if health < 50%
+const int VHF_DMGROLL = 2048; /// Add random angles each frame if health < 50%
+const int VHF_DMGHEADROLL = 4096; /// Add random head angles each frame if health < 50%
+const int VHF_MULTISLOT = 8192; /// Vehicle has multiple player slots
+const int VHF_PLAYERSLOT = 16384; /// This ent is a player slot on a multi-person vehicle
+
+// fields:
+.entity tur_head;
#endif
if(!vehicle_initialize(VEH_BUMBLEBEE, false)) { remove(self); return; }
}
- METHOD(Bumblebee, vr_impact, bool(Bumblebee thisveh))
+ METHOD(Bumblebee, vr_impact, void(Bumblebee thisveh))
{
if(autocvar_g_vehicle_bumblebee_bouncepain)
vehicles_impact(autocvar_g_vehicle_bumblebee_bouncepain_x, autocvar_g_vehicle_bumblebee_bouncepain_y, autocvar_g_vehicle_bumblebee_bouncepain_z);
-
- return true;
}
- METHOD(Bumblebee, vr_enter, bool(Bumblebee thisveh))
+ METHOD(Bumblebee, vr_enter, void(Bumblebee thisveh))
{
SELFPARAM();
self.touch = bumblebee_touch;
self.nextthink = 0;
self.movetype = MOVETYPE_BOUNCEMISSILE;
- return true;
}
- METHOD(Bumblebee, vr_think, bool(Bumblebee thisveh))
+ METHOD(Bumblebee, vr_think, void(Bumblebee thisveh))
{
SELFPARAM();
self.angles_z *= 0.8;
self.phase = 0;
self.touch();
other = oldother;
- return true;
+ return;
}
if(self.gunner2)
self.phase = 0;
self.touch();
other = oldother;
- return true;
+ return;
}
}
-
- return true;
}
- METHOD(Bumblebee, vr_death, bool(Bumblebee thisveh))
+ METHOD(Bumblebee, vr_death, void(Bumblebee thisveh))
{
SELFPARAM();
entity oldself = self;
self.nextthink = 0;
setorigin(self, self.pos1);
- return true;
}
- METHOD(Bumblebee, vr_spawn, bool(Bumblebee thisveh))
+ METHOD(Bumblebee, vr_spawn, void(Bumblebee thisveh))
{
SELFPARAM();
if(!self.gun1)
self.PlayerPhysplug = bumblebee_pilot_frame;
setorigin(self, self.origin + '0 0 25');
- return true;
}
- METHOD(Bumblebee, vr_setup, bool(Bumblebee thisveh))
+ METHOD(Bumblebee, vr_setup, void(Bumblebee thisveh))
{
SELFPARAM();
if(autocvar_g_vehicle_bumblebee_energy)
self.vehicle_health = autocvar_g_vehicle_bumblebee_health;
self.max_health = self.vehicle_health;
self.vehicle_shield = autocvar_g_vehicle_bumblebee_shield;
-
- return true;
- }
- METHOD(Bumblebee, vr_precache, bool(Bumblebee thisveh))
- {
- return true;
}
#endif // SVQC
string_null);
}
- METHOD(Bumblebee, vr_hud, bool(Bumblebee thisveh))
+ METHOD(Bumblebee, vr_hud, void(Bumblebee thisveh))
{
Vehicles_drawHUD(VEH_BUMBLEBEE.m_icon, "vehicle_bumble_weapon1", "vehicle_bumble_weapon2",
"vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
"vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
vCROSS_HEAL);
- return true;
}
- METHOD(Bumblebee, vr_setup, bool(Bumblebee thisveh))
+ METHOD(Bumblebee, vr_setup, void(Bumblebee thisveh))
{
AuxiliaryXhair[0].axh_image = vCROSS_LOCK; // Raygun-locked
AuxiliaryXhair[1].axh_image = vCROSS_BURST; // Gunner1
AuxiliaryXhair[2].axh_image = vCROSS_BURST; // Gunner2
- return true;
- }
- METHOD(Bumblebee, vr_precache, bool(Bumblebee thisveh))
- {
- return true;
}
#endif
#endif
#endif
- METHOD(Racer, vr_impact, bool(Racer thisveh))
+ METHOD(Racer, vr_impact, void(Racer thisveh))
{
#ifdef SVQC
if(autocvar_g_vehicle_racer_bouncepain)
vehicles_impact(autocvar_g_vehicle_racer_bouncepain_x, autocvar_g_vehicle_racer_bouncepain_y, autocvar_g_vehicle_racer_bouncepain_z);
#endif
- return true;
}
- METHOD(Racer, vr_enter, bool(Racer thisveh))
+ METHOD(Racer, vr_enter, void(Racer thisveh))
{
#ifdef SVQC
self.movetype = MOVETYPE_BOUNCE;
self.move_movetype = MOVETYPE_BOUNCE;
#endif
-
- return true;
}
- METHOD(Racer, vr_spawn, bool(Racer thisveh))
+ METHOD(Racer, vr_spawn, void(Racer thisveh))
{
#ifdef SVQC
if(self.scale != 0.5)
self.vehicle_health = autocvar_g_vehicle_racer_health;
self.vehicle_shield = autocvar_g_vehicle_racer_shield;
#endif
- return true;
}
- METHOD(Racer, vr_death, bool(Racer thisveh))
+ METHOD(Racer, vr_death, void(Racer thisveh))
{
#ifdef SVQC
self.SendEntity = func_null; // stop networking this racer (for now)
self.think = racer_blowup_think;
self.nextthink = time;
#endif
- return true;
}
#ifdef CSQC
- METHOD(Racer, vr_hud, bool(Racer thisveh))
+ METHOD(Racer, vr_hud, void(Racer thisveh))
{
Vehicles_drawHUD(VEH_RACER.m_icon, "vehicle_racer_weapon1", "vehicle_racer_weapon2",
"vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
"vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color,
vCROSS_GUIDE);
- return true;
}
#endif
- METHOD(Racer, vr_setup, bool(Racer thisveh))
+ METHOD(Racer, vr_setup, void(Racer thisveh))
{
#ifdef SVQC
self.vehicle_exit = racer_exit;
#ifdef CSQC
AuxiliaryXhair[0].axh_image = vCROSS_LOCK; // Rocket
#endif
- return true;
}
- METHOD(Racer, vr_precache, bool(Racer thisveh))
- {
- return true;
- }
-
-#endif // REGISTER_VEHICLE
+#endif
if(!vehicle_initialize(VEH_RAPTOR, false)) { remove(self); return; }
}
- METHOD(Raptor, vr_impact, bool(Raptor thisveh))
+ METHOD(Raptor, vr_impact, void(Raptor thisveh))
{
if(autocvar_g_vehicle_raptor_bouncepain)
vehicles_impact(autocvar_g_vehicle_raptor_bouncepain_x, autocvar_g_vehicle_raptor_bouncepain_y, autocvar_g_vehicle_raptor_bouncepain_z);
-
- return true;
}
- METHOD(Raptor, vr_enter, bool(Raptor thisveh))
+ METHOD(Raptor, vr_enter, void(Raptor thisveh))
{
self.vehicle_weapon2mode = RSM_BOMB;
self.owner.PlayerPhysplug = raptor_takeoff;
setorigin(self.owner.flagcarried, '-20 0 96');
CSQCVehicleSetup(self.owner, 0);
- return true;
- }
- METHOD(Raptor, vr_think, bool(Raptor thisveh))
- {
- return true;
}
- METHOD(Raptor, vr_death, bool(Raptor thisveh))
+ METHOD(Raptor, vr_death, void(Raptor thisveh))
{
self.health = 0;
self.event_damage = func_null;
self.colormod = '-0.5 -0.5 -0.5';
self.touch = raptor_blowup;
- return true;
}
- METHOD(Raptor, vr_spawn, bool(Raptor thisveh))
+ METHOD(Raptor, vr_spawn, void(Raptor thisveh))
{
if(!self.gun1)
{
self.damageforcescale = 0.25;
self.vehicle_health = autocvar_g_vehicle_raptor_health;
self.vehicle_shield = autocvar_g_vehicle_raptor_shield;
- return true;
}
- METHOD(Raptor, vr_setup, bool(Raptor thisveh))
+ METHOD(Raptor, vr_setup, void(Raptor thisveh))
{
if(autocvar_g_vehicle_raptor_shield)
self.vehicle_flags |= VHF_HASSHIELD;
self.vehicle_health = autocvar_g_vehicle_raptor_health;
self.vehicle_shield = autocvar_g_vehicle_raptor_shield;
self.max_health = self.vehicle_health;
-
- return true;
- }
- METHOD(Raptor, vr_precache, bool(Raptor thisveh))
- {
- return true;
}
-#endif // SVQC
+#endif
#ifdef CSQC
- METHOD(Raptor, vr_hud, bool(Raptor thisveh))
+ METHOD(Raptor, vr_hud, void(Raptor thisveh))
{
string crosshair;
"vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
"vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color,
crosshair);
- return true;
}
- METHOD(Raptor, vr_setup, bool(Raptor thisveh))
+ METHOD(Raptor, vr_setup, void(Raptor thisveh))
{
AuxiliaryXhair[1].axh_image = vCROSS_LOCK;
- return true;
- }
- METHOD(Raptor, vr_precache, bool(Raptor thisveh))
- {
- return true;
}
-#endif // CSQC
-#endif // REGISTER_VEHICLE
+#endif
+#endif
if(!vehicle_initialize(VEH_SPIDERBOT, false)) { remove(self); return; }
}
- METHOD(Spiderbot, vr_impact, bool(Spiderbot thisveh))
+ METHOD(Spiderbot, vr_impact, void(Spiderbot thisveh))
{
if(autocvar_g_vehicle_spiderbot_bouncepain)
vehicles_impact(autocvar_g_vehicle_spiderbot_bouncepain_x, autocvar_g_vehicle_spiderbot_bouncepain_y, autocvar_g_vehicle_spiderbot_bouncepain_z);
-
- return true;
}
- METHOD(Spiderbot, vr_enter, bool(Spiderbot thisveh))
+ METHOD(Spiderbot, vr_enter, void(Spiderbot thisveh))
{
self.vehicle_weapon2mode = SBRM_GUIDE;
self.movetype = MOVETYPE_WALK;
setattachment(self.owner.flagcarried, self.tur_head, "");
setorigin(self.owner.flagcarried, '-20 0 120');
}
-
- return true;
}
- METHOD(Spiderbot, vr_think, bool(Spiderbot thisveh))
+ METHOD(Spiderbot, vr_think, void(Spiderbot thisveh))
{
if(self.flags & FL_ONGROUND)
movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
-
- return true;
}
- METHOD(Spiderbot, vr_death, bool(Spiderbot thisveh))
+ METHOD(Spiderbot, vr_death, void(Spiderbot thisveh))
{
self.health = 0;
self.event_damage = func_null;
self.movetype = MOVETYPE_TOSS;
CSQCModel_UnlinkEntity(); // networking the death scene would be a nightmare
-
- return true;
}
- METHOD(Spiderbot, vr_spawn, bool(Spiderbot thisveh))
+ METHOD(Spiderbot, vr_spawn, void(Spiderbot thisveh))
{
if(!self.gun1)
{
self.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
self.PlayerPhysplug = spiderbot_frame;
-
- return true;
}
- METHOD(Spiderbot, vr_setup, bool(Spiderbot thisveh))
+ METHOD(Spiderbot, vr_setup, void(Spiderbot thisveh))
{
if(autocvar_g_vehicle_spiderbot_shield)
self.vehicle_flags |= VHF_HASSHIELD;
self.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
self.max_health = self.vehicle_health;
self.pushable = true; // spiderbot can use jumppads
-
- return true;
- }
- METHOD(Spiderbot, vr_precache, bool(Spiderbot thisveh))
- {
- return true;
}
#endif // SVQC
float autocvar_cl_vehicle_spiderbot_cross_alpha = 0.6;
float autocvar_cl_vehicle_spiderbot_cross_size = 1;
- METHOD(Spiderbot, vr_hud, bool(Spiderbot thisveh))
+ METHOD(Spiderbot, vr_hud, void(Spiderbot thisveh))
{
string crosshair;
"vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
"vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color,
crosshair);
- return true;
}
- METHOD(Spiderbot, vr_setup, bool(Spiderbot thisveh))
+ METHOD(Spiderbot, vr_setup, void(Spiderbot thisveh))
{
AuxiliaryXhair[0].axh_image = vCROSS_HINT; // Minigun1
AuxiliaryXhair[1].axh_image = vCROSS_HINT; // Minigun2
-
- return true;
- }
- METHOD(Spiderbot, vr_precache, bool(Spiderbot thisveh))
- {
- return true;
}
-#endif // CSQC
-#endif // REGISTER_VEHICLE
+#endif
+#endif