From 3c25c16787d6e860b58201403e8a78da6392311f Mon Sep 17 00:00:00 2001 From: Fesiug Date: Sun, 17 Sep 2023 20:34:13 -0400 Subject: [PATCH] The cutscene entity --- .../entities/entities/benny_cutscene.lua | 16 +++++ .../gamemode/modules/player/cl_camera.lua | 72 ++++++++++++++++++- .../benny/gamemode/modules/player/cl_hud.lua | 2 +- 3 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 gamemodes/benny/entities/entities/benny_cutscene.lua diff --git a/gamemodes/benny/entities/entities/benny_cutscene.lua b/gamemodes/benny/entities/entities/benny_cutscene.lua new file mode 100644 index 0000000..a8ac9c2 --- /dev/null +++ b/gamemodes/benny/entities/entities/benny_cutscene.lua @@ -0,0 +1,16 @@ + +AddCSLuaFile() + +ENT.Base = "base_anim" +ENT.Type = "anim" +ENT.AutomaticFrameAdvance = true + +function ENT:Initialize() + self:SetModel( "models/benny/test.mdl" ) + self:ResetSequence( "test" ) +end + +function ENT:Think() + self:NextThink( CurTime() ) + return true +end \ No newline at end of file diff --git a/gamemodes/benny/gamemode/modules/player/cl_camera.lua b/gamemodes/benny/gamemode/modules/player/cl_camera.lua index 3fef628..25c54d9 100644 --- a/gamemodes/benny/gamemode/modules/player/cl_camera.lua +++ b/gamemodes/benny/gamemode/modules/player/cl_camera.lua @@ -5,6 +5,29 @@ local debugcolor = Color( 255, 0, 255, 1 ) tempmapcameras = {} +tempmapcameras["benny_caramelldansen"] = {} + +tempmapcameras["benny_caramelldansen"]["main"] = { + Type = "Standard", + Pos = Vector( -510, 0, 128 ), + Ang = Angle( 12, 0, 0 ), + FOV = 90, + Checks = { + { + Vector( -512, -512, 64 ), + Vector( 512, 512, -64 ), + }, + }, + Special = function( self, ply ) + local pos = Vector() + pos:Set( self.Pos ) + local ang = Angle() + ang:Set( self.Ang ) + + return pos, ang, self.FOV + end +} + tempmapcameras["benny_test"] = {} tempmapcameras["benny_test"]["main"] = { @@ -163,15 +186,60 @@ local tempcam = { end } +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() -- print( LocalPlayer():GetPos() ) -- BENNY_ACTIVECAMERA = tempcam + + local csent = ents.FindByClass( "benny_cutscene" )[1] + if IsValid( csent ) then + BENNY_ACTIVECAMERA = cscam + cuts = csent + return true + end + if tempmapcameras[ game.GetMap() ] then for name, camera in pairs( tempmapcameras[ game.GetMap() ] ) do if camera.Checks then for i, v in ipairs(camera.Checks) do + debugoverlay.Box( vector_origin, v[1], v[2], 0, debugcolor ) if LocalPlayer():GetPos():WithinAABox( v[1], v[2] ) then - debugoverlay.Box( vector_origin, v[1], v[2], 0, debugcolor ) BENNY_ACTIVECAMERA = camera return true end @@ -212,7 +280,7 @@ hook.Add( "CalcView", "MyCalcView", function( ply, pos, ang, fov ) view.fov = tonumber(st[7]) end - view.fov = Convert( view.fov, (ScrH()/ScrW())/(3/4) ) + --view.fov = Convert( view.fov, (ScrH()/ScrW())/(3/4) ) return view end end ) diff --git a/gamemodes/benny/gamemode/modules/player/cl_hud.lua b/gamemodes/benny/gamemode/modules/player/cl_hud.lua index dff8ce7..3a612a9 100644 --- a/gamemodes/benny/gamemode/modules/player/cl_hud.lua +++ b/gamemodes/benny/gamemode/modules/player/cl_hud.lua @@ -141,7 +141,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function() localss = ss(1) local b = ss(20) - local scheme = schemes["yanghao"] + local scheme = schemes["benny"] do -- Health -- BG