TP animation fixes

and holstering code tweaks whatevs
This commit is contained in:
Fesiug 2024-10-08 17:58:47 -04:00
parent 3f6f5464b9
commit 825c32e217
Signed by: Fesiug
GPG Key ID: 374BFF45E1EEF243
4 changed files with 53 additions and 47 deletions

View File

@ -124,7 +124,7 @@ function SWEP:EquipItem( ent )
self:SetDesireR( 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 + EF_BONEMERGE_FASTCULL )
ent:PhysicsInit( SOLID_NONE ) ent:PhysicsInit( SOLID_NONE )
ent:SetMoveType( MOVETYPE_NONE ) ent:SetMoveType( MOVETYPE_NONE )
ent:SetNoDraw( true ) ent:SetNoDraw( true )
@ -162,7 +162,7 @@ function SWEP:DropItem()
ent:SetHandler( NULL ) ent:SetHandler( NULL )
ent:RemoveEFlags( EFL_KEEP_ON_RECREATE_ENTITIES ) ent:RemoveEFlags( EFL_KEEP_ON_RECREATE_ENTITIES )
ent:RemoveEffects( EF_BONEMERGE ) ent:RemoveEffects( EF_BONEMERGE + EF_BONEMERGE_FASTCULL )
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 )
@ -180,6 +180,8 @@ function SWEP:DropItem()
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 )
@ -193,23 +195,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()
local DesireR_Valid = DesireR:IsValid() DesireR = DesireR:IsValid() and DesireR or false
local ActiveR_Valid = ActiveR:IsValid() ActiveR = ActiveR:IsValid() and ActiveR or false
if DesireR != ActiveR then if DesireR != ActiveR then
if ActiveR_Valid then if ActiveR 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_Valid then if DesireR then
self:SetActive( DesireR ) self:SetActive( DesireR )
end end
end end
else else
if ActiveR_Valid and ActiveR:GetHolsterIn() != 0 then if ActiveR and ActiveR:GetHolsterIn() != 0 then
ActiveR:CancelHolster() ActiveR:CancelHolster()
end end
end end

View File

@ -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( GESTURE_SLOT_JUMP ) == ply:LookupSequence("dive_end_handgun") then if ply:GetLayerSequence( BGESTURE_JUMP ) == ply:LookupSequence("dive_end_handgun") then
local progress = ply:GetLayerCycle( GESTURE_SLOT_JUMP ) local progress = ply:GetLayerCycle( BGESTURE_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 )

View File

@ -23,7 +23,6 @@ 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 )
@ -51,7 +50,7 @@ do -- Base
function ITEM:PlayerAnimation( seqname ) function ITEM:PlayerAnimation( seqname )
local p = self:GetOwner() local p = self:GetOwner()
p:DoAnimationEvent( p:LookupSequence( seqname ) ) p:DoCustomAnimEvent( BGESTURE_ITEM1_RIGHT, p:LookupSequence( seqname ) )
end end
function ITEM:EntThink() end function ITEM:EntThink() end

View File

@ -189,10 +189,33 @@ 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
-- breaks GESTURE_SLOT_ATTACK_AND_RELOAD and I can't fucking have that BGESTURE_ITEM1_RIGHT = GESTURE_SLOT_ATTACK_AND_RELOAD -- 0
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 )
if event == PLAYERANIMEVENT_CUSTOM_GESTURE then -- 23, PLAYERANIMEVENT_CANCEL_RELOAD, is annoying and breaks animations
p:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, data, 0, true ) if event >= 0 and event <= 6 then
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)
@ -214,8 +237,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( GESTURE_SLOT_JUMP ) == ply:LookupSequence("dive_end_handgun") local diveend = ply:GetLayerSequence( BGESTURE_JUMP ) == ply:LookupSequence("dive_end_handgun")
local divestart = ply:GetLayerSequence( GESTURE_SLOT_JUMP ) == ply:LookupSequence("dive_start_handgun") local divestart = ply:GetLayerSequence( BGESTURE_JUMP ) == ply:LookupSequence("dive_start_handgun")
if ply:GetInDive() or diveend then speed = 1 end if ply:GetInDive() or diveend then speed = 1 end
@ -248,17 +271,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( GESTURE_SLOT_JUMP ) local magicnumber = ply:GetLayerCycle( BGESTURE_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( GESTURE_SLOT_JUMP, magicnumber ) ply:AnimSetGestureWeight( BGESTURE_JUMP, magicnumber )
elseif divestart then elseif divestart then
local magicnumber = ply:GetLayerCycle( GESTURE_SLOT_JUMP ) local magicnumber = ply:GetLayerCycle( BGESTURE_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( GESTURE_SLOT_JUMP, magicnumber ) ply:AnimSetGestureWeight( BGESTURE_JUMP, magicnumber )
else else
ply:AnimSetGestureWeight( GESTURE_SLOT_JUMP, 1 ) ply:AnimSetGestureWeight( BGESTURE_JUMP, 1 )
end end
--local dir = ply:GetVelocity():GetNormalized() --local dir = ply:GetVelocity():GetNormalized()
@ -296,10 +319,8 @@ function GM:CalcMainActivity( ply, velocity )
local w = ply:HandlerCheck() local w = ply:HandlerCheck()
local wpntype = "none" local wpntype = "none"
if w then if w and w:ItemR() then
if w:ItemR() and w:ItemR().Class.HoldType then wpntype = w:ItemR().HoldType
wpntype = w:ItemR().Class.HoldType
end
end end
plyTable.CalcSeqOverride = ply:LookupSequence( Animations["idle"][wpntype] ) plyTable.CalcSeqOverride = ply:LookupSequence( Animations["idle"][wpntype] )
@ -393,35 +414,19 @@ 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:AddVCDSequenceToGestureSlot( GESTURE_SLOT_JUMP, ply:LookupSequence( "dive_start_handgun" ), 0, true ) ply:HandlerCheck():EmitSound( "weapons/slam/throw.wav", 70, 100, .25 )
end ply:DoCustomAnimEvent( BGESTURE_JUMP, ply:LookupSequence( "dive_start_handgun" ) )
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()