I could not search because I didn't know what to look for.
Search for "event handler".
An eventhandler basically executes a bit of code or a script, whenever the event happens. So if you attach a fired EH to a unit, it will execute some code whenever that unit fires.
However, a simpler way to do it would involve a "detected" trigger. A little knows secret is that those triggers will go off when enough shots (that are loud enough) are fired by someone on the side to be detected. I believe it takes like 3 shots from an m16 to make it go off.