Arrivals and departures
Moderators: winston, another_commander
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Arrivals and departures
Thanks, cim! Here's another technical question, though. I'm creating ships one of two ways: either via the stations launchShipWithRole, or with the systems addShips function. This is working fine, except that, when I create ships using "addShips", sometimes ships who have a destination system somewhere else will just turn around and try to dock with the station again, rather than jumping out to their destination. I'm assuming that I'm missing a step somewhere when I create the ships with addShips, but I can't for the life of me figure out where! Is there a command I can give the ship to say, "start heading for your destination system"?
-
- Quite Grand Sub-Admiral
- Posts: 6680
- Joined: Wed Feb 28, 2007 7:54 am
Re: Arrivals and departures
Would something likephkb wrote:Is there a command I can give the ship to say, "start heading for your destination system"?
ship.exitSystem(DestinationSystemID)
work for what you want to do? Note, the ship needs to have enough fuel to reach the designated destination and be far away enough from the main station for the command to trigger successfully.Re: Arrivals and departures
What role/AI of ships is this happening to?phkb wrote:I'm assuming that I'm missing a step somewhere when I create the ships with addShips, but I can't for the life of me figure out where! Is there a command I can give the ship to say, "start heading for your destination system"?
A few ideas:
- Are you setting home system to the current system?
- I assume you're using the
[shipkey]
roles to add the ships in the first place: if so, are you then setting the primary role, AI script, and so on? - Are you making sure the ships have enough fuel on board to make at least one jump towards their destination?
- If traders, are you giving them cargo?
Code: Select all
PS.target.AIScript.oolite_priorityai.setParameter("oolite_flag_behaviourLogging",true);
PS.target.AIScript.oolite_priorityai.reconsiderNow(); // or just wait for the next normal reconsideration
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Arrivals and departures
Thanks cim and another_commander. I wasn't setting the fuel value, so that might have been the problem. I'll report back if that doesn't fix the issue.
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Arrivals and departures
Technical question: When a ship group docks with a station, does the leader always dock first?
Also:
Also:
How do I access the controller for a ship with JS AI? I've tried these variations without success.cim wrote:If it's using JS AI and intends to dock, asking the AI controller for controller.getParameter("oolite_selectedStation") will tell you where, at least for core AIs.
Code: Select all
var ctl = ship.AIScript.oolite_priorityai.controller;
var ctl = worldScripts["oolite-libPriorityAI"].PriorityAIController(ship);
Re: Arrivals and departures
If it's an escort group, then the escorts won't request clearance until the leader has entered the docking approach pattern. If it's a normal group, it depends on the group AI: the group leader is likely to be the first to request clearance but if there's already a queue they might not be the first to dock.phkb wrote:Technical question: When a ship group docks with a station, does the leader always dock first?
Even in the escort group case, if the group leader were to be interrupted while docking and cancel its approach, it might then end up behind its former escorts in the docking queue. Extremely unlikely, but not impossible in the core game without player intervention.
Another detail is that the way core game NPC escort contracts work is that they're "to aegis". Once the freighter starts docking, the escorts are released from its escort group and become individual ships. Usually they'll dock next anyway, but if there was an outbound freighter looking for escorts, some of them might join it without docking.
The controller is at
Code: Select all
ship.AIScript.oolite_priorityai
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Arrivals and departures
I've tried everything, but I can't seem to get a connection to the controller. Here's my code.cim wrote:The controller is atCode: Select all
ship.AIScript.oolite_priorityai
Code: Select all
var ships = system.shipsWithPrimaryRole("trader");
for (var i = 0; i < ships.length; i++) {
log(this.name, "checking ship " + ships[i]);
if (ships[i].AIScript != "oolite-nullAI.js") {
log(this.name, ships[i].AIScript.name);
if (ships[i].AIScript.oolite_priorityai) {
var ctl = ships[i].AIScript.oolite_priorityai;
var stn = ctl.getParameter("oolite_selectedStation");
log(this.name, "result: " + stn);
}
}
}
Code: Select all
13:08:23.973 [StationDockControl]: checking ship [Ship "Cobra Mark I" position: (17094.4, -65303.9, 447890) scanClass: CLASS_NEUTRAL status: STATUS_IN_FLIGHT]
13:08:23.973 [StationDockControl]: Oolite Trader AI
13:08:23.973 [StationDockControl]: checking ship [Ship "Moray Star Boat" position: (-1450.88, -36299.3, 397332) scanClass: CLASS_NEUTRAL status: STATUS_IN_FLIGHT]
13:08:23.973 [StationDockControl]: Oolite Trader AI
13:08:23.973 [StationDockControl]: checking ship [Ship "Moray Medical Boat" position: (-14943.8, 19470.3, 346846) scanClass: CLASS_NEUTRAL status: STATUS_IN_FLIGHT]
13:08:23.973 [StationDockControl]: Oolite Trader AI
ships[i].AIScript.oolite_priorityai
is always null or undefined. What am I doing wrong?Re: Arrivals and departures
You might be checking too soon, depending on where you run that code. The AI controller is initialised in thephkb wrote:What am I doing wrong?
aiStarted
event in the ship's AI script. That doesn't happen until after the shipSpawned
event, which only occurs on the next frame of the simulation after the ship is added.The
oolite_selectedStation
parameter then won't be populated until the AI has evaluated its priorities at least once, which to avoid having every AI in the system try to do this on the same frame will happen at a randomised time, possibly up to a second later.The code itself is fine - I pasted it into the debug console on a new game and got lines like
Code: Select all
07:23:29.125 [oolite-debug-console]: checking ship [Ship "Boa" position: (-34027.6, 17387.1, 190453) scanClass: CLASS_NEUTRAL status: STATUS_IN_FLIGHT]
07:23:29.125 [oolite-debug-console]: Oolite Trader AI
07:23:29.125 [oolite-debug-console]: result: [Station "Coriolis Station" "Coriolis Station" position: (-49474.3, 60752.2, 427652) scanClass: CLASS_STATION status: STATUS_ACTIVE]
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Arrivals and departures
D'oh! Had the code in the startUpComplete!
Thanks cim.
Thanks cim.
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Arrivals and departures
Another technical question: How do I create a ship (via
Perrhaps some context... I'm trying to create a ship that looks exactly like the one seen in the dock list. I'm using
addShips
or launchShipsWithRole
) with a specific entityPersonality
?Perrhaps some context... I'm trying to create a ship that looks exactly like the one seen in the dock list. I'm using
modelPersonality
to control what the ship variant looks like on the mission screen, and I'd like to transfer that same look into a real ship. Is that possible?- Norby
- ---- 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
I am missing the personality parameter also from addShips long time ago, but regardless a possible improvement in trunk this is not in 1.80.phkb wrote:I'm usingmodelPersonality
to control what the ship variant looks like on the mission screen, and I'd like to transfer that same look into a real ship. Is that possible?
The only workaround what I can imagine is in Respray for Griffs which replace the whole outlook using setMaterials and contain a setDecal function to restore shader uniforms. You must give fix colors to the shaders in uniforms instead of entityPersonality and randomUnitVector to get the same ship.
This is a massive work due to the materials section in shipdata.plist is different for almost all ships and probably will not work for oxp ships what you are not verified. So I think a request for a personality parameter in addShips would be much better.
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Arrivals and departures
Well, that's annoying. I was hoping for a 1.80 release...Norby wrote:So I think a request for a personality parameter in addShips would be much better.
I can still do a 1.80 release with a caveat - ships will probably get an automatic respray on launch. What do people think? Immersion killer? Spells the end this this project?
To the devs, what's the chance of getting the ability to set the entitypersonality when creating ships, or a writable "entityPersonality" property in 1.81?
Re: Arrivals and departures
Difficult. Most of the ship adding functions at least potentially add multiple ships, so adding per-ship customisations to them isn't straightforward in terms of syntax. There are also a lot of different ship adding functions, and this isn't the only "on initialisation" customisation which has been requested, so this feels like a larger project.phkb wrote:To the devs, what's the chance of getting the ability to set the entitypersonality when creating ships
Straightforward enough to implement in theory - but I vaguely remember there being some reason it couldn't/shouldn't be done, which is why "create with personality" is an option for mission screens, rather than just making thephkb wrote:or a writable "entityPersonality" property in 1.81?
entityPersonality
writable in the first place and letting people update it on mission.displayModel
. I'll look into it.- Norby
- ---- 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
No imho. EscortDeck has the same problem but nobody complained yet. Just a speciality of Ooniverse either the reason is a free respray in each dock or some kind of camofluage to forget the questionable actions happened last time in the deep space.phkb wrote:ships will probably get an automatic respray on launch. What do people think? Immersion killer?
I think to a new array-type parameter of addShips after the existing ones. If this personality array is smaller than the number of the added ships then others can get random numbers.cim wrote:potentially add multiple ships
Personality should be read-only imho after a ship is created but a way would be good to set it at creation or right after.cim wrote:there being some reason it couldn't/shouldn't be done
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Arrivals and departures
I'm glad you think so -- I've come a bit too far to turn back now!Norby wrote:No imho. EscortDeck has the same problem but nobody complained yet. Just a speciality of Ooniverse either the reason is a free respray in each dock or some kind of camofluage to forget the questionable actions happened last time in the deep space.