Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local emitter = ParticleEmitter(vector_origin)
- local spews = {}
- function SpewBloodWorld(pos, force, time)
- time = time and CurTime() + time or CurTime() + 1 + math.random()
- table.insert(spews, {pos = pos, force = force, time = time})
- end
- function SpewBloodEntity(ent, pos, force, time)
- time = time and CurTime() + time or CurTime() + 1 + math.random()
- local len = (force*1):Length()
- local pos, ang = WorldToLocal(pos, force:Angle(), ent:EyePos(), ent:EyeAngles())
- table.insert(spews, {ent = ent, lpos = pos, lang = ang, time = time, force = len})
- end
- local function OnCollide(p, pos, normal)
- util.Decal(math.random() > 0.99 and "blood" or "Impact.Flesh", pos, pos - normal * 5)
- p:SetEndLength(1)
- p:SetVelocity(p:GetVelocity() * VectorRand() * 1.1)
- if math.random() > 0.96 then
- WorldSound("physics/flesh/flesh_squishy_impact_hard"..math.random(4)..".wav", p:GetPos(), 50, math.random(200,255))
- end
- end
- local function SpewThink()
- for id, data in pairs(spews) do
- if data.ent then
- if data.ent:IsValid() then
- local pos, ang = LocalToWorld(data.ent:EyePos(), data.ent:EyeAngles(), data.lpos, data.lang)
- data.pos = pos
- data.force = ang:Forward() * data.len
- print(pos:Distance(data.ent:EyePos()), data.force)
- else
- table.remove(spews, id)
- end
- end
- for i=1, math.random(3) do
- local p = emitter:Add("decals/blood" .. math.random(8), data.pos)
- if p then
- p:SetStartSize(1)
- p:SetEndSize(1)
- p:SetStartLength(0)
- p:SetEndLength(10)
- p:SetRollDelta(10)
- --p:SetColor(255, 0, 0, 255)
- p:SetVelocity(data.force + VectorRand() * 10)
- p:SetLifeTime(1)
- p:SetDieTime(1+(math.random()*3))
- p:SetGravity(physenv.GetGravity())
- p:SetBounce(0.5)
- p:SetCollide(true)
- p:SetCollideCallback(OnCollide)
- end
- if data.time < CurTime() then
- table.remove(spews, id)
- end
- end
- end
- end
- hook.Add("Think","blood_spew",SpewThink)
- SpewBloodEntity(me, me:EyePos() + me:GetAimVector() * 20, VectorRand()*100, 10)
Advertisement
Add Comment
Please, Sign In to add comment