Missions (Extensions)

**Missions** are a core element of Extensions.

*For the list of missions in Hacknet, see Missions*.

## Description

Every Extension mission is defined in a single `.xml` file and, unlike other Extension elements, has a strict parser.

Every mission file is defined inside the `mission` tags:

```
<mission id="ExampleMission" activeCheck="false" shouldIgnoreSenderVerification="false">

</mission>

```

* `activeCheck`, if set to true, ensures that the mission will be checking the goal(s) for completion every frame, negating the need to reply to the e-mail.
* `shouldIgnoreSenderVerification`, if set to true, ensures that the player can reply to any sender instead of a specific one to pass the mission.

## Structure

The order of the elements is as follows:

* `goal` (Goals)
* `missionStart` (Mission start function)
* `missionEnd` (Mission end function)
* `nextMission` (Next mission)
* `branchMissions` (Branch missions)
* `posting` (Mission posting)
* `email` (Mission e-mail)

Example:

```
<!-- element REQUIRED. all attributes optional, default values shown -->
<mission activeCheck="false" shouldIgnoreSenderVerification="false">
        <!-- element REQUIRED. -->
        <goals>
                <!-- goal elements go here, but are optional. -->
        </goals>
        <!-- element and attributes optional, defaults shown. -->
        <missionStart val="0" suppress="true"><!-- N/A --></missionStart>
        <missionEnd val="0"><!-- N/A --></missionEnd>
        <!-- element REQUIRED, attribute optional. -->
        <nextMission IsSilent="false">NONE</nextMission>

        <!-- element optional. -->
        <branchMissions>
                <!-- branch elements go here, but are optional -->
        </branchMissions>

        <!-- element and attributes optional, defaults shown. -->
        <posting title="UNKNOWN" reqs="" requiredRank="0" difficulty="0" client="UNKNOWN" target="UNKNOWN">UNKNOWN</posting>

        <!-- element and all children REQUIRED. Even if IsSilent="true".  -->
        <email>
                <sender></sender>
                <subject></subject>
                <body></body>
                <attachments>
                        <!--
                        comp, link, account and note elements go here,
                        but are optional
                        -->
                </attachments>
        </email>
</mission>

```

### Goals (optional)

A mission can have any number of goals: once all goals have been met, the mission can be completed.

Goal types:

**`filedeletion`**

```
<goal type="filedeletion" target="ExampleNode" file="Example_file.txt" path="home" />
```

The goal requires the file `Example_file.txt` in the `/home` folder on the computer with the ID `ExampleNode` to be deleted, renamed or its contents changed.

**`clearfolder`**

```
<goal type="clearfolder" target="ExampleNode" path="home" />
```

The goal requires all contents of the `/home` folder on the computer with the ID `ExampleNode` to be deleted.

**`filedownload`**

```
<goal type="filedownload" target="ExampleNode" file="Example_file.txt" path="home" />
```

The goal requires the file `Example_file.txt` in the `/home` folder on the computer with the ID `ExampleNode` to be downloaded to the player's computer.

**`filechange`**

```
<goal type="filechange" target="ExampleNode" file="Example_file.txt" path="home" keyword="qwerty" caseSensitive="true" />
```

The goal requires the file `Example_file.txt` in the `/home` folder on the computer with the ID `ExampleNode` to be changed by appending `qwerty` to it, mindind the case-sensitivity.

```
<goal type="filechange" target="Example_file.txt" file="changeFile.txt" path="home" keyword="asdfgh" removal="true" />
```

The goal requires the file `Example_file.txt` in the `/home` folder on the computer with the ID `ExampleNode` to be changed by removing `asdfgh` to it, using the `replace` command.

**`fileupload`**

```
<goal type="fileupload" target="ExampleNode" file="Example_file.txt" path="home" destTarget="ExampleDropServer" destPath="Drop/Uploads" />
```

The goal requires the file `Example_file.txt` in the `/home` folder on the computer with the ID `ExampleNode` to be uploaded to the `ExampleDropServer`, `/Drop/Uploads` folder (assuming the destination server has the `uploadServerDaemon` daemon).

```
<goal type="fileupload" target="ExampleNode" file="Example_file.dec" path="home" destTarget="ExampleDropServer" destPath="Drop/Uploads" decrypt="true" decryptPass="password" />
```

The goal requires the **encrypted** file `Example_file.dec` in the `/home` folder on the computer with the ID `ExampleNode` to be uploaded to the `ExampleDropServer`, `/Drop/Uploads` folder (assuming the destination server has the `uploadServerDaemon` daemon). If the `decrypt` attribute is set to `true`, the player must decrypt the target file to complete the mission.

**`getadmin`**

```
<goal type="getadmin" target="ExampleNode" />
```

The goal requires the player to get admin status on the `ExampleNode` computer. The mission can be completed only if the player has the admin status on the system while replying to e-mail.

**`getstring`**

```
<goal type="getstring" target="password" />
```

The goal requires the player to reply to the mission e-mail with the string `password`.

**`delay`**

```
<goal type="delay" time="10.0" />
```

The goal requires the player to wait 10 seconds before replying to the e-mail.

If `activeCheck` is set to `true` in the <mission> tag, the mission will automatically complete in 10 seconds.

