dockEscorts can dock at the wrong station

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

dockEscorts can dock at the wrong station

Post by Eric Walch »

I think since 1.71 escorts don't dock okay. I often saw them heading for a far away station. I just encountered again such an escort. So I decided to follow the code a bit to see were it goes wrong. The escortAI itself does not contain code to dock. It is activated when the mother uses dockEscorts:

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;
}
Here no target station is set. That is probably the main cause of the bug. Than when the escort is in dockingAi is first does a GLOBAL:

Code: Select all

	GLOBAL =
	 {
		ENTER = ("setSpeedTo: 0.0", requestDockingCoordinates, "setStateTo: AWAIT_COORDS");
		UPDATE = ("pauseAI: 2");
	};
Here happens the real bug because requestDockingCoordinates has no target station at this point. And without a target is starts looking for a station:

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];
	}
And when looking for that function it jump to another function in witch I read:

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
and here goes it wrong in the way that it filters all the stations from the sortedEntities list. And this list is sorted to player distance and not resorted after filtering.

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!
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

That also explains part of the behaviour of the woma escorts I told you about earlier. They also could approach another station than their mother.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Commander McLane wrote:
That also explains part of the behaviour of the woma escorts I told you about earlier. They also could approach another station than their mother.
It was even this woma escort that made me think it must be a core bug. When working on the dredger script and the behemoth script I often saw other escorts docking at those ships. I always thought this was a oxp bug of sending the escorts away to soon.

When I saw a woma escort docking wrong I immediately knew those ships only escort the fuelship and no other. And the mother docks the escorts only when close to the main station.

But yesterday I noticed your woma escort heading at full speed ahead of the mother. With the target inspector I noticed its orientation never changed. It belonged to a woma ship that was spawned as trader. This could be important as with the trader version the escorts still keep waggling. I never wanted to change the ships characteristics and kept its maximum speed at 100. I only changed the fuelship AI to have a cruise speed of 95% to get rid of the escort waggling. When added as trader it still gets a traderAI. Traders have a cruise speed of 65%. Effectively this comes down to 65% of 100 = 65. At this low speed escorts start waggling.

Probably this waggling is the cause of escorts going head-on sometimes. After following the escort for some time I decided to re-find its mother. I now noticed it had just 1 escort left and had another that started to go straight-on at full speed. But all these escorts were on behaviour FLYING_ESCORT like you had.
Screet
---- E L I T E ----
---- E L I T E ----
Posts: 1883
Joined: Wed Dec 10, 2008 3:02 am
Location: Bremen, Germany

Post by Screet »

Eric Walch wrote:
When I saw a woma escort docking wrong I immediately knew those ships only escort the fuelship and no other. And the mother docks the escorts only when close to the main station.
Yesterday I made a trip to one of your buoy-factories...and guess what: Even a woma transport did dock there. A CM3 was docked already and several other ships like fer-de-lance have been sitting around the station, the space was much more busy with waiting ships than that of a systems stations.

Very beautiful sight anyway...maybe you can at some point come up with an advertisement-sheet for them, handle the commander a cup of coffee and that sheet as welcome when he docks? I guess there should be free coffee available, as they bought happily my 50+ tons of alcoholics for a price even a rock hermit would not pay ;)

I do remember that you wrote about relaxed collision checking when the player is far away, resulting in NPCs docking attempts / being docked going to explode. Maybe the relaxing should not be for easier, but for less easy detection, as the player notices the explosion, but would not notice if a ship slightly scratches the station?

Screet
Post Reply