Does anyone know a way to override core functions, such as util.ScreenShake?
11 replies, posted
I always hated the screenshake effect, used when things collide or grenades and such go off. I've tried messing with CalcView and overriding the function in any way possible, but I simply cannot figure out how to stop screen shake.
I'd be very grateful if anyone knows the secret, please
Keep in mind that the original function won't get overridden if it was localized.
Better yet
util = {}
No, Don't.
Note that not all screen shake is due to stuff calling that function, some of it comes from the engine which you can't override. I remember a request to add a hook for it but I can't find it currently.
You may wish to override all the env_shake entities to do nothing. Also keep in mind that overriding it in Lua doesn't remove it from C++, which means core game mechanics might still shake the screen.
My main reason behind this is simply if you slam a prop on the ground with a physgun, it shakes lots of player's screens. Unfortunately I can't seem to get these solutions to work either :/
Bobblehead, could you give me a pointer to get started with implementing that please?
hook.Add("OnEntityCreated","noshake",function(ent)
if ent:GetClass() == "env_shake" then
timer.Simple(0,function()ent:Remove()end)
end
end)
But I doubt this will fix prop-slamming issues.
Yeah, the prop slamming cannot be helped. I overrided the util.ScreenShake function and it did what it was meant to do but apparently the prop thing doesn't use util.ScreenShake
util.NewScreenShake = util.NewScreenShake || util.ScreenShake
function util.ScreenShake(pos, amplitude, frequency, duration, radius)
print("Nice try idiot")
end
util.ScreenShake(Vector(0, 0, 0), 5, 5, 1, 5000)
Here's the code I used
It uses util.ScreenShake, but when you override it in Lua it doesn't change the underlying C++ function.
Perhaps you could request an OnScreenShake hook.
Thank you for all your help everyone. I hope one day Garry will let us turn this effect off :P
Sorry, you need to Log In to post a reply to this thread.