-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[ALL] Fix melee hits erroneously hitting teammates (with support for on hit attributes) #1507
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
base: master
Are you sure you want to change the base?
Conversation
note that this is a basic implementation, and doesn't consider other teammate related on hit events, so this is marked as a draft until this is fixed. |
This PR now functions as expected. Here's a demo video about it! |
Implemented a HL2MP version |
I would not remove or replace this code, because some plugins/vscripts abuse it in order to bypass teammates. |
that code is no longer needed since the majority of melee weapons don't have the listed exceptions (since very few melee weapons have on hit attributes for teammates) However, I'll possibly make it so that you could switch back to the original behavior using vscript |
There are now 3 ways to set the old melee behavior:
SourceMod plugins could also hook into the CTFPlayerShared::SetOldMeleeTrace function as well. |
This is a balance decision, not a bug. Also being able to not hit teammates anymore would be very very badly received by the community as well as make Spychecking even easier (making Spy much weaker when he already is very weak) |
this absolutely isn't a balance decision. it's a bug. even if it isn't one, it's genuinely annoying to hit your teammates during combat. for example: if you're playing as demoknight and a teammate goes in front of you while you're charging into an enemy, the teammate will tank the sword damage, which frustrates the demoknight player. in contrast: many hitscan and projectile weapons pass through teammates, and it only makes sense that melee weapons should also be treated the same way. spychecking can already be done by shooting your teammates or using a flamethrower. this change only lines up with how teammates should react when someone's shooting projectiles. this also wouldn't be negatively received by the community, as a bunch of larger figures have expressed the same problems. this is a reason i added a toggle convar to it, for server owners that prefer the older melee hit registration. this PR also does not prevent every instance of teammate hits, as this PR makes it so the Disciplinary Action and PASS time mechanics will function normally, as well as the unused add_give_health_to_teammate_on_hit attribute. |
I don't see why it wouldn't be.
It's annoying but necessary, the same applies to autobalance and projectiles being consumed by teammates. It would be stupid to suddenly be hit by a projectile that you physically couldn't see coming, similar to being hit by melee you can't even see. It's just something necessary, but annoying.
Exactly, so why make it even easier to check? I've had times with people have hit me once and then because I didn't react they didn't think I was suspicious. Now it would be really obvious because you hear the melee sound that otherwise doesn't play.
Doesn't mean they're right though, they just say it's annoying but removing hits on teammates would 100% be a very unpopular decision that gets removed within a week. Some community figures also call for Quickplay back but they're objectively wrong when they say it's an improvement. Just because someone has a large subscriber/view count doesn't mean they are more correct.
Those aren't the hits I'm talking about. Not having teammate hits actually removes a lot of silly interactions. |
With some re-evaluation, yeah this is a balance change. I'll mark this PR as a modding resource for those who want to implement this functionality in their mods |
I decided to revert the modding resource tag and decided to stick with my original opinion and it won't be changed any longer |
Description
One commonly reported Source issue is one related to melee hit registration. If you swing a bat and it hit a teammate, intending to hit the enemy behind the teammate, it will hit the teammate instead of the enemy, which makes melee weapons feel unresponsive. There was a fix for this issue introduced for MvM bots, but not for players. This code changes this line of code to ONLY hit teammates if friendly fire (mp_friendlyfire) is enabled. This uses a custom trace filter, meaning that special instances (such as Disciplinary Action hits and PASS Time steals) function as expected.
One side effect of this is that MvM bots can now use the Disciplinary Action properly as well, since the code works for both bots and player
For TF, there are multiple ways to restore the original behavior:
SourceMod plugins could also hook into the CTFPlayerShared::SetOldMeleeTrace function as well.
For HL2MP, it reuses the CTraceFilterIgnoreTeammates filter from TF and implements it in a similar way.