2023-09-06 04:06:14 -04:00
|
|
|
|
2023-09-13 22:15:43 -04:00
|
|
|
BENNY_ACTIVECAMERA = nil
|
2023-09-06 04:06:14 -04:00
|
|
|
|
2023-09-17 20:34:13 -04:00
|
|
|
local fixer = Angle( 0, -90, 90 )
|
|
|
|
local fixer2 = Angle( 0, -90, 90 )
|
|
|
|
local cscam = {
|
|
|
|
Special = function( self, ply )
|
|
|
|
local pos = Vector()
|
|
|
|
local ang = Angle()
|
|
|
|
local fov = 90
|
|
|
|
|
|
|
|
cuts:SetupBones()
|
|
|
|
local mat = cuts:GetBoneMatrix( cuts:LookupBone( "camera" ) )
|
|
|
|
local matf = cuts:GetBoneMatrix( cuts:LookupBone( "camera.fov" ) )
|
|
|
|
|
|
|
|
pos:Set( mat:GetTranslation() )
|
|
|
|
ang:Set( mat:GetAngles() )
|
|
|
|
ang:Sub( fixer )
|
|
|
|
|
|
|
|
local fix, fixa = matf:GetTranslation(), matf:GetAngles()
|
|
|
|
fix:Sub( cuts:GetPos() )
|
|
|
|
fov = fix.z
|
|
|
|
|
|
|
|
do
|
|
|
|
local x, y, z = pos.x, pos.y, pos.z
|
|
|
|
end
|
|
|
|
|
|
|
|
do
|
|
|
|
local p, y, r = ang.p, ang.y, ang.r
|
|
|
|
ang.p = -r
|
|
|
|
ang.r = 0
|
|
|
|
end
|
|
|
|
|
|
|
|
fov = Convert( fov, (4/3) ) -- Convert to vertical FOV.. somehow
|
|
|
|
fov = Convert( fov, (ScrH()/ScrW())/(3/4) ) -- Shut up default Source FOV widescreen magic
|
|
|
|
|
|
|
|
return pos, ang, fov
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2023-09-06 05:33:02 -04:00
|
|
|
local function decide_active()
|
2023-09-17 20:34:13 -04:00
|
|
|
local csent = ents.FindByClass( "benny_cutscene" )[1]
|
|
|
|
if IsValid( csent ) then
|
|
|
|
BENNY_ACTIVECAMERA = cscam
|
|
|
|
cuts = csent
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2023-09-13 22:15:43 -04:00
|
|
|
return false
|
2023-09-06 05:33:02 -04:00
|
|
|
end
|
|
|
|
|
2023-09-23 22:51:35 -04:00
|
|
|
function bennyfp( origin, angles, fov )
|
|
|
|
local ply = LocalPlayer()
|
2023-09-25 20:42:13 -04:00
|
|
|
if !IsValid( ply:GetActiveWeapon() ) then return origin, angles, fov end
|
2023-09-23 22:51:35 -04:00
|
|
|
|
2023-10-22 00:38:30 -04:00
|
|
|
local pos, ang = ply:CamSpot( TPSOverride )
|
2023-09-23 22:51:35 -04:00
|
|
|
|
|
|
|
return pos, ang, 90
|
|
|
|
end
|
|
|
|
|
2023-11-06 14:03:14 -05:00
|
|
|
hook.Add( "CalcView", "Benny_CalcView", function( ply, pos, ang, fov )
|
2023-12-17 19:47:52 -05:00
|
|
|
if ConVarCL_Bool("cam_unlock") then return end
|
2023-11-14 02:45:34 -05:00
|
|
|
if ply:NoclippingAndNotVaulting() then return end
|
2023-09-13 22:15:43 -04:00
|
|
|
decide_active()
|
|
|
|
local camera = BENNY_ACTIVECAMERA
|
2023-09-23 22:51:35 -04:00
|
|
|
local view = {}
|
|
|
|
view.origin = pos
|
|
|
|
view.angles = ang
|
|
|
|
view.fov = 90
|
2023-10-02 01:25:47 -04:00
|
|
|
if false and camera then
|
2023-09-23 22:51:35 -04:00
|
|
|
view.origin = camera.Pos
|
|
|
|
view.angles = camera.Ang
|
|
|
|
view.fov = camera.FOV or 60
|
2023-09-06 04:06:14 -04:00
|
|
|
if camera.Special then
|
|
|
|
view.origin, view.angles, view.fov = camera.Special( camera, ply )
|
|
|
|
end
|
2023-09-23 22:51:35 -04:00
|
|
|
end
|
|
|
|
|
2023-11-18 00:29:04 -05:00
|
|
|
local wep = ply:BennyCheck()
|
|
|
|
if wep then -- and ply:GetActiveWeapon():GetAim() > 0 then
|
2024-03-07 20:27:18 -05:00
|
|
|
--local cv = wep:bWepClass( true ) and wep:bWepClass( true ).Custom_CalcView or wep:bWepClass( false ) and wep:bWepClass( false ).Custom_CalcView
|
2023-11-18 00:29:04 -05:00
|
|
|
local halt = false
|
2024-03-07 20:27:18 -05:00
|
|
|
--if cv then
|
|
|
|
-- halt = cv( wep, view, view.origin, view.angles, view.fov )
|
|
|
|
--end
|
2023-11-18 00:29:04 -05:00
|
|
|
if !halt then
|
|
|
|
view.drawviewer = true
|
|
|
|
view.origin, view.angles, view.fov = bennyfp( view.origin, view.angles, view.fov )
|
|
|
|
end
|
2023-09-23 22:51:35 -04:00
|
|
|
end
|
2023-09-06 04:06:14 -04:00
|
|
|
|
2023-12-17 19:47:52 -05:00
|
|
|
local st = ConVarCL_String("cam_override")
|
2023-09-23 22:51:35 -04:00
|
|
|
if st != "" then
|
|
|
|
local st = string.Explode( " ", st )
|
|
|
|
view.origin.x = tonumber(st[1])
|
|
|
|
view.origin.y = tonumber(st[2])
|
|
|
|
view.origin.z = tonumber(st[3])
|
2023-09-06 04:06:14 -04:00
|
|
|
|
2023-09-23 22:51:35 -04:00
|
|
|
view.angles.x = tonumber(st[4])
|
|
|
|
view.angles.y = tonumber(st[5])
|
|
|
|
view.angles.z = tonumber(st[6])
|
2023-09-06 04:06:14 -04:00
|
|
|
|
2023-09-23 22:51:35 -04:00
|
|
|
view.fov = tonumber(st[7])
|
2023-09-06 04:06:14 -04:00
|
|
|
end
|
2023-09-23 22:51:35 -04:00
|
|
|
|
2023-10-09 03:00:32 -04:00
|
|
|
if globhit then
|
|
|
|
globhit:Set( view.origin )
|
|
|
|
globang:Set( view.angles )
|
|
|
|
end
|
2023-10-02 01:25:47 -04:00
|
|
|
|
2023-09-23 22:51:35 -04:00
|
|
|
view.fov = Convert( view.fov, (ScrH()/ScrW())/(3/4) )
|
|
|
|
return view
|
2023-09-06 04:06:14 -04:00
|
|
|
end )
|
|
|
|
|
|
|
|
function Convert( fovDegrees, ratio )
|
|
|
|
local halfAngleRadians = fovDegrees * ( 0.5 * math.pi / 180 )
|
|
|
|
local t = math.tan( halfAngleRadians )
|
|
|
|
t = t * ratio
|
|
|
|
local retDegrees = ( 180 / math.pi ) * math.atan( t )
|
|
|
|
return retDegrees * 2
|
|
|
|
end
|
|
|
|
|
|
|
|
concommand.Add( "benny_dev_eyetrace", function( ply )
|
|
|
|
local tr = ply:GetEyeTrace()
|
2023-09-06 05:33:02 -04:00
|
|
|
print( string.format("Vector( %i, %i, %i )", math.Round( tr.HitPos.x ), math.Round( tr.HitPos.y ), math.Round( tr.HitPos.z ) ) )
|
2023-09-06 04:06:14 -04:00
|
|
|
print( tr.Entity )
|
2023-12-06 21:02:12 -05:00
|
|
|
end)
|
|
|
|
|
|
|
|
if game.GetMap():Left( 13 ) == "bennysurvive_" then
|
|
|
|
local ourMat = Material( "color" )
|
|
|
|
hook.Add("PostDraw2DSkyBox", "ExampleHook", function()
|
|
|
|
local r, g, b = render.GetFogColor()
|
|
|
|
r=(r+1)/255
|
|
|
|
g=(g+1)/255
|
|
|
|
b=(b+1)/255
|
|
|
|
local v = Vector( r, g, b )
|
|
|
|
render.OverrideDepthEnable( true, false ) -- ignore Z to prevent drawing over 3D skybox
|
|
|
|
ourMat:SetVector( "$color", v )
|
|
|
|
render.SetMaterial( ourMat )
|
|
|
|
render.DrawScreenQuadEx( 0, 0, ScrW(), ScrH() )
|
|
|
|
render.OverrideDepthEnable( false, false )
|
|
|
|
end)
|
|
|
|
end
|