ship.exitSystem(targetSystem) and WITCHSPACE_UNAVAILABLE

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

Moderators: winston, another_commander, Getafix

Post Reply
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:

ship.exitSystem(targetSystem) and WITCHSPACE_UNAVAILABLE

Post by Commander McLane »

The JS method 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?
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: ship.exitSystem(targetSystem) and WITCHSPACE_UNAVAILABLE

Post by JensAyton »

Commander McLane wrote:
Half-related question: does exitSystem(targetSystem) mimic the behaviour of performHyperSpaceExit or performHyperSpaceExitWithoutReplacing?
performHyperSpaceExitWithoutReplacing.
Post Reply