Advertisement
TylerB

decap

Jun 6th, 2015
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 19.28 KB | None | 0 0
  1. if SERVER then
  2.     hook.Add("TTTBeginRound","head_remove",function()
  3.         for k,v in pairs(ents.FindByModel("models/Gibs/HGIBS.mdl")) do
  4.             if v.isskull then
  5.                 v:Remove()
  6.             end
  7.         end
  8.     end)
  9.  
  10.     if not pointadmin then pointadmin = {} end
  11.    
  12.     util.AddNetworkString("blua")
  13.    
  14.     function pointadmin.BroadcastLua(str)
  15.         net.Start("blua")
  16.             net.WriteString(str)
  17.         net.Broadcast()
  18.     end
  19.    
  20.     function game.GetServer() return "buildrp" end
  21.    
  22.     hook.Add("EntityTakeDamage", "decapitation", function( target, dmginfo )
  23.         if not (target:IsPlayer() or target:GetClass() == "prop_ragdoll") then return end
  24.         if not dmginfo:GetAttacker():IsPlayer() then return end
  25.         if target.pa_god then return end
  26.        
  27.         local headpos = target:GetBonePosition(target:LookupBone("ValveBiped.Bip01_head1"))
  28.        
  29.         if IsValid(dmginfo:GetAttacker():GetActiveWeapon()) then
  30.             if dmginfo:GetAttacker():GetActiveWeapon():GetClass() == "weapon_stunstick" then dmginfo:SetDamage(10) end
  31.             if dmginfo:GetAttacker():GetActiveWeapon():GetClass() == "weapon_crowbar" then dmginfo:SetDamage(5) end
  32.         end
  33.        
  34.         if dmginfo:GetDamagePosition():Distance(headpos) < 9 then dmginfo:ScaleDamage(10) end
  35.        
  36.         if (target:IsPlayer() and target:Alive() or true) and not target.Babygod and not target.decapped and dmginfo:GetDamagePosition():Distance(headpos) < 9 and target:Health() - dmginfo:GetDamage() <= 0 then
  37.  
  38.             local RF = RecipientFilter()
  39.             for k,v in pairs(player.GetAll()) do
  40.                 if v:IsAdmin() then
  41.                     RF:AddPlayer(v)
  42.                 end
  43.             end
  44.            
  45.             local infli = dmginfo:GetInflictor()
  46.             local class = infli:IsPlayer() and dmginfo:GetInflictor():GetActiveWeapon() or NULL
  47.            
  48.             if IsValid(class) then class = class:GetClass() end
  49.            
  50.             if game.GetServer() == "buildrp" then
  51.                 -- umsg.Start("DRPLogMsg", RF)
  52.                     -- umsg.Short(255)
  53.                     -- umsg.Short(190)
  54.                     -- umsg.Short(0)
  55.                     -- umsg.String( (target:IsPlayer() and target:Name() or target:GetModel()).." was decapitated by "..(infli:Name()).." using "..(class).."." )
  56.                 -- umsg.End()
  57.                
  58.                 if target:IsPlayer() then
  59.                     hook.Call("DoPlayerDeath", GAMEMODE, target, dmginfo:GetAttacker(), dmginfo)
  60.                     --pointadmin.SpawnEcho((target:IsPlayer() and target or target:GetModel()),Color(255, 255, 255)," ("..target:SteamID()..") was ",Color(255,85,85),"decapitated",Color(255, 255, 255)," by ",infli," with a "..class..".")
  61.                     --pointadmin.LogFile((target:IsPlayer() and target:Name() or target:GetModel()).." was decapitated by "..(infli:Name()).." using "..(class)..".\n")
  62.                 end
  63.             end
  64.        
  65.             if not target:IsPlayer() then
  66.                 target:ManipulateBoneScale(target:LookupBone("ValveBiped.Bip01_head1"),Vector(0,0,0))
  67.             end
  68.            
  69.             local skull = ents.Create("prop_physics")
  70.             skull:SetModel("models/Gibs/HGIBS.mdl")
  71.             skull:SetPos(headpos)
  72.             skull:SetAngles(target:EyeAngles())
  73.             skull:Spawn()
  74.             skull:SetModelScale(1.25,0)
  75.             skull.isskull = true
  76.             skull:SetCollisionGroup(COLLISION_GROUP_DEBRIS_TRIGGER)
  77.            
  78.             skull:GetPhysicsObject():AddAngleVelocity(Vector(math.random(-1000,1000),math.random(-1000,1000),math.random(-1000,1000)))
  79.            
  80.             skull:SetNWString("killer",(target:IsPlayer() and target:Name() or target:GetNWString("nick","Someone")).."'s skull")
  81.             skull:SetNWBool("skull",true)
  82.             skull:SetNWInt("killtime",CurTime())
  83.            
  84.             if target:IsPlayer() then
  85.                 if game.GetServer() != "ttt" then
  86.                     target:CreateRagdoll()
  87.                     target:KillSilent()
  88.                     -- target:StripWeapons()
  89.                     -- target:Spectate( OBS_MODE_CHASE )
  90.                     -- target:SpectateEntity( skull )
  91.                    
  92.                     -- timer.Simple(5, function()
  93.                         -- if not IsValid(target) then return end
  94.                        
  95.                         -- target:Spawn()
  96.                     -- end)
  97.                 else
  98.                
  99.                 end
  100.             end
  101.            
  102.             local dir = headpos - dmginfo:GetAttacker():GetPos()
  103.                
  104.             dir:Normalize()
  105.                
  106.             skull:GetPhysicsObject():SetVelocity(dir*dmginfo:GetDamage())
  107.            
  108.             local r = math.random(2,4)
  109.            
  110.             for i = 1,10 do skull:EmitSound("physics/body/body_medium_break"..r..".wav",100,math.random(90,100)) end
  111.            
  112.             if game.GetServer() != "ttt" then
  113.                 timer.Simple(60,function()
  114.                     if not IsValid(skull) then return end
  115.                     if not skull.isskull then return end
  116.                    
  117.                     skull:Remove()
  118.                 end)
  119.             else
  120.            
  121.            
  122.             end
  123.            
  124.             -- kill me because im too fucking lazy to make a table
  125.            
  126.             local com = false
  127.             local fem = false
  128.            
  129.             if string.find(target:GetModel(),"alyx") or string.find(target:GetModel(),"mossman") or string.find(target:GetModel(),"female") then
  130.                 fem = true
  131.             end
  132.            
  133.             if string.find(target:GetModel(),"police") or string.find(target:GetModel(),"combine") or string.find(target:GetModel(),"soldier") then
  134.                 com = true
  135.             end
  136.      
  137.             --if target:IsPlayer() then
  138.                 if string.find(target:GetModel(),"barney") then
  139.                     local r = math.random(1,9)
  140.                     for i = 1, 2 do target:EmitSound("vo/npc/barney/ba_pain0"..r..".wav",80) end
  141.                 elseif string.find(target:GetModel(),"alyx") then
  142.                     local r = math.random(1,3)
  143.                     for i = 1, 2 do target:EmitSound("vo/npc/alyx/no0"..r..".wav",80) end
  144.                 elseif string.find(target:GetModel(),"breen") then
  145.                     for i = 1, 2 do target:EmitSound("vo/citadel/br_no.wav",80) end
  146.                 elseif string.find(target:GetModel(),"kleiner") then
  147.                     for i = 1, 2 do target:EmitSound("vo/k_lab/kl_ahhhh.wav",80) end
  148.                 elseif string.find(target:GetModel(),"monk") then
  149.                     for i = 1, 2 do target:EmitSound("vo/ravenholm/monk_death07.wav",80) end
  150.                 elseif com then
  151.                     local r = math.random(1,4)
  152.                     for i = 1, 2 do target:EmitSound("npc/metropolice/die"..r..".wav",80) end
  153.                 elseif not fem then
  154.                     local r = math.random(1,5)
  155.                     for i = 1, 2 do target:EmitSound("player/crit_death"..r..".wav",80) end
  156.                 else
  157.                     for i = 1, 2 do target:EmitSound("ambient/voices/f_scream1.wav",80) end
  158.                 end
  159.             if not target:IsPlayer() then
  160.                 target.decapped = true
  161.             end
  162.  
  163.             if game.GetServer() == "ttt" then
  164.                 timer.Simple(0.1,function()
  165.                     if target:IsPlayer() then
  166.                         for k,v in pairs(ents.FindByClass("prop_ragdoll")) do
  167.                             if v:GetNWString("nick", "") == target:Name() then
  168.                                 target = v
  169.                                 target.decapped = true
  170.                                 target:ManipulateBoneScale(target:LookupBone("ValveBiped.Bip01_head1"),Vector(0,0,0))
  171.                             end
  172.                         end
  173.                     end
  174.                    
  175.                     print(target)
  176.                     pointadmin.BroadcastLua([[
  177.                         timer.Simple(0.1,function()
  178.                             local ragdoll = Entity(]]..target:EntIndex()..[[)
  179.                                
  180.                             if ragdoll:IsPlayer() then
  181.                                 ragdoll = ragdoll:GetRagdollEntity()
  182.                             end
  183.                            
  184.                             local skull = Entity(]]..skull:EntIndex()..[[)
  185.                            
  186.                             if IsValid(skull) then
  187.                                 for i = 1, 256 do
  188.                                     timer.Simple(i/32, function()
  189.                                         if not IsValid(skull) then return end
  190.                    
  191.                                         for i = 1, 2 do
  192.                                             local x = (math.random(-100,100)/100) * 15
  193.                                             local y = (math.random(-100,100)/100) * 15
  194.                                             local z = (math.random(-100,100)/100) * 15
  195.                                            
  196.                                             util.Decal( "blood", skull:GetPos() + Vector(x,y,z), skull:GetPos() + Vector(x*2,y*2,z*2))
  197.                                         end                
  198.                                     end)
  199.                                 end
  200.                                
  201.                                 for i = 1, 50 do
  202.                                     timer.Simple(i/5, function()
  203.                    
  204.                                         if not IsValid(skull) then return end
  205.                                        
  206.                                         local effectdata = EffectData()
  207.                                         effectdata:SetOrigin( skull:GetPos() )
  208.                                        
  209.                                         for i = 1,1 do
  210.                                             effectdata:SetOrigin( skull:GetPos() + Vector(math.random(-5,5),math.random(-5,5),math.random(-5,5)) )
  211.                                             util.Effect( "bloodimpact", effectdata )
  212.                                         end            
  213.                                     end)
  214.                                 end                        
  215.                             end
  216.                                        
  217.                             if not IsValid(ragdoll) then return end
  218.                    
  219.                             local headpos = ragdoll:GetBonePosition(ragdoll:LookupBone("ValveBiped.Bip01_head1"))
  220.                        
  221.                             local effectdata = EffectData()
  222.                             effectdata:SetOrigin( headpos )
  223.                    
  224.                             --for i = 1,1 do util.Effect( "Explosion", effectdata ) end
  225.                  
  226.                             for i = 1,25 do
  227.                                 effectdata:SetOrigin( headpos + Vector(math.random(-15,15),math.random(-15,15),math.random(-15,15)) )
  228.                                 util.Effect( "BloodImpact", effectdata )
  229.                             end
  230.                            
  231.                             for i = 1, 100 do
  232.                                 timer.Simple(i/10, function()
  233.  
  234.                                     if not IsValid(ragdoll) then return end
  235.                                    
  236.                                     local pos = ragdoll:GetBonePosition(ragdoll:LookupBone("ValveBiped.Bip01_head1"))
  237.                                    
  238.                                     local effectdata = EffectData()
  239.                                     effectdata:SetOrigin( pos )
  240.                                    
  241.                                     for i = 1,1 do
  242.                                         effectdata:SetOrigin( pos + Vector(math.random(-5,5),math.random(-5,5),math.random(-5,5)) )
  243.                                         util.Effect( "bloodimpact", effectdata )
  244.                                     end            
  245.                                 end)
  246.                             end
  247.  
  248.                             for i = 1, 256 do
  249.                                 local x = (math.random(-100,100)/100) * 100
  250.                                 local y = (math.random(-100,100)/100) * 100
  251.                                 local z = (math.random(-100,100)/100) * 100
  252.                                
  253.                                 util.Decal( "blood", headpos, headpos + Vector(x,y,z))
  254.                             end
  255.                            
  256.                             ragdoll:AddCallback("BuildBonePositions", function()
  257.                                 local bone = ragdoll:LookupBone("ValveBiped.Bip01_Head1")
  258.                                 local mat = ragdoll:GetBoneMatrix(bone)
  259.                                 mat:Scale(Vector(0, 0, 0))
  260.                                 ragdoll:SetBoneMatrix(ragdoll:LookupBone("ValveBiped.Bip01_Head1"), mat)
  261.                                 ragdoll:ManipulateBoneScale(ragdoll:LookupBone("ValveBiped.Bip01_Head1"), Vector(0,0,0))
  262.                             end)
  263.                         end)
  264.                     ]])
  265.                 end)
  266.             else
  267.                     pointadmin.BroadcastLua([[
  268.                         timer.Simple(0.1,function()
  269.                             local ragdoll = Entity(]]..target:EntIndex()..[[)
  270.                                
  271.                             if ragdoll:IsPlayer() then
  272.                                 ragdoll = ragdoll:GetRagdollEntity()
  273.                             end
  274.                            
  275.                             local skull = Entity(]]..skull:EntIndex()..[[)
  276.                            
  277.                             if IsValid(skull) then
  278.                                 for i = 1, 1024 do
  279.                                     timer.Simple(i/32, function()
  280.                                         if not IsValid(skull) then return end
  281.                    
  282.                                         for i = 1, 2 do
  283.                                             local x = (math.random(-100,100)/100) * 15
  284.                                             local y = (math.random(-100,100)/100) * 15
  285.                                             local z = (math.random(-100,100)/100) * 15
  286.                                            
  287.                                             util.Decal( "blood", skull:GetPos() + Vector(x,y,z), skull:GetPos() + Vector(x*2,y*2,z*2))
  288.                                         end                
  289.                                     end)
  290.                                 end
  291.                                
  292.                                 for i = 1, 50 do
  293.                                     timer.Simple(i/5, function()
  294.                    
  295.                                         if not IsValid(skull) then return end
  296.                                        
  297.                                         local effectdata = EffectData()
  298.                                         effectdata:SetOrigin( skull:GetPos() )
  299.                                        
  300.                                         for i = 1,1 do
  301.                                             effectdata:SetOrigin( skull:GetPos() + Vector(math.random(-5,5),math.random(-5,5),math.random(-5,5)) )
  302.                                             util.Effect( "bloodimpact", effectdata )
  303.                                         end            
  304.                                     end)
  305.                                 end                        
  306.                             end
  307.                                        
  308.                             if not IsValid(ragdoll) then return end
  309.                    
  310.                             local headpos = ragdoll:GetBonePosition(ragdoll:LookupBone("ValveBiped.Bip01_head1"))
  311.                        
  312.                             local effectdata = EffectData()
  313.                             effectdata:SetOrigin( headpos )
  314.                    
  315.                             --for i = 1,1 do util.Effect( "Explosion", effectdata ) end
  316.                  
  317.                             for i = 1,25 do
  318.                                 effectdata:SetOrigin( headpos + Vector(math.random(-15,15),math.random(-15,15),math.random(-15,15)) )
  319.                                 util.Effect( "BloodImpact", effectdata )
  320.                             end
  321.                            
  322.                             for i = 1, 100 do
  323.                                 timer.Simple(i/10, function()
  324.  
  325.                                     if not IsValid(ragdoll) then return end
  326.                                    
  327.                                     local pos = ragdoll:GetBonePosition(ragdoll:LookupBone("ValveBiped.Bip01_head1"))
  328.                                    
  329.                                     local effectdata = EffectData()
  330.                                     effectdata:SetOrigin( pos )
  331.                                    
  332.                                     for i = 1,1 do
  333.                                         effectdata:SetOrigin( pos + Vector(math.random(-5,5),math.random(-5,5),math.random(-5,5)) )
  334.                                         util.Effect( "bloodimpact", effectdata )
  335.                                     end            
  336.                                 end)
  337.                             end
  338.  
  339.                             for i = 1, 256 do
  340.                                 local x = (math.random(-100,100)/100) * 100
  341.                                 local y = (math.random(-100,100)/100) * 100
  342.                                 local z = (math.random(-100,100)/100) * 100
  343.                                
  344.                                 util.Decal( "blood", headpos, headpos + Vector(x,y,z))
  345.                             end
  346.                            
  347.                             ragdoll:AddCallback("BuildBonePositions", function()
  348.                                 local bone = ragdoll:LookupBone("ValveBiped.Bip01_Head1")
  349.                                 local mat = ragdoll:GetBoneMatrix(bone)
  350.                                 mat:Scale(Vector(0, 0, 0))
  351.                                 ragdoll:SetBoneMatrix(ragdoll:LookupBone("ValveBiped.Bip01_Head1"), mat)
  352.                                 ragdoll:ManipulateBoneScale(ragdoll:LookupBone("ValveBiped.Bip01_Head1"), Vector(0,0,0))
  353.                             end)
  354.                         end)
  355.                     ]])
  356.                 end
  357.         end
  358.        
  359.         return dmginfo
  360.     end)
  361. else
  362.     net.Receive("blua", function() RunString(net.ReadString()) end)
  363.    
  364.     hook.Add("HUDDrawTargetID","DrawSkull",function()
  365.         local ply = LocalPlayer():GetEyeTrace().Entity
  366.  
  367.         if IsValid(ply) then
  368.             if ply:GetNWBool("skull",false) then
  369.                 draw.SimpleText( ply:GetNWString("killer","Unidentified Skull"), "TargetID", (ScrW()/2) + 1, (ScrH()/2)+11, COLOR_BLACK, TEXT_ALIGN_CENTER )
  370.                 draw.SimpleText( ply:GetNWString("killer","Unidentified Skull"), "TargetID", (ScrW()/2), (ScrH()/2)+10, COLOR_WHITE, TEXT_ALIGN_CENTER )
  371.                
  372.                 if not pointadmin then return end
  373.                
  374.                 local text = ply:GetNWInt("killtime",0) == 0 and "" or "Dismembered "..(CurTime() - ply:GetNWInt("killtime",0)).." seconds ago."
  375.                
  376.                 draw.SimpleText( text, "TargetID", (ScrW()/2) + 1, (ScrH()/2)+38, COLOR_BLACK, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  377.                 draw.SimpleText( text, "TargetID", (ScrW()/2), (ScrH()/2)+37, COLOR_WHITE, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  378.             end
  379.         end
  380.     end)
  381. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement