Garry's Mod

Garry's Mod

[ARC9] PolyArms Project
grenade fragmentation
-- Simulate grenade shrapnel using trace lines with custom damage and effects timer.Simple(0.1, function() if not IsValid(self) then return end local num_shrapnel = math.random(50, 120) for i = 1, num_shrapnel do local dir = VectorRand():GetNormalized() local src = self:GetPos() + Vector(0, 0, 5) -- raise slightly to avoid ground hits local tr = util.TraceLine({ start = src, endpos = src + dir * 3072, filter = {self} }) if IsValid(tr.Entity) and tr.Entity.TakeDamage then local dmg = DamageInfo() dmg:SetDamage(math.random(10, 65)) dmg:SetAttacker(IsValid(self:GetOwner()) and self:GetOwner() or self) dmg:SetInflictor(self) dmg:SetDamageType(DMG_SLASH) tr.Entity:TakeDamageInfo(dmg) end if tr.Hit then local ed = EffectData() ed:SetOrigin(tr.HitPos) ed:SetNormal(tr.HitNormal) util.Effect("cball_bounce", ed) end end end)
Last edited by Dahaka; 23 May @ 8:02pm
< >
Showing 1-1 of 1 comments
Darsu  [developer] 23 May @ 10:57pm 
This just adds unnecessary randomization to damage
< >
Showing 1-1 of 1 comments
Per page: 1530 50