Elvas Tower: Activity events triggered by AI trains - Elvas Tower

Jump to content

Posting Rules

All new threads will be started by members of the Open Rails team, Staff, and/or Admins. Existing threads started in other forums may get moved here when it makes sense to do so.

Once a thread is started any member may post replies to it.
  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Activity events triggered by AI trains Rate Topic: -----

#1 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Status: Elite Member
  • Posts: 6,996
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 02 January 2019 - 01:51 PM

After having read the wish of nonours1952 in another thread in this forum, I realized that it wouldn't be too complicated to enable also to AI trains location event triggering, and I already had some positive test.
I will speak using an example.
Here is a test activity for route USA2 (.apk compressed zip)
Attached File  TestEventAI.zip (2.81K)
Number of downloads: 465
And here is the extension activity file, to be placed in an OpenRails subfolder within the Activities subfolder of route USA2
SIMISA@@@@@@@@@@JINX0a0t______

Tr_Activity (
	Tr_Activity_File (
		Events (
			EventCategoryLocation (
				ID ( 1 )
				ORTSTrainService ( "TestEventAI" )
				ORTSTrainStartTime ( 43230 )
				ORTSContinue ( 3 )
				)
			EventCategoryLocation (
				ID ( 2 )
				ORTSTrainService ( "TestEventAI" )
				ORTSContinue ( 3 )
				Outcomes (
					ORTSActivitySound (
						ORTSActSoundFile ( "milanogrecopirelli.wav" "Ground" )
						)
					)
				)
			EventCategoryLocation (
				ID ( 4 )
				ORTSContinue ( 3 )
				Outcomes (
									ORTSActivitySound (
						ORTSActSoundFile ( "abbadialariana.wav" "Location" )
						ORTSSoundLocation ( -12506 14779 -939.019 1159.00 394.96 )
						)
					)
				)
			EventCategoryLocation (
				ID ( 5 )
				ORTSTrainService ( "TestEventAI" )
				ORTSContinue ( 3 )
				Outcomes (
					ORTSRestartWaitingTrain (
						ORTSWaitingTrainToRestart ( "TesteventAI_Wait" )
							ORTSDelayToRestart ( 5 )
							ORTSMatchingWPDelay ( 31230 )
							)
					)
 			)
			EventCategoryLocation (
				ID ( 6 )
				ORTSTrainService ( "TestEventAI" )
				ORTSTrainStartTime ( 43230 )
				ORTSContinue ( 3 )
				Outcomes (
					ORTSActivitySound (
						ORTSActSoundFile ( "leccomaggianico.wav" "Location" )
						ORTSSoundLocation ( -12506 14779 -939.019 1159.00 394.96 )
						)
					)
				)
			EventCategoryLocation (
				ID ( 7 )
				ORTSContinue ( 0 )
				)
			)
		)
	)

This file is shown in detail to describe syntax and operation of the features.
It must be also said that the data contained in the extension activity file may also alternatively be embedded in the base activity file, with the usual disadvantage that editing of such base activity file with the MSTS AE deletes the additional data.
To link a location event to an AI train either only the train service name can be provided
				ORTSTrainService ( "TestEventAI" )

or additionally also the train start time may be provided
				ORTSTrainStartTime ( 43230 )

This second parameter is useful when one service is present more than once in an activity.
The rest of the event syntax is the one already known for the activity extensions, with two improvements:
- the first one is that now, like Goku suggested, data about outcomes like activity related sounds and weather changes are inserted in the Outcomes subblock, therefore providing a cleaner structure (the old format however is still supported for weather change and activity sound, with the exclusion of the new feature described in the second point here).
- the second one is that now, as can be seen, activity sounds provide a new feature, which is recalled by following format
					ORTSActivitySound (
						ORTSActSoundFile ( "leccomaggianico.wav" "Location" )
						ORTSSoundLocation ( -12506 14779 -939.019 1159.00 394.96 )
						)

meaning that when the AI train (or also the player train) passes over the location event, a sound is played at the location indicated in ORTSSoundLocation. This way e.g. an announcement for a train arriving or passing by can be heard in the station a reasonable time before the train effectively passes or arrives.
The other events above show also the possibility of an AI train commanding the restart of another AI train waiting at a signal, or simply displaying a message, or playing a sound at ground near of the AI train. The other (not used in this example) available activity sound types allow e.g. to play a sound in the cab of the player train when an AI train passes over a location event, allowing to simulate vocal communication exchange from the AI train engineer to the player train engineer.
An absolutely preliminary development (not runtime) patch may be found here


When the feature will be a bit more consolidated I foresee to insert it in the OR MG version, waiting also for eventual approval for insertion in the official OR version.