**`hasflag`**

```
<goal type="hasflag" target="testFlag" />
```

The goal requires the player to have a `testFlag` flag set to complete the mission.

**`AddDegree`**

```
<goal type="AddDegree" owner="John Stalvern" degree="Masters in Digital Security" uni="Manchester University" gpa="3.0" />
```

The goal requires the player to add a degree matching the details provided to the Academic Database. The database **must** have an ID `academic` and the `AcademicDatabase` daemon.

**`wipedegrees`**

```
<goal type="wipedegrees" owner="John Stalvern" />
```

The goal requires the player to delete a degree matching the details provided from the Academic Database. The database **must** have an ID `academic` and the `AcademicDatabase` daemon.

**`sendemail`**

```
<goal type="sendemail" mailServer="jmail" recipient="mailuser123" subject="Email Subject" />
```

The goal requires the player to send an e-mail to the address and with the subject specified above (in the case above, `mailuser123@jmail.com`, subject `Email Subject`).

The goal is useful for sending medical records to different addresses. The subject line for these is `MedicalRecord - Lastname_Firstname`.

**`getadminpasswordstring`**

```
<goal type="getadminpasswordstring" target="ExampleNode" />
```

The goal requires the player to reply with the admin password to the computer `ExampleNode`.

**`modifyDeathRowRecord`**

```
<goal type="modifyDeathRowRecord" name="John Boorman">I'm ready, Warden</goal>
```

The goal requires the player to create a death row record in the Death Row Database for John Boorman with the last words "I'm ready, Warden". The database **must** have an ID `deathRow` and the `deathRowDatabase` daemon.

**`removeDeathRowRecord`**

```
<goal type="removeDeathRowRecord" name="Joseph Felman" />
```

The goal requires the player to delete Joseph Felman's death row record from the Death Row Database. The database **must** have an ID `deathRow` and the `deathRowDatabase` daemon.

**`databaseEntryChange`**

```
<goal type="databaseEntryChange" comp="dPets_MF" recordName="minx" fieldName="NeoPoints" operation="greater" targetValue="999999" />
```

The goal requires the player to change the value of `NeoPoints` in the computer `dPets_MF` to the amount more than `999999`. The target computer must have the `DatabaseDaemon` daemon.

### Mission functions (optional)

*See Actions\_(Extensions)#RunFunction for the full list of mission functions.*
Missions allow running start and end functions via `missionStart` and `missionEnd`. The `val` attribute is used to pass integer value to the function.

Only one `missionStart` and `missionEnd` is allowed per mission, meaning the player can execute maximum of two various functions/sets of actions per mission.

```
<missionStart>loadConditionalActions:Actions/ExampleActions.xml</missionStart>
<missionEnd val="10">addRank</missionEnd>

```

### Next mission

The next mission is defined with the `nextMission` tag:

```
<nextMission IsSilent="false">Missions/ExampleMission2.xml</nextMission>
```

The `IsSilent` attribute, if set to `true`, silences the currently running mission, not the next one. Silenced missions do not send emails.

If there is no next mission, change the parameter to `NONE`:

```
<nextMission IsSilent="false">NONE</nextMission>
```

### Branch missions (optional)

Branch missions allow the player to have branching story paths depending on their actions.

Branch missions are loaded during the load step of this mission, and are held in parallel.
Every frame (if `activeCheck` is set to `true`) or every time an e-mail is responded to, the mission system will check the goals of the main, and if it does not pass them, it will check (in order) the goals of all the branch missions defined. If successful, the branch mission's `nextMission` will be loaded.

```
<branchMissions>
 <branch>Missions/BranchMission1.xml</branch>
 <branch>Missions/BranchMission2.xml</branch>
</branchMissions>

```

Branch missions do not send e-mails. The only tags that need to be defined for the branch missions are goals, mission functions and next mission. Do **NOT** remove the email tags and make sure the senders are the same for both the main mission and all branch missions.

### Mission posting (optional)

The posting of a mission gets put up on a hub server (`variableMissionListingServer`, `missionHubServer` or `DHSDaemon`).

```
<posting title="Example Mission Name" reqs="testFlag" requiredRank="10" client="Client" target="Target" normal="posting tags here">Brief description of the mission goes here.</posting>

```

* `reqs` are flags that are required for the mission to be unlocked.
* `requiredRank` is the rank required for the mission to be unlocked.
	+ It is best to avoid using the rank attribute as gets reset after the save file is reloaded, meaning the mission may become unlocked even if the player has lower rank.
* `client` is the client name that gets put up on `missionHubServer`.
* `target` is the target that gets put up on `missionHubServer`.
* `normal`

### Mission e-mail

The mission e-mail gets sent once the mission is loaded in.

```
<email>
 <sender>Anonymous</sender>
 <subject>Example Mission</subject>
 <body>This is the body of the email.

-Anon</body>
 <attachments>
  <note title="Example Note">Notes go here.

They support newlines.</note>
  <link comp="ExampleNode" />
  <account comp="ExampleNode" user="admin" pass="password" />
 </attachments>
</email>

```

`attachments` are clickable items that either add a note for the player, a node to the netmap or give account details for the player.