Shared shoulder cam offset, better movement
This commit is contained in:
parent
cbeade3204
commit
447bb603c1
|
@ -269,17 +269,7 @@ function bennyfp( origin, angles, fov )
|
||||||
local ply = LocalPlayer()
|
local ply = LocalPlayer()
|
||||||
if !IsValid( ply:GetActiveWeapon() ) then return origin, angles, fov end
|
if !IsValid( ply:GetActiveWeapon() ) then return origin, angles, fov end
|
||||||
|
|
||||||
local pos, ang = Vector(), Angle()
|
local pos, ang = ply:CamSpot( TPSOverride )
|
||||||
|
|
||||||
pos:Set( ply:GetPos() )
|
|
||||||
pos.z = pos.z + 64
|
|
||||||
ang:Set( TPSOverride )
|
|
||||||
|
|
||||||
pos:Add( 16 * ang:Right() )
|
|
||||||
pos:Add( -32 * ang:Forward() )
|
|
||||||
pos:Add( 0 * ang:Up() )
|
|
||||||
|
|
||||||
pos:Add( 16 * ang:Up() * (ang.p/90) )
|
|
||||||
|
|
||||||
return pos, ang, 90
|
return pos, ang, 90
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,35 @@
|
||||||
|
|
||||||
local PT = FindMetaTable( "Player" )
|
local PT = FindMetaTable( "Player" )
|
||||||
|
|
||||||
|
function PT:CamSpot( ang )
|
||||||
|
local w = self:GetActiveWeapon()
|
||||||
|
if !IsValid( w ) then w = false end
|
||||||
|
|
||||||
|
local aim = w and w:GetAim() or 0
|
||||||
|
aim = w:GetUserAim() and math.ease.OutCubic( aim ) or math.ease.InCubic( aim )
|
||||||
|
|
||||||
|
local pos = self:GetPos()
|
||||||
|
|
||||||
|
local perc = math.TimeFraction( self:GetViewOffset().z, self:GetViewOffsetDucked().z, self:GetCurrentViewOffset().z )
|
||||||
|
pos.z = pos.z + Lerp( perc, 64, 52 )
|
||||||
|
|
||||||
|
pos:Add( Lerp( aim, 16, 16 ) * ang:Right() )
|
||||||
|
pos:Add( Lerp( aim, -64, -32 ) * ang:Forward() )
|
||||||
|
pos:Add( 0 * ang:Up() )
|
||||||
|
|
||||||
|
pos:Add( Lerp( aim, 16, 16 ) * ang:Up() * (ang.p/90) )
|
||||||
|
|
||||||
|
local tr = util.TraceHull( {
|
||||||
|
start = self:GetPos() + Vector( 0, 0, Lerp( perc, 64, 52 ) ),
|
||||||
|
endpos = pos,
|
||||||
|
mins = -Vector( 4, 4, 4 ),
|
||||||
|
maxs = Vector( 4, 4, 4 ),
|
||||||
|
filter = self
|
||||||
|
})
|
||||||
|
|
||||||
|
return tr.HitPos, ang, 90
|
||||||
|
end
|
||||||
|
|
||||||
function PT:INV_Get()
|
function PT:INV_Get()
|
||||||
if !self.INV then
|
if !self.INV then
|
||||||
print( "Inventory created")
|
print( "Inventory created")
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
local wa, wb = 0, 0
|
local wa, wb = 0, 0
|
||||||
|
|
||||||
local blop = Angle()
|
local blop = Angle()
|
||||||
TPSOverride = Angle()
|
local lastmoveangle = 0
|
||||||
|
TPSOverride = TPSOverride or Angle()
|
||||||
hook.Add( "CreateMove", "CamFuck", function( cmd )
|
hook.Add( "CreateMove", "CamFuck", function( cmd )
|
||||||
if false and BENNY_ACTIVECAMERA and LocalPlayer():GetMoveType() != MOVETYPE_NOCLIP then
|
if false and BENNY_ACTIVECAMERA and LocalPlayer():GetMoveType() != MOVETYPE_NOCLIP then
|
||||||
local x, y = cmd:GetForwardMove(), cmd:GetSideMove()
|
local x, y = cmd:GetForwardMove(), cmd:GetSideMove()
|
||||||
|
@ -54,36 +55,43 @@ hook.Add( "CreateMove", "CamFuck", function( cmd )
|
||||||
|
|
||||||
if true and LocalPlayer():GetMoveType() != MOVETYPE_NOCLIP then -- FPS cam
|
if true and LocalPlayer():GetMoveType() != MOVETYPE_NOCLIP then -- FPS cam
|
||||||
local p = LocalPlayer()
|
local p = LocalPlayer()
|
||||||
|
local w = p:GetActiveWeapon()
|
||||||
|
if !IsValid(w) then w = false end
|
||||||
|
local aimed = w and w:GetUserAim()
|
||||||
|
|
||||||
local opos, ang = p:EyePos(), TPSOverride
|
local opos, ang = p:CamSpot( TPSOverride )
|
||||||
|
|
||||||
ang:Add( Angle( cmd:GetMouseY()*0.022, -cmd:GetMouseX()*0.022, 0 ) )
|
ang:Add( Angle( cmd:GetMouseY()*0.022, -cmd:GetMouseX()*0.022, 0 ) )
|
||||||
ang:Normalize()
|
ang:Normalize()
|
||||||
|
|
||||||
-- PROTO: These and the values in CalcView should use a common function
|
|
||||||
-- to get their position, and to allow easy shoulder switching or overhead.
|
|
||||||
opos:Add( 16 * ang:Right() )
|
|
||||||
opos:Add( -32 * ang:Forward() )
|
|
||||||
opos:Add( 0 * ang:Up() )
|
|
||||||
opos:Add( 16 * ang:Up() * (ang.p/90) )
|
|
||||||
|
|
||||||
local tr = util.TraceLine( {
|
if aimed then
|
||||||
start = opos,
|
local tr = util.TraceLine( {
|
||||||
endpos = opos+(ang:Forward()*(2^16)),
|
start = opos,
|
||||||
filter = p,
|
endpos = opos+(ang:Forward()*(2^16)),
|
||||||
mask = MASK_SOLID,
|
filter = p,
|
||||||
} )
|
mask = MASK_SOLID,
|
||||||
|
} )
|
||||||
|
|
||||||
local planner = (tr.HitPos-p:EyePos()):Angle()
|
local planner = (tr.HitPos-p:EyePos()):Angle()
|
||||||
planner:Normalize()
|
planner:Normalize()
|
||||||
|
cmd:SetViewAngles( planner )
|
||||||
|
lastmoveangle = planner.y
|
||||||
|
end
|
||||||
|
|
||||||
local moveintent = Vector( cmd:GetForwardMove(), cmd:GetSideMove(), 0 )
|
local moveintent = Vector( cmd:GetForwardMove(), cmd:GetSideMove(), 0 )
|
||||||
|
|
||||||
|
if !aimed then
|
||||||
|
if !moveintent:IsEqualTol( vector_origin, 1 ) then
|
||||||
|
lastmoveangle = ang.y - moveintent:Angle().y
|
||||||
|
end
|
||||||
|
cmd:SetViewAngles( Angle( ang.p, lastmoveangle, 0 ))
|
||||||
|
end
|
||||||
|
|
||||||
local fixang = Angle()
|
local fixang = Angle()
|
||||||
fixang.y = cmd:GetViewAngles().y - ang.y
|
fixang.y = cmd:GetViewAngles().y - ang.y
|
||||||
moveintent:Rotate( fixang )
|
moveintent:Rotate( fixang )
|
||||||
|
|
||||||
cmd:SetViewAngles( planner )
|
|
||||||
|
|
||||||
cmd:ClearMovement()
|
cmd:ClearMovement()
|
||||||
cmd:SetForwardMove( moveintent.x )
|
cmd:SetForwardMove( moveintent.x )
|
||||||
|
|
Loading…
Reference in New Issue