And I hope that Goku will have time to add this to his OR-oriented activity editor, simplifying creation of these data structures.

12/1/2019: patch file deleted because new release available

#2 User is offline   Goku 

  • Superintendant
  • Group: Status: Elite Member
  • Posts: 1,785
  • Joined: 12-December 13
  • Gender:Male
  • Simulator:my own
  • Country:

Posted 02 January 2019 - 02:17 PM

Quote

To link a location event to an AI train either only the train service name can be provided
ORTSTrainStartTime ( "TestEventAI" )
or additionally also the train start time may be provided
ORTSTrainStartTime ( 43230 )

I think that this value should be defined precisely always using two parameters:
ORTSTrainService ( "TestEventAI" 43230 )
Or even just using Traffic Service ID:
ORTSTrainService ( 3 )
.. but the second option would be too difficult to use by hand and brings more risks of bugs.

The solution with separate optional parameters has a major bug.
Assume that player first create an AI event in activity where only one "test" service is used.
Then he puts more "test" services in the traffic and now the event points to undefined service.

And yes. Of course it can be implemented in TSRE.

#3 User is offline   Goku 

  • Superintendant
  • Group: Status: Elite Member
  • Posts: 1,785
  • Joined: 12-December 13
  • Gender:Male
  • Simulator:my own
  • Country:

Posted 02 January 2019 - 02:25 PM

Isn't the problem with one service used multiple times here too?
ORTSWaitingTrainToRestart ( "TesteventAI_Wait" )


Also, could you point me to other new features that are not present in TSRE AE?

#4 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Status: Elite Member
  • Posts: 6,996
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 03 January 2019 - 12:37 AM

View PostGoku, on 02 January 2019 - 02:17 PM, said:

I think that this value should be defined precisely always using two parameters:
ORTSTrainService ( "TestEventAI" 43230 )
...
The solution with separate optional parameters has a major bug.
Assume that player first create an AI event in activity where only one "test" service is used.
Then he puts more "test" services in the traffic and now the event points to undefined service.

Hi Goku, I don't see the risk. In any case, if the activity creator modifies the activity, he knows that he has to check that everything he already put in the activity still works. By the way in case there are more services with same name and no starting time parameter, OR would point to the first service with that name in the traffic list. And avoiding the second parameter is a simplification for the many activity creators that don't use the same service multiple times in an activity.

Goku said:

Isn't the problem with one service used multiple times here too?
ORTSWaitingTrainToRestart ( "TesteventAI_Wait" )

Yes, I'm aware of that. A second optional parameter "ORTSWaitingTrainStartTime" must be foreseen.

Goku said:

Also, could you point me to other new features that are not present in TSRE AE?

I don't think there are other ones.


Goku said:

And yes. Of course it can be implemented in TSRE.

That's good.

#5 User is offline   Goku 

  • Superintendant
  • Group: Status: Elite Member
  • Posts: 1,785
  • Joined: 12-December 13
  • Gender:Male
  • Simulator:my own
  • Country:

Posted 03 January 2019 - 04:24 AM

Quote

Hi Goku, I don't see the risk. In any case, if the activity creator modifies the activity, he knows that he has to check that everything he already put in the activity still works. By the way in case there are more services with same name and no starting time parameter, OR would point to the first service with that name in the traffic list.

I was thinking that if you want triggering just by service and not by traffic train, then maybe better is to trigger the event by all trains using this service? For sound events it might be useful. I don't know if it would make problems in other cases.

Quote

And avoiding the second parameter is a simplification for the many activity creators that don't use the same service multiple times in an activity.

I don't see any simplification. You usually will copy the line from traffic service definition anyway. But if defining train just by service is an useful feature, then it's fine.

---

I also don't like the name of this parameter, because it doesn't say anything about what it do.

ORTSTrainService ( "TestEventAI" )


I think that it should sound something like that:

ORTSTriggerByTrain ( "TestEventAI" 43230 /* optioanal */ )


Or if OR avoids using two value parameters:

ORTSTriggerByTrain (
 Service ( "TestEventAI" )
 StartTime ( 43230 ) // Optional
)



Quote

meaning that when the AI train (or also the player train)

Is it good that event can always be triggered by player train even if user just want to make event for other train?
I think that it will limit usability of this feature.

#6 User is offline   James Ross 

  • Open Rails Developer
  • Group: Status: Elite Member
  • Posts: 5,490
  • Joined: 30-June 10
  • Gender:Not Telling
  • Simulator:Open Rails
  • Country:

Posted 03 January 2019 - 08:33 AM

View PostGoku, on 03 January 2019 - 04:24 AM, said:

