Compare commits
No commits in common. "3975ebf158698a1bafd073c91aeb96a259c4c125" and "3f6f5464b9f6f7a2681a24040c3b124d31caccc0" have entirely different histories.
3975ebf158
...
3f6f5464b9
|
@ -1,159 +0,0 @@
|
||||||
|
|
||||||
AddCSLuaFile()
|
|
||||||
|
|
||||||
ENT.Type = "point"
|
|
||||||
|
|
||||||
function ENT:SetupDataTables()
|
|
||||||
for i=1, 32 do
|
|
||||||
self:NetworkVar("Entity", i-1, "Item" .. i )
|
|
||||||
end
|
|
||||||
self:NetworkVar( "Int", "ReservedSlots" )
|
|
||||||
end
|
|
||||||
|
|
||||||
function ENT:Initialize()
|
|
||||||
self:AddEFlags( EFL_FORCE_CHECK_TRANSMIT )
|
|
||||||
self:SetTransmitWithParent( true ) -- Transmit only when the owner does
|
|
||||||
end
|
|
||||||
|
|
||||||
function ENT:Think()
|
|
||||||
if !self:GetOwner():IsValid() then
|
|
||||||
self:Print("existing without an owner." )
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function ENT:Print( ... )
|
|
||||||
print( "[Inventory[" .. self:EntIndex() .. "], " .. tostring(self:GetOwner()) .. "]", ...)
|
|
||||||
end
|
|
||||||
|
|
||||||
function ENT:UpdateTransmitState()
|
|
||||||
return TRANSMIT_ALWAYS
|
|
||||||
end
|
|
||||||
|
|
||||||
function ENT: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 )
|
|
||||||
self:Print("To be saved during recreate.")
|
|
||||||
return
|
|
||||||
else
|
|
||||||
self:Print("Will NOT be saved during recreate.")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
self:Print("Will NOT be saved during recreate. No owner either")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
function ENT:AttachToEntity( ent )
|
|
||||||
if ent.SetInventory then
|
|
||||||
ent:SetInventory( self )
|
|
||||||
else
|
|
||||||
error( "[Inventory " .. tostring(self) .. "] " .. tostring(ent) .. " doesn't have a SetInventory function. Not attaching.")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
self:SetOwner( ent )
|
|
||||||
self:SetParent( ent )
|
|
||||||
self:SetPos( vector_origin )
|
|
||||||
self:SetAngles( angle_zero )
|
|
||||||
self:ReevalRecreate()
|
|
||||||
self:Print("Attached to: " .. tostring(ent))
|
|
||||||
end
|
|
||||||
|
|
||||||
function ENT:GetItems()
|
|
||||||
local itemlist = {}
|
|
||||||
|
|
||||||
for i=1, 32 do
|
|
||||||
local curr = self["GetItem"..i](self)
|
|
||||||
if curr == NULL then continue end
|
|
||||||
table.insert( itemlist, curr )
|
|
||||||
end
|
|
||||||
|
|
||||||
return itemlist
|
|
||||||
end
|
|
||||||
|
|
||||||
function ENT:GetWeighted()
|
|
||||||
local itemlist = {}
|
|
||||||
|
|
||||||
for i, v in pairs(self:GetItems()) do
|
|
||||||
if i == 0 then continue end
|
|
||||||
table.insert( itemlist, v )
|
|
||||||
end
|
|
||||||
|
|
||||||
table.sort( itemlist, function( a, b )
|
|
||||||
return a:GetAcquisition() < b:GetAcquisition()
|
|
||||||
end)
|
|
||||||
|
|
||||||
return itemlist
|
|
||||||
end
|
|
||||||
|
|
||||||
function ENT:AddItem( ent )
|
|
||||||
if !ent:IsValid() then
|
|
||||||
self:Print("Invalid entity, printing trace" )
|
|
||||||
debug.Trace()
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
for i=1+self:GetReservedSlots(), 32 do
|
|
||||||
local curr = self["GetItem"..i](self)
|
|
||||||
if curr == NULL then continue end
|
|
||||||
if curr == ent then self:Print("We already own this entity " .. tostring(ent) ) return false end
|
|
||||||
end
|
|
||||||
|
|
||||||
for i=1+self:GetReservedSlots(), 32 do
|
|
||||||
local curr = self["GetItem"..i](self)
|
|
||||||
if curr == NULL then
|
|
||||||
self["SetItem"..i](self, ent)
|
|
||||||
ent:SetParent( self:GetOwner() )
|
|
||||||
ent:SetOwner( self:GetOwner() )
|
|
||||||
self:ReevalRecreate() -- Why do I have to do this.
|
|
||||||
if ent.GetInventory then ent:GetInventory():ReevalRecreate() end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self:Print("Inventory full, can't fit " .. tostring(ent) )
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
function ENT:RemoveItem( ent )
|
|
||||||
if !ent:IsValid() then
|
|
||||||
self:Print("Invalid entity, printing trace" )
|
|
||||||
debug.Trace()
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
for i=1+self:GetReservedSlots(), 32 do
|
|
||||||
local curr = self["GetItem"..i](self)
|
|
||||||
if curr == ent then
|
|
||||||
self["SetItem"..i](self, NULL)
|
|
||||||
ent:SetParent( NULL )
|
|
||||||
ent:SetOwner( NULL )
|
|
||||||
self:ReevalRecreate() -- Why do I have to do this.
|
|
||||||
if ent.GetInventory then ent:GetInventory():ReevalRecreate() end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self:Print("Couldn't remove " .. tostring(ent) .. " from inventory." )
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
function ENT:GetItem( ent )
|
|
||||||
if !ent:IsValid() then
|
|
||||||
self:Print("Invalid entity, printing trace" )
|
|
||||||
debug.Trace()
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
for i=1+self:GetReservedSlots(), 32 do
|
|
||||||
local curr = self["GetItem"..i](self)
|
|
||||||
if curr == ent then
|
|
||||||
return curr, i
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self:Print("Couldn't find " .. tostring(ent) .. " in inventory." )
|
|
||||||
return false
|
|
||||||
end
|
|
|
@ -62,14 +62,11 @@ end
|
||||||
function SWEP:SetActive( ent )
|
function SWEP:SetActive( ent )
|
||||||
local p = self:GetOwner()
|
local p = self:GetOwner()
|
||||||
if ent:GetOwner() != p then return false end
|
if ent:GetOwner() != p then return false end
|
||||||
|
--if self:GetActiveR():IsValid() then self:Deactive() end
|
||||||
self:SetActiveR( ent )
|
self:SetActiveR( ent )
|
||||||
if ent:IsValid() then
|
if self:GetActiveR():IsValid() then
|
||||||
ent:Deploy()
|
self:GetActiveR():Deploy()
|
||||||
ent:SetNoDraw( false )
|
self:GetActiveR():SetNoDraw( false )
|
||||||
-- LAZY FIX
|
|
||||||
for i, v in ipairs(ent:GetChildren()) do
|
|
||||||
v:SetNoDraw(false)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -78,6 +75,7 @@ function SWEP:Deactive()
|
||||||
end
|
end
|
||||||
|
|
||||||
function SWEP:PrimaryAttack()
|
function SWEP:PrimaryAttack()
|
||||||
|
local p = self:GetOwner()
|
||||||
if self:GetActiveR():IsValid() then
|
if self:GetActiveR():IsValid() then
|
||||||
self:GetActiveR():Attack()
|
self:GetActiveR():Attack()
|
||||||
end
|
end
|
||||||
|
@ -90,6 +88,7 @@ function SWEP:Reload()
|
||||||
end
|
end
|
||||||
|
|
||||||
function SWEP:SecondaryAttack()
|
function SWEP:SecondaryAttack()
|
||||||
|
local p = self:GetOwner()
|
||||||
if self:GetActiveR():IsValid() then
|
if self:GetActiveR():IsValid() then
|
||||||
self:GetActiveR():AttackAlt()
|
self:GetActiveR():AttackAlt()
|
||||||
end
|
end
|
||||||
|
@ -122,34 +121,27 @@ function SWEP:EquipItem( ent )
|
||||||
end
|
end
|
||||||
print("[equip]", ent)
|
print("[equip]", ent)
|
||||||
|
|
||||||
--self:SetDesireR( ent )
|
self:SetDesireR( ent )
|
||||||
ent:SetHandler( self )
|
|
||||||
|
|
||||||
ent:AddEFlags( EFL_KEEP_ON_RECREATE_ENTITIES )
|
ent:AddEFlags( EFL_KEEP_ON_RECREATE_ENTITIES )
|
||||||
ent:AddEffects( EF_BONEMERGE + EF_BONEMERGE_FASTCULL + EF_NOINTERP )
|
ent:AddEffects( EF_BONEMERGE )
|
||||||
ent:PhysicsInit( SOLID_NONE )
|
ent:PhysicsInit( SOLID_NONE )
|
||||||
ent:SetMoveType( MOVETYPE_NONE )
|
ent:SetMoveType( MOVETYPE_NONE )
|
||||||
ent:SetAcquisition( CurTime() )
|
|
||||||
|
|
||||||
-- Inventory
|
|
||||||
local inv = p:GetInventory()
|
|
||||||
local result = inv:AddItem( ent )
|
|
||||||
if !result then
|
|
||||||
print("[EquipItem " .. tostring(self) .. "] AddItem failed! " .. tostring(ent))
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
ent:SetNoDraw( true )
|
ent:SetNoDraw( true )
|
||||||
-- LAZY FIX
|
ent:SetParent( p )
|
||||||
for i, v in ipairs(ent:GetChildren()) do
|
ent:SetOwner( p )
|
||||||
v:SetNoDraw(true)
|
ent:SetHandler( self )
|
||||||
end
|
|
||||||
ent:SetLocalPos( vector_origin )
|
ent:SetLocalPos( vector_origin )
|
||||||
ent:SetLocalAngles( angle_zero )
|
ent:SetLocalAngles( angle_zero )
|
||||||
|
ent:SetAcquisition( CurTime() )
|
||||||
|
|
||||||
ent:EmitSound( "ae/items/pickup.ogg", 70, 100, 1, CHAN_STATIC )
|
ent:EmitSound( "ae/items/pickup.ogg", 70, 100, 1, CHAN_STATIC )
|
||||||
|
|
||||||
-- Start prediction
|
--self:SetActive( ent )
|
||||||
|
local inv = p:GetInventory()
|
||||||
|
inv[ent] = true
|
||||||
|
inv:Sync()
|
||||||
|
|
||||||
net.Start("AEINV_PredictItem")
|
net.Start("AEINV_PredictItem")
|
||||||
net.WriteEntity( ent )
|
net.WriteEntity( ent )
|
||||||
net.WriteBool( true )
|
net.WriteBool( true )
|
||||||
|
@ -164,36 +156,30 @@ function SWEP:DropItem()
|
||||||
if CLIENT then print("[drop] DropItem called on cl not allowed") return end
|
if CLIENT then print("[drop] DropItem called on cl not allowed") return end
|
||||||
|
|
||||||
self:SetDesireR( NULL )
|
self:SetDesireR( NULL )
|
||||||
|
|
||||||
|
ent:SetParent( NULL )
|
||||||
|
ent:SetOwner( NULL )
|
||||||
ent:SetHandler( NULL )
|
ent:SetHandler( NULL )
|
||||||
|
|
||||||
ent:RemoveEFlags( EFL_KEEP_ON_RECREATE_ENTITIES )
|
ent:RemoveEFlags( EFL_KEEP_ON_RECREATE_ENTITIES )
|
||||||
ent:RemoveEffects( EF_BONEMERGE + EF_BONEMERGE_FASTCULL )
|
ent:RemoveEffects( EF_BONEMERGE )
|
||||||
ent:PhysicsInit( SOLID_VPHYSICS )
|
ent:PhysicsInit( SOLID_VPHYSICS )
|
||||||
ent:SetMoveType( MOVETYPE_VPHYSICS )
|
ent:SetMoveType( MOVETYPE_VPHYSICS )
|
||||||
ent:SetCollisionGroup( COLLISION_GROUP_PROJECTILE )
|
ent:SetCollisionGroup( COLLISION_GROUP_PROJECTILE )
|
||||||
|
|
||||||
-- Inventory
|
|
||||||
local inv = p:GetInventory()
|
|
||||||
local result = inv:RemoveItem( ent )
|
|
||||||
if !result then
|
|
||||||
print("[DropItem " .. tostring(self) .. "] RemoveItem failed! " .. tostring(ent))
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
ent:SetNoDraw( false )
|
ent:SetNoDraw( false )
|
||||||
-- LAZY FIX
|
|
||||||
for i, v in ipairs(ent:GetChildren()) do
|
|
||||||
v:SetNoDraw(false)
|
|
||||||
end
|
|
||||||
ent:SetPos( p:EyePos() + p:GetAimVector() * 0 )
|
ent:SetPos( p:EyePos() + p:GetAimVector() * 0 )
|
||||||
ent:SetAngles( p:EyeAngles() + Angle( 0, 180, 0 ) )
|
ent:SetAngles( p:EyeAngles() + Angle( 0, 180, 0 ) )
|
||||||
|
|
||||||
|
|
||||||
|
local inv = p:GetInventory()
|
||||||
|
inv[ent] = nil
|
||||||
|
inv:Sync()
|
||||||
|
|
||||||
local ep = ent:GetPhysicsObject()
|
local ep = ent:GetPhysicsObject()
|
||||||
ep:SetVelocity( p:GetAimVector() * 800 )
|
ep:SetVelocity( p:GetAimVector() * 800 )
|
||||||
ep:SetAngleVelocity( Vector( 0, -360*3, 0 ) )
|
ep:SetAngleVelocity( Vector( 0, -360*3, 0 ) )
|
||||||
ep:Wake()
|
ep:Wake()
|
||||||
|
|
||||||
-- Prediction is not actually turned off here, for better throwing
|
|
||||||
--net.Start("AEINV_PredictItem")
|
--net.Start("AEINV_PredictItem")
|
||||||
-- net.WriteEntity( ent )
|
-- net.WriteEntity( ent )
|
||||||
-- net.WriteBool( false )
|
-- net.WriteBool( false )
|
||||||
|
@ -207,23 +193,23 @@ function SWEP:Think()
|
||||||
if p:IsValid() then
|
if p:IsValid() then
|
||||||
local DesireR = self:GetDesireR()
|
local DesireR = self:GetDesireR()
|
||||||
local ActiveR = self:GetActiveR()
|
local ActiveR = self:GetActiveR()
|
||||||
DesireR = DesireR:IsValid() and DesireR or false
|
local DesireR_Valid = DesireR:IsValid()
|
||||||
ActiveR = ActiveR:IsValid() and ActiveR or false
|
local ActiveR_Valid = ActiveR:IsValid()
|
||||||
|
|
||||||
if DesireR != ActiveR then
|
if DesireR != ActiveR then
|
||||||
if ActiveR then
|
if ActiveR_Valid then
|
||||||
if ActiveR:GetHolsterIn() == 0 then
|
if ActiveR:GetHolsterIn() == 0 then
|
||||||
ActiveR:StartHolster()
|
ActiveR:StartHolster()
|
||||||
else
|
else
|
||||||
-- Waiting for holster to finish
|
-- Waiting for holster to finish
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if DesireR then
|
if DesireR_Valid then
|
||||||
self:SetActive( DesireR )
|
self:SetActive( DesireR )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if ActiveR and ActiveR:GetHolsterIn() != 0 then
|
if ActiveR_Valid and ActiveR:GetHolsterIn() != 0 then
|
||||||
ActiveR:CancelHolster()
|
ActiveR:CancelHolster()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -88,8 +88,8 @@ function GM:CalcView( ply, pos, ang, fov )
|
||||||
view.origin = bm:GetTranslation()
|
view.origin = bm:GetTranslation()
|
||||||
view.origin:Add( vector_up*8 )
|
view.origin:Add( vector_up*8 )
|
||||||
|
|
||||||
if ply:GetLayerSequence( BGESTURE_JUMP ) == ply:LookupSequence("dive_end_handgun") then
|
if ply:GetLayerSequence( GESTURE_SLOT_JUMP ) == ply:LookupSequence("dive_end_handgun") then
|
||||||
local progress = ply:GetLayerCycle( BGESTURE_JUMP )
|
local progress = ply:GetLayerCycle( GESTURE_SLOT_JUMP )
|
||||||
|
|
||||||
progress = math.TimeFraction( 0.15, 0.7, progress )
|
progress = math.TimeFraction( 0.15, 0.7, progress )
|
||||||
progress = math.Clamp( progress, 0, 1 )
|
progress = math.Clamp( progress, 0, 1 )
|
||||||
|
|
|
@ -368,6 +368,6 @@ function printallbones( ent )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
concommand.Add("b-debug_listbones", function( ply, cmd, args )
|
concommand.Add("b-debug_listbones", function( ply, cmd )
|
||||||
printallbones( args[1] and Entity(args[1]) or ply )
|
printallbones( ply )
|
||||||
end)
|
end)
|
|
@ -369,81 +369,77 @@ function GM:HUDPaint()
|
||||||
S_Pop()
|
S_Pop()
|
||||||
|
|
||||||
if handler then
|
if handler then
|
||||||
if !p:GetInventory():IsValid() then
|
-- Inventory
|
||||||
hTextS( "No inventory entity!!", "HUD_36", ScrW()/2, ScrH() - 20 - 36, COLOR_MAIN, TEXT_ALIGN_CENTER, nil, COLOR_DARK )
|
local Pw, Ph, Pg = 110, 30, 10
|
||||||
else
|
local thespace = 0
|
||||||
-- Inventory
|
for i, v in ipairs( p:GetInventory():GetWeighted() ) do
|
||||||
local Pw, Ph, Pg = 110, 30, 10
|
thespace = thespace + Pw + Pg
|
||||||
local thespace = 0
|
end
|
||||||
|
thespace = thespace - Pg
|
||||||
|
thespace = thespace/2
|
||||||
|
|
||||||
|
S_Push( ScrW()/2 - thespace, ScrH() - 20 - Ph )
|
||||||
for i, v in ipairs( p:GetInventory():GetWeighted() ) do
|
for i, v in ipairs( p:GetInventory():GetWeighted() ) do
|
||||||
thespace = thespace + Pw + Pg
|
hCol( v == handler:GetDesireR() and COLOR_BRIGHT or COLOR_DARK )
|
||||||
end
|
hRect( (i-1)*(Pw+Pg), 0, Pw, Ph )
|
||||||
thespace = thespace - Pg
|
if v == handler:GetActiveR() then
|
||||||
thespace = thespace/2
|
hCol( COLOR_MAIN )
|
||||||
|
hORect( (i-1)*(Pw+Pg)+1, 1, Pw-2, Ph-2, 1 )
|
||||||
S_Push( ScrW()/2 - thespace, ScrH() - 20 - Ph )
|
|
||||||
for i, v in ipairs( p:GetInventory():GetWeighted() ) do
|
|
||||||
hCol( v == handler:GetDesireR() and COLOR_BRIGHT or COLOR_DARK )
|
|
||||||
hRect( (i-1)*(Pw+Pg), 0, Pw, Ph )
|
|
||||||
if v == handler:GetActiveR() then
|
|
||||||
hCol( COLOR_MAIN )
|
|
||||||
hORect( (i-1)*(Pw+Pg)+1, 1, Pw-2, Ph-2, 1 )
|
|
||||||
end
|
|
||||||
local x, y = (i-1)*(Pw+Pg), 0
|
|
||||||
hText( l8( v.Class.PrintName ), "HUD_24", x + Pw/2, y + 5, COLOR_MAIN, TEXT_ALIGN_CENTER )
|
|
||||||
hText( i, "HUD_16", x + 4, y + 2, COLOR_MAIN )
|
|
||||||
end
|
end
|
||||||
S_Pop()
|
local x, y = (i-1)*(Pw+Pg), 0
|
||||||
|
hText( l8( v.Class.PrintName ), "HUD_24", x + Pw/2, y + 5, COLOR_MAIN, TEXT_ALIGN_CENTER )
|
||||||
local wep = handler:GetDesireR()
|
hText( i, "HUD_16", x + 4, y + 2, COLOR_MAIN )
|
||||||
if wep and wep.GetClip then
|
|
||||||
local Bw, Bh = 8+(8+2)*30-2+8, 160
|
|
||||||
S_Push( w - 20 - Bw, h - 20 - Bh )
|
|
||||||
hCol( COLOR_DARK )
|
|
||||||
hRect( 0, 0, Bw, Bh )
|
|
||||||
|
|
||||||
S_Push( 0, 0 )
|
|
||||||
hCol( COLOR_MAIN )
|
|
||||||
local leng = Bw-8-8
|
|
||||||
hRect( 8, 8, leng-70, 26 )
|
|
||||||
hRect( 8 + leng - 70 + 4, 8, leng-(leng-70)-4, 26 )
|
|
||||||
hText( l8( wep.Class.PrintName ), "HUD_36", 12, 6, COLOR_DARK )
|
|
||||||
local bc = wep.Class.BurstCount
|
|
||||||
hText( fmlookup[bc] or bc .. "RND", "HUD_24", 10 + (leng - 70) + 70/2, 11, COLOR_DARK, TEXT_ALIGN_CENTER )
|
|
||||||
S_Pop()
|
|
||||||
|
|
||||||
local Tw, Th = 6, 18
|
|
||||||
|
|
||||||
if wep.Class.ClipSize>45 then
|
|
||||||
Tw = 3
|
|
||||||
Th = 13
|
|
||||||
elseif wep.Class.ClipSize<14 then
|
|
||||||
Tw = 8
|
|
||||||
Th = 22
|
|
||||||
end
|
|
||||||
|
|
||||||
S_Push( Bw - Tw - 8, Bh - Th - 8 )
|
|
||||||
for i=0, wep.Class.ClipSize-1 do
|
|
||||||
if i>29 then
|
|
||||||
hCol( COLOR_DARK )
|
|
||||||
hRect( (0 - Tw - 2)*i-4, -4, Tw+2, Th+8 )
|
|
||||||
end
|
|
||||||
end
|
|
||||||
for i=0, wep.Class.ClipSize-1 do
|
|
||||||
if wep:GetClip() >= (i+1) then
|
|
||||||
hCol( COLOR_MAIN )
|
|
||||||
hRect( (0 - Tw - 2)*i, 0, Tw, Th )
|
|
||||||
hCol( COLOR_DARK )
|
|
||||||
hRect( (0 - Tw - 2)*i, Th-4, Tw, 2 )
|
|
||||||
else
|
|
||||||
hCol( COLOR_BRIGHT )
|
|
||||||
hORect( (0 - Tw - 2)*i, 0, Tw, Th )
|
|
||||||
--hORect( (0 - 8 - 2)*i+1, 1, 8-2, 18-2 )
|
|
||||||
end
|
|
||||||
end
|
|
||||||
S_Pop()
|
|
||||||
S_Pop()
|
|
||||||
end
|
end
|
||||||
|
S_Pop()
|
||||||
|
|
||||||
|
local wep = handler:GetDesireR()
|
||||||
|
if wep and wep.GetClip then
|
||||||
|
local Bw, Bh = 8+(8+2)*30-2+8, 160
|
||||||
|
S_Push( w - 20 - Bw, h - 20 - Bh )
|
||||||
|
hCol( COLOR_DARK )
|
||||||
|
hRect( 0, 0, Bw, Bh )
|
||||||
|
|
||||||
|
S_Push( 0, 0 )
|
||||||
|
hCol( COLOR_MAIN )
|
||||||
|
local leng = Bw-8-8
|
||||||
|
hRect( 8, 8, leng-70, 26 )
|
||||||
|
hRect( 8 + leng - 70 + 4, 8, leng-(leng-70)-4, 26 )
|
||||||
|
hText( l8( wep.Class.PrintName ), "HUD_36", 12, 6, COLOR_DARK )
|
||||||
|
local bc = wep.Class.BurstCount
|
||||||
|
hText( fmlookup[bc] or bc .. "RND", "HUD_24", 10 + (leng - 70) + 70/2, 11, COLOR_DARK, TEXT_ALIGN_CENTER )
|
||||||
|
S_Pop()
|
||||||
|
|
||||||
|
local Tw, Th = 6, 18
|
||||||
|
|
||||||
|
if wep.Class.ClipSize>45 then
|
||||||
|
Tw = 3
|
||||||
|
Th = 13
|
||||||
|
elseif wep.Class.ClipSize<14 then
|
||||||
|
Tw = 8
|
||||||
|
Th = 22
|
||||||
|
end
|
||||||
|
|
||||||
|
S_Push( Bw - Tw - 8, Bh - Th - 8 )
|
||||||
|
for i=0, wep.Class.ClipSize-1 do
|
||||||
|
if i>29 then
|
||||||
|
hCol( COLOR_DARK )
|
||||||
|
hRect( (0 - Tw - 2)*i-4, -4, Tw+2, Th+8 )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for i=0, wep.Class.ClipSize-1 do
|
||||||
|
if wep:GetClip() >= (i+1) then
|
||||||
|
hCol( COLOR_MAIN )
|
||||||
|
hRect( (0 - Tw - 2)*i, 0, Tw, Th )
|
||||||
|
hCol( COLOR_DARK )
|
||||||
|
hRect( (0 - Tw - 2)*i, Th-4, Tw, 2 )
|
||||||
|
else
|
||||||
|
hCol( COLOR_BRIGHT )
|
||||||
|
hORect( (0 - Tw - 2)*i, 0, Tw, Th )
|
||||||
|
--hORect( (0 - 8 - 2)*i+1, 1, 8-2, 18-2 )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
S_Pop()
|
||||||
|
S_Pop()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -877,82 +873,6 @@ local function QuickDrawStat( wide, data, first )
|
||||||
return gap
|
return gap
|
||||||
end
|
end
|
||||||
|
|
||||||
local c_swag = HSVToColor( 120, 0.5, 1 )
|
|
||||||
local c_swag2 = HSVToColor( 60, 0.5, 1 )
|
|
||||||
local c_swag3 = HSVToColor( 180, 0.5, 1 )
|
|
||||||
|
|
||||||
local function recurse( ent, y )
|
|
||||||
local p = LocalPlayer()
|
|
||||||
local h = p:HandlerCheck()
|
|
||||||
local inv = ent:GetInventory()
|
|
||||||
local irs = inv:GetReservedSlots()
|
|
||||||
|
|
||||||
S_Push( 20, 0 )
|
|
||||||
hTextS( "Inventory [" .. inv:EntIndex() .. "]", "HUD_16", 0, y, nil, nil, nil, color_black )
|
|
||||||
y = y + 12
|
|
||||||
for i=1, 32 do
|
|
||||||
local curr = inv["GetItem"..i](self)
|
|
||||||
if irs < i and curr == NULL then continue end
|
|
||||||
local ofinterest = curr != NULL and
|
|
||||||
((curr == h:GetActiveR() or curr == h:GetActiveL()) and c_swag or
|
|
||||||
(curr == h:GetDesireR() or curr == h:GetDesireL()) and c_swag2) or
|
|
||||||
irs >= i and c_swag3 or nil
|
|
||||||
|
|
||||||
local entname = curr == NULL and (irs >= i and "Reserved" or "Null") or tostring(curr)
|
|
||||||
hTextS( i, "HUD_16", 0, y, ofinterest, nil, nil, color_black )
|
|
||||||
hTextS( entname, "HUD_16", 20, y, ofinterest, nil, nil, color_black )
|
|
||||||
y = y + 12
|
|
||||||
if curr.GetInventory then
|
|
||||||
y = recurse( curr, y )
|
|
||||||
end
|
|
||||||
end
|
|
||||||
S_Pop()
|
|
||||||
|
|
||||||
return y
|
|
||||||
end
|
|
||||||
|
|
||||||
hook.Add("HUDPaint", "Benny_HUDPaint_Debug", function()
|
|
||||||
local p = LocalPlayer()
|
|
||||||
stack = util.Stack()
|
|
||||||
|
|
||||||
local y = 0
|
|
||||||
S_Push( 20, 120 )
|
|
||||||
hTextS( p, "HUD_16", 0, y, nil, nil, nil, color_black )
|
|
||||||
y = y + 12
|
|
||||||
|
|
||||||
local h = p:HandlerCheck()
|
|
||||||
if h then
|
|
||||||
hTextS( "Handler:", "HUD_16", 20, y, nil, nil, nil, color_black )
|
|
||||||
y = y + 12
|
|
||||||
|
|
||||||
hTextS( "R Active: " .. tostring(h:GetActiveR()), "HUD_16", 40, y, nil, nil, nil, color_black )
|
|
||||||
y = y + 12
|
|
||||||
hTextS( "R Desire: " .. tostring(h:GetDesireR()), "HUD_16", 40, y, nil, nil, nil, color_black )
|
|
||||||
y = y + 12
|
|
||||||
hTextS( "L Active: " .. tostring(h:GetActiveL()), "HUD_16", 40, y, nil, nil, nil, color_black )
|
|
||||||
y = y + 12
|
|
||||||
hTextS( "L Desire: " .. tostring(h:GetDesireL()), "HUD_16", 40, y, nil, nil, nil, color_black )
|
|
||||||
y = y + 12
|
|
||||||
end
|
|
||||||
|
|
||||||
local x = 20+20
|
|
||||||
y = recurse( p, y )
|
|
||||||
|
|
||||||
if false then
|
|
||||||
hTextS( "Inventory (Weighted):", "HUD_16", 20, y, nil, nil, nil, color_black )
|
|
||||||
y = y + 12
|
|
||||||
|
|
||||||
for i, v in ipairs(p:GetInventory():GetWeighted()) do
|
|
||||||
hTextS( i .. ": " .. tostring(v), "HUD_16", 20+20, y, nil, nil, nil, color_black )
|
|
||||||
y = y + 12
|
|
||||||
end
|
|
||||||
end
|
|
||||||
S_Pop()
|
|
||||||
|
|
||||||
if stack:Size() != 0 then print("Stack unfinished.") end
|
|
||||||
return
|
|
||||||
end)
|
|
||||||
|
|
||||||
local ScoreWide = 600
|
local ScoreWide = 600
|
||||||
function GM:ScoreboardShow()
|
function GM:ScoreboardShow()
|
||||||
drawscoreboard = true
|
drawscoreboard = true
|
||||||
|
|
|
@ -1,64 +1,179 @@
|
||||||
|
|
||||||
local Emeta = FindMetaTable("Entity")
|
---------------------
|
||||||
|
-- Your Name is Benny
|
||||||
|
---------------------
|
||||||
|
|
||||||
local qt2 = {
|
local PT = FindMetaTable("Player")
|
||||||
["slot1"] = 1,
|
|
||||||
["slot2"] = 2,
|
|
||||||
["slot3"] = 3,
|
|
||||||
["slot4"] = 4,
|
|
||||||
["slot5"] = 5,
|
|
||||||
["slot6"] = 6,
|
|
||||||
["slot7"] = 7,
|
|
||||||
["slot8"] = 8,
|
|
||||||
["slot9"] = 9,
|
|
||||||
["slot0"] = 0,
|
|
||||||
}
|
|
||||||
local qt = {
|
|
||||||
["invprev"] = -1,
|
|
||||||
["invnext"] = 1,
|
|
||||||
}
|
|
||||||
|
|
||||||
hook.Add( "PlayerBindPress", "Benny_PlayerBindPress_Original", function( ply, bind, pressed, code )
|
function PT:GetItems()
|
||||||
if qt2[bind] then
|
return
|
||||||
local Num = qt2[bind]
|
end
|
||||||
if pressed then
|
|
||||||
local inv = ply:GetInventory():GetWeighted()
|
|
||||||
local wep = ply:HandlerCheck()
|
|
||||||
local invf = table.Flip( inv )
|
|
||||||
|
|
||||||
local NumOfActive = 0
|
InventoryMeta = {}
|
||||||
NumOfActive = invf[wep:GetDesireR()]
|
|
||||||
|
|
||||||
if Num == NumOfActive then
|
function InventoryMeta:Destroy()
|
||||||
Num = 0
|
local p = self[0].Owner
|
||||||
end
|
p.Inventory = nil
|
||||||
input.SelectWeapon( ply:GetWeapon("goat_"..Num) )
|
p:GetInventory()
|
||||||
|
end
|
||||||
|
|
||||||
|
function InventoryMeta:BugCheck()
|
||||||
|
for i, v in pairs(self) do
|
||||||
|
if i != 0 and !i:IsValid() then
|
||||||
|
self[i] = nil
|
||||||
end
|
end
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
if qt[bind] then
|
end
|
||||||
if pressed then
|
|
||||||
local Num = 0
|
|
||||||
|
|
||||||
local inv = ply:GetInventory():GetWeighted()
|
function InventoryMeta:GetWeighted()
|
||||||
local wep = ply:HandlerCheck()
|
local itemlist = {}
|
||||||
local invf = table.Flip( inv )
|
|
||||||
local invc = #inv
|
|
||||||
|
|
||||||
Num = wep:GetDesireR() and invf[wep:GetDesireR()] or 0
|
|
||||||
Num = Num + qt[bind]
|
|
||||||
|
|
||||||
if Num > invc then
|
for i, v in pairs(self) do
|
||||||
Num = 0
|
if i == 0 then continue end
|
||||||
elseif Num < 0 then
|
table.insert( itemlist, i )
|
||||||
Num = invc
|
end
|
||||||
|
|
||||||
|
table.sort( itemlist, function( a, b )
|
||||||
|
return a:GetAcquisition() < b:GetAcquisition()
|
||||||
|
end)
|
||||||
|
|
||||||
|
return itemlist
|
||||||
|
end
|
||||||
|
|
||||||
|
function InventoryMeta:Sync()
|
||||||
|
if SERVER then
|
||||||
|
net.Start("AEINV_InvSync")
|
||||||
|
local count = table.Count( self )-1 -- The header is included
|
||||||
|
net.WriteUInt( count, 8 )
|
||||||
|
for key, _ in pairs( self ) do
|
||||||
|
if key == 0 then continue end
|
||||||
|
net.WriteEntity( key )
|
||||||
end
|
end
|
||||||
|
net.Send( self[0].Owner )
|
||||||
input.SelectWeapon( ply:GetWeapon("goat_"..Num) )
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
end)
|
end
|
||||||
|
|
||||||
|
InventoryMeta.__index = InventoryMeta
|
||||||
|
|
||||||
|
function PT:GetInventory()
|
||||||
|
if !self.Inventory then
|
||||||
|
print("[inventory] new inventory created: ", self)
|
||||||
|
self.Inventory = {}
|
||||||
|
self.Inventory[0] = { Owner = self }
|
||||||
|
setmetatable( self.Inventory, InventoryMeta )
|
||||||
|
|
||||||
|
if SERVER then
|
||||||
|
for i, v in pairs( self:GetChildren() ) do
|
||||||
|
if v.AEItem then
|
||||||
|
print( "[inventory] regen: adding", v)
|
||||||
|
self.Inventory[v] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.Inventory:Sync()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self.Inventory:BugCheck()
|
||||||
|
|
||||||
|
return self.Inventory
|
||||||
|
end
|
||||||
|
|
||||||
|
gameevent.Listen( "OnRequestFullUpdate" )
|
||||||
|
hook.Add( "OnRequestFullUpdate", "Benny_OnRequestFullUpdate_Inventory", function( data )
|
||||||
|
local name = data.name // Same as Player:Nick()
|
||||||
|
local steamid = data.networkid // Same as Player:SteamID()
|
||||||
|
local id = data.userid // Same as Player:UserID()
|
||||||
|
local index = data.index // Same as Entity:EntIndex() minus one
|
||||||
|
|
||||||
|
if SERVER then
|
||||||
|
print("[inventory]", Player(id), "FullUpdate resync")
|
||||||
|
Player(id):GetInventory():Sync()
|
||||||
|
end
|
||||||
|
end )
|
||||||
|
|
||||||
|
if SERVER then
|
||||||
|
util.AddNetworkString("AEINV_InvSync")
|
||||||
|
else
|
||||||
|
net.Receive("AEINV_InvSync", function()
|
||||||
|
print("[inventory] sync start:")
|
||||||
|
local p = LocalPlayer()
|
||||||
|
p.Inventory = nil
|
||||||
|
if p.GetInventory then
|
||||||
|
local inv = p:GetInventory()
|
||||||
|
local count = net.ReadUInt(8)
|
||||||
|
for i=1, count do
|
||||||
|
local key = net.ReadEntity()
|
||||||
|
print( "\tadded", key)
|
||||||
|
inv[key] = true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
print("\ti don't have an inventory, maybe you asked too early!!")
|
||||||
|
end
|
||||||
|
print("\tsync done")
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
do
|
||||||
|
local qt2 = {
|
||||||
|
["slot1"] = 1,
|
||||||
|
["slot2"] = 2,
|
||||||
|
["slot3"] = 3,
|
||||||
|
["slot4"] = 4,
|
||||||
|
["slot5"] = 5,
|
||||||
|
["slot6"] = 6,
|
||||||
|
["slot7"] = 7,
|
||||||
|
["slot8"] = 8,
|
||||||
|
["slot9"] = 9,
|
||||||
|
["slot0"] = 0,
|
||||||
|
}
|
||||||
|
local qt = {
|
||||||
|
["invprev"] = -1,
|
||||||
|
["invnext"] = 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
hook.Add( "PlayerBindPress", "Benny_PlayerBindPress_Original", function( ply, bind, pressed, code )
|
||||||
|
if qt2[bind] then
|
||||||
|
local Num = qt2[bind]
|
||||||
|
if pressed then
|
||||||
|
local inv = ply:GetInventory():GetWeighted()
|
||||||
|
local wep = ply:HandlerCheck()
|
||||||
|
local invf = table.Flip( inv )
|
||||||
|
|
||||||
|
local NumOfActive = 0
|
||||||
|
NumOfActive = invf[wep:GetDesireR()]
|
||||||
|
|
||||||
|
if Num == NumOfActive then
|
||||||
|
Num = 0
|
||||||
|
end
|
||||||
|
input.SelectWeapon( ply:GetWeapon("goat_"..Num) )
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
if qt[bind] then
|
||||||
|
if pressed then
|
||||||
|
local Num = 0
|
||||||
|
|
||||||
|
local inv = ply:GetInventory():GetWeighted()
|
||||||
|
local wep = ply:HandlerCheck()
|
||||||
|
local invf = table.Flip( inv )
|
||||||
|
local invc = #inv
|
||||||
|
|
||||||
|
Num = wep:GetDesireR() and invf[wep:GetDesireR()] or 0
|
||||||
|
Num = Num + qt[bind]
|
||||||
|
|
||||||
|
if Num > invc then
|
||||||
|
Num = 0
|
||||||
|
elseif Num < 0 then
|
||||||
|
Num = invc
|
||||||
|
end
|
||||||
|
|
||||||
|
input.SelectWeapon( ply:GetWeapon("goat_"..Num) )
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
hook.Add( "PlayerSwitchWeapon", "Benny_PlayerSwitchWeapon_Goat", function( ply, old, ent )
|
hook.Add( "PlayerSwitchWeapon", "Benny_PlayerSwitchWeapon_Goat", function( ply, old, ent )
|
||||||
if ent.BennyItemHandler then return true end -- what happened?
|
if ent.BennyItemHandler then return true end -- what happened?
|
||||||
|
@ -80,6 +195,7 @@ end)
|
||||||
|
|
||||||
for i=0, 9 do
|
for i=0, 9 do
|
||||||
local tent = {}
|
local tent = {}
|
||||||
|
--tent.Base = "goat"
|
||||||
tent.Goat = i
|
tent.Goat = i
|
||||||
|
|
||||||
weapons.Register( tent, "goat_" .. i )
|
weapons.Register( tent, "goat_" .. i )
|
||||||
|
|
|
@ -19,22 +19,6 @@ function Emeta:__index( key )
|
||||||
return Emetaindex( self, key )
|
return Emetaindex( self, key )
|
||||||
end
|
end
|
||||||
|
|
||||||
function Emeta:SetupInventory()
|
|
||||||
local oldinv = self:GetInventory()
|
|
||||||
if IsValid( oldinv ) then
|
|
||||||
print( "[Inventory " .. tostring(oldinv) .. "] Removing to create a new inv" )
|
|
||||||
oldinv:Remove()
|
|
||||||
end
|
|
||||||
|
|
||||||
local inventory = ents.Create( "inventory" )
|
|
||||||
if IsValid( inventory ) then
|
|
||||||
inventory:AttachToEntity( self )
|
|
||||||
inventory:Spawn()
|
|
||||||
return inventory
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local Itemmeta = {}
|
local Itemmeta = {}
|
||||||
|
|
||||||
function Itemmeta:__tostring()
|
function Itemmeta:__tostring()
|
||||||
|
|
|
@ -23,6 +23,7 @@ do -- Base
|
||||||
ITEM.CancelHolsterSound = bSound("dev/grab.ogg")
|
ITEM.CancelHolsterSound = bSound("dev/grab.ogg")
|
||||||
|
|
||||||
function ITEM:EntInitialize()
|
function ITEM:EntInitialize()
|
||||||
|
print( self )
|
||||||
for k, v in ipairs(self.DefaultBodygroups) do
|
for k, v in ipairs(self.DefaultBodygroups) do
|
||||||
if v then
|
if v then
|
||||||
self:SetBodygroup( k-1, v )
|
self:SetBodygroup( k-1, v )
|
||||||
|
@ -50,24 +51,7 @@ do -- Base
|
||||||
|
|
||||||
function ITEM:PlayerAnimation( seqname )
|
function ITEM:PlayerAnimation( seqname )
|
||||||
local p = self:GetOwner()
|
local p = self:GetOwner()
|
||||||
p:DoCustomAnimEvent( BGESTURE_ITEM1_RIGHT, p:LookupSequence( seqname ) )
|
p:DoAnimationEvent( 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
|
end
|
||||||
|
|
||||||
function ITEM:EntThink() end
|
function ITEM:EntThink() end
|
||||||
|
@ -88,10 +72,6 @@ do -- Base
|
||||||
|
|
||||||
self:GetHandler():SetActiveR( NULL )
|
self:GetHandler():SetActiveR( NULL )
|
||||||
self:SetNoDraw( true )
|
self:SetNoDraw( true )
|
||||||
-- LAZY FIX
|
|
||||||
for i, v in ipairs(self:GetChildren()) do
|
|
||||||
v:SetNoDraw(true)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function ITEM:CancelHolster()
|
function ITEM:CancelHolster()
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
do -- Base Firearm
|
do -- Base Firearm
|
||||||
local AnimationLookup = {
|
local AnimationLookup = {
|
||||||
["fire"] = {
|
["fire"] = {
|
||||||
|
@ -41,6 +42,7 @@ do -- Base Firearm
|
||||||
"Clip",
|
"Clip",
|
||||||
"BurstCount",
|
"BurstCount",
|
||||||
"Firemode",
|
"Firemode",
|
||||||
|
"ReloadStage",
|
||||||
},
|
},
|
||||||
["Float"] = {
|
["Float"] = {
|
||||||
"Delay",
|
"Delay",
|
||||||
|
@ -50,9 +52,6 @@ do -- Base Firearm
|
||||||
"Accuracy_Amount",
|
"Accuracy_Amount",
|
||||||
"DelayReload",
|
"DelayReload",
|
||||||
},
|
},
|
||||||
["Entity"] = {
|
|
||||||
"Inventory"
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ITEM.Delay = 0.2
|
ITEM.Delay = 0.2
|
||||||
|
@ -72,10 +71,6 @@ do -- Base Firearm
|
||||||
|
|
||||||
function ITEM:EntInitialize()
|
function ITEM:EntInitialize()
|
||||||
Base.EntInitialize( self )
|
Base.EntInitialize( self )
|
||||||
if SERVER then
|
|
||||||
local inv = self:SetupInventory()
|
|
||||||
inv:SetReservedSlots( 1 )
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function ITEM:Attack()
|
function ITEM:Attack()
|
||||||
|
@ -138,27 +133,8 @@ do -- Base Firearm
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if self:GetRefillTime() != 0 and self:GetRefillTime() <= CurTime() then
|
if self:GetRefillTime() != 0 and self:GetRefillTime() <= CurTime() then
|
||||||
self:SetClip( self.ClipSize )
|
self:SetClip( class.ClipSize )
|
||||||
self:SetRefillTime( 0 )
|
self:SetRefillTime( 0 )
|
||||||
|
|
||||||
if SERVER then
|
|
||||||
local inv = self:GetInventory()
|
|
||||||
local ent = ents.Create("b-item_mag_m16a2")
|
|
||||||
if IsValid(ent) then
|
|
||||||
ent:AddEffects( EF_BONEMERGE + EF_BONEMERGE_FASTCULL )
|
|
||||||
ent:SetOwner( self )
|
|
||||||
ent:SetParent( self )
|
|
||||||
ent:SetLocalPos( vector_origin )
|
|
||||||
ent:SetLocalAngles( angle_zero )
|
|
||||||
ent:Spawn()
|
|
||||||
self:ReevalRecreate()
|
|
||||||
ent:ReevalRecreate()
|
|
||||||
|
|
||||||
ent:SetMoveType( MOVETYPE_NONE )
|
|
||||||
|
|
||||||
inv:SetItem1( ent )
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
Base.Think( self )
|
Base.Think( self )
|
||||||
end
|
end
|
||||||
|
@ -174,52 +150,23 @@ do -- Base Firearm
|
||||||
local p = self:GetOwner()
|
local p = self:GetOwner()
|
||||||
local time = 0.4
|
local time = 0.4
|
||||||
|
|
||||||
if self:GetInventory():GetItem1():IsValid() then -- Mag loaded
|
if self:GetReloadStage() == 0 then -- Mag loaded
|
||||||
-- Unload the mag
|
-- Unload the mag
|
||||||
|
self:SetReloadStage(1)
|
||||||
self:SetClip( 0 )
|
self:SetClip( 0 )
|
||||||
self:Sound( self.MagOutSound, 70, 100, 0.4 )
|
self:Sound( self.MagOutSound, 70, 100, 0.4 )
|
||||||
self:PlayerAnimation( AnimationLookup["reload"][self.HoldType] )
|
self:PlayerAnimation( AnimationLookup["reload"][self.HoldType] )
|
||||||
self:PlayAnimation( self:LookupSequence( "magout" ) )
|
self:PlayAnimation( self:LookupSequence( "magout" ) )
|
||||||
time = 0.4
|
time = 0.4
|
||||||
|
|
||||||
if CLIENT then
|
|
||||||
local inv = self:GetInventory()
|
|
||||||
local curr = inv:GetItem1()
|
|
||||||
if curr:IsValid() then
|
|
||||||
local bm = self:GetBoneMatrix( self:LookupBone("Weapon") )
|
|
||||||
debugoverlay.Cross( bm:GetTranslation(), 16, 0.5 )
|
|
||||||
|
|
||||||
local class = ITEMS["mag_m16a2"]
|
|
||||||
local ent = ents.CreateClientProp( class.Model ) --- TO BE A SHARED ENTITY IN THE FUTURE :3
|
|
||||||
ent:SetPos( bm:GetTranslation() )
|
|
||||||
ent:SetAngles( bm:GetAngles() + Angle( 0, -90, -90 ) )
|
|
||||||
ent:Spawn()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if SERVER then
|
|
||||||
local inv = self:GetInventory()
|
|
||||||
local curr = inv:GetItem1()
|
|
||||||
if curr:IsValid() then
|
|
||||||
inv:SetItem1( NULL )
|
|
||||||
curr:SetOwner( NULL )
|
|
||||||
curr:SetParent( NULL )
|
|
||||||
|
|
||||||
curr:Remove()
|
|
||||||
self:ReevalRecreate()
|
|
||||||
-- curr:SetMoveType( MOVETYPE_VPHYSICS )
|
|
||||||
-- curr:GetPhysicsObject():Wake()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
-- Load it
|
-- Load it
|
||||||
self:SetRefillTime( CurTime() + 0.4 )
|
self:SetReloadStage(0)
|
||||||
|
self:SetClip( self.ClipSize )
|
||||||
self:Sound( self.MagInSound, 70, 100, 0.4 )
|
self:Sound( self.MagInSound, 70, 100, 0.4 )
|
||||||
self:PlayerAnimation( AnimationLookup["reload_insert"][self.HoldType] )
|
self:PlayerAnimation( AnimationLookup["reload_insert"][self.HoldType] )
|
||||||
self:PlayAnimation( self:LookupSequence( "magin" ) )
|
self:PlayAnimation( self:LookupSequence( "magin" ) )
|
||||||
|
time = 0.8
|
||||||
end
|
end
|
||||||
|
|
||||||
time = 0.8
|
|
||||||
self:SetDelay( CurTime() + time )
|
self:SetDelay( CurTime() + time )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -239,14 +186,6 @@ do -- Base Firearm
|
||||||
Base.CancelHolster( self )
|
Base.CancelHolster( self )
|
||||||
end
|
end
|
||||||
|
|
||||||
do -- Base Mag
|
|
||||||
local ITEM, Base = CreateItem( "base_mag", "base" )
|
|
||||||
|
|
||||||
ITEM.PrintName = "Magazine Base"
|
|
||||||
ITEM.Description = "Testing testing"
|
|
||||||
ITEM.Category = "base"
|
|
||||||
end
|
|
||||||
|
|
||||||
do -- Handguns
|
do -- Handguns
|
||||||
do -- G18
|
do -- G18
|
||||||
local ITEM, Base = CreateItem( "g18", "base_firearm" )
|
local ITEM, Base = CreateItem( "g18", "base_firearm" )
|
||||||
|
@ -323,20 +262,6 @@ do -- Base Firearm
|
||||||
ITEM.MagInSound = bSound("weapons/m16a2/magin.ogg")
|
ITEM.MagInSound = bSound("weapons/m16a2/magin.ogg")
|
||||||
ITEM.BoltDropSound = bSound("weapons/m16a2/cock.ogg")
|
ITEM.BoltDropSound = bSound("weapons/m16a2/cock.ogg")
|
||||||
ITEM.BoltPullSound = bSound("weapons/fnc/cock.ogg")
|
ITEM.BoltPullSound = bSound("weapons/fnc/cock.ogg")
|
||||||
|
|
||||||
do
|
|
||||||
local ITEM, Base = CreateItem( "mag_m16a2", "base_mag" )
|
|
||||||
|
|
||||||
ITEM.PrintName = "#Item.mag_m16a2.Name"
|
|
||||||
ITEM.Description = "#Item.mag_m16a2.Description"
|
|
||||||
ITEM.Category = "magazine"
|
|
||||||
|
|
||||||
ITEM.Model = bModel("weapons/test_m16a2_mag")
|
|
||||||
ITEM.DefaultBodygroups = {}
|
|
||||||
ITEM.HoldType = "magazine"
|
|
||||||
|
|
||||||
ITEM.ClipSize = 30
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -44,8 +44,6 @@ function GM:PlayerSpawn( ply )
|
||||||
ply:SetHealth_Blood( 1000 )
|
ply:SetHealth_Blood( 1000 )
|
||||||
ply:SetHealth_Stamina( 1000 )
|
ply:SetHealth_Stamina( 1000 )
|
||||||
|
|
||||||
ply:SetupInventory()
|
|
||||||
|
|
||||||
ply:MakeCharacter()
|
ply:MakeCharacter()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -191,33 +189,10 @@ function PT:HandlerCheck()
|
||||||
return ( wep:IsValid() and wep:GetClass() == "itemhandler" and wep.GetActiveR ) and wep or false
|
return ( wep:IsValid() and wep:GetClass() == "itemhandler" and wep.GetActiveR ) and wep or false
|
||||||
end
|
end
|
||||||
|
|
||||||
BGESTURE_ITEM1_RIGHT = GESTURE_SLOT_ATTACK_AND_RELOAD -- 0
|
-- breaks GESTURE_SLOT_ATTACK_AND_RELOAD and I can't fucking have that
|
||||||
BGESTURE_ITEM1_LEFT = GESTURE_SLOT_GRENADE -- 1
|
|
||||||
BGESTURE_ITEM2_RIGHT = GESTURE_SLOT_JUMP -- 2
|
|
||||||
BGESTURE_ITEM2_LEFT = GESTURE_SLOT_SWIM -- 3
|
|
||||||
BGESTURE_ACTION_RIGHT = GESTURE_SLOT_FLINCH -- 4
|
|
||||||
BGESTURE_ACTION_LEFT = GESTURE_SLOT_VCD -- 5
|
|
||||||
BGESTURE_JUMP = GESTURE_SLOT_CUSTOM -- 6
|
|
||||||
|
|
||||||
-- PLAYERANIMEVENT_ATTACK_PRIMARY = 0 -- Primary attack
|
|
||||||
-- PLAYERANIMEVENT_ATTACK_SECONDARY = 1 -- Secondary attack
|
|
||||||
-- PLAYERANIMEVENT_ATTACK_GRENADE = 2 -- Grenade throw
|
|
||||||
-- PLAYERANIMEVENT_RELOAD = 3 -- Reload
|
|
||||||
-- PLAYERANIMEVENT_RELOAD_LOOP = 4 -- Looping reload (single-reload shotguns)
|
|
||||||
-- PLAYERANIMEVENT_RELOAD_END = 5 -- Looping reload end
|
|
||||||
-- PLAYERANIMEVENT_JUMP = 6 -- Jump
|
|
||||||
|
|
||||||
-- breaks GESTURE_SLOT_ATTACK_AND_RELOAD, so do my own thing
|
|
||||||
-- 0 through 6 are real
|
|
||||||
hook.Add("DoAnimationEvent", "Benny_DoAnimationEvent_FixAnimations", function( p, event, data )
|
hook.Add("DoAnimationEvent", "Benny_DoAnimationEvent_FixAnimations", function( p, event, data )
|
||||||
-- 23, PLAYERANIMEVENT_CANCEL_RELOAD, is annoying and breaks animations
|
if event == PLAYERANIMEVENT_CUSTOM_GESTURE then
|
||||||
if event >= 0 and event <= 6 then
|
p:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, data, 0, true )
|
||||||
if data == 0 then
|
|
||||||
-- print("[DoAnimationEvent] Called " .. event .. " with data 0." )
|
|
||||||
return ACT_INVALID
|
|
||||||
end
|
|
||||||
-- print("running?", event, data )
|
|
||||||
p:AddVCDSequenceToGestureSlot( event, math.floor(data), 0, true )
|
|
||||||
end
|
end
|
||||||
return ACT_INVALID
|
return ACT_INVALID
|
||||||
end)
|
end)
|
||||||
|
@ -239,8 +214,8 @@ function GM:UpdateAnimation( ply, vel, maxseqgroundspeed )
|
||||||
normal.x = normal.x * needer
|
normal.x = normal.x * needer
|
||||||
normal.y = normal.y * needer
|
normal.y = normal.y * needer
|
||||||
|
|
||||||
local diveend = ply:GetLayerSequence( BGESTURE_JUMP ) == ply:LookupSequence("dive_end_handgun")
|
local diveend = ply:GetLayerSequence( GESTURE_SLOT_JUMP ) == ply:LookupSequence("dive_end_handgun")
|
||||||
local divestart = ply:GetLayerSequence( BGESTURE_JUMP ) == ply:LookupSequence("dive_start_handgun")
|
local divestart = ply:GetLayerSequence( GESTURE_SLOT_JUMP ) == ply:LookupSequence("dive_start_handgun")
|
||||||
|
|
||||||
if ply:GetInDive() or diveend then speed = 1 end
|
if ply:GetInDive() or diveend then speed = 1 end
|
||||||
|
|
||||||
|
@ -273,17 +248,17 @@ function GM:UpdateAnimation( ply, vel, maxseqgroundspeed )
|
||||||
ply:SetRenderAngles( Angle( 0, ply:EyeAngles().y, 0 ) )
|
ply:SetRenderAngles( Angle( 0, ply:EyeAngles().y, 0 ) )
|
||||||
|
|
||||||
if diveend then
|
if diveend then
|
||||||
local magicnumber = ply:GetLayerCycle( BGESTURE_JUMP )
|
local magicnumber = ply:GetLayerCycle( GESTURE_SLOT_JUMP )
|
||||||
magicnumber = math.Remap( magicnumber, 0.5, 0.75, 1, 0 )
|
magicnumber = math.Remap( magicnumber, 0.5, 0.75, 1, 0 )
|
||||||
magicnumber = math.Clamp( magicnumber, 0, 1 )
|
magicnumber = math.Clamp( magicnumber, 0, 1 )
|
||||||
ply:AnimSetGestureWeight( BGESTURE_JUMP, magicnumber )
|
ply:AnimSetGestureWeight( GESTURE_SLOT_JUMP, magicnumber )
|
||||||
elseif divestart then
|
elseif divestart then
|
||||||
local magicnumber = ply:GetLayerCycle( BGESTURE_JUMP )
|
local magicnumber = ply:GetLayerCycle( GESTURE_SLOT_JUMP )
|
||||||
magicnumber = math.Remap( magicnumber, 0.1, 0.6, 1, 0 )
|
magicnumber = math.Remap( magicnumber, 0.1, 0.6, 1, 0 )
|
||||||
magicnumber = math.Clamp( magicnumber, 0, 1 )
|
magicnumber = math.Clamp( magicnumber, 0, 1 )
|
||||||
ply:AnimSetGestureWeight( BGESTURE_JUMP, magicnumber )
|
ply:AnimSetGestureWeight( GESTURE_SLOT_JUMP, magicnumber )
|
||||||
else
|
else
|
||||||
ply:AnimSetGestureWeight( BGESTURE_JUMP, 1 )
|
ply:AnimSetGestureWeight( GESTURE_SLOT_JUMP, 1 )
|
||||||
end
|
end
|
||||||
|
|
||||||
--local dir = ply:GetVelocity():GetNormalized()
|
--local dir = ply:GetVelocity():GetNormalized()
|
||||||
|
@ -321,8 +296,10 @@ function GM:CalcMainActivity( ply, velocity )
|
||||||
|
|
||||||
local w = ply:HandlerCheck()
|
local w = ply:HandlerCheck()
|
||||||
local wpntype = "none"
|
local wpntype = "none"
|
||||||
if w and w:ItemR() then
|
if w then
|
||||||
wpntype = w:ItemR().HoldType
|
if w:ItemR() and w:ItemR().Class.HoldType then
|
||||||
|
wpntype = w:ItemR().Class.HoldType
|
||||||
|
end
|
||||||
end
|
end
|
||||||
plyTable.CalcSeqOverride = ply:LookupSequence( Animations["idle"][wpntype] )
|
plyTable.CalcSeqOverride = ply:LookupSequence( Animations["idle"][wpntype] )
|
||||||
|
|
||||||
|
@ -416,19 +393,35 @@ hook.Add("Move", "Benny_Move", function( ply, mv )
|
||||||
ply:SetInDive( true )
|
ply:SetInDive( true )
|
||||||
ply:SetDivedAt( CurTime() )
|
ply:SetDivedAt( CurTime() )
|
||||||
if SERVER or CLIENT and IsFirstTimePredicted() then
|
if SERVER or CLIENT and IsFirstTimePredicted() then
|
||||||
ply:HandlerCheck():EmitSound( "weapons/slam/throw.wav", 70, 100, .25 )
|
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_JUMP, ply:LookupSequence( "dive_start_handgun" ), 0, true )
|
||||||
ply:DoCustomAnimEvent( BGESTURE_JUMP, ply:LookupSequence( "dive_start_handgun" ) )
|
end
|
||||||
|
if (SERVER) or (CLIENT and IsFirstTimePredicted()) then
|
||||||
|
local rfil = nil
|
||||||
|
if SERVER then
|
||||||
|
rfil = RecipientFilter()
|
||||||
|
rfil:AddPAS(ply:GetPos())
|
||||||
|
rfil:RemovePlayer( ply )
|
||||||
|
end
|
||||||
|
ply:EmitSound("weapons/slam/throw.wav", 70, 100, .25, nil, nil, nil, rfil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if ply:OnGround() and ply:GetInDive() then
|
if ply:OnGround() and ply:GetInDive() then
|
||||||
|
if (SERVER) or (CLIENT and IsFirstTimePredicted()) then
|
||||||
|
local rfil = nil
|
||||||
|
if SERVER then
|
||||||
|
rfil = RecipientFilter()
|
||||||
|
rfil:AddPAS(ply:GetPos())
|
||||||
|
rfil:RemovePlayer( ply )
|
||||||
|
end
|
||||||
|
ply:EmitSound("npc/combine_soldier/gear1.wav", 70, 100, .25, nil, nil, nil, rfil)
|
||||||
|
end
|
||||||
ply:SetInDive(false)
|
ply:SetInDive(false)
|
||||||
ply:SetDivedAt( CurTime() )
|
ply:SetDivedAt( CurTime() )
|
||||||
|
if SERVER or CLIENT and IsFirstTimePredicted() then
|
||||||
|
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_JUMP, ply:LookupSequence( "dive_end_handgun" ), 0, true )
|
||||||
|
end
|
||||||
mv:SetVelocity( mv:GetVelocity() + Vector( 0, 0, 120 ) )
|
mv:SetVelocity( mv:GetVelocity() + Vector( 0, 0, 120 ) )
|
||||||
ply:SetGroundEntity( NULL )
|
ply:SetGroundEntity( NULL )
|
||||||
if SERVER or CLIENT and IsFirstTimePredicted() then
|
|
||||||
ply:HandlerCheck():EmitSound( "npc/combine_soldier/gear1.wav", 70, 100, .25 )
|
|
||||||
ply:DoCustomAnimEvent( BGESTURE_JUMP, ply:LookupSequence( "dive_end_handgun" ) )
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
--if !ply:OnGround() and ply:GetInDive() then
|
--if !ply:OnGround() and ply:GetInDive() then
|
||||||
-- local da = ply:GetDivedAt()
|
-- local da = ply:GetDivedAt()
|
||||||
|
|
|
@ -47,7 +47,6 @@ function PLAYER:SetupDataTables()
|
||||||
self.Player:NetworkVar( "Float", "DivedAt" )
|
self.Player:NetworkVar( "Float", "DivedAt" )
|
||||||
self.Player:NetworkVar( "Float", "TouchedObjectiveTime" )
|
self.Player:NetworkVar( "Float", "TouchedObjectiveTime" )
|
||||||
|
|
||||||
self.Player:NetworkVar( "Entity", "Inventory" )
|
|
||||||
self.Player:NetworkVar( "Entity", "TouchedObjective" )
|
self.Player:NetworkVar( "Entity", "TouchedObjective" )
|
||||||
|
|
||||||
self.Player:NetworkVar( "Vector", "VaultPos1")
|
self.Player:NetworkVar( "Vector", "VaultPos1")
|
||||||
|
|
Loading…
Reference in New Issue