real head movement

This commit is contained in:
Darky 2022-03-26 21:08:43 +07:00
parent 5885bb184d
commit 8ee7170bf8
2 changed files with 15 additions and 0 deletions

View File

@ -2,6 +2,8 @@ SWEP.SmoothedMagnification = 1
SWEP.FOV = 90
function SWEP:CalcView(ply, pos, ang, fov)
if self:GetOwner():ShouldDrawLocalPlayer() then return end
local rec = (self:GetLastRecoilTime() + 0.25) - CurTime()
-- rec = rec * 0.5

View File

@ -1,6 +1,7 @@
// third person inverse kinematics
function SWEP:ShouldTPIK()
if render.GetDXLevel() < 90 then return false end
if self:GetSafe() then return false end
if self:GetBlindFireAmount() > 0 then return false end
if !self:GetOwner():ShouldDrawLocalPlayer() then return false end
@ -83,6 +84,8 @@ function SWEP:DoTPIK()
local ply_l_hand_index = ply:LookupBone("ValveBiped.Bip01_L_Hand")
local ply_r_hand_index = ply:LookupBone("ValveBiped.Bip01_R_Hand")
local ply_head_index = ply:LookupBone("ValveBiped.Bip01_Head1")
if !ply_l_shoulder_index then return end
if !ply_r_shoulder_index then return end
if !ply_l_elbow_index then return end
@ -90,10 +93,14 @@ function SWEP:DoTPIK()
if !ply_l_hand_index then return end
if !ply_r_hand_index then return end
if !ply_head_index then return end
local ply_r_shoulder_matrix = ply:GetBoneMatrix(ply_r_shoulder_index)
local ply_r_elbow_matrix = ply:GetBoneMatrix(ply_r_elbow_index)
local ply_r_hand_matrix = ply:GetBoneMatrix(ply_r_hand_index)
local ply_head_matrix = ply:GetBoneMatrix(ply_head_index)
local r_upperarm_length = 12
local r_forearm_length = 12
local l_upperarm_length = 12
@ -116,6 +123,12 @@ function SWEP:DoTPIK()
ply_r_elbow_angle.r = -90
ply_r_elbow_matrix:SetAngles(ply_r_elbow_angle)
local camcontrol = self:GetCameraControl()*4
local ply_head_angle = ply:GetBoneMatrix(ply_head_index):GetAngles() + Angle(camcontrol.z, -camcontrol.x, camcontrol.y)
ply_head_matrix:SetAngles(ply_head_angle)
ply:SetBoneMatrix(ply_head_index, ply_head_matrix)
ply:SetBoneMatrix(ply_r_elbow_index, ply_r_elbow_matrix)
ply:SetBoneMatrix(ply_r_shoulder_index, ply_r_shoulder_matrix)