Initial commit

This commit is contained in:
Winded 2013-06-28 21:53:04 +03:00
commit fa6a626116
4 changed files with 139 additions and 0 deletions

5
README.md Normal file
View File

@ -0,0 +1,5 @@
Physgun Undo
============
A Garry's Mod tool to put ragdolls on their model idle pose, which most likely is a stand pose.
Pull requests are welcome.

6
info.txt Normal file
View File

@ -0,0 +1,6 @@
"AddonInfo"
{
"name" "Standing Pose Tool"
"author_name" "author"
"info" "This small tool can pose a ragdoll to it's model pose, which usually is a standing pose for ragdolls. It does not work properly with all ragdolls, but for most of them it does."
}

55
lua/autorun/standpose.lua Normal file
View File

@ -0,0 +1,55 @@
local propt = {}
propt.MenuLabel = "Stand Pose"
propt.Order = 5000
propt.Filter = function( self, ent )
if ( !IsValid( ent ) ) then return false end
if ( ent:GetClass() != "prop_ragdoll" ) then return false end
return true
end
propt.Action = function( self, ent )
self:MsgStart()
net.WriteEntity( ent )
self:MsgEnd()
end
propt.Receive = function( self, length, player )
local rag = net.ReadEntity()
if ( !IsValid( rag ) ) then return end
if ( !IsValid( player ) ) then return end
if ( rag:GetClass() != "prop_ragdoll" ) then return end
local tr = util.TraceLine({start = rag:GetPos(),endpos = rag:GetPos() - Vector(0,0,3000),filter = rag})
local ent = ents.Create("prop_dynamic")
ent:SetModel(rag:GetModel())
ent:SetPos(tr.HitPos)
local angle = (tr.HitPos - player:GetPos()):Angle()
ent:SetAngles(Angle(0,angle.y-180,0))
ent:Spawn()
for i=0,rag:GetPhysicsObjectCount()-1 do
local phys = rag:GetPhysicsObjectNum(i)
local b = rag:TranslatePhysBoneToBone(i)
local pos,ang = ent:GetBonePosition(b)
phys:EnableMotion(true)
phys:Wake()
phys:SetPos(pos)
phys:SetAngles(ang)
if string.sub(rag:GetBoneName(b),1,4) == "prp_" then
phys:EnableMotion(true)
phys:Wake()
else
phys:EnableMotion(false)
phys:Wake()
end
end
ent:Remove()
end
properties.Add("standpose",propt)

View File

@ -0,0 +1,73 @@
TOOL.Category = "Poser"
TOOL.Name = "Stand Pose"
TOOL.Command = nil
TOOL.ConfigName = nil
function TOOL:LeftClick(tr)
if self:GetStage() == 0 then
if !IsValid(tr.Entity) then return false end
if tr.Entity:GetClass() != "prop_ragdoll" then return false end
if CLIENT then return true end
self.SelectedEnt = tr.Entity
self:SetStage(1)
return true
else
local rag = self.SelectedEnt
if !IsValid(rag) then
self:SetStage(0)
return true
end
if CLIENT then return true end
local ent = ents.Create("prop_dynamic")
ent:SetModel(rag:GetModel())
ent:SetPos(tr.HitPos)
local angle = (tr.HitPos - self:GetOwner():GetPos()):Angle()
ent:SetAngles(Angle(0,angle.y-180,0))
ent:Spawn()
for i=0,rag:GetPhysicsObjectCount()-1 do
local phys = rag:GetPhysicsObjectNum(i)
local b = rag:TranslatePhysBoneToBone(i)
local pos,ang = ent:GetBonePosition(b)
phys:EnableMotion(true)
phys:Wake()
phys:SetPos(pos)
phys:SetAngles(ang)
if string.sub(rag:GetBoneName(b),1,4) == "prp_" then
phys:EnableMotion(true)
phys:Wake()
else
phys:EnableMotion(false)
phys:Wake()
end
end
ent:Remove()
self:SetStage(0)
return true
end
end
function TOOL:RightClick(tr)
if self:GetStage() == 1 then
self:SetStage(0)
return true
end
return false
end
if CLIENT then
language.Add("tool.ragdollstand.name","Stand Pose")
language.Add("tool.ragdollstand.desc","Position ragdolls in a standing pose.")
language.Add("tool.ragdollstand.0","Left Click to select a ragdoll.")
language.Add("tool.ragdollstand.1","Now click on a position where you want the ragdoll to stand or Right Click to cancel.")
end