Register

Effect Macro

A Module for Foundry Virtual Tabletop

Author: Zhell Project Source: Project URL Version 10 Last Updated 6 days, 16 hours ago

Effect Macro

A module that allows users to embed macros directly into effects.

These macros are then called automatically when the appropriate trigger happens. The options are:

An effect can have a macro of any of these types, not just one. There is also the static 'never' type meant for being explicitly called by other scripts. This type is never called automatically.

How To Use

Macros are added in the ActiveEffect config. Selecting the type of trigger and clicking 'Add Macro' (or 'Edit Macro' for an existing macro) opens a macro editor. When an embedded macro is triggered, it is run as if executed by the owner of the actor who has the effect; if no such owner exists or is currently active, then it is run as if executed by the GM.

Script Helpers

By default, these variables are pre-defined in any effect macro.

actor, the Actor who has the effect currently.

character, the assigned character of the user who triggered the macro (if they have any), otherwise the same as actor.

token, the actor's token on the scene.

scene, the current scene where token exists, otherwise the currently active scene.

origin, the actor or item who is the origin of the effect (depending on the system, as seen under Source in the Effects tab of the actor), otherwise the same as actor.

effect, the Active Effect itself.

Added functions

A set of asynchronous functions have been added to active effects.

ActiveEffect#callMacro(type, context={}) calls a macro embedded in the effect of the specific type. The context object can be used to pass additional parameters to the script, and can be referenced with this.

ActiveEffect#hasMacro(type) returns true or false dependng on whether the effect has a macro of the given type.

ActiveEffect#removeMacro(type) removes a macro of the given type from the effect.

ActiveEffect#createMacro(type, script) creates an embedded macro of the given type inside the effect. Identical to using the provided interface and writing a macro there. The provided script can be a function or a string.

ActiveEffect#updateMacro(type, script) updates a macro of the given type on an effect. In most cases functionally identical to createMacro, and will remove the embedded macro if no script is provided. The provided script can be a function or a string.

The types can be any of the following: onCreate, onDelete, onToggle, onEnable, onDisable, onTurnStart, onTurnEnd, onEachTurn, onCombatStart, onCombatEnd, onCombatantDefeated, never.

System Specific Triggers

The module works in every system that has Active Effect support, however it can leverage system-specific hooks as well, if added. These are the system-specific hooks added so far:

dnd5e. When you make an attack roll (dnd5e.rollAttack), when you roll damage (dnd5e.rollDamage), when you make a saving throw/death saving throw (dnd5e.rollAbilitySave and dnd5e.rollDeathSave), and when you make an ability check, skill check, or tool check (dnd5e.rollAbilityTest, dnd5e.rollSkill, dnd5e.rollToolCheck). The arguments passed to the system hooks are passed to the macro as well and can be accessed with this.

Categories

Available Versions

  1. Version 1.0.1

    Compatible Foundry Versions: 9 - 9 Installation Link: Manifest URL Update Notes: Read Notes
  2. Version 10.0.0

    Compatible Foundry Versions: 10 - 10.279 Installation Link: Manifest URL Update Notes: Read Notes
  3. Version 10.0.1

    Compatible Foundry Versions: 10 - 10.284 Installation Link: Manifest URL Update Notes: Read Notes
  4. Version 10.0.2

    Compatible Foundry Versions: 10 - 10.285 Installation Link: Manifest URL Update Notes: Read Notes
  5. Version 10.0.3

    Compatible Foundry Versions: 10 - 10.285 Installation Link: Manifest URL Update Notes: Read Notes
  6. Version 10.0.4

    Compatible Foundry Versions: 10 - 10.286 Installation Link: Manifest URL Update Notes: Read Notes
  7. Version 10.0.5

    Compatible Foundry Versions: 10 - 10.286 Installation Link: Manifest URL Update Notes: Read Notes
  8. Version 10.0.6

    Compatible Foundry Versions: 10 - 10.286 Installation Link: Manifest URL Update Notes: Read Notes
  9. Version 10.0.7

    Compatible Foundry Versions: 10 - 10.288 Installation Link: Manifest URL Update Notes: Read Notes
  10. Version 10.0.8

    Compatible Foundry Versions: 10 - 10.290 Installation Link: Manifest URL Update Notes: Read Notes
  11. Version 10.0.9

    Compatible Foundry Versions: 10 - 10.290 Installation Link: Manifest URL Update Notes: Read Notes
  12. Version 10.0.10

    Compatible Foundry Versions: 10 - 10.290 Installation Link: Manifest URL Update Notes: Read Notes
  13. Version 10.0.11

    Compatible Foundry Versions: 10 - 10.290 Installation Link: Manifest URL Update Notes: Read Notes