123 lines
3.5 KiB
Lua
123 lines
3.5 KiB
Lua
|
|
---------------------
|
|
-- Your Name is Benny
|
|
---------------------
|
|
|
|
local cam_f = CreateConVar( "b-cam_f", -75 )
|
|
local cam_r = CreateConVar( "b-cam_r", 12 )
|
|
local cam_u = CreateConVar( "b-cam_u", 12 )
|
|
local cam_fov = CreateConVar( "b-cam_fov", 75 )
|
|
|
|
local m = 3
|
|
local m2 = Vector( m, m, m )
|
|
local m1 = m2:GetNegated()
|
|
|
|
TPSOverride = TPSOverride or Angle( 0, 0, 0 )
|
|
|
|
function CamSpot( ang, pos )
|
|
if !ang then ang = TPSOverride end
|
|
if !pos then pos = LocalPlayer():EyePos() end
|
|
local f, r, u = TPSOverride:Forward(), TPSOverride:Right(), TPSOverride:Up()
|
|
local tr = {
|
|
start = pos,
|
|
endpos = pos + (f*cam_f:GetFloat()) + (r*cam_r:GetFloat()) + (u*cam_u:GetFloat()),
|
|
filter = LocalPlayer(), -- ply,
|
|
mins = m1,
|
|
maxs = m2,
|
|
}
|
|
tr = util.TraceHull(tr)
|
|
return tr.HitPos
|
|
end
|
|
|
|
function GM:CalcView( ply, pos, ang, fov )
|
|
local view = {
|
|
origin = CamSpot(TPSOverride), -- pos includes the smoothstair offset which looks stupid here
|
|
angles = TPSOverride,
|
|
fov = cam_fov:GetFloat(),
|
|
drawviewer = true
|
|
}
|
|
|
|
if false then
|
|
ply:SetupBones()
|
|
local bm = ply:GetBoneMatrix(ply:LookupBone("DEF-spine.006"))
|
|
view.origin = bm:GetTranslation()
|
|
|
|
if ply:GetLayerSequence( GESTURE_SLOT_JUMP ) == ply:LookupSequence("dive_end_handgun") and ply:GetLayerCycle( GESTURE_SLOT_JUMP )<0.8 then
|
|
local angles = ply:GetBoneMatrix(ply:LookupBone("DEF-spine.004")):GetAngles()
|
|
angles.y = ang.y
|
|
|
|
local magic = math.Remap( ply:GetLayerCycle( GESTURE_SLOT_JUMP ), 0.6, 0.8, 0, 1 )
|
|
magic = math.Clamp( magic, 0, 1 )
|
|
angles.p = Lerp( magic, angles.r-90, ang.p )
|
|
angles.r = 0
|
|
view.angles = angles
|
|
else
|
|
local special = math.Remap( ang.p, 0, 79, 0, 1 )
|
|
special = math.Clamp(special, 0, 1 )
|
|
special = math.ease.InCubic( special )
|
|
local special2 = math.Remap( ang.p, -79, 0, 0, 1 )
|
|
special2 = math.Clamp(special2, 0, 1 )
|
|
special2 = special2 * (1-special)
|
|
view.origin:Sub(ang:Forward()*2)
|
|
view.origin:Add(ang:Up()*4*special2)
|
|
view.origin:Add(ang:Up()*4*special)
|
|
end
|
|
|
|
|
|
local bid = ply:LookupBone("DEF-spine.006")
|
|
ply:ManipulateBoneScale( bid, vector_origin )
|
|
local bid = ply:LookupBone("DEF-spine.005")
|
|
ply:ManipulateBoneScale( bid, vector_origin )
|
|
--local bm = ply:GetBoneMatrix(bid)
|
|
--bm:Scale(Vector(0, 0, 0))
|
|
--ply:SetBoneMatrix(bid, bm)
|
|
--local bid = ply:LookupBone("DEF-spine.005")
|
|
--local bm = ply:GetBoneMatrix(bid)
|
|
--bm:Scale(Vector(0, 0, 0))
|
|
--ply:SetBoneMatrix(bid, bm)
|
|
end
|
|
|
|
return view
|
|
end
|
|
|
|
hook.Add( "InputMouseApply", "Benny_InputMouseApply", function( cmd, x, y, ang )
|
|
local p = LocalPlayer()
|
|
local w = p:HandlerCheck()
|
|
if w then--and (y!=0 or x!=0) then
|
|
if x != 0 then
|
|
TPSOverride.y = TPSOverride.y + (-x*0.022)
|
|
end
|
|
if y != 0 then
|
|
TPSOverride.p = math.Clamp( TPSOverride.p + (y*0.022), -80, 80 )
|
|
end
|
|
return true
|
|
end
|
|
end)
|
|
|
|
hook.Add("CreateMove", "Benny_CreateMove_Camera", function( cmd )
|
|
local p = LocalPlayer()
|
|
if p:GetMoveType() == MOVETYPE_NOCLIP then
|
|
cmd:SetViewAngles( TPSOverride )
|
|
else
|
|
local tr_forward = util.TraceLine( {
|
|
start = CamSpot(TPSOverride),
|
|
endpos = CamSpot(TPSOverride)+(TPSOverride:Forward()*(2^16)),
|
|
filter = p,
|
|
mask = MASK_SHOT,
|
|
} )
|
|
|
|
local planner = (tr_forward.HitPos-p:EyePos()):Angle()
|
|
planner:Normalize()
|
|
cmd:SetViewAngles( planner )
|
|
|
|
local moveintent = Vector( cmd:GetForwardMove(), cmd:GetSideMove(), 0 )
|
|
|
|
|
|
local fixang = Angle()
|
|
fixang.y = cmd:GetViewAngles().y - TPSOverride.y
|
|
moveintent:Rotate( fixang )
|
|
|
|
cmd:SetForwardMove( moveintent.x )
|
|
cmd:SetSideMove( moveintent.y )
|
|
end
|
|
end) |