Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if SERVER then
- AddCSLuaFile("flyingragdolls.lua")
- end
- hook.Add("PlayerDeath", "OnRagdollController",
- function(ply, weapon, killer)
- if SERVER then
- local ragdoll_controller = ents.Create("prop_physics")
- ragdoll_controller:SetModel("models/props_junk/PopCan01a.mdl")
- ragdoll_controller:SetPos(ply:GetPos())
- ragdoll_controller:Spawn()
- ply:SetNWEntity("ragdoll_controller", ragdoll_controller)
- local pobj = ragdoll_controller:GetPhysicsObject()
- if( pobj:IsValid() ) then
- pobj:Wake()
- end
- timer.Create(ply:UserID() .. "_dead", 0, 0,
- function()
- if( !ply ) then
- return
- end
- if( !ply:IsValid() ) then
- return false
- end
- if( ply:Alive() ) then
- ragdoll_controller:Remove()
- ply:SetNWEntity("ragdoll_controller", nil)
- return false
- end
- if( ply:KeyDown(IN_FORWARD) ) then
- pobj:ApplyForceCenter(ply:GetCursorAimVector() * 100)
- pobj:AddVelocity(pobj:GetVelocity() * -0.035)
- end
- end
- )
- end
- end
- )
- if CLIENT then
- hook.Add("OnEntityCreated", "OnRagdollCreate",
- function(ent)
- if(!ent) then
- return
- end
- local c=ent:GetClass()
- if c=="class C_HL2MPRagdoll" then
- print("Death ragdoll: ", ent)
- local ply = nil
- for k,v in pairs(player.GetAll()) do
- if v:GetRagdollEntity() == ent then
- ply = v
- end
- end
- local timerid = CurTime() + math.random()
- local rotation = 0
- local bodyparts = {}
- bodyparts[10] = 800
- timer.Create(timerid ,0,0,function()
- if( !ent:IsValid() ) then
- return false
- end
- local ragdoll_controller = ply:GetNWEntity("ragdoll_controller")
- if( ragdoll_controller == nil ) then
- return
- end
- local add = Vector(0,0,0)
- local move = false
- local pos = ragdoll_controller:GetPos()
- for bodypart, acceleration in pairs(bodyparts) do
- local pobj = ent:GetPhysicsObjectNum(bodypart)
- if( pobj:IsValid() ) then
- pobj:ApplyForceCenter( (pos - pobj:GetPos()) * FrameTime() * 2000 )
- end
- end
- end)
- end
- end
- )
- end
Advertisement
Add Comment
Please, Sign In to add comment