Variables example mission

From FreeSpace Wiki
Revision as of 13:02, 10 January 2009 by TopAce (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

In this tutorial mission you will learn how to use variables. The player must take down all four of the Sathanas's forward beam cannons, much like in Bearbaiting. However, this Sathanas will not fire at you or jump out x seconds into the mission.

Download the mission, open it in FRED, (play it), and use it to follow this tutorial.

The mission

In this mission, the player receives an Erinyes-class fighter armed with Akheton SDGs and Trebuchets. There will be a Sathanas in front of you, with all four of its turrets at 1% integrity, and the Sathanas will "play dead."

Every ten seconds, the player will receive a message that tells him how many of the turrets are destroyed.

If the player takes down three turrets, he will receive a message that urges him to hurry up.

If the player takes down the last of the turrets, he will complete his only directive and receive a new message. Ten seconds later, the mission will quit using end-mission.

The variable

There is only one variable in this mission. It's a numeric variable named "TurretsDown". Its default value is 0, because at the start of the mission, all the turrets will be intact. The value of this variable will change four times over the course of the mission; every time the player takes down any of the four main turrets.

Mission Events

You will spend most of your variable-manipulation time in the Events window (SHIFT-E). The example mission's Event are these:


There are four turrets overall. Every turret the player takes down adds 1 to the TurretsDown numeric variable. You can see how to make the "Add 1 to this variable"-type tree in the "Turret 1 down" Event. The other three "Turret x down" Events are the same, except they obviously check the relevant turrets (turret02 for "Turret 2 down," etc).

"Only one to go" will send a message as soon as the player takes down 3 turrets.

"Status report" will send the player a message every ten seconds, telling him how many turrets he took down already. The message that is sent here is the following:

Turrets destroyed: $TurretsDown

Here, $TurretsDown will be substituted by the number of the TurretsDown variable (=how many turrets have been destroyed). Note that the number here will be constantly updated, so the right variable will be displayed every time.

"All down" will send a message as soon as the player has taken down all four turrets. Note that the is-subsystem-destroyed-delay could also be used here, and the directive will tell you how many are to be taken down. This variable-based Event's directive will not tell you that. The $TurretsDown string will not work for directives.

"Quit" will automatically quit from the mission 10 seconds after the player takes down the fourth turret. It is irrelevant when dealing with variables.


As soon as you are confident in yourself, make a new mission that is somewhat like this. Don't make it the same as the one in this example, but use it as a sample. Create a mission in which the player must take down five of a Cain's turrets, for example.


  • Bearbaiting doesn't make use of variables. It uses a more cumbersome method.
  • There's a shorter yet more complicated way of adding up variables in this mission, using every-time-argument and invalidate-argument. These operators may be too difficult for tutorial purposes, so a longer yet easier-to-understand method is used here.

External links

  • The sample mission, optimized for FreeSpace Open 3.6.9. Easier difficulties recommended. Will not run on retail.