util.Effect - Explosion.

I seem to be having some problems with an entity which doesn’t “always” explode. It sometimes explodes, and sometimes it doesn’t.

And I have a hard head into understanding why, I’ve already tried removing the “AlreadyBlewUp” but that isn’t the fix either.

local DefaultHealth = 99.2
local ExplosionRadius = 512
local ExplosionDamage = 100



if victim.DefaultHealth <= 0 and not victim.AlreadyBlewUp then
victim.AlreadyBlewUp = true
local effectdata = EffectData()
effectdata:SetOrigin(victim:GetPos())
util.Effect("Explosion", effectdata, true, true)
util.BlastDamage(inflictor, attacker, victim:GetPos(), 512, 100)
victim:Remove()
end


Hooked onto
hook.Add(“EntityTakeDamage”, “EntityBlowUp”, EntityBlowUp)

The code itself isn’t really important as it works, but I don’t fully understand this util.Effect stuff.

This is what happens, you shoot the entity untill it’s health is gone, and it well explodes. But sometimes, it doesn’t explode. And sometimes it just shows the explosion effect, but doesn’t do the explosion damage.

Any ideas on this?

Well, regardless of the code looking horribly messy, I would assume that the damage comparison isn’t being read. I don’t know what would cause this however, as everything looks fine. Have you tried placing this in PlayerDeath, or OnPlayer… blah blah?

Here is the piece above.



if victim:IsVehicle() then
victim.VehicleHealth = (victim.VehicleHealth or DefaultHealth) - amount


It’s hooked onto “EntityTakeDamage”.