I have this weapon that fires projectile SENT's. It works nicely for everything, except when I shoot nearby func_breakable_surf entities. Sometimes maybe one or two shots nearby won't trigger a game crash, but eventually it happens. I haven't gotten a close enough pinpoint on it, but here's what I've done to try and prevent it:
function ENT:PhysicsCollide( data, asshole )
if IsValid(data.HitEntity) && string.EndsWith(data.HitEntity:GetClass(),"surf") then print("Hit Surf") end
function ENT:StartTouch( hit )
if IsValid(hit) && string.EndsWith(hit:GetClass(),"surf") then return end
Analysing the crash logs isn't something I know much about, so I asked someone more experienced than I to look at them.
First they believed the issue might be related to entity spam, or improper cleanup, but I've guaranteed that it's being removed properly and there have never been more than 17 active at one time.
That being dismissed, we wondered if the problem was caused by "the ent collision with the glass," so I wrote the lines of code I showcased above. The crash is still happening.
If I were to guess what's causing it, I think it's this:
local Slicer = DamageInfo()
Slicer:SetDamage(20)
Slicer:SetDamageType(bit.bor(DMG_DISSOLVE,DMG_ENERGYBEAM,DMG_RADIATION,DMG_AIRBOAT,DMG_BLAST))
Slicer:SetAttacker(self.Owner)
if self:GetVelocity():Length() > 1000 then
-- hit:TakeDamageInfo(Slicer)
util.BlastDamageInfo(Slicer,data.HitPos,80)
end
More specifically, I am blaming util.BlastDamageInfo
If it's more specific, I'm suspicious about the DMG Enumerations being used.
Well, I've verified that getting rid of util.BlastDamageInfo stops the crashes. The problem is I don't want to get rid of that!!! There has to be a better way, does anyone know?
Ok I have looked into this, if you specify a valid entity via Slicer:SetInflictor then the crash should be gone. I will make sure that this is not necessary and it won't crash in future versions of the game.
Well upon further debugging (I made a test map in Hammer that's full of these brushes) the game didn't crash. The problem showcases itself in one of the later levels of half-life 2, specifically the one right before the first citadel level.
I'll throw in some IsValid checks later. I'll also try to add some way to make sure it's only calling once per entity touched, in case the issue is overflow.
It's fixed. Thanks for the help
I was never setting inflictor, so I did that and added IsValid checks for GetInflictor and GetAttacker. I didn't do the redundancy checks I mentioned in my last post, but it's not crashing anymore so thank you!
Sorry, you need to Log In to post a reply to this thread.