--VERTICAL AUTO-RECENTER, a camera script to auto-recenter your vertcial aim --by Nero1024 --cvar to enable recentering rawset(_G, "cv_camaimrecenter", CV_RegisterVar({ name = "camaimrecenter", defaultvalue = "1", PossibleValue = {Yes = 1, No = 0}, flags = 0 })) --recentering factor cvar --positive values determine the slowness of the recentering --a value of 1.0 have no recentering --0 is (almost) instantaneous --negative values are bouncy and jittery like you just bumped into something --values higher than 1.0 or lower than -1.0 makes the camera freak out rawset(_G, "cv_camaimrecenterfactor", CV_RegisterVar({ name = "camaimrecenterfactor", defaultvalue = "0.9", PossibleValue = {MIN = -1*FRACUNIT, MAX = FRACUNIT}, flags = CV_FLOAT })) --speed threshold where recentering happens cvar --number is multiplied by player's scale (usually 1 FRACUNIT) --negative numbers makes the recentering constant rawset(_G, "cv_camaimrecenterthreshold", CV_RegisterVar({ name = "camaimrecenterthreshold", defaultvalue = "5" })) local cv_chasecam = CV_FindVar("chasecam") local cv_chasecam2 = CV_FindVar("chasecam2") --thinker addHook("PlayerThink", function(p) p.aiming_centerfactor = cv_camaimrecenterfactor.value p.aiming_threshold = cv_camaimrecenterthreshold.value p.chasecam_on = cv_chasecam.value p.chasecam2_on = cv_chasecam2.value --debugging printer --print("factor: " .. p.aiming_centerfactor .. ", threshold: " .. p.aiming_threshold .. ", chase: " .. p.chasecam_on .. p.chasecam2_on .. ", mo: " .. tostring(p.mo)) --don't bother recentering if recentering is off or in first person or has no mobj if cv_camaimrecenter.value == 0 or not p.chasecam_on --or (not netgame and not p.chasecam2_on) or not p.mo return end --reset vertical view angle when moving if (abs(p.mo.momx) > (p.aiming_threshold * p.mo.scale) or abs(p.mo.momy) > (p.aiming_threshold * p.mo.scale)) and (abs(p.cmd.forwardmove) > 0 or abs(p.cmd.sidemove) > 0) p.aiming = FixedMul(p.aiming, p.aiming_centerfactor) end end)