inertia test

This commit is contained in:
Darsu 2023-05-17 17:36:49 +07:00
parent 74261082a1
commit 3e58a276cb
4 changed files with 53 additions and 13 deletions

View File

@ -126,6 +126,10 @@ function ARC9.StartCommand(ply, cmd)
cmd:RemoveKey(IN_SPEED)
end
if wpn.InertiaEnabled then
wpn.InertiaSideMoveRaw = cmd:GetSideMove() * 0.0001
end
local eyeang = cmd:GetViewAngles()
if eyeang.p != eyeang.p then eyeang.p = 0 end

View File

@ -274,15 +274,31 @@ function SWEP:GetViewModelPosition(pos, ang)
-- self.SwayScale = Lerp(sightdelta, 1, 0.1)
end
local fswayang = self:GetFreeSwayAngles()
if fswayang then
local getfreeswayang, getfreeswayoffset = self:GetFreeSwayAngles(), self:GetFreeAimOffset()
extra_offsetang[2] = extra_offsetang[2] - (getfreeswayang[1] * cor_val)
extra_offsetang[1] = extra_offsetang[1] + (getfreeswayang[2] * cor_val)
-- extra_offsetpos.x = extra_offsetpos.x + (self:GetFreeSwayAngles().y * cor_val) - 0.01
-- extra_offsetpos.z = extra_offsetpos.z + (self:GetFreeSwayAngles().p * cor_val) - 0.05 -- idkkkkkkkk
extra_offsetang[2] = extra_offsetang[2] - (getfreeswayoffset[1] * cor_val)
extra_offsetang[1] = extra_offsetang[1] + (getfreeswayoffset[2] * cor_val)
local fswayang
if self.InertiaEnabled then
fswayang = self:GetInertiaSwayAngles()
local inertiaanchor
if self.InertiaCustomAnchor then
inertiaanchor = self.InertiaCustomAnchor
else
inertiaanchor = Vector(self.CustomizeRotateAnchor)
inertiaanchor.x = inertiaanchor.x * 0.5
end
local rap_pos, rap_ang = self:RotateAroundPoint2(pos, ang, inertiaanchor, vector_origin, fswayang * -0.5)
pos:Set(rap_pos)
ang:Set(rap_ang)
else
fswayang = self:GetFreeSwayAngles()
if fswayang then
local getfreeswayang, getfreeswayoffset = fswayang, self:GetFreeAimOffset()
extra_offsetang[2] = extra_offsetang[2] - (getfreeswayang[1] * cor_val)
extra_offsetang[1] = extra_offsetang[1] + (getfreeswayang[2] * cor_val)
extra_offsetang[2] = extra_offsetang[2] - (getfreeswayoffset[1] * cor_val)
extra_offsetang[1] = extra_offsetang[1] + (getfreeswayoffset[2] * cor_val)
end
end
if singleplayer or IsFirstTimePredicted() then
@ -418,7 +434,7 @@ function SWEP:GetViewModelPosition(pos, ang)
-- pos, ang = self:GetViewModelLeftRight(pos, ang)
pos, ang = self:GetViewModelInertia(pos, ang)
pos, ang = self:GetViewModelSway(pos, ang)
if !self.InertiaEnabled then pos, ang = self:GetViewModelSway(pos, ang) end
pos, ang = self:GetViewModelSmooth(pos, ang)
-- if singleplayer or IsFirstTimePredicted() then
pos, ang = WorldToLocal(pos, ang, oldpos, oldang)

View File

@ -64,4 +64,24 @@ function SWEP:GetFreeSwayAngles()
ang = ang * smoothswayamt
return ang
end
SWEP.InertiaDiff = Angle()
SWEP.InertiaSideMoveRaw = 0
SWEP.InertiaSideMoveSmooth = 0
function SWEP:GetInertiaSwayAngles()
if !self.InertiaEnabled then return end
-- if !arc9_mod_inertia:GetBool() then return end
local eyee = self:GetOwner():EyeAngles()
self.InertiaDiff = LerpAngle(FrameTime() * 6, self.InertiaDiff, eyee - self:GetLastAimAngle())
self.InertiaSideMoveSmooth = Lerp(FrameTime() * 2, self.InertiaSideMoveSmooth, self.InertiaSideMoveRaw * 0.003)
self:SetLastAimAngle(eyee)
self.InertiaDiff.y = self.InertiaDiff.y - self.InertiaSideMoveSmooth
return self.InertiaDiff * -25
end

View File

@ -962,9 +962,9 @@ function SWEP:GetShootDir()
dir:Add(self:GetFreeAimOffset())
local fswayang = self:GetFreeSwayAngles()
if fswayang then
dir:Add(fswayang)
end
if fswayang then dir:Add(fswayang) end
if self.InertiaEnabled then dir:Add(self:GetInertiaSwayAngles()) end
return dir
end