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

Arrivals and departures

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

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:
A technical question: I've noticed that some ships, when they are spawned, get a group or escort group assigned to them, even though they are single ships. What's happening behind the scenes in those cases?
I missed this one earlier. Most ships will probably get a group containing just themselves when they're created, to make operations on groups easier to write. Similarly they'll get an escort group containing themselves and their no escorts, to make it possible to attach escorts to them later.

On the lone escort question, the current system populator never creates lone escorts - they have to be survivors of a battle, or left near the station when the mothership docks - but there's no reason you couldn't put them in and perhaps in some of the rougher systems there should be one or two added to start with.
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4704
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 »

I guess I'm trying to work out what to do with a lone escort that docks. Because I need to keep track of escorts under normal circumstances, I can't just drop or forget about a lone escort when it docks with a station. If I re-launch them with their original settings, they're just going to redock immediately - which will look a little silly.

I think the simplest solution would be to turn them into pirates. After they've had a few drinks at the station bar, obviously. They would probably consider a humanitarian option, if there was one.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2310
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: Arrivals and departures

Post by Wildeblood »

phkb wrote:
I guess I'm trying to work out what to do with a lone escort that docks. Because I need to keep track of escorts under normal circumstances, I can't just drop or forget about a lone escort when it docks with a station.
Why not?

Stations have shipyards, don' they? That means the ooniverse has pilots who've seen enough violence, decided to retire while they're still alive, sold their ships to brokers, and hopped on shuttles to the nearest planets...
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4704
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 »

I could even put their ship up for sale on the F3 screen!
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:
I guess I'm trying to work out what to do with a lone escort that docks. Because I need to keep track of escorts under normal circumstances, I can't just drop or forget about a lone escort when it docks with a station. If I re-launch them with their original settings, they're just going to redock immediately - which will look a little silly.
Freighters docking in the sort of system which generates loose escorts are probably short a few escorts themselves by the time they reach the station.
User avatar
Disembodied
Jedi Spam Assassin
Jedi Spam Assassin
Posts: 6883
Joined: Thu Jul 12, 2007 10:54 pm
Location: Carter's Snort

Re: Arrivals and departures

Post by Disembodied »

phkb wrote:
I think the simplest solution would be to turn them into pirates.
Being an escort-turned-pirate would be a bit of a step, I think: it would almost certainly rule out ever getting any escort contracts again for a long time. Plus, the escort has probably fought and killed members of various pirate clans in the region, who might be reluctant to let it join.

If there was an option to say that certain ships were heading to drydock, or maintenance, then any awkward left-overs could be disposed of that way.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Arrivals and departures

Post by Smivs »

A lone returning escort will most likely have just survived a serious firefight and may need repairs etc. Also the pilot might think he/she/it deserves a few days R&R, and will then need to find more work. All in all, it could therefore be several days between docking and re-launching, and it is therefore very likely that the player will have moved on before then, and will not be bothered by the fact that a returning lone escort has not re-appeared before they leave.
You can safely just lose these escorts I think.
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4704
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 for all the suggestions, everyone. Dropping them in the name of R&R is definitely the way.
Ngalo
Competent
Competent
Posts: 58
Joined: Mon Mar 02, 2015 2:08 pm
Location: drifting in remLock mask near Vezadi Station

Re: Arrivals and departures

Post by Ngalo »

phkb wrote:
If I re-launch them with their original settings, they're just going to redock immediately - which will look a little silly.
Not necessarily that silly. There have been times when I've launched and then remembered don't have enough fuel...
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2310
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: Arrivals and departures

Post by Wildeblood »

Code: Select all

this.shipLaunchedFromStation = function (station) {
    if (player.ship.fuel < 7) {
        station.dockPlayer();
        player.consoleMessage("Forgot something?", 5);
    }
}
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4704
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 »

