Calculating Action Results

The result of an action has to be calculated – this can be done in 3 ways.

It doesn’t matter if it’s about a base attack, a fireball or a healing potion – the status changes you defined in the user/target changes need to be calculated. This also applies to special actions, e.g. a combatant’s death, defending or switching members.

There are 3 ways to do this:

  • No Animation
    If the action isn’t animated through schematics, the result will be calculated automatically.
    This also happens when using them via a menu screen that doesn’t animate the action.
  • Calculate Action Node
    Use a Calculate Action node at the point you want the damage to be calculated.
    You can also use the node multiple times, the result will be calculated each time (except for the use costs for an ability/item).
  • Damage Dealers/Zones
    The Damage Dealer and Damage Zone components on your combatants and equipment are used for calculating the result when they physically interact.
    E.g. a weapon’s damage dealer entering an enemy’s damage zone causes the attack’s damage to be calculated.

Additionally, you can also use status effects and schematics in any way to change the status of combatants, e.g. change their status values, apply/remove status effects, etc.

There isn’t much to say about not animating an action, so let’s take a closer look into the others.

Calculate Action Node #

Actions, like using abilities or items, use schematics to animate them. The Calculate Action node can be used in them to calculate the result of the action – every time this node is used the action using the schematic will calculate it’s result. E.g. an ability or item will calcualte the status changes defined in the user changes and target changes.

The use costs of an ability or item (e.g. casting a fire spell costs 5 MP) will only be consumed the first time the Calculate Action node is used. If you want an action to do it’s status changes multiple times, simply use multiple Calculate Action nodes – but keep in mind, that each calculation will do the status changes defined for the ability/item.

You can optionally have different Next slot on the node, based on the result of the calculation (e.g. when the attack missed, blocked or a critical hit).

Predetermine Outcome #

You can predetermine if an action is a hit, critical hit, miss or was blocked by using the Determine Action Outcome node. This is only available for abilities and items.

This allows you to first check if it’s a hit or miss and use different animations, effects or other things in your schematic, before using the Calculate Action node. The actual status changes will be calcualted in the Calculate Action node, the Determine Action Outcome node only calculates hit, critical hit and block chances.

There are additional nodes available to check the predetermined outcome, remove it or even set the outcome.

E.g. a combatant has a status effect applied that guarantees critical hits (checked using the Check Status node).

The Set Det. Action Outcome node is used to set the action’s outcome to be Critical.

Damage Dealers/Zones #

Damage Dealers and Damage Zones are components you can add to the game objects (prefabs) of your combatants and equipment.

They’re used for physical-based damage calculation, e.g. a sword or fireball actually hitting a combatant (i.e. their colliders interacting with each other).

Both require a Collider component, and at least one of them should also involve a Rigidbody component – otherwise Unity’s physics system doesn’t recognize their interactions (collission or trigger). They can be used with both 2D and 3D colliders/rigidbodies, just keep in mind that 2D can only interact with 2D and 3D with 3D – i.e. you can’t mix 2D and 3D physics.

Damage Dealers #

Damage Dealer components are added to the prefabs of your combatants or equipment (e.g. a sword), or added to other things that should deal damage, e.g. a prefab used by a fireball spell.

Damage dealers need to have an action set and be activated to be able to deal damage – see below for details.

Start Type #

The Start Type defines how the damage dealer can cause damage on a damage zone:

  • Trigger Enter
    When a damage zone enters the damage dealer’s trigger.
  • Trigger Exit
    When a damage zone exits the damage dealer’s trigger.
  • Trigger Stay
    While a damage zone stays the damage dealer’s trigger.
  • Collision Enter
    When a damage zone starts colliding with the damage dealer’s collider.
  • Collision Exit
    When a damage zone stops colliding with the damage dealer’s collider.
  • Collision Stay
    While a damage zone is colliding with the damage dealer’s collider.
  • Custom
    By calling the damage dealer’s CustomDamage function.

The Trigger start types require the collider to have Is Trigger enabled, the Collision start types require it to be disabled.

Environmental Damage (Always On) #

Damage dealers can be used on their own to create environmental hazards, e.g. a trap or damaging area. You can also use it to cause contact damage on combatants, e.g. the player running into an enemy can damage the player.

To use it that way, enable the Always On setting – you have to define the ability that’ll be used for the calculations. The combatant used by the damage dealer has to know the ability and able to use it (e.g. use costs).

The combatant that’ll be used to deal damage (i.e. user of the ability) can either be on the damage dealer’s game object or parent object, or defined in the damage dealer’s settings.

For environmental hazards, you’ll set a combatant in the damage dealer’s settings – for contact damage, just add the damage dealer to the combatant’s prefab (root or a child object).

Destroy Settings #

A damage dealer can automatically be destroyed, either after a defined amount of time or on dealing damage.

E.g. a projectile will be destroyed on after 5 seconds and when dealing damage.

Damage Settings #

When hitting a game object (via it’s collider) that doesn’t have a Damage Zone component attached, the damage dealer can optionally search in child or parent objects of the hit game object.

The damage dealer can also be limited to only dealing damage one time or only hitting one target.

E.g. swinging a sword can damage a combatant only once per use, but hit multiple combatants in one swing.

Activation Settings #

Define which actions can activate a damage dealer. A base attack, counter attack and defined abilities and items can activate it.

You can also use activation tags, instead of defining a specific action.

E.g. all sword equipment prefabs have damage dealers with the tag weapon added to them.

Any ability using the weapon tag in their damage dealer setup will be able to activate the damage dealer.