I think that it should sound something like that:

ORTSTriggerByTrain ( "TestEventAI" 43230 /* optioanal */ )


This format would be my preference too; the two sibling elements are unnecessarily verbose IMO (nested and not).

#7 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Status: Elite Member
  • Posts: 6,996
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 04 January 2019 - 01:57 AM

OK, if James and Goku think the same thing, that most likely means that their idea is better...
here is my updated additional .act file
SIMISA@@@@@@@@@@JINX0a0t______

Tr_Activity (
	Tr_Activity_File (
		Events (
			EventCategoryLocation (
				ID ( 1 )
				ORTSTriggeringTrain ( "TestEventAI" 43230 )
				ORTSContinue ( 3 )
				)
			EventCategoryLocation (
				ID ( 2 )
				ORTSTriggeringTrain ( "TestEventAI" )
				ORTSContinue ( 3 )
				Outcomes (
					ORTSActivitySound (
						ORTSActSoundFile ( "milanogrecopirelli.wav" "Ground" )
						)
					)
				)
			EventCategoryLocation (
				ID ( 4 )
				ORTSContinue ( 3 )
				Outcomes (
									ORTSActivitySound (
						ORTSActSoundFile ( "abbadialariana.wav" "Location" )
						ORTSSoundLocation ( -12506 14779 -939.019 1159.00 394.96 )
						)
					)
				)
			EventCategoryLocation (
				ID ( 5 )
				ORTSTriggeringTrain ( "TestEventAI" )
				ORTSContinue ( 3 )
				Outcomes (
					ORTSRestartWaitingTrain (
						ORTSWaitingTrainToRestart ( "TesteventAI_Wait" 42900 )
							ORTSDelayToRestart ( 5 )
							ORTSMatchingWPDelay ( 31230 )
							)
					)
 			)
			EventCategoryLocation (
				ID ( 6 )
				ORTSTriggeringTrain ( "TestEventAI" 43230 )
				ORTSContinue ( 3 )
				Outcomes (
					ORTSActivitySound (
						ORTSActSoundFile ( "leccomaggianico.wav" "Location" )
						ORTSSoundLocation ( -12506 14779 -939.019 1159.00 394.96 )
						)
					)
				)
			EventCategoryLocation (
				ID ( 7 )
				ORTSContinue ( 0 )
				)
			)
		)
	)

So I have put in the same line service name and starting hour, I have changed name of the parameter as Goku suggested, and I have added also to ORTSWaitingTrainToRestart the (optional) starting time.
Goku said
"Is it good that event can always be triggered by player train even if user just want to make event for other train? "
That's not what I meant. The event is triggered by the player train only if the ORTSTriggeringTrain is not present.
Here an updated development patch file. I refactored also a bit the restart train feature.

12/1/2019: patch file deleted because new release available

#8 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Status: Elite Member
  • Posts: 6,996
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 06 January 2019 - 09:08 AM

A blueprint has been opened for this option, see https://blueprints.l...ed-by-ai-trains .
A Trello box already exists, see https://trello.com/c...location-events .

#9 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Status: Elite Member
  • Posts: 6,996
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 12 January 2019 - 09:52 AM

New release of patch available
Attached File  AITrainEvents_totale3.zip (5.78K)
Number of downloads: 496
which removes a crash bug and corrects some issues.
It is inserted in today's OR NewYear MG release.

#10 User is offline   Goku 

  • Superintendant
  • Group: Status: Elite Member
  • Posts: 1,785
  • Joined: 12-December 13
  • Gender:Male
  • Simulator:my own
  • Country:

Posted 18 January 2019 - 08:20 AM

I would like to implement these new features, but I have some questions.

1.
Could someone explain me Waiting Points? Where they are stored etc.
I would like to make a selection box, so that user isn't forced to search them by hand.

2.

Quote

- the first one is that now, like Goku suggested, data about outcomes like activity related sounds and weather changes are inserted in the Outcomes subblock, therefore providing a cleaner structure (the old format however is still supported for weather change and activity sound, with the exclusion of the new feature described in the second point here).
- the second one is that now, as can be seen, activity sounds provide a new feature, which is recalled by following format
ORTSActivitySound (
    ORTSActSoundFile ( "leccomaggianico.wav" "Location" )
    ORTSSoundLocation ( -12506 14779 -939.019 1159.00 394.96 )
)

The ORTSSoundLocation value is optional? Can it be anything?

3.
TSRE will not read full weather block located in outcome subblock. TSRE stores there only a name of the weather definition in separate file. The idea of separate file for weather changes and weather editor was never finished, but we talked about it.
Full weather block is written in Event subblock if player decide to do so.

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users