Flags functionality - thatlonelybugbear/automated-conditions-5e GitHub Wiki

🎯 Automated Conditions 5e: Roll Flags Guide

AC5e processes Active Effects with relevant module flags. If the effect's condition evaluates to true, it alters the relevant roll accordingly.


📦 Flag Types

flags.automated-conditions-5e.ACTIONTYPE.MODE

Affects rolls made by the actor who has an Active effect with this flag.


flags.automated-conditions-5e.aura.ACTIONTYPE.MODE

Affects rolls made by other actors whose token is within range of the source token.

Required:

  • radius=10; — Sets the aura range in grid units.

Optional:

  • singleAura; – Only one aura of the same name applies (strongest or closest).
  • includeSelf; – Affects the aura source as well.
  • allies; – Affects only allies of the aura source.
  • enemies; – Affects only enemies of the aura source.

If neither allies nor enemies is used, the aura affects all tokens in range.


flags.automated-conditions-5e.grants.ACTIONTYPE.MODE

Affects rolls made against the actor (i.e., when the actor is the target of the roll).


🛠 How to Use

Step 1: Choose ACTIONTYPE

Replace ACTIONTYPE with a roll type to affect:

General Types:

  • all
  • attack
  • check
  • damage
  • save

Specific Types:

  • concentration
  • death
  • initiative
  • skill
  • tool

Step 2: Choose MODE

Replace MODE with one of the following:

  • advantage — Grants advantage
  • disadvantage — Imposes disadvantage
  • critical — Forces a critical success
  • fumble — Forces a critical failure
  • success — Treats the roll as a success
  • fail — Treats the roll as a failure
  • bonus — Adds a numeric or calculated bonus
    • When using MODE = bonus, include: bonus=XXX; where XXX is:
      • A fixed number (e.g., bonus=2;)
      • A formula, referencing actors via:
        • @ or rollingActor — e.g., @abilities.cha.mod or rollingActor.cha.mod
        • # or targetActor — e.g., ##attributes.spell.dc or targetActor.concentration.effects.size
        • auraActor — e.g., auraActor.attributes.ac.value for any aura related ones.

Step 3: Add Conditions in the Effect's value Field

Conditions are semicolon-separated expressions evaluated using a dynamic "sandbox" of data relevant to the current roll.

✅ If any one condition is true, the roll is affected.

What Is the Evaluation Sandbox?

The sandbox contains detailed data about the actor performing the roll, potential targets, and other contextual information. This data can be referenced in condition expressions like so:

rollingActor.abilities.cha.mod >= 4 &&  targetActor.attributes.hp.value < 10 && (fire || cold); targetActor.statuses.incapacitated;

Actor Roles in the Sandbox

Depending on the type of roll, actors are categorized like this:

  • rollingActor – the actor performing the roll.
  • opponentActor – the opposing actor (if any). For example:
    • During an attack, this is the target of the attack.
    • During a saving throw, this is the actor whose item or effect triggered the save.
      • targetActor will be deprecated from AC5e v13.502.2
  • auraActor – only present if the roll is affected by an aura. Represents the aura's source.

What Data Can I Use?

Each <actorType> (e.g. rollingActor, targetActor) includes the following:

system Data (Actor's abilities, attributes, etc.)

This mirrors the Foundry system data structure. Example fields:

rollingActor.abilities.cha.mod       // Charisma modifier
rollingActor.attributes.hp.value     // Current HP

token Data (from the active scene token)

Includes token-specific information:

rollingActor.token.name
rollingActor.tokenSize            // token.width x token.height
rollingActor.tokenElevation       // token.document.elevation
rollingActor.tokenSenses          // List of token's detection modes
rollingActor.tokenUuid            // Unique token UUID

effects and equipment

rollingActor.effects              // List of active effects
rollingActor.equippedItems       // Array of equipped item names

statuses

Includes token statuses like prone, bloodied, etc.

rollingActor.statuses.prone  // true if the rolling actor is prone

✅ Creature Type

An Array of data, derived from race or custom type:

rollingActor.creatureType.includes('elemental') || targetActor.creatureType.includes('green')

Global or Roll-Specific Context

In addition to actor data, some useful values are also available:

Key Description
distance Distance between rolling and target token (if any)
isConcentration true if this is a concentration check
isInitiative true if this is an initiative roll
isDeathSave true if this is a death saving throw
isTurn true if it's currently the rolling actor's turn
isTargetTurn true if it's the target's turn
canSee true if the rolling actor can see the target
isSeen true if the target can see the rolling actor
spellLevel spell level if relevant
worldTime Current world time in seconds
tokenId Rolling actor's active token ID
targetId Targeted token's ID if any
effectOriginTokenId ID of the effect's origin active token

🔧 Activity and Item Data

If the roll involves a specific action or item, you'll also have access to:

activity

  • activity.name
  • activity.activation.type — e.g., action, bonus, reaction
  • activity.actionType — e.g., mwak, rsak, save
  • activity.type — item type (e.g., spell, feat)
  • activity.damageTypes — array of damage types involved

item

  • item.name, item.type, item.school (for spells)
  • item.identifier
  • item.properties

All these are accessible directly as paths. For example:

('mgc' && 'fin') || ('Claw' && 'poison')   // true if either an the roll involves a magical finesse weapon, or one named Claw and dealing poison damage

🔥 Damage Types

If the activity deals specific damage types, each one is added to the sandbox:

cold || fire  // true if the damage type is either cold or fire

⚔️ Action Types

If the activity has an action type (e.g., mwak, rsak, save, etc.), that is also flagged:

mwak // true for Melee Weapon Attack

These work in combination with other flags:

mwak && fire // true for fire-dealing melee weapon attacks

📚 Config and Utilities

The sandbox also exposes some config constants:

CONFIG = {
  abilities, skills, tools, damageTypes, spellSchools,
  attackModes, actionTypes, itemProperties, etc.
}

And helpers like:

ac5e.checkDistance(), ac5e.checkVisibility(), ac5e.checkCreatureType(), ac5e.checkArmor()

This sandbox gives you powerful control over when a specific AC5e module flags should apply, letting you create smart, level-aware, context-sensitive automation with minimal code.

⚠️ **GitHub.com Fallback** ⚠️