playerJumpFailed mostly useless

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:

playerJumpFailed mostly useless

Post by Commander McLane »

I noticed that the playerJumpFailed event handler in its current form is mostly useless.

It may return three reasons for why a jump failed: 'blocked', 'insufficient fuel', or 'too far'. Problem is, that in the two latter cases (if your fuel isn't enough, or you have targeted a system too far away) the countdown doesn't even start. The engine handles you a message right away, and that's it. Not even 'playerStartedJumpCountdown' is fired, much less happens anything at the end of the countdown.

You will only get the 'insufficient fuel' if you had enough fuel when you hit 'H', but lost it during the countdown. And you'll never get a 'too far', because there is no way to even start a countdown in that case.

The bottom line is that because of this behaviour there is no way to check via script if the player has insufficient fuel, or targeted the wrong system. Which means there is no way a script could detect whether the player is stuck in interstellar space.

A solution for this would be to start the countdown anyway, and only have the code check for insufficient fuel or illegal distance at its end. (This is how the AI handling of NPC jumps works.) Or to let the handler fire already when 'H' is pressed. Or to introduce another method of checking whether the player can reach another system.

The 'big solution' would be to make the whole jump-business accessible to JS. Like a system-property that contains all systems in jumprange, depending on the player's current fuel, perhaps in an array. So if(system.systemsInRange.length == 0), we know that the player is stuck. (Of course it would have to work in interstellar space as well.) The engine already does the calculation when 'H' is pressed, or when an NPC performs performHyperSpaceExit, I only don't know how difficult it is to make it available to JS.
Post Reply