Log in

Forge Trigger

Triggers define when an ability should be automatically added to the stack.Their syntax in the card files are very similar to that used by the various AbilityFactorys, that is: every trigger line starts with "T:" (without the quotes) and is a collection of name-value pairs (name and value are separated by $) separated by pipes (|). Like with AbilityFactorys, there are a few that show up almost always if not always. There are two parameters that are always present on a trigger:

  • Mode - Specifies what kind of situation the trigger should wait for.
  • TriggerDescription - Describes the trigger, much like AF's SpellDescription parameter.
  • (Execute - Specifies the name of the SVar that holds the ability to run when the trigger goes off.)
NOTE: The Execute parameter may be absent, if you are writing a delayed triggered ability. See below.

Depending on which Mode is specified, other parameters may be expected. Below are the currently available modes.

The script has access to many things that were previously internal to triggers. These things are accessed via Triggered-variables (Previously only "Triggered" was available in a very limited form). Triggered variables are always of the form "Triggered<Variable Name>[Controller/Owner]" and are specific to each trigger mode. You can use Triggered-variables that return a card or a player directly in Defined$ parameters or to grab extra info from (like you use "Targeted" for, for instance "SVar:X:TriggeredCard$CardPower"). You can get the controller or owner of a card returned by a Triggered-variable by appending "Controller" or "Owner" to the variable.Triggered-variables that return an integer can only be accessed from Count$, i.e. "SVar:X:Count$TriggeredLifeAmount".

Other parameters that triggers can use are:

  • Secondary - If a trigger has Secondary$ True set, it means that it's trigger description won't show up in a card's text box.This can be used if you need to use several triggers to emulate a single effect on a real card.
  • Static - This parameter is mainly used for "As CARDNAME enters the battlefield..." type things. It causes the triggered ability to resolve right away,instead of going on the stack.

Contents

Always

Always-triggers represent State triggers, a special kind of triggers.These triggers will not do any checks for intervening if-clauses and will not go on the stack if an instance of it has already been put there.They are checked every time state effects are checked. They can be used for cards similar to Emperor Crocodile, for instance. There are no special parameters and no triggered-variables.

AttackerBlocked

AttackerBlocked-triggers go off when a creature becomes blocked. It goes off only once (no matter how many blockers there are) right after the declare blockers step. There are 2 special parameters:

  • ValidCard - The attacking creature must match this for the trigger to go off.
  • ValidBlocker - The blocking creature must match this for the trigger to go off.

There are 3 Triggered-variables:

  • Attacker - The card of the attacking creature.
  • Blocker - The card of the blocking creaure.
  • NumBlockers - The number of things blocking the attacker

AttackerUnblocked

AttackerUnblocked-triggers go off when a creature attacks and is not blocked, right after the declare blockers step. There is 1 special parameter:

  • ValidCard - The attacking creature must match this for the trigger to go off.

There is 1 Triggered-variable:

  • Attacker - The card of the attacking creature.

Attacks

Attacks-triggers go off when a creature attacks. That is, it goes off once for each creature that attacks during your each combat phase (Right after the declare attackers step). There are 2 special parameters:

  • ValidCard - The attacking creature must match this for the trigger to go off.
  • Alone - If this is True, the trigger will only go off if the creature attacks alone.

There is 1 Triggered-variable:

  • Attacker - The card of the attacking creature.

BecomesTarget

BecomesTarget-triggers go off when a spell or ability (or either) is put on the stack targeting something that matches a Valid-expression. There are 3 special parameters:

  • SourceType - Can be Spell or Ability.It is optional.
  • ValidSource - The card that targets something must match this.
  • ValidTarget - The targeted object must match this.

There are 2 Triggered-variables:

  • Source - The targeting card.
  • Target - The targeted object.

Blocks

Blocks-triggers go off when a creature blocks (No surprise there ;) ). There are 2 special parameters:

  • ValidCard - The blocking creature must match this.
  • ValidBlocked - The creature being blocked must match this.

There are 2 Triggered-variables:

  • Attacker - The card of the attacking creature.
  • Blocker - The card of the blocking creaure.

ChangesZone

