Cinematic intro added

master
AlmTech 5 years ago
parent 7178897511
commit ffe697b6e4
  1. 2
      gamemode/engine/core/server/sv_player_init.lua
  2. 9
      gamemode/engine/core/sh_player_binds.lua
  3. 49
      gamemode/engine/derma/menus/menu_intro.lua
  4. 42
      gamemode/engine/lib/client/cl_cinematic.lua

@ -25,7 +25,7 @@ end
function GM:PlayerSpawn( ply ) function GM:PlayerSpawn( ply )
if( !ply.isloaded ) then if( ply.isloaded ) then -- replace logic ( reversed )
ply:Spectate( OBS_MODE_FIXED ) ply:Spectate( OBS_MODE_FIXED )
Quantum.Net.OpenMenu( ply, "character", Quantum.Server.Char.GetPlayerChars( ply ) ) Quantum.Net.OpenMenu( ply, "character", Quantum.Server.Char.GetPlayerChars( ply ) )
else else

@ -14,13 +14,16 @@ if SERVER then
end, end,
["openCharMenu"] = function( pl ) ["openCharMenu"] = function( pl )
Quantum.Net.OpenMenu( pl, "character", Quantum.Server.Char.GetPlayerChars_cl( pl ) ) Quantum.Net.OpenMenu( pl, "character", Quantum.Server.Char.GetPlayerChars_cl( pl ) )
end,
["introTest"] = function( pl )
Quantum.Net.OpenMenu( pl, "intro", Quantum.Server.Char.GetPlayerChars_cl( pl ) )
end end
} }
function GM:KeyRelease( ply, key ) function GM:KeyRelease( ply, key )
if( keyfuncs[key] ) then keyfuncs[key]( ply ) end if( keyfuncs[key] ) then keyfuncs[key]( ply ) end
end end
function GM:ShowHelp( ply ) function GM:ShowHelp( ply ) keyfuncs["openCharMenu"]( ply ) end
keyfuncs["openCharMenu"]( ply ) function GM:ShowTeam( ply ) keyfuncs["introTest"]( ply ) end
end
end end

@ -0,0 +1,49 @@
-- __ _ _______ _ __
-- / / /\ | | |__ __| | | \ \
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > >
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
local intro = {}
function intro.open( dt )
local chars = dt.cont
local resScale = Quantum.Client.ResolutionScale
local sw, sh = ScrW(), ScrH()
local padding = 10 * resScale
local padding_s = 4 * resScale
if( !f ) then
Quantum.Client.IsInMenu = true -- hide the hud
local f = vgui.Create( "DFrame" )
f:SetSize( sw, sh )
f:SetTitle( "Cinematic Intro Test" )
f.Paint = function( self ) end
f:SetDraggable( false )
f:MakePopup()
function f:OnClose()
Quantum.Client.IsInMenu = false
Quantum.Client.Cam.Stop() -- stop the cinematic
end
local scene = {
pos1 = Vector(6879, 4135, 72),
pos2 = Vector(8760, 2740, 86),
ang1 = Angle(7, 122, 0),
ang2 = Angle(1, -104, 0)
}
local scene2 = {
pos1 = Vector( 8917, 2194, 83 ),
pos2 = Vector( 8312, 2265, 83 ),
ang1 = Angle( 2, -123, 0 ),
ang2 = Angle( 3, -41, 0 )
}
Quantum.Client.Cam.Start( {[1] = scene, [2] = scene2}, 80, {[1] = 10, [2] = 8}, false ) -- start the cinematic
end
end
return intro

