ValveSoftware / source-sdk-2013

The 2013 edition of the Source SDK
https://developer.valvesoftware.com/wiki/SDK2013_GettingStarted
Other
3.73k stars 1.99k forks source link

Antlion worker acid damage causes constant HUD effects #394

Open SamVanheer opened 7 years ago

SamVanheer commented 7 years ago

Originally found by Hell-met: https://facepunch.com/showthread.php?t=1507632&p=51218004&viewfull=1#post51218004

If you've taken acid damage from antlion workers once, then you will get the HUD flashing effect every time you take damage.

I debugged this, i'll explain in detail.

Acid damage is supposed to be time based damage, but isn't reset like poison damage because gamerules says it's not time based: https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/sp/src/game/shared/hl2/hl2_gamerules.cpp#L209

Unfortunately, gamerules also says that acid damage is a damage type that should be shown on the HUD: https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/sp/src/game/shared/singleplay_gamerules.cpp#L58

Because the gamerules methods disagree, it ends up reporting acid damage every time the amount of damage you've taken, the amount of damage that armor absorbed, or the types of damage you've taken have changed: https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/sp/src/game/server/hl2/hl2_player.cpp#L3198

So to fix this, CHalfLife2 gamerules needs to exclude acid damage from the HUD damage types.

This should be relatively easy to fix:

int CHalfLife2::Damage_GetShowOnHud( void )
{
    return BaseClass::Damage_GetShowOnHud() & ~DMG_ACID;
}

Of course, if acid damage is supposed to show up on-screen, clearing the DMG_ACID flag is the better solution.

ihonnyboy commented 7 years ago

It's actually much easier to fix, without suppressing the effect. You came close to the solution. Just add DMG_ACID to Damage_IsTimeBased:

bool CHalfLife2::Damage_IsTimeBased( int iDmgType ) { // Damage types that are time-based.

ifdef HL2_EPISODIC

// This makes me think EP2 should have its own rules, but they are #ifdef all over in here. return ( ( iDmgType & ( DMG_PARALYZE | DMG_NERVEGAS | DMG_POISON | DMG_RADIATION | DMG_DROWNRECOVER | DMG_ACID | DMG_SLOWBURN ) ) != 0 ); //add DMG_ACID to this line

else

return BaseClass::Damage_IsTimeBased( iDmgType );

endif

}

Toybasher commented 6 years ago

Please fix this. It's extremely distracting and a simple fix.