Breaking NoSpread in your weapon base (or making it harder.) and general info on making cheating mor
15 replies, posted
This post is going to be long, but it's worth the read if you want to make it harder to cheat.
So seeing as I've done nothing but hurt the GMod community by cheating in the game, I've decided that since I no longer really care to cheat (and my group of friends does not) I will release the spread method I was planning to use in the F2S gamemode I was working on (it was based on NanoCat's F2S)
[code]
math.randomseed( ( CurTime() / engine.TickInterval() * 1000 ) + math.sqrt( ( self.Owner:EyeAngles().x * self.Owner:EyeAngles().x ) + self.Owner:EyeAngles().y * self.Owner:EyeAngles().y ) )
local ang = math.Rand(-math.pi, math.pi)
local x = math.cos(ang) * math.Rand(0, 1)
local y = math.sin(ang) * math.Rand(0, 1)
local spread = (ang * x) + (ang * y)
cone = self.Multipliers.Idle + spread
[/code]
Keep in mind, the multipliers come from NanoCat's SWEP base, you might not have them, you can do
[code]
cone = spread
[/code]
If you want it to pretty much work universally, but adding modifiers will probably help you out like...a lot.
If you want to implement this into specific weapon bases, I will gladly help you, but you have to upload the main part of the weapon base so I can do it from there.
It's predictable, but you can't exactly compensate correctly because your viewangles will change while trying to do compensational spread (which changes your randomseed) and you can't force seed because the seed isn't generated using CommandNumber, theoretically it shows up clientside but it doesn't actually work, especially if you do the calculation on the server as well (just make sure that if you plan to calculate on the server that you don't fuck with anything at all in how the randomseed is generated because it will unsync the spread.)
If you want it to be completely unpredictable, as in NoSpread is completely impossible, and don't much care for the clients getting random hits and misses, you could always use the server's SysTime() or you could do something with the PunchAngle (because PunchAngle differs slightly from the server to the client.) which will unsync the spread between client and server, ultimately making it impossible to do NoSpread.
You can make it harder for aimbots by using PunchAngle for your recoil (but there's a problem with decaying the PunchAngle in GMod iirc, making it look terrible at high ping.) You can also break ESP by doing some 3D stuff with your HUD (if the cheat is C++, if it is Lua then it won't break the ESP.) and if you want to make it harder to cheat in general, add Cake Anti-Cheat to your server, it's pretty good and only a few people have decrypted it + bypassed it iirc
If you have any questions feel free to ask, and if you have any corrections to make on my post, feel free to do so.
Shoutouts to:
NanoCat (help with randomseed generation)
Styles (helping with ideas on making spread harder to compensate for)
Altimor (helping with the actual spread method itself)
Aethi (testing)
Keegan (testing)
Frost (testing)
D3X (testing)
[quote]don't much care for the clients getting random hits and misses[/quote]
Why?... That is the one thing that pisses people off the most.
[QUOTE=Nookyava;46905149]Why?... That is the one thing that pisses people off the most.[/QUOTE]
You are very good at reading Nookyava, I said "if you don't care for the client getting random hits and misses" then you can do the spread fully serverside, had you even taken 5 seconds out of your day to actually take a look at the code, you'd see that it's completely synced as it is right now, next time, instead of just skimming over the post and making yourself look like an idiot, you should read it.
[code]math.sqrt( ( self.Owner:EyeAngles().x * self.Owner:EyeAngles().x ) + self.Owner:EyeAngles().y * self.Owner:EyeAngles().y ) )[/code]
What's this for
Also, wouldn't it be easier to just replace FireBullets with code that does this all for you?
[QUOTE=Willox;46905192][code]math.sqrt( ( self.Owner:EyeAngles().x * self.Owner:EyeAngles().x ) + self.Owner:EyeAngles().y * self.Owner:EyeAngles().y ) )[/code]
What's this for
Also, wouldn't it be easier to just replace FireBullets with code that does this all for you?[/QUOTE]
It just square roots the player's viewangles, I'm not exactly sure why NanoCat decided to do it that way but he gave me that and told me that would work, I know you and him are friends so it'd probably be best to ask him why he did that himself. The general idea behind it though, is that when the player's viewangles change, the number changes and in doing so the randomseed changes, so compensating for spread is pretty difficult. It was how CS:GO did it with their first spread patch (before they completely unsynced spread between client and server)
And to your second question, I was doing penetration with FireBullets but implementing something similar probably wouldn't be too hard, in fact, inside FireBullets you could probably do some basic bullet physics which causes bullets to drop as they travel (aimbots wouldn't compensate for it.)
Unless the spread makes it impossible to hit anything if you're aiming directly at it, eliminating the ability to cancel spread isn't that big of a hindrance to cheaters. Nonetheless, good on your for posting this.
This might be easier to use then
[code]
local meta = FindMetaTable "Entity"
meta.OldFireBullets = meta.OldFireBullets or meta.FireBullets
local function rand()
return math.random() * 2 - 1
end
function meta:FireBullets( bullet, suppress )
local spread = bullet.Spread
if type(spread) == "Vector" then
bullet.Spread = vector_origin
math.randomseed( CurTime() + math.sqrt( bullet.Dir.x ^ 2 * bullet.Dir.y ^ 2 * bullet.Dir.z ^ 2 ) )
bullet.Dir = bullet.Dir + Vector( spread.x * rand(), spread.y * rand(), spread.z * rand() )
end
self:OldFireBullets( bullet, suppress )
end
[/code]
I tested that it predicts correctly too (not that your original code didn't).
[t]http://i.imgur.com/KcyU42j.jpg[/t]
[QUOTE=sasherz;46905363]Unless the spread makes it impossible to hit anything if you're aiming directly at it, eliminating the ability to cancel spread isn't that big of a hindrance to cheaters. Nonetheless, good on your for posting this.[/QUOTE]
That's why I said it'd be good to use modifiers actually, in NanoCat's SWEP base there's some stuff for modifiers, when you're not moving your modifier is "Idle" (which is 1 technically.) and they can be manually changed with each and every weapon, so for example, if you were running you'd have spread that was nearly as bad as CS:GO's spread while running and gunning (shots could go 90 degrees downward or upward)
But yes, you're technically correct that it's not a huge hindrance, but if you add PunchAngle most people don't actually have any method of compensating for PunchAngle, which will make your shots land above the target.
Thanks for being one of the only people that actually understood what I was posting (and reading the entire post.)
EDIT: Thanks for contributing Willox! I'm sure it'll help someone out!
You've probably never used a weapon in gmod that uses punch angles correctly.
[QUOTE=Willox;46905389]You've probably never used a weapon in gmod that uses punch angles correctly.[/QUOTE]
It's unlikely that I have seen PunchAngle used properly, I've used Spy's weapons and I've used NanoCat's weapons, which are pretty much the only two weapon bases I've ever seen that had PunchAngle used in them.
[QUOTE=Reyjr43;46905415]It's unlikely, I've used Spy's weapons and I've used NanoCat's weapons, which are pretty much the only two weapon bases I've ever seen that had PunchAngle used in them.[/QUOTE]
The weapons in this repo are a good example I suppose: [url]https://github.com/wiox/gmod-csweapons[/url]
[QUOTE=Willox;46905426]The weapons in this repo are a good example I suppose: [url]https://github.com/wiox/gmod-csweapons[/url][/QUOTE]
I'll take a look sometime in the future, thanks for giving me a good example! I'll probably end up seeing how PunchAngle is used in them (properly) so I can do the same with NanoCat's F2S wep base.
EDIT: Oh...huh, that's interesting, what's the difference between SetViewPunchAngles and just PunchAngle, though?
If you mean ViewPunch(), I believe it increments the viewpunch angles by the given angle whilst SetViewPunchAngles lets you set the angles to whatever you want.
Whoever [URL="http://facepunch.com/member.php?u=678795"]"Sunshines"[/URL] is, you seem to have pissed him off
[QUOTE=Exho;46905592]Whoever [URL="http://facepunch.com/member.php?u=678795"]"Sunshines"[/URL] is, you seem to have pissed him off[/QUOTE]
Yeah, that's what I was thinking but I wasn't going to post anything about it because then they'd probably rate me dumb and call me mad or something.
There's no reason for that sqrt. The only difference is using length instead of length squared.
Sorry, you need to Log In to post a reply to this thread.