From 0aac95d5a0205a65fa32363180b48793192852c7 Mon Sep 17 00:00:00 2001 From: Fesiug Date: Sat, 21 Sep 2024 16:55:44 -0400 Subject: [PATCH] Holster improvements, default bodygroups, debug menu prediction fixes Print all bones function too --- .../benny/entities/weapons/itemhandler.lua | 12 ++-- gamemodes/benny/gamemode/debugmenu.lua | 60 +++++++++++++++---- gamemodes/benny/gamemode/items.lua | 28 +++++---- 3 files changed, 73 insertions(+), 27 deletions(-) diff --git a/gamemodes/benny/entities/weapons/itemhandler.lua b/gamemodes/benny/entities/weapons/itemhandler.lua index 7074c1d..fa6ef89 100644 --- a/gamemodes/benny/entities/weapons/itemhandler.lua +++ b/gamemodes/benny/entities/weapons/itemhandler.lua @@ -226,17 +226,19 @@ function SWEP:Think() end if p:KeyPressed(IN_WEAPON1) then - if !self:ItemR() then + if self:GetDesireR() == NULL then if SERVER then local trace = self:ItemCheckTrace() self:EquipItem( trace.Entity ) end else - ActiveR.Class.Drop( ActiveR.Class, ActiveR, self ) - if SERVER then - self:DropItem() + if self:GetActiveR() != NULL then + ActiveR.Class.Drop( ActiveR.Class, ActiveR, self ) + if SERVER then + self:DropItem() + end + self:SetActiveR( NULL ) end - self:SetActiveR( NULL ) end end if p:KeyPressed(IN_WEAPON2) then diff --git a/gamemodes/benny/gamemode/debugmenu.lua b/gamemodes/benny/gamemode/debugmenu.lua index 3106e80..9da3161 100644 --- a/gamemodes/benny/gamemode/debugmenu.lua +++ b/gamemodes/benny/gamemode/debugmenu.lua @@ -121,9 +121,21 @@ local function OpenDebugMenu() modeller:SetDirectionalLight(BOX_LEFT, HSLToColor( 0, 0, 1.00 ) ) modeller:SetDirectionalLight(BOX_RIGHT, HSLToColor( 0, 0, 1.00 ) ) - function modeller:Update( mdl ) - if self.Entity:GetModel() == mdl then return end - self.Entity:SetModel( mdl ) + function modeller:Update( idata ) + if self.Entity:GetModel() == idata.Model then return end + self.Entity:SetModel( idata.Model ) + + for i=0, self.Entity:GetNumBodyGroups()-1 do + self.Entity:SetBodygroup( i, 0 ) + end + + for k, v in ipairs(idata.DefaultBodygroups) do + if v then + self.Entity:SetBodygroup( k-1, v ) + end + end + + local worked = self.Entity:PhysicsInit( SOLID_VPHYSICS ) if worked then @@ -264,7 +276,7 @@ local function OpenDebugMenu() function button:Think() if self:IsHovered() then texter:SetText( l8(idata.Description) .. "\n\nClipsize: " .. (idata.ClipSize or "?") ) - modeller:Update( idata.Model ) + modeller:Update( idata ) end end end @@ -308,16 +320,40 @@ function OpenMyTeamMenu() DebugMenu:Center() end -hook.Add("PlayerButtonDown", "PlayerButtonDown_DebugMenu", function( ply, button ) - if button == KEY_F1 then - OpenDebugMenu() - elseif button == KEY_F2 then - OpenMyTeamMenu() +hook.Add("PlayerButtonDown", "Benny_PlayerButtonDown_DebugMenu", function( ply, button ) + if CLIENT and IsFirstTimePredicted() then + if button == KEY_F1 then + OpenDebugMenu() + elseif button == KEY_F2 then + OpenMyTeamMenu() + end end end) -hook.Add("PlayerButtonUp", "PlayerButtonUp_DebugMenu", function( ply, button ) - if button == KEY_F1 then - --if IsValid(DebugMenu) then DebugMenu:Remove() end +local c_id = Color( 255, 200, 200 ) +local c_name = Color( 200, 255, 255 ) +local c_white = Color( 255, 255, 255 ) + +local function recursebones( ent, O_id, level ) + local gap = "" + for i=1, level do gap = gap .. " " end + for index, id in ipairs( ent:GetChildBones( O_id ) ) do + chat.AddText( gap, c_id, tostring(id), c_white, " - ", c_name, ent:GetBoneName(id) ) + recursebones( ent, id, level+1 ) end +end + +function printallbones( ent ) + if !ent:IsValid() then print("invalid ent") return end + + for id=0, ent:GetBoneCount()-1 do + if ent:GetBoneName(id) == "__INVALIDBONE__" then continue end + if ent:GetBoneParent(id) != -1 then continue end + chat.AddText( gap, c_id, tostring(id), c_white, " - ", c_name, ent:GetBoneName(id) ) + recursebones( ent, id, 1 ) + end +end + +concommand.Add("b-debug_listbones", function( ply, cmd ) + printallbones( ply ) end) \ No newline at end of file diff --git a/gamemodes/benny/gamemode/items.lua b/gamemodes/benny/gamemode/items.lua index 5dbca1e..2dba702 100644 --- a/gamemodes/benny/gamemode/items.lua +++ b/gamemodes/benny/gamemode/items.lua @@ -47,16 +47,23 @@ AddItem( "base", { Description = "Beginning item base.", Category = "base", + Model = "models/benny/weapons/test_m16a2.mdl", + DefaultBodygroups = {}, Vars = { ["Float"] = { "Acquisition", "HolsterIn", }, }, - HoldType = "slam", ["Initialize"] = function( class, ent, handler ) print( class, "Initialized base initialization" ) + + for k, v in ipairs(class.DefaultBodygroups) do + if v then + ent:SetBodygroup( k-1, v ) + end + end end, ["Deploy"] = function( class, ent, handler ) @@ -321,7 +328,7 @@ AddItem( "base_firearm", { handler:EmitSound( "weapons/elite/elite_deploy.wav", 70, 125, 0.4, CHAN_STATIC ) local ply = handler:GetOwner() if SERVER or CLIENT and IsFirstTimePredicted() then - ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["deploy"][class.HoldType] ), 0, true ) + ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["deploy"][class.HoldType] ), 0.25, true ) end end, }) @@ -540,13 +547,14 @@ do -- Handguns Model = "models/benny/weapons/test_mk23.mdl", HoldType = "handgun", + DefaultBodygroups = { false, false, 1 }, ClipSize = 12, - Delay = (60/350), + Delay = (60/320), FireSound = { - "benny/weapons/usp/01.ogg", - "benny/weapons/usp/02.ogg", - "benny/weapons/usp/03.ogg", + "benny/weapons/usp/sup_01.ogg", + "benny/weapons/usp/sup_02.ogg", + "benny/weapons/usp/sup_03.ogg", }, MagOutSound = "benny/weapons/usp/magout.ogg", MagInSound = "benny/weapons/usp/magin.ogg", @@ -630,7 +638,7 @@ do -- Rifles HoldType = "rifle", ClipSize = 30, - Delay = (60/750), + Delay = (60/800), FireSound = { "benny/weapons/m16a2/01.ogg", "benny/weapons/m16a2/02.ogg", @@ -699,7 +707,7 @@ do -- Rifles HoldType = "rifle", ClipSize = 30, - Delay = (60/900), + Delay = (60/1050), BurstCount = 3, BurstRunaway = true, BurstAuto = true, @@ -754,7 +762,7 @@ do -- SMGs Model = "models/benny/weapons/test_tmp.mdl",--"models/weapons/w_rif_ar556.mdl", HoldType = "handgun", - ClipSize = 20, + ClipSize = 25, Delay = (60/850), FireSound = { "benny/weapons/tmp/01.ogg", @@ -790,7 +798,7 @@ do -- SMGs Model = "models/benny/weapons/test_mp5k.mdl",--"models/weapons/w_rif_ar556.mdl", HoldType = "handgun", - ClipSize = 20, + ClipSize = 30, Delay = (60/750), FireSound = { "benny/weapons/mp5k/01.ogg",