The AI of the docking ship
The command "requestDockingCoordinates" looks for the nearest station and guides the ship to its docking port.
If no station in the system exist it returns: NO_STATION_FOUND
The command "recallDockingInstructions" uses the previously found station and retransmit the last instructions.
Both commands are alike but the first time requestDockingCoordinates must be used.
If an other ship is in launching status it returns: TRY_AGAIN_LATER
If the ship is moving to fast or is turning to fast with a non-rotating station it returns: HOLD_POSITION
If the ship is already to close to give accurate coordinates (<1000 meter) it returns: BACK_OFF
If the ship is still to far away to give accurate coordinates (>12500 meter) it returns: APPROACH
If none of the above is valid and the ship has not moved much, approach coordinates in front of the dockingport are calculated and it returns: APPROACH_COORDINATES
The actual value of the coordinates depends on the distance to the dockingport.
By issuing a "requestDockingCoordinates" the ship is added on the waitinglist for being handled by the station. If the ship for some reason aborts the docking it must issue a "abortDocking" command. This removes the ship from the waiting list. If it is not done the carrier could wait indefinitely for the last ship.
The same is true when a ship is killed in the docking procedure. e.g. by smashing into the carrier. The ship stays on the dockinglist and the carrier stays put. This can be prevented by putting a "abortDocking" command into the death_actions of the ships that are on the carrier. This way it is always sure he is removed from the list. And if he was not on a list the command does nothing.
The AI of the station or carrier
Whenever a carrier receives a "requestDockingCoordinates" from a ship it goes for a standstill. This could take some time as carriers are usually heavy. In the meantime it issues a "DOCKING_REQUESTED" to his own AI. That should react to jump to a new state were the docking is handled. When the ship came to a standstill it can calculate docking coordinates and thus from this point on is starts sending coordinates tho the waiting ships. From here on it just works as a station.
In this new state it should wait for the next two events: "DOCKING_COMPLETE" or "DOCKING_ABORTED". This event only happens when the last ship that is on the dockinglist has docked or has aborted.
But the carrier needs not waiting till docking is ready. It can break of waiting by just giving a new moving command.
Return to OXP howto AI