An Introduction to Flags

From Scenario League Wiki
Jump to navigationJump to search

An introduction to the use of 'flags' for constructing events in Civ2 Test of Time scenarios.

by William Keenan and Cam Hills (January 2000)


The Goal

The inclusion of flags in the Event Macro Language for Civ2 'Test of Time' opens vast opportunities for scenario designers. The goal of this paper is to educate designers in the use of single flags in event structures.


What is a Flag?

One could think of a flag as a tiny light bulb inside the computer that can be turned off or on as needed.


Why use Flags?

The use of flags is one key technique that allows the game to better 'remember' how things have developed in the game so far. The scenario can follow a path that makes sense given what has previously happened.

Flags can be used in any setting

Microprose have released two 'official' scenarios — the Midgard scenario's focus is on the fantasy game, while the Time Threat Paradox has a significant futuristic bent. Despite this, it should be made clear that the use of flags can be extremely useful in historical scenarios as well.

Use of flags — A design concept

To give an indication of how flags may be used in a scenario centered on the American Revolution, let's propose a theoretical example relating to the French participation.

The old (pre-ToT) way of handling the French intervention in the American Revolution would typically be to have Lafayette and his armies appear on a given turn, late in the war. As any student of history knows, the French intervention was by no means guaranteed. Through the use of flags we can make our scenarios much more historically accurate by simulating these complex conditions in our event structures.

Let us say that we decided the important conditions for French intervention were:

Benjamin Franklin has been dispatched to Paris and has been there for over a year;
The British have not captured more then ten strategic cities;
General Washington remains alive; and
The game year is 1779 or later.

All these conditions (and more) could be made prerequisites of French intervention through the use of flags.

Though French intervention would be an exciting topic to cover in this tip we need to delay it until the next paper in this tip series and instead tackle simpler events structures to begin with — although before we do, we will address a few more 'flag basics'.


How many Flags are there?

There are a total of 256 event flags that the scenario designer can toggle. They are organized into eight groups of thirty-two flags each. Each group of 32 flags corresponds to a civilization in the game and the eighth group is always the barbarians.

Tot flags tribes 01.png


We can think of flags as little light bulbs being turned on Tot flags onbulb.png and off Tot flags offbulb.png.

Count from the Right and Begin with Zero

When counting, we are taught from our childhood days to begin with the number one, but computers begin counting from the number zero. To a computer the first item in any list is item #0. Since Flags are the domain of the computer we must count like a computer. Therefore the 32 flags are numbered 0, 1, 2, 3, …31 rather then 1 to 32.

Therefore, 'Setting Flag=1 to on' is setting the second flag to 'on' as the computer understands it, not the first flag.

This is very likely to cause many event writers untold grief because the computer will not return an error message if we number a flag incorrectly. Rather it will cause the intended trigger to fail without explanation and probably cause a different trigger to happen instead.

'Reverse programmer notation' is a term that appears in some files as well as the Official Guide. It simply means that the first flag (flag 0) is on the right-hand side and the last flag (flag 31) is on the left-hand side.

When modifying or creating text-based files in Civ2 ToT for scenario development, the use of the semi-colon (;) in most cases (exceptions include text boxes) tell the computer that the line from that point on for its purposes is empty. For you and I however, it can be a valuable place to include notes and explanations. You will notice the use of the semi-colon in the examples set out later. This tip will also show rows of light bulbs — these are used to help the reader visualise what is happening with flags (you shouldn't try to put images of light bulbs into a 'text only' events file!).

The Continuous Modifier

At the beginning of each turn the 'Civilization Events Parser' resets all the flags to the 'off' position. In order to keep our flags 'lit' beyond the end of the turn we need to insert the 'Continuous' modifier into our event structure when setting the flag.

Tot flags event1.png


This tells the 'events parser' that that particular flag is not to be reset at the end of the turn.

After George Washington was killed our flags will look like this;

Americans Tot flags onflag0.png
British Tot flags offflag0.png


Since we used the 'Continuous' modifier we can check this flag throughout the scenario. A simple example of how we might use this flag is to display a different text based event on whether George Washington is alive or not. Let us say that the British capture the city of Philadelphia and we want one of two messages to be displayed based on whether George Washington is alive or not:

Tot flags event2.png


Using a Flag without the 'Continuous' modifier

Let us now look at an example of where we do not want to use the 'Continuous' modifier when setting a flag. Suppose we want to give the Americans a new Militia unit at the end of each turn in which a British regular army unit was destroyed by an attacking American unit. In order to create only one unit per turn we need the assistance of a flag.

Tot flags event3.png


Since we did not use the continuous modifier, flag 1 will be reset to off at the beginning of the next turn.

Tot flags event4.png


We can extend the scope of British units that contribute to the trigger with very little additional effort. In addition to the destruction of British regulars we will also include Hussein Mercenaries.

Allowing or preventing units being created

In our final example we will modify the event structure that creates American militia units to only create them if George Washington is still alive.

Tot flags event5.png


Concluding Comments

The objective of this design tip was to provide an entry-level familiarization with the most basic type of flag setting and checking. This tip however only 'scratches the surface' of the possibilities and options that the Test of Time framework offers.

We encourage the reader to experiment with ideas learned here and having mastered them move on to more complex event structures and flag masks.

It is intended that more advice on how to adopt the Test of Time events' macro language to your scenario will be prepared and launched onto the Scenario League in 2000. Future tips will cover matters including; masks, and binary masks vs. hexadecimal masks, each supported with practical examples and demonstrations.