Fix weapon interpolation, fix inputs when paused

This commit is contained in:
Fesiug 2024-09-17 17:46:44 -04:00
parent 915f463b2a
commit 6701618db1
Signed by: Fesiug
GPG Key ID: 374BFF45E1EEF243
3 changed files with 49 additions and 33 deletions

View File

@ -37,23 +37,37 @@ else
end
function ENT:PlayAnimation( seqid, speed )
local time = self:SequenceDuration( seqid )
speed = speed or 1
self.AnimStartTime = ( UnPredictedCurTime() )
self.AnimEndTime = ( UnPredictedCurTime() + time )
self:SetAnimStartTime( self.AnimStartTime )
self:SetAnimEndTime( self.AnimEndTime )
self:ResetSequence( seqid )
-- Interpolation
if CLIENT and IsFirstTimePredicted() then
self.CLCycle = 0
self.StartTime = UnPredictedCurTime()
end
end
function ENT:Think()
self:NextThink( CurTime()-5 )
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() )
if CLIENT then
self:SetNextClientThink( CurTime()-5 )
-- Smooth interpolated shooting on local player
-- Interpolation
if self:GetOwner() == LocalPlayer() then
local cycle = math.Remap( UnPredictedCurTime(), self.AnimStartTime or 0, self.AnimEndTime or 0, 0, 1 )
self:SetCycle( cycle )
local diff = (UnPredictedCurTime()) - (self.LastThink or UnPredictedCurTime())
if diff then
self.CLCycle = math.Approach( self.CLCycle or 0, 1, ( 1/self:SequenceDuration() ) * diff )
self:SetCycle( self.CLCycle )
self.LastThink = UnPredictedCurTime()
end
end
end

View File

@ -4,7 +4,7 @@ AddCSLuaFile()
SWEP.Base = "weapon_base"
SWEP.BennyItemHandler = true
SWEP.ViewModel = "models/weapons/c_arms.mdl"
SWEP.ViewModel = "models/weapons/c_pistol.mdl"
SWEP.ViewModelFOV = 74
SWEP.ViewModelFlip = false
SWEP.UseHands = true
@ -144,8 +144,8 @@ function SWEP:EquipItem( ent )
ent:SetNoDraw( true )
ent:SetParent( p )
ent:SetOwner( p )
ent:SetPos( vector_origin )
ent:SetAngles( Angle( 0, p:EyeAngles().y, 0 ) )
ent:SetLocalPos( vector_origin )
ent:SetLocalAngles( angle_zero )
ent:SetAcquisition( CurTime() )
ent:EmitSound( "ae/items/pickup.ogg", 70, 100, 1, CHAN_STATIC )

View File

@ -333,26 +333,28 @@ end )
if CLIENT then
hook.Add("CreateMove", "Benny_CreateMove_Controls", function( cmd )
if input.IsButtonDown( KEY_E ) then
cmd:AddKey( IN_WEAPON1 )
end
if input.IsButtonDown( KEY_Q ) then
cmd:AddKey( IN_WEAPON2 )
end
if input.IsButtonDown( KEY_C ) then
cmd:AddKey( IN_GRENADE1 )
end
if input.IsButtonDown( KEY_Z ) then
cmd:AddKey( IN_GRENADE2 )
end
if input.IsButtonDown( KEY_R ) then
cmd:AddKey( IN_ALT1 )
end
if input.IsButtonDown( KEY_T ) then
cmd:AddKey( IN_ALT2 )
end
if input.IsButtonDown( KEY_X ) then
cmd:AddKey( IN_BULLRUSH )
if !gui.IsGameUIVisible() then
if input.IsButtonDown( KEY_E ) then
cmd:AddKey( IN_WEAPON1 )
end
if input.IsButtonDown( KEY_Q ) then
cmd:AddKey( IN_WEAPON2 )
end
if input.IsButtonDown( KEY_C ) then
cmd:AddKey( IN_GRENADE1 )
end
if input.IsButtonDown( KEY_Z ) then
cmd:AddKey( IN_GRENADE2 )
end
if input.IsButtonDown( KEY_R ) then
cmd:AddKey( IN_ALT1 )
end
if input.IsButtonDown( KEY_T ) then
cmd:AddKey( IN_ALT2 )
end
if input.IsButtonDown( KEY_X ) then
cmd:AddKey( IN_BULLRUSH )
end
end
end)
end