2023-09-13 22:15:43 -04:00
|
|
|
|
|
|
|
-- Movement
|
|
|
|
|
|
|
|
local wa, wb = 0, 0
|
|
|
|
|
|
|
|
local blop = Angle()
|
2023-10-22 00:38:30 -04:00
|
|
|
local lastmoveangle = 0
|
2023-11-01 17:44:44 -04:00
|
|
|
local lastmoveangle_lerp
|
2023-10-22 00:38:30 -04:00
|
|
|
TPSOverride = TPSOverride or Angle()
|
2023-11-12 04:54:48 -05:00
|
|
|
|
|
|
|
hook.Add( "PlayerNoClip", "Benny_PlayerNoClip", function( ply, desiredNoClipState )
|
|
|
|
if CLIENT then
|
|
|
|
if desiredNoClipState then
|
2023-11-14 02:45:34 -05:00
|
|
|
ply:SetEyeAngles( TPSOverride )
|
2023-11-12 04:54:48 -05:00
|
|
|
else
|
2023-11-12 06:10:08 -05:00
|
|
|
TPSOverride:Set( LocalPlayer():EyeAngles() )
|
2023-11-12 04:54:48 -05:00
|
|
|
lastmoveangle = LocalPlayer():EyeAngles().y
|
|
|
|
lastmoveangle_lerp = LocalPlayer():EyeAngles().y
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
hook.Add( "InputMouseApply", "Benny_InputMouseApply", function( cmd, x, y, ang )
|
2023-11-14 02:45:34 -05:00
|
|
|
if LocalPlayer():BennyCheck() and !LocalPlayer():NoclippingAndNotVaulting() then
|
2023-11-12 04:54:48 -05:00
|
|
|
TPSOverride:Add( Angle( y*0.022, -x*0.022, 0 ) )
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2023-11-06 14:03:14 -05:00
|
|
|
hook.Add( "CreateMove", "Benny_CreateMove", function( cmd )
|
2023-11-14 02:45:34 -05:00
|
|
|
if false and BENNY_ACTIVECAMERA and !LocalPlayer():NoclippingAndNotVaulting() then
|
2023-09-13 22:15:43 -04:00
|
|
|
local x, y = cmd:GetForwardMove(), cmd:GetSideMove()
|
2023-09-23 22:51:35 -04:00
|
|
|
|
|
|
|
local lx=input.GetAnalogValue(ANALOG_JOY_X) // Left X Axis: left -, right +
|
|
|
|
local ly=input.GetAnalogValue(ANALOG_JOY_Y) // Left Y Axis: up -, bottom +
|
|
|
|
|
|
|
|
local lr=input.GetAnalogValue(ANALOG_JOY_R) // Right X Axis: left -, right +
|
|
|
|
local lu=input.GetAnalogValue(ANALOG_JOY_U) // Right Y Axis: up -, bottom +
|
|
|
|
|
|
|
|
lx=lx/32768; ly=ly/32768; lr=lr/32768; lu=lu/32768; // Conversion to floats -1.0 - 1.0
|
|
|
|
|
|
|
|
if lx != 0 or ly != 0 then
|
|
|
|
x, y = ly * -320, lx * 320
|
|
|
|
end
|
|
|
|
|
2023-09-13 22:15:43 -04:00
|
|
|
wa, wb = x, y
|
|
|
|
|
|
|
|
local ad = Vector( x, y, 0 )
|
|
|
|
|
|
|
|
local an = Angle()
|
|
|
|
an:Set( RenderAngles() )
|
|
|
|
an.p = 0
|
|
|
|
|
|
|
|
local am = Angle()
|
|
|
|
am:Set( cmd:GetViewAngles() )
|
|
|
|
am.p = 0
|
|
|
|
|
|
|
|
ad:Rotate( am )
|
|
|
|
ad:Rotate( -an )
|
|
|
|
|
2023-09-23 22:51:35 -04:00
|
|
|
-- ad:Normalize()
|
|
|
|
-- ad:Mul(320)
|
2023-09-13 22:15:43 -04:00
|
|
|
|
2023-11-16 01:54:54 -05:00
|
|
|
--cmd:ClearMovement()
|
2023-09-13 22:15:43 -04:00
|
|
|
cmd:SetForwardMove( ad.x )
|
|
|
|
cmd:SetSideMove( ad.y )
|
|
|
|
|
|
|
|
if x != 0 or y != 0 then
|
|
|
|
local thing = Vector( x, -y, 0 ):Angle()
|
|
|
|
thing.y = thing.y + an.y
|
|
|
|
blop.y = math.ApproachAngle( blop.y, thing.y, FrameTime() * 360 )
|
|
|
|
end
|
|
|
|
cmd:SetViewAngles( blop )
|
|
|
|
|
|
|
|
end
|
2023-10-09 15:11:00 -04:00
|
|
|
|
2023-11-06 14:03:14 -05:00
|
|
|
local p = LocalPlayer()
|
|
|
|
local w = p:GetActiveWeapon()
|
2023-11-14 02:45:34 -05:00
|
|
|
if p:BennyCheck() and !LocalPlayer():NoclippingAndNotVaulting() then -- FPS cam
|
2023-11-06 14:03:14 -05:00
|
|
|
local aimed = w:GetUserAim()
|
2023-10-22 00:38:30 -04:00
|
|
|
local opos, ang = p:CamSpot( TPSOverride )
|
2023-10-09 15:11:00 -04:00
|
|
|
|
2023-11-11 21:08:27 -05:00
|
|
|
local lx=input.GetAnalogValue(ANALOG_JOY_X) // Left X Axis: left -, right +
|
|
|
|
local ly=input.GetAnalogValue(ANALOG_JOY_Y) // Left Y Axis: up -, bottom +
|
|
|
|
local lr=input.GetAnalogValue(ANALOG_JOY_R) // Right X Axis: left -, right +
|
|
|
|
local lu=input.GetAnalogValue(ANALOG_JOY_U) // Right Y Axis: up -, bottom +
|
|
|
|
lx=lx/32768; ly=ly/32768; lr=lr/32768; lu=lu/32768; // Conversion to floats -1.0 - 1.0
|
|
|
|
|
|
|
|
local moveintent
|
|
|
|
if lx != 0 or ly != 0 then
|
|
|
|
moveintent = Vector( ly * -320, lx * 320, 0 )
|
|
|
|
else
|
|
|
|
moveintent = Vector( cmd:GetForwardMove(), cmd:GetSideMove(), 0 )
|
|
|
|
end
|
|
|
|
|
|
|
|
local dir_p, dir_y = lr>0, lu>0
|
|
|
|
dir_p = dir_p and 1 or -1
|
|
|
|
dir_y = dir_y and -1 or 1
|
|
|
|
local look_p, look_y = dir_p * math.ease.InCirc( math.abs(lr) ), dir_y * math.ease.InCirc( math.abs(lu) )
|
|
|
|
|
2023-11-12 04:54:48 -05:00
|
|
|
-- ang:Add( Angle( cmd:GetMouseY()*0.022, -cmd:GetMouseX()*0.022, 0 ) )
|
2023-11-11 21:08:27 -05:00
|
|
|
ang:Add( Angle( look_p * 180 * 0.5 * FrameTime(), look_y * 180 * FrameTime(), 0 ) )
|
|
|
|
ang.p = math.Clamp( ang.p, -89.9, 89.9 )
|
2023-10-09 15:11:00 -04:00
|
|
|
ang:Normalize()
|
|
|
|
|
2023-10-22 00:38:30 -04:00
|
|
|
if aimed then
|
|
|
|
local tr = util.TraceLine( {
|
|
|
|
start = opos,
|
|
|
|
endpos = opos+(ang:Forward()*(2^16)),
|
|
|
|
filter = p,
|
|
|
|
mask = MASK_SOLID,
|
|
|
|
} )
|
2023-10-09 15:11:00 -04:00
|
|
|
|
2023-10-22 00:38:30 -04:00
|
|
|
local planner = (tr.HitPos-p:EyePos()):Angle()
|
|
|
|
planner:Normalize()
|
|
|
|
cmd:SetViewAngles( planner )
|
|
|
|
lastmoveangle = planner.y
|
|
|
|
end
|
2023-10-09 15:11:00 -04:00
|
|
|
|
2023-10-22 00:38:30 -04:00
|
|
|
if !aimed then
|
|
|
|
if !moveintent:IsEqualTol( vector_origin, 1 ) then
|
|
|
|
lastmoveangle = ang.y - moveintent:Angle().y
|
|
|
|
end
|
2023-11-01 17:44:44 -04:00
|
|
|
lastmoveangle_lerp = math.ApproachAngle( lastmoveangle_lerp or lastmoveangle, lastmoveangle, FrameTime() * 360 )
|
|
|
|
cmd:SetViewAngles( Angle( ang.p, lastmoveangle_lerp, 0 ) )
|
2023-11-01 18:04:34 -04:00
|
|
|
else
|
|
|
|
lastmoveangle_lerp = lastmoveangle
|
2023-10-22 00:38:30 -04:00
|
|
|
end
|
|
|
|
|
2023-10-09 15:11:00 -04:00
|
|
|
local fixang = Angle()
|
|
|
|
fixang.y = cmd:GetViewAngles().y - ang.y
|
|
|
|
moveintent:Rotate( fixang )
|
|
|
|
|
|
|
|
|
2023-11-16 01:54:54 -05:00
|
|
|
-- cmd:ClearMovement()
|
2023-10-09 15:11:00 -04:00
|
|
|
cmd:SetForwardMove( moveintent.x )
|
|
|
|
cmd:SetSideMove( moveintent.y )
|
|
|
|
end
|
2023-09-13 22:15:43 -04:00
|
|
|
end)
|
|
|
|
|
|
|
|
function GM:PlayerNoClip()
|
|
|
|
return true
|
|
|
|
end
|