Page 3 of 11

Re: Arrivals and departures

Posted: Sat Apr 04, 2015 5:33 am
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?

Re: Arrivals and departures

Posted: Sat Apr 04, 2015 6:40 am
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)

Re: Arrivals and departures

Posted: Sun Apr 05, 2015 6:41 am
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?

Re: Arrivals and departures

Posted: Sun Apr 05, 2015 8:17 am
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.

Re: Arrivals and departures

Posted: Mon Apr 06, 2015 1:40 am
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).

Re: Arrivals and departures

Posted: Mon Apr 06, 2015 9:03 am
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.

Re: Arrivals and departures

Posted: Mon Apr 06, 2015 9:10 am
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.

Re: Arrivals and departures

Posted: Mon Apr 06, 2015 9:24 am
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.

Re: Arrivals and departures

Posted: Mon Apr 06, 2015 11:51 am
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?

Re: Arrivals and departures

Posted: Mon Apr 06, 2015 12:04 pm
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.

Re: Arrivals and departures

Posted: Mon Apr 06, 2015 4:44 pm
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";

Re: Arrivals and departures

Posted: Tue Apr 07, 2015 1:41 am
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.

Re: Arrivals and departures

Posted: Tue Apr 07, 2015 5:56 am
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.

Re: Arrivals and departures

Posted: Tue Apr 07, 2015 7:04 am
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!

Re: Arrivals and departures

Posted: Tue Apr 07, 2015 10:34 am
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.