SC - Conditional AE
SC - Conditional AE
Overview
SC - Conditional AE extends the D&D 5e Active Effect workflow in three practical ways:
- a Condition tab on the Active Effect sheet
- an optional Formula column for effect changes
- a macro execution change that can run when an effect turns on or off
In practice, this lets you build effects that:
- only apply while a JavaScript condition returns
true - roll a fresh number when the effect activates and write that result into the change value
- trigger a world macro as the effect is enabled, disabled, or removed
If a condition evaluates to false, the effect is suppressed and does not apply.
Installation
This module will be free, but it is currently in development.
The public manifest URL is intentionally hidden until the release build is ready.
For now, treat this page as documentation for the upcoming release workflow and feature set. Installation details will be published when the module leaves development.
Requirements
- Foundry VTT
v13orv14 - system:
dnd5e - dnd5e system version:
4.0.0+ - recommended: libWrapper
Compatibility notes from the module behavior:
- legacy DAE condition flags are adapted into the new Condition tab
- DAE-style expressions using
@data references are supported through compatibility mode - a safe fallback type is registered for Aura Effects data when Aura Effects itself is not active
Feature Overview
| Feature | What it does | Where you use it |
|---|---|---|
| Condition tab | Runs JavaScript to decide whether the Active Effect should currently apply. | Active Effect sheet |
| Formula column | Rolls a formula on activation and writes the rolled total into the normal change value. | Active Effect changes table |
| Macro execution change | Executes a world macro when the effect turns on or off. | Active Effect changes table |
Condition Tab
When Show condition tab is enabled, Active Effect sheets gain a dedicated Condition tab.
Use it to write either:
- a short expression such as
actor?.system?.attributes?.hp?.value > 0 - or a full JavaScript block that explicitly returns
trueorfalse
Examples:
return actor?.system?.attributes?.hp?.value > 0;actor?.system?.attributes?.hp?.value > 0The module builds the condition context with variables such as:
effectactortargetActoritemoriginoriginActoruserrollDatasourcegetPropertyhasPropertydeepClonegame
Behavior details worth knowing:
- empty conditions always allow the effect
- invalid condition code suppresses the effect instead of partially applying it
- conditions must stay synchronous in native JavaScript mode
- actor effects and transferred item effects both evaluate through the same condition service

Example Conditions
These examples are ready to copy into the Condition tab.
Actor Must Have More Than 0 HP
return (actor?.system?.attributes?.hp?.value ?? 0) > 0;Actor Must Be Bloodied
const hp = actor?.system?.attributes?.hp?.value ?? 0;
const maxHp = actor?.system?.attributes?.hp?.max ?? 0;
return hp <= maxHp / 2;Actor Must Be Below Half HP
const hp = actor?.system?.attributes?.hp?.value ?? 0;
const maxHp = actor?.system?.attributes?.hp?.max ?? 0;
return maxHp > 0 && hp < maxHp / 2;Item Must Be Equipped
return item?.system?.equipped === true;Item Must Be Attuned
return item?.system?.attunement === 2;Item Must Be Equipped And The Actor Must Be Alive
return item?.system?.equipped === true
&& (actor?.system?.attributes?.hp?.value ?? 0) > 0;Item Must Have At Least One Socket Occupied
Use this when the effect belongs to an item that also uses SC - Simple Sockets.
const sockets = item?.getFlag?.("sc-simple-sockets", "sockets") ?? [];
return sockets.some((slot) => Boolean(slot?.gem));Item Must Have At Least Two Occupied Sockets
const sockets = item?.getFlag?.("sc-simple-sockets", "sockets") ?? [];
const occupied = sockets.filter((slot) => Boolean(slot?.gem));
return occupied.length >= 2;Item Must Have A Specific Gem UUID Socketed
const sockets = item?.getFlag?.("sc-simple-sockets", "sockets") ?? [];
return sockets.some((slot) => slot?.gem?.uuid === "Item.yourGemUuidHere");Item Must Have At Least One Socket Defined
const sockets = item?.getFlag?.("sc-simple-sockets", "sockets") ?? [];
return sockets.length > 0;Only The GM Can Benefit From The Effect
return user?.isGM === true;Effect Must Only Apply During Combat
return Boolean(game?.combat);For socket checks, the examples above use direct flag reads instead of async API calls because native SC - Conditional AE conditions are synchronous.
Formula-Backed Changes
When Enable formula column is enabled, eligible Active Effect changes can store an extra formula alongside the normal value.
Use this when you want the effect to roll at activation time instead of hard-coding the final number.
Example setup:
Attribute Key: system.attributes.hp.tempmax
Mode: Add
Value: 0
Formula: -2d6Ready-to-copy formula ideas:
Roll Negative Temporary Hit Point Maximum
Attribute Key: system.attributes.hp.tempmax
Mode: Add
Value: 0
Formula: -2d6Roll Positive Temporary Hit Point Maximum
Attribute Key: system.attributes.hp.tempmax
Mode: Add
Value: 0
Formula: 2d6Roll A Small Temporary Hit Point Bonus
Attribute Key: system.attributes.hp.tempmax
Mode: Add
Value: 0
Formula: 1d4 + 1Scale Temporary Hit Point Maximum With Spellcasting
Attribute Key: system.attributes.hp.tempmax
Mode: Add
Value: 0
Formula: 1d6 + @abilities.cha.modScale Temporary Hit Point Maximum With Proficiency
Attribute Key: system.attributes.hp.tempmax
Mode: Add
Value: 0
Formula: 1d8 + @profTypical runtime flow:
- The effect becomes active.
- The responsible user is prompted to review or edit the formula.
- The formula is rolled.
- The rolled total is written into the effect's normal Value field.

