Abilities
Last updated
Last updated
Abilities can be found in the Resources/Abilities folder. They can be assigned to cards to give them special power. The engine is also made in a way to make it easy to code your own abilities.
Determines WHEN the ability will be resolved.
Ongoing: Always active as long as this card is in play. (Ongoing only works with a limited number of effects such as status and stat bonus). Ongoing abilities bonus are recalculated any time there is a state change.
Activate: For Activated abilities, the player will need to manually click-hold on the card and select the ability. Some activated abilities can cost mana or can cost the character's turn action.
On Play: Resolved when the card is played from your hand.
On Play Other: Resolved when this card is already in play and another card is played. Usually this type of trigger will have some trigger conditions.
Start/End of Turn: Resolved once every turn, during your turn.
On Before/After Attack: Resolved when attacking with the card. OnAfterAttack will resolve only if the card survived the attack.
On Before/After Defend: Resolved when being attacked. OnAfterDefend will resolve only if the card survived the attack.
On Kill: When killing another card during an attack.
On Death: When this card dies.
On Death Other: When this card is in play and another card dies.
Ability won't trigger unless all the trigger conditions are met. For example, you could have an "OnPlay" ability that only triggers if the player has less than 10 health, or a Start of Turn ability that triggers only if you have 5 cards on the board..
There are many conditions already available in the Resources/Condition folder, but you can also code your own. (See the scripts section).
Determines WHO is affected by the ability?
There are 3 different categories of possible target:
Cards
Players
Board Slots
And different targets you can choose form:
Self: The card with this ability
Player Self: The owner of the card with this ability
All Cards Board: All cards currently in play, excluding secrets.
All Cards Hand: All cards in both player's hand.
All Cards All Piles: All existing cards, on board, hand, deck, discard or secret area. You will usually want to use some target conditions to filter only the deck or discard or other.
All Slots: All slots on the board, whether they are empty or occupied. Usually used for summon abilities.
All Card Data: All existing card data in the game (scriptable objects), this is usually used to instantiate new cards (like discover effect), since it doesn't represent an existing card in the game, but only the data of the card.
Play Target: When playing a spell, you will be asked to drag the spell directly on top of a target when playing it. Use only for spells.
Ability Triggerer: The card that caused the ability to be triggered. This is usually the same than the caster (self) but for some Triggers it is not. OnPlayOther, OnDeathOther, OnAttack, OnDefend, and OnKill have a different triggerer than the caster.
Select Target: Player will be asked to click on a target of his choice on the board. Can be a card, player or slot. Choice can be restricted with a target condition.
Card Selector: A menu will open to let the player select a card as target. This is useful for abilities that let you retrieve a card from your discard or deck. Choice of cards can be refined with target condition.
Choice Selector: A menu will open to let the player choose between a few different abilities. If you use this, place the choice abilities under chain_abilities array.
This is really useful to target multiple cards (but not all) or to limit the choices of the player. For example, if you want an ability that says "All wolves gain +1 attack", the Target would be "All Board Cards", and the target condition "Is Wolf".
Another example would be a skill that let you take a blue spell from your discard. The Target would be "Card Selector", and the target conditions would be "Is Blue" and "Is Spell" (You also need to add "Is Ally" and "Is In Discard" with the card selector, otherwise it will show cards in your deck and your opponent deck/discard).
Target filters are a bit more complex and slightly less performant than conditions, since they involve manipulating arrays instead of just a bool check. But they are a lot more flexible when you want to target multiple targets with a more global condition instead of a condition that is only checked on each individual target.
For example targets filters could be used to target X number of random targets on the board, or to target the card with the highest attack, cards that have duplicates, etc.. This is done by targeting AllBoardCards and then adding a filter that will use all board cards as source and only add the new targets into the destination array. Filters also work with AllPlayers and AllSlots.
More info on this will be added to the Scripts section.
Determines WHAT will happen to the targets when the ability is resolved.
Several effects are already available in the Resources/Effects folder. If an effect has a parameter and you want to use it with different values, you can simply duplicate one effect with Ctrl-D.
Effects can also be coded easily like conditions, by creating your own scripts. See the scripts section to know how to code your own effects.
A value and duration can be passed to each effect.
Some more complex abilities could have multiple effects, each with different targets and conditions, but that are all triggered by the same thing. To simplify the creation of these more complex abilities, you can instead create multiple abilities, and only the first one will have a trigger. Set the trigger to None on the other ones. And only attach the first ability on your card.
Then, on that first ability, add the other abilities into the chain_abilities array. This means those abilities will be triggered immediately after the first one, whenever it is triggered.
This array is also used when using the Choice Selector.
Activated abilities can have a mana or exhaust cost required to activate the ability. Exhaust means the card won't be able to attack in the same turn, or use the ability on the first turn it is played. An activated ability without an exhaust cost can be triggered multiple times per turn.