]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/effects/qc/damageeffects.qc
Optimize damageeffects code: when a hitscan weapon hits a surface avoid executing...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / effects / qc / damageeffects.qc
index 20a335b6b8aac92dab451125497cabc9cec43d68..cb58a055c5dfcf2328479fcdc0ef13ce300c2452 100644 (file)
@@ -18,7 +18,7 @@ bool Damage_DamageInfo_SendEntity(entity this, entity to, int sf)
        return true;
 }
 
-void Damage_DamageInfo(vector org, float coredamage, float edgedamage, float rad, vector force, int deathtype, float bloodtype, entity dmgowner)
+void Damage_DamageInfo(vector org, bool is_solid_hit, float coredamage, float edgedamage, float rad, vector force, int deathtype, float bloodtype, entity dmgowner)
 {
        // TODO maybe call this from non-edgedamage too?
        // TODO maybe make the client do the particle effects for the weapons and the impact sounds using this info?
@@ -39,6 +39,8 @@ void Damage_DamageInfo(vector org, float coredamage, float edgedamage, float rad
        e.dmg_force = vlen(force);
        e.velocity = force;
        e.species = bloodtype;
+       if(is_solid_hit)
+               e.species |= 0x80;
 
        Net_LinkEntity(e, false, 0.2, Damage_DamageInfo_SendEntity);
 }
@@ -193,6 +195,8 @@ NET_HANDLE(ENT_CLIENT_DAMAGEINFO, bool isNew)
        edge = ReadByte();
        force = ReadVector();
        species = ReadByte();
+       bool is_solid_hit = (species & 0x80);
+       species = (species & 0x7F);
 
        return = true;
 
@@ -396,11 +400,16 @@ NET_HANDLE(ENT_CLIENT_DAMAGEINFO, bool isNew)
                w_random = prandom();
 
                vector force_dir = normalize(force);
-               traceline(w_org - force_dir * 16, w_org + force_dir * 16, MOVE_NOMONSTERS, NULL);
-               if(trace_fraction < 1 && !(hitwep.spawnflags & WEP_TYPE_HITSCAN))
-                       w_backoff = trace_plane_normal;
-               else
+               if (is_solid_hit) // traceline not needed
                        w_backoff = -force_dir;
+               else
+               {
+                       traceline(w_org - force_dir * 16, w_org + force_dir * 16, MOVE_NOMONSTERS, NULL);
+                       if(trace_fraction < 1 && !(hitwep.spawnflags & WEP_TYPE_HITSCAN))
+                               w_backoff = trace_plane_normal;
+                       else
+                               w_backoff = -force_dir;
+               }
                setorigin(this, w_org + w_backoff * 2); // for sound() calls
 
                if(!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY))