Benny/gamemodes/benny/gamemode/items/base.lua

101 lines
2.6 KiB
Lua

do -- Base
local ITEM, Base = CreateItem( "base" )
ITEM.PrintName = "Item Base"
ITEM.Description = "Testing testing"
ITEM.Category = "base"
ITEM.Model = bModel("weapons/test_g18")
ITEM.DefaultBodygroups = {}
ITEM.HoldType = "handgun"
ITEM.Vars = {
["Float"] = {
"Acquisition",
"HolsterIn",
},
}
ITEM.DeploySound = bSound("dev/magpouch.ogg")
ITEM.StartHolsterSound = bSound("dev/magpouch_replace_small.ogg")
ITEM.FinishHolsterSound = bSound("dev/holster.ogg")
ITEM.CancelHolsterSound = bSound("dev/grab.ogg")
function ITEM:EntInitialize()
for k, v in ipairs(self.DefaultBodygroups) do
if v then
self:SetBodygroup( k-1, v )
end
end
end
function ITEM:Sound( soundName, soundLevel, pitchPercent, volume, channel, soundFlags, dsp, filter )
local emiton = self
if self:GetHandler():IsValid() then
emiton = self:GetHandler()
end
emiton:EmitSound( soundName, soundLevel, pitchPercent, volume, channel, soundFlags, dsp )
end
function ITEM:Attack() end
function ITEM:AttackAlt() end
function ITEM:Think()
if self:GetHolsterIn() != 0 and self:GetHolsterIn() <= CurTime() then
self:FinishHolster()
self:SetHolsterIn( 0 )
end
end
function ITEM:PlayerAnimation( seqname )
local p = self:GetOwner()
p:DoCustomAnimEvent( BGESTURE_ITEM1_RIGHT, p:LookupSequence( seqname ) )
end
-- Use after children added.
function ITEM:ReevalRecreate()
self:RemoveEFlags( EFL_KEEP_ON_RECREATE_ENTITIES )
if self:GetOwner():IsValid() then
if self:GetOwner():IsEFlagSet( EFL_KEEP_ON_RECREATE_ENTITIES ) then
self:AddEFlags( EFL_KEEP_ON_RECREATE_ENTITIES )
print( "[Item " .. tostring(self) .. "] To be saved during recreate.")
return
else
print( "[Item " .. tostring(self) .. "] Will NOT be saved during recreate.")
return
end
end
print( "[Item " .. tostring(self) .. "] Will NOT be saved during recreate. No owner either")
return
end
function ITEM:EntThink() end
function ITEM:EntPhysicsCollide() end
function ITEM:Reload() end
function ITEM:Drop() end
function ITEM:Deploy()
self:Sound( self.DeploySound, 70, 100, 0.4 )
end
function ITEM:StartHolster()
self:Sound( self.StartHolsterSound, 70, 100, 0.4 )
self:SetHolsterIn( CurTime() + 0.25 )
end
function ITEM:FinishHolster()
self:Sound( self.FinishHolsterSound, 70, 100, 0.4, CHAN_STATIC )
self:GetHandler():SetActiveR( NULL )
self:SetNoDraw( true )
-- LAZY FIX
for i, v in ipairs(self:GetChildren()) do
v:SetNoDraw(true)
end
end
function ITEM:CancelHolster()
self:SetHolsterIn( 0 )
self:Sound( self.CancelHolsterSound, 70, 100, 0.4 )
end
end