Page 1 of 1

Determining the head- and tail-engine in an AI consist

Posted: Sat Dec 16, 2017 6:20 pm
by chrisell
I've come across an issue I've not had before - needing to determine which engine is at the front and which is at the rear of a AI consist.
When the player is driving, this is easy. But for a double-cab engine (BR186) that is in an AI consist, I need to figure out if it's at the front or back and which way it's facing to sort out my driver character logic (which engine gets a driver and which cab is he in?)
GetIsEngineWithKey only works for player trains. For AI trains I can't seem to put my finger on how to determine the 'driven' engine (head) and the 'undriven' engine (tail) of the consist.

Anyone got any smart ideas?

Re: Determining the head- and tail-engine in an AI consist

Posted: Sat Dec 16, 2017 8:22 pm
by 749006
I might be misunderstanding but Is it any different to your DD-AR?

When you put one in a scenario you decide to place the driver on the Motor coach or the Driving trailer depending on which direction you wish to lead.

If I set up a formation using the DVT, coaches and loco for example I place the driver Icon at the end I wish to lead
The loco must normally face outwards - ie the default Cab, normally no1 end, faces away from the train even if on the rear of the formation.

Peter

Re: Determining the head- and tail-engine in an AI consist

Posted: Sat Dec 16, 2017 9:42 pm
by chrisell
The difference with an EMU like the DD-AR is that each end wagon only has one cab, so it can only be placed in the consist one way round. With a double-ended engine like the 186, it could be put on the end of the consist either way around (because there's two cabs).

Re: Determining the head- and tail-engine in an AI consist

Posted: Sun Dec 17, 2017 8:41 am
by markpullinger
Hi. would linking it to the headlight state work?

Re: Determining the head- and tail-engine in an AI consist

Posted: Sun Dec 17, 2017 10:18 am
by deltic009
markpullinger wrote:Hi. would linking it to the headlight state work?
No, the games headlight system can't be queried or referenced in scripts unfortunately. I am aware that some locos like the recently released Western Hydraulic Pack have a control which is called InCab and changes between 1 and -1 depending on which can the player occupies. But in terms of AI I'm pretty sure the AI driver is only ever considered to be travelling in whichever is the default cab.

One thing that may or may not be usable, I added controls and scripts so that custom headlight and script placements could be neutralised by an instruction controlling behaviour when one or other cab was coupled to a vehicle - whether this could be an approach with similar results for what you want to achieve I am not sure, but thought I'd mention it.

Re: Determining the head- and tail-engine in an AI consist

Posted: Sun Dec 17, 2017 3:23 pm
by 749006
If I was creating a consist for normal or AI use with T&T locos, like the NR Track Inspection train with two 67's, I start with the first loco, then the stock the the last loco.
Before coupling the second loco to the stock I put Driver Icons on both locos to make sure they face outwards and then couple the second loco to the train.

One of the driver icons disappears leaving just the one at the outer end.
But with some locos this can cause a problem and both locos need to face the same way in the consist.

Peter

Re: Determining the head- and tail-engine in an AI consist

Posted: Sun Dec 17, 2017 4:12 pm
by chrisell
I beginning to think this might not be possible.
What I really need is a way to query which engine has the driver icon in the scenario editor but there's no such call available to me. And because either engine can be flipped, I can't just look at speed and which coupler is connected (although that does work for the head unit, but only once the consist is moving).
I might just have to make both engines head units and deal with the complaints from people about the pantographs being wrong on AI trains :)

Re: Determining the head- and tail-engine in an AI consist

Posted: Mon Dec 18, 2017 8:43 am
by karma99
You might need to resort to a manual setting and have the user set a character in the engine number when they place it down to indicate whether it's the head or tail.
Not very elegant but often the only way if you can't get the information in game.