Custom Enhancers - brandonandzeus/Trainworks2 GitHub Wiki

Custom Enhancers

As alluded to in Custom Relics, Enhancers are a type of Custom Relic. This tutorial will be very simple as much of the stuff from Custom Relics and Custom Spells apply here.

If you recall, there were upgrades you could purchase in Merchant of Steel/Magic and apply them to eligible cards in your deck. Internally, these shop upgrades are called Enhancers.

To dive a little deeper, an Enhancer is a relic that applies a CardUpgrade to a single eligible card. Enhancers are permanent for the rest of the run. The card starts with the CardUpgrade applied to it. Some examples of enhancers are Powerstone, Strengthstone, and Sapstone. Unlike a simple CardUpgrade, though, only a certain number of Enhancers can be applied to a card from the Merchants.

Stealthystone

Stealthystone, as you guessed, allows a unit to start with 5 Stealth at the cost of losing 5 Attack.

Now, let's dive into the code. Again, the framework provides a Builder for this, which does most of the heavy lifting.

var filter = new CardUpgradeMaskDataBuilder
{
    CardUpgradeMaskID = TestPlugin.GUID + "_SteathyStoneUpgradeMask",
    ExcludeNonAttackingMonsters = true,
    CardType = CardType.Monster,
    CostRange = new Vector2 { x = 0, y = 99 },
};

Here, we create a CardUpgradeMask for the enhancer. It allows any attacking monster that costs between 0 and 99 ember to be upgraded with this upgrade.

var upgrade = new CardUpgradeDataBuilder
{
    UpgradeID = TestPlugin.GUID + "_SteathyStoneUpgrade",
    UpgradeTitle = "Stealthystone",
    UpgradeDescription = "Upgrade a unit with -5[attack] and [stealth] 5",
    BonusDamage = -5,
    StatusEffectUpgrades =
    {
        new StatusEffectStackData {statusId = VanillaStatusEffectIDs.Stealth, count = 5},
    },
    HideUpgradeIconOnCard = false,
    FiltersBuilders = { filter },
    AssetPath = "assets/StealthyStone.png",
}.Build();

Here's the CardUpgrade again nothing too new here, as you've seen a similar setup to IcyBoost. The only points of interest:

  • UpgradeTitle: Enhancers will use an upgrade slot on the card. This is for when the player mouses over the enhancer, as when its applied it becomes a simple CardUpgrade.
  • UpgradeDescription: Description of the upgrade.
  • HideUpgradeIconOnCard: which is set to false here to tell it it is an enhancer.
  • AssetPath: This is the icon for the Enhancer when applied to a card.

Now, the enhancer itself.

new EnhancerDataBuilder
{
    EnhancerID = TestPlugin.GUID + "_SteathyStone",
    Name = "Stealthystone",
    Description = "Upgrade a unit with -5[attack] and [stealth] [effect0.upgrade.status0.power]",
    EnhancerPoolIDs = { VanillaEnhancerPoolIDs.UnitUpgradePoolCommon, VanillaEnhancerPoolIDs.UnitUpgradePoolCommon, VanillaEnhancerPoolIDs.UnitUpgradePoolCommon, VanillaEnhancerPoolIDs.UnitUpgradePoolCommon, VanillaEnhancerPoolIDs.UnitUpgradePoolCommon, VanillaEnhancerPoolIDs.UnitUpgradePoolCommon, VanillaEnhancerPoolIDs.UnitUpgradePoolCommon, VanillaEnhancerPoolIDs.UnitUpgradePoolCommon },
    Upgrade = upgrade,
    Rarity = CollectableRarity.Common,
    CardType = CardType.Monster,
    IconPath = "assets/StealthyStone.png",
}.BuildAndRegister();

Again, nothing too interesting here:

  • Description: Here, we can use effect0.upgrade to get details about the CardUpgrade. This text will be presented to you when you see the Enhancer up for sale in Merchant of Steel.
  • EnhancerPoolIDs: Just like Cards and Relics, Enhancers are added to a pool. UnitUpgradePoolCommon is the first two items presented in a Merchant of Steel shop. You can add the Enhancer many times to ensure you see it at least once to test it.
  • Upgrade: This is important to the CardUpgradeData the enhancer uses.
  • CardType: The CardType the enhancer can be applied to.

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

For fun, if you look up any Enhancer in MonsterTrainGameData, you will find that the fields of an Enhancer are very similar to that of any Relic if you compare them. The only difference is that Enhancers only have one effect. "relicEffectClassName": "RelicEffectCardUpgrade" This is required for Enhancers. But no need to worry about that, as EnhancerDataBuilder handles the setup for you.

And that's all there is to it. Now that we know all of the things a Clan can have, let's move on to Building custom clans.

Next: Custom Clans