Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

station scripts / DOCKING_REQUESTED

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

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:

station scripts / DOCKING_REQUESTED

Post by Commander McLane »

Stations get the AI message "DOCKING_REQUESTED" when an NPC (or the player, I believe) requests to dock. There seems to be no corresponding JS event, however. At least there is none documented.

How can I in the station's ship script establish the ship which has sent the DOCKING_REQUESTED? Is there a workaround for this? Or can we get a new event handler for stations which fires parallel to DOCKING_REQUESTED and returns the ship that made the request?
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: station scripts / DOCKING_REQUESTED

Post by cim »

Commander McLane wrote:
Stations get the AI message "DOCKING_REQUESTED" when an NPC (or the player, I believe) requests to dock. There seems to be no corresponding JS event, however. At least there is none documented.

How can I in the station's ship script establish the ship which has sent the DOCKING_REQUESTED? Is there a workaround for this? Or can we get a new event handler for stations which fires parallel to DOCKING_REQUESTED and returns the ship that made the request?
Workaround: search for ships in scanner range with dockingAI.plist as their AI. Not going to work particularly well if the station isn't the only nearby one. Also if there's more than one it doesn't tell you anything about their order in the docking queue unless you keep an internal list.

Workaround: give the ships a customised docking AI that sends a comms message to the station when they request docking clearance. Then use the commsMessageReceived event on the station.
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:

Re: station scripts / DOCKING_REQUESTED

Post by Commander McLane »

cim wrote:
Workaround: search for ships in scanner range with dockingAI.plist as their AI. Not going to work particularly well if the station isn't the only nearby one. Also if there's more than one it doesn't tell you anything about their order in the docking queue unless you keep an internal list.

Workaround: give the ships a customised docking AI that sends a comms message to the station when they request docking clearance. Then use the commsMessageReceived event on the station.
I should add: I also want to catch the player ship (it's actually what I'm specifically after). Therefore entity filtering based on their current AI won't work.

And yes, there may well be other stations nearby, and I want to filter out only the ships who are requesting to dock with my station (although I could do that based on what they're targeting).

EDIT: Oh, I just discovered that I can cover the player as well, because the player ship now has oolite-player-AI as its default AI, which switches to dockingAI when not insta-docking. :D This must be a relatively recent change which escaped my attention. Previously the player ship had always dockingAI during flight, which would've made the detection based on AI impossible. Okay, so I'll give it a go.
User avatar
Micha
Commodore
Commodore
Posts: 815
Joined: Tue Sep 02, 2008 2:01 pm
Location: London, UK
Contact:

Re: station scripts / DOCKING_REQUESTED

Post by Micha »

cim wrote:
Also if there's more than one it doesn't tell you anything about their order in the docking queue unless you keep an internal list.
In the current implementation there is no such thing as a docking queue. It's more a docking scrum apart from the 2-3 ships which are currently actively approaching the station dock through the docking stages.

The way it works is that ships approach the station and ask for docking instructions. The station replies with a bunch of docking stages. The ship AI then periodically checks whether the first approach stage is free. If it is, it claims it, and drives the ship towards that coordinate, otherwise it waits. From then on, the AI checks whether the next stage is free, and if it is, it releases its current stage, claims the next, and drives towards it until docked.
(There's a little additional complexity to fit the player in with Docking Clearance.)

Hence there's absolutely no correlation between the order in which ships first approach a station and request docking instructions, and the order in which they actually dock.
The glass is twice as big as it needs to be.
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:

Re: station scripts / DOCKING_REQUESTED

Post by Commander McLane »

The hard part is still to catch the player trying to sneak in without hitting 'C'. In that case there is neither an AI message for the station nor could there be a JS-event (except after the docking was successful, but that would be too late for me).

I can just count on the fact that the station entity is going to evade the player if he doesn't announce his wish to dock.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: station scripts / DOCKING_REQUESTED

Post by Eric Walch »

Micha wrote:
(There's a little additional complexity to fit the player in with Docking Clearance.)
And I think it needs even more complexity. Currently you can set that a ship needs clearance before getting in, but clearance is only based on the presence of a docking queue. For some stations you want never any clearance for strange ships (like the player).
So maybe we need a new mechanism that can block certain ships on request. Or just a station property that refuses all ships unless they are in the same group as the station. (Or have the station as leader.)
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: station scripts / DOCKING_REQUESTED

Post by cim »

Commander McLane wrote:
I can just count on the fact that the station entity is going to evade the player if he doesn't announce his wish to dock.
Well, not if the player sneaks in between two legitimate dockings. (Unless all the legitimate ships have a heavily customised dockingAI that lets them dock while the station is evading all over the place, which probably isn't impossible with frame callbacks)
User avatar
Micha
Commodore
Commodore
Posts: 815
Joined: Tue Sep 02, 2008 2:01 pm
Location: London, UK
Contact:

Re: station scripts / DOCKING_REQUESTED

Post by Micha »

Eric Walch wrote:
So maybe we need a new mechanism that can block certain ships on request. Or just a station property that refuses all ships unless they are in the same group as the station. (Or have the station as leader.)
So how would you like that to work in-game? Blast-doors (or shields) in front of the docking port, which get lowered on request?
The glass is twice as big as it needs to be.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: station scripts / DOCKING_REQUESTED

Post by Eric Walch »

Micha wrote:
So how would you like that to work in-game? Blast-doors (or shields) in front of the docking port, which get lowered on request?
A) One option would be to deny docking clearance for the ship even when there is no queue. That will only stop ships using an AI to enter the dock or a player with docking computers. When manually docking you dock, but get fined as now happens without clearance.

B) Not even trigger the 'enterDock' code on top of A. When a player than docks, he will just crash into the back wall of the ship. :twisted:

A seems an addition that fits in current game experience. For B I am not sure if I would like that. Somehow still defendable as with the short docks, you might expect that there is some sort of break mechanism inside a dock that enables ships to come to come to a full stop within meters. When not set properly because no clearance was given, that would mean a normal collision on manual docking.

But as said, I would like A better.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: station scripts / DOCKING_REQUESTED

Post by JensAyton »

Eric Walch wrote:
B) Not even trigger the 'enterDock' code on top of A. When a player than docks, he will just crash into the back wall of the ship.
I tried that a while back, and I think the code’s still there, but what actually happens is that you fly through the back wall of the docking bay and out through the back of the station. The special cases for dock collision detection would need to be rewritten to handle rejected ships.
Post Reply