Mission Creation for MSFS: Difference between revisions

From FSDeveloper Wiki
Jump to navigationJump to search
(Added/expanded chapter on mission coding)
(Updated for the newest version of the simulator and the SimpleMission sample project. Improved structure and writing style.)
Line 23: Line 23:


== Overview ==
== Overview ==
Creating a mission is a complex task involving a diverse use of tools & skills. Getting your first mission going is likely to cause you some headaches.
Creating a mission involves using different tools and skills. While it may be challenging to get your first mission up and running, once you understand the basic rules and files that make up a mission, the possibilities are endless. Essentially, a mission is a scripted set of events that tells a story, ranging from exciting scenarios like mountain rescues or engine problems to simpler flights with interesting points along the way.


Still here? Good. Once you ''do'' have that first one running, the sky's your limit. That basic set of rules and files that make up a mission are always the same so once you've got those sorted, it's just a case of coming up with an idea and writing it.
To turn your mission idea into a playable experience, you need to plan the mission flow and then code it. Start by outlining the flow on paper, showing how the mission progresses from start to finish. Next, select and use triggers and actions to create the mission's logic. Triggers check for conditions or events, while actions allow you to modify and control various aspects of the mission. You can also use objectives to give the player a clear sense of direction and purpose. Once you've scripted your mission, you can fine-tune and test it using the script editor, console for error checking, and tools for finding and fixing problems.


At it's simplest, a mission is just a scripted set of events that tell some kind of story. It may be dramatic - mountain rescue, failing aircraft, poor weather. It could just as easily be a simple flight from A to B with you pointing out areas of interest along the way, or a completely abstract challenge like finding out how many times you can touch-and-go in a 747 in five minutes.
With patience and creativity, you can create rewarding and enjoyable missions that captivate players and keep them coming back for more!


Technically speaking, there are two main classes of 'things' in a mission; Actions and Triggers. An Action makes something happen, and a Trigger checks to see if something's happened and calls an Action if it has. By stringing together Actions and Triggers, you tell your story.
== Come up with a scenario and story ==
You need to decide what kind of mission you want to create, for example, a tutorial, an emergency scenario, or a treasure hunt.
You also need to think of how the mission will progress from start to finish.
* How will you introduce the player to the mission and explain their role and objective?
* What will you reveal to the player and what will they have to discover on their own?
* What are the possible ways that the player can complete the mission? Are there branching paths or different outcomes?
* How will you end the mission and give feedback or rewards to the player?
It can help to have a written structure that outlines your mission in detail. You can follow the same three-stage layout as a screenplay. This gives you a clear and coherent way of telling your story.  
* The first section is your introduction, where you need to capture the player’s interest and set up the context and premise of the mission.
* The second section is where you trigger an event that challenges the player and makes them react (for example, an engine failure, a storm, or an enemy attack).
* The third section is where you conclude the mission and let the player reflect on their performance and enjoy their success (or failure).
* You can also add some twists or surprises along the way.  


You'll also need to prepare the conditions of your flight; what will be the plane, time, location, route, and weather of your mission? Are there other planes flying around or parked on the airport? And how much assistance will you give the player?
=== Give your players the freedom to choose their own path ===


Lastly, your mission will need sound files for the mission speech and some text and images for the briefing, loading, and ending screens.
You can also provide different threads or options for each section, depending on the player’s choices or actions. This will make your mission more dynamic and replayable, as the player can try different approaches or strategies. You can make your mission react to the player’s choices by changing the dialogue, the environment, or the difficulty. You can also use choke-points to connect your sections and keep your mission consistent. Choke-points are specific locations or conditions that mark the end of one section and the start of another. For example, in your introduction, the choke-point could be reaching the head of the valley. No matter which path the player took, they have to reach that point to trigger the next section. Choke-points help you keep track of your mission progression and avoid inconsistencies or errors. They also help you create different combinations of sections and options. For example, if you have three sections, each with three options, you can have nine different ways of flying a single mission.


== Before coding ==
== Turn your story into a mission ==
=== Come up with a basic storyline ===
Now for the most fun part you will make your idea into a real mission that you can play.
The first step of creating a mission is coming up with a scenario and story. You can make a tutorial, emergency scenario, even a treasure hunt, but you will need to think of a mission progression. What is the start of the mission? What will you need to tell the player and what will they have to find out on their own? What are the possible ways to complete the mission? Are there branching paths? And of course, how will the mission end? Will the player receive a grade or reward?
First, you need to plan the flow of the mission. This means how the mission goes from start to finish. You can use paper and a pencil to draw the flow. This will help you see the logic of the mission without worrying about coding.
For example, let’s say your mission has these steps:
# You take off from the airport.
# You hear some speech after 30 seconds.
# You have three ways to get to point B, where the next part of the mission starts.
You can draw three boxes on the paper and write the steps inside them: 'Takeoff', 'Speech', and 'At point B'. The speech should happen 30 seconds after takeoff, so note that down next to the Speech box. Then you can draw three lines from the “Speech” box to the “At point B” box. These are the three paths the player can follow. On each line, you can write what you need to do: disable the other two paths and enable the next part of the mission.


It can help to have a written structure. Think of it as a screenplay, and follow the same three-stage layout.
Now that you have a good map of your mission flow, it will be easier to code it later.


The first section is your introduction. You need to get the player's interest, explain who they are and why they're there. You use the first bit to get everything set up so that when The Exciting Thing happens, they know why and what to do about it.
=== Actions and triggers ===