@ -9,31 +9,43 @@
function Quantum.Client.Cam.InvertAngle( ang ) return Angle( -ang.x, ang.y, -ang.z ) end -- Flip the camera 180* relative to target function Quantum.Client.Cam.InvertAngle( ang ) return Angle( -ang.x, ang.y, -ang.z ) end -- Flip the camera 180* relative to target
function Quantum.Client.Cam.Stop()
hook.Remove( "CalcView", "Quantum_Cinematic" )
Quantum.Client.Cam.Temp.scene_index = nil -- remove the var becuase it is unneeded
Quantum.Debug( "Stopped cinematic." )
end
function Quantum.Client.Cam.Start( scene, fov, velocity, loop ) function Quantum.Client.Cam.Start( scene, fov, velocity, loop )
local frac = 0 local frac = 0
local time = velocity || 10 -- speed of the camera ( how long till it reaches its finish point ) local time -- speed of the camera ( how long till it reaches its finish point )
local scene_index = 1 Quantum.Client.Cam.Temp = {}
Quantum.Client.Cam.Temp.scene_index = 1
local view = {} -- calcview vector data local view = {} -- calcview vector data
scene.pos2 = scene.pos2 || scene.pos1 -- if there is no finish pos then make it stay still at starting pos
scene.ang2 = scene.ang2 || scene.ang1
hook.Remove( "CalcView", "Quantum_Cinematic" ) -- if a cinematic is already running; cancel it hook.Remove( "CalcView", "Quantum_Cinematic" ) -- if a cinematic is already running; cancel it
hook.Add( "CalcView", "Quantum_Cinematic", function( ply, pos, ang, fov ) hook.Add( "CalcView", "Quantum_Cinematic", function( ply, pos, ang, fov )
frac = math.Clamp( frac + FrameTime()/velocity, 0, 1 ) time = velocity[Quantum.Client.Cam.Temp.scene_index] || 5
frac = math.Clamp( frac + FrameTime()/time, 0, 1 )
if( frac <= 0 ) then return end if( frac <= 0 ) then return end
view.origin = LerpVector( frac, scene.pos1[scene_index], scene.pos2[scene_index] ), scene[Quantum.Client.Cam.Temp.scene_index].pos2 = scene[Quantum.Client.Cam.Temp.scene_index].pos2 || scene[Quantum.Client.Cam.Temp.scene_index].pos1 -- if there is no finish pos then make it stay still at starting pos
view.angles = LerpAngle( frac, scene.ang1[scene_index], scene.ang2[scene_index] ), scene[Quantum.Client.Cam.Temp.scene_index].ang2 = scene[Quantum.Client.Cam.Temp.scene_index].ang2 || scene[Quantum.Client.Cam.Temp.scene_index].ang1
view.fov = fov,
view.origin = LerpVector( frac, scene[Quantum.Client.Cam.Temp.scene_index].pos1, scene[Quantum.Client.Cam.Temp.scene_index].pos2 )
view.angles = LerpAngle( frac, scene[Quantum.Client.Cam.Temp.scene_index].ang1, scene[Quantum.Client.Cam.Temp.scene_index].ang2 )
view.fov = fov
view.drawviewer = true view.drawviewer = true
if( view.origin:IsEqualTol( scene.pos2[scene_index], 2 ) ) then if( view.origin:IsEqualTol( scene[Quantum.Client.Cam.Temp.scene_index].pos2, 1 ) ) then
frac = 0 if( Quantum.Client.Cam.Temp.scene_index + 1 <= #scene ) then
scene_index = scene_index + 1 frac = 0
if( scene_index > #scene.pos1 && loop ) then scene_index = 1 end -- if all scenes are finished, loop them if loop is enabled Quantum.Client.Cam.Temp.scene_index = Quantum.Client.Cam.Temp.scene_index + 1
end
if( Quantum.Client.Cam.Temp.scene_index > #scene ) then -- if all scenes are finished, loop them if loop is enabled
Quantum.Client.Cam.Temp.scene_index = 1
end
-- otherwise it will just stop at the end. -- otherwise it will just stop at the end.
end end
@ -41,7 +53,3 @@ function Quantum.Client.Cam.Start( scene, fov, velocity, loop )
end) end)
end end
function Quantum.Client.Cam.Stop()
hook.Remove( "CalcView", "Quantum_Cinematic" )
Quantum.Debug( "Stopped cinematic." )
end
Loading…
Cancel
Save