ChangesZone-triggers go off whenever, you guessed it, a card changes zone. There are 3 special parameters:

  • ValidCard - The card that was moved must match this for the trigger to go off.
  • Origin - The card must be moved from this zone for the trigger to go off. (Defaults to "Any")
  • Destination - The card must be moved to this zone for the trigger to go off. (Defaults to "Any")

There is 1 Triggered-variable:

  • Card - The card that was moved.

Clashed

Clashed-triggers go off whenever a player has clashed, regardless of wether you won or not. They are always run after the clash is through. There are 2 special parameters:

  • ValidPlayer - Who clashed.
  • Won - True if the player must have won, false otherwise.

There are no Triggered-variables.

CounterAdded

CounterAdded - triggers go off when a counter is added to a card. There are 2 special parameters:

  • ValidCard - The card getting the counter must match this for the trigger to go off.
  • CounterType - The counter must be of this type for the trigger to go off.

There is 1 Triggered-variable:

  • Card - the card the counter was added to

Cycled

Cycled-triggers simply go off whenever you cycle a card. There is 1 special parameters:

  • ValidCard - The card that was cycled must match this.

There is 1 Triggered-variable:

  • Card - The card that was cycled.

DamageDone

DamageDone-triggers go off whenever any source deals damage to any target. There are 4 special parameters:

  • ValidSource - The source of the damage must match this.
  • ValidTarget - The target of the damage must match this.
  • CombatDamage - If set to true, the trigger will only go off if the damage dealt was combat damage.If set to false, it will only go off if it wasn't combat damage.. If omitted, it will go off either way.
  • DamageAmount - Specifies how much damage must be done for the trigger to go off. It takes the form "<operator><operand>" where <operator> can be LT (Less Than),LE (Less than or Equal),EQ (Equal),GE (Greater than or Equal) or GT (Greater Than) and <operand> is a positive integer.

There are 3 Triggered-variables:

  • Source - The source of the damage.
  • Target - The target of the damage.
  • DamageAmount - The amount of damage dealt(integer).

BEWARE: Since the Target variable can be either a player or a card, you must take care to limit this in the ValidTarget parameter!

Discarded

Discarded-triggers go off whenever a card is discarded from a players hand (side note: ChangesZone-triggers may also go off here because the card is moved from the hand to the graveyard) There are 3 special parameters:

  • ValidPlayer - The player who discarded the card must match this.
  • ValidCard - The discarded card must match this.
  • ValidCause - The card that caused the player to discard must match this.

There is 1 Triggered-variable:

  • Card - The card that was discarded.

Drawn

Drawn-triggers go off when a player draws a card. There is 1 special parameter:

  • ValidCard - The drawn card must match this.

There is 1 Triggered-variable:

  • Card - The card that was drawn.

LandPlayed

LandPlayed-triggers of course go off when a land is played. There is 1 special parameter:

  • ValidCard - The played card must match this.

There is 1 Triggered-variable:

  • Card - The card that was played.

LifeGained & LifeLost

These triggers go off on when a player either gains or loses life, of course. There is 1 special parameter:

  • ValidPlayer - The player who gained or lost life must match this.

There are 2 Triggered-variables:

  • Player - The player that gained/lost life.
  • LifeAmount - The amount of life lost/gained. (integer)

Phase

Phase-triggers go off at specific points in the turns. Currently only Untap,Upkeep,Draw and EndOfTurn phases cause these to go off. There are 2 special parameters:

  • Phase - The phase during which the trigger should go off. Valid options: "Untap","Upkeep","Draw" or "End of Turn".
  • ValidPlayer - The player who's turn it should be.

There is 1 Triggered-variable:

  • Player - The player whose turn it is.

Sacrificed

Sacrificed-triggers go off whenever a player sacrifices a permanent. There are 2 special parameters:

  • ValidPlayer - The player who sacrificed the card must match this.
  • ValidCard - The sacrificed card must match this.

There is 1 Triggered-variable:

  • Card - The card that was Sacrificed.

Shuffled

Shuffled-triggers go off whenever a player shuffles his/her library. There is 1 special parameter:

  • ValidPlayer - The player who's turn it should be.

There is 1 Triggered-variable:

  • Player - The player whose turn it is.

SpellCast,AbilityCast & SpellAbilityCast

Triggers go off whenever a spell,ability or either respectively is cast by either player. There are 4 special parameters:

  • ValidControllingPlayer - The player who controls the cast spell must match this.
  • ValidActivatingPlayer - The player who activated the ability/spell must match this. (NOTE: For spells, the activator and controller are the same. They usually the same for abilities too, with the exception being abilities that can be activated by any player)
  • ValidCard - The card the cast spell or ability originates from must match this.
  • TargetsValid - If this parameter is present, the spell or ability must be targeted and at least one of it's targets must match this.

There are 4 Triggered-variable:

  • Card - The card that the cast spell or ability originates from.
  • SpellAbility - The SpellAbility object.
  • Player - The player that controls the card that the cast spell or ability originates from.
  • Activator - The player that activated the ability.

Taps & Untaps

These triggers go off when a permanent taps or untaps. There is 1 special parameter:

  • ValidCard - The card that taps or untaps must match this.

There is 1 Triggered-variable:

  • Card - The card that was tapped/untapped.

TapsForMana

This trigger goes off when a land is tapped for a mana ability. There is 1 special parameter:

  • ValidCard - The card that taps.

There are 3 Triggered-variable:

  • Card - The card that was tapped.
  • Player - the payer that did the tapping
  • Produced - a String of the Mana produced by this tapping

Restrictions