In part two, The Exciting Thing happens. It doesn't matter what it is, but assuming you have some kind of event to which the player is supposed to react, this part details what happens. Once they've managed to cope with the situation and get it under control, they move on to...
Next, you need to choose the elements you will use to turn your mission map into code. The main elements of a mission are [[MSFS_Mission_Script_-_Actions|Actions]] and [[MSFS_Mission_Script_-_Triggers|Triggers]]. These elements let you check things and do things in your mission. For example, you can check if the player is flying high or low, or if they are in a certain area. You can also do things like play speech, activate or deactivate objects, or change the difficulty.


Part three, the conclusion. Having successfully dealt with the engine fire/squalling brats in the back seats/condor-strike, the player gets to reflect on what they've done and enjoy the feeling of success for a little while. You could always throw in a last-minute plot twist of course.
To keep the example going, you might have a [[Property Trigger]] checking "Altitude AGL > 10" to test for takeoff. That would start a 30-second [[Timer Trigger]] using an [[Object Activation Action]] which, in turn, would call a [[Dialog Action]] for your "Speech" box. You would need one Trigger per potential path; they might be set to detect altitude, or heading, or more likely that the player has entered an area. Each of those would need another [[Dialog Action]] (just to keep the player informed), an [[Object Activation Action]] to enable the Trigger that checks "At Point B" and another [[Object Activation Action]] to disable the other two paths.  


Structuring like this gives you a tidy way of making your mission appear much more complex. You can easily provide different threads, or ways of achieving something, without too much extra effort. Let's say your Introduction sees the player getting from a bush strip to the head of a particular valley. You start with them following the river, simple enough. Later on, you could add the option to fly across the peaks and save time; as long as they reach the same head of the same valley, the rest of the mission isn't affected. If they've tried the mission before and failed, chances are they'll decide to try shortcuts anyway. Wouldn't it feel better if, having decided to cross the ridge instead of fly round, the mission reacts to that by saying "Hey, you're going over the ridge! A bit risky in this weather but the views will be stunning"? You can issue different Rewards, or maybe even alter how the next section plays out, depending on the path they took.
== Create a mission project ==
 
=== Start with the SimpleMission sample project ===
In short, you can see your mission sections as leading up to choke-points, such as the head of the valley. If you have three sections, each with three different ways of achieving it, that's nine different ways of flying a single mission.
 
 
=== Turn your story into a mission ===
Now comes the longest, and hopefully the most fun part; turning your idea into an immersive mission.
 
First, you have to clearly define the flow of the mission. You may find it easier to have a big sheet of paper and draw the mission out in pencil before you start coding. That lets you work out how it fits together logically without having to worry about whether or not you've got the spelling right.
 
For example, you know that after you take off you want to have some speech, and then there are three ways of getting from A to B, where the next section starts. OK, so that's three boxes to draw; 'Takeoff', 'Speech' and 'At point B'. The speech should happen 30 seconds after takeoff, so note that down next to the Speech box. Then you can draw three lines between 'Speech' and 'At Point B' to show the three paths, and the first thing to do on each path is disable the other two paths.
 
Already you've got a decent map of what happens in what order, and translating from these into actual mission-system code will be easier.
 
Read the list of possible [[MSFS_Mission_Script_-_Actions|Actions]] and [[MSFS_Mission_Script_-_Triggers|Triggers]], to find out what kinds of things you can check for and do. Try and spot a likely match for each of the boxes on your sheet of paper.
 
To keep the example going, you might have a [[Property Trigger]] checking "Altitude AGL > 10" to test for takeoff. That would start a 30-second [[Timer Trigger]] using an [[Object Activation Action] which, in turn, would call a [[Dialog Action]] for your "Speech" box. You would need one Trigger per potential path; they might be set to detect altitude, or heading, or more likely that the player has entered an area. Each of those would need another [[Dialog Action]] (just to keep the player informed), an [[Object Activation Action]] to enable the Trigger that checks "At Point B" and another [[Object Activation Action]] to disable the other two paths.
 
 
=== Create a mission project ===
==== Using the SimpleMission sample project ====
You can use the SimpleMission sample project. [https://flightsim.to/file/23934/mission-creation-resources Download it] and complete [[SimpleMission_(MSFS)#Step_1:_Download_the_SimpleMission_project|step 1 and 2 of the guide]].
You can use the SimpleMission sample project. [https://flightsim.to/file/23934/mission-creation-resources Download it] and complete [[SimpleMission_(MSFS)#Step_1:_Download_the_SimpleMission_project|step 1 and 2 of the guide]].


 
== Decide on flight conditions ==
=== Decide on flight conditions ===
Next, you will have to configure the flight conditions. To start, you can create a [[flightplan (MSFS)|flight plan]] in the worldmap or with [[Little Navmap]]. This flight plan will be shown to the player when the mission starts, so it shouldn't spoil the unexpected parts of the flight (e.g., an emergency).  
Next, you will have to configure the flight conditions. To start, you can create a [[flightplan (MSFS)|flight plan]] in the worldmap or with [[Little Navmap]]. This flight plan will be shown to the player when the mission starts, so it shouldn't spoil the unexpected parts of the flight (e.g., an emergency).  


Then you decide on the starting point of the mission (e.g., at the beginning of the flight or in the air somewhere along the route).  
Then you decide on the starting point of the mission (e.g., at the beginning of the flight or in the air somewhere along the route).  


==== [[Flight_file_(MSFS)|Create the flight file]] ====
=== [[Flight_file_(MSFS)|Create the flight file]] ===
Load the flightplan and select the desired starting location in the worldmap. Now choose the aircraft, livery, fuel, payload, and atc options. Then choose the time, weather preset, and the multiplayer and traffic settings. Load the flight. Set up the aircraft how you want it (lights, switches, autopilot, etc.). You can customize the weather and save it as a preset. Lastly, locate the plane exactly where you want it, with the correct speed and trim settings. Then click <code>ESC</code> to pause the game and then <code>SPACE</code> to save the flight as a <code>.FLT</code>. Move the flight file and flightplan to the mission project.
# Load your flightplan and pick your starting location in the worldmap.  
# Select your aircraft, livery, fuel, payload, and atc options.  
# Choose your time, weather preset, and the multiplayer and traffic settings.  
# Load your flight.  
# Set up your aircraft as you want it (lights, switches, autopilot, etc.).  
# You can customize the weather and save it as a preset.  
# Position your plane exactly where you want it, with the correct speed and trim settings.  
# Pause the game and save the flight as a <code>.FLT</code> and as a <code>.PLN</code>.
# Move your flight file and flightplan to the mission folder in PackageSources.


You will need to [[Flight_file_(MSFS)#Creating_your_flight_file|manually edit the .FLT]] to choose the assistance preset, mission category, traffic, briefing and loading screen. You can use the .FLT in the [https://flightsim.to/file/23934/mission-creation-resources SimpleMission project] as a reference.
You will need to [[Flight_file_(MSFS)#Creating_your_flight_file|manually edit the .FLT]] to choose the assistance preset, mission category, traffic, briefing and loading screen. You can use the .FLT in the [https://flightsim.to/file/23934/mission-creation-resources SimpleMission project] as a reference.


===== Add pictures =====
==== Add pictures ====
Lastly, you will have to add pictures for the mission thumbnail, and the loading, briefing, and ending screens. The names for the loading an briefing pictures are defined in the [[Flight_file_(MSFS)#Creating_your_flight_file|.FLT file]]. The thumbnail will need to be named: <code>Activity_Widget.jpg</code> and the endscreen picture will need to be named: <code>rewardscreen.jpg</code>. You can use the pictures in the [https://flightsim.to/file/23934/mission-creation-resources SimpleMission project] as a reference.
Add pictures for your mission thumbnail, and the loading, briefing, and ending screens. The names for the loading an briefing pictures are defined in the [[Flight_file_(MSFS)#Pictures|.FLT file]]. The thumbnail will need to be named: <code>Activity_Widget.jpg</code> and the endscreen picture will need to be named: <code>rewardscreen.jpg</code>. You can use the pictures in the [https://flightsim.to/file/23934/mission-creation-resources SimpleMission project] as a reference.
 
==== [[Weather definitions (MSFS)|Define custom weather]]  ====
You can customize the weather with the weather panel during flight. Save it as a new preset. You can find the .WPR file in <code>\AppData\Roaming\Microsoft Flight Simulator\Weather\Presets\</code>. Move it next to the .flt file and rename it to <code>Weather.WPR</code>. You can fine-tune the weather by editing the .WPR file in Notepad++. You can use the .WPR in the [https://flightsim.to/file/23934/mission-creation-resources SimpleMission project] as a reference.
 
 
=== Set up a [[:Category:MSFS Mission Script|mission script]] ===
You can set up a [[Category:MSFS_Mission_Script|mission script]] with the SimpleMission sample project. The project contains an .xml you can use as a starting point. [https://flightsim.to/file/23934/mission-creation-resources Download it] and complete [[SimpleMission_(MSFS)#Step_3:_Open_the_project_folder|step 3 of the guide]].
 
 
 
== Coding your mission ==
Now you will turn your mission diagram from [[#Turn_your_story_into_a_mission|Chapter 2.2]] into a mission script. For this you can use the script editor.
 
 
=== Script editor ===
With the project open, select your mission asset group and click load in editor:
 
[[File:OpenScriptEditor.png|500px|thumb|left|How to open the script editor]]<br clear=all>
 
With the built-in script editor you can create the mission with a visual representation of the script. All building blocks of the mission – such as triggers and actions – are represented by nodes (also called '''''mission objects'''''). Each node contains some settings specific to the building block and can be connected to other nodes.
 
[[File:BasicMissionNodes.png|700px|thumb|left|Some of the nodes of a basic mission]]<br clear=all>
 
Nodes have two types of connections. Connections on the right size are references to other nodes and connections on the left size means the node is referenced by other nodes.


You can use special comment nodes to clarify the working of complex missions:
=== [[Weather definitions (MSFS)|Define custom weather]]  ===
# Change the weather with the weather panel during flight.
# Save it as a new preset.
# Find the .WPR file in <code>\AppData\Roaming\Microsoft Flight Simulator\Weather\Presets\</code>.
# Move it mission folder (next to the .flt) and rename it to <code>Weather.WPR</code>.
# Tweak the preset by editing the .WPR file in Notepad++. See [https://docs.flightsimulator.com/html/Content_Configuration/Flights_And_Missions/Weather_Definitions.htm the documentation].


[[File:CommentNodes.png|500px|thumb|left|Comment nodes used to show the working of a block of nodes]]<br clear=all>
== Set up a [[:Category:MSFS Mission Script|mission script]] ==
Continue with the [https://flightsim.to/file/23934/mission-creation-resources SimpleMission sample project] and complete [[SimpleMission_(MSFS)#Step_3:_Open_the_project_folder|step 3 of the guide]].


== Code your mission ==
You need to turn your mission diagram into a mission script with the script editor. For everything that happens in your mission, you need to choose and add the correct triggers and link them to actions.


=== [[:Category:MSFS_Mission_Script#Building_blocks|Script Building Blocks]] ===
=== Script Building Blocks ===
There are different [[Category:MSFS_Mission_Script#Building_blocks|types of nodes]] that you can use to make your mission.
There are different [[Category:MSFS_Mission_Script#Building_blocks|types of nodes]] that you can use to make your mission.


==== [[MSFS Mission Script - Triggers|Triggers]] & [[MSFS Mission Script - Actions|Actions]] ====
==== [[MSFS Mission Script - Triggers|Triggers]] & [[MSFS Mission Script - Actions|Actions]] ====
The basic parts of a mission script are triggers and actions. When a trigger ‘fires’, it can start different actions and activate other triggers. A bunch of these together makes up a basic mission.  
Triggers and actions are fundamental components of a mission, working together to create an engaging experience. Triggers act as checkpoints, monitoring events or conditions, while actions determine what happens when those conditions are met. Triggers check for specific events or conditions, activating actions that perform tasks like activating objects, adjusting timers, displaying messages, playing sounds, and modifying goals. By combining triggers and actions, mission creators can script the flow and behavior of the mission, crafting interactive experiences for players.


==== [[MSFS Mission Script - Mission objects|Mission objects]] ====
==== [[MSFS Mission Script - Mission objects|Mission objects]] ====
Mission objecs define a range of things like mission type, goals, world traffic, camera, and thermals.
Mission objects define a range of things like mission type, goals, world traffic, and a custom camera.


==== [[MSFS Mission Script - Calculator|Calculators]] ====
==== [[MSFS Mission Script - Calculator|Calculators]] ====
Line 127: Line 115:
{{blockquote|1='''[[:Category:MSFS_Mission_Script#Building_blocks|Look here for a complete overview of objects.]]'''}}
{{blockquote|1='''[[:Category:MSFS_Mission_Script#Building_blocks|Look here for a complete overview of objects.]]'''}}


=== Script editor ===
To turn your mission map into a mission script, we will use the script editor. It allows you to create the mission with a visual representation of the script. All building blocks of the mission – such as triggers and actions – are represented by nodes (also called '''''mission objects'''''). Each node contains some settings specific to the building block and can be connected to other nodes. Nodes have ingoing and outgoing connections. Connections on the right size are references to other nodes and connections on the left size means the node is referenced by other nodes.
[[File:BasicMissionNodes.png|700px|thumb|left|Some of the nodes of a basic mission]]<br clear=all>
=== Loading a script ===
To start using the script editor, open the mission project, select your mission asset group, and click load in editor:


=== Creating your mission script ===
[[File:OpenScriptEditor.png|500px|thumb|left|How to open the script editor]]<br clear=all>
You need to turn your mission diagram into a mission script with the script editor. For everything that happens in your mission, you need to choose and add the correct triggers and link them to actions. For each trigger you have to think: maybe you want something to happen after 10 seconds, or when the plane is at a particular location? There are many triggers too choose from, so you will need to familiarize yourself with [[MSFS_Mission_Script_-_Triggers|all the triggers available to you]], so you can choose the one you need.


==== Placing objects in the world ====
=== Adding objectives to your mission ===
Before you can place objects in the world you have to start a flight and load the mission. The process for loading the mission is described in [[#Testing_the_mission|Chapter 4]].
Once you have loaded a script in the script editor, you can start adding objectives to your mission. Objectives are the goals that the player needs to achieve or avoid to complete the mission. They also provide feedback and guidance to the player during the mission.  


==== The main mission object ====
Each objective has a state that shows how the player is doing:
You use the mission object to add objectives and an ending to your mission. You can [[MSFS_Mission_Script_-_Mission_objects#List_of_Mission_Types|choose from different types]], according to the type of mission you're creating.
* ''Completed:'' The player completed the objective.
* ''Failed:'' The player failed the objective.  
* ''Aborted:'' The player aborted the objective.


===== Objectives and goal nodes =====
If any ''mandatory'' objective is Failed or Aborted, the mission ends with a popup and a short message. If all ''mandatory'' objectives are Completed, the mission ends with a debriefing and a reward screen.
You can add objectives to your mission that determine the mission ending. Each objective has a state that can determine the mission ending. If any objective is set to ''Failed'' or ''Aborted'', the mission ends with pupup and a short message. If all objectives are set to ''Completed'', the mission ends with a debriefing / rewardscreen.


Objectives can be ''Optional'', which means they don't lead to a mission ending at failure and aren't needed to complete the mission, but they still shop up in the ''objectives panel''.
By default, all objectives are ''mandatory''. If you don't want this, set the objective to be ''Optional''. The player can skip or fail optional objectives without ending the mission. But they still show up in the objectives panel, so the player can try them if they want.


To set and change the states of objectives, you have to link each objective with a [[MSFS_Mission_Script_-_Mission_objects#Goals|Goal or SubGoal node]]. This node has the same states as objectives. You can set the starting state in the node. You have to use a [[(Sub)Goal_Resolution_Action|(Sub)GoalResolutionAction]] to change the state throughout the mission.
To use objectives, you need to link each to a [[MSFS_Mission_Script_-_Mission_objects#Goals|Goal or SubGoal node]]. The goal node determines the state of the objective it is linked to. You also set the initial state in the goal node. To change the state during the mission, you need to use a [[(Sub)Goal_Resolution_Action|(Sub)GoalResolutionAction]].


'''Steps'''
==== Steps ====
Objectives can have steps that show up in the objectives panel:
You can also add steps to your objectives. Steps are smaller tasks that help the player complete the objective. They show up in the objectives panel too:


[[File:ObjectivesPanel.jpg|500px|thumb|left|View of objectives and steps in the objectives panel]]<br clear=all>
[[File:ObjectivesPanel.jpg|500px|thumb|left|View of objectives and steps in the objectives panel]]<br clear=all>


==== Managing triggers ====
=== Comments ===
To prevent triggers from firing at unintended moments, you need to make sure triggers are only active when they are needed. Most triggers should start out deactivated and be activated with an [[Object_Activation_Action|ObjectActivationAction]] when the previous trigger in the mission's flow has fired.
As you create your mission script, you may want to add some comments in the script editor. Comments are nodes that you can add in the script editor to explain what each node or connection does. They can help you organize your script and make it easier to understand and edit later. Comments are not part of the mission script and do not affect how it works. They are only visible in the script editor.
 
[[File:CommentNodes.png|500px|thumb|left|Comment nodes used to show the working of a block of nodes]]<br clear=all>


[[File:MissionFlowchartTrigger.png|600px|thumb|left|A trigger to warn the player of a low altitude has to be active at the appropriate time]]<br clear=all>
=== Placing objects in the world ===
You can precisely place objects in the world using the script editor and the gizmo. First, [[#Testing_the_mission|compile and start your mission]]. When the world is loaded, you can add different kinds of objects:
* [[MSFS_Mission_Script_-_Areas|Areas]], for use in [[Proximity_Trigger|proximity triggers]].
* Static scenery objects with [[MSFS_Mission_Script_-_Library_Objects|library objects]].
* [[MSFS_Mission_Script_-_Sim_Objects|Simobjects]], using containers or flocks.
* [[MSFS_Mission_Script_-_Areas#InGameMarker|Markers]] and [[MSFS_Mission_Script_-_Mission_objects#PointOfInterest|POI's]].
* [[MSFS_Mission_Script_-_Mission_objects#Racing_.2F_Multiplayer|Race points]].
* A custom [[MSFS_Mission_Script_-_Mission_objects#Camera|camera]].
* A landing zone for [[MSFS_Mission_Script_-_Mission_objects#List_of_Mission_Types|landing challenges]].
* A [[MSFS_Mission_Script_-_Calculator#List_of_parameter_types|path for a calculator]].


Triggers have a property called ''OneShot''. If it is enabled, the trigger will deactivate itself after it has fired. But some triggers won't fire in every playthrough, such as the llow altitude warning of the example above. If you aren't sure the trigger will deactivate itself, you should deactivate it manually with an ''ObjectActivationAction'' when the trigger isn't needed anymore.
If the object has a [[World_position_(MSFS)|world position]], it will spawn in the middle of your view.  


==== Unconnected nodes ====
To change the location, you can move the object with the Gizmo. For gizmo options, in the script editor click <code>View > Gizmo</code>.  
You can use the script editor to look for breaks in your mission logic. All nodes that aren't referenced by another node are marked with a white dot:


[[File:Script editor example.jpg|300px|thumb|left|Script object overview]]<br clear=all>
With the Developer Camera enabled you can double click on the objects in the script editor and the camera will go to their location.


This may be a sign of trouble. For actions this means they aren't executed. For triggers this means they will either be active from the beginning or they will always be disabled. For some nodes such as the main [[MSFS_Mission_Script_-_Mission_objects#Defining_the_mission_type|mission object]] this isn't an issue.
[[File:MissionGizmo.jpg|700px|thumb|left|Area with gizmo and gizmo options]]<br clear=all>


== Test, optimize, and debug your mission ==
In this section, you will learn how to test, optimize, and debug your mission. You will use the script editor and other tools to check for errors and fix problems in your mission script.


=== Testing the mission ===
=== Testing the mission ===
The first step to test your mission script is to compile the mission. Compiling the mission means turning your script into a file that can be loaded and played by MSFS. When you build your project, the mission will get compiled and turned into an .SPB file.
==== Console ====
The [https://docs.flightsimulator.com/html/Developer_Mode/Menus/Debug/The_Console.htm console] is where you can see the results of compiling the mission. It shows you any errors or warnings in your script. You need to fix any errors before you can play your mission. Warnings are not critical, but they may indicate potential problems or improvements in your script.


To quickly test your mission, you can load a flight and then load your mission from a project, as described in [[#Quickly_load_flight_and_mission|Paragraph 4.1]]. However, this won't work for all triggers (such as the intro TimerTrigger). To test your mission more reliably, you first have to build your project and then load the mission flight, as described in [[#Build_project_and_load_the_mission|Paragraph 4.2]].
==== Start the mission ====
When your script has successfully compiled, you can start the mission. To do that, go to custom activities and select your mission.


==== Quickly load flight and mission ====
=== Loading and updating your mission elements ===
You can quickly start a flight without building your project:
With the script editor open you can see if the elements are loaded in the mission. To add elements, click the plus in the overview window and select the element you want to add.


#Start a flight in the right area or load your mission .FLT.
If the names are white, they are loaded, but if they are red, it means they are not loaded. While working on your mission, you can update the elements by clicking <code>Script Editor > Game > Update</code>.
#Load the mission in the script editor.
#In the script editor, click <code>Game > Update</code>.


==== Build project and load the mission ====
[[File:ScriptEditorOverview.png|400px|thumb|left|Script object overview]]<br clear=all>
To test your mission more reliably, you first have to build your project and then load the mission flight:


#Build the project.
=== World objects debug ===
#Go to custom activities and select your mission.
When the mission is loaded in, make sure <code>Debug > World Objects</code> is enabled. Now you will see your areas and waypoints overlayed in the world.  


==== How to edit the mission while it's loaded in ====
=== Debugging calculators ===
When the mission is loaded in, make sure <code>Options > World Objects</code> is enabled.
You can debug [[MSFS_Mission_Script_-_Calculator|calculators]] by enabling *DisplayAllowed* and using &lt;code>Options > Flight Object Debug</code>. Now you can see the parameters and actions of your calculator in real time.


Now you will see your areas overlayed in the world. With the script editor open you can see if the objects are loaded in the mission. If the names are white, they are loaded, but if they are red it means they are not loaded. While working on your mission, you can update the objects by clicking <code>Script Editor > Game > Update</code>.
=== Managing triggers ===
You will use many triggers in your mission, but you need to control when they are active. Otherwise, they may fire at the wrong time and cause problems or confusion.


[[File:ScriptEditorOverview.png|400px|thumb|left|Script object overview]]<br clear=all>
For example, imagine you have a trigger that tells the player off if they fly too low during cruise. You don’t want this trigger to fire when the player is landing, because they have to go down to the runway. That would be confusing and annoying.
 
To avoid this, you need to activate and deactivate triggers at the right moments. Most triggers should start inactive and become active with an [[Object_Activation_Action|ObjectActivationAction]] when the previous trigger in the mission’s flow has fired. You should also use an [[Object_Activation_Action|ObjectActivationAction]] to deactivate them when they are not needed anymore.


To add objects, click the plus in the overview window and select the object you want to add. If the object has a [[World_position_(MSFS)|world position]], it will spawn in the middle of your view. To change the location, you can move the object with the Gizmo. For gizmo options, in the script editor click <code>View > Gizmo</code>.
[[File:MissionFlowchartTrigger.png|600px|thumb|left|A trigger to warn the player of a low altitude has to be active at the appropriate time]]<br clear=all>


With the Developer Camera enabled you can double click on the objects in the script editor and the camera will go to their location.
Triggers have a property called OneShot. If you enable this property, the trigger will deactivate itself after it has fired. This can save you some time and nodes, but be careful not to use it for triggers that you want to fire more than once.


[[File:MissionGizmo.jpg|700px|thumb|left|Area with gizmo and gizmo options]]<br clear=all>
=== Unconnected nodes ===
You can use the script editor to look for breaks in your mission logic. All nodes that aren't referenced by another node are marked with a white dot.


If nodes are 'isolated' like this, they may not function as expected.
* Actions that are never referenced won't execute.
* Triggers that aren't referenced by a [[Object_Activation_Action|ObjectActivationAction]] aren't properly managed.
* For some nodes, such as the main [[MSFS_Mission_Script_-_Mission_objects#Defining_the_mission_type|mission object]], this isn't an issue.


=== Debugging mission ===
[[File:Script editor example.jpg|300px|thumb|left|Script object overview]]<br clear=all>
You can't really use the script editor to view the state of the mission during testing, so your options for debugging are limited. You can debug [[MSFS_Mission_Script_-_Calculator|calculators]] by enabling *DisplayAllowed* and using &lt;code>Options > Flight Object Debug</code>.


== Exporting the mission ==
To compile the mission for export, click <code>Clean All</code>, then <code>Build All</code>. Make sure there are no errors in the console from the building process. Then click <code>Build & Export</code>, ensure the mission package is checkmarked, choose <code>Community Publishing</code>, and select the Export Directory.


=== Exporting the mission ===
To compile the mission for export, click <code>Clean All</code>, then <code>Build All</code>, Make sure there are no errors in the console from the building process. Then click <code>Build & Export</code>, ensure the mission package is checkmarked, choose <code>Community Publishing</code>, and select the Export Directory.


== Conclusion ==
I hope you enjoyed this tutorial and found it useful. Creating a mission is a complex and creative task that requires a lot of skills and patience. But it is also very rewarding and fun. You can make any kind of mission you want, from tutorials to emergencies to adventures. You can give your players the freedom to choose their own path and make your mission dynamic and replayable.




If you want to learn more about creating missions for MSFS, you can check out these pages:
{{Template:Navbox-Mission-Creation-MSFS}}
{{Template:Navbox-Mission-Creation-MSFS}}

Revision as of 05:41, 21 May 2023


Overview

Creating a mission involves using different tools and skills. While it may be challenging to get your first mission up and running, once you understand the basic rules and files that make up a mission, the possibilities are endless. Essentially, a mission is a scripted set of events that tells a story, ranging from exciting scenarios like mountain rescues or engine problems to simpler flights with interesting points along the way.

To turn your mission idea into a playable experience, you need to plan the mission flow and then code it. Start by outlining the flow on paper, showing how the mission progresses from start to finish. Next, select and use triggers and actions to create the mission's logic. Triggers check for conditions or events, while actions allow you to modify and control various aspects of the mission. You can also use objectives to give the player a clear sense of direction and purpose. Once you've scripted your mission, you can fine-tune and test it using the script editor, console for error checking, and tools for finding and fixing problems.

With patience and creativity, you can create rewarding and enjoyable missions that captivate players and keep them coming back for more!

Come up with a scenario and story

You need to decide what kind of mission you want to create, for example, a tutorial, an emergency scenario, or a treasure hunt. You also need to think of how the mission will progress from start to finish.

  • How will you introduce the player to the mission and explain their role and objective?
  • What will you reveal to the player and what will they have to discover on their own?
  • What are the possible ways that the player can complete the mission? Are there branching paths or different outcomes?
  • How will you end the mission and give feedback or rewards to the player?

It can help to have a written structure that outlines your mission in detail. You can follow the same three-stage layout as a screenplay. This gives you a clear and coherent way of telling your story.

  • The first section is your introduction, where you need to capture the player’s interest and set up the context and premise of the mission.
  • The second section is where you trigger an event that challenges the player and makes them react (for example, an engine failure, a storm, or an enemy attack).
  • The third section is where you conclude the mission and let the player reflect on their performance and enjoy their success (or failure).
  • You can also add some twists or surprises along the way.

Give your players the freedom to choose their own path

You can also provide different threads or options for each section, depending on the player’s choices or actions. This will make your mission more dynamic and replayable, as the player can try different approaches or strategies. You can make your mission react to the player’s choices by changing the dialogue, the environment, or the difficulty. You can also use choke-points to connect your sections and keep your mission consistent. Choke-points are specific locations or conditions that mark the end of one section and the start of another. For example, in your introduction, the choke-point could be reaching the head of the valley. No matter which path the player took, they have to reach that point to trigger the next section. Choke-points help you keep track of your mission progression and avoid inconsistencies or errors. They also help you create different combinations of sections and options. For example, if you have three sections, each with three options, you can have nine different ways of flying a single mission.

Turn your story into a mission

Now for the most fun part you will make your idea into a real mission that you can play. First, you need to plan the flow of the mission. This means how the mission goes from start to finish. You can use paper and a pencil to draw the flow. This will help you see the logic of the mission without worrying about coding. For example, let’s say your mission has these steps:

  1. You take off from the airport.
  2. You hear some speech after 30 seconds.
  3. You have three ways to get to point B, where the next part of the mission starts.

You can draw three boxes on the paper and write the steps inside them: 'Takeoff', 'Speech', and 'At point B'. The speech should happen 30 seconds after takeoff, so note that down next to the Speech box. Then you can draw three lines from the “Speech” box to the “At point B” box. These are the three paths the player can follow. On each line, you can write what you need to do: disable the other two paths and enable the next part of the mission.

Now that you have a good map of your mission flow, it will be easier to code it later.

Actions and triggers

Next, you need to choose the elements you will use to turn your mission map into code. The main elements of a mission are Actions and Triggers. These elements let you check things and do things in your mission. For example, you can check if the player is flying high or low, or if they are in a certain area. You can also do things like play speech, activate or deactivate objects, or change the difficulty.

To keep the example going, you might have a Property Trigger checking "Altitude AGL > 10" to test for takeoff. That would start a 30-second Timer Trigger using an Object Activation Action which, in turn, would call a Dialog Action for your "Speech" box. You would need one Trigger per potential path; they might be set to detect altitude, or heading, or more likely that the player has entered an area. Each of those would need another Dialog Action (just to keep the player informed), an Object Activation Action to enable the Trigger that checks "At Point B" and another Object Activation Action to disable the other two paths.

Create a mission project

Start with the SimpleMission sample project

You can use the SimpleMission sample project. Download it and complete step 1 and 2 of the guide.

Decide on flight conditions

Next, you will have to configure the flight conditions. To start, you can create a flight plan in the worldmap or with Little Navmap. This flight plan will be shown to the player when the mission starts, so it shouldn't spoil the unexpected parts of the flight (e.g., an emergency).

Then you decide on the starting point of the mission (e.g., at the beginning of the flight or in the air somewhere along the route).

Create the flight file

  1. Load your flightplan and pick your starting location in the worldmap.
  2. Select your aircraft, livery, fuel, payload, and atc options.
  3. Choose your time, weather preset, and the multiplayer and traffic settings.
  4. Load your flight.
  5. Set up your aircraft as you want it (lights, switches, autopilot, etc.).
  6. You can customize the weather and save it as a preset.
  7. Position your plane exactly where you want it, with the correct speed and trim settings.
  8. Pause the game and save the flight as a .FLT and as a .PLN.
  9. Move your flight file and flightplan to the mission folder in PackageSources.

You will need to manually edit the .FLT to choose the assistance preset, mission category, traffic, briefing and loading screen. You can use the .FLT in the SimpleMission project as a reference.

Add pictures

Add pictures for your mission thumbnail, and the loading, briefing, and ending screens. The names for the loading an briefing pictures are defined in the .FLT file. The thumbnail will need to be named: Activity_Widget.jpg and the endscreen picture will need to be named: rewardscreen.jpg. You can use the pictures in the SimpleMission project as a reference.

Define custom weather

  1. Change the weather with the weather panel during flight.
  2. Save it as a new preset.
  3. Find the .WPR file in \AppData\Roaming\Microsoft Flight Simulator\Weather\Presets\.
  4. Move it mission folder (next to the .flt) and rename it to Weather.WPR.
  5. Tweak the preset by editing the .WPR file in Notepad++. See the documentation.

Set up a mission script

Continue with the SimpleMission sample project and complete step 3 of the guide.

Code your mission

You need to turn your mission diagram into a mission script with the script editor. For everything that happens in your mission, you need to choose and add the correct triggers and link them to actions.

Script Building Blocks

There are different that you can use to make your mission.

Triggers & Actions

Triggers and actions are fundamental components of a mission, working together to create an engaging experience. Triggers act as checkpoints, monitoring events or conditions, while actions determine what happens when those conditions are met. Triggers check for specific events or conditions, activating actions that perform tasks like activating objects, adjusting timers, displaying messages, playing sounds, and modifying goals. By combining triggers and actions, mission creators can script the flow and behavior of the mission, crafting interactive experiences for players.

Mission objects

Mission objects define a range of things like mission type, goals, world traffic, and a custom camera.

Calculators

You can use calculators for more advanced logic in your mission. It can take in multiple variables and trigger different actions based on a logic. You can also use this to calculate a mission score and probably many more applications which you can explore.

Script editor

To turn your mission map into a mission script, we will use the script editor. It allows you to create the mission with a visual representation of the script. All building blocks of the mission – such as triggers and actions – are represented by nodes (also called mission objects). Each node contains some settings specific to the building block and can be connected to other nodes. Nodes have ingoing and outgoing connections. Connections on the right size are references to other nodes and connections on the left size means the node is referenced by other nodes.

Some of the nodes of a basic mission


Loading a script

To start using the script editor, open the mission project, select your mission asset group, and click load in editor:

How to open the script editor


Adding objectives to your mission

Once you have loaded a script in the script editor, you can start adding objectives to your mission. Objectives are the goals that the player needs to achieve or avoid to complete the mission. They also provide feedback and guidance to the player during the mission.

Each objective has a state that shows how the player is doing:

  • Completed: The player completed the objective.
  • Failed: The player failed the objective.
  • Aborted: The player aborted the objective.

If any mandatory objective is Failed or Aborted, the mission ends with a popup and a short message. If all mandatory objectives are Completed, the mission ends with a debriefing and a reward screen.

By default, all objectives are mandatory. If you don't want this, set the objective to be Optional. The player can skip or fail optional objectives without ending the mission. But they still show up in the objectives panel, so the player can try them if they want.

To use objectives, you need to link each to a Goal or SubGoal node. The goal node determines the state of the objective it is linked to. You also set the initial state in the goal node. To change the state during the mission, you need to use a (Sub)GoalResolutionAction.

Steps

You can also add steps to your objectives. Steps are smaller tasks that help the player complete the objective. They show up in the objectives panel too:

View of objectives and steps in the objectives panel


Comments

As you create your mission script, you may want to add some comments in the script editor. Comments are nodes that you can add in the script editor to explain what each node or connection does. They can help you organize your script and make it easier to understand and edit later. Comments are not part of the mission script and do not affect how it works. They are only visible in the script editor.

Comment nodes used to show the working of a block of nodes


Placing objects in the world

You can precisely place objects in the world using the script editor and the gizmo. First, compile and start your mission. When the world is loaded, you can add different kinds of objects:

If the object has a world position, it will spawn in the middle of your view.

To change the location, you can move the object with the Gizmo. For gizmo options, in the script editor click View > Gizmo.

With the Developer Camera enabled you can double click on the objects in the script editor and the camera will go to their location.

Area with gizmo and gizmo options


Test, optimize, and debug your mission

In this section, you will learn how to test, optimize, and debug your mission. You will use the script editor and other tools to check for errors and fix problems in your mission script.

Testing the mission

The first step to test your mission script is to compile the mission. Compiling the mission means turning your script into a file that can be loaded and played by MSFS. When you build your project, the mission will get compiled and turned into an .SPB file.

Console

The console is where you can see the results of compiling the mission. It shows you any errors or warnings in your script. You need to fix any errors before you can play your mission. Warnings are not critical, but they may indicate potential problems or improvements in your script.

Start the mission

When your script has successfully compiled, you can start the mission. To do that, go to custom activities and select your mission.

Loading and updating your mission elements

With the script editor open you can see if the elements are loaded in the mission. To add elements, click the plus in the overview window and select the element you want to add.

If the names are white, they are loaded, but if they are red, it means they are not loaded. While working on your mission, you can update the elements by clicking Script Editor > Game > Update.

Script object overview


World objects debug

When the mission is loaded in, make sure Debug > World Objects is enabled. Now you will see your areas and waypoints overlayed in the world.

Debugging calculators

You can debug calculators by enabling *DisplayAllowed* and using <code>Options > Flight Object Debug. Now you can see the parameters and actions of your calculator in real time.

Managing triggers

You will use many triggers in your mission, but you need to control when they are active. Otherwise, they may fire at the wrong time and cause problems or confusion.

For example, imagine you have a trigger that tells the player off if they fly too low during cruise. You don’t want this trigger to fire when the player is landing, because they have to go down to the runway. That would be confusing and annoying.

To avoid this, you need to activate and deactivate triggers at the right moments. Most triggers should start inactive and become active with an ObjectActivationAction when the previous trigger in the mission’s flow has fired. You should also use an ObjectActivationAction to deactivate them when they are not needed anymore.

A trigger to warn the player of a low altitude has to be active at the appropriate time


Triggers have a property called OneShot. If you enable this property, the trigger will deactivate itself after it has fired. This can save you some time and nodes, but be careful not to use it for triggers that you want to fire more than once.

Unconnected nodes

You can use the script editor to look for breaks in your mission logic. All nodes that aren't referenced by another node are marked with a white dot.

If nodes are 'isolated' like this, they may not function as expected.

  • Actions that are never referenced won't execute.
  • Triggers that aren't referenced by a ObjectActivationAction aren't properly managed.
  • For some nodes, such as the main mission object, this isn't an issue.
Script object overview


Exporting the mission

To compile the mission for export, click Clean All, then Build All. Make sure there are no errors in the console from the building process. Then click Build & Export, ensure the mission package is checkmarked, choose Community Publishing, and select the Export Directory.


Conclusion

I hope you enjoyed this tutorial and found it useful. Creating a mission is a complex and creative task that requires a lot of skills and patience. But it is also very rewarding and fun. You can make any kind of mission you want, from tutorials to emergencies to adventures. You can give your players the freedom to choose their own path and make your mission dynamic and replayable.


If you want to learn more about creating missions for MSFS, you can check out these pages:

Pages relevant to mission creation for MSFS.

Mission structure

Flightplan
Weather definitions
Flight file
Mission script
Triggers
AirportLandingTrigger & AreaLandingTrigger · CounterTrigger · PropertyTrigger · ProximityTrigger · TimerTrigger
Actions
ObjectActivationAction · DialogAction · AdjustPayloadAction · ChangeAssistanceItemAction · FadeToColorAction · RandomAction · RequestTeleportAction · CountAction · ResetTimerAction · TimerAdjustAction · GoalResolutionAction & SubGoalResolutionAction · GrantRewardAction · PointOfInterestActivationAction · ActivateWaypointsAction · AITakeControlsAction · SendMessageToAIAction
Mission objects
Mission definition · Goal · LivingWorldExclusion · Camera
Calculator
Flow states
Events
Areas
Rectangle Area · Cylinder Area · Polygon Area · Corridor Area · InGameMarker
Library objects
Sim objects
RTC

Mission tools

MSFS Script Editor · BushTripInjector · BushMissionGen · MSFSLocalizer · SPB2XML · Little Navmap

Other

Example mission files
Porting FSX Missions to MSFS
Localisation
Click the links to access the topic pages (Default - Opens in same window).