Arrivals and departures

An area for discussing new ideas and additions to Oolite.

Moderators: another_commander, winston

User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4646
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Arrivals and departures

Post by phkb »

With escorts, there doesn't appear to be a way for me to create them manually. I can set them up, but the "escortGroup" property of a ship is read only - I assume because normally an escort group is created on the fly as defined in the shipdata.plist file. Given that what I am trying to achieve here is an approximation, would it work if I create the escort members as a normal ship group? Would they operate as escorts if I do that? Or do I need to switch their AI to something else?
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Arrivals and departures

Post by cim »

The escortGroup property is read-only - you can't change a ship's escort group to another group - but you can add ships to the existing group by using group.addShip() as usual.

In practice though it's best to use ship.offerToEscort(othership) to do this as this will make sure all the bits get set up properly and the ship doesn't exceed its escort limit.

escort_roles in shipdata can be used to make sure a ship has some blank escort slots available (and if you want to do the set up entirely manually, only has blank slots when created)
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4646
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Arrivals and departures

Post by phkb »

Thanks cim. Another issue: the ten minutes between pressing F1 and being in space. If I have 5 ships who are due to launch inside those 10 minutes I'd expect to see them in space after I launch. However, I can't just launch them all in the shipWillLaunchFromStation - they still end up launching after the player. Does this mean I have manually create them in the vicinity on the dock using system.addShips and skip the station.launchShipWithRole function?
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Arrivals and departures

Post by cim »

phkb wrote:
Does this mean I have manually create them in the vicinity on the dock using system.addShips and skip the station.launchShipWithRole function?
Yes.
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4646
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Arrivals and departures

Post by phkb »

Ah. Thought so. This rabbit hole sure is deep. :)

Edit: So, thinking of the best way to push out a bunch of launched ships. Would player.ship.vectorForward coupled with a random selection of player.ship.vectorUp/vectorDown/vectorRight do the job? Is player.ship.vectorForward accurate at the shipWillLaunchFromStation stage? Or should I get a series of vectors based on the station dock orientation?

Edit: Actually, given I'm going to need to do this on docking and launching, I'm probably going to have to use station dock orientation. I think I've worked out the dock position for this (entity.position with entity.heading).
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Arrivals and departures

Post by cim »

phkb wrote:
Edit: Actually, given I'm going to need to do this on docking and launching, I'm probably going to have to use station dock orientation. I think I've worked out the dock position for this (entity.position with entity.heading).
Remember that for subentities like docks the position and orientation are reported relative to the parent entity.

That said, you can fly quite a way in 10 minutes, so for a lot of the ships "somewhere vaguely near the station" is probably sufficient.
User avatar
Disembodied
Jedi Spam Assassin
Jedi Spam Assassin
Posts: 6881
Joined: Thu Jul 12, 2007 10:54 pm
Location: Carter's Snort

Re: Arrivals and departures

Post by Disembodied »

cim wrote:
That said, you can fly quite a way in 10 minutes, so for a lot of the ships "somewhere vaguely near the station" is probably sufficient.
Would most ships - ones with interstellar destinations, anyway - not have jumped away within (say) five minutes of exiting the station? And any planetary shuttles/transporters would at least have entered the atmosphere.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2286
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: Arrivals and departures

Post by Wildeblood »

Disembodied wrote:
Would most ships - ones with interstellar destinations, anyway - not have jumped away within (say) five minutes of exiting the station?
Threadjack: I was just thinking last night that opening wormholes anywhere near a station or planet or other ship should be too dangerous to be lawful, and I might make a little script that only allowed witchspace jumps from torus speed.
User avatar
Vincentz
Deadly
Deadly
Posts: 174
Joined: Sun Mar 22, 2015 11:26 pm

Re: Arrivals and departures

Post by Vincentz »

Wildeblood wrote:
Disembodied wrote:
Would most ships - ones with interstellar destinations, anyway - not have jumped away within (say) five minutes of exiting the station?
Threadjack: I was just thinking last night that opening wormholes anywhere near a station or planet or other ship should be too dangerous to be lawful, and I might make a little script that only allowed witchspace jumps from torus speed.
I would definitely play with that. Thought about that as well atleast 10 times during the last 24 hours ;)
Though it would be pretty difficult to use other ships wormholes (?) and how would the AI respond to it? When "mothership" makes wormhole, escorts follow, but if "mothership" cant create wormhole because of escorts too close?
"There is a single light of science, and to brighten it anywhere is to brighten it everywhere." - Isaac Asimov
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2286
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: Arrivals and departures

