Strange crash with ammo box entity

Relevant Code:




if SERVER or CLIENT then
	local bul={}
	local randvec = Vector(0,0,0)
	bul.Tracer=3
	bul.Num=1
	bul.TracerName="Tracer"
	bul.Spread = Vector(0,0,0)
	function ENT:OnTakeDamage(dmginfo)
		local at = dmginfo:GetAttacker()

		if IsValid(at) then
			if at:GetClass() == "tfa_ammo_explosion" then 
				return
			end
		end
		
		self:TakePhysicsDamage(dmginfo)
		
		if GetConVarNumber("sv_tfa_ammo_detonation", 1) == 0 then
			return
		end
		
		rand = math.random(1 ,math.Round( math.Clamp(1/self.ExplosionChance,1,10000) ))

		if dmginfo:GetDamage() > self.DamageThreshold or rand == 1 then			
			bul.AmmoType=self.AmmoType
			bul.Damage=self.Damage
			bul.Force=math.Max(self.Damage/25,0.1)
			
			
			bul.Attacker=self
			
			if IsValid(at) then
				bul.Attacker=at
			end
			
			local upang=self:GetAngles():Up()
			bul.Dir=upang+randvec*0.75
			--PrintTable(bul)
			local numbuls = math.random( math.Round(self.AmmoCount*0.25),math.Round(self.AmmoCount*0.75))
			local i=1
			while i<=math.Clamp(numbuls,1,5) do
			
				randvec.x=math.Rand(-1,1)
				randvec.y=math.Rand(-1,1)
				randvec.z=math.Rand(-1,1)
				bul.Dir= ( upang+randvec*0.75 ):GetNormalized()
				bul.Src=self:GetPos()
				self:FireBullets(bul) 
				
				i=i+1
			end
		
			local effectdata = EffectData()
			effectdata:SetOrigin(self:GetPos())
			effectdata:SetMagnitude(1)
			effectdata:SetScale(1)
			util.Effect("cball_explode", effectdata)
			util.Effect("Explosion", effectdata)
			self:Remove()
		end	

	end
end


The game seems to crash instantly upon shooting this thing with anything past the damage threshold.

You’re calling self:TakePhysicsDamage inside the ENT:OnTakeDamage hook, creating an infinite loop.

Oh my god, I’m retarded. Thanks.

[editline]14th March 2015[/editline]

Still have the issue after removing the statement.