exitSystem(targetSystem)
has an unexpected glitch if used with parameter.With no parameter used, if there is insufficient fuel to jump, the AI message WITCHSPACE_UNAVAILABLE is sent to the ship.
But if the parameter is used, and the target system is not the closest system, WITCHSPACE_UNAVAILABLE is only sent if there is not enough fuel to reach the closest system, regardless how far the target system is.
Example: my test NPC had a system 6.8 LY away as its target. The closest system was 1.2 LY away, but the target was explicitly defined. Here's what happens with different fuel levels:
6.6 LY of fuel:
exitSystem(targetSystem)
returns false
, but no AI message is received at all. No AI activity is logged, either.1.2 LY of fuel:
exitSystem(targetSystem)
returns false
, but no AI message is received at all. No AI activity is logged, either.0 LY of fuel:
exitSystem(targetSystem)
returns false
, AI message WITCHSPACE_UNAVAILABLE is received and logged.1.1 LY of fuel:
exitSystem(targetSystem)
returns false
, AI message WITCHSPACE_UNAVAILABLE is received and logged.When performing a hyperSpaceExit, the code should take the distance to the targetSystem into consideration, sending WITCHSPACE_UNAVAILABLE to the AI if there is not enough fuel to reach the target system, not only if there is not enough fuel to reach any system.
My current workaround is
Code: Select all
if(this.ship.exitSystem(targetSystem) == false) this.ship.reactToAIMessage("WITCHSPACE_UNAVAILABLE");
Half-related question: does
exitSystem(targetSystem)
mimic the behaviour of performHyperSpaceExit
or performHyperSpaceExitWithoutReplacing
?