Fleshing Out a Champion - brandonandzeus/Trainworks2 GitHub Wiki

Fleshing Out a Champion

This tutorial assumes you've already worked through the previous one on custom clans. We'll be using the champion from that tutorial as a base.

Adding an upgrade path

If you have made it this far, congrats. Champion Upgrade Paths are simply a Tree of CardUpgradeData. We have encountered CardUpgradeData objects all throughout this tutorial, back in IcyBoost from Custom Spell Cards and the Stealthystone enhancer from the Custom Enhancers Tutorial. So this shouldn't be new to you.

So let's give Slimeboy a single upgrade path. How about the main gimmick that whenever he gets hit, he gets spikier? Let's plan this out. Here's a table summarizing the upgrade path.

Name MaxHP Attack Size Effect
Spikey I 10 10 0 Revenge: Gain spikes 1
Spikey II 20 40 0 Revenge: Gain spikes 3
Spikey III 80 40 0 Revenge: Gain spikes 7

Note that Upgrade Paths are not cumulative. If I select SpikeyII in the second Forge, the SpikeyI upgrade is removed and replaced with SpikeyII.

So from this table, it's easy to go from this to a CardUpgradeData. Let's show some code for SpikeyI.

        public static CardUpgradeDataBuilder SpikeyBoiI()
        {
            return new CardUpgradeDataBuilder
            {
                UpgradeID = TestPlugin.GUID + "_SpikeyI",
                UpgradeTitle = "Spikey I",
                BonusHP = 10,
                BonusDamage = 10,
                TriggerUpgradeBuilders =
                {
                    new CharacterTriggerDataBuilder
                    {
                        TriggerID = TestPlugin.GUID + "_SpikeyTriggerI",
                        Trigger = CharacterTriggerData.Trigger.OnHit,
                        Description = "Gain [spikes] [effect0.status0.power]",
                        EffectBuilders =
                        {
                            new CardEffectDataBuilder
                            {
                                EffectStateType = typeof(CardEffectAddStatusEffect),
                                TargetMode = TargetMode.Self,
                                TargetTeamType = Team.Type.Monsters,
                                ParamStatusEffects =
                                {
                                    new StatusEffectStackData {statusId = VanillaStatusEffectIDs.Spikes, count = 1}
                                }
                            }
                        }
                    }
                }
            };
        }

I like to define my Upgrades in separate functions and then have a function to form the UpgradeTree. By now, you should understand how to make CardUpgradeDatas.

The only interesting field are setting the UpgradeTitle, which will be presented to the player when they visit the Forge.

Now for the successive upgrades on this path.

        public static CardUpgradeDataBuilder SpikeyBoiII()
        {
            return new CardUpgradeDataBuilder
            {
                UpgradeID = TestPlugin.CLANID + "_SpikeyII",
                UpgradeTitle = "Spikey II",
                BonusHP = 40,
                BonusDamage = 20,
                TriggerUpgradeBuilders =
                {
                    new CharacterTriggerDataBuilder
                    {
                        TriggerID = TestPlugin.CLANID + "_SpikeyTriggerII",
                        Trigger = CharacterTriggerData.Trigger.OnHit,
                        Description = "Gain [spikes] [effect0.status0.power]",
                        EffectBuilders =
                        {
                            new CardEffectDataBuilder
                            {
                                EffectStateType = typeof(CardEffectAddStatusEffect),
                                TargetMode = TargetMode.Self,
                                TargetTeamType = Team.Type.Monsters,
                                ParamStatusEffects =
                                {
                                    new StatusEffectStackData {statusId = VanillaStatusEffectIDs.Spikes, count = 3}
                                }
                            }
                        }
                    }
                }
            };
        }

        public static CardUpgradeDataBuilder SpikeyBoiIII()
        {
            return new CardUpgradeDataBuilder
            {
                UpgradeID = TestPlugin.CLANID + "_SpikeyIII",
                UpgradeTitle = "Spikey III",
                BonusHP = 80,
                BonusDamage = 40,
                TriggerUpgradeBuilders =
                {
                    new CharacterTriggerDataBuilder
                    {
                        TriggerID = TestPlugin.CLANID + "_SpikeyTriggerIII",
                        Trigger = CharacterTriggerData.Trigger.OnHit,
                        Description = "Gain [spikes] [effect0.status0.power]",
                        EffectBuilders =
                        {
                            new CardEffectDataBuilder
                            {
                                EffectStateType = typeof(CardEffectAddStatusEffect),
                                TargetMode = TargetMode.Self,
                                TargetTeamType = Team.Type.Monsters,
                                ParamStatusEffects =
                                {
                                    new StatusEffectStackData {statusId = VanillaStatusEffectIDs.Spikes, count = 7}
                                }
                            }
                        }
                    }
                }
            };
        }

Again nothing interesting I just changed the numbers.

Last but not least, a function to make the CardUpgradeTreeData, again, is just another Builder.

        public static CardUpgradeTreeDataBuilder FormUpgradeTree()
        {
            return new CardUpgradeTreeDataBuilder
            {
                UpgradeTrees =
                {
                    new List<CardUpgradeDataBuilder> { SpikeyBoiI(), SpikeyBoiII(), SpikeyBoiIII() },
                    // Normally champions have 3 upgrade paths, but 1 is the minimum required.
                }
            };
        }

All you need for CardUpgradeTreeDataBuilder is just a List of 'lists of 3 CardUpgradeDataBuilders' You can have more than 3 upgrade paths, but 2 upgrade paths will only ever be shown in the Forge.

The last step make sure our ChampionCardDataBuilder knows about the CardUpgradeTreeData.

            new ChampionCardDataBuilder()
            {
                Champion = championCharacterBuilder,
                ChampionIconPath = "assets/slimeboy-character.png",
                StarterCardID = VanillaCardIDs.Torch,
                CardID = ID,
                Name = "Slimeboy",
                ClanID = Clan.ID,
                UpgradeTree = FormUpgradeTree(),
                AssetPath = "assets/slimeboy.png"
            }.BuildAndRegister(0);

And there you have it now. Visit the forge, and you should be able to choose this singular upgrade path.

This concludes the easy part of this tutorial. You should have everything needed to make a clan now! Yay!

If you wish to move on we will now take an even deeper dive into the codebase and now start work on Custom Effects, this will get into nitty-gritty details of the codebase but will truly make a clan stand out.

If you wish Custom Status Effects.