How to make explosions not damage people thru walls

I have a custom weapon that shoot globs of acid that explode when the contact the wall. The damage is applied to everything within a sphere (ents.FindInSphere()). How would I make it so that it doesn’t damage any entities through walls? Should I simply use traces to check if there’s a wall between the collision point and the entity? Or is there a built in function for this (which I highly doubt)?

You guys are an enormous help and are very patient with the hundreds of questions I have every time I try to do something with my gamemode. I’m considering adding facepunch as a co-developer for the gamemode, you’re that useful.

First you should not use ents.FindInSphere for collision detection since it will only check if the collision is near the feet of the players, not if it is touching them.

Now I have not done this myself but I think you could use the env_physexplosion entity for this purpose. According to it’s documentation you can setup it’s keyvalues so that it will test for LOS before pushing players away. This is a little bit hacky but it is the only LOS explosion function I know to be included in the game. To retrieve the players hit by the explosion you can use the entity’s output or if you might want to try and convert the physical damage/force it applies to the player to your own damage, with the right inflictor and attacker.

Or another way would be to do traces like you said.

You can read the source to env_physexplosion’s simple LOS test here :
http://www.koders.com/cpp/fid1C213FE061B9808CBF2951E58A13502B5287F2C7.aspx?s=env_physexplosion#L873