Skip to content

Conversation

@dystopm
Copy link
Contributor

@dystopm dystopm commented Aug 10, 2025

Purpose

The AddMultiDamage function can be skipped entirely when no damage will be applied. While some existing cases already avoid calling it with zero damage (e.g. FireBullets3, shield hit avoids TraceAttack->AddMultiDamage calls), there are other scenarios where it is still invoked with a damage value of 0 or less (e.g., hitting a player with shotgun pellets while they have an active Shield).

These unnecessary calls not only waste processing but can also have unintended side effects for APIs implemented by developers that rely on TakeDamage being called only when damage is actually applied. This PR ensures that the function only executes when flDamage > 0.

Approach

Added a simple check at the start of AddMultiDamage to immediately return if the flDamage parameter is 0 or less.

return;

#ifdef REGAMEDLL_FIXES
if (flDamage <= 0.0f) // avoid zero or negative damage TakeDamage
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix makes sense.
However, there is one detail I remember, some custom maps intentionally use negative damage values (e.g., env_laser with damage = -300) as a way to heal players.

The maps I recall include bhop_zerocheaters, deathrun_forest, deathrun_friends, but there are many more with different scenarios.

This is not a bug but rather a hidden feature that level designers sometimes rely on. With your change, such maps would stop working as intended, since TakeDamage would never be triggered.

So the fix could unintentionally break existing community content.
One possible approach could be to allow negative values (skip only flDamage == 0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants