Recoil tweaks, no move in pregame, sound,
This commit is contained in:
parent
dd680e2b4b
commit
5baa31e570
|
@ -65,6 +65,10 @@ function SWEP:PrimaryAttack( mine )
|
|||
|
||||
recoil.dist = Lerp( self:GetBubbleRecoil(), self.RecoilDistStart, self.RecoilDistEnd ) -- total distance to travel
|
||||
|
||||
--recoil.up2 = recoil.up + 180
|
||||
--recoil.speed2 = recoil.speed * 0.25
|
||||
--recoil.dist2 = recoil.dist
|
||||
|
||||
table.insert( self.RecoilTable, recoil )
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,16 +7,31 @@ function SWEP:Think()
|
|||
if CLIENT and IsFirstTimePredicted() then
|
||||
for i, data in pairs( self.RecoilTable ) do
|
||||
local ft = FrameTime()
|
||||
local fp = ft * data.speed
|
||||
data.dist = math.Approach( data.dist, 0, fp )
|
||||
|
||||
local diff = data.dist - math.Approach( data.dist, 0, ft * data.speed )
|
||||
data.dist = math.Approach( data.dist, 0, ft * data.speed )
|
||||
local m_p, m_y = math.cos(math.rad(data.up)), math.sin(math.rad(data.up))
|
||||
|
||||
local p_p, p_y = m_p * fp, m_y * fp
|
||||
local p_p, p_y = m_p * diff, m_y * diff
|
||||
|
||||
p:SetEyeAngles( p:EyeAngles() - Angle( p_p, p_y, 0 ) )
|
||||
if data.dist == 0 then
|
||||
self.RecoilTable[i] = nil
|
||||
|
||||
if data.up2 then
|
||||
if data.dist == 0 then
|
||||
local diff = data.dist2 - math.Approach( data.dist2, 0, ft * data.speed2 )
|
||||
data.dist2 = math.Approach( data.dist2, 0, ft * data.speed2 )
|
||||
local m_p, m_y = math.cos(math.rad(data.up2)), math.sin(math.rad(data.up2))
|
||||
|
||||
local p_p, p_y = m_p * diff, m_y * diff
|
||||
|
||||
p:SetEyeAngles( p:EyeAngles() - Angle( p_p, p_y, 0 ) )
|
||||
end
|
||||
if data.dist2 == 0 then
|
||||
self.RecoilTable[i] = nil
|
||||
end
|
||||
else
|
||||
if data.dist == 0 then
|
||||
self.RecoilTable[i] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -37,7 +37,7 @@ SWEP.SpreadEnd = 10
|
|||
|
||||
SWEP.RecoilUp = 33
|
||||
SWEP.RecoilSpeed = 90
|
||||
SWEP.RecoilDistStart = 0
|
||||
SWEP.RecoilDistStart = 1
|
||||
SWEP.RecoilDistEnd = 10
|
||||
SWEP.RecoilDistFunc = math.ease.InExpo
|
||||
|
||||
|
|
|
@ -31,5 +31,5 @@ SWEP.SpreadEnd = 3
|
|||
|
||||
SWEP.RecoilUp = 45
|
||||
SWEP.RecoilSpeed = 40
|
||||
SWEP.RecoilDistStart = 1
|
||||
SWEP.RecoilDistStart = 2
|
||||
SWEP.RecoilDistEnd = 3
|
|
@ -105,6 +105,9 @@ hook.Add("HUDPaint", "CNR_HUD", function()
|
|||
for i, ent in ents.Iterator() do
|
||||
if ( ent:GetClass() == "cnr_logic" ) then gamelogic = ent print("Located CNR game logic entity") break end
|
||||
end
|
||||
if !gamelogic:IsValid() then
|
||||
print("Couldn't locate CNR game logic entity!")
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
|
@ -149,7 +152,7 @@ hook.Add("HUDPaint", "CNR_HUD", function()
|
|||
surface.SetDrawColor( color_white )
|
||||
surface.DrawRect( n_x, n_y, n_w, n_h )
|
||||
draw.SimpleText( "ROUND NUMBER", "CNR_HUD_3", n_x + b, n_y + s(4), color_black )
|
||||
draw.SimpleText( gamelogic:GetRound() .. " - " .. gamelogic:GetSwappedAtRound() .. " : " .. (gamelogic:GetTeamSwap() and "Swap" or "Not"), "CNR_HUD_4", n_x + b, n_y + s(12), color_black )
|
||||
draw.SimpleText( gamelogic:GetRound(), "CNR_HUD_4", n_x + b, n_y + s(12), color_black )
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1 +1,11 @@
|
|||
include("shared.lua")
|
||||
|
||||
net.Receive("CNR_Logic_Ingame", function()
|
||||
Entity(0):EmitSound( "cnr/events/start.ogg", 0, 100, 0.5, CHAN_STATIC )
|
||||
end)
|
||||
net.Receive("CNR_Logic_Postgame", function()
|
||||
Entity(0):EmitSound( "cnr/events/win.ogg", 0, 100, 0.5, CHAN_STATIC )
|
||||
end)
|
||||
net.Receive("CNR_Logic_Pregame", function()
|
||||
Entity(0):EmitSound( "cnr/events/pregame.ogg", 0, 100, 0.5, CHAN_STATIC )
|
||||
end)
|
|
@ -16,6 +16,9 @@ STATE_INGAME = 3
|
|||
STATE_POSTGAME = 4
|
||||
|
||||
if SERVER then
|
||||
util.AddNetworkString("CNR_Logic_Ingame")
|
||||
util.AddNetworkString("CNR_Logic_Postgame")
|
||||
util.AddNetworkString("CNR_Logic_Pregame")
|
||||
gamelogic = NULL
|
||||
hook.Add( "Think", "CNR_GameLogic", function()
|
||||
if !gamelogic:IsValid() then
|
||||
|
@ -54,6 +57,8 @@ if SERVER then
|
|||
-- Begin round
|
||||
state = STATE_INGAME
|
||||
gamelogic:SetRoundStartedAt( RealTime() )
|
||||
net.Start( "CNR_Logic_Ingame" )
|
||||
net.Broadcast()
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -62,6 +67,8 @@ if SERVER then
|
|||
if (gamelogic:GetRoundStartedAt() + CONVARS["time_round"]:GetInt()) <= RealTime() then
|
||||
state = STATE_POSTGAME
|
||||
gamelogic:SetRoundFinishedAt( RealTime() )
|
||||
net.Start( "CNR_Logic_Postgame" )
|
||||
net.Broadcast()
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -85,6 +92,8 @@ if SERVER then
|
|||
for i, v in player.Iterator() do
|
||||
v:Spawn()
|
||||
end
|
||||
net.Start( "CNR_Logic_Pregame" )
|
||||
net.Broadcast()
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -96,7 +105,7 @@ LOGIC = {}
|
|||
|
||||
function LOGIC:GetLogic()
|
||||
for i, ent in ents.Iterator() do
|
||||
if ( ent:GetClass() == "cnr_logic" ) then return ent end
|
||||
if ( ent:GetClass() == "cnr_logic" ) and ent.GetState then return ent end
|
||||
end
|
||||
if SERVER then
|
||||
gamelogic = ents.Create( "cnr_logic" )
|
||||
|
|
|
@ -137,3 +137,22 @@ function GM:PlayerSetModel( p )
|
|||
p:SetModel( "models/player/group03/male_07.mdl" )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
hook.Add( "StartCommand", "CNR_StartCommand", function( ply, cmd )
|
||||
if ( ply:IsBot() or !ply:Alive() ) then return end
|
||||
|
||||
local gamelogic = LOGIC:GetLogic()
|
||||
if IsValid( gamelogic ) and gamelogic:GetState() == STATE_PREGAME then
|
||||
cmd:ClearMovement()
|
||||
cmd:ClearButtons()
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add( "Move", "CNR_Move", function( ply, mv )
|
||||
local gamelogic = LOGIC:GetLogic()
|
||||
if IsValid( gamelogic ) and gamelogic:GetState() == STATE_PREGAME then
|
||||
mv:SetMaxClientSpeed( 0 )
|
||||
mv:SetMaxSpeed( 0 )
|
||||
end
|
||||
end)
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue