diff --git a/copsnrobbers.code-workspace b/copsnrobbers.code-workspace new file mode 100644 index 0000000..8b8a1e8 --- /dev/null +++ b/copsnrobbers.code-workspace @@ -0,0 +1,16 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": { + "editor.detectIndentation": false, + "editor.insertSpaces": false + }, + "extensions": { + "recommendations": [ + "venner.vscode-glua-enhanced" + ] + } +} \ No newline at end of file diff --git a/gamemodes/copsnrobbers/backgrounds/none.png b/gamemodes/copsnrobbers/backgrounds/none.png new file mode 100644 index 0000000..d540125 Binary files /dev/null and b/gamemodes/copsnrobbers/backgrounds/none.png differ diff --git a/gamemodes/copsnrobbers/copsnrobbers.txt b/gamemodes/copsnrobbers/copsnrobbers.txt new file mode 100644 index 0000000..a1c9d6c --- /dev/null +++ b/gamemodes/copsnrobbers/copsnrobbers.txt @@ -0,0 +1,53 @@ +"cg" +{ + "base" "base" + "title" "Cops 'n Robbers" + "maps" "^cnr_" + "category" "pvp" + "menusystem" "1" + // "workshopid" "0" + + "settings" + { + 1 + { + "name" "cnr_roundlength" + "text" "Round length (minutes)" + "help" "" + "type" "Numeric" + "default" "3" + } + 2 + { + "name" "cnr_roundlength" + "text" "Haste time (minutes)" + "help" "" + "type" "Numeric" + "default" "1" + } + 3 + { + "name" "cnr_maxrounds" + "text" "Game ends after X rounds" + "help" "" + "type" "Numeric" + "default" "6" + } + 4 + { + "name" "cnr_teamswap" + "text" "Swap teams after X rounds" + "help" "" + "type" "Numeric" + "default" "2" + } + 5 + { + "name" "cnr_friendlyfire" + "text" "Friendly fire" + "help" "Enable friendly fire" + "type" "CheckBox" + "default" "0" + } + } +} \ No newline at end of file diff --git a/gamemodes/copsnrobbers/entities/entities/cnr_goal.lua b/gamemodes/copsnrobbers/entities/entities/cnr_goal.lua new file mode 100644 index 0000000..e69de29 diff --git a/gamemodes/copsnrobbers/entities/entities/cnr_palette.lua b/gamemodes/copsnrobbers/entities/entities/cnr_palette.lua new file mode 100644 index 0000000..e69de29 diff --git a/gamemodes/copsnrobbers/entities/weapons/cnr/cl_vm.lua b/gamemodes/copsnrobbers/entities/weapons/cnr/cl_vm.lua new file mode 100644 index 0000000..a38519e --- /dev/null +++ b/gamemodes/copsnrobbers/entities/weapons/cnr/cl_vm.lua @@ -0,0 +1,17 @@ + +function SWEP:GetViewModelPosition( pos, ang ) + local p = self:GetOwner() + + local speed = math.Clamp( p:GetVelocity():Length2D()/320, 0, 1 ) + + local newpos, newang = Vector( pos ), Angle( ang ) + + newpos:Add( ang:Right() * self.ActivePos.x ) + newpos:Add( ang:Forward() * self.ActivePos.y ) + newpos:Add( ang:Up() * self.ActivePos.z ) + + newpos:Add( ang:Right() * 2 * math.sin( CurTime() * math.pi * 2 ) * speed ) + newpos:Add( ang:Up() * -0.5 * math.abs( math.sin( CurTime() * math.pi * 2 ) ) * speed ) + + return newpos, newang +end \ No newline at end of file diff --git a/gamemodes/copsnrobbers/entities/weapons/cnr/sh_reload.lua b/gamemodes/copsnrobbers/entities/weapons/cnr/sh_reload.lua new file mode 100644 index 0000000..91e07a3 --- /dev/null +++ b/gamemodes/copsnrobbers/entities/weapons/cnr/sh_reload.lua @@ -0,0 +1,14 @@ + +function SWEP:Reload() + if self:GetDelay() > CurTime() then + return false + end + if self:Clip1() >= self.Primary.ClipSize then + return false + end + self:SendWeaponAnim( ACT_VM_RELOAD ) + self:GetOwner():GetViewModel():SetPlaybackRate( 2.5 ) + self:SetDelay( CurTime() + self:SequenceDuration()/2.5 ) + self:SetClip1( self.Primary.ClipSize ) + return true +end \ No newline at end of file diff --git a/gamemodes/copsnrobbers/entities/weapons/cnr/sh_shoot.lua b/gamemodes/copsnrobbers/entities/weapons/cnr/sh_shoot.lua new file mode 100644 index 0000000..baff605 --- /dev/null +++ b/gamemodes/copsnrobbers/entities/weapons/cnr/sh_shoot.lua @@ -0,0 +1,48 @@ + +function SWEP:Spread() + local spread = math.Clamp( math.TimeFraction( self.SpreadBurstStart, self.SpreadBurstEnd, self:GetBurstCount() ), 0, 1 ) + spread = Lerp( spread, self.SpreadStart, self.SpreadEnd ) + return spread +end + +function SWEP:PrimaryAttack( mine ) + if self:GetDelay() > CurTime() then + return false + end + if self:Clip1() == 0 then + self:EmitSound( "weapons/clipempty_rifle.wav", 90, 100, 1, CHAN_STATIC ) + self:SetDelay( CurTime() + self.Delay ) + return false + end + + if self:GetBurstCount() >= self.MaxBurst then + return false + end + + self:SetDelay( CurTime() + self.Delay ) + self:SetBurstCount( self:GetBurstCount() + 1 ) + self:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) + self:SetClip1( self:Clip1() - 1 ) + + self:EmitSound( self.Sound_Shoot, 90, 100, 1, CHAN_WEAPON ) + + local spread = math.rad( self:Spread() ) + self:FireBullets( { + Attacker = self:GetOwner(), + Tracer = 1, + Damage = 25, + Force = 1, + Num = 1, + Dir = self:GetOwner():EyeAngles():Forward(), + Spread = Vector( spread, spread, 0 ), + Src = self:GetOwner():EyePos(), + Callback = function( attacker, tr, dmginfo ) + end + }) + + return true +end + +function SWEP:SecondaryAttack() + return true +end \ No newline at end of file diff --git a/gamemodes/copsnrobbers/entities/weapons/cnr/sh_think.lua b/gamemodes/copsnrobbers/entities/weapons/cnr/sh_think.lua new file mode 100644 index 0000000..9df4aee --- /dev/null +++ b/gamemodes/copsnrobbers/entities/weapons/cnr/sh_think.lua @@ -0,0 +1,16 @@ + +SWEP.RecoilTable = {} + +function SWEP:Think() + local p = self:GetOwner() + + if CLIENT and IsFirstTimePredicted() then + for i, v in pairs( self.RecoilTable ) do + + end + end + + if !p:KeyDown( IN_ATTACK ) then + self:SetBurstCount( 0 ) + end +end \ No newline at end of file diff --git a/gamemodes/copsnrobbers/entities/weapons/cnr/shared.lua b/gamemodes/copsnrobbers/entities/weapons/cnr/shared.lua new file mode 100644 index 0000000..a4b87fe --- /dev/null +++ b/gamemodes/copsnrobbers/entities/weapons/cnr/shared.lua @@ -0,0 +1,64 @@ + +SWEP.Base = "weapon_base" + +SWEP.PrintName = "CNR weapon base" +SWEP.Slot = 5 + +SWEP.ViewModel = "models/weapons/cstrike/c_rif_ak47.mdl" +SWEP.ViewModelFOV = 90 +SWEP.UseHands = true +SWEP.WorldModel = "models/weapons/w_rif_ak47.mdl" + +SWEP.Sound_Shoot = "weapons/m4a1/m4a1_unsil-1.wav" + +SWEP.Delay = ( 60 / 900 ) +SWEP.MaxBurst = math.huge +SWEP.ActivePos = Vector( 2, -2, -2 ) + +SWEP.SpreadStart = 1 +SWEP.SpreadEnd = 10 +SWEP.SpreadBurstStart = 3 +SWEP.SpreadBurstEnd = 10 + +SWEP.Primary.Ammo = "pistol" +SWEP.Primary.ClipSize = 0 +SWEP.Primary.DefaultClip = 0 +SWEP.Primary.Automatic = true +SWEP.Secondary.Ammo = "none" +SWEP.Secondary.ClipSize = -1 +SWEP.Secondary.DefaultClip = 0 +SWEP.Secondary.Automatic = true + +AddCSLuaFile("sh_think.lua") + include ("sh_think.lua") + +AddCSLuaFile("sh_shoot.lua") + include ("sh_shoot.lua") + +AddCSLuaFile("sh_reload.lua") + include ("sh_reload.lua") + +AddCSLuaFile("cl_vm.lua") +if CLIENT then + include ("cl_vm.lua") +end + +function SWEP:Initialize() + self:SetClip1( self.Primary.ClipSize ) +end + +function SWEP:SetupDataTables() + self:NetworkVar( "Float", 0, "Delay" ) + self:NetworkVar( "Int", 0, "BurstCount" ) +end + +SWEP.m_WeaponDeploySpeed = 10 +SWEP.BobScale = 0 +SWEP.SwayScale = 0 +function SWEP:Deploy() + self:SendWeaponAnim( ACT_VM_IDLE ) + return true +end +function SWEP:Holster() + return true +end \ No newline at end of file diff --git a/gamemodes/copsnrobbers/entities/weapons/cnr_ak47.lua b/gamemodes/copsnrobbers/entities/weapons/cnr_ak47.lua new file mode 100644 index 0000000..6672066 --- /dev/null +++ b/gamemodes/copsnrobbers/entities/weapons/cnr_ak47.lua @@ -0,0 +1,17 @@ + +SWEP.Base = "cnr" + +SWEP.PrintName = "CV-74" +SWEP.Slot = 0 + +SWEP.ViewModel = "models/weapons/cstrike/c_rif_ak47.mdl" +SWEP.ViewModelFOV = 90 +SWEP.WorldModel = "models/weapons/w_rif_ak47.mdl" +SWEP.ActivePos = Vector( 1, -8, -1 ) + +SWEP.Sound_Shoot = "weapons/ak47/ak47-1.wav" + +SWEP.Primary.ClipSize = 30 +SWEP.Delay = ( 60 / 700 ) +SWEP.DamageClose = 25 +SWEP.DamageFar = 13 \ No newline at end of file diff --git a/gamemodes/copsnrobbers/entities/weapons/cnr_glock.lua b/gamemodes/copsnrobbers/entities/weapons/cnr_glock.lua new file mode 100644 index 0000000..a30656e --- /dev/null +++ b/gamemodes/copsnrobbers/entities/weapons/cnr_glock.lua @@ -0,0 +1,18 @@ + +SWEP.Base = "cnr" + +SWEP.PrintName = "CAL.9" +SWEP.Slot = 1 + +SWEP.ViewModel = "models/weapons/cstrike/c_pist_glock18.mdl" +SWEP.ViewModelFOV = 90 +SWEP.WorldModel = "models/weapons/w_pist_glock18.mdl" +SWEP.ActivePos = Vector( 1, -6, -1 ) + +SWEP.Sound_Shoot = "weapons/glock/glock18-1.wav" + +SWEP.Primary.ClipSize = 17 +SWEP.Delay = ( 60 / 500 ) +SWEP.MaxBurst = 1 +SWEP.DamageClose = 22 +SWEP.DamageFar = 11 \ No newline at end of file diff --git a/gamemodes/copsnrobbers/entities/weapons/cnr_m249.lua b/gamemodes/copsnrobbers/entities/weapons/cnr_m249.lua new file mode 100644 index 0000000..440ce53 --- /dev/null +++ b/gamemodes/copsnrobbers/entities/weapons/cnr_m249.lua @@ -0,0 +1,17 @@ + +SWEP.Base = "cnr" + +SWEP.PrintName = "REPT-499" +SWEP.Slot = 0 + +SWEP.ViewModel = "models/weapons/cstrike/c_mach_m249para.mdl" +SWEP.ViewModelFOV = 90 +SWEP.WorldModel = "models/weapons/w_mach_m249para.mdl" +SWEP.ActivePos = Vector( 2, -2, -2 ) + +SWEP.Sound_Shoot = "weapons/p90/p90-1.wav" + +SWEP.Primary.ClipSize = 60 +SWEP.Delay = ( 60 / 700 ) +SWEP.DamageClose = 25 +SWEP.DamageFar = 13 \ No newline at end of file diff --git a/gamemodes/copsnrobbers/entities/weapons/cnr_m4a1.lua b/gamemodes/copsnrobbers/entities/weapons/cnr_m4a1.lua new file mode 100644 index 0000000..a665fb4 --- /dev/null +++ b/gamemodes/copsnrobbers/entities/weapons/cnr_m4a1.lua @@ -0,0 +1,17 @@ + +SWEP.Base = "cnr" + +SWEP.PrintName = "N4A4" +SWEP.Slot = 0 + +SWEP.ViewModel = "models/weapons/cstrike/c_rif_m4a1.mdl" +SWEP.ViewModelFOV = 90 +SWEP.WorldModel = "models/weapons/w_rif_m4a1.mdl" +SWEP.ActivePos = Vector( 2, -2, -2 ) + +SWEP.Sound_Shoot = "weapons/m4a1/m4a1_unsil-1.wav" + +SWEP.Primary.ClipSize = 30 +SWEP.Delay = ( 60 / 900 ) +SWEP.DamageClose = 25 +SWEP.DamageFar = 13 \ No newline at end of file diff --git a/gamemodes/copsnrobbers/entities/weapons/cnr_m4s90.lua b/gamemodes/copsnrobbers/entities/weapons/cnr_m4s90.lua new file mode 100644 index 0000000..f821aa1 --- /dev/null +++ b/gamemodes/copsnrobbers/entities/weapons/cnr_m4s90.lua @@ -0,0 +1,18 @@ + +SWEP.Base = "cnr" + +SWEP.PrintName = "MAXI R90" +SWEP.Slot = 0 + +SWEP.ViewModel = "models/weapons/cstrike/c_shot_xm1014.mdl" +SWEP.ViewModelFOV = 90 +SWEP.WorldModel = "models/weapons/w_shot_xm1014.mdl" +SWEP.ActivePos = Vector( 2, -2, -2 ) + +SWEP.Sound_Shoot = "weapons/xm1014/xm1014-1.wav" + +SWEP.Primary.ClipSize = 5 +SWEP.Delay = ( 60 / 300 ) +SWEP.MaxBurst = 1 +SWEP.DamageClose = 25 +SWEP.DamageFar = 13 \ No newline at end of file diff --git a/gamemodes/copsnrobbers/entities/weapons/cnr_mac10.lua b/gamemodes/copsnrobbers/entities/weapons/cnr_mac10.lua new file mode 100644 index 0000000..9ce5d88 --- /dev/null +++ b/gamemodes/copsnrobbers/entities/weapons/cnr_mac10.lua @@ -0,0 +1,17 @@ + +SWEP.Base = "cnr" + +SWEP.PrintName = "SPITFIRE" +SWEP.Slot = 0 + +SWEP.ViewModel = "models/weapons/cstrike/c_smg_mac10.mdl" +SWEP.ViewModelFOV = 90 +SWEP.WorldModel = "models/weapons/w_smg_mac10.mdl" +SWEP.ActivePos = Vector( 2, -2, -2 ) + +SWEP.Sound_Shoot = "weapons/mac10/mac10-1.wav" + +SWEP.Primary.ClipSize = 32 +SWEP.Delay = ( 60 / 1100 ) +SWEP.DamageClose = 25 +SWEP.DamageFar = 13 \ No newline at end of file diff --git a/gamemodes/copsnrobbers/entities/weapons/cnr_mossberg.lua b/gamemodes/copsnrobbers/entities/weapons/cnr_mossberg.lua new file mode 100644 index 0000000..73d946a --- /dev/null +++ b/gamemodes/copsnrobbers/entities/weapons/cnr_mossberg.lua @@ -0,0 +1,18 @@ + +SWEP.Base = "cnr" + +SWEP.PrintName = "SLIMLINE" +SWEP.Slot = 0 + +SWEP.ViewModel = "models/weapons/cstrike/c_shot_m3super90.mdl" +SWEP.ViewModelFOV = 90 +SWEP.WorldModel = "models/weapons/w_shot_m3super90.mdl" +SWEP.ActivePos = Vector( 2, -2, -2 ) + +SWEP.Sound_Shoot = "weapons/m3/m3-1.wav" + +SWEP.Primary.ClipSize = 4 +SWEP.Delay = ( 60 / 80 ) +SWEP.MaxBurst = 1 +SWEP.DamageClose = 25 +SWEP.DamageFar = 13 \ No newline at end of file diff --git a/gamemodes/copsnrobbers/entities/weapons/cnr_mp5.lua b/gamemodes/copsnrobbers/entities/weapons/cnr_mp5.lua new file mode 100644 index 0000000..112dfad --- /dev/null +++ b/gamemodes/copsnrobbers/entities/weapons/cnr_mp5.lua @@ -0,0 +1,17 @@ + +SWEP.Base = "cnr" + +SWEP.PrintName = "SWORDFISH DELUXE" +SWEP.Slot = 0 + +SWEP.ViewModel = "models/weapons/cstrike/c_smg_mp5.mdl" +SWEP.ViewModelFOV = 90 +SWEP.WorldModel = "models/weapons/w_smg_mp5.mdl" +SWEP.ActivePos = Vector( 2, -2, -2 ) + +SWEP.Sound_Shoot = "weapons/mp5navy/mp5-1.wav" + +SWEP.Primary.ClipSize = 30 +SWEP.Delay = ( 60 / 900 ) +SWEP.DamageClose = 25 +SWEP.DamageFar = 13 \ No newline at end of file diff --git a/gamemodes/copsnrobbers/entities/weapons/cnr_p220.lua b/gamemodes/copsnrobbers/entities/weapons/cnr_p220.lua new file mode 100644 index 0000000..c5d07f6 --- /dev/null +++ b/gamemodes/copsnrobbers/entities/weapons/cnr_p220.lua @@ -0,0 +1,18 @@ + +SWEP.Base = "cnr" + +SWEP.PrintName = "CAL.357" +SWEP.Slot = 1 + +SWEP.ViewModel = "models/weapons/cstrike/c_pist_p228.mdl" +SWEP.ViewModelFOV = 90 +SWEP.WorldModel = "models/weapons/w_pist_p228.mdl" +SWEP.ActivePos = Vector( 1, -6, -1 ) + +SWEP.Sound_Shoot = "weapons/p228/p228-1.wav" + +SWEP.Primary.ClipSize = 13 +SWEP.Delay = ( 60 / 400 ) +SWEP.MaxBurst = 1 +SWEP.DamageClose = 25 +SWEP.DamageFar = 13 \ No newline at end of file diff --git a/gamemodes/copsnrobbers/entities/weapons/cnr_usp.lua b/gamemodes/copsnrobbers/entities/weapons/cnr_usp.lua new file mode 100644 index 0000000..4be0322 --- /dev/null +++ b/gamemodes/copsnrobbers/entities/weapons/cnr_usp.lua @@ -0,0 +1,18 @@ + +SWEP.Base = "cnr" + +SWEP.PrintName = "CAL.45" +SWEP.Slot = 1 + +SWEP.ViewModel = "models/weapons/cstrike/c_pist_usp.mdl" +SWEP.ViewModelFOV = 90 +SWEP.WorldModel = "models/weapons/w_pist_usp.mdl" +SWEP.ActivePos = Vector( 1, -6, -1 ) + +SWEP.Sound_Shoot = "weapons/usp/usp_unsil-1.wav" + +SWEP.Primary.ClipSize = 12 +SWEP.Delay = ( 60 / 400 ) +SWEP.MaxBurst = 1 +SWEP.DamageClose = 25 +SWEP.DamageFar = 13 \ No newline at end of file diff --git a/gamemodes/copsnrobbers/gamemode/cl_hud.lua b/gamemodes/copsnrobbers/gamemode/cl_hud.lua new file mode 100644 index 0000000..e7204c4 --- /dev/null +++ b/gamemodes/copsnrobbers/gamemode/cl_hud.lua @@ -0,0 +1,83 @@ + +local hide = { + ["CHudHealth"] = true, + ["CHudBattery"] = true, + ["CHudAmmo"] = true, + ["CHudSecondaryAmmo"] = true, +} + +hook.Add( "HUDShouldDraw", "HideHUD", function( name ) + if ( hide[ name ] ) then + return false + end +end ) + +surface.CreateFont( "CNR_HUD_1", { + font = "Bahnschrift Light", + size = ScreenScaleH(24), + weight = 0, +}) +surface.CreateFont( "CNR_HUD_2", { + font = "Bahnschrift Bold", + size = ScreenScaleH(48), + weight = 0, +}) + +surface.CreateFont( "CNR_HUD_3", { + font = "Bahnschrift Light", + size = ScreenScaleH(16), + weight = 0, +}) +surface.CreateFont( "CNR_HUD_4", { + font = "Bahnschrift Bold", + size = ScreenScaleH(32), + weight = 0, +}) + +hook.Add("HUDPaint", "CNR_HUD", function() + local p, sw, sh = LocalPlayer(), ScrW(), ScrH() + local c = sw/2 + local s = ScreenScaleH + local c1 = sw*0.125 + local c2 = sw*(1-0.125) + local b = s(8) + + local w = p:GetActiveWeapon() + w = IsValid(w) and w or false + + do + local b_w, b_h = s(64+8), s(64) + local b_x, b_y = c1, sh - b_h - s(16) + surface.SetDrawColor( color_white ) + surface.DrawRect( b_x, b_y, b_w, b_h ) + draw.SimpleText( "HP", "CNR_HUD_1", c1 + b, sh - s(64+12), color_black ) + draw.SimpleText( p:Health(), "CNR_HUD_2", c1 + b, sh - s(64), color_black ) + end + + if w then + local b_w, b_h = s(64+8), s(64) + local b_x, b_y = c2 - b_w, sh - b_h - s(16) + surface.SetDrawColor( color_white ) + surface.DrawRect( b_x, b_y, b_w, b_h ) + draw.SimpleText( "AMMO", "CNR_HUD_1", c2 - b, sh - s(64+12), color_black, TEXT_ALIGN_RIGHT ) + draw.SimpleText( w:Clip1(), "CNR_HUD_2", c2 - b, sh - s(64), color_black, TEXT_ALIGN_RIGHT ) + end + + do + local b_w, b_h = s(82), s(48) + local b_x, b_y = c1, s(16) + surface.SetDrawColor( color_white ) + surface.DrawRect( b_x, b_y, b_w, b_h ) + draw.SimpleText( "TIME", "CNR_HUD_3", b_x + b, b_y + s(4), color_black, TEXT_ALIGN_LEFT ) + draw.SimpleText( string.FormattedTime( -CurTime(), "%02i:%02i"), "CNR_HUD_4", b_x + b, b_y + s(12), color_black, TEXT_ALIGN_LEFT ) + end + + do + local b_w, b_h = s(182), s(32) + local b_x, b_y = c1, s(16+16) + b + b_h + surface.SetDrawColor( color_white ) + surface.DrawRect( b_x, b_y, b_w, b_h ) + draw.SimpleText( "$", "CNR_HUD_4", b_x + b, b_y, color_black, TEXT_ALIGN_LEFT ) + draw.SimpleText( "100,000,000", "CNR_HUD_4", b_x + b_w - b, b_y, color_black, TEXT_ALIGN_RIGHT ) + end +end) \ No newline at end of file diff --git a/gamemodes/copsnrobbers/cl_init.lua b/gamemodes/copsnrobbers/gamemode/cl_init.lua similarity index 100% rename from gamemodes/copsnrobbers/cl_init.lua rename to gamemodes/copsnrobbers/gamemode/cl_init.lua diff --git a/gamemodes/copsnrobbers/init.lua b/gamemodes/copsnrobbers/gamemode/init.lua similarity index 69% rename from gamemodes/copsnrobbers/init.lua rename to gamemodes/copsnrobbers/gamemode/init.lua index b8ab5f2..ad68616 100644 --- a/gamemodes/copsnrobbers/init.lua +++ b/gamemodes/copsnrobbers/gamemode/init.lua @@ -1,3 +1,3 @@ AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") -include("shared.lua") + include ("shared.lua") diff --git a/gamemodes/copsnrobbers/gamemode/player_class_cnr.lua b/gamemodes/copsnrobbers/gamemode/player_class_cnr.lua new file mode 100644 index 0000000..cc36160 --- /dev/null +++ b/gamemodes/copsnrobbers/gamemode/player_class_cnr.lua @@ -0,0 +1,28 @@ + +AddCSLuaFile() + +local PLAYER = {} + +PLAYER.DisplayName = "CNR Player Class" + +PLAYER.SlowWalkSpeed = 200 +PLAYER.WalkSpeed = 250 +PLAYER.RunSpeed = 280 +PLAYER.CrouchedWalkSpeed = 0.3 +PLAYER.DuckSpeed = 0.3 +PLAYER.UnDuckSpeed = 0.3 +PLAYER.JumpPower = 200 +PLAYER.CanUseFlashlight = true +PLAYER.MaxHealth = 100 +PLAYER.MaxArmor = 100 +PLAYER.StartHealth = 100 +PLAYER.StartArmor = 0 +PLAYER.DropWeaponOnDie = false +PLAYER.TeammateNoCollide = true +PLAYER.AvoidPlayers = true +PLAYER.UseVMHands = true + +function PLAYER:SetupDataTables() +end + +player_manager.RegisterClass( "player_cnr", PLAYER, "player_default" ) diff --git a/gamemodes/copsnrobbers/gamemode/shared.lua b/gamemodes/copsnrobbers/gamemode/shared.lua new file mode 100644 index 0000000..27789d1 --- /dev/null +++ b/gamemodes/copsnrobbers/gamemode/shared.lua @@ -0,0 +1,134 @@ + +GM.Name = "Cops 'n Robbers" +GM.Author = "Fesiug" +GM.Email = "publicfesiug@outlook.com" +GM.Website = "https://github.com/Fesiug/copsnrobbers" +GM.TeamBased = true + +AddCSLuaFile("cl_hud.lua") +if CLIENT then + include ("cl_hud.lua") +end + +AddCSLuaFile("player_class_cnr.lua") + include ("player_class_cnr.lua") + +function GM:Initialize() + -- Do stuff +end + +function GM:OnDamagedByExplosion( ply, dmginfo ) + -- ply:SetDSP( 35, false ) +end +function GM:PlayerCanJoinTeam( ply, teamid ) + local TimeBetweenSwitches = 0.5 + if ( ply.LastTeamSwitch && RealTime() - ply.LastTeamSwitch < TimeBetweenSwitches ) then + ply.LastTeamSwitch = ply.LastTeamSwitch + 0.5 + ply:ChatPrint( Format( "Please wait %i more seconds before trying to change team again", ( TimeBetweenSwitches - ( RealTime() - ply.LastTeamSwitch ) ) + 1 ) ) + return false + end + + if ( ply:Team() == teamid ) then + ply:ChatPrint( "You're already on that team" ) + return false + end + + return true +end + +-- Write this so at the end of a round you can shittalk +local sv_alltalk = GetConVar( "sv_alltalk" ) +function GM:PlayerCanHearPlayersVoice( pListener, pTalker ) + local alltalk = sv_alltalk:GetInt() + if ( alltalk >= 1 ) then return true, alltalk == 2 end + + return pListener:Team() == pTalker:Team(), false +end + +function GM:PlayerShouldTaunt( ply, actid ) + return false +end +function GM:AllowPlayerPickup( ply, object ) + return false +end +function GM:PlayerDeathSound() + return true +end + +function GM:CreateTeams() + + TEAM_SIDEA = 1 + team.SetUp( TEAM_SIDEA, "Side A", Color( 200, 200, 255 ) ) + team.SetSpawnPoint( TEAM_SIDEA, "info_player_counterterrorist" ) + + TEAM_SIDEB = 2 + team.SetUp( TEAM_SIDEB, "Side B", Color( 255, 200, 200 ) ) + team.SetSpawnPoint( TEAM_SIDEB, "info_player_terrorist" ) + + team.SetSpawnPoint( TEAM_SPECTATOR, "worldspawn" ) + +end + +function GM:ScalePlayerDamage( ply, hitgroup, dmginfo ) + -- More damage if we're shot in the head + if ( hitgroup == HITGROUP_HEAD ) then + dmginfo:ScaleDamage( 2 ) + end +end + +function GM:PlayerSpawn( p, transition ) + player_manager.SetPlayerClass( p, "player_cnr" ) + + if ( self.TeamBased and ( p:Team() == TEAM_SPECTATOR or p:Team() == TEAM_UNASSIGNED ) ) then + self:PlayerSpawnAsSpectator( p ) + return + end + p:UnSpectate() + + p:SetSlowWalkSpeed( 190 ) + p:SetWalkSpeed( 320 ) + p:SetRunSpeed( 320 ) + + if ( !transition ) then + GAMEMODE:PlayerLoadout( p ) + end + + GAMEMODE:PlayerSetModel( p ) + + p:SetupHands() +end + +function GM:PlayerLoadout( p ) + if p:Team() == TEAM_SIDEA then + p:Give("cnr_m4a1") + p:Give("cnr_usp") + elseif p:Team() == TEAM_SIDEB then + p:Give("cnr_ak47") + p:Give("cnr_glock") + end + + return true +end + +function GM:PlayerSetModel( p ) + if p:Team() == TEAM_SIDEA then + p:SetModel( "models/player/combine_soldier.mdl" ) + elseif p:Team() == TEAM_SIDEB then + p:SetModel( "models/player/group03/male_07.mdl" ) + end +end + +concommand.Add( "cnr_cheat_weapons", function( p ) + p:Give( "cnr_ak47" ) + p:Give( "cnr_glock" ) + p:Give( "cnr_m4a1" ) + p:Give( "cnr_m4s90" ) + p:Give( "cnr_m249" ) + p:Give( "cnr_mac10" ) + p:Give( "cnr_mossberg" ) + p:Give( "cnr_mp5" ) + p:Give( "cnr_p220" ) + p:Give( "cnr_usp" ) +end) + +-- Include module loader here diff --git a/gamemodes/copsnrobbers/icon24.png b/gamemodes/copsnrobbers/icon24.png new file mode 100644 index 0000000..110ff01 Binary files /dev/null and b/gamemodes/copsnrobbers/icon24.png differ diff --git a/gamemodes/copsnrobbers/shared.lua b/gamemodes/copsnrobbers/shared.lua deleted file mode 100644 index 7a10a75..0000000 --- a/gamemodes/copsnrobbers/shared.lua +++ /dev/null @@ -1,2 +0,0 @@ - --- Include module loader here