Post by Wildeblood »

Vincentz wrote:
Wildeblood wrote:
Threadjack: I was just thinking last night that opening wormholes anywhere near a station or planet or other ship should be too dangerous to be lawful, and I might make a little script that only allowed witchspace jumps from torus speed.
I would definitely play with that. Thought about that as well atleast 10 times during the last 24 hours ;)
Though it would be pretty difficult to use other ships wormholes (?) and how would the AI respond to it? ...
Yeah well, I was only thinking of the player ship. NPCs don't have any torus drive.

You wave the differences away by saying, "That's relativity for ya.": the subjective experience inside a moving ship will be very different to the observed phenomena from outside a ship.
User avatar
Norby
---- E L I T E ----
---- E L I T E ----
Posts: 2577
Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:

Re: Arrivals and departures

Post by Norby »

Vincentz wrote:
if "mothership" cant create wormhole because of escorts too close?
I used a trick to prevent masslock while a ship is landed on the escort deck:
ship.scanClass="CLASS_CARGO";
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4646
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Arrivals and departures

Post by phkb »

cim wrote:
Remember that for subentities like docks the position and orientation are reported relative to the parent entity.
So to get the docks actual position would that be station.position.add(dock.position)? I tried this with

Code: Select all

pos = (station.position.add(dock.position)).add(dock.heading.multiply(1000));
to try and put a ship 1000 meters along the launch path, but it seemed to create them off to one side, so I guess I'm doing something wrong here.
phkb wrote:
Another one: if I launch a ship this way, it doesn't appear to launch any escorts - it just launches the ship. Am I correct in my understanding that launching a ship using a specific ship key will only launch that ship, and no escorts?
I've been doing some testing and I'm discovering that system.addShips("[anaconda]", 1, pos, 1000); will sometimes add one ship and sometimes add multiple ships (one or more escorts). Is it possible to only create one ship, and skip the escort creation?

Edit: Actually, station.launchShipWithRole will also launch escorts, so the question applies to a broader context.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Arrivals and departures

Post by cim »

phkb wrote:
So to get the docks actual position would that be station.position.add(dock.position)
Very rarely - you need to account for the rotation of the station with respect to the universal coordinate frame.

Code: Select all

station.position.add(
  station.vectorForward.multiply(dock.position.z).add(
    station.vectorUp.multiply(dock.position.y).add(
     station.vectorRight.multiply(dock.position.x)
    )
  )
)
Similarly to get the dock's actual facing you need to quaternion multiply the dock's orientation and the station's orientation.
phkb wrote:
Is it possible to only create one ship, and skip the escort creation?
Not really, no. like_ship the thing you're trying to launch so that its escort_roles entry is just

Code: Select all

escort_roles = (
{ role = ""; min = 16; max = 16; }
)
This will give it 16 blank escort slots which you can then fill or not as you choose.
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4646
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Arrivals and departures

Post by phkb »

cim wrote:
like_ship the thing you're trying to launch
When you say that, how does that work in practice? I know I can create a shipdata.plist file and put the data in there, but I don't want to hard code anything if I don't have to. In fact, hardcoding will be the end of this concept in my view. Is it possible to create a shipdata.plist entry on the fly and launch a ship with it?

I've tried these options without success:

Code: Select all

	var p = player.ship;
	var myship = {like_ship:"anaconda", escorts:0, escort_roles:{role:"", min:16, max:16}};
	var ships = system.addShips(myship, 1, p.position.add(p.vectorForward.multiply(10000)), 100);

Code: Select all

	var p = player.ship;
	var myship = Ship.shipDataForKey("anaconda");
	myship["like_ship"] = "anaconda";
	myship["escorts"] = 0;
	myship["escore_roles"] = {role:"", min:16, max:16};
	var ships = system.addShips(myship, 1, p.position.add(p.vectorForward.multiply(10000)), 100);
In both cases, "ships" is null. I'm sorry to pester you with these requests!
User avatar
Norby
---- E L I T E ----
---- E L I T E ----
Posts: 2577
Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:

Re: Arrivals and departures

Post by Norby »

cim wrote:
you need to account for the rotation of the station with respect to the universal coordinate frame.
Yes, I had the same problem with ILS until I figured out the same solution.
phkb wrote:
Is it possible to only create one ship, and skip the escort creation?
Call remove() for each element in ship.escorts after addShips.
Post Reply