117 lines
1.9 KiB
Lua
117 lines
1.9 KiB
Lua
|
|
||
|
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",
|
||
|
|
||
|
Vars = {
|
||
|
["Float"] = {
|
||
|
"Acquisition",
|
||
|
},
|
||
|
},
|
||
|
|
||
|
["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",
|
||
|
Base = "base",
|
||
|
|
||
|
Vars = {
|
||
|
["Int"] = {
|
||
|
"Clip",
|
||
|
"BurstCount",
|
||
|
},
|
||
|
["Float"] = {
|
||
|
"Delay",
|
||
|
"DelayBurst",
|
||
|
"RefillTime",
|
||
|
"Accuracy_Reset",
|
||
|
"Accuracy_Amount",
|
||
|
"DelayReload",
|
||
|
},
|
||
|
},
|
||
|
|
||
|
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,
|
||
|
})
|
||
|
|
||
|
AddItem( "mk23", {
|
||
|
PrintName = "MK.23",
|
||
|
Base = "base_firearm",
|
||
|
|
||
|
Model = "models/weapons/w_pist_usp.mdl",
|
||
|
|
||
|
ClipSize = 12,
|
||
|
Delay = (60/300),
|
||
|
FireSound = "weapons/usp/usp_unsil-1.wav",
|
||
|
|
||
|
Accuracy = 5/60,
|
||
|
BurstCount = 1,
|
||
|
Accuracy_Add = 0.5,
|
||
|
Accuracy_Reset = 0.4,
|
||
|
Accuracy_Decay = 5,
|
||
|
})
|