2024-03-06 17:47:44 -05:00
|
|
|
|
2024-03-07 20:34:16 -05:00
|
|
|
---------------------
|
|
|
|
-- Your Name is Benny
|
|
|
|
---------------------
|
|
|
|
|
2024-03-06 17:47:44 -05:00
|
|
|
ITEMS = {}
|
|
|
|
|
|
|
|
local itemmeta = {}
|
|
|
|
|
|
|
|
function itemmeta:__tostring()
|
|
|
|
return "ItemDef [" .. self.ClassName .. "]"
|
|
|
|
end
|
|
|
|
|
|
|
|
local ITEMHELPER = {
|
|
|
|
Get = function( self, key )
|
|
|
|
return self.key
|
|
|
|
end,
|
|
|
|
GetRaw = function( self, key )
|
|
|
|
return rawget( self, key )
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
|
|
|
|
function itemmeta.__index( self, key )
|
|
|
|
if ITEMHELPER[key] then return ITEMHELPER[key] end
|
|
|
|
if rawget(self, "BaseClass") then
|
|
|
|
return rawget(self, "BaseClass")[key]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function AddItem( itemname, item )
|
|
|
|
if item then
|
|
|
|
ITEMS[itemname] = item
|
|
|
|
item.ClassName = itemname
|
|
|
|
item.BaseClass = ITEMS[item.Base]
|
|
|
|
setmetatable( item, itemmeta )
|
|
|
|
else
|
|
|
|
return ITEMS[itemname]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
AddItem( "base", {
|
|
|
|
PrintName = "Base Item",
|
2024-03-07 20:27:18 -05:00
|
|
|
Description = "Beginning item base.",
|
|
|
|
Category = "base",
|
2024-03-06 17:47:44 -05:00
|
|
|
|
|
|
|
Vars = {
|
|
|
|
["Float"] = {
|
|
|
|
"Acquisition",
|
|
|
|
},
|
|
|
|
},
|
2024-03-12 18:43:31 -04:00
|
|
|
HoldType = "slam",
|
2024-03-06 17:47:44 -05:00
|
|
|
|
|
|
|
["Initialize"] = function( class, ent, handler )
|
|
|
|
print( class, "Initialized base initialization" )
|
|
|
|
end,
|
|
|
|
|
|
|
|
["Deploy"] = function( class, ent, handler )
|
|
|
|
end,
|
|
|
|
|
|
|
|
["Holster"] = function( class, ent, handler )
|
|
|
|
end,
|
|
|
|
|
|
|
|
["Attack"] = function( class, ent, handler )
|
|
|
|
end,
|
|
|
|
|
|
|
|
["Think"] = function( class, ent, handler )
|
|
|
|
end,
|
|
|
|
|
|
|
|
["Reload"] = function( class, ent, handler )
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
AddItem( "base_firearm", {
|
|
|
|
PrintName = "Base Firearm",
|
2024-03-07 20:27:18 -05:00
|
|
|
Description = "Item base for firearms.",
|
|
|
|
Category = "base",
|
2024-03-06 17:47:44 -05:00
|
|
|
Base = "base",
|
|
|
|
|
|
|
|
Vars = {
|
|
|
|
["Int"] = {
|
|
|
|
"Clip",
|
|
|
|
"BurstCount",
|
|
|
|
},
|
|
|
|
["Float"] = {
|
|
|
|
"Delay",
|
|
|
|
"DelayBurst",
|
|
|
|
"RefillTime",
|
|
|
|
"Accuracy_Reset",
|
|
|
|
"Accuracy_Amount",
|
|
|
|
"DelayReload",
|
|
|
|
},
|
|
|
|
},
|
2024-03-12 18:43:31 -04:00
|
|
|
HoldType = "rpg",
|
2024-03-06 17:47:44 -05:00
|
|
|
|
|
|
|
Delay = 0.1,
|
|
|
|
Pellets = 1,
|
|
|
|
ClipSize = 15,
|
|
|
|
BurstCount = math.huge,
|
|
|
|
BurstRunaway = false,
|
|
|
|
BurstAuto = false,
|
|
|
|
BurstDelay = 0,
|
|
|
|
|
|
|
|
["Initialize"] = function( class, ent, handler )
|
|
|
|
ITEMS["base"].Initialize( class, ent, handler )
|
|
|
|
|
|
|
|
ent:SetClip( class.ClipSize )
|
|
|
|
|
|
|
|
print( class, "Initialized a firearm" )
|
|
|
|
end,
|
2024-03-08 20:10:47 -05:00
|
|
|
|
2024-03-12 18:43:31 -04:00
|
|
|
["Think"] = function( class, ent, handler )
|
|
|
|
local InProcess = ent:GetBurstCount() > 0
|
|
|
|
local Topped = ent:GetBurstCount() == class.BurstCount
|
|
|
|
local Runaway = class.BurstRunaway
|
|
|
|
local BAuto = class.BurstAuto
|
|
|
|
local Firedown = handler:GetOwner():KeyDown( IN_ATTACK )
|
|
|
|
if Runaway and InProcess and !Topped then
|
|
|
|
class["Attack"]( class, 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
|
|
|
|
end,
|
|
|
|
|
2024-03-08 20:10:47 -05:00
|
|
|
["Attack"] = function( class, ent, handler )
|
|
|
|
if ent:GetClip() <= 0 then return end
|
|
|
|
if ent:GetDelay() > CurTime() then return end
|
2024-03-12 18:43:31 -04:00
|
|
|
if ent:GetBurstCount() >= class.BurstCount then return end
|
2024-03-08 20:10:47 -05:00
|
|
|
|
2024-03-12 18:43:31 -04:00
|
|
|
ent:SetBurstCount( ent:GetBurstCount() + 1 )
|
2024-03-08 20:10:47 -05:00
|
|
|
ent:SetClip( ent:GetClip() - 1 )
|
|
|
|
ent:SetDelay( CurTime() + class.Delay )
|
2024-03-12 18:43:31 -04:00
|
|
|
handler:EmitSound( class.FireSound, 140, 100, 0.4, CHAN_STATIC )
|
|
|
|
|
|
|
|
local acc = 0
|
|
|
|
local p = handler:GetOwner()
|
|
|
|
handler:FireBullets( {
|
|
|
|
Attacker = p,
|
|
|
|
Damage = 1,
|
|
|
|
Force = 1,
|
|
|
|
Num = class.Pellets,
|
|
|
|
Dir = p:GetAimVector(),
|
|
|
|
Src = p:GetShootPos(),
|
|
|
|
Spread = Vector( acc, acc, 0 ),
|
|
|
|
} )
|
2024-03-08 20:10:47 -05:00
|
|
|
end,
|
|
|
|
|
|
|
|
["Reload"] = function( class, ent, handler )
|
2024-03-12 18:43:31 -04:00
|
|
|
if ent:GetClip() >= class.ClipSize then return end
|
|
|
|
if ent:GetDelay() > CurTime() then return end
|
|
|
|
handler:EmitSound( "weapons/m4a1/m4a1_boltpull.wav", 70, 125, 0.4, CHAN_STATIC )
|
|
|
|
ent:SetDelay( CurTime() + 0.5 )
|
2024-03-08 20:10:47 -05:00
|
|
|
ent:SetClip( class.ClipSize )
|
|
|
|
end,
|
2024-03-12 18:43:31 -04:00
|
|
|
|
|
|
|
["Deploy"] = function( class, ent, handler )
|
|
|
|
handler:EmitSound( "weapons/usp/usp_slideback.wav", 70, 125, 0.4, CHAN_STATIC )
|
|
|
|
ent:SetDelay( CurTime() + 0.5 )
|
|
|
|
end,
|
|
|
|
|
|
|
|
["Holster"] = function( class, ent, handler )
|
|
|
|
handler:EmitSound( "weapons/m4a1/m4a1_deploy.wav", 70, 125, 0.4, CHAN_STATIC )
|
|
|
|
ent:SetDelay( CurTime() + 0.5 )
|
|
|
|
end,
|
2024-03-06 17:47:44 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
AddItem( "mk23", {
|
2024-03-07 20:27:18 -05:00
|
|
|
PrintName = "#Item.mk23.Name",
|
|
|
|
Description = "#Item.mk23.Description",
|
|
|
|
Category = "pistol",
|
2024-03-06 17:47:44 -05:00
|
|
|
Base = "base_firearm",
|
|
|
|
|
2024-03-12 18:43:31 -04:00
|
|
|
Model = "models/weapons/w_pist_usp.mdl",
|
|
|
|
HoldType = "revolver",
|
2024-03-06 17:47:44 -05:00
|
|
|
|
|
|
|
ClipSize = 12,
|
2024-03-12 18:43:31 -04:00
|
|
|
Delay = (60/350),
|
2024-03-06 17:47:44 -05:00
|
|
|
FireSound = "weapons/usp/usp_unsil-1.wav",
|
|
|
|
|
|
|
|
Accuracy = 5/60,
|
|
|
|
BurstCount = 1,
|
|
|
|
Accuracy_Add = 0.5,
|
|
|
|
Accuracy_Reset = 0.4,
|
|
|
|
Accuracy_Decay = 5,
|
2024-03-07 22:34:29 -05:00
|
|
|
})
|
|
|
|
|
2024-03-12 18:43:31 -04:00
|
|
|
AddItem( "fnc", {
|
|
|
|
PrintName = "#Item.fnc.Name",
|
|
|
|
Description = "#Item.fnc.Description",
|
|
|
|
Base = "base_firearm",
|
|
|
|
|
|
|
|
Model = "models/weapons/w_rif_ar556.mdl",
|
|
|
|
HoldType = "rpg",
|
|
|
|
|
|
|
|
ClipSize = 30,
|
|
|
|
Delay = (60/750),
|
|
|
|
FireSound = "weapons/m4a1/m4a1_unsil-1.wav",
|
|
|
|
|
|
|
|
Accuracy = 1,
|
|
|
|
Accuracy_Add = 0.4,
|
|
|
|
Accuracy_Reset = 0.4,
|
|
|
|
Accuracy_Decay = 12,
|
|
|
|
})
|
|
|
|
|
2024-03-07 22:34:29 -05:00
|
|
|
for ID, Data in pairs(ITEMS) do
|
|
|
|
local tent = {}
|
|
|
|
tent.Base = "b-itembase"
|
|
|
|
tent.PrintName = Data.PrintName or ID
|
|
|
|
tent.ID = ID
|
|
|
|
tent.Class = ITEMS[ID]
|
|
|
|
tent.Spawnable = true
|
|
|
|
tent.AdminOnly = false
|
|
|
|
tent.Category = "Other"
|
|
|
|
|
|
|
|
-- print("aei_" .. ID)
|
|
|
|
scripted_ents.Register( tent, "b-item_" .. ID )
|
|
|
|
end
|