I'd recommend in general if you want a modified bounty hunter AI using route1patrolAI or route2patrolAI as your basis, rather than pirateAI. The pirate AI has a lot of complication that a bounty hunter probably doesn't need. The patrol AIs will collect loot, too: the major differences between patrol and pirate AI (beyond what they shoot at and how they work in groups) are:
- pirates will stop looting and look for a station when their hold gets full, while patrols will just treat the full hold as a bonus and keep looking for things to shoot. If you'd rather they quit when they had enough loot, the easiest way is to make "HOLD_FULL" trigger an AI switch to
route1traderAI.plist
- patrols will move up and down the witchpoint-planet (route1patrol) or sun-planet (route2patrol) lane to search for hostiles. Pirates wait for their targets to come to them.
Code: Select all
scanForOffenders, "scanForShipWithPrimaryRole: PIRATE"
This bit will probably not do what you hope (even if as Smivs suggests you move it to DESIRED_RANGE_ACHIEVED)
It will first scan for offenders using the traditional bounty hunter algorithm. This will send a non-urgent message of either "TARGET_FOUND" or "NOTHING_FOUND" to the AI, which it will pick up on its next update. If it sends "TARGET_FOUND" then it will place the details of that target into the "found target".
It will then scan for ships with role "PIRATE" (the roles are case-sensitive, so this should be "pirate" unless you're using a custom "PIRATE" role elsewhere). If it finds any, it will do the same with sending "TARGET_FOUND" or "NOTHING_FOUND".
There are then four possibilities:
-
both return TARGET_FOUND. In this case, it will go after the "pirate", not the offender, as that will be in the "found target" slot.
-
both return NOTHING_FOUND. In this case, whatever that event does will happen. (You don't have anything set for this, yet, so what will happen is the ship will float in space doing nothing until someone finally shoots at it. Possibly you want it to wait ten seconds, or whatever, and then try the scan again.
-
offender returns NOTHING_FOUND, "pirate" returns TARGET_FOUND. I'm not completely sure what will happen in this case. It might go after the pirate, or it might decide to do "NOTHING_FOUND" instead. Exactly what happens probably depends on what you put as the "NOTHING_FOUND" action.
-
offender returns TARGET_FOUND, "pirate" returns NOTHING_FOUND. The ship will go to attack state, but the failed search for a pirate will have cleared the "found target" slot. It will go into "ATTACK_SHIP" state, but then very soon after receive a "TARGET_LOST" message, and see if there's any loot to be had.
If you do want to scan for both offenders and pirates generally, then you'll need to scan for one, wait for the response, and then if the response is NOTHING_FOUND, scan for the other. You will generally need two AI separate states to do this, and it will rapidly get very complicated.
(On the other hand, all ships added with role "pirate" have a bounty, so you can probably get away with just having the scan for offenders)