a bit better sway procedural anim

This commit is contained in:
Darsu 2025-01-17 02:39:13 +07:00
parent 15e95f7910
commit 5896bbe4e4
3 changed files with 27 additions and 9 deletions

View File

@ -211,11 +211,22 @@ function ARC9.StartCommand(ply, cmd)
local isScope = wpn:IsUsingRTScope()
if isScope then
local swayspeed = 2
local swayamt = wpn:GetFreeSwayAmount()
local swayang = Angle(math.sin(CurTime() * 0.6 * swayspeed) + (math.cos(CurTime() * 2) * 0.5), math.sin(CurTime() * 0.4 * swayspeed) + (math.cos(CurTime() * 1.6) * 0.5), 0)
local ct = CurTime()
swayang = swayang * wpn:GetSightAmount() * swayamt * 0.2
local swayspeed = 1.5
local swayamt = wpn:GetFreeSwayAmount()
if wpn:GetOutOfBreath() then swayspeed = 2.25 end
local swayang = Angle(math.sin(ct * 0.6 * swayspeed) + (math.cos(ct * 2 * swayspeed) * 0.5), math.sin(ct * 0.4 * swayspeed) + (math.cos(ct * 1.6 * swayspeed) * 0.5), 0)
swayang.p = swayang.p + (math.cos(ct * 5 * swayspeed) + math.cos(ct * 2)) * -0.15 -- smaller movement
swayang.y = swayang.y + (math.cos(ct * 2.9 * swayspeed) + (math.sin(ct * 7.1)) - (math.sin(ct * 4) * 2)) * 0.1
swayang.p = swayang.p - math.exp(math.exp((math.cos(ct * 1.33 * swayspeed)))) * -0.07 -- random drags
swayang.y = swayang.y - math.exp(math.exp((math.sin(ct * 0.8 * swayspeed)))) * 0.07
swayang = swayang * wpn:GetSightAmount() * swayamt * 0.2 * 0.75
local eyeang = cmd:GetViewAngles()

View File

@ -55,15 +55,22 @@ function SWEP:GetFreeSwayAngles()
local swayamt = self:GetFreeSwayAmount()
if swayamt == 0 then return end
local swayspeed = 2
local swayspeed = 1.5
local isScope = self:IsUsingRTScope()
swayamt = isScope and 0 or swayamt * (1-self:GetSightAmount() * 0.2)
smoothswayamt = CLIENT and Lerp(RealFrameTime(), smoothswayamt, swayamt) or swayamt
smoothswayamt = CLIENT and Lerp(RealFrameTime() * 2, smoothswayamt, swayamt) or swayamt
if self:GetOutOfBreath() then swayspeed = 2.25 end
local ang = Angle(math.sin(ct * 0.6 * swayspeed) + (math.cos(ct * 2 * swayspeed) * 0.5), math.sin(ct * 0.4 * swayspeed) + (math.cos(ct * 1.6 * swayspeed) * 0.5), 0)
ang.p = ang.p + (math.cos(ct * 5 * swayspeed) + math.cos(ct * 2)) * -0.15 -- smaller movement
ang.y = ang.y + (math.cos(ct * 2.9 * swayspeed) + (math.sin(ct * 7.1)) - (math.sin(ct * 4) * 2)) * 0.1
local ang = Angle(math.sin(ct * 0.6 * swayspeed) + (math.cos(ct * 2) * 0.5), math.sin(ct * 0.4 * swayspeed) + (math.cos(ct * 1.6) * 0.5), 0)
ang.p = ang.p - math.exp(math.exp((math.cos(ct * 1.33 * swayspeed)))) * -0.07 -- random drags
ang.y = ang.y - math.exp(math.exp((math.sin(ct * 0.8 * swayspeed)))) * 0.07
ang = ang * smoothswayamt
ang = ang * smoothswayamt * 0.75
return ang
end

View File

@ -168,7 +168,7 @@ function SWEP:RotateAroundPoint2(pos, ang, point, offset, offset_ang)
end
function SWEP:IsUsingRTScope()
return self:GetSightAmount() > 0.5 and self:GetSight() and self:GetSight().atttbl and self:GetSight().atttbl.RTScope
return self:GetSightAmount() > 0.5 and self:GetSight() and self:GetSight().atttbl and self:GetSight().atttbl.RTScope and !self:GetSight().Disassociate
end
if CLIENT then