From 7892e4aee4861fcc8191a3f0890293665b9c7abd Mon Sep 17 00:00:00 2001 From: terencehill Date: Fri, 2 Dec 2022 16:34:14 +0100 Subject: [PATCH] Correctly show particle fx and decal when a grenade stuck on the ceiling explodes (see 0889fb8c for a similar fix to electro orbs) --- qcsrc/common/weapons/weapon/electro.qc | 4 ++-- qcsrc/common/weapons/weapon/minelayer.qc | 2 +- qcsrc/common/weapons/weapon/mortar.qc | 8 ++++---- qcsrc/server/main.qh | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index e122077b3..97929c7dd 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -56,7 +56,7 @@ void W_Electro_ExplodeCombo(entity this) W_Electro_TriggerCombo(this.origin, WEP_CVAR(electro, combo_comboradius), this.realowner); this.event_damage = func_null; - this.velocity = this.movedir; // particle fx and decals need .velocity + this.velocity = this.movedir; // .velocity must be != '0 0 0' for particle fx and decal to work RadiusDamage( this, @@ -86,7 +86,7 @@ void W_Electro_Explode(entity this, entity directhitentity) this.event_damage = func_null; this.takedamage = DAMAGE_NO; - this.velocity = this.movedir; // particle fx and decals need .velocity + this.velocity = this.movedir; // .velocity must be != '0 0 0' for particle fx and decal to work if(this.move_movetype == MOVETYPE_BOUNCE || this.classname == "electro_orb") // TODO: classname is more reliable anyway? { diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index 9ab5533f1..b1ccb1b05 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -92,7 +92,7 @@ void W_MineLayer_DoRemoteExplode(entity this) this.takedamage = DAMAGE_NO; if(this.move_movetype == MOVETYPE_NONE || this.move_movetype == MOVETYPE_FOLLOW) - this.velocity = this.movedir; // particle fx and decals need .velocity + this.velocity = this.movedir; // .velocity must be != '0 0 0' for particle fx and decal to work RadiusDamage(this, this.realowner, WEP_CVAR(minelayer, remote_damage), WEP_CVAR(minelayer, remote_edgedamage), WEP_CVAR(minelayer, remote_radius), NULL, NULL, WEP_CVAR(minelayer, remote_force), this.projectiledeathtype | HITTYPE_BOUNCE, this.weaponentity_fld, NULL); diff --git a/qcsrc/common/weapons/weapon/mortar.qc b/qcsrc/common/weapons/weapon/mortar.qc index a1264748f..52b8a571a 100644 --- a/qcsrc/common/weapons/weapon/mortar.qc +++ b/qcsrc/common/weapons/weapon/mortar.qc @@ -15,7 +15,7 @@ void W_Mortar_Grenade_Explode(entity this, entity directhitentity) this.takedamage = DAMAGE_NO; if(this.move_movetype == MOVETYPE_NONE) - this.velocity = this.oldvelocity; + this.velocity = this.movedir; // .velocity must be != '0 0 0' for particle fx and decal to work RadiusDamage(this, this.realowner, WEP_CVAR_PRI(mortar, damage), WEP_CVAR_PRI(mortar, edgedamage), WEP_CVAR_PRI(mortar, radius), NULL, NULL, WEP_CVAR_PRI(mortar, force), this.projectiledeathtype, this.weaponentity_fld, directhitentity); @@ -40,7 +40,7 @@ void W_Mortar_Grenade_Explode2(entity this, entity directhitentity) this.takedamage = DAMAGE_NO; if(this.move_movetype == MOVETYPE_NONE) - this.velocity = this.oldvelocity; + this.velocity = this.movedir; // .velocity must be != '0 0 0' for particle fx and decal to work RadiusDamage(this, this.realowner, WEP_CVAR_SEC(mortar, damage), WEP_CVAR_SEC(mortar, edgedamage), WEP_CVAR_SEC(mortar, radius), NULL, NULL, WEP_CVAR_SEC(mortar, force), this.projectiledeathtype, this.weaponentity_fld, directhitentity); @@ -98,7 +98,7 @@ void W_Mortar_Grenade_Touch1(entity this, entity toucher) spamsound(this, CH_SHOTS, SND_GRENADE_STICK, VOL_BASE, ATTN_NORM); // let it stick whereever it is - this.oldvelocity = this.velocity; + this.movedir = this.velocity; // save to this temporary field, will be restored on explosion this.velocity = '0 0 0'; set_movetype(this, MOVETYPE_NONE); // also disables gravity this.gravity = 0; // nope, it does NOT! maybe a bug in CSQC code? TODO @@ -134,7 +134,7 @@ void W_Mortar_Grenade_Touch2(entity this, entity toucher) spamsound(this, CH_SHOTS, SND_GRENADE_STICK, VOL_BASE, ATTN_NORM); // let it stick whereever it is - this.oldvelocity = this.velocity; + this.movedir = this.velocity; // save to this temporary field, will be restored on explosion this.velocity = '0 0 0'; set_movetype(this, MOVETYPE_NONE); // also disables gravity this.gravity = 0; // nope, it does NOT! maybe a bug in CSQC code? TODO diff --git a/qcsrc/server/main.qh b/qcsrc/server/main.qh index 40e708e86..ed095ba48 100644 --- a/qcsrc/server/main.qh +++ b/qcsrc/server/main.qh @@ -35,7 +35,8 @@ float client_cefc_accumulatortime; float servertime, serverprevtime, serverframetime; -.vector oldvelocity; // for fall damage +// set in CreatureFrame_All for entities that can be damaged by fall (players) and contents (projectiles) +.vector oldvelocity; .float watersound_finished; -- 2.39.2