# Campaign packs

`PM.CampaignPacks` creates and patches campaign packs. A campaign pack is what a player picks when starting a new campaign, career or sandbox: it decides which galaxy the campaign plays in, and which [campaign features](/doc/campaign-features-9YIewcIArR) a new campaign starts with. Redux's own campaign is the pack with the id `Default`. This pack enables `Ksp2Redux:All`.

Campaign packs live under the `campaign_pack` label. Campaign packs are boot-time content, so this label is the same in all feature sets. Thus, the new campaign menu shows a pack that a mod creates, also when the mod is not enabled in any campaign.

## Creating a pack

`PM.CampaignPacks:CreateCampaignPack(id, callback)` creates a new pack. The id names the pack and its asset, and the callback fills it in. This is the 2.5x Kerbolar System's pack, which plays all of Redux and enables the two features of the mod:

```lua
PM.CampaignPacks:CreateCampaignPack("Kerbolar25x", function(campaignPack)
    campaignPack.Features = { "Ksp2Redux:All", "KerbolarUpscale:Rescale", "KerbolarUpscale:Antennas" }
    campaignPack.CampaignPackDescriptionLocalizationKey = "CampaignPacks/Description/Kerbolar25x"
end)
```

## The fields

| Field | Default | What it does |
|-------|---------|--------------|
| `CampaignPackId` | the id you created it with | The pack's id, which saves store. |
| `CampaignPackLocalizationKey` | `CampaignPacks/<id>` | The title on the pack's card. |
| `CampaignPackDescriptionLocalizationKey` | none    | The description on the card. |
| `ImageKey` | none    | Addressable key of a sprite for the card. Without one, the card shows only the title and description. |
| `Galaxy` | `GalaxyDefinition_Default` | The key of the galaxy the campaign plays in. |
| `Features` | empty   | The features a new campaign from this pack starts with. |
| `GameModes` | empty   | The ids of the game modes that offer this pack, such as `"Sandbox"`. Empty offers it in every game mode. |

`Features` accepts qualified feature ids. A new campaign also gets these features:

* the default features of the modding framework
* the features that the player selected as Default Features
* all the features that the pack features and these features require

Thus, to enable the mod itself, it is sufficient to list `KerbolarUpscale:Rescale`. To include the Redux game, a pack lists `Ksp2Redux:All` or the specific `Ksp2Redux:` features that it needs. See [Which features a campaign has](/doc/campaign-features-9YIewcIArR).

If a pack does not list some Redux features, its campaigns do not have that content. To replace the full galaxy, do not list `Ksp2Redux:Galaxy`, and name your own galaxy. To start your own part set with no stock parts, do not list `Ksp2Redux:Parts` and the features that require it.

The localization keys are ordinary localization entries. A mod can ship them in a `localizations` folder as a CSV:

```text
Key,Type,Desc,English
CampaignPacks/Kerbolar25x,Text,,2.5x Kerbolar System
CampaignPacks/Description/Kerbolar25x,Text,,"The complete Redux experience in a Kerbolar System 2.5 times the size"
```

## Patching and copying packs

`PM.CampaignPacks:Patch(name)` patches existing packs, targeted with `:Named(...)` by pack id. `PM.CampaignPacks:Duplicate(source, newName)` copies a pack, so a variant of Redux's campaign starts from everything Redux's pack already sets:

```lua
PM.CampaignPacks:Duplicate("Default", "MyHardMode"):Do(function(pack)
    pack.CampaignPackId = "MyHardMode"
    pack.CampaignPackLocalizationKey = "CampaignPacks/MyHardMode"
    pack.Features:Append("MyMod:HardMode")
end)
```

A copy keeps its source's `CampaignPackId`, and packs are registered by that id, so always set a new one as above. Otherwise the copy replaces the original.

## Your own tech nodes and missions

The tech tree or missions of a pack are usual new tech nodes and missions. Gate them on one of your features, so that only campaigns with that feature get them. To replace the Redux tech tree or missions, and not add to them, do not list `Ksp2Redux:Nodes` or `Ksp2Redux:Missions` in the `Features` of the pack. Then list the features that supply your tech nodes or missions.

## Packs, galaxies and saves

* Career and sandbox both pick a campaign pack on the new campaign menu, and get the pack's galaxy with it. If a pack sets `GameModes`, only those game modes offer the pack, so a mod can ship a sandbox setup, such as a test galaxy with its own part set, without it showing up in career.
* **Edit Pack** next to the pack picker opens the feature editor with the features of the pack. A player can use it to change the feature set of a new campaign before the campaign starts.
* The game reads the `Features` of a pack one time, when the player creates a campaign. After that, the campaign keeps its own feature set. The player changes that feature set with **Edit Pack** on the campaign selection screen. If the `Features` of a pack change later, existing campaigns do not change.
* A save remembers its pack. Each time it loads, the pack's current `Galaxy` is used, so a save follows later changes to its pack's galaxy. If the pack is no longer installed, the save uses the default galaxy.
* If a save is from before campaign features, it gets the `Features` of its pack when it first loads. A sandbox save that selected a galaxy instead of a pack moves to `Default`. A save on the retired `Classic` pack also moves to `Default`.
* A player cannot switch a campaign to a different pack or galaxy once it is created.