Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // How many gib particles to emit (careful, 1 gib particle emits like 30 giblets, so don't set this number super high)
- local TTTGore_GibsParticle = 3
- // How many blood streams to make
- local TTTGore_BloodStreams = 10
- // How many little gib models to spawn
- local TTTGore_GibModels = 8
- // How many times to create the blood effect after losing a limb
- local TTTGore_BloodMissingLimbDuration = 50
- // Doesn't look very good because of how source ragdolls work, but attempts to separate the limbs when exploded
- local TTTGore_SeparateLimbs = true
- // Should ragdolls leave blood decals when damaged
- local TTTGore_RagdollBlood = true
- // Should ragdolls emit blood squirts when shot
- local TTTGore_RagdollBloodSquirt = true
- /*=================================================================================================
- DO NOT TOUCH ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU'RE DOING!
- =================================================================================================*/
- hook.Add("TTTOnCorpseCreated", "TTTGoreRagdoll", function(rag, ply)
- if (bit.band(rag.dmgtype, DMG_BLAST) == DMG_BLAST || bit.band(rag.dmgtype, DMG_FALL) == DMG_FALL) then
- local limbstoremove
- if bit.band(rag.dmgtype, DMG_BLAST) == DMG_BLAST then
- limbstoremove = 4-math.floor(ply.TTTGore_DamageDistance/64)
- else
- limbstoremove = math.Clamp(math.floor(ply.TTTGore_DamageTaken/25), 0, 4)
- end
- if limbstoremove <= 0 then
- return
- end
- if limbstoremove == 4 then
- local pos = rag:GetPos()
- for i=1, TTTGore_GibsParticle do
- local effectdata = EffectData()
- effectdata:SetStart( pos )
- effectdata:SetOrigin( pos )
- util.Effect( "gibs", effectdata )
- end
- for i=1, TTTGore_BloodStreams do
- local vPoint = pos
- local effectdata = EffectData()
- effectdata:SetOrigin( vPoint )
- util.Effect("bloodstream",effectdata)
- end
- if SERVER then
- for i=1,TTTGore_GibModels do
- TTTGoreCreateGib("models/monstermash/gibs/gib_"..((i%8)+1)..".mdl", pos, rag:GetAngles(), rag)
- end
- rag:Remove()
- end
- else
- if bit.band(rag.dmgtype, DMG_BLAST) == DMG_BLAST then
- sound.Play("deathgibs/explosion"..math.random(1,3)..".mp3", ply:GetShootPos(), 90, 100)
- end
- local limbtable = {"LeftLeg", "LeftArm", "RightLeg", "RightArm"}
- for i=1, limbstoremove do
- local limb = table.Random(limbtable)
- local limbside = string.sub( limb, 1, 1 )
- table.remove(limbtable, table.KeyFromValue(limbtable, limb))
- if string.find(limb, "Leg") then
- rag:ManipulateBoneScale( rag:LookupBone( "ValveBiped.Bip01_"..limbside.."_Thigh" ), Vector(0,0,0) )
- rag:ManipulateBoneScale( rag:LookupBone( "ValveBiped.Bip01_"..limbside.."_Calf" ), Vector(0,0,0) )
- rag:ManipulateBoneScale( rag:LookupBone( "ValveBiped.Bip01_"..limbside.."_Foot" ), Vector(0,0,0) )
- rag:ManipulateBoneScale( rag:LookupBone( "ValveBiped.Bip01_"..limbside.."_Toe0" ), Vector(0,0,0) )
- TTTGoreEmitBlood(rag, i, "ValveBiped.Bip01_"..limbside.."_Thigh")
- elseif string.find(limb, "Arm") then
- rag:ManipulateBoneScale( rag:LookupBone( "ValveBiped.Bip01_"..limbside.."_UpperArm" ), Vector(0,0,0) )
- rag:ManipulateBoneScale( rag:LookupBone( "ValveBiped.Bip01_"..limbside.."_Forearm" ), Vector(0,0,0) )
- if rag:LookupBone( "ValveBiped.Bip01_"..limbside.."_Ulna" ) then
- rag:ManipulateBoneScale( rag:LookupBone( "ValveBiped.Bip01_"..limbside.."_Ulna" ), Vector(0,0,0) )
- end
- if rag:LookupBone( "ValveBiped.Bip01_"..limbside.."_Wrist" ) then
- rag:ManipulateBoneScale( rag:LookupBone( "ValveBiped.Bip01_"..limbside.."_Wrist" ), Vector(0,0,0) )
- end
- rag:ManipulateBoneScale( rag:LookupBone( "ValveBiped.Bip01_"..limbside.."_Hand" ), Vector(0,0,0) )
- TTTGoreEmitBlood(rag, i, "ValveBiped.Bip01_"..limbside.."_UpperArm")
- TTTGoreCreateLimb(rag, ply, limb)
- end
- end
- end
- return
- end
- end)
- local RedBloodEffect = {
- "blood_advisor_pierce_spray",
- "blood_advisor_pierce_spray_b",
- "blood_advisor_pierce_spray_c",
- "blood_advisor_puncture_withdraw",
- "blood_zombie_split_spray"
- }
- local YellowBloodEffect = {
- "blood_advisor_shrapnel_impact",
- }
- hook.Add("EntityTakeDamage", "TTTGoreDamage", function(target, dmginfo)
- if target:IsPlayer() then
- target.TTTGore_DamageTaken = dmginfo:GetDamage()
- target.TTTGore_DamageDistance = target:GetPos():Distance(dmginfo:GetInflictor():GetPos())
- end
- if (target:GetClass() == "prop_ragdoll" ) && TTTGore_RagdollBlood then
- local startp = dmginfo:GetDamagePosition()
- local traceinfo = {start = startp, endpos = startp - Vector(0,0,50), filter = target, mask = MASK_SOLID_BRUSHONLY}
- local trace = util.TraceLine(traceinfo)
- local todecal1 = trace.HitPos + trace.HitNormal
- local todecal2 = trace.HitPos - trace.HitNormal
- local BloodEffect = nil
- if target:GetMaterialType() == 70 || target:GetMaterialType() == 66 then
- util.Decal("Blood", todecal1, todecal2)
- local effect = EffectData()
- local origin = dmginfo:GetDamagePosition()
- effect:SetOrigin( origin )
- util.Effect( "bloodimpact", effect )
- BloodEffect = table.Random(RedBloodEffect)
- elseif target:GetMaterialType() == 65 || target:GetMaterialType() == 72 then
- util.Decal("YellowBlood", todecal1, todecal2)
- BloodEffect = table.Random(YellowBloodEffect)
- end
- if BloodEffect == nil || !dmginfo:IsBulletDamage() || !TTTGore_RagdollBloodSquirt then return end
- local BloodTrail = ents.Create( "info_particle_system" )
- BloodTrail:SetKeyValue( "effect_name", BloodEffect )
- BloodTrail:SetKeyValue( "start_active", tostring( 1 ) )
- BloodTrail:SetPos( dmginfo:GetDamagePosition() )
- local AngleMark = target:GetPos() - dmginfo:GetAttacker():GetPos()
- AngleMark = AngleMark:Angle()
- AngleMark.p = -100
- BloodTrail:SetAngles( AngleMark )
- BloodTrail:SetParent(target)
- BloodTrail:Spawn()
- BloodTrail:Activate()
- BloodTrail:Fire( "Kill", nil, 1 )
- end
- end)
- function TTTGoreEmitBlood(rag, i, bone)
- timer.Create( "GoreBlood_"..tostring(rag)..tostring(i), 0.1, TTTGore_BloodMissingLimbDuration, function()
- if !IsValid(rag) then return end
- local effect = EffectData()
- local origin = rag:GetBonePosition(rag:LookupBone( bone ))
- effect:SetOrigin( origin )
- util.Effect( "BloodImpact", effect )
- end)
- end
- function TTTGoreCreateLimb(rag, ply, limb)
- if CLIENT then return end
- if TTTGore_SeparateLimbs then
- local limbside = string.sub( limb, 1, 1 )
- local limbragdoll = ents.Create("prop_ragdoll")
- if not IsValid(limbragdoll) then return nil end
- limbragdoll:SetPos(rag:GetPos())
- limbragdoll:SetModel(rag:GetModel())
- limbragdoll:SetSkin(rag:GetSkin())
- for key, value in pairs(rag:GetBodyGroups()) do
- limbragdoll:SetBodygroup(value.id, rag:GetBodygroup(value.id))
- end
- limbragdoll:SetAngles(rag:GetAngles())
- limbragdoll:SetColor(rag:GetColor())
- limbragdoll:Spawn()
- limbragdoll:Activate()
- local playerColor = ply:GetPlayerColor()
- limbragdoll.GetPlayerColor = function()
- return playerColor
- end
- local num = limbragdoll:GetPhysicsObjectCount()-1
- for i=0, num do
- local bone = limbragdoll:GetPhysicsObjectNum(i)
- if IsValid(bone) then
- local bp, ba = limbragdoll:GetBonePosition(limbragdoll:TranslatePhysBoneToBone(i))
- if bp and ba then
- bone:SetPos(bp)
- bone:SetAngles(ba)
- end
- bone:SetVelocity(rag:GetVelocity())
- end
- end
- local numbones = limbragdoll:GetBoneCount()
- for i=1, numbones do
- limbragdoll:ManipulateBoneScale( i, Vector(0,0,0) )
- end
- if string.find(limb, "Leg") then
- limbragdoll:ManipulateBoneScale( limbragdoll:LookupBone( "ValveBiped.Bip01_"..limbside.."_Thigh" ), Vector(1,1,1) )
- limbragdoll:ManipulateBoneScale( limbragdoll:LookupBone( "ValveBiped.Bip01_"..limbside.."_Calf" ), Vector(1,1,1) )
- limbragdoll:ManipulateBoneScale( limbragdoll:LookupBone( "ValveBiped.Bip01_"..limbside.."_Foot" ), Vector(1,1,1) )
- limbragdoll:ManipulateBoneScale( limbragdoll:LookupBone( "ValveBiped.Bip01_"..limbside.."_Toe0" ), Vector(1,1,1) )
- TTTGoreEmitBlood(limbragdoll, math.random(9001, 90010), "ValveBiped.Bip01_"..limbside.."_Thigh")
- elseif string.find(limb, "Arm") then
- limbragdoll:ManipulateBoneScale( limbragdoll:LookupBone( "ValveBiped.Bip01_"..limbside.."_UpperArm" ), Vector(1,1,1) )
- limbragdoll:ManipulateBoneScale( limbragdoll:LookupBone( "ValveBiped.Bip01_"..limbside.."_Forearm" ), Vector(1,1,1) )
- if limbragdoll:LookupBone( "ValveBiped.Bip01_"..limbside.."_Ulna" ) then
- limbragdoll:ManipulateBoneScale( limbragdoll:LookupBone( "ValveBiped.Bip01_"..limbside.."_Ulna" ), Vector(1,1,1) )
- end
- if limbragdoll:LookupBone( "ValveBiped.Bip01_"..limbside.."_Wrist" ) then
- limbragdoll:ManipulateBoneScale( limbragdoll:LookupBone( "ValveBiped.Bip01_"..limbside.."_Wrist" ), Vector(1,1,1) )
- end
- limbragdoll:ManipulateBoneScale( limbragdoll:LookupBone( "ValveBiped.Bip01_"..limbside.."_Hand" ), Vector(1,1,1) )
- TTTGoreEmitBlood(limbragdoll, math.random(9001, 90010), "ValveBiped.Bip01_"..limbside.."_UpperArm")
- end
- end
- end
- function TTTGoreCreateGib(path,vector,angle,victim)
- if CLIENT then return end
- local ent = ents.Create("prop_physics")
- ent:SetPos(vector)
- ent:SetModel(path)
- ent:SetAngles(angle)
- ent:SetSkin(victim:GetSkin())
- ent:SetMaterial(victim:GetMaterial())
- ent:Spawn()
- local phys = ent:GetPhysicsObject()
- if ( !IsValid( phys ) ) then ent:Remove() return end
- phys:ApplyForceCenter( Vector( math.random(-200,200), math.random(-200,200), 100 ) )
- local num = math.Rand(1,3)
- for i = 0.1, num, 0.1 do
- timer.Simple(i,function()
- if !IsValid(ent) then return end
- local effectdata = EffectData()
- effectdata:SetOrigin( ent:GetPos() )
- util.Effect( "BloodImpact", effectdata )
- end)
- end
- if victim:IsOnFire() then ent:Ignite(math.Rand(6, 8), 0) end
- local color = Color( 105, 0, 0, 255 )
- local trail = util.SpriteTrail(ent, 0, color, false, 7, 1, 1, 1/(15+1)*0.5, "effects/bloodstream.vmt")
- ent:SetCollisionGroup(COLLISION_GROUP_WEAPON or COLLISION_GROUP_DEBRIS_TRIGGER)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement