I think I asked this before, but never got a response (unless I did, in which case, I'm dumb).
Can anyone help me figure out this really weird fleet behavior? I use the following code:
else { //no battle? fine, i'll MAKE MY OWN
satelliteFleet.clearAssignments(); // just in case the hold assignment all satellite fleets get is *** with a few things
satelliteFleet.addAssignmentAtStart(FleetAssignment.INTERCEPT, fleet, 999999999, null); // again, sanity
fleet.addAssignmentAtStart(FleetAssignment.INTERCEPT, satelliteFleet, 1, null);
BattleAPI newBattle = Global.getFactory().createBattle(satelliteFleet, fleet); // force the satellite to engage the enemy
// removing the createBattle doesnt fix the god damn issue where fleets drift
battleJoined = newBattle;
}
to spawn a satellite fleet on top of a fleet and engage them in combat if they were not already engaged in battle. The code for spawning a satellite fleet is:
public CampaignFleetAPI spawnSatelliteFleet(@NotNull Vector2f coordinates, @NotNull LocationAPI location, boolean temporary, boolean dummy) {
CampaignFleetAPI satelliteFleet = createSatelliteFleetTemplate();
location.addEntity(satelliteFleet);
satelliteFleet.setLocation(coordinates.x, coordinates.y);
if (temporary) {
niko_MPC_temporarySatelliteFleetDespawner script = new niko_MPC_temporarySatelliteFleetDespawner(satelliteFleet, this);
satelliteFleet.addScript(script);
satelliteFleet.getMemoryWithoutUpdate().set(niko_MPC_ids.temporaryFleetDespawnerId, script);
}
satelliteFleet.addAssignment(FleetAssignment.HOLD, location.createToken(coordinates), 99999999f);
if (dummy) {
newDummySatellite(satelliteFleet);
}
else {
newSatellite(satelliteFleet);
}
return satelliteFleet;
}
, and
public CampaignFleetAPI createSatelliteFleetTemplate() {
CampaignFleetAPI fleet = Global.getFactory().createEmptyFleet(getCurrentSatelliteFactionId(), getSatelliteFleetName(), true);
// fleet.setFaction(getCurrentSatelliteFactionId());
setTemplateMemoryKeys(fleet);
fleet.setAI(new niko_MPC_satelliteFleetAI((CampaignFleet) fleet));
fleet.addEventListener(new niko_MPC_satelliteFleetDespawnListener());
PersonAPI aiCaptain = new AICoreOfficerPluginImpl().createPerson(Commodities.GAMMA_CORE, "derelict", null);
fleet.setCommander(aiCaptain);
return fleet;
}
. The fleet AI is nothing special, it only overrides wantsToJoin and pickEncounterOption.
This is only called when a fleet reaches their interaction target, through the reportFleetReachedEntity listener. This works perfectly except for the fact that fleets act REALLY weird when you I do this. In this case, the fleet we spawn on seems to maintain their velocity and not do the "normal" thing of stop and fight the enemy. This still happens if I give the satellite fleet a intercept order and not create a new battle (relying on the satellitefleet's AI to attack the fleet). Other fleets that attack the fleets behave normally.
If I force the satellitefleet into an orbit around the planet, the fleet will actually kind of /loop around/ (as if "orbitting" in a very loose fashion) the satellite fleet, but it still won't have the expected behavior of stopping. In this scenario, any external fleet coming in to fight will also do this weird "loop" instead of stopping and fighting.
In case you wonder what I mean by "expected behavior of stopping", I mean I've always seen fleets fighting eachother kinda bump into eachother before backing off just enough to get their fleet circle borders touching and then stopping.
A video illustrating what I mean:
https://cdn.discordapp.com/attachments/824910699415207937/1025820788667985991/Jdk7_2022.10.01_-_13.24.53.02.mp4Ideally, I'd be able to keep using the createBattle method, as I store the battle in a global list for future reference.