Guns are now very drop-unsafe

Adds more guns
This commit is contained in:
Fesiug 2024-09-21 23:44:08 -04:00
parent bf1dd2f99b
commit a7825e495a
Signed by: Fesiug
GPG Key ID: 374BFF45E1EEF243
4 changed files with 334 additions and 25 deletions

View File

@ -60,6 +60,8 @@ function ENT:Think()
end end
end end
self.Class:EntThink( self )
if CLIENT then return true end if CLIENT then return true end
self.BAsleep = self.BAsleep or false self.BAsleep = self.BAsleep or false
@ -72,7 +74,7 @@ function ENT:Think()
net.WriteEntity(self) net.WriteEntity(self)
net.Broadcast() net.Broadcast()
print("SV Stopping prediction on", self) print("SV Stopping prediction on", self)
self:SetCollisionGroup( COLLISION_GROUP_WEAPON ) --self:SetCollisionGroup( COLLISION_GROUP_WEAPON )
self.BAsleep = true self.BAsleep = true
end end
elseif self.BAsleep then elseif self.BAsleep then
@ -114,6 +116,7 @@ end
if SERVER then if SERVER then
function ENT:PhysicsCollide( data, collider ) function ENT:PhysicsCollide( data, collider )
self.Class:EntPhysicsCollide( self, data, collider )
if ( data.DeltaTime > 0.1 ) then if ( data.DeltaTime > 0.1 ) then
--self:EmitSound( str, 70, 100, 1, CHAN_STATIC ) --self:EmitSound( str, 70, 100, 1, CHAN_STATIC )
end end

View File

@ -205,14 +205,11 @@ function SWEP:Think()
local ActiveR_Valid = ActiveR:IsValid() local ActiveR_Valid = ActiveR:IsValid()
if DesireR != ActiveR then if DesireR != ActiveR then
print(DesireR, ActiveR)
if ActiveR_Valid then if ActiveR_Valid then
if ActiveR:GetHolsterIn() == 0 then if ActiveR:GetHolsterIn() == 0 then
--self:Deactive()
print("hi?")
ActiveR.Class.Holster( ActiveR.Class, ActiveR, self ) ActiveR.Class.Holster( ActiveR.Class, ActiveR, self )
else else
-- wait -- Waiting for holster to finish
end end
else else
if DesireR_Valid then if DesireR_Valid then

View File

