Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix certain CS:S weapons always gibbing NPCs #240

Merged

Conversation

Blixibon
Copy link
Collaborator

This happened because custom damage values in FireBulletsInfo_t were automatically set to always gib if they had high damage. This fix uses a flag added to Mapbase v7.0 to get around this functionality.

…ERGIB to always be added in base bullet code
…/source-sdk-2013 into ez2/feature/css-weapons-gib-fix

# Conflicts:
#	sp/src/game/shared/baseentity_shared.cpp
#	sp/src/game/shared/shareddefs.h
@Blixibon Blixibon requested a review from 1upD November 27, 2023 22:00
Copy link

@1upD 1upD left a comment

Choose a reason for hiding this comment

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

LGTM

@Blixibon
Copy link
Collaborator Author

I was mistaken in the scope of the original change; It only fixed machine guns, rather than all weapons (e.g. deagles). I've amended that with further changes to all CS:S weapons.

@1upD This may need an additional review when you get a chance

if (GetNPCDamageMultiplier() != 1.0f)
{
info.m_flDamage = round( GetAmmoDef()->NPCDamage( info.m_iAmmoType ) * GetNPCDamageMultiplier() );
info.m_nFlags |= FIRE_BULLETS_NO_AUTO_GIB_TYPE;
Copy link

Choose a reason for hiding this comment

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

I feel a little confused here. What is the check for GetNPCDamageMultiplier() != 1.0f for? Why does it only specify no auto gib if the NPC damage multiplier isn't 1.0?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

FIRE_BULLETS_NO_AUTO_GIB_TYPE only comes into play when m_flDamage is set to a non-zero value. It's meant to bypass a hardcoded feature in which any m_flDamage value greater than 20 adds DMG_ALWAYSGIB to the bullet's damage types.

Copy link

Choose a reason for hiding this comment

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

I still don't understand. If the result of GetNPCDamageMultiplier() is 1.0f, that means that m_flDamage should also be 1.0? But what if GetAmmoDef()->NPCDamage( info.m_iAmmoType) is not 1? This does not look right to me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, m_flDamage should not be 1.0. It is a direct damage override value, not a multiplier.

When m_flDamage is set to 0 (the default), the bullet firing code uses the ammo type's player or NPC damage, depending on which type of entity is firing the bullets. When m_flDamage is not set to 0, the bullet firing code overrides those values and uses the value stored in m_flDamage instead.

GetNPCDamageMultiplier() is intended to be multiplied with the ammo type's NPC damage, so it takes the ammo type's NPC damage in the same manner as the underlying code, multiplies it, rounds it to the nearest whole number, and then assigns that value to m_flDamage to override the default behavior. When GetNPCDamageMultiplier() is set to 1.0, the damage does not need to be overridden because the default NPC damage value multiplied by 1.0 is equivalent to the default NPC damage value.

Copy link

Choose a reason for hiding this comment

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

I'm sorry, I didn't understand the default behavior. This makes perfect sense now.

One last question - why is DMG_ALWAYSGIB only applied if m_flDamage is not passed as 0? It seems weird to me that the default damage doesn't cause gibbing but override damage does

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't know. m_flDamage only seems to be used by func_tank in default HL2, so I suspect this is from some kind of unused legacy case. The flag FIRE_BULLETS_NO_AUTO_GIB_TYPE is one I added in a previous Mapbase update, and it's meant to get around this functionality without interfering with default behavior.

@1upD 1upD self-requested a review March 3, 2024 00:45
@1upD 1upD merged commit fff5973 into entropy-zero:ez2/mapbase Mar 7, 2024
5 checks passed
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.

None yet

2 participants