Garry's Mod

Garry's Mod

437 个评价
Clientside Hitreg
2
4
   
奖励
收藏
已收藏
取消收藏
素材类型: 插件
插件类型: 工具
插件标签: 快乐, 写实
文件大小
发表于
更新日期
41.886 KB
2023 年 5 月 19 日 上午 6:55
10 月 7 日 下午 6:20
12 项改动说明 ( 查看 )

订阅以下载
Clientside Hitreg

在 wget 的 1 个合集中
ESB TTT addons
13 件物品
描述
This is a simple implementation of client-side hit registration, which aims to eliminate instances of so-called "fake hits" (hits where you see blood impacts but deal no damage)

This also works with not only players, but also npcs, props, etc, even if they're not set to be lag-compensated
That means that this should useful for any kind of PvP or PvE gamemode (if they involve shooting guns)

This does only work with bullets though, not all kinds of traces, so this won't affect stuff like melee weapons and projectiles and such

server cvars:
clhr_shotguns 1 : allow shotguns to use clientside hitreg

clhr_tolerance 8 : hitpos tolerance for lag-compensated entities

clhr_tolerance_nolc 128 : hitpos tolerance for entities that are not lag-compensated

clhr_tolerance_ping 100 : when calculating hitpos tolerance, clamps ping to this max value

clhr_supertolerant 0 : the client is always right (not recommended for public servers)

clhr_targetbits 255 : bitfield for targets that are allowed for clientside hitreg (for if you want to exclude certain types of entities)
1 = players
2 = npcs
4 = nextbots
8 = vehicles
16 = weapons
32 = ragdolls
64 = props
128 = other

clhr_nofirebulletsincallback 0 : prevent bullets from being fired inside the callbacks of client-registered hits
(you may enable this if client-registered hits are causing some weirdness with certain implementations of bullet penetration)

clhr_subtick 0 : subtick hitreg simulation (very experimental, not recommended) <video>

clhr_printshots 0 : print attempts at client-registered hits in the console (for debug purposes)

FAQ:
How exactly does this work?
On the server's side, when you miss a shot, it will temporarily store data about that shot including possible targets that could've been hit
On the client's side, when you hit a shot, it sends a message about that shot to the server in case the server disagrees with the shot's results
Back on the server's side when it receives the client's message, it will check if you're claiming a shot that missed should've actually hit, then decides if it should take your word for it by comparing the data you sent vs the data it stored

Wouldn't cheaters be able to exploit this?
Yes, but this has pretty conservative checks to minimise that
Cheaters won't be able to hit people across the map through walls for 9999 damage with a crowbar or anything crazy like that
At most, this can mildly help cheaters with letting their aimbot be more consistent, so they kinda benefit from this in just the same way that a normal user does

Doesn't explaining how this works and having the server-side code be public make this less secure?
No, security through obscurity is silly
Feel free to scrutinise the code and pick it apart, since I did just hastily make this in a couple of days (at least that's my excuse for the many questionable decisions in the source code)
Still, I'm pretty confident that this shouldn't be buggy and should be compatible with pretty much anything, but PLEASE report to me any bugs or errors you encounter with this addon

Can I use this along with LeyHitreg?
No, that's like using 2 adblockers at the same time, they will conflict with each other and break stuff
Only use one or the other, depending on which one is more compatible with whatever set of addons that you have

How is this different from LeyHitreg?
I haven't looked into how exactly LeyHitreg performs its clientside hitreg, but I've done some tests with it when I was fixing some random-spread-related issues it was causing with one of my addons
From my tests, LeyHitreg seems very overzealous and lets you land up to like 50% more shots than you should, I think it's way too generous
To prove this, I've fired a thousand shots with an average chance to hit of 26.4%, and 338 of those shots landed with LeyHitreg
Using the binomial distribution formula, this has an odds to occur of like 1 in 8 million
It always kinda felt like I only needed to aim in someone's general direction to land shots in a server that has LeyHitreg installed, it appears to perform some sort of aim-assist or bullet-magnetism

Also this addon works with shotguns and on npcs while LeyHitreg doesn't

Why do fake hits still occasionally happen with this?
This addon is quite strict with how it validates hits sent by the client, since it makes sure that a shot is actually possible from where you fired it to where you claim it hits
The value of the clhr_tolerance convar is used to tell how far away the claimed hit position can be from the line of the shot (basically a cylinder check)
If you find that the default value of 8 units is too strict, you may increase it to like 16 or higher
You can scroll up to the "server cvars" section to see more console variables that you can adjust

I did a quick test where I tried to get a lot of "fake hits" with 200 ms ping and 50 ms jitter while aiming for the head of a player bot that's wildly swinging its crowbar and chasing me in a circle
I fired a thousand shots with an average chance to hit of 72.9%:
- 534 shots hit without clientside hitreg (30.65% fake hits)
- 756 shots hit at 8 units of tolerance (1.82% fake hits)
- 768 shots hit at 16 units of tolerance (0.26% fake hits)

(whenever I say "average chance to hit", it's calculated clientside using the bullet's cone of spread and the hitboxes within it)

more info:
for addon coders, here's some compatibility features:
https://psteamcommunity.yuanyoumao.com/workshop/filedetails/discussion/2977785840/3824163953450188003/

thanks to figardo for some early testing

anyone is free to edit and share edited versions of this addon's code (just make it clear what you changed)

github page: https://github.com/wgetJane/gmod-clientside-hitreg

my addons:
my maps:
热门讨论 查看全部(1)
0
2023 年 5 月 19 日 下午 6:52
置顶: Here's some compatibility features for addon coders
wget
97 条留言
wget  [作者] 10 月 9 日 上午 10:05 
@Goggles
that is a very odd error, it points to a line where it makes more sense for a previous line to trigger the error first

can you explain what the circumstances were so that it could be replicated
Spanospy 10 月 9 日 上午 9:12 
@goggles I'm betting one of your subscribed addons is messing with it. Share your collection :steamhappy:
Goggles 10 月 9 日 上午 7:07 
whats this mean

[clientside_hitreg] addons/clientside_hitreg/lua/marghitreg/sv_marghitreg.lua:889: attempt to index local 'ply' (a nil value)
1. v - addons/clientside_hitreg/lua/marghitreg/sv_marghitreg.lua:889
2. unknown - lua/includes/modules/hook.lua:102
ALE199 10 月 8 日 上午 2:15 
I see and thanks again ^^
wget  [作者] 10 月 8 日 上午 2:02 
@ALE199
just prevents the infinite loop by sort of inversing what zippy's thing does, shouldn't affect other addons that don't do the same thing
https://github.com/wgetJane/gmod-clientside-hitreg/commit/045d4553f0b60c1c4623d62ad584d24c42816787
thanks for reporting the issue
ALE199 10 月 8 日 上午 1:06 
how did you fix it if I could ask?
ALE199 10 月 8 日 上午 1:06 
Ok tested and it works perfectly! I'll try online with friends to see if it works with more than one person but I will say, you done gods work, great job man!
ALE199 10 月 8 日 上午 12:58 
Also I will say it's very cool that you still are working on this, you've been very patient and helpful ^^
ALE199 10 月 8 日 上午 12:58 
Alright I will and well Zippy turned off all his comments on steam (understandable tbh) but I don't wanna struggle with all the rigamarore to concact him so I hope someone else has this niche problem and askes him to fix it.
the banks are out of money 10 月 7 日 下午 8:18 
they sure ain't the best practices i've seen