@ -102,6 +102,12 @@ AddItem( "base", {
end end
end, end,
["EntThink"] = function( class, ent, handler )
end,
["EntPhysicsCollide"] = function( class, ent, data, collider )
end,
["Reload"] = function( class, ent, handler ) ["Reload"] = function( class, ent, handler )
end, end,
}) })
@ -129,7 +135,7 @@ local AnimationLookup = {
}, },
["holster"] = { ["holster"] = {
["handgun"] = "handgun_holster", ["handgun"] = "handgun_holster",
["rifle"] = "holster_handgun", ["rifle"] = "handgun_holster",
}, },
} }
@ -191,7 +197,10 @@ AddItem( "base_firearm", {
local Topped = ent:GetBurstCount() == class.BurstCount local Topped = ent:GetBurstCount() == class.BurstCount
local Runaway = class.BurstRunaway local Runaway = class.BurstRunaway
local BAuto = class.BurstAuto local BAuto = class.BurstAuto
local Firedown = handler:GetOwner():KeyDown( IN_ATTACK ) local Firedown = false
if IsValid(handler) then
Firedown = handler:GetOwner():KeyDown( IN_ATTACK )
end
if Runaway and InProcess and !Topped then if Runaway and InProcess and !Topped then
class:Attack( ent, handler ) class:Attack( ent, handler )
else else
@ -213,6 +222,33 @@ AddItem( "base_firearm", {
BaseClass.Think( class, ent, handler ) BaseClass.Think( class, ent, handler )
end, end,
["EntThink"] = function( class, ent, handler )
if IsValid(handler) then return end
local InProcess = ent:GetBurstCount() > 0
local Topped = ent:GetBurstCount() == class.BurstCount
local Runaway = class.BurstRunaway
local BAuto = class.BurstAuto
local Firedown = false
if Runaway and InProcess and !Topped then
class:Attack( ent, handler )
else
if !Firedown then
if !Topped and InProcess then
ent:SetDelayBurst( CurTime() + class.BurstDelay )
end
ent:SetBurstCount( 0 )
end
if Topped and BAuto then
ent:SetBurstCount( 0 )
ent:SetDelayBurst( CurTime() + class.BurstDelay )
end
end
if ent:GetRefillTime() != 0 and ent:GetRefillTime() <= CurTime() then
ent:SetClip( class.ClipSize )
ent:SetRefillTime( 0 )
end
end,
["Attack"] = function( class, ent, handler ) ["Attack"] = function( class, ent, handler )
if ent:GetClip() <= 0 then return end if ent:GetClip() <= 0 then return end
if ent:GetDelay() > CurTime() then return end if ent:GetDelay() > CurTime() then return end
@ -220,6 +256,9 @@ AddItem( "base_firearm", {
if ent:GetBurstCount() >= class.BurstCount then return end if ent:GetBurstCount() >= class.BurstCount then return end
if ent:GetHolsterIn() != 0 then return end if ent:GetHolsterIn() != 0 then return end
local HandlerValid = IsValid(handler)
local handlerorself = HandlerValid and handler or ent
local Runaway = class.BurstRunaway local Runaway = class.BurstRunaway
local BAuto = class.BurstAuto local BAuto = class.BurstAuto
ent:SetBurstCount( ent:GetBurstCount() + 1 ) ent:SetBurstCount( ent:GetBurstCount() + 1 )
@ -232,19 +271,20 @@ AddItem( "base_firearm", {
ent:SetClip( ent:GetClip() - 1 ) ent:SetClip( ent:GetClip() - 1 )
if ent:GetClip() == 0 then if ent:GetClip() == 0 then
handler:EmitSound( "benny/weapons/1911/slidedrop.ogg", 70, 100, 0.4, CHAN_STATIC ) handlerorself:EmitSound( "benny/weapons/1911/slidedrop.ogg", 70, 100, 0.4, CHAN_STATIC )
end end
ent:SetDelay( CurTime() + class.Delay ) ent:SetDelay( CurTime() + class.Delay )
handler:EmitSound( istable(class.FireSound) and TSelShared(class.FireSound, "FireSound") or class.FireSound, 140, 100, 0.4, CHAN_STATIC ) handlerorself:EmitSound( istable(class.FireSound) and TSelShared(class.FireSound, "FireSound") or class.FireSound, 100, 100, 0.5, CHAN_STATIC )
local acc = math.rad( class.Accuracy or 0 ) local acc = math.rad( class.Accuracy or 0 )
if HandlerValid then
local p = handler:GetOwner() local p = handler:GetOwner()
p:LagCompensation(true) p:LagCompensation(true)
handler:FireBullets( { handler:FireBullets( {
Attacker = p, Attacker = p,
Damage = 1, Damage = 1,
Force = 1, Force = 5,
Tracer = 0, Tracer = 0,
Num = class.Pellets, Num = class.Pellets,
Dir = p:GetAimVector(), Dir = p:GetAimVector(),
@ -252,9 +292,26 @@ AddItem( "base_firearm", {
Spread = Vector( acc, acc, 0 ), Spread = Vector( acc, acc, 0 ),
} ) } )
p:LagCompensation(false) p:LagCompensation(false)
else
ent:FireBullets( {
Attacker = ent,
Damage = 1,
Force = 1,
Tracer = 0,
Num = class.Pellets,
Dir = ent:GetForward(),
Src = ent:GetPos(),
Spread = Vector( acc, acc, 0 ),
} )
local physobj = ent:GetPhysicsObject()
if physobj:IsValid() then
physobj:AddVelocity( ent:GetForward() * -300 )
physobj:AddAngleVelocity( VectorRand( -360*20, 360*20 ) )
end
end
local ply = handler:GetOwner() local ply = handlerorself:GetOwner()
if SERVER or CLIENT and IsFirstTimePredicted() then if HandlerValid and (SERVER or CLIENT and IsFirstTimePredicted()) then
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["fire"][class.HoldType] ), 0, true ) ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["fire"][class.HoldType] ), 0, true )
end end
@ -318,6 +375,12 @@ AddItem( "base_firearm", {
end end
end, end,
["EntPhysicsCollide"] = function( class, ent, data, collider )
if ( data.DeltaTime > 0.1 and data.Speed > 200 ) then
class:Attack( ent )
end
end,
["FinishHolster"] = function( class, ent, handler ) ["FinishHolster"] = function( class, ent, handler )
handler:EmitSound( "weapons/m4a1/m4a1_deploy.wav", 70, 125, 0.4, CHAN_STATIC ) handler:EmitSound( "weapons/m4a1/m4a1_deploy.wav", 70, 125, 0.4, CHAN_STATIC )
BaseClass.FinishHolster( class, ent, handler ) BaseClass.FinishHolster( class, ent, handler )
@ -727,6 +790,7 @@ do -- Rifles
end end
do -- MGs do -- MGs
AddItem( "qbb", { AddItem( "qbb", {
PrintName = "#Item.qbb.Name", PrintName = "#Item.qbb.Name",
Description = "#Item.qbb.Description", Description = "#Item.qbb.Description",
@ -749,6 +813,53 @@ do -- MGs
Accuracy_Reset = 0.4, Accuracy_Reset = 0.4,
Accuracy_Decay = 12, Accuracy_Decay = 12,
}) })
AddItem( "stoner", {
PrintName = "#Item.stoner.Name",
Description = "#Item.stoner.Description",
Category = "machinegun",
Base = "base_firearm",
Model = "models/benny/weapons/test_stoner.mdl",
HoldType = "rifle",
ClipSize = 100,
Delay = (60/880),
FireSound = {
"benny/weapons/stoner63/01.ogg",
"benny/weapons/stoner63/02.ogg",
"benny/weapons/stoner63/03.ogg",
},
Accuracy = 1,
Accuracy_Add = 0.4,
Accuracy_Reset = 0.4,
Accuracy_Decay = 12,
})
AddItem( "hk21", {
PrintName = "#Item.hk21.Name",
Description = "#Item.hk21.Description",
Category = "machinegun",
Base = "base_firearm",
Model = "models/benny/weapons/test_hk21.mdl",
HoldType = "rifle",
ClipSize = 70,
Delay = (60/640),
FireSound = {
"benny/weapons/hk21/39_01.ogg",
"benny/weapons/hk21/39_02.ogg",
"benny/weapons/hk21/39_03.ogg",
},
Accuracy = 1,
Accuracy_Add = 0.4,
Accuracy_Reset = 0.4,
Accuracy_Decay = 12,
})
end end
do -- SMGs do -- SMGs
@ -835,7 +946,7 @@ do -- Shotguns
Category = "shotgun", Category = "shotgun",
Base = "base_firearm", Base = "base_firearm",
Model = "models/weapons/w_shotgun.mdl", Model = "models/benny/weapons/test_spas12.mdl",
HoldType = "rifle", HoldType = "rifle",
ClipSize = 8, ClipSize = 8,
@ -858,6 +969,180 @@ do -- Shotguns
Accuracy_Decay = 12, Accuracy_Decay = 12,
}) })
AddItem( "aa12", {
PrintName = "#Item.aa12.Name",
Description = "#Item.aa12.Description",
Category = "shotgun",
Base = "base_firearm",
Model = "models/benny/weapons/test_aa12.mdl",
HoldType = "rifle",
ClipSize = 8,
Pellets = 8,
Delay = 0.4,
BurstCount = 1,
FireSound = {
"benny/weapons/spas12/01.ogg",
"benny/weapons/spas12/02.ogg",
"benny/weapons/spas12/03.ogg",
},
MagOutSound = "benny/weapons/spas12/magout-01.ogg",
MagInSound = "benny/weapons/spas12/magout-02.ogg",
BoltDropSound = "benny/weapons/spas12/magin.ogg",
BoltPullSound = "benny/weapons/glock/magin.ogg",
Accuracy = 8,
Accuracy_Add = 0.4,
Accuracy_Reset = 0.4,
Accuracy_Decay = 12,
})
AddItem( "db", {
PrintName = "#Item.db.Name",
Description = "#Item.db.Description",
Category = "shotgun",
Base = "base_firearm",
Model = "models/benny/weapons/test_db.mdl",
HoldType = "rifle",
ClipSize = 2,
Pellets = 8,
Delay = 0.4,
BurstCount = 1,
FireSound = {
"benny/weapons/spas12/01.ogg",
"benny/weapons/spas12/02.ogg",
"benny/weapons/spas12/03.ogg",
},
MagOutSound = "benny/weapons/spas12/magout-01.ogg",
MagInSound = "benny/weapons/spas12/magout-02.ogg",
BoltDropSound = "benny/weapons/spas12/magin.ogg",
BoltPullSound = "benny/weapons/glock/magin.ogg",
Accuracy = 4,
Accuracy_Add = 0.4,
Accuracy_Reset = 0.4,
Accuracy_Decay = 12,
})
AddItem( "1887", {
PrintName = "#Item.1887.Name",
Description = "#Item.1887.Description",
Category = "shotgun",
Base = "base_firearm",
Model = "models/benny/weapons/test_1887.mdl",
HoldType = "rifle",
ClipSize = 5,
Pellets = 8,
Delay = 0.4,
BurstCount = 1,
FireSound = {
"benny/weapons/spas12/01.ogg",
"benny/weapons/spas12/02.ogg",
"benny/weapons/spas12/03.ogg",
},
MagOutSound = "benny/weapons/spas12/magout-01.ogg",
MagInSound = "benny/weapons/spas12/magout-02.ogg",
BoltDropSound = "benny/weapons/spas12/magin.ogg",
BoltPullSound = "benny/weapons/glock/magin.ogg",
Accuracy = 8,
Accuracy_Add = 0.4,
Accuracy_Reset = 0.4,
Accuracy_Decay = 12,
})
AddItem( "spas15", {
PrintName = "#Item.spas15.Name",
Description = "#Item.spas15.Description",
Category = "shotgun",
Base = "base_firearm",
Model = "models/benny/weapons/test_spas15.mdl",
HoldType = "rifle",
ClipSize = 6,
Pellets = 8,
Delay = 0.6,
BurstCount = 1,
FireSound = {
"benny/weapons/spas12/01.ogg",
"benny/weapons/spas12/02.ogg",
"benny/weapons/spas12/03.ogg",
},
MagOutSound = "benny/weapons/spas12/magout-01.ogg",
MagInSound = "benny/weapons/spas12/magout-02.ogg",
BoltDropSound = "benny/weapons/spas12/magin.ogg",
BoltPullSound = "benny/weapons/glock/magin.ogg",
Accuracy = 8,
Accuracy_Add = 0.4,
Accuracy_Reset = 0.4,
Accuracy_Decay = 12,
})
AddItem( "r870", {
PrintName = "#Item.r870.Name",
Description = "#Item.r870.Description",
Category = "shotgun",
Base = "base_firearm",
Model = "models/benny/weapons/test_r870.mdl",
HoldType = "rifle",
ClipSize = 4,
Pellets = 8,
Delay = 0.6,
BurstCount = 1,
FireSound = {
"benny/weapons/spas12/01.ogg",
"benny/weapons/spas12/02.ogg",
"benny/weapons/spas12/03.ogg",
},
MagOutSound = "benny/weapons/spas12/magout-01.ogg",
MagInSound = "benny/weapons/spas12/magout-02.ogg",
BoltDropSound = "benny/weapons/spas12/magin.ogg",
BoltPullSound = "benny/weapons/glock/magin.ogg",
Accuracy = 8,
Accuracy_Add = 0.4,
Accuracy_Reset = 0.4,
Accuracy_Decay = 12,
})
AddItem( "striker", {
PrintName = "#Item.striker.Name",
Description = "#Item.striker.Description",
Category = "shotgun",
Base = "base_firearm",
Model = "models/benny/weapons/test_striker.mdl",
HoldType = "rifle",
ClipSize = 12,
Pellets = 8,
Delay = 0.3,
BurstCount = 1,
FireSound = {
"benny/weapons/spas12/01.ogg",
"benny/weapons/spas12/02.ogg",
"benny/weapons/spas12/03.ogg",
},
MagOutSound = "benny/weapons/spas12/magout-01.ogg",
MagInSound = "benny/weapons/spas12/magout-02.ogg",
BoltDropSound = "benny/weapons/spas12/magin.ogg",
BoltPullSound = "benny/weapons/glock/magin.ogg",
Accuracy = 8,
Accuracy_Add = 0.4,
Accuracy_Reset = 0.4,
Accuracy_Decay = 12,
})
end end
-- bat -- bat

View File

@ -35,6 +35,12 @@ L["#Item.qbz.Description"] = "Low-profile bullpup assault rifle"
L["#Item.qbb.Name"] = "QBB-LSW" L["#Item.qbb.Name"] = "QBB-LSW"
L["#Item.qbb.Description"] = "Bullpup machine gun" L["#Item.qbb.Description"] = "Bullpup machine gun"
L["#Item.stoner.Name"] = "STONER-63"
L["#Item.stoner.Description"] = "Modular machine gun"
L["#Item.hk21.Name"] = "HK-21"
L["#Item.hk21.Description"] = "Powerful medium machine gun"
L["#Item.m16a2.Name"] = "M16A2" L["#Item.m16a2.Name"] = "M16A2"
L["#Item.m16a2.Description"] = "Rugged burst rifle" L["#Item.m16a2.Description"] = "Rugged burst rifle"
@ -56,6 +62,24 @@ L["#Item.mp7.Description"] = "Special forces PDW"
L["#Item.mac11.Name"] = "MAC-11" L["#Item.mac11.Name"] = "MAC-11"
L["#Item.mac11.Description"] = "Tiny hornet gun" L["#Item.mac11.Description"] = "Tiny hornet gun"
L["#Item.1887.Name"] = "1887"
L["#Item.1887.Description"] = "Lever-action"
L["#Item.db.Name"] = "DB"
L["#Item.db.Description"] = "Side-by-side shotgun"
L["#Item.aa12.Name"] = "AA-12"
L["#Item.aa12.Description"] = "Automatic combat shotgun"
L["#Item.striker.Name"] = "Streetsweeper"
L["#Item.striker.Description"] = "Semi-automatic drum-fed shotgun"
L["#Item.r870.Name"] = "R870"
L["#Item.r870.Description"] = "Sawn-off pump-action shotgun"
L["#Item.spas15.Name"] = "SPAS-15"
L["#Item.spas15.Description"] = "Mag-fed pump-action shotgun"
L["#Item.satchels.Name"] = "Satchels" L["#Item.satchels.Name"] = "Satchels"
L["#Item.satchels.Description"] = "Packs of bombs and a detonator" L["#Item.satchels.Description"] = "Packs of bombs and a detonator"