You can use certain optional parameters to further restrict when a trigger should go off.These parameters are:

  • TriggerZones - This parameter can be used to restrict which zone the card must be in in order for the trigger to go off. For example, if the trigger should only go off while the card is in the graveyard (As in Auntie's Snitch or Bridge from Below) you can use TriggerZones$ Graveyard
  • TriggerPhases - This parameter can be used to restrict the phases in which the trigger can trigger.
  • OpponentTurn - This parameter can be used to restrict the trigger to only trigger on your opponents turn.(True/False)
  • PlayerTurn - This parameter can be used to restrict the trigger to only trigger on your turn.(True/False)
  • Metalcraft - If this parameter is set to "True", the controller of this card must have 3 or more artifacts on the battlefield for the trigger to go off.
  • Threshold - As Metalcraft but requires the controller of the card to have 7 cards in the graveyard.
  • PlayersPoisoned - This parameter specifies that a certain or both players must have at least 1 poison counter. Valid values are "You", "Opponent" or "Each".
  • IsPresent - This parameter expects a ValidCard formula and only lets the trigger go off if there is a permanent on the battlefield that matches it.
  • PresentCompare,PresentZone & PresentPlayer - These parameters only matter if the IsPresent parameter is used. They can be used to narrow down and how many valid cards must be present and where they must be.
  • IsPresent2,PresentCompare2,PresentZone2 & PresentPlayer2 - Second requirement (see above).
  • CheckSVar - Calculates the named SVar and compares the result against the accompanying SVarCompare parameter which takes the form of <operator><operand> where <operator> is in LT,LE,EQ,NE,GE,GT.

Examples

Learn by example!

Contagion Clasp

(When Contagion Clasp enters the battlefield, put a -1/-1 counter on target creature.) The first thing to do is to identify the WHEN, i.e. when the trigger should go off so that we can decide on the proper mode. Here it should go off when a particular card moves from one zone into another, so ChangesZone is the logical mode here.
T:Mode$ ChangesZone
Next we look at which of ChangesZone's 3 special parameters we want to make use of. Well, we want the trigger to go off when the card enters one specific zone, so we'll want to use the Destination parameter. Also, we only care about when it's a specific card being moved so we'll use ValidCard.
T:Mode$ ChangesZone | Destination$ Battlefield | ValidCard$ Card.Self
There, we've defined a trigger that goes off when this card moves from any zone (remember, Origin and Destination defaults to "Any") to the battlefield zone. But we still have to use two more parameters. First, "Execute". Execute should contain the name of the SVar that holds the Ability you want to be triggered.It can be any valid SVar name. I like to follow the convention "Trig<name of the abilityfactory used>" but your mileage may vary.
T:Mode$ ChangesZone | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigPutCounter
Lastly, "TriggerDescription". This is what will be put in the cards text box, i.e. the rules text. Always try to keep it as close to Oracle wording as possible. Also, you should use "CARDNAME" instead of the name of the card for convention.
T:Mode$ ChangesZone | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigPutCounter | TriggerDescription$ When CARDNAME enters the battlefield, put a -1/-1 counter on target creature.
So we're all done,then?No, it's not a triggered ability until it actually has an ability. To define the ability we want to be triggered we simply use an AbilityFactory but instead of putting it on it's own line beginning with "A:", we put it in an SVar named what we put for the Execute parameter.
T:Mode$ ChangesZone | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigPutCounter | TriggerDescription$ When CARDNAME enters the battlefield, put a -1/-1 counter on target creature.
SVar:TrigPutCounter:AB$PutCounter | Cost$ 0 | Tgt$ TgtC | CounterType$ M1M1 | CounterNum$ 1

You may notice some strange things about the ability, namely the Cost parameter and the lack of a SpellDescription parameter.The reasoning for these things is that AbilityFactory requires non-drawback abilities to have a cost and drawback abilities not to have one. But if you want to do something like "When CARDNAME comes into play, you may pay 1 to...", that's where you'd use the Cost parameter here. The SpellDescription is missing because triggers use their own TriggerDescription instead.

AEther Vial

(At the beginning of your upkeep, you may put a charge counter on AEther Vial.) Okay let's apply the procedure we learned when doing Contagion Clasp:
Identify the WHEN - It should go off at the beginning of a specific PHASE so, well, Phase mode it is!
T:Mode$ Phase
Next,look at Phase modes special parameters: Phase and ValidPlayer. We can tell right away that Phase should be "Upkeep" and ValidPlayer should be "You" since it should only trigger on your turn.
T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You
Next up, we have to make sure that the trigger only goes off when AEther Vial is in play. If it's not, why would we want to put counters on it? We can use the TriggerZones parameter to restrict where the card must be in order for the trigger to go off. It takes a comma-separated list of zones but since we only want AEther Vial to trigger when it's on the battlefield, we just give it "Battlefield".
T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Battlefield
Now then, there's one word in the rules text that changes things: "may". To give the player a choice about wether or not to make use of the triggered ability, we can use the OptionalDecider parameter. It's used the same way as Defined parameters for AFs and the player it evaluates to gets to decide if the trigger happens.
T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Battlefield | OptionalDecider$ You
Lastly as before, we add the Execute and TriggerDescription parameters...
T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Battlefield | OptionalDecider$ You | Execute$ TrigPutCounter | TriggerDescription$ At the beginning of your upkeep, you may put a charge counter on CARDNAME.
...And our mad AbilityFactory-skills to write up the actual ability!
T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Battlefield | OptionalDecider$ You | Execute$ TrigPutCounter | TriggerDescription$ At the beginning of your upkeep, you may put a charge counter on CARDNAME.
SVar:TrigPutCounter:AB$PutCounter | Cost$ 0 | Defined$ Self | CounterType$ CHARGE | CounterNum$ 1

DING! Goblins are up!

Cinder Wall

(When Cinder Wall blocks, destroy it at end of combat.) This will be an example of a delayed trigger. A delayed trigger goes on the stack twice, once when the conditions are met, and once when the effect should happen.In Cinder Wall's case, once when it blocks, and once at the following end of combat step. To start with, we create a Blocks trigger that looks this.
T:Mode$ Blocks | ValidCard$ Card.Self
And this is where delayed triggers differ from ordinary triggers.We do NOT add an Execute parameter that points to an SVar containing the trigger's effect as an AF. Instead we add a DelayedTrigger parameter that points to an SVar containing ANOTHER trigger that specifies when the delayed effect should occur. This delayed trigger is built like an ordinary trigger and further points to an ability (Using the Execute parameter).Don't forget to omit the "T:" from the delayed trigger, for the same reason you omit "A:" from abilities in SVars!
T:Mode$ Blocks | ValidCard$ Card.Self DelayedTrigger$ DelTrig | TriggerDescription$ When CARDNAME blocks, destroy it at end of combat.
SVar:DelTrig:Mode$ Phase | Phase$ EndCombat | Execute$ TrigDestroy | TriggerDescription$ Destroy CARDNAME. SVar:TrigDestroy:AB$Destroy | Cost$ 0 | Defined$ Self