CopsNRobbers/gamemodes/copsnrobbers/entities/weapons/cnr/sh_think.lua

31 lines
945 B
Lua
Raw Normal View History

2023-12-21 13:58:05 -05:00
SWEP.RecoilTable = {}
function SWEP:Think()
local p = self:GetOwner()
if CLIENT and IsFirstTimePredicted() then
2023-12-21 16:15:25 -05:00
for i, data in pairs( self.RecoilTable ) do
local ft = FrameTime()
local fp = ft * data.speed
data.dist = math.Approach( data.dist, 0, fp )
2023-12-21 13:58:05 -05:00
2023-12-21 16:15:25 -05:00
local m_p, m_y = math.cos(math.rad(data.up)), math.sin(math.rad(data.up))
local p_p, p_y = m_p * fp, m_y * fp
p:SetEyeAngles( p:EyeAngles() - Angle( p_p, p_y, 0 ) )
if data.dist == 0 then
self.RecoilTable[i] = nil
end
2023-12-21 13:58:05 -05:00
end
end
if !p:KeyDown( IN_ATTACK ) then
self:SetBurstCount( 0 )
end
2023-12-21 16:15:25 -05:00
local up = self:GetDelay() > CurTime()-engine.TickInterval()
self:SetBubbleSpread( math.Approach( self:GetBubbleSpread(), up and 1 or 0, FrameTime()/(up and self.BubbleSpreadUp or self.BubbleSpreadDown) ) )
self:SetBubbleRecoil( math.Approach( self:GetBubbleRecoil(), up and 1 or 0, FrameTime()/(up and self.BubbleRecoilUp or self.BubbleRecoilDown) ) )
2023-12-21 13:58:05 -05:00
end