I made a deployable particle turret that uses sysFindObject with the criteria "st;AYN;N:75". According to the docs, this should find the closest ship or station that is active and angry at the player, within 75 light seconds. However, it appears to find objects further than 75ls away, and also ignores angry friendlies.

Here's the mod:
https://drive.google.com/open?id=1SWBf-du66x_HUOxtSnTwH6CidAzbbUgB

Reproduce by destroying Starton Eridani and then firing turrets (they're on the launcher slot). The turrets will prioritize distant Charon/Centauri pirates over the attacking guards even though the guards are much closer.

derakon 20 Mar 2018:

Oh, forgot to mention -- use the "howitzer Sapphire" ship to test.

nms 20 Mar 2018:

Maybe it doesn't work to use N and N:x; in the same string, even though they do different things? In that case you could just use N and check the distance if it returns an object. Also, you only need semicolons after multi-character criteria, though I don't think superfluous ones should stop it from working.

giantcabbage 20 Mar 2018:

(sysFindObject gPlayerShip "st;AYN;N:75") does work and returns the closest ship/station within 75 ls hostile to the player (or "stAYNN:75;" with the semicolon in the usual place).

The problem in your example is likely that you are not searching for objects near or angry with the player, but with gSource.

If you want objects which are close to the turret, but angry with the player you will need a much more complex expression.
i.e. first find active objects which are close to the turret, then filter the ones angry with the player, then find the nearest.