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()
|
||||
if !IsValid( ply:GetActiveWeapon() ) then return origin, angles, fov end
|
||||
|
||||
local pos, ang = Vector(), Angle()
|
||||
|
||||
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) )
|
||||
local pos, ang = ply:CamSpot( TPSOverride )
|
||||
|
||||
return pos, ang, 90
|
||||
end
|
||||
|
|
|
@ -1,6 +1,35 @@
|
|||
|
||||
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()
|
||||
if !self.INV then
|
||||
print( "Inventory created")
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
local wa, wb = 0, 0
|
||||
|
||||
local blop = Angle()
|
||||
TPSOverride = Angle()
|
||||
local lastmoveangle = 0
|
||||
TPSOverride = TPSOverride or Angle()
|
||||
hook.Add( "CreateMove", "CamFuck", function( cmd )
|
||||
if false and BENNY_ACTIVECAMERA and LocalPlayer():GetMoveType() != MOVETYPE_NOCLIP then
|
||||
local x, y = cmd:GetForwardMove(), cmd:GetSideMove()
|
||||
|
@ -54,19 +55,17 @@ hook.Add( "CreateMove", "CamFuck", function( cmd )
|
|||
|
||||
if true and LocalPlayer():GetMoveType() != MOVETYPE_NOCLIP then -- FPS cam
|
||||
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: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) )
|
||||
|
||||
if aimed then
|
||||
local tr = util.TraceLine( {
|
||||
start = opos,
|
||||
endpos = opos+(ang:Forward()*(2^16)),
|
||||
|
@ -76,14 +75,23 @@ hook.Add( "CreateMove", "CamFuck", function( cmd )
|
|||
|
||||
local planner = (tr.HitPos-p:EyePos()):Angle()
|
||||
planner:Normalize()
|
||||
cmd:SetViewAngles( planner )
|
||||
lastmoveangle = planner.y
|
||||
end
|
||||
|
||||
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()
|
||||
fixang.y = cmd:GetViewAngles().y - ang.y
|
||||
moveintent:Rotate( fixang )
|
||||
|
||||
cmd:SetViewAngles( planner )
|
||||
|
||||
cmd:ClearMovement()
|
||||
cmd:SetForwardMove( moveintent.x )
|
||||
|
|
Loading…
Reference in New Issue