BENNY_ACTIVECAMERA = nil 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 } local function decide_active() local csent = ents.FindByClass( "benny_cutscene" )[1] if IsValid( csent ) then BENNY_ACTIVECAMERA = cscam cuts = csent return true end return false end function bennyfp( origin, angles, fov ) local ply = LocalPlayer() if !IsValid( ply:GetActiveWeapon() ) then return origin, angles, fov end local pos, ang = ply:CamSpot( TPSOverride ) return pos, ang, 90 end hook.Add( "CalcView", "Benny_CalcView", function( ply, pos, ang, fov ) if ConVarCL_Bool("cam_unlock") then return end if ply:NoclippingAndNotVaulting() then return end decide_active() local camera = BENNY_ACTIVECAMERA local view = {} view.origin = pos view.angles = ang view.fov = 90 if false and camera then view.origin = camera.Pos view.angles = camera.Ang view.fov = camera.FOV or 60 if camera.Special then view.origin, view.angles, view.fov = camera.Special( camera, ply ) end end local wep = ply:BennyCheck() if wep then -- and ply:GetActiveWeapon():GetAim() > 0 then --local cv = wep:bWepClass( true ) and wep:bWepClass( true ).Custom_CalcView or wep:bWepClass( false ) and wep:bWepClass( false ).Custom_CalcView local halt = false --if cv then -- halt = cv( wep, view, view.origin, view.angles, view.fov ) --end if !halt then view.drawviewer = true view.origin, view.angles, view.fov = bennyfp( view.origin, view.angles, view.fov ) end end local st = ConVarCL_String("cam_override") 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]) view.angles.x = tonumber(st[4]) view.angles.y = tonumber(st[5]) view.angles.z = tonumber(st[6]) view.fov = tonumber(st[7]) end if globhit then globhit:Set( view.origin ) globang:Set( view.angles ) end view.fov = Convert( view.fov, (ScrH()/ScrW())/(3/4) ) return view 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() print( string.format("Vector( %i, %i, %i )", math.Round( tr.HitPos.x ), math.Round( tr.HitPos.y ), math.Round( tr.HitPos.z ) ) ) print( tr.Entity ) 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