Trainworks CustomEffects - brandonandzeus/Trainworks2 GitHub Wiki

Trainworks CustomEffects Reference.

Card Effects

CardEffectAddCardUpgradeToTargetCards

As of Trainworks 2.4.0

A much-improved generic version of CardEffectAddTempCardUpgradeToCardsInHand. The base game card effect has several limitations and bugs:

  • Hardcoded to target cards in hand only.
  • Can't be used within CharacterTrigger Effects. It will crash due to a Null reference exception.
  • Can't be used with Scaling CardTraits. It has a bug in that the scaling card trait keeps reapplying itself to the CardUpgrade.

This CardEffect also allows you to choose whether to apply the upgrade to the card as a temporary CardUpgrade or permanently.

Parameters

  • TargetMode: One of (DrawPile, Eaten, Discard, Exhaust, LastDrawnCard, LastDrawnCard.Invert(), SelfCard, SelfCard.Invert(), or Hand)
  • ParamCardUpgrade: CardUpgrade to apply. The Filters within the CardUpgrade will be used to filter out cards from the target cards.
  • ParamBool: True to apply the CardUpgrade permanently, False for a temporary CardUpgrade.

CardEffectAddCardUpgradeToTargetUnits

As of Trainworks 2.4.0

A less-quirky improved version of CardEffectAddTempCardUpgradeToUnits. The base game card effect has a few quirks:

  • The game marks several upgrades as isUnitSynthesisUpgrade extraneously. This seems to be a bandage the devs made to fix Kinhost Carapace. This version does not check this.

This CardEffect also allows you to choose whether to apply the upgrade as a temporary CardUpgrade or permanently. Note that this version still ignores the value of CardUpgradeData.Filters.

Parameters

  • ParamCardUpgrade: CardUpgrade to apply. The Filters within the CardUpgrade will be used to filter out cards from the target cards.
  • ParamBool: True to apply the CardUpgrade permanently, False for a temporary CardUpgrade.

CardEffectHealAndDamageRelativeCustomTargets

As of Trainworks 2.4.0

A generic version of the base game's card effect. It had a few restrictions:

  • The TargetMode was essentially ignored in most cases. Only the first character out of the list of targets was healed.
  • The healing multiplier was hardcoded to 5.
  • The damage step was hardcoded to be the front enemy unit.

This version is more configurable allowing you to customize more parameters.

  1. All targets specified with the TargetMode will be healed for amount. (Note that TeamType should be one of Team.Type.Heroes or Team.Type.Monsters)
  2. The TargetMode for the damage step is configured through ParamAdditionalInt. (The opposing TeamType from step 1 is used).
  3. The damage multiplier based on amount healed is set through ParamMultiplier.
  4. Damage dealt can be configured through ParamBool. if true the damage calculated is split among targets. If false then (total healed amount * ParamMultiplier) damage is done to all units.

Parameters

  • ParamInt: Amount to heal.
  • ParamMultiplier: Damage multiplier.
  • AdditionalParamInt: Secondary TargetMode to use.
  • ParamBool: True to split the damage among targets (total amount healed * ParamMultiplier) / num_targets, false to deal the same amount (total amount healed * ParamMultiplier)

CardEffectModifyTargetCardCost

As of Trainworks 2.4.0

A genericized version of the similar CardEffect of the same name from the base game. The base game's CardEffect was hardcoded to target the hand.

Additionally, the Cost modification can be made permanent through ParamBool

Parameters

  • TargetCardType: Target card filter. Note default is Spell cards only. Set to CardType.Invalid to disable filtering.
  • ParamInt: Cost modification

CardEffectRandomDiscardFromCardPile

As of Trainworks 2.4.0

A genericized version of CardEffectRandomDiscard. The former was hard coded to target the Hand. This version allows you to discard a card from any location through TargetMode. Think of this as CardEffectRecursion except the card goes straight to the trash. You can even filter the candidate cards to discard with TargetCardType or apply a CardUpgrade (temporarily or permanently) to the discarded card through ParamCardUpgradeData.

This will trigger CardTriggerType.OnDiscard as the implementation will move the card to the deck and draw it (if it was exhausted/eaten), then discard it.

Parameters

  • TargetCardType: (Required) Target card filter. Note default is Spell cards only. Set to CardType.Invalid to disable filtering.
  • TargetCharacterSubtype: If TargetCardType is Monster additional filtering based on subtype. The default is the None subtype which matches all.
  • ParamCardUpgrade: CardUpgrade to apply. Note that CardUpgradeMaskData filters can be applied to restrict the upgrade from hitting non matching cards.
  • ParamBool: If true the CardUpgrade is applied permanently.

Card Traits

CardTraitScalingUpgradeUnitAttackSafely

A safe version of CardTraitScalingUpgradeUnitAttack intended to be used on Monster Cards. This Card Trait completely avoids the issue that Kinhost Carapace has by restricting the effects of the CardTrait to a single CardUpgrade type that is specified within the CardTrait.

This is a scaling CardTrait for parameters see the section of ScalingCardTrait parameters.

Parameters

  • ParamInt: Multiplier
  • ParamCardUpgradeData: CardUpgrade that should be scaled.

CardTraitScalingUpgradeUnitHealthSafely

A safe version of CardTraitScalingUpgradeUnitHealth intended to be used on Monster Cards. This Card Trait completely avoids the issue that Kinhost Carapace has by restricting the effects of the CardTrait to a single CardUpgrade type that is specified within the CardTrait.

