Diziet Sma wrote:If I understand you correctly, they will fly the full distance before attempting to hyperspace?
No, they don't, and they never have.
Diziet Sma wrote:A better solution (if it can be done) would be for the trader to check to see if it is masslocked. If so, it could then continue to move away, checking at intervals to see if it can jump yet.
Or am I misunderstanding, and they will jump the moment they are able to do so?
Yes, exactly. Like they always have.
The explanation is in the AI-code I posted: When in state "EXIT_SYSTEM", the AI tries to execute the "UPDATE" part on every update. As there is no update interval specified via "pauseAI: n.n", the default interval is used, which is the smallest interval possible: 0.125 seconds. In other words: the AI tries to jump out
eight times a second. (That's why you see the counter in the AI-inspector only oscillate between 0.0 and 0.1.) (And BTW: This is how AIs with an "UPDATE" message always work, which is why it is highly advisable to
always set an update interval, except in those few cases where you
really want the AI to check for something
permanently. In all other cases it only leads to an unnecessary slowdown of the game, especially if there are
many ships continuously performing AI updates.)
If it is still masslocked, it will receive the "WITCHSPACE BLOCKED" message, and execute the code therein. In other words: it will try to get further away from the blocking structure.
The only change I made is that until now the AI only tries to get at most 10000 meters away. That's too little for big stations. If it has reached this distance, it actually turns around and flies back, in order to maintain the distance. That way it ends up in an orbit, de-facto oscillating between 8000 and 12000 meters. It's a real orbit, because only the pitch is changed in order to maintain the pre-set distance. It doesn't roll away from its current course.
But the very moment the "performHyperspaceExit"-method doesn't produce a "WITCHSPACE BLOCKED"-response, the method is performed. Which means at most 1/8 of a second after the safe distance is reached.
So the only change I made is to make sure that the ship is able to reach the safe distance in the first place.
Or, in yet other words: The beauty of the solution is that it doesn't change a thing for smaller stations.