Holster improvements, default bodygroups, debug menu prediction fixes

Print all bones function too
This commit is contained in:
Fesiug 2024-09-21 16:55:44 -04:00
parent e58125205e
commit 0aac95d5a0
Signed by: Fesiug
GPG Key ID: 374BFF45E1EEF243
3 changed files with 73 additions and 27 deletions

View File

@ -226,12 +226,13 @@ 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
if self:GetActiveR() != NULL then
ActiveR.Class.Drop( ActiveR.Class, ActiveR, self )
if SERVER then
self:DropItem()
@ -239,6 +240,7 @@ function SWEP:Think()
self:SetActiveR( NULL )
end
end
end
if p:KeyPressed(IN_WEAPON2) then
end
if p:KeyPressed(IN_ALT1) then

View File

@ -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 )
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)
hook.Add("PlayerButtonUp", "PlayerButtonUp_DebugMenu", function( ply, button )
if button == KEY_F1 then
--if IsValid(DebugMenu) then DebugMenu:Remove() end
end
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)

View File

@ -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",