Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This function will replace the ragdolls' BuildBonePositions function
- local function GSBuildBones( self, numbones, numphysbone ) //Note: the two last argument doesn't seem to work
- local ModelType = self:GetModelType() //Retrive the modeltype
- local Bonetree = GSBonetrees[ ModelType ] //Make a variable containing our bonetree
- local Index = self:EntIndex() //Used for removing
- local ShouldRemove = true //If all the bones are gone
- for _, bone in pairs( self.GSDecappedBones ) do //Loop through bones
- local Searched = {} //Create a tabel containing all the searched bones
- local ParentBone = bone //Localize parentbone
- repeat
- table.insert( Searched, ParentBone ) //Insert it into the searched table
- ParentBone = self:GetParentBone( ParentBone ) //Try the current bone
- until ( table.HasValue( Searched, ParentBone ) || !table.HasValue( self.GSDecappedBones, ParentBone ) || !ParentBone )
- if ( !ParentBone || ParentBone == bone ) then
- ParentBone = self:GetBoneBackup()
- end
- if ( !ParentBone ) then
- /*RunConsoleCommand( "GSRemoveRagdoll", Index )
- return*/
- end
- ParentBone = self:TranslatePhysBoneToBone( ParentBone )
- if ( ParentBone ) then
- local Pos = self:GetBoneMatrix( ParentBone ):GetTranslation()
- local RealBone = self:TranslatePhysBoneToBone( bone ) //Translate the physbone
- local BoneMatrix = self:GetBoneMatrix( RealBone )
- if ValidEntity(BoneMatrix) then
- BoneMatrix:Scale( vector_origin ) //vector_origin = Vector( 0, 0, 0 )
- BoneMatrix:SetTranslation( Pos )
- self:SetBoneMatrix( RealBone, BoneMatrix )
- end
- end
- end
- end
- //Description: recieves info from the server
- local function GSInitializeCS( Umsg )
- local Ent = Umsg:ReadEntity()
- Ent.PhysCount = Umsg:ReadLong()
- local OldFunc = Ent.BuildBonePositions
- if ( OldFunc ) then //It allready has a BuildBonePositions function :O
- //Lets merge it with our own :D
- Ent.BuildBonePositions = function( self, NumBones, NumPhysBones )
- OldFunc( self, NumBones, NumPhysBones ) //Call the old function
- GSBuildBones( self, NumBones, NumPhysBones ) //Call our function
- end
- else
- Ent.BuildBonePositions = GSBuildBones //Give it our function to use
- end
- Ent.GSDecappedBones = {}
- end
- usermessage.Hook( "GSInitializeCS", GSInitializeCS ) //Hook it up
- //Description: Recieves bones to decap
- local function GSRecieveBones( Umsg )
- local Ent = Umsg:ReadEntity()
- Ent.GSDecappedBones = Ent.GSDecappedBones || {}
- local Count = Umsg:ReadLong()
- for i = 1, Count do
- if ( Ent.GSDecappedBones ) then
- table.insert( Ent.GSDecappedBones, Umsg:ReadLong() )
- end
- end
- end
- usermessage.Hook( "GSRecieveBones", GSRecieveBones )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement