Turns out that whenever a ship spawns it fires SIGNAL_CHANGESECTOR. This alone isn't enough, because, of course, the ship could just be changing sector, so you have to check "get flight time" is 0. However, again this isn't enough, since when a ship undocks it fires SIGNAL_CHANGESECTOR and its flight time is 0. But if a ship is undocking "get current action" returns ACTION_START_IN_STATION, whereas when spawning it returns ACTION_NONE.
So in summary, we can check for ship spawning the instant it spawns by:
- Attaching a secondary signal to SIGNAL_CHANGESECTOR.
- In the signal script check "get flight time" is 0.
- and also check "get current action" is ACTION_NONE.
I haven't done extensive testing (just SETA for 5 mins or so) to see if these three conditions can occur when a ship does anything else other than spawning. Does anyone know of any other conditions, or is this finally a nice clean way to stop ships spawning in captured sectors (either by destroying instantly or moving instantly to a better sector)?