I wouldn't work with conditions at all in an AI. I'm not even sure it's possible. At least AFAIK there is no AI like this out there.
I think this may be a case of "nonconformist newcomer prooves that the Earth is round"... Is it really impossible to use conditions in the AI.plist or simply never tried before, thus believed to be impossible?I seem to recall scripting in an AI...or rather a shipdata.plist's *_actions section, it involves calling the method 'performScriptAction' <array> IIRC.
However generally using script in the AI is not recomended as this only updates every 'somany' seconds.
Maybe because of old habits, programming without conditions feels akward... especially in an AI...
EDIT:scanForNearestShipWithRole: won't do as the point is to identify who's shooting and send the proper reply. It would be all right for the most part, but when it returns the final scan returns "NOTHING_FOUND", it would simply take no action against a non slaver/pirate/police hostile.What you want to do can be achieved much easier with the usual set of AI methods. You just have to define three states instead of your single state and roll between them.
So: first state "IDENTIFY_SLAVER" has "scanForNearestShipWithRole: slaver" in the ENTER-part. Then it needs a "TARGET_FOUND" with whatever you want to do to that target, e.g. setTargetToFoundTarget, "commsMessage: ...". Then it needs a "NOTHING_FOUND", which serves as the else-part of your condition and contains a "setStateTo: IDENTIFY_POLICE".
So far I've C&Pd the shipdata and characters form renegades.oxp, written the descriptions and am currently tinkering with the AI.
My idea is this:
Create 1~3 slavers in the system (script, I know)
Seek and destroy the slavers, and engage any pirates found along the way while looking for slavers.
When fighting a slaver, comm any attackers without changing target. If no slaver is around, dish out the usual way. With the method suggested by CmL, i'd have to prioritize the targets and engage them in order (1-slavers, 2-pirates, 3-other attackers and 4-police), which may not be a bad idea.
Have different messages for each of the four types of attacker
When out of slavers, sunskim keeping the same Rules of Engagement and exit.
Now for the real fun part on the script:
As a death action, eject a pod and a crate of computers.
If the crate is captured or destroyed, funny things would happen when the player docked (I'll PM LB, AH and CmL in due time for advice as I really don't want to
The pod being destroyed, captured or left alone would alter the funny things to different outcomes.
As for the Spartacus Brotherhood, I won't even think about that for now...