diff --git a/gamemodes/copsnrobbers/entities/weapons/cnr/sh_shoot.lua b/gamemodes/copsnrobbers/entities/weapons/cnr/sh_shoot.lua index fe78c35..0bd7090 100644 --- a/gamemodes/copsnrobbers/entities/weapons/cnr/sh_shoot.lua +++ b/gamemodes/copsnrobbers/entities/weapons/cnr/sh_shoot.lua @@ -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 diff --git a/gamemodes/copsnrobbers/entities/weapons/cnr/sh_think.lua b/gamemodes/copsnrobbers/entities/weapons/cnr/sh_think.lua index 0773b63..db14560 100644 --- a/gamemodes/copsnrobbers/entities/weapons/cnr/sh_think.lua +++ b/gamemodes/copsnrobbers/entities/weapons/cnr/sh_think.lua @@ -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 diff --git a/gamemodes/copsnrobbers/entities/weapons/cnr/shared.lua b/gamemodes/copsnrobbers/entities/weapons/cnr/shared.lua index e4e76e1..f1477cf 100644 --- a/gamemodes/copsnrobbers/entities/weapons/cnr/shared.lua +++ b/gamemodes/copsnrobbers/entities/weapons/cnr/shared.lua @@ -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 diff --git a/gamemodes/copsnrobbers/entities/weapons/cnr_glock.lua b/gamemodes/copsnrobbers/entities/weapons/cnr_glock.lua index 236518a..0076ee9 100644 --- a/gamemodes/copsnrobbers/entities/weapons/cnr_glock.lua +++ b/gamemodes/copsnrobbers/entities/weapons/cnr_glock.lua @@ -31,5 +31,5 @@ SWEP.SpreadEnd = 3 SWEP.RecoilUp = 45 SWEP.RecoilSpeed = 40 -SWEP.RecoilDistStart = 1 +SWEP.RecoilDistStart = 2 SWEP.RecoilDistEnd = 3 \ No newline at end of file diff --git a/gamemodes/copsnrobbers/gamemode/cl_hud.lua b/gamemodes/copsnrobbers/gamemode/cl_hud.lua index 093a5e3..58959b8 100644 --- a/gamemodes/copsnrobbers/gamemode/cl_hud.lua +++ b/gamemodes/copsnrobbers/gamemode/cl_hud.lua @@ -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 diff --git a/gamemodes/copsnrobbers/gamemode/cl_init.lua b/gamemodes/copsnrobbers/gamemode/cl_init.lua index 33dcc35..b2acdd2 100644 --- a/gamemodes/copsnrobbers/gamemode/cl_init.lua +++ b/gamemodes/copsnrobbers/gamemode/cl_init.lua @@ -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) \ No newline at end of file diff --git a/gamemodes/copsnrobbers/gamemode/logic.lua b/gamemodes/copsnrobbers/gamemode/logic.lua index 7b1f2ae..f3cbf5d 100644 --- a/gamemodes/copsnrobbers/gamemode/logic.lua +++ b/gamemodes/copsnrobbers/gamemode/logic.lua @@ -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" ) diff --git a/gamemodes/copsnrobbers/gamemode/playerbs.lua b/gamemodes/copsnrobbers/gamemode/playerbs.lua index b7a076b..b554ae6 100644 --- a/gamemodes/copsnrobbers/gamemode/playerbs.lua +++ b/gamemodes/copsnrobbers/gamemode/playerbs.lua @@ -136,4 +136,23 @@ function GM:PlayerSetModel( p ) else p:SetModel( "models/player/group03/male_07.mdl" ) end -end \ No newline at end of file +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) \ No newline at end of file diff --git a/sound/cnr/events/lose.ogg b/sound/cnr/events/lose.ogg new file mode 100644 index 0000000..7178729 Binary files /dev/null and b/sound/cnr/events/lose.ogg differ diff --git a/sound/cnr/events/pregame.ogg b/sound/cnr/events/pregame.ogg new file mode 100644 index 0000000..91cea57 Binary files /dev/null and b/sound/cnr/events/pregame.ogg differ diff --git a/sound/cnr/events/start.ogg b/sound/cnr/events/start.ogg new file mode 100644 index 0000000..ecef1ec Binary files /dev/null and b/sound/cnr/events/start.ogg differ diff --git a/sound/cnr/events/win.ogg b/sound/cnr/events/win.ogg new file mode 100644 index 0000000..15b9f29 Binary files /dev/null and b/sound/cnr/events/win.ogg differ