Editor Variables

General discussion about Railroad Tycoon II.
User avatar
Gregorius
Cat
Posts: 9
Joined: Sat Apr 24, 2021 12:51 pm
Location: Luxembourg

Editor Variables Unread post

Hello,

First I followed Hawk's instructions to look around the Terminal for RRT2 stuff, which helped a little bit. Trying to register there about a week ago was not crowned with success, my onsite-contact-message about the lack of any registration confirmation mail in return stayed unanswered, so here I am.

I own many games, nevertheless, it always took and takes me back to RRT2. First time I began looking at the editor was around the year 2000, with not much result, then again some 10 years later with very moderate success (none in fact). About 3 years ago, I gave it a more serious try, in fact it took me several days to make a base map and get something going.

A few weeks ago, I loaded the map I made for Luxembourg to check where I was the last time I tried.

I am in no way a programmer (more like a 'script-kiddie') but I think I got rather far in putting together a somewhat historical scenario for the map.

Now, an apparently unsurmountable hurdle hits me: the variables. I don't get it (math class zero).

Anyone's help to solve my little problem would be great!

Description:

One first main goal in my scenario is to connect a certain amount of desired territories by a certain date (from 1840-1868).
I got dozens of events etc. in place to achieve this goal and everything is fine. If achieved, the game checks it and proposes to go on with the game etc.
But honestly, I got this working only with workarounds, instead of variables. Nevertheless, I would like to sometimes check on the way, how many territories have already been connected, to encourage the player to further connect. And, I got the feeling as if variables are really helpful, if understood.

So, first, I setup a TerritoryVariable1 at the very beginning when a Company is created,.
Everytime one of the desired Territories is built on or connected, +1 is added to the TerritoryVariable1 (trigger: TerritoryConnectedToTerritory(x) and testing against the Territory x).

Now, to check if this works, I also set up an event with TerritoryVariable1>=2 as trigger (without effect, just a message) and the same with TerritoryVariable1>=3 to give me a message when connecting the second and third territory.

Strangely enough (for me), when playing the scenario and first creating a company, I get the message that the Ter.Var. is set up, but then I build a station on one of the desired territories and one on another, and sometimes I already get the test-message for connecting 2 territories after building the 1st station, immediately followed by the second message confirming that I made the 3rd territory connection. The AI player hasn't even begun to build yet, so it's not him...

Ok, I hope my description makes some sense to anyone... !!jabber!!

So, if anyone could give me 2 or 3 hints about the variables in general, in plain text, this would really help me to continue the luxembourg scenario. I already have read appendix A: trigger functions etc. - the description there about variables doesn't enter my brain...hmmmm.

(and sorry, engl. is not my home language)
User avatar
RulerofRails
CEO
Posts: 2061
Joined: Sun Dec 08, 2013 1:26 am

Re: Editor Variables Unread post

I have much less experience with RTII events than RT3 ones. The theory is similar to RT3, but the UI is less friendly for the beginner, especially for debugging.

Sometimes there are "advanced" ways to use some functions other than intended. But for the sake of simplicity let's go with intended/established use.

The way the "TerritoryConnectedToTerritory (x)" trigger works is like this:

We are testing if one territory is connected to another. It's IMPORTANT that we are using two different Territory IDs. One in the test against field, and the other in place of (x) in the trigger.

For example if Belgium has Territory ID#4 and France is Territory ID#5 to test if they were connected we would use "Test against Territories ID 4) and the trigger "TerritoryConnectedToTerritory (5)"

Please note that the territory being tested against is the ACTIVE one. That is Belgium in our example.

If we want to also test if Belgium is connected to Germany, we need to make a second event.



Territory IDs should not be confused with Territory Variables. Territory IDs are the game's way of story basic information for each territory, the name, the price, goodwill, etc..

Each Territory has 4 variables assigned to it. Variables are basically numerical storage we can utilize when building events. There is no need to "activate" a variable. The use is to check the value of a variable with other events. This way we can build a chain/story.

In our case we are checking two different territories, it follows that anything we do with the Effects will be done to one of the territories: the ACTIVE one. In the example that's Belgium.

If we use the effect: Add to TerritoryVariable1 "+1". The TerritoryVariable1 used is the Belgian one.

