Sacrificial piece of s*** goat weapons

This commit is contained in:
Fesiug 2024-09-20 16:20:22 -04:00
parent 6701618db1
commit 3946029046
Signed by: Fesiug
GPG Key ID: 374BFF45E1EEF243
6 changed files with 151 additions and 68 deletions

View File

@ -19,8 +19,6 @@ function ENT:Initialize()
end end
self.Class:Initialize( self ) self.Class:Initialize( self )
--self:UseClientSideAnimation()
end end
if SERVER then if SERVER then
@ -46,15 +44,6 @@ function ENT:PlayAnimation( seqid, speed )
end end
function ENT:Think() function ENT:Think()
if false and SERVER then
print( "m_flAnimTime", self:GetInternalVariable("m_flAnimTime") )
print( "m_flPrevAnimTime", self:GetInternalVariable("m_flPrevAnimTime") )
print( "m_bClientSideAnimation", self:GetInternalVariable("m_bClientSideAnimation") )
print( "m_bClientSideFrameReset", self:GetInternalVariable("m_bClientSideFrameReset") )
print( "cycle", self:GetInternalVariable("cycle") )
end
self:NextThink( CurTime() ) self:NextThink( CurTime() )
if CLIENT then if CLIENT then
self:SetNextClientThink( CurTime()-5 ) self:SetNextClientThink( CurTime()-5 )

View File

@ -0,0 +1,26 @@
SWEP.Base = "weapon_base"
function SWEP:PrimaryAttack()
return true
end
function SWEP:SecondaryAttack()
return true
end
function SWEP:Reload()
return true
end
function SWEP:Think()
return true
end
function SWEP:Deploy()
return true
end
function SWEP:Holster()
return true
end

View File

@ -23,10 +23,10 @@ SWEP.Secondary.Ammo = "none"
SWEP.Secondary.Automatic = true SWEP.Secondary.Automatic = true
function SWEP:SetupDataTables() function SWEP:SetupDataTables()
self:NetworkVar( "Entity", 0, "ActiveR" ) self:NetworkVar( "Entity", "ActiveR" )
self:NetworkVar( "Entity", 1, "ActiveL" ) self:NetworkVar( "Entity", "ActiveL" )
self:NetworkVar( "Entity", 2, "DesireR" ) self:NetworkVar( "Entity", "DesireR" )
self:NetworkVar( "Entity", 3, "DesireL" ) self:NetworkVar( "Entity", "DesireL" )
end end
function SWEP:ItemR( run ) function SWEP:ItemR( run )
@ -137,6 +137,8 @@ function SWEP:EquipItem( ent )
end end
print("Pick up", ent) print("Pick up", ent)
self:SetDesireR( ent )
ent:AddEFlags( EFL_KEEP_ON_RECREATE_ENTITIES ) ent:AddEFlags( EFL_KEEP_ON_RECREATE_ENTITIES )
ent:AddEffects( EF_BONEMERGE ) ent:AddEffects( EF_BONEMERGE )
ent:PhysicsInit( SOLID_NONE ) ent:PhysicsInit( SOLID_NONE )
@ -169,6 +171,8 @@ function SWEP:DropItem()
if CLIENT then print("DropItem called on CLIENT but certain things aren't finished yet.") return end if CLIENT then print("DropItem called on CLIENT but certain things aren't finished yet.") return end
self:Deactive() self:Deactive()
self:SetDesireR( NULL )
ent:SetParent( NULL ) ent:SetParent( NULL )
ent:SetOwner( NULL ) ent:SetOwner( NULL )
@ -202,17 +206,38 @@ function SWEP:Think()
local p = self:GetOwner() local p = self:GetOwner()
if p:IsValid() then if p:IsValid() then
if p:KeyDown(IN_WEAPON1) then
local DesireR = self:GetDesireR()
local ActiveR = self:GetActiveR()
local DesireR_Valid = DesireR:IsValid()
local ActiveR_Valid = ActiveR:IsValid()
-- If we're holding the weapon we want...
if ActiveR == DesireR then
-- Do nothing
-- If we want no weapon equipped
elseif !DesireR_Valid then
if ActiveR_Valid then
self:Deactive()
else
-- We're holding nothing. Do nothing.
end
-- If we want a weapon equipped
elseif DesireR_Valid then
if ActiveR != DesireR then
self:Deactive()
end
self:SetActive( DesireR )
end
if p:KeyPressed(IN_WEAPON1) then
if SERVER then if SERVER then
if !self:ItemR() then if !self:ItemR() then
local trace = self:ItemCheckTrace() local trace = self:ItemCheckTrace()
self:EquipItem( trace.Entity ) self:EquipItem( trace.Entity )
end else
end
end
if p:KeyReleased(IN_WEAPON1) then
if SERVER then
if self:ItemR() then
self:DropItem() self:DropItem()
end end
end end
@ -244,5 +269,6 @@ end
function SWEP:Deploy() function SWEP:Deploy()
end end
function SWEP:Holster() function SWEP:Holster( ent )
return false
end end

