Code: Select all
- (void) dockEscorts
{
if (escortCount < 1)
return;
// deletions:
if (escorter_okay)
{
float delay = i * 3.0 + 1.5; // send them off at three second intervals
AI *ai = [escorter getAI];
[escorter setGroupID:NO_TARGET]; // act individually now!
[ai setStateMachine:@"dockingAI.plist" afterDelay:delay];
[ai setState:@"ABORT" afterDelay:delay + 0.25];
[escorter doScriptEvent:@"escortDock" withArgument:[NSNumber numberWithFloat:delay]];
}
escort_ids[i] = NO_TARGET;
}
escortCount = 0;
}
Code: Select all
GLOBAL =
{
ENTER = ("setSpeedTo: 0.0", requestDockingCoordinates, "setStateTo: AWAIT_COORDS");
UPDATE = ("pauseAI: 2");
};
Code: Select all
{
allStations = [UNIVERSE findShipsMatchingPredicate:IsStationPredicate
parameter:nil
inRange:SCANNER_MAX_RANGE2 * 1000000.0 // 1000x scanner range (25600 km), squared.
ofEntity:self];
if ([allStations count] != 0) station = [allStations objectAtIndex:0];
}
Code: Select all
// NOTE: OOJSSystem relies on this returning entities in distance-from-player order.
// This can be easily changed by removing the [reference isPlayer] conditions in FindJSVisibleEntities().
- (NSMutableArray *) findEntitiesMatchingPredicate:(EntityFilterPredicate)predicate
parameter:(void *)parameter
inRange:(double)range
ofEntity:(Entity *)e1
This also explains why I saw in the past a buoy repair ship that just had dropped the N-buoy going to the grs station instead of the mainstation it was much closer by: I myself was at that point closer to the GRS station.
Best fix would be in requestDockingCoordinates to sort the allStations list there and not just pick the first from the list. The first is not closest to the ship but to the player!