Expanding your Missions

If you've had Flight Simulator X for a while, all but the most incurious have probably tried a mission or two. If you haven't, now's the time – go try one out! Calling them 'missions' is probably a bit grand; they can be anything from a full storyline taking an hour or more to finish, down to a simple test taking only a few minutes. They can be a bit of harmless fun, or something that would test the skills of virtual pilots to the limit.

If you've tried any at all, chances are you've long since run out. Some of the braver among you might have tried writing your own missions. If not, you really should give it a go – I can thoroughly recommend trying the FSX Mission Editor for three good reasons: first, it makes life much easier for mission authors; second, it's free to try and lastly because I wrote it! Even with a tool like this (and there are others too), there are some things that are difficult or just impossible to do with the mission-writing commands that Microsoft supplied. Happily, they thought of that and allowed people to add their own commands to FSX' mission system. This article is about one such extension.

Don't run away just yet if you've never tried to write your own missions though. I'll discuss some of basics here before getting into any of the more advanced stuff that the SimVar extension can do.

Existing System

The standard mission system is part of the normal simulator package, there's nothing you need to do to enable it. For those who have never tried one, a 'mission' is basically a set of tasks which have to be completed, strung together with appropriate speech, scenery and computer-controlled vehicles. What with computers being the way they are, the mission is written in a rather complicated-looking language; happily, various tools are available which make this easier. One is even included as a standard part of FSX Deluxe.

Conceptually, a mission is made up of a collection of three different groups of things: Triggers, Actions and Other Stuff. These get linked together in a way which only allows the player to progress when they do the right things, in the right order.

A Trigger, for example, might be watching to see if the player has flown into a certain area, or is above a certain altitude, or has landed. An Action might be to show a message, or to make part of the plane fail, or to switch a Trigger on or off. The 'Other Stuff' could be bits of scenery that help to set the scene.

Microsoft provided a smallish set of these commands which let you control the simulated world to some degree. This was good because there weren't many to learn, but at the same time it was bad because it could get a little tricky working out how to make more complex sequences work. In their defence, it often was possible, but something that seemed logically simple could take a dozen commands to actually get working properly.

Limitations

On the other hand, some things simple couldn't be done. The best example is what Microsoft called a 'Property Trigger'; this simply means that the mission system is told to watch a certain property, usually of the player's plane, and do something when the property reaches a certain value. You might, for example, tell it to show a message is you get below 200 feet altitude or if the oil pressure is low. Now, if you read the mission author's manual that comes with FSX, it lists many hundreds of different things that can be tested for covering every system in every type of aircraft, and all manner of environmental values such as air pressure and temperature, time, wind speeds etc. Fantastic – except that the Property Trigger only allows you to test about 40 of the nearly 900 possible values. An important part of my mission was to test whether the landing lights were on, and I just couldn't do it.

I also found it was almost impossible to control the aircraft in many ways I wanted to. The standard mission commands allow you to make bits fail but not much else. However, if you've ever tried the flying lessons that come with FSX (under the Learning Center, if you've not found them already), the plane not only flew itself from time to time but the radios and autopilot were sometimes set for you. OK, so the simulator can do it but not from a mission – exactly where you might want to! You might want, for example, to write a long-haul mission where a co-pilot handles all of the radios for you. Surely this should be possible – but no.

Ways Round

I don't like taking no for an answer, especially when I can see that what I'm asking is perfectly achievable. I started looking through Microsoft's manuals on how to write extra commands for the mission system and it didn't look too tricky. What I decided eventually was that rather than creating specific commands for the things I wanted to check, I'd create a small number of powerful commands which would allow mission writers to access anything that the simulator allowed. That's a lot easier from my point of view, and a lot more flexible from the mission author's point of view, because you don't need to hope that the right command has been added. For example, if I'd added one command to check the landing lights, it would have been useless to check if the panel lights were on. It also allows the same extension code to be used across many different missions.

So, basically the SimVar extension allows a mission author full control over the simulation, to the limits of what Microsoft allowed, and far beyond the limits of the standard mission commands.

Having said that, there are a collection of other, more specific commands to do things that would have been tricky to do any other way. I'll describe some of them later.