Additionally, using the damage dealer can be limited to defined battle systems.

Activating Damage Dealers #

Damage dealers need to have an action set and be activated to be able to deal damage. Only an action matching the damage dealer’s setup can be set to it, i.e. either set up for that action or via activation tags.

Activating a damage dealer is generally handled by schematics, either automatically while a schematic runs, or manually by the Activate Damage Dealer node. Keep in mind that the schematic needs to have some wait time between activation and deactivation, or the damage dealer has no time to hit anything.

Abilities and items also have Damage Dealer Settings to define activation tags they’ll use, as well as a sound and prefab that’ll be used when the damage dealer hits a damage zone.

Additionally, abilities and items can also use battle animations (schematics) to animate the damage dealer’s use. They’ll be used when the damage dealer hits a damage zone. When animating damage dealers, you need to use a Calculate Action node in the schematics to calculate the action’s results.

Auto Activation #

Auto activation can be used to automatically activate damage dealers on the user of an ability or item. This includes equipment dispalyed on the combatant (via Equipment Viewer components).

The Battle Animation settings of abilities and items can use auto activation via the Auto Damage Dealers setting for the individual schematic added to them:

  • None
    Doesn’t use auto activation.
  • Set Action
    Sets the damage dealer’s actions when starting the schematic and removes it at the end.
    Only sets the action, but doesn’t activate it (e.g. can be activated via animation events, scripting or the Activate Damage Dealer node).
  • Activate
    Activates the damage dealer (and sets it’s action).
    This’ll activate the damage dealer at the start of a schematic and deactivate it at the end.

Set Damage Dealer Action Node #

The Set Damage Dealer Action node is used in schematics to set a damage dealer’s action without activating it.

Requires the schematic to be started by an ability or item, otherwise it doesn’t have an action available to set.

Activate Damage Dealer Node #

The Activate Damage Dealer node is used to manually activate and deactivate a damage dealer. This is used for prefabs spawned by an action (e.g. a fireball’s damage dealers) or when you need to have more control over when the damage dealer is active.

The node can also set the action (default setup) of the damage dealer, in which case it has to be used in a schematic animating an ability or item, or it doesn’t have an action available.

Activation without setting the action is always possible, but requires the damage dealer to already have an action set.

You can define additinal activation tags, as well as use a different sound or prefab than defined by the ability or item.

Animation Events #

You can also activate/deactivate damage dealers via animation events.

If the damage dealer already has an action set and the animation is running directly on the damage dealer, you can use the SetDamageActive(bool active) function to activate (true) or deactivate (false) it.

Otherwise, you can add the Combatant Animation Events component to your combatant prefabs to activate/deactivate damage dealers on the combatant:

  • CalculateCurrentAction()
    Calculates the combatant’s current action outcome.
    Same as using a Calculate Action node.
  • CalculateCurrentAction(float damageFactor)
    Calculates the combatant’s current action outcome with the provided damage factor.
    Same as using a Calculate Action node.
  • ActivateDamageDealers()
    Activates all Damage Dealer components on the combatant.
    The damage dealers need to have an action set before activation (e.g. via Set Damage Dealer Action node used in a schematic animating an ability or item).
  • DeactivateDamageDealers()
    Deactivates all Damage Dealer components on the combatant.
  • CurrentActionActivateDamageDealers()
    Activates all Damage Dealer components of the combatant’s current action (have to be set up for auto activation).
  • CurrentActionDeactivateDamageDealers()
    Deactivates all Damage Dealer components of the combatant’s current action (have to be set up for auto activation).

Damage Zones #

Damage Zone components are added to the prefabs of your combatants or equipment (e.g. a shield). A combatant needs at least one damage zone to receive damage from damage dealers.

You can add multiple damage zones and create vulnerable spots  by using the Damage Factor setting. The damage factor determines how much damage on a damage zone will do by multiplying the damage by the defined factor, e.g.:

  • 1 is 100 % damage
  • 0.5 is 50 % damage
  • 1.75 is 175 % damage

Optionally, you can also block the damage completely – e.g. adding a blocking damage zone to a shield will allow a combatant to block attacks with the shield.

Additionally, damage zones can display flying texts caused by the calculations at the damage zone’s game object instead of the combatant’s game object.

They can also play an audio clip or a sound type (on the damage zone’s combatant, i.e. using it’s sound assignments) when receiving damage.

Schematics #

Damage zones can use a schematic when they receive damage.

The schematic will use the user of the attack (i.e. the combatant the damage dealer came from) as Machine Object and the damage zone’s game object as Starting Object.

Use Damage Zone Node #

Schematics used to animate an ability or item can also directly use a Damage Zone component without using a Damage Dealer component. The Use Damage Zone node will use a damage zone on a defined game object.

This can be used in combination with a Raycast node to select a game object, e.g. below the cursor or the center of the screen (crosshair) to implement a FPS shooting mechanic.

Damage Over Time #

Damaging or healing over time is handled by status effects.

E.g. an ability applies a poison status effect.

The effect will reduce the target’s health by 5 % every 10 seconds, and end after 60 seconds.

Learn more about status effects in this documentation.

Combining #

You aren’t limited to use only one of the ways to deal damage.

Different actions can each use the appropriate way to deal damage.

E.g. a targeted magic spell does damage to a selected target (Calculate Action node).

A firewall magic spawns a prefab that deals damage to every combatant walking into it (using damage dealers).

You can also combine them in a single action.

E.g. an explosion magic deals damage directly to a target (Calculate Action node) and spawns fiery debris that can hit other combatants (using damage dealers).