I have a Boa with a bunch of escort ships in the list. The Boa launches and heads off (via the "launchShipWithRole" function), I add it to a new group and assign it as the leader. Then, as each escort is created with the "launchShipWithRole" function, I start adding things to it: I switch the AI to an escort, I add the ship to the Boa's group and do "ship.offerToEscort(leaderShip);" followed by "ship.performEscort();" and finally, just to make sure, "leaderShip.updateEscortFormation();". What I expect to see when I watch this happen outside the station is for the Boa to head off in one direction (without music), and for each escort ship to head off in the same direction, following the leader. But what I see is the Boa launch, head off, and then each escort launches and heads in a completely different directions. They all seem to be completely aimless until the Boa enters a wormhole, whereupon they all make a bee line for it.

I can confirm each of the escorts is part of the group, with the Boa as the leader. But I can't work out why their behaviour on launch is different to what happens with the standard process. Any ideas?

Here's the (almost) complete code for launching the leader:

Code: Select all

	var ship = station.launchShipWithRole("[" + shipData.shipDataKey + "]");

	// push all the stored data onto the ship;
	if (oolite.compareVersion("1.80") < 0) {
		ship.entityPersonality = shipData.personality; // can only do this in Oolite 1.81 or greater
	}
	ship.primaryRole = shipData.primaryRole; // shipData.primaryRole equals "trader" at this point
	ship.accuracy = shipData.accuracy;
	ship.heatInsulation = shipData.heatInsulation;
	ship.setBounty(shipData.bounty, "setup actions");
	ship.shipUniqueName = shipData.shipName;
	ship.homeSystem = shipData.homeSystem;
	ship.destinationSystem = shipData.destinationSystem;
	ship.fuel = shipData.fuel;

	var seed = "0 0 0 0 " + shipData.pilotHomeSystem.toString() + " 2";

	if (shipData.goods != "") {
		// put some cargo in the hold
		ship.setCargoType(shipData.goods);
	}

	if (shipData.equipment != "") {
		// process all the equipment additions
		...snip...
	}

	// set the ai of the ship (if required)
	if (shipData.shipAI != "") ship.switchAI(shipData.shipAI); // shipData.shipAI equals "oolite-traderAI.js" at this point

	// create a group with the ship as the leader
	var stdGroup = new ShipGroup(shipData.groupName, ship);
	ship.group = stdGroup;

	// put the group into a holding array so we can easily find it later for any escort members
	this._launchingGroups.push(stdGroup);
And here's the equivalent code for launching the escorts

Code: Select all

	var ship = station.launchShipWithRole("[" + shipData.shipDataKey + "]");

	// push all the stored data onto the ship;
	if (oolite.compareVersion("1.80") < 0) {
		ship.entityPersonality = shipData.personality; // can only do this in Oolite 1.81 or greater
	}
	ship.primaryRole = shipData.primaryRole; // shipData.primaryRole will equal one of these: escort, escort-heavy, escort-medium
	ship.accuracy = shipData.accuracy;
	ship.heatInsulation = shipData.heatInsulation;
	ship.setBounty(shipData.bounty, "setup actions");
	ship.shipUniqueName = shipData.shipName;
	ship.homeSystem = shipData.homeSystem;
	ship.destinationSystem = shipData.destinationSystem;
	ship.fuel = shipData.fuel;

	var seed = "0 0 0 0 " + shipData.pilotHomeSystem.toString() + " 2";

	if (shipData.goods != "") {
		// put some cargo in the hold
		ship.setCargoType(shipData.goods);
	}

	if (shipData.equipment != "") {
		// process all the equipment additions
		...snip...
	}

	// set the ai of the ship (if required)
	if (shipData.shipAI != "") ship.switchAI(shipData.shipAI); // shipData.shipAI equals "oolite-escortAI.js" at this point

	// is this ship part of a group
	var groupName = shipData.groupName;

	var stdGroup = null;
	// look for an existing group
	if (this._launchingGroups.length > 0) {
		for (var j = 0; j < this._launchingGroups.length; j++) {
			if (this._launchingGroups[j].name == groupName) {
				stdGroup = this._launchingGroups[j];
				break;
			}
		}
	}
	// if we found an escort group, just add the ship
	ship.group = stdGroup;
	stdGroup.addShip(ship);
	ship.offerToEscort(stdGroup.leader);
	stdGroup.leader.updateEscortFormation();
	ship.performEscort();
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 »

