]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/sv_main.qc
Add an option to only account for vertical travel when calculating fall damage
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / sv_main.qc
index 54c9744332d5033ccbd5518f4f79b29dca36606c..cd4693a2bdfbed24c6a0d2b2880c28e0726e96d6 100644 (file)
@@ -114,13 +114,21 @@ void CreatureFrame_FallDamage(entity this)
        }
        if(!have_hook)
        {
-               float dm = vlen(this.oldvelocity) - velocity_len; // dm is now the velocity DECREASE. Velocity INCREASE should never cause a sound or any damage.
+               float dm;
+               if(autocvar_g_balance_falldamage_onlyvertical)
+                       dm = vlen('0 0 1' * this.oldvelocity.z) - vlen('0 0 1' * this.velocity.z);
+               else
+                       dm = vlen(this.oldvelocity) - velocity_len; // dm is now the velocity DECREASE. Velocity INCREASE should never cause a sound or any damage.
                if (IS_DEAD(this))
                        dm = (dm - autocvar_g_balance_falldamage_deadminspeed) * autocvar_g_balance_falldamage_factor;
                else
                        dm = min((dm - autocvar_g_balance_falldamage_minspeed) * autocvar_g_balance_falldamage_factor, autocvar_g_balance_falldamage_maxdamage);
                if (dm > 0)
-                       Damage (this, NULL, NULL, dm, DEATH_FALL.m_id, DMG_NOWEP, this.origin, '0 0 0');
+               {
+                       tracebox(this.origin, this.mins, this.maxs, this.origin - '0 0 1', MOVE_NOMONSTERS, this);
+                       if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODAMAGE))
+                               Damage (this, NULL, NULL, dm, DEATH_FALL.m_id, DMG_NOWEP, this.origin, '0 0 0');
+               }
        }
 
        if(autocvar_g_maxspeed > 0 && velocity_len > autocvar_g_maxspeed)