View File

@ -114,61 +114,93 @@ end
do 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 = { local qt = {
["slot1"] = true, ["invprev"] = -1,
["slot2"] = true, ["invnext"] = 1,
["slot3"] = true,
["slot4"] = true,
["slot5"] = true,
["slot6"] = true,
["slot7"] = true,
["slot8"] = true,
["slot9"] = true,
["slot0"] = true,
["invprev"] = true,
["invnext"] = true,
} }
hook.Add( "PlayerBindPress", "Benny_PlayerBindPress_Original", function( ply, bind, pressed, code ) hook.Add( "PlayerBindPress", "Benny_PlayerBindPress_Original", function( ply, bind, pressed, code )
if qt[bind] and pressed then 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 return true
end end
end) end)
end end
-- breaks GESTURE_SLOT_ATTACK_AND_RELOAD and I can't fucking have that
hook.Add("DoAnimationEvent", "Benny_DoAnimationEvent_FixAnimations", function( ply, event, data )
return ACT_INVALID
end)
local dads = { hook.Add( "PlayerSwitchWeapon", "Benny_PlayerSwitchWeapon_Goat", function( ply, old, ent )
[KEY_1] = 1, if ent.BennyItemHandler then return true end -- what happened?
[KEY_2] = 2,
[KEY_3] = 3,
[KEY_4] = 4,
[KEY_5] = 5,
[KEY_6] = 6,
[KEY_7] = 7,
[KEY_8] = 8,
[KEY_9] = 9,
[KEY_0] = 0,
}
local function beatup( ply, num )
local inv = ply:GetInventory():GetWeighted()
local wep = ply:HandlerCheck() local wep = ply:HandlerCheck()
if !wep then print("PlayerSwitchWeapon Benny Handler Missing!!") return false end
if ent:IsValid() and ent.Goat then
local inv = ply:GetInventory():GetWeighted()
local ent = inv[num] if ent.Goat == 0 then wep:SetDesireR( NULL ) return false end
if ent then
if ent == wep:GetActiveR() then local ent = inv[ent.Goat]
wep:Deactive() if ent then
else wep:SetDesireR( ent )
wep:SetActive(ent)
end end
end end
end
hook.Add( "PlayerButtonDown", "Benny_PlayerButtonDown_Inv", function( ply, button ) return false
local wep = ply:HandlerCheck()
if dads[button] then
beatup( ply, dads[button] )
end
end) end)
for i=0, 9 do
local tent = {}
tent.Base = "goat"
tent.Goat = i
weapons.Register( tent, "goat_" .. i )
end

View File

@ -17,6 +17,19 @@ function GM:PlayerSpawn( ply )
ply:SetViewOffsetDucked( Vector( 0, 0, 50 ) ) ply:SetViewOffsetDucked( Vector( 0, 0, 50 ) )
ply:Give( "itemhandler" ) ply:Give( "itemhandler" )
ply:Give( "goat_1" )
ply:Give( "goat_2" )
ply:Give( "goat_3" )
ply:Give( "goat_4" )
ply:Give( "goat_5" )
ply:Give( "goat_6" )
ply:Give( "goat_7" )
ply:Give( "goat_8" )
ply:Give( "goat_9" )
ply:Give( "goat_0" )
ply:SetActiveWeapon( ply:GetWeapon( "itemhandler" ) )
ply:SetStamina( 1 ) ply:SetStamina( 1 )
ply:SetCrouchedWalkSpeed( 0.3 ) ply:SetCrouchedWalkSpeed( 0.3 )

View File

@ -51,9 +51,6 @@ function PLAYER:SetupDataTables()
self.Player:NetworkVar( "Vector", "VaultPos1") self.Player:NetworkVar( "Vector", "VaultPos1")
self.Player:NetworkVar( "Vector", "VaultPos2") self.Player:NetworkVar( "Vector", "VaultPos2")
self.Player:NetworkVar( "String", "ReqID1")
self.Player:NetworkVar( "String", "ReqID2")
end end
player_manager.RegisterClass( "player_benny", PLAYER, "player_default" ) player_manager.RegisterClass( "player_benny", PLAYER, "player_default" )