Missions

From Kerbal Space Program 2 Modding Wiki
Jump to navigation Jump to search

Exploration Mode has multiple in-game missions that you're supposed to finish in the campaign. Have you ever wondered *how* to make missions, though? Simple!


Missions in the game are JSON files, but we can also use PatchManager to create new missions.


The Mission Editor

The Mission Editor is a handy resource made by modders that makes mission creation much faster and more intuitive. You can use it here: https://ksp2community.github.io/editors/

This will eventually be replaced by a full Unity version.


Mission Data

MissionID: The ID your mission will have.

name: The name your mission will have. It's best to have this as a localization key, but if you don't plan on localizing your mod you can just set it to whatever your mission name is.

description: The description your mission will have. Note, this is the description shown in the UI that appears when you click on a mission. Not the brief. It's also recommended to have this as a localization key.

type: There are multiple types of missions. Primary, Secondary, Tutorial and FTUE. The first 2 are for the missions you see in Mission Control. Tutorial missions are the ones seen in the Training Center and FTUE are the pop-ups that appear when you have Cadet Orientation on.

Owner: There are multiple owners that you can choose from. None, Agency, Owner and Player. Player means only the player will have it. Agency means the agency the player is in will own it. (Which means in multiplayer everyone in that agency can complete it.) Global and None are self explanatory.

state: There are multiple states of missions. Inactive, Active, Complete, Failed and Invalid. You should only focus on the first 2 when creating missions. Inactive means that it'll be invisible until a mission activates your mission. Active means it'll be enabled from the start.

MissionGranterKey. There are multiple mission granters to choose from. It's best to choose the one that suits your mission the best.

TriumphLoopVideoKey: Videos that play once you've submitted the mission. Best example of this are the first few primary missions.

uiDisplayType: Default, Video, Flight, VAB, VAB_Flight. Usually use Default.

missionStages: Here we get to the fun part of missions. The actual mission. They are set up in various "stages". So if you wanted to have the player leave Kerbin and return, you'd have 2 stages for leaving Kerbin and then landing back on Kerbin. Let's see how this is set up.

stages:

StageID: 0,1,2 (just counts up depending on what stage it is)

name: This doesn't get displayed, so you can name it whatever you want.

description: This also doesn't get displayed.

Objective: This does get displayed, so preferably link it to a localization key or just state the objective here.

DisplayObjective: Self-explanatory.

RevealObjectiveOnActivate: This shows the objective once the stage is activated.

MissionRewardType: You can only choose Science Points.

RewardAmount: How much of whatever you chose is going to be rewarded.

ConditionMode: AND, OR, XOR, NOT.

Condition children: These are the things you need to do to actually finish a mission stage.

There are event conditions and property conditions. Event conditions listen to messages like GameStateChangedMessage or FlagPlantedMessage. Property conditions look at what your current active vessel has, for example where it's located, its deltaV, etc.

Note that you can create conditionsets inside of conditionsets. If you wanted to make something where a player can plant a flag on the Mun or Minmus, you can do so by just creating a ConditionSet with its mode set to AND, listening to FlagPlantedMessage, then creating

a condition set inside of that with its mode set to OR, and checking the active vessel SOI.


ContentBranches: Here's the stuff that gets done inside of the Mission Control building. They're similarly set up to the missionStages.

ID: What type of content branch it is. There are 3 to choose from, which are: Brief, Debrief, OnSubmit. Brief and Debrief are the short little dialogues you get when you finish/start a mission. OnSubmit is mostly used to activate missions.

Action: There are multiple actions that you can make your branches do:

Activate Mission, Fullscreen Video, Message Box (note that this is different from CharacterDialog), Audio, OAB Settings, Character Dialog, Create Snapshot, Destination Position, Disable Input, Highlight, Indicator, Pause, Reload Snapshot Resolution, Set View State, Lua Script


Saving your Mission

So you've finally completed your mission! Great! Putting it into the game is simple. Click the floppy disk icon and save it as a .patch file. You will then have to place it into your mod and run the game.