Shotgun reloading, nicer UI, mroe

This commit is contained in:
Fesiug 2023-12-22 09:07:47 -05:00
parent 5baa31e570
commit 7215d129dd
16 changed files with 213 additions and 56 deletions

View File

@ -6,13 +6,23 @@ function SWEP:Reload()
if self:GetDelayReload() > CurTime() then
return false
end
if self:GetShotgunReloading() == 1 then
return false
end
if self:Clip1() >= self.Primary.ClipSize then
return false
end
if self.ShotgunReloading then
self:SendWeaponAnim( ACT_SHOTGUN_RELOAD_START )
self:GetOwner():GetViewModel():SetPlaybackRate( 2.5 )
self:SetDelayReload( CurTime() + 0.1 )
self:SetShotgunReloading( 1 )
else
self:SendWeaponAnim( ACT_VM_RELOAD )
self:GetOwner():GetViewModel():SetPlaybackRate( 2.5 )
self:SetDelayReload( CurTime() + self:SequenceDuration()/2.5 )
self:SetRefillTime( CurTime() + self:SequenceDuration()/2.5 )
--self:SetClip1( self.Primary.ClipSize )
end
return true
end

View File

@ -45,7 +45,7 @@ function SWEP:PrimaryAttack( mine )
self:FireBullets( {
Attacker = self:GetOwner(),
Tracer = 1,
Damage = 25,
Damage = self.DamageClose,
Force = 1,
Num = 1,
Dir = newdir,

View File

@ -45,7 +45,23 @@ function SWEP:Think()
self:SetBubbleRecoil( math.Approach( self:GetBubbleRecoil(), up and 1 or 0, FrameTime()/(up and self.BubbleRecoilUp or self.BubbleRecoilDown) ) )
if self:GetRefillTime() != -1 and CurTime() >= self:GetRefillTime() then
self:SetClip1( self.Primary.ClipSize )
self:SetClip1( self.ShotgunReloading and (self:Clip1() + 1) or self.Primary.ClipSize )
self:SetRefillTime( -1 )
end
if self:GetShotgunReloading() == 1 then
if p:KeyDown( IN_ATTACK ) or (self:GetDelayReload() <= CurTime() and self:Clip1() == self.Primary.ClipSize) then
self:SendWeaponAnim( ACT_SHOTGUN_RELOAD_FINISH )
self:GetOwner():GetViewModel():SetPlaybackRate( 2.5 )
self:SetRefillTime( -1 )
self:SetShotgunReloading( 0 )
else
if self:GetDelayReload() <= CurTime() then
self:SendWeaponAnim( ACT_VM_RELOAD )
self:GetOwner():GetViewModel():SetPlaybackRate( 2.5 )
self:SetDelayReload( CurTime() + 0.2 )
self:SetRefillTime( CurTime() + 0.1 )
end
end
end
end

View File

@ -76,6 +76,7 @@ function SWEP:SetupDataTables()
self:NetworkVar( "Float", 4, "BubbleSpread" )
self:NetworkVar( "Float", 5, "BubbleRecoil" )
self:NetworkVar( "Int", 0, "BurstCount" )
self:NetworkVar( "Int", 1, "ShotgunReloading" )
self:SetRefillTime( -1 )
end

View File

@ -24,7 +24,7 @@ SWEP.DamageFar = 11
SWEP.BubbleSpreadUp = 0.2
SWEP.BubbleRecoilUp = 0.2
SWEP.BubbleSpreadDown = 0.3
SWEP.BubbleRecoilDown = 0.3
SWEP.BubbleRecoilDown = 0.2
SWEP.SpreadStart = 1
SWEP.SpreadEnd = 3
@ -32,4 +32,4 @@ SWEP.SpreadEnd = 3
SWEP.RecoilUp = 45
SWEP.RecoilSpeed = 40
SWEP.RecoilDistStart = 2
SWEP.RecoilDistEnd = 3
SWEP.RecoilDistEnd = 5

View File

@ -20,3 +20,5 @@ SWEP.Delay = ( 60 / 180 )
SWEP.MaxBurst = 1
SWEP.DamageClose = 25
SWEP.DamageFar = 13
SWEP.ShotgunReloading = true

View File

@ -17,5 +17,5 @@ SWEP.Sound_Fire = {
SWEP.Primary.ClipSize = 32
SWEP.Delay = ( 60 / 1600 )
SWEP.DamageClose = 25
SWEP.DamageFar = 13
SWEP.DamageClose = 14
SWEP.DamageFar = 10

View File

@ -20,3 +20,5 @@ SWEP.Delay = ( 60 / 80 )
SWEP.MaxBurst = 1
SWEP.DamageClose = 25
SWEP.DamageFar = 13
SWEP.ShotgunReloading = true

View File

@ -1,7 +1,7 @@
SWEP.Base = "cnr"
SWEP.PrintName = "SWORDFISH DELUXE"
SWEP.PrintName = "SWORDFISH-5"
SWEP.Slot = 0
SWEP.ViewModel = "models/weapons/cstrike/c_smg_mp5.mdl"
@ -17,5 +17,18 @@ SWEP.Sound_Fire = {
SWEP.Primary.ClipSize = 30
SWEP.Delay = ( 60 / 900 )
SWEP.DamageClose = 25
SWEP.DamageFar = 13
SWEP.DamageClose = 16
SWEP.DamageFar = 10
SWEP.BubbleSpreadUp = 0.8
SWEP.BubbleRecoilUp = 0.8
SWEP.BubbleSpreadDown = 0.2
SWEP.BubbleRecoilDown = 0.2
SWEP.SpreadStart = 0
SWEP.SpreadEnd = 10
SWEP.RecoilUp = 60
SWEP.RecoilSpeed = 180
SWEP.RecoilDistStart = 1
SWEP.RecoilDistEnd = 5

View File

@ -22,7 +22,7 @@ SWEP.DamageClose = 25
SWEP.DamageFar = 21
SWEP.BubbleSpreadUp = 0.8
SWEP.BubbleRecoilUp = 0.8
SWEP.BubbleRecoilUp = 0.2
SWEP.BubbleSpreadDown = 0.1
SWEP.BubbleRecoilDown = 0.1
@ -32,4 +32,4 @@ SWEP.SpreadEnd = 4
SWEP.RecoilUp = 33
SWEP.RecoilSpeed = 60
SWEP.RecoilDistStart = 0.8
SWEP.RecoilDistEnd = 2.2
SWEP.RecoilDistEnd = 4

View File

@ -22,7 +22,7 @@ SWEP.DamageClose = 25
SWEP.DamageFar = 13
SWEP.BubbleSpreadUp = 0.6
SWEP.BubbleRecoilUp = 0.6
SWEP.BubbleRecoilUp = 0.3
SWEP.BubbleSpreadDown = 0.2
SWEP.BubbleRecoilDown = 0.2
@ -31,5 +31,5 @@ SWEP.SpreadEnd = 5
SWEP.RecoilUp = 45
SWEP.RecoilSpeed = 60
SWEP.RecoilDistStart = 1
SWEP.RecoilDistEnd = 3
SWEP.RecoilDistStart = 2
SWEP.RecoilDistEnd = 4

View File

@ -34,6 +34,18 @@ surface.CreateFont( "CNR_HUD_4", {
weight = 0,
})
surface.CreateFont( "CNR_SEL_1", {
font = "Bahnschrift Light",
size = ScreenScaleH(18),
weight = 0,
})
surface.CreateFont( "CNR_SEL_2", {
font = "Bahnschrift Light",
size = ScreenScaleH(10),
weight = 0,
})
local special1 = {
normal = 12,
colon = 5,
@ -147,12 +159,12 @@ hook.Add("HUDPaint", "CNR_HUD", function()
MonoDraw( fuckhead, "CNR_HUD_4", b_x + b, b_y + s(12), color_black, false, special1 )
do
local n_w, n_h = s(128), s(42)
local n_w, n_h = s(56), s(42)
local n_x, n_y = b_x + b + b_w, b_y
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(), "CNR_HUD_4", n_x + b, n_y + s(12), color_black )
draw.SimpleText( "ROUND", "CNR_HUD_3", n_x + b, n_y + s(4), color_black )
draw.SimpleText( gamelogic:GetRound() .. "/" .. CONVARS["rounds_max"]:GetInt(), "CNR_HUD_4", n_x + b, n_y + s(12), color_black )
end
end

View File

@ -1,5 +1,20 @@
local teams = {
function GM:ShowTeam()
if IsValid( teampanel ) then teampanel:Remove() return end
local s = ScreenScaleH
teampanel = vgui.Create( "DFrame" )
teampanel:SetSize( s(320), s(240) )
teampanel:Center()
teampanel:MakePopup()
function teampanel:Paint( w, h )
surface.SetDrawColor( color_white )
surface.DrawRect( 0, 0, w, h )
return true
end
-- the ids are undefined pretty early and whatever
local teams = {
{
Name = "Side A",
ID = TEAM_SIDEA,
@ -12,25 +27,15 @@ local teams = {
Name = "Spectate",
ID = TEAM_SPECTATOR,
},
}
function GM:ShowTeam()
if IsValid( teampanel ) then teampanel:Remove() return end
local s = ScreenScaleH
teampanel = vgui.Create( "DFrame" )
teampanel:SetSize( s(320), s(160) )
teampanel:Center()
teampanel:MakePopup()
function teampanel:Paint( w, h )
surface.SetDrawColor( color_white )
surface.DrawRect( 0, 0, w, h )
return true
end
{
Name = "Auto-Select",
ID = true,
},
}
for i, v in ipairs( teams ) do
local button = teampanel:Add( "DButton" )
button:SetSize( s(320), s(32) )
button:SetSize( s(320), s(48) )
button:DockMargin( 0, s(2), 0, 0 )
button:Dock( TOP )
@ -40,12 +45,50 @@ function GM:ShowTeam()
surface.SetDrawColor( color_black )
surface.DrawOutlinedRect( 0, 0, w, h, s(1) )
draw.SimpleText( v.Name, "CNR_HUD_1", s(4), s(4), color_black )
draw.SimpleText( v.Name, "CNR_SEL_1", s(4), s(4), color_black )
local plys = team.GetPlayers( v.ID )
local mew = { [1] = {} }
local curr = 1
for _, v in ipairs( plys ) do
local concat = ""
local nick = v:Nick()
if #nick > 8 then
nick = nick:Left(8) .. ".."
end
concat = concat .. nick
--if i!= #plys then
-- concat = concat .. ", "
--end
if #mew[curr] > 5 then
curr = curr + 1
end
if !mew[curr] then
mew[curr] = {}
end
table.insert( mew[curr], concat )
end
local bump = 0
for _, row in ipairs( mew ) do
bump = 0
for i, v in ipairs( row ) do
local tada = v .. ((i!=#row) and ", " or "")
draw.SimpleText( tada, "CNR_SEL_2", s(4)+bump, s(4+16 + s((_-1)*4)), color_black )
surface.SetFont( "CNR_SEL_2" )
bump = bump + surface.GetTextSize( tada )
end
end
return true
end
function button:DoClick()
if v.ID == true then
RunConsoleCommand( "changeteam", team.BestAutoJoinTeam() )
else
RunConsoleCommand( "changeteam", v.ID )
end
teampanel:Remove()
end
end

View File

@ -45,6 +45,23 @@ if SERVER then
-- Begin pregame
state = STATE_PREGAME
gamelogic:SetPregameStartedAt( RealTime() )
net.Start( "CNR_Logic_Pregame" )
net.Broadcast()
-- Begin preparations for a new round
gamelogic:SetMoney( 0 )
-- Swap teams
if CONVARS["rounds_swap"]:GetBool() and gamelogic:GetRound() > (gamelogic:GetSwappedAtRound()-1)+CONVARS["rounds_swap"]:GetInt() then
gamelogic:SetTeamSwap( !gamelogic:GetTeamSwap() )
gamelogic:SetSwappedAtRound( gamelogic:GetRound() )
end
LOGIC:SetSpawnpoints()
for i, v in player.Iterator() do
v:Spawn()
end
end
end
@ -69,6 +86,7 @@ if SERVER then
gamelogic:SetRoundFinishedAt( RealTime() )
net.Start( "CNR_Logic_Postgame" )
net.Broadcast()
gamelogic:SetRound( gamelogic:GetRound() + 1 )
end
end
@ -76,10 +94,11 @@ if SERVER then
if (gamelogic:GetRoundFinishedAt() + CONVARS["time_postgame"]:GetInt()) <= RealTime() then
state = STATE_PREGAME
gamelogic:SetPregameStartedAt( RealTime() )
net.Start( "CNR_Logic_Pregame" )
net.Broadcast()
-- Begin preparations for a new round
gamelogic:SetMoney( 0 )
gamelogic:SetRound( gamelogic:GetRound() + 1 )
-- Swap teams
if CONVARS["rounds_swap"]:GetBool() and gamelogic:GetRound() > (gamelogic:GetSwappedAtRound()-1)+CONVARS["rounds_swap"]:GetInt() then
@ -92,8 +111,6 @@ if SERVER then
for i, v in player.Iterator() do
v:Spawn()
end
net.Start( "CNR_Logic_Pregame" )
net.Broadcast()
end
end

View File

@ -58,8 +58,12 @@ function GM:ScalePlayerDamage( ply, hitgroup, dmginfo )
end
function GM:PlayerInitialSpawn( pl, transition )
if pl:IsBot() then
pl:SetTeam( team.BestAutoJoinTeam() )
else
pl:SetTeam( TEAM_UNASSIGNED )
pl:ConCommand( "gm_showteam" )
end
end
function GM:PlayerSpawnAsSpectator( pl )
pl:StripWeapons()
@ -156,3 +160,34 @@ hook.Add( "Move", "CNR_Move", function( ply, mv )
mv:SetMaxSpeed( 0 )
end
end)
if SERVER then
util.AddNetworkString( "CNR_Kill" )
function GM:DoPlayerDeath( ply, attacker, dmginfo )
ply:CreateRagdoll()
ply:AddDeaths( 1 )
if ( attacker:IsValid() && attacker:IsPlayer() ) then
if ( attacker == ply ) then
attacker:AddFrags( -1 )
else
attacker:AddFrags( 1 )
end
end
net.Start( "CNR_Kill" )
net.WriteEntity( ply )
net.WriteEntity( attacker )
net.WriteEntity( dmginfo:GetInflictor() )
net.Broadcast()
end
else
local c_attacker = Color( 255, 100, 100 )
local c_victim = Color( 100, 100, 255 )
net.Receive( "CNR_Kill", function()
local victim = net.ReadEntity()
local attacker = net.ReadEntity()
local inflictor = net.ReadEntity()
chat.AddText( c_attacker, attacker:Nick(), color_white, " [", inflictor:GetPrintName(), "] ", c_victim, victim:Nick(), color_white )
end)
end

View File

@ -5,13 +5,6 @@ GM.Email = "publicfesiug@outlook.com"
GM.Website = "https://github.com/Fesiug/copsnrobbers"
GM.TeamBased = true
AddCSLuaFile("cl_hud.lua")
AddCSLuaFile("cl_selectteam.lua")
if CLIENT then
include ("cl_hud.lua")
include ("cl_selectteam.lua")
end
AddCSLuaFile("player_class_cnr.lua")
include ("player_class_cnr.lua")
@ -21,6 +14,13 @@ AddCSLuaFile("logic.lua")
AddCSLuaFile("playerbs.lua")
include ("playerbs.lua")
AddCSLuaFile("cl_hud.lua")
AddCSLuaFile("cl_selectteam.lua")
if CLIENT then
include ("cl_hud.lua")
include ("cl_selectteam.lua")
end
function GM:Initialize()
-- Do stuff
end
@ -39,4 +39,10 @@ concommand.Add( "cnr_cheat_weapons", function( p )
p:Give( "cnr_usp" )
end)
if SERVER then
function GM:ShowTeam( ply )
ply:SendLua( "GAMEMODE:ShowTeam()" )
end
end
-- Include module loader here