To make a TerritoryVariable work here it's IMPORTANT that all events test against the SAME Territory: ID#4 (aka Belgium).*

*Side-note: another type of variable could be used, for example a Game Variable instead of a Territory one. In that case this doesn't matter.

It's IMPORTANT that the event doesn't trigger more than once. Otherwise our "count" (aka. the value of our variable) will be wrong. Make sure to use the "One Time Only" check on the Trigger page.


I assume you are familiar with how to display a variable? The Trigger should be "TerritoryVariable1", testing against in our case Belgium (ID#4). Then in Message Text we put "(TRIGGER)". This will show us what is the current value of the variable. By setting Frequency to "Status" we can see the value of the variable at any time in the company book. Please note if the variable is 0, you will not see the message, because a Trigger of something that is zero evaluates as false and will not be displayed.


I hope this helps you to understand the way variables can be useful. Where I put the word "IMPORTANT" may be something that is incorrect in your effort so far. Start by checking those. It could be something else, but let's start here.

PS. Your English is quite good. It's a complicated subject but I could still understand everything.
User avatar
Gregorius
Cat
Posts: 9
Joined: Sat Apr 24, 2021 12:51 pm
Location: Luxembourg

Re: Editor Variables Unread post

Hi RulerofRails,

This is enlightning! Thank you so much, it will help a lot.

Your first IMPORTANT explains already why my approach can't work.

I will try my best to get corrections done and report soon after.

To try the GameVariable came to mind already, but I became a little tired testing to find another workaround.

I prefer to understand the first thing before trying the next one.

Thanks again and have a nice Sunday! !!clap!!

Gregorius
User avatar
Gregorius
Cat
Posts: 9
Joined: Sat Apr 24, 2021 12:51 pm
Location: Luxembourg

Re: Editor Variables Unread post

Good Day,

After some testing, I got it working now. I chose the GameVariable as you mentioned.

There are still some mysteries left, like how to delete once added Territories in the Territory-List (I thought I had this done once, some years ago). There are a dozen territories in the list I don't need, as I had defined them before understanding to better use City IDs. I changed this now to avoid Customs at every station all the time. Or perhaps, they don't matter at all, just spoiling the list a little bit, who cares?

Perhaps more important: after the primary goal has been reached and I don't need the GameVariable1 anymore, do I have to do something about it, like to set it back by 'selling' it?

Also, regarding the "StationVisited(x)" as a trigger, I can't get it to work at all. No idea, why. I thought this would be an easy one...I presume the StationID is the one from the City where the station is at, what else could it be?

I feel a bit culpable to bother you with those questions about RRT2 and would like to do my part by helping to test Southern British Columbia, but frankly, I don't think I am capable of doing so...

On the other hand, what I can offer as a musician, is for you to use one or more of my (royalty free) music tracks to perhaps incorporate in scenarios or something.

Ok, most of my stuff is not 'train-music', but there are some tracks that could perhaps fit? Some examples, if you like:

http://www.musicker.net/a/sumtingwileewong.mp3

http://www.musicker.net/a/sjwb.mp3

http://www.musicker.net/a/jongforsu.mp3


They are all published on CD, registered etc. - so they are really mine and you can use them.

I don't want to spam here too much, but if you should like some of it, there are also videos going with it:

http://www.musicker.net/v/sumtingwileewong.mp4


Anyway, thank you for your help!
User avatar
RulerofRails
CEO
Posts: 2061
Joined: Sun Dec 08, 2013 1:26 am

Re: Editor Variables Unread post

Sorry, I don't know how to delete "ghost" territories (no land cells) from the list in RTII. Leaving the extra ones shouldn't harm anything. I'm sure you understand that a territory can be removed "physically" by painting over it with a different territory.


I don't know all the details of how you are using the variable. Is it part of the win conditions, or a task along the way?, etc.. Variables are most often used to store information in numeric form. The game doesn't care what value each may have (except integer overflow), the game will play the same whether GameVariable1 is 0 or 2,000.

I can imagine you want to keep a record somewhere that the player has fulfilled their task. It will be safe to leave this in "raw" form as long as whatever event is set to trigger on completion is set to "One Time Only Event."

In some more complicated cases you may want to keep the record of task completion with a different variable. This allows the variable in question to be re-used. This can be questionable in practice because overlap is almost always a headache/problem (linear progression via time or story can avoid this). However, sometimes a task is re-ocurring, making a "natural" re-use of a variable.

FYI, the variable can be updated/reset in the same event that awards completion. For example, if there is a reward of say $100k that is applied when GameVariable1 = 5, we can add as an additional effect, "SetGameVariable1 to 0". Or in the case of recording to another variable, when GameVariable1 = 5, we can have effects "SetGameVariable1 to 0" as well as "AddtoGameVariable2 (Add 1)"


Station IDs are different to City IDs. There can be multiple stations in one city. In the editor, check the station list for the ID# of any station. The number before the name is the ID#.

The first station built on a map will normally have an ID of 1, then 2, 3, 4, etc.. If during building, some stations were built in the editor and later deleted , we might see stations IDs start higher. I just loaded a map and its station IDs start at 21, this is extreme, but you get the idea.


I'm happy to try to answer any questions you may have. Don't feel obligated to do anything, I'm really not expecting it. Thanks for the offer with your songs. I got a western feeling from them which is a good fit for this type of game. RT3 has a global song list, not per individual scenario. These games aren't demanding on modern PCs. My normal practice is to listen to my own playlist in another application while playing. As far as I understand other players do similar.

I'm not really a map maker. I am a player first, but am interested in the details of the game and understanding how things work. The South Central British Columbia map wasn't made by me. The author, JSS, was really ambitious with the events in it. Probably a little too much so, because he never "finished" it. With the extra knowledge gathered over the years I was brave enough to tackle getting it to all work smoothly, and filling out the late game a bit. It remains an ambitious effort, also for me. I do have a new version in "alpha" (I didn't test it properly yet). A test run on this takes me at least 5 hours (it's quite an involved map). There are many choices and different paths that need to be tested. Probably needs a solid week more. But, I am busy in real life and also got distracted with other things, cause maybe my motivation lagged a bit (played it so many times already to get to this point). If you aren't an experienced player in RT3, I wouldn't recommend trying it.


The event stuff seems to come easy to me and I enjoy it, while the map making stuff like land creation/economy setup isn't really enjoyable for me. I'm happy if I can do something to make it a bit easier for others to use the events. A lot is possible. Also, play-testing a map at release is really helpful I feel (much better than you go to a map long after and get a bit let down when this or that doesn't work properly or something unintended happens). Maybe not many have the time, but useful feedback seems hard to come by. I can probably find time to give it a test spin or two if you want.
User avatar
Gregorius
Cat
Posts: 9
Joined: Sat Apr 24, 2021 12:51 pm
Location: Luxembourg

Re: Editor Variables Unread post

----original message-------
I don't know all the details of how you are using the variable. Is it part of the win conditions, or a task along the way?
-----------------------

Well, that's a pertinent question and the answer will be a rather long one:

Historically, in the 1800s, after a long time fighting for it, Luxembourg finally became a sovereign country. The French, as well as so many others, had occupied Luxembourg (located right between France, Germany and Belgium) again and again for centuries. Every time someone occupied, they fortified the capital because of it's strategic location. This went on for about 8 or 9 centuries, in fact since the founding itself (as a small castle already), in 963, and was always improved.

The real heavy work was started in the late 17th by Vauban, a french marshal and engineer, who put several thousands (!) of men at work for 3 or 4 years only to expand the fortifications around the capital until it became one of the heaviest fortresses from Europe, very difficult to conquer because of the overall topographical situation etc.

This may sound nice, but for all those centuries, we (mostly peasants) were caught in the middle between the idiots surrounding, fighting each other. People built Catacombs under most of the capital city to hide when assaults were taking place again - those "Casemates" are still an attraction point for tourists today.

Later the fortress came under spanish control, then french again.

So, soon after the French (Napoleon) had to leave for good, Luxembourg became independent and the French could hardly take the fortress with them.

From then on, we were member of the German Bond (Confederation). The German Emperor as well as the other countries around understood that they ought to include Luxembourg in the then developing european rail grid.

So there was a mutual goal to put in place a basic rail grid in Luxembourg: on their side, to pass their stuff through, on our side, the commerce that comes with it.

They probably could as well have gone around our tiny (about 75 x 50 km2) country, but you know, our Grand-Duke was family, so...in German it's called "Vetternwirtschaft", family business, and certainly for them, there were some bucks to make.

The Emperor helped financing the rails crossing through and our magnats did the rest.

So, after all this, let's return to our RRT scenario:

like it was, there were 10 towns where the rails had to go through to satisfy as a basic grid for the country. Those are the towns whose TerritoryConnectedToCity(x) add a +1 to the GameVariable1.

Now, as you suggested, I added the GameVariable1 permanently to the Status Report, a fine thing, thx again for that tip, it works nicely.

But, when trying to trigger other events (like just messages with no effect) to inform about the way to the goal, i.e. how much of the needed towns have been connected, with "GameYear=1865 AND GameVariable1" and with (TRIGGER) in the message, the trigger is translated in just 1 connected, although in the status report one can clearly see that there are more than 1 connected. I don't test it against territories, could that perhaps be the problem? Or the GameVariable1 is misplaced there probably.

------original message-------
In the editor, check the station list for the ID# of any station. The number before the name is the ID#.
The first station built on a map will normally have an ID of 1, then 2, 3, 4, etc..
--------------------

Well, that's my problem somehow. The map (in the editor) starts with no station at all. As one event asks for taking x passengers to a station (after it has bee built by the player), there is no ID to add to the trigger as no station exists there before; the event is only triggered after the station has been built. Perhaps I should think about some workaround.

------original message--------
I can probably find time to give it a test spin or two if you want.
--------------------

I would be more than happy about it! You will probably find the problem quicker than by reading my description of it.
The 1st goal/mission we are talking about here goes from 1838 to 1868.

At the moment I am translating the whole game into luxembourgish.

As soon as this has been done, i will translate the Luxembourg Scenario into english and when I think it's ready to do so, I will post an .mp2 with a few words of events description.

One final question would be:

as the Luxembourg map has a 1st goal (the base town connection grid), there will be other goals after this one has been reached. I can see in the editor that the map can be marked as a campaign map. Is it possible to make a whole campagn out of the editor instead of only a scenario?

Thank you.
User avatar
RulerofRails
CEO
Posts: 2061
Joined: Sun Dec 08, 2013 1:26 am

Re: Editor Variables Unread post

Sorry for the delay in responding. Was too busy for couple days to check the site. :oops:
But, when trying to trigger other events (like just messages with no effect) to inform about the way to the goal, i.e. how much of the needed towns have been connected, with "GameYear=1865 AND GameVariable1" and with (TRIGGER) in the message, the trigger is translated in just 1 connected, although in the status report one can clearly see that there are more than 1 connected. I don't test it against territories, could that perhaps be the problem? Or the GameVariable1 is misplaced there probably.
Don't need to test for territories here. Not sure, but you could try changing the order of the triggers, i.e. put GameVariable1 before GameYear=1865.


For your passenger task, the "established" way to do this is to make a hidden territory under the city and then use the trigger: CompanyTerritoryLoadsHauledLifetime(*)

* is the cargo ID number. Consult the list in "EDITOR2.txt" file which should be in your game folder. There is a usage example in that file as well.
Passengers are ID#0, so we would use: CompanyTerritoryLoadsHauledLifetime(0)


The campaign feature is made mainly for editing existing campaign maps. It may be possible to make a custom campaign with some hacking. I'm sure it would be difficult and time consuming. To my knowledge, no one has done this. Also, I don't think there is any actual gameplay advantage to be gained. For example, you don't take anything with you from one mission to the next. Also, there is no enforced linear order for the missions. So, there is little to gain compared to making a map series. For example in RT3, we have the "Age of Steam" map series.
User avatar
Gregorius
Cat
Posts: 9
Joined: Sat Apr 24, 2021 12:51 pm
Location: Luxembourg

Re: Editor Variables Unread post

Sorry for the late reply, I was out of town and as a no-Iphone guy, I was not near any internet for the last 10 days.

The solution for the 'passenger task' is so obvious I should have come to it by myself :oops:

But this is also a good way to use some of my ghost territories in the list we were talking about before.

I will try to analyse and implement your other observations soon and be back with any comments (and perhaps one or two more questions).

Thanks again for your friendly assistance!
Post Reply