94 lines
2.3 KiB
Text
94 lines
2.3 KiB
Text
AddCSLuaFile()
|
|
|
|
ENT.Type = "anim"
|
|
ENT.Base = "base_anim"
|
|
ENT.AutomaticFrameAdvance = true
|
|
|
|
local bones_to_animate = {
|
|
"ValveBiped.Bip01_Pelvis",
|
|
"ValveBiped.Bip01_Spine2",
|
|
"ValveBiped.Bip01_Head1",
|
|
"ValveBiped.Bip01_R_Thigh",
|
|
"ValveBiped.Bip01_L_Thigh",
|
|
"ValveBiped.Bip01_L_Calf",
|
|
"ValveBiped.Bip01_R_Calf",
|
|
"ValveBiped.Bip01_R_Foot",
|
|
"ValveBiped.Bip01_L_Foot",
|
|
"ValveBiped.Bip01_R_Upperarm",
|
|
"ValveBiped.Bip01_L_Upperarm",
|
|
"ValveBiped.Bip01_R_Forearm",
|
|
"ValveBiped.Bip01_L_Forearm",
|
|
"ValveBiped.Bip01_R_Hand",
|
|
"ValveBiped.Bip01_L_Hand",
|
|
}
|
|
|
|
function ENT:Initialize()
|
|
if SERVER then
|
|
print("I AM SERVERSIDE")
|
|
self:SetModel("models/dav0r/hoverball.mdl")
|
|
end
|
|
|
|
if CLIENT then
|
|
print("I AM CLIENTSIDE")
|
|
timer.Simple(0.2, function()
|
|
|
|
end)
|
|
end
|
|
end
|
|
|
|
function ENT:Draw()
|
|
if CLIENT then
|
|
local old_ragdoll = self:GetNWEntity("parent")
|
|
if IsValid(old_ragdoll) then
|
|
if !self.ready_to_unfake then
|
|
self.ragdoll = ClientsideModel(old_ragdoll:GetModel())
|
|
self.ragdoll:SetModel(old_ragdoll:GetModel())
|
|
|
|
self.bone_list = {}
|
|
|
|
self.ragdoll:SetupBones()
|
|
|
|
for i,name in pairs(bones_to_animate) do
|
|
local bone_index = old_ragdoll:LookupBone(name)
|
|
|
|
self.bone_list[name] = old_ragdoll:GetBoneMatrix(bone_index)
|
|
end
|
|
|
|
print("BONES:"..self.ragdoll:GetBoneCount())
|
|
|
|
self.ready_to_unfake = true
|
|
end
|
|
|
|
self.ragdoll:SetPos(old_ragdoll:GetPos())
|
|
|
|
for name,matrix in pairs(self.bone_list) do
|
|
local bone_index = self.ragdoll:LookupBone(name)
|
|
if bone_index == -1 then
|
|
print(name.." does not exist, skipping...")
|
|
continue
|
|
end
|
|
|
|
print(name)
|
|
--local bone_matrix = old_ragdoll:GetBoneMatrix(bone_index)
|
|
|
|
self.ragdoll:SetBoneMatrix(bone_index, matrix)
|
|
end
|
|
end
|
|
end
|
|
|
|
self:DrawModel()
|
|
self.ragdoll:DrawModel()
|
|
end
|
|
|
|
function ENT:Think()
|
|
|
|
return true
|
|
end
|
|
|
|
function ENT:OnRemove()
|
|
if CLIENT then
|
|
if self.anim_ragdoll then
|
|
self.anim_ragdoll:Remove()
|
|
end
|
|
end
|
|
end
|