Everything you need for mining is all in a delicious little package called vfleet_MiningEvents. In fact, you SHOULD be able to take most of the code without having to change much.
How it works, is it checks every fleet if it has mining power. If it does, it is automatically a miner. You may or may not like this. Most of the action happens in the "public void advance(SectorAPI sector, LocationAPI location)" method.
Here is where you determine whether or not to chase an asteroid:
//Check Ore count
float oreCount = 0;
float oreSize = 5;
while(fleetCargo.removeItems(CargoAPI.CargoItemType.RESOURCES, "vfleet_ore", 1)) {
oreCount = oreCount + 1;
}
fleetCargo.addItems(CargoAPI.CargoItemType.RESOURCES, "vfleet_ore", oreCount);
if (oreCount * oreSize > cargoCapacity) {
//Find location to dump stuff
FactionAPI fleetFaction = fleet.getFaction();
String fleetFactionID = fleetFaction.getId();
SectorEntityToken returnLocation = system.getEntityByName("Fleet Storage");
if (fleetFactionID.equals("hegemony")) {
returnLocation = system.getEntityByName("Orbital Station");
}
if (fleetFactionID.equals("tritachyon")) {
returnLocation = system.getEntityByName("Corporate HQ");
}
if (fleetFactionID.equals("independant")) {
returnLocation = system.getEntityByName("Orbital Station");
}
Script script = minerArrived1();
[b]fleet.clearAssignments();
fleet.addAssignment(FleetAssignment.GO_TO_LOCATION, returnLocation, 1000, script); //Tell it to go to go home.[/b]
}
else {
[b]fleet.clearAssignments();
fleet.addAssignment(FleetAssignment.GO_TO_LOCATION, targetAsteroid, 1); //Tell it to go to the asteroid.[/b]
}
I don't know if the fleet.clearAssignments(); is needed, but I added it to be safe. This way, every frame it's told to go to the asteroid.
HOWEVER, the miners STILL think they're pirate hunters. If you want to put an end to that, you probably saw Alex's OTHER solution:
Heck, you could actually set up a (really, really hacky) custom AI for the fleet if you wanted. CampaignFleetAPI.setLocation() lets you put a fleet anywhere you want, so you could simulate movement that way. You'd be fighting against their AI, though, so I don't know how well that would work in practice, and whether I should even bring it up
But my patience is extremely limited. I threatened my computer's life far too many times just trying to make that mod work. If anyone can do this though, I'm sure LazyWizard could :p.
Oh, I do have a request... While your looking through the files, do forgive my messes. I tend to mangle EVERYTHING in my vigorous attempts to get from point A to point bloody B.