Interesting. That suggests that they're part of the Boa's group but not part of its escort group, so they wander around until they get an "enter wormhole" command, which is sent to both group and escort group, and then they follow that.

What happens if you take out these five lines in the escort set up

Code: Select all

    ship.group = stdGroup;
   stdGroup.addShip(ship);
   ship.offerToEscort(stdGroup.leader);
   stdGroup.leader.updateEscortFormation();
   ship.performEscort();
and just leave

Code: Select all

   log(this.name,"Offering to escort: "+ship.offerToEscort(stdGroup.leader));
You need to check the return value of offerToEscort: if it's false, the setup is still failing.

offerToEscort should handle all the necessary group set up for you (and you don't need to call updateEscortFormation or performEscort manually, either - the AI should manage those as needed)
Zireael
---- E L I T E ----
---- E L I T E ----
Posts: 1396
Joined: Tue Nov 09, 2010 1:44 pm

Re: Arrivals and departures

Post by Zireael »

Following this thread intently - I'm seeing Ooniverse transform into a living, breathing universe with many pilots with their own lives...
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4704
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 »

Still no joy. Each call to "offerToEscort" returns "false". I thought I was on to something when I looked at my shipdata.plist file for all these ships I was creating and saw I had "escorts = 0" as well as escort_roles set up. But removing escorts = 0 did nothing.
Here's an example of my shipdata.plist entries, in case there's something there:

Code: Select all

	"dock_anaconda" = {
		like_ship = "anaconda";
		escort_roles = {roles = ""; min = 0; max = 16;};
		roles = "dockonly";
	};
	"dock_griff_anaconda-NPC" = {
		like_ship = "griff_anaconda-NPC";
		escort_roles = {roles = ""; min = 0; max = 16;};
		roles = "dockonly";
		is_external_dependency = yes;
	};
	"dock_boa" = {
		like_ship = "boa";
		escort_roles = {roles = ""; min = 0; max = 16;};
		roles = "dockonly";
	};
	"dock_griff_boa-NPC" = {
		like_ship = "griff_boa-NPC";
		escort_roles = {roles = ""; min = 0; max = 16;};
		roles = "dockonly";
		is_external_dependency = yes;
	};
	"dock_python" = {
		like_ship = "python";
		escort_roles = {roles = ""; min = 0; max = 16;};
		roles = "dockonly";
	};
	"dock_python-trader" = {
		like_ship = "python-trader";
		escort_roles = {roles = ""; min = 0; max = 16;};
		roles = "dockonly";
	};
	"dock_griff_python_trader-NPC" = {
		like_ship = "griff_python_trader-NPC";
		escort_roles = {roles = ""; min = 0; max = 16;};
		roles = "dockonly";
		is_external_dependency = yes;
	};
(Note: I've tried "min = 16" as well as the current "min = 0".)
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4704
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 »

Wait... just noticed I have "roles = " instead of "role =" on all my shipdata.plist entries. Testing (with fingers crossed)...

...but no. Still "false" on the "offerToEscort". Anything else I should check?

And just got this message in my log:

Code: Select all

02:29:04.470 [eship.setUp.escortShipRoles]: ----- WARNING: Ship <ShipEntity 0x5d03560>{"Python ET Special" position: (0, 0, 0) scanClass: CLASS_NEUTRAL status: STATUS_DOCKED} has bad escort_roles definition.
My updated entry for this ship is:

Code: Select all

	"dock_staer9_python-x" = {
		like_ship = "staer9_python-x";
		escort_roles = {role = ""; min = 0; max = 16;};
		roles = "dockonly";
		is_external_dependency = yes;
	};
Although in the original "like_ship" entry, it just has "escorts = 2". Have I got it wrong?
Last edited by phkb on Mon May 18, 2015 4:43 pm, edited 1 time in total.
Post Reply