OK, did a quick test. All fleet behaviors were turned OFF- no active Assignments. This worked:
Spoiler
package data.scripts;
import java.util.List;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.EveryFrameScript;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import java.util.Collections;
import org.lazywizard.lazylib.CollectionUtils;
import org.lazywizard.lazylib.MathUtils;
import org.lazywizard.lazylib.campaign.FleetUtils;
@SuppressWarnings("unchecked")
public class FleetAIScript implements EveryFrameScript {
//EveryFrameScripts must implement these
@Override
public boolean isDone()
{
return false;
}
@Override
public boolean runWhilePaused()
{
return false;
}
@Override
public void advance(float amount)
{
List<CampaignFleetAPI> fleets = Global.getSector().getCurrentLocation().getFleets();
for(CampaignFleetAPI fleet : fleets){
if(fleet.getName().toLowerCase().contains("raiding party")){
List<CampaignFleetAPI> enemyFleets = FleetUtils.getEnemyFleetsInSystem(fleet);
for(CampaignFleetAPI enemyFleet : enemyFleets){
if(MathUtils.getDistance(fleet,enemyFleet) < 1000f){
if(enemyFleet.getName().toLowerCase().contains("raiding party")
|| enemyFleet.getName().toLowerCase().contains("system police")
|| (enemyFleet.isPlayerFleet() && Global.getSector().getPlayerFleet().getCommanderStats().getLevel() < 10)){
fleet.setMoveDestinationOverride(enemyFleet.getLocation().x,enemyFleet.getLocation().y);
fleet.setInteractionTarget(enemyFleet);
}
}
}
}
}
}
}
Fleets with this code will now attack suicidally (which is a good thing, as they were previously rather gun-shy, to the point of not acting like raiders or being at all scary to players) if they're closer than X.
I haven't tested whether this will override normal behavior properly or not; if yes... tbh, I'm kind of tempted to write a complete Fleet AI (why not, lol), except that then the game's doing double work, since we can't do that via a Plugin
I'm kind of scratching my head about why that previous stuff didn't work right. It looks like some of the issue was the sorting code; I probably need to do some work to ensure good behaviors. Now I'll test with the core behaviors enabled again and see if it's still kosher; if yes, then I need to think about whether I want to write up a complete Fleet AI system or not.
Now that I have some ideas about why I'm seeing certain behaviors, it's tempting to just replace it with a fiat AI that does exactly what I want.