Parameters

  • ParamInt: Multiplier
  • ParamCardUpgradeData: CardUpgrade that should be scaled.

CardTraitScalingUpgradeUnitSizeSafely

A safe version of CardTraitScalingUpgradeUnitSize intended to be used on Monster Cards. This Card Trait completely avoids the issue that Kinhost Carapace has by restricting the effects of the CardTrait to a single CardUpgrade type that is specified within the CardTrait.

Parameters

  • ParamInt: Multiplier
  • ParamCardUpgradeData: CardUpgrade that should be scaled.

CardTraitScalingUpgradeUnitStatusEffectSafely

A safe version of CardTraitScalingUpgradeUnitStatusEffect intended to be used on Monster Cards. This Card Trait completely avoids the issue that Kinhost Carapace has by restricting the effects of the CardTrait to a single CardUpgrade type that is specified within the CardTrait.

Parameters

  • ParamInt: Multiplier
  • ParamCardUpgradeData: CardUpgrade that should be scaled.
  • ParamStatusEffects: Status effects to append to the CardUpgrade to the unit. Note that the count of each StatusEffectStackData is ignored and replaced with the scaled value from the tracked value.

Room Modifiers

RoomStateDamageSpellCostModifier

As of Trainworks 2.4.0

A more correct, less quirky, genericized version of the base game room modifier of a similar name which had quirks.

This version checks the following

  • If the card is a spell. If not then the cost isn't modified
  • If the card has any effects that are damaging (CardEffectDamage, CardEffectDamageByUnitsKilled, CardEffectDamagePerTargetAttack, CardEffectHealAndDamageRelative)
  • OR If the card has a CardTriggerEffect.OnCast with a CardEffect that is damaging (see list above).

This RoomModifier can be extended by mods by adding to the list of Damaging CardEffects via adding to RoomStateDamageSpellCostModifier.DamagingCardEffects

Parameters

  • ParamInt: Spell cost modifier.

RoomStateHealSpellCostModifier

As of Trainworks 2.4.0

A more correct, less quirky, genericized version of the base game room modifier of a similar name which had quirks.

This version checks the following

  • If the card is a spell. If not then the cost isn't modified
  • If the card has any effects that are healing (CardEffectHeal and its subclasses)
  • OR If the card has a CardTriggerEffect.OnCast with a CardEffect that are healing (see list above).

This RoomModifier can be extended by mods by adding to the list of Healing CardEffects via adding to RoomStateHealSpellCostModifier.OtherHealingCardEffects

Parameters

  • ParamInt: Spell cost modifier.

Target Modes

As of Trainworks 2.4.0

Character Target Modes.

  • Strongest: The unit with the most attack from the list of valid targets is selected. If multiple targets fit the condition then the frontmost is selected.
  • StrongestExcludingSelf: Like the above, but selfTarget (The character who triggered the effect) can not be selected. This TargetMode is only valid within a CharacterTriggerData's Effects.
  • OverrideTarget: This one is only for Custom Card Triggers / Character Triggers. Simply specify the overrideTargetCharacter that was passed to CombatManager.QueueAndRunTrigger. A use case for this specific target mode would be an interaction between two characters on the floor. Having this Target mode removes the need for a Custom Card Effect to handle this specific parameter. Note that LastAttackedCharacter also uses overrideTargetCharacter (along with attacked characters), however, that requires a selfTarget. Otherwise, the overrideTargetCharacter parameter is unused in the base game. So only use if needed for custom triggers.

Card Target Modes.

Unless otherwise specified card target modes can not be inverted

  • PlayedCard: Returns the card currently playing effects. Like self, but for cards. (Can be inverted)
  • Hand: Now working! Previously this didn't fill the targetCards in CardEffectParams.

Inverted Target Modes

As of Trainworks 2.5.0

Any previous Character TargetMode (except Tower and Pyre) can be inverted. In this case, the following happens.

  • For inverted Character Target Modes
    • We take the list of all characters selected by TargetTeamType on the floor. Let's call this Set A
    • Any targets from the original target mode and targeting params. This is Set B.
    • The set difference A - B will be the targets selected.
  • For inverted Card Target Modes
    • Only PlayedCard and LastDrawnCard can be inverted. All Cards in hand except the played card / last drawn card are targeted.

Any TargetMode can be inverted by calling the Invert() function on the TargetMode.

Note behavior is not defined if LastTargetedCharacters.Invert() is used as a TargetMode and the CardEffect's TargetMode that ran directly before it was Tower or Pyre

Examples:

  1. Target every Monster unit that wasn't selected when the card was played.
TargetMode = TargetMode.DropTargetCharacter.Invert(),
TargetTeamType = Team.Type.Monsters,
  1. Target every unit on the floor that is not a Train Steward.
TargetMode = TargetMode.Room.Invert(),
TargetTeamType = Team.Type.Monsters | Team.Type.Heroes,
TargetCharacterSubtype = VanillaSubtypeIDs.Steward,
  1. All heroes on the floor except the weakest hero unit with spikes. If no heroes on the floor have spikes this will select all hero units.
TargetMode = TargetMode.Weakest.Invert(),
TargetTeamType = Team.Type.Heroes,
TargetModeStatusEffectsFilter = {VanillaStatusEffectIDs.Spikes}