New Commands

So, what are the actual new commands? There aren't very many, in fact less than twenty, but they expose pretty much every feature of the simulator. I'll cover some of the specific ones first, because they're simpler.

Simple Controls

To start with the simplest ones, they allow you to change the simulation rate, and time of day. Simple indeed, but perhaps more important than you might think. Have you ever flown a mission which has a long flight section where not much happens? Have you ever use the rate control to speed time up to cover that 20 minute stretch in five minutes? It's the obvious thing to do. Here's the problem: you complete the long flight and get three messages in a row telling you what to do next, and then you fly into an area which makes the next part of the mission start, then something else happens. All at four or eight times faster than real-time. So, you don't get to hear all the instructions and before you know it you've failed the mission because you flew into a forbidden area. Well, using the first of the extra commands you can prevent this by telling the sim to go back into real-time flying before doing anything important.

There are other commands to deal with displaying messages, creating a very controlled fuel leak and a new camera view which makes sure that two different planes are in view at the same time.

More Complex Controls

Another group allow you to change the simulated environment. You can change the weather during a mission instead of just choosing a theme which lasts for the whole time. One thing that there's been a lot of interest in is controlling AI – that is, computer-controlled – aircraft. The standard mission system lets you set up AI which follow a pre-set path in the mission, or record a flight and play it back during a mission. That's fine up to a point, but what if you need a plane to do something in relation to the player's plane? It's all very well assuming that the player's following your expected path exactly, but chances are they're not. You end up with messages like “Now follow the Cessna to your left” when in fact it's on the right, or three thousand feet below, or twenty miles away.

Well, SimVar gets round this by letting you tell AI planes to fly to a point relative to the player, and even to try and stay there. That means you can have a 'wingman' in your missions; maybe an instructor, or a guide, or a border patrol plane which follows you as you weave around trying to lose it.

Remembering things

One thing I wanted to do right from the start was to get Flight Simulator to remember what had happened in one mission and use it to change what happens in another. That would let people create storylines, built up over several missions, where each could change itself slightly depending on the player's choices in previous missions.

To start with, SimVar lets you remember things inside a single mission. You can set a flag which says “the player went along route 1” or “the player went along route 2”, for example, and there's no limit to what you can get it to remember. Later in the same mission, you can get it to check any of these values and choose to do one thing or another based on what happened earlier.

The next trick is that anything you set in this way gets saved to disk when the mission is finished. By using another new command you can get another mission to read that file when it starts. This means that anything you set in one mission can be read in another, giving the possibility of a continuing storylines! Even better, the file that stores the settings can be used to change the mission briefings too.

Imagine your first mission lets the player land at one of three different airports. By saving some indication of which airport was used, the second mission can be set to start at the correct airport. The mission briefing for the second mission can even say “Take off from <insert airport name here>, fly towards...”!

With the newest version of the SimVar extension, you can also make sure that the file that stores these values isn't changed between missions by cheats.

Examples

Cockpit Control

TODO

AI Control

TODO

New Keyboard Commands

TODO

New Tests

TODO

SimVar Extension Details

List of Commands

Command

What it Does

IF

Test any SimVar

SET

Set any writeable SimVar

DEBUG

Switch the extension's debug messages on or off

PROFILE

Set an internal variable

SAVEONFAIL

Save the profile even if the mission fails

SAVEONCHANGE

Save the profile every time any value changes

UNIQUEID

Set a secret value which will stop the profile from being reloaded if it's manually changed

FUELLEAK

Start or stop a controlled fuel leak

MESSAGE

Display a small text message on screen

FXTRACK

Attach a visual effect to the player or an AI

METAR

Set local or global weather

WXSTATION

Create a new weather station

EVENT

Send a simulator event

WHEN

Make a mission action happen when a particular key is pressed

PROFILENAME

Set the name of the file to store the mission profile in

WPT

Set dynamic waypoints relative to the player or an AI

SIMRATE

Set the simulation speed

SIMTIME

Set the time and optionally the day of the year

TARGETCAM

Force a cinematic camera to show two aircraft in the same view