Responsibility selection follows the module logic:
- an active non-GM owner is preferred first
- if no active player owner is available, the active GM handles the roll
This is useful for:
- variable temporary HP penalties or bonuses
- random stat adjustments
- effects that should re-roll whenever they come back online
Macro Execution Changes
To execute a world macro from an Active Effect, add a change with:
- Key:
cae.macro.execute - Mode:
Custom - Value: a macro name or UUID, followed by optional arguments
Example:
Apply Rage "fire" 2That would try to execute the macro Apply Rage and pass fire and 2 as macro arguments.
The execution scope includes:
actionactortokeneffectitemoriginchangeargsmacroArgslastArgspeakeruser
Action values:
onwhen the effect is applied or re-enabledoffwhen the effect is disabled or deleted
The service also supports:
sc-conditional-ae.macro.executeas a legacy keymacro.executewhen DAE is not active
If DAE is active, DAE remains responsible for macro.execute.
Compatibility Notes
The module includes explicit compatibility behavior for older and adjacent workflows.
| Integration | Behavior |
|---|---|
| DAE condition flags | Reads legacy `flags.dae.enableCondition` and `flags.dae.disableCondition` values and surfaces them through the Condition tab. |
| DAE expression syntax | Supports compatibility expressions that use `@` roll-data references, `dae.eval(...)`, and `dae.roll(...)`. |
| DAE macro changes | Adds `cae.macro.execute` to DAE specials and avoids taking over `macro.execute` when DAE is active. |
| Aura Effects | Registers a fallback Active Effect type for Aura Effects data when that module is not active, so imported effect data has a safer landing path. |
Module Settings
Go to Game Settings -> Module Settings -> SC - Conditional AE.
| Setting | Default | What it does |
|---|---|---|
| Enable formula column | On | Adds the Formula column to Active Effect changes and enables activation-time rolls. |
| Show condition tab | On | Adds the Condition tab to Active Effect configuration sheets. |
| Documentation | - | Opens the module wiki. |
| Support the developer | - | Opens the Patreon support page. |
Both boolean settings require a reload after you change them.
Troubleshooting
The effect never applies
Check these first:
- Confirm the Condition tab returns
true. - Verify the code is valid JavaScript.
- Do not use async code in the native JavaScript condition workflow.
- If the effect came from DAE, verify the original expression still makes sense for the current actor data.
The Formula column is missing
- Make sure Enable formula column is on.
- Reload the world after changing that setting.
The macro does not run
- Confirm the change key is
cae.macro.execute. - Confirm the change mode is Custom.
- Make sure the referenced macro exists in the world macro directory.
- Check whether the effect is being suppressed by its condition.
Notes and Limits
- This page reflects the current development build and may change before release.
- The public manifest URL is intentionally not shown yet.
- Native JavaScript conditions are synchronous; asynchronous logic is only relevant to compatibility expressions handled outside that path.
- If condition code throws an error, the effect is treated as unavailable.