# Fundamentals

This tutorial walks you through building a small but complete mission with events, waypoints, messages, and a briefing. It assumes you have read the Quickstart. Budget about 30 minutes.

The mission we are building: the player escorts a friendly transport along a waypoint route to rendezvous with a friendly capital ship. Hostile fighters arrive shortly after the mission starts. If the transport completes its route, the mission succeeds.

Save often. Press `Ctrl+S` every few minutes. Test in-game after each major step. Catching problems early saves a lot of rework later.

## 1. Plan before you open QtFRED

Before placing anything, sketch out what the mission needs:

- A player fighter wing (Alpha)
- A friendly transport that needs to reach a rendezvous point
- A friendly capital ship at the destination, set as a protect target
- A hostile fighter wing that arrives ~30 seconds in
- A waypoint path for the transport to follow
- Events: a timed trigger for the hostile arrival, a radio message when they arrive
- A primary mission goal tied to the transport completing its route
- A two-stage briefing and a debriefing

Knowing this upfront prevents building yourself into a corner. You will still adjust things as you go and that is normal.

## 2. Place the ships

Open a new mission. The player ship is already there. Select it and click Form Wing, name the wing `Alpha`. Move Alpha 1 to roughly `0, 0, -2000` using the Object Orientation Editor.

Place the friendly transport near the origin. Open the Ship Editor, name it `Transport 1`, set its team to Friendly, and set its initial velocity to 0. It will start stationary and move when given orders.

Place a friendly capital ship some distance away at the end of where the transport's route will go. Name it `Command Ship` and set it to Friendly. Open its Ship Editor and click Flags to open the Ship Flags subdialog. Enable Protect Ship. This tells hostile AI not to target or attack it, making it a safe destination for the transport to reach. Velocity 0 is fine here too.

Place two hostile fighters somewhere off to the side. Select both, click Form Wing, name the wing `Epsilon`, set team to Hostile. Open the Arrival / Departure tab in the Ship Editor for each Epsilon ship and set arrival location to Hyperspace. Leave the arrival cue as `true` for now.

Save and do a quick test. All ships should appear. Epsilon will arrive immediately and that is fine for now.

## 3. Add a waypoint path for the transport

In the Other dropdown on the toolbar, select Waypoint, then `Ctrl+Alt+click` in the viewport to lay out a short route from the transport's position toward the Command Ship. Three or four points is plenty. Open the Waypoint Editor and name the path `Transport Route`.

Open the Ship Editor for Transport 1, go to Initial Orders, and set its initial goal to Waypoints Once › Transport Route. The transport will fly the route once from start to finish.

Save and test. The transport should start moving along the route.

## 4. Delay the hostile arrival with an event

Open Editors › Mission Events. Click Add event and name it `Epsilon Arrives`. Set its Condition SEXP to:

    (has-time-elapsed 30)

No action is needed in this event. It acts purely as a named trigger that other things can reference.

Now go back to the Ship Editor for each ship in Epsilon wing. In the Arrival / Departure tab, change the Arrival cue SEXP to:

    (is-event-true-delay 0 "Epsilon Arrives")

This way all of Epsilon's ships key off the same named event. If you want to change the delay later, you only need to edit the event's condition in one place.

Save and test. The first 30 seconds should be quiet, then Epsilon jumps in.

## 5. Send a message when the hostiles arrive

Messages are created and sent from the same Mission Events editor. On the right side of the dialog, click Add under the message list to create a new message. Give it the name `Epsilon Inbound` and write a short line of text such as "Hostile fighters inbound! Protect the transport!" Set a sender if desired, or leave it as `<mission>`.

Now create a new event and name it `Epsilon Arrival Message`. Set its Condition to:

    (has-arrived-delay 0 "Epsilon 1")

In the Actions tree, add a `send-message` SEXP and select `Epsilon Inbound` as the message. Leave the priority at Normal.

Save and test. The message should appear on screen as Epsilon jumps in.

## 6. Add a mission goal

Open Editors › Mission Goals. Add a primary goal:

- Description: Escort the transport to the rendezvous
- Completion condition: `(are-waypoints-done-delay 0 "Transport 1" "Transport Route")`

Add a secondary goal for destroying Epsilon wing if you like. See SEXPs for an overview of how conditions are built.

## 7. Write the briefing

Write the briefing now. Be creative and give the player a reason to protect the transport from Epsilon wing.

Open Editors › Briefing. Build two stages:

Stage | Camera | Text
--- | --- | ---
1 | Wide view of the whole scene | Explain the mission: escort the transport safely to the Command Ship.
2 | Closer on the transport's route | Warn that hostile fighters are expected; the player must intercept them while keeping the transport moving.

For each stage, position the briefing map camera, add icons for the relevant ships using Make icon from ship, and type the stage text at the bottom. See the Briefing Editor help for full details. Set the Music track at the top of the dialog.

Save and walk through the briefing before launching to check camera positions and icon placement.

## 8. Write the debriefing

Open Editors › Debriefing. Add two stages:

Stage | Usage formula | Text
--- | --- | ---
Success | `(are-waypoints-done-delay 0 "Transport 1" "Transport Route")` | The transport completed its route. Commend the player.
Failure | `(is-destroyed-delay 0 "Transport 1")` | The transport was lost. Acknowledge the failure.

Assign music tracks for success and failure in the Debriefing music section.

## 9. Final test

Save and run a full play-through. Check:

- The transport moves along its route from the start
- The first 30 seconds are calm
- Epsilon and the arrival message both trigger at 30 seconds
- The primary goal completes when the transport finishes the route
- The briefing camera moves and icons look correct
- The correct debriefing stage shows depending on outcome

## Next steps

- Add a second hostile wave that arrives when the transport is near the end of its route, using `are-waypoints-done-delay` on an earlier waypoint as the trigger.
- Add a Command Briefing before the main briefing.
- Chain this into a campaign using the Campaign Editor.