Custom Relics - KittenAqua/TrainworksModdingTools GitHub Wiki

These wiki pages are deprecated and are outdated. Please find the newer tutorials here

Custom Relics

Relics are actually very similar to cards and especially characters, so if you haven't yet, it'd be a grand idea to gander over that tutorial first.

Wimp-cicle

Download the relic art here.

Wimp-cicle, like its namesake, generates a card at the start of your turn. This time it's not an imp but a Train Steward. The first thing we need to do is create a card pool.

CardPool cardPool = new CardPoolBuilder {
    CardPoolID = "Wimp-ciclePool",
    CardIDs = {VanillaCardIDs.TrainSteward}
}.Build();

Card pools are a bit weird by Monster Train standards. You have some, like the MegaPool, that have tons and tons of cards in them. Then you have some, like the StingOnlyPool, that have exactly one. As it turns out, there actually is a TrainStewardOnly pool as well, but unlike CardData, CharacterData, etc., card pools aren't stored in a global list, so we can't easily grab it. Since this one's small, it's more straightforward to just make it ourselves.

Relics, like cards, characters, and any other form of content, are made using a builder.

new CollectableRelicDataBuilder
{
    CollectableRelicID = TestPlugin.GUID + "_WimpcicleRelic",
    Name = "Wimp-cicle",
    Description = "At the start of your turn, add a Train Steward to your hand",
    RelicPoolIDs = new List<string> { VanillaRelicPoolIDs.MegaRelicPool },
    IconPath = "assets/wimpcicle.png",
    EffectBuilders = new List<RelicEffectDataBuilder>
    {
        new RelicEffectDataBuilder
        {
            RelicEffectClassName = "RelicEffectAddBattleCardToHand",
            ParamInt = 1,
            ParamCardPool = cardPool,
            ParamTrigger = CharacterTriggerData.Trigger.PreCombat,
            ParamTargetMode = TargetMode.FrontInRoom
        }
    },
    Rarity = CollectableRarity.Common
}.BuildAndRegister();
  • CollectableRelicID: Must be unique.
  • Name: Whatever you want. As with the others, this will be the same across all languages. Use NameKey if you want localization support.
  • Description: Same as it was everywhere else.
  • RelicPoolIDs: Like cards, relics go into pools. If you're making a regular relic, stuff it in the MegaRelicPool. It's the one the game uses for relic choices on the map and in the shop.
  • IconPath: Location of the relic art relative to your plugin's directory.
  • EffectBuilders: This is a list of RelicEffectDataBuilders. They're pretty much the same as regular EffectDataBuilders, but they use their own effect types.
  • RelicEffectClassName: We're just gonna follow Imp-cicle's lead here. In fact, aside from the card pool this whole effect will be identical to Imp-cicle.
  • ParamInt: Varies by relic effect type. For RelicEffectAddBattleCardToHand, this is the number of cards to add.
  • ParamCardPool: The card pool to choose cards from. Since our card pool only has Train Steward in it, it'll always choose Train Steward. If we made a pool of, for example, all the starter cards, it'd choose one of those at random instead.
  • ParamTrigger: When the relic effect fires. In this case it's "PreCombat", which is actually the start of your turn.
  • ParamTargetMode: Who the relic effect targets. Why Imp-cicle targets the unit in front is anyone's guess, but it does, and thus so do we.
  • Rarity: This is actually kind of a terrible relic, so let's make everyone's day worse by having it be common.

If you wanted to, you could set a clan ID to restrict the relic to that clan. Leaving it off (as we did here) makes it clanless.

How do we test a relic? If you have Harmony set up, you can use a Harmony patch very similar to AddCardToStartingDeckPatch. Here's the code:

[HarmonyPatch(typeof(SaveManager), nameof(SaveManager.SetupRun))]
class AddRelicAtStartOfRunPatch
{
    static void Postfix(ref SaveManager __instance)
    {
        __instance.AddRelic(CustomCollectableRelicManager.GetRelicDataByID(Wimpcicle.ID));
    }
}

This will add the relic at the start of a new run, making it very easy to test.

Next: Custom Clans

⚠️ **GitHub.com Fallback** ⚠️