Great proggers!

This commit is contained in:
Fesiug 2023-09-24 01:19:23 -04:00
parent fec4842bb9
commit 3900f1087f
5 changed files with 250 additions and 44 deletions

View File

@ -1,20 +1,56 @@
-- The benny weapon handles the weapon pickups you find throughout the game.
SWEP.Base = "weapon_base"
SWEP.Base = "weapon_base"
SWEP.PrintName = "Benny Weapon Handler"
SWEP.PrintName = "Benny Weapon Handler"
SWEP.ViewModel = "models/weapons/c_pistol.mdl"
SWEP.WorldModel = "models/weapons/w_pistol.mdl"
SWEP.ViewModel = "models/weapons/c_pistol.mdl"
SWEP.ViewModelFOV = 10
SWEP.WorldModel = "models/weapons/w_pistol.mdl"
SWEP.Primary.ClipSize = 0
SWEP.Primary.DefaultClip = 0
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = 0
SWEP.Secondary.DefaultClip = 0
SWEP.Secondary.Automatic = true
SWEP.Secondary.Ammo = "none"
function SWEP:SetupDataTables()
self:NetworkVar( "Float", 0, "Aim" )
self:NetworkVar( "Float", 1, "Delay1" )
self:NetworkVar( "Float", 2, "Delay2" )
self:NetworkVar( "String", 0, "Wep1" )
self:NetworkVar( "String", 1, "Wep2" )
self:NetworkVarNotify( "Wep1", self.OnVarChanged )
self:NetworkVarNotify( "Wep2", self.OnVarChanged )
end
function SWEP:OnVarChanged( name, old, new )
print( name, old, new )
if name == "Wep1" then
self.B_WepT1 = self:GetOwner():INV_Get()[new]
self.B_ClassT1 = WEAPONS[self.B_WepT1.Class]
elseif name == "Wep2" then
self.B_WepT2 = self:GetOwner():INV_Get()[new]
self.B_ClassT2 = WEAPONS[self.B_WepT1.Class]
end
end
function SWEP:PrimaryAttack()
if self:GetDelay1() > CurTime() then
return
end
if self:Clip1() == 0 then
self:EmitSound( "benny/weapons/common/06-13.ogg", 80, 100, 1, CHAN_STATIC )
self:SetDelay1( CurTime() + 0.2 )
return
end
if !self:B_Wep1() then
return
end
@ -24,16 +60,47 @@ function SWEP:PrimaryAttack()
self:EmitSound( "benny/weapons/1911/0".. math.random(1,3) ..".ogg", 110, 100, 1, CHAN_STATIC )
self:SetClip1( self:Clip1() - 1 )
self:B_Ammo1( self:Clip1() - 1 )
self:SetDelay1( CurTime() + 0.2 )
return true
end
-- BENNY shit
function SWEP:B_Wep1()
return self:GetOwner():INV_Get()[self:GetWep1()]
end
function SWEP:B_Wep2()
return self:GetOwner():INV_Get()[self:GetWep2()]
end
function SWEP:B_Ammo1( value )
self:SetClip1( value )
self:B_Wep1().Ammo = value
end
function SWEP:B_Ammo2( value )
self:SetClip2( value )
self:B_Wep2().Ammo = value
end
function SWEP:B_MaxAmmo1( value )
self:SetClip1( value )
self:B_Wep1().Ammo = value
end
function SWEP:B_Class1()
return WEAPONS[ self:B_Wep1().Class ]
end
function SWEP:SecondaryAttack()
return true
end
function SWEP:Reload()
self:SetClip1( 17 )
if self:B_Wep1() then
self:B_Ammo1( self:B_Class1().Ammo )
end
return true
end

View File

@ -303,7 +303,7 @@ hook.Add( "CalcView", "MyCalcView", function( ply, pos, ang, fov )
end
-- PROTO: Add correct benny weapon check
if IsValid(ply:GetActiveWeapon()) and ply:GetActiveWeapon():GetAim() > 0 then
if true or IsValid(ply:GetActiveWeapon()) and ply:GetActiveWeapon():GetAim() > 0 then
view.drawviewer = true
view.origin, view.angles, view.fov = bennyfp( view.origin, view.angles, view.fov )
end

View File

@ -140,6 +140,11 @@ end
local color_caption = Color( 0, 0, 0, 127 )
local mat_grad = Material( "benny/hud/grad.png", "mips smooth" )
local wep1 = {
Name = "COBRA .45",
Firemode = "SEMI",
}
hook.Add( "HUDPaint", "Benny_HUDPaint", function()
local sw, sh = ScrW(), ScrH()
local b = ss(20)
@ -185,41 +190,76 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
end
do -- Weapon
local inv = p:INV_Get()
local wep1 = wep.B_WepT1
local wep1c = wep.B_ClassT1
local wep2 = wep.B_WepT2
local wep2c = wep.B_ClassT2
do
local ox, oy = 170, 24
-- Debug
surface.SetFont( "Benny_12" )
surface.SetTextColor( scheme["fg"] )
surface.SetTextPos( ss(ox), ss(oy) )
surface.DrawText( "Wep1: " .. wep:GetWep1() )
local num = 1
if wep1 then for i, v in pairs( wep1 ) do
surface.SetTextPos( ss(ox+16), ss(oy+10*num) )
surface.DrawText( i .. ": " .. (v or "[no " .. i .. "]") )
num = num + 1
end end
surface.SetTextPos( ss(ox+128), ss(oy) )
surface.DrawText( "Wep2: " .. wep:GetWep2() )
if wep2 then for i, v in pairs( wep2 ) do
surface.SetTextPos( ss(ox+128+16), ss(oy+10*num) )
surface.DrawText( i .. ": " .. (v or "[no " .. i .. "]") )
num = num + 1
end end
end
local w, h = 150, 100
local BOXHEIGHT = 44
-- BG
surface.SetDrawColor( scheme["bg"] )
surface.DrawRect( sw - b - ss(w), sh - b - ss(BOXHEIGHT), ss(w), ss(BOXHEIGHT) )
-- Text bar
surface.SetFont( "Benny_18" )
surface.SetDrawColor( scheme["fg"] )
surface.DrawRect( sw - b - ss(w-4), sh - b - ss(BOXHEIGHT-4), ss(w-8), ss(14) )
if wep1 then
-- BG
surface.SetDrawColor( scheme["bg"] )
surface.DrawRect( sw - b - ss(w), sh - b - ss(BOXHEIGHT), ss(w), ss(BOXHEIGHT) )
surface.SetTextColor( scheme["bg"] )
surface.SetTextPos( sw - b - ss(w-6), sh - b - ss(BOXHEIGHT-3) )
surface.DrawText( "GLOCK-17" )
surface.SetDrawColor( scheme["fg"] )
surface.DrawRect( sw - b - ss(w-4), sh - b + ss(16) - ss(BOXHEIGHT-4), ss(29), ss(10) )
surface.SetFont( "Benny_12" )
surface.SetTextColor( scheme["bg"] )
surface.SetTextPos( sw - b - ss(w-7), sh - b + ss(16) - ss(BOXHEIGHT-4) )
surface.DrawText( "3BST" )
surface.SetFont( "Benny_12" )
local text = wep:Clip1() .. " - MAG 3"
local tw = surface.GetTextSize( text )
surface.SetTextColor( scheme["fg"] )
surface.SetTextPos( sw - b - ss(4) - tw, sh - b - ss(24) )
surface.DrawText( text )
for i=1, 17 do
-- Text bar
surface.SetFont( "Benny_18" )
surface.SetDrawColor( scheme["fg"] )
surface.DrawOutlinedRect( sw - b - ss(3+4) - ( ss(5) * (i-1) ), sh - b - ss(8+4), ss(3), ss(8), ss(0.5) )
if i <= wep:Clip1() then
surface.DrawRect( sw - b - ss(3+4) - ( ss(5) * (i-1) ), sh - b - ss(8+4), ss(3), ss(8) )
surface.DrawRect( sw - b - ss(w-4), sh - b - ss(BOXHEIGHT-4), ss(w-8), ss(14) )
surface.SetTextColor( scheme["bg"] )
surface.SetTextPos( sw - b - ss(w-6), sh - b - ss(BOXHEIGHT-3) )
surface.DrawText( wep1c.Name or "???" )
surface.SetDrawColor( scheme["fg"] )
surface.DrawRect( sw - b - ss(w-4), sh - b + ss(16) - ss(BOXHEIGHT-4), ss(29), ss(10) )
surface.SetFont( "Benny_12" )
surface.SetTextColor( scheme["bg"] )
surface.SetTextPos( sw - b - ss(w-7), sh - b + ss(16) - ss(BOXHEIGHT-4) )
surface.DrawText( wep1c.Firemode or "???" )
surface.SetFont( "Benny_12" )
local text = wep:Clip1() .. " - MAG 3"
local tw = surface.GetTextSize( text )
surface.SetTextColor( scheme["fg"] )
surface.SetTextPos( sw - b - ss(4) - tw, sh - b - ss(24) )
surface.DrawText( text )
for i=1, math.max( wep:Clip1(), wep.B_ClassT1.Ammo ) do
surface.SetDrawColor( scheme["fg"] )
surface.DrawOutlinedRect( sw - b - ss(3+4) - ( ss(5) * (i-1) ), sh - b - ss(8+4), ss(3), ss(8), ss(0.5) )
if i <= wep:Clip1() then
surface.DrawRect( sw - b - ss(3+4) - ( ss(5) * (i-1) ), sh - b - ss(8+4), ss(3), ss(8) )
end
end
end
end

View File

@ -4,4 +4,53 @@ function GM:PlayerSpawn( ply )
ply:SetModel( "models/player/combine_super_soldier.mdl" )
ply:SetPlayerColor( Vector( 0.275, 0.2, 0.145 ) )
ply:Give( "benny" )
end
if SERVER then
util.AddNetworkString( "benny_sendinv" )
end
concommand.Add("benny_debug_give", function(ply, cmd, args)
assert(SERVER, "not server")
-- PROTO: Check for the correct 'benny' weapon.
local ply = Entity( args[1] )
local wep = ply:GetActiveWeapon()
local inv = ply:INV_Get()
local str = UUID_generate()
local class = WEAPONS[args[3]]
local item = {
Class = args[3],
Ammo = class.Ammo,
}
inv[str] = item
-- PROTO: WriteTable.
net.Start( "benny_sendinv" )
net.WriteString( str )
net.WriteTable( item )
net.Send( ply )
local slot = tonumber(args[2])
if slot == 1 then
wep:SetWep1( str )
wep:SetClip1( class.Ammo )
elseif slot == 2 then
wep:SetWep2( str )
wep:SetClip2( class.Ammo )
else
end
end)
if CLIENT then
net.Receive( "benny_sendinv", function( len, ply )
assert(CLIENT, "not client")
local ply = LocalPlayer()
assert(IsValid( ply ), "ply is invalid?")
ply:INV_Get()[net.ReadString()] = net.ReadTable()
end)
end

View File

@ -1,47 +1,97 @@
WEAPONS = {}
local wep = {}
WEAPONS["1911"] = wep
wep.Name = "COBRA .45"
wep.Description = "Hits hard. They don't make them like they used to! Low capacity."
wep.WModel = "models/weapons/w_pist_usp.mdl"
wep.Delay = (60/300)
wep.Ammo = 8
wep.Damage = 30
local wep = {}
WEAPONS["usp"] = wep
wep.Name = "USP .45"
wep.Description = "It works for hardasses around the world, it works for you. Higher capacity."
wep.WModel = "models/weapons/w_pist_usp.mdl"
wep.Delay = (60/300)
wep.Ammo = 12
wep.Damage = 30
local wep = {}
WEAPONS["glock"] = wep
wep.Name = "GLOCK-18"
wep.WModel = "models/weapons/w_pist_glock18.mdl"
wep.Description = "Superb precision but poor capacity."
wep.WModel = "models/weapons/w_pist_glock18.mdl"
wep.Delay = (60/800)
wep.Ammo = 17
wep.Damage = 18
local wep = {}
WEAPONS["python"] = wep
wep.Name = "PYTHON"
wep.Description = "Superb precision but poor capacity."
WEAPONS["nambu"] = wep
wep.Name = "NAMBU .38"
wep.Description = "Eastern revolver that hits as much as it costs. Low capacity."
wep.Delay = (60/180)
wep.Ammo = 6
wep.Damage = 36
wep.Damage = 26
local wep = {}
WEAPONS["anaconda"] = wep
wep.Name = "ANACONDA"
wep.Description = "Precise and kicks like a mule, but low capacity."
wep.Delay = (60/180)
wep.Ammo = 6
wep.Damage = 40
local wep = {}
WEAPONS["tmp"] = wep
wep.Name = "TMP"
wep.Description = "Precise."
wep.Delay = (60/800)
wep.Ammo = 15
wep.Damage = 18
local wep = {}
WEAPONS["mp7"] = wep
wep.Name = "MP7"
wep.Description = "Small, pistol-sized, and simple."
wep.Delay = (60/700)
wep.Ammo = 15
wep.Damage = 16
local wep = {}
WEAPONS["mp5k"] = wep
wep.Name = "MP5K"
wep.Description = "Quality manufacturing, but cumbersome."
wep.Delay = (60/700)
wep.Ammo = 15
wep.Damage = 18
local wep = {}
WEAPONS["mac11"] = wep
wep.Name = "MAC-11"
wep.Description = "More fit for combat in a phone booth."
wep.Ammo = 15
wep.Delay = (60/800)
wep.Ammo = 16
wep.Damage = 16
local wep = {}
WEAPONS["bizon"] = wep
wep.Name = "BIZON"
wep.Description = "Unwieldy bullet storm."
wep.Ammo = 40
wep.Delay = (60/600)
wep.Ammo = 40
wep.Damage = 16