From 65622d886158c7623d0cc22b4a748f84904b6e9d Mon Sep 17 00:00:00 2001 From: LegendaryGuard Date: Sat, 20 Aug 2022 23:06:26 +0200 Subject: [PATCH] Enhance some functions for vehicles --- qcsrc/common/vehicles/sv_vehicles.qc | 48 +++++++++++++++++++++---- qcsrc/common/vehicles/sv_vehicles.qh | 2 ++ qcsrc/common/vehicles/vehicle/raptor.qc | 1 + 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc index 752391030e..c96595533a 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qc +++ b/qcsrc/common/vehicles/sv_vehicles.qc @@ -374,6 +374,35 @@ vector vehicle_aimturret(entity _vehic, vector _target, entity _turrret, string return vtag; } +void vehicles_remove(entity this) +{ + Vehicle info = this.vehicledef; //REGISTRY_GET(Vehicles, this.vehicleid); + info.vr_death(info, this); + + // to avoid weird entity assignments to other stuff like projectiles + this.active = ACTIVE_NOT; + vehicles_reset(this); + this.classname = ""; + + this.tur_head.exteriormodeltoclient = NULL; + + CSQCModel_UnlinkEntity(this); + + delete(this.wp00); + delete(this.gun1); + delete(this.gun2); + delete(this.gun3); + delete(this.gunner1); + delete(this.gunner2); + delete(this.vehicle_viewport); + delete(this.vehicle_controller); + delete(this.vehicle_shieldent); + delete(this.vehicle_hudmodel); + delete(this.tur_head); + delete(this.vehicle); + delete(this); +} + void vehicles_reset_colors(entity this, entity player) { int eff = 0, cmap; @@ -521,12 +550,19 @@ void vehicles_setreturn(entity veh) { if (veh.cannot_respawn) { + RadiusDamage (veh, veh.enemy, 250, 15, 250, NULL, NULL, 250, DEATH_VH_CRUSH.m_id, DMG_NOWEP, NULL); sound (veh, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM); Send_Effect(EFFECT_EXPLOSION_BIG, veh.origin + '0 0 100', '0 0 0', 1); tmp_vehcount--; - delete(veh); + vehicles_clearreturn(ret); + + antilag_clear(veh, veh); + + vehicles_remove(veh); + delete(ret); + return; } ret.cnt = time + veh.respawntime; @@ -1117,13 +1153,11 @@ void vehicles_think(entity this) Send_Effect(EFFECT_TELEPORT, this.origin + '0 0 100', '0 0 0', 1); tmp_vehcount--; + + antilag_clear(this, this); + + vehicles_remove(this); - // to avoid weird entity assignments to other stuff like projectiles - delete(this.vehicle_shieldent); - delete(this.vehicle_hudmodel); - delete(this.tur_head); - delete(this.vehicle); - delete(this); return; } diff --git a/qcsrc/common/vehicles/sv_vehicles.qh b/qcsrc/common/vehicles/sv_vehicles.qh index b59550fa7d..1a0d6b5600 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qh +++ b/qcsrc/common/vehicles/sv_vehicles.qh @@ -117,6 +117,8 @@ bool vehicle_initialize(entity this, Vehicle info, float nodrop); bool vehicle_impulse(entity this, int imp); bool vehicles_crushable(entity e); void vehicles_enter(entity pl, entity veh); +void vehicles_reset(entity this); +void vehicles_remove(entity this); IntrusiveList g_vehicle_returners; STATIC_INIT(g_vehicle_returners) { g_vehicle_returners = IL_NEW(); } diff --git a/qcsrc/common/vehicles/vehicle/raptor.qc b/qcsrc/common/vehicles/vehicle/raptor.qc index da2c1da0be..35588bcd8e 100644 --- a/qcsrc/common/vehicles/vehicle/raptor.qc +++ b/qcsrc/common/vehicles/vehicle/raptor.qc @@ -615,6 +615,7 @@ METHOD(Raptor, vr_enter, void(Raptor thisveh, entity instance)) } METHOD(Raptor, vr_death, void(Raptor thisveh, entity instance)) { + CSQCModel_UnlinkEntity(instance); // networking the death scene would be a nightmare SetResourceExplicit(instance, RES_HEALTH, 0); instance.event_damage = func_null; instance.solid = SOLID_CORPSE; -- 2.39.2