Code : <a href="https://github.com/kjaegers/ScriptCards/blob/main/X_OtherScripts/AuraTriggers.js" rel="nofollow">https://github.com/kjaegers/ScriptCards/blob/main/X_OtherScripts/AuraTriggers.js</a> Docs : <a href="https://github.com/kjaegers/ScriptCards/blob/main/X_OtherScripts/AuraTriggers.md" rel="nofollow">https://github.com/kjaegers/ScriptCards/blob/main/X_OtherScripts/AuraTriggers.md</a> Discord : <a href="https://discord.gg/exT3mDKvbs" rel="nofollow">https://discord.gg/exT3mDKvbs</a> Current Version : 0.8 Aura Triggers allows you to define effects that take place
when token enter or exit an active aura on another token. It supports tokens of
varying radius correctly, with the aura radius extending around the token
regardless of size. The script is not yet on OneClick, so it can be found at the
GitHub link above. Triggers are defined as JSON array in the “gmnotes” field on
a token. A notes field can contain multiple aura definitions that are keyed to
the color of the two auras on the token itself, meaning one color can represent
multiple auras and/or changing the color of an aura can activate/deactivate the
aura effects. JSON elements are case sensitive, and I HIGHLY suggest
running your JSON through an online JSON validator (I use <a href="https://jsonlint.com/" rel="nofollow">https://jsonlint.com/</a> ) to ensure it is
properly formatted. Nearly all of the elements are optional and contain
defaults if they are not set. Supported JSON elements to define an aura and its
effects are: name (string): Display/logical name for the aura
effect. color (string): Must exactly match the aura color
on token, with the # sign (aura1_color or aura2_color). icon (string): Roll20 status marker key to apply
while in aura. toPCs (boolean, default true): Apply to
player-controlled character tokens. toNPCs (boolean, default true): Apply to
non-player-controlled character tokens. toGraphics (boolean, default false): Apply to
non-character graphics. toLayers (string, default objects): Restrict
affected targets to specific Roll20 layers. Example: "objects,gmlayer". Supported
layer values: objects (alias token), gmlayer, map, walls, foreground. ignoreWalls (boolean, default false): if using Path Math to let walls block auras, setting this to true prevents this aura from being impacted by walls. applySelf (boolean, default false): Apply the aura
effect to the aura source token itself. removeOnExit (boolean, default true): Remove status
marker when token exits aura. chatActionOnEnter (string, default ""):
Sent once when token enters an aura. chatActionWhileInside (string, default
""): Sent on movement checks while token remains inside an aura. chatActionOnExit (string, default ""):
Sent once when token exits an aura. chatActionOnStartTurn (string, default `""`): Sent when token starts its turn while inside an aura. chatActionOnEndTurn (string, default `""`): Sent when token ends its turn while inside an aura. sourceVfxOnEnter (string, optional): VFX played at
aura source token on enter event. targetVfxOnEnter (string, optional): VFX played at
affected token on enter event. sourceVfxOnExit (string, optional): VFX played at
aura source token on exit event. targetVfxOnExit (string, optional): VFX played at
affected token on exit event. sourceVfxWhileInside (string, optional): VFX played at aura source token while affected token remains inside. targetVfxWhileInside (string, optional): VFX played at affected token while it remains inside an aura. sourceVfxOnStartTurn (string, optional): VFX played at aura source token when affected token starts turn in aura. targetVfxOnStartTurn (string, optional): VFX played at affected token when it starts turn in aura. sourceVfxOnEndTurn (string, optional): VFX played at aura source token when affected token ends turn in aura. targetVfxOnEndTurn (string, optional): VFX played at affected token when it ends turn in aura. soundOnEnter (string, optional): Jukebox track
title to play on enter event. soundOnExit (string, optional): Jukebox track title
to play on exit event. soundWhileInside (string, optional): Jukebox track title to play while token remains inside an aura. soundOnStartTurn (string, optional): Jukebox track title to play when token starts turn in aura. soundOnEndTurn (string, optional): Jukebox track title to play when token ends turn in aura. attributeFilter (string, optional): Additional
character-attribute condition(s) required for the aura to apply. Note that Aura visibility (if players can see auras or not) is not checked, so GMs can have auras you can see while players cannot. The OnEnter and OnExit (and the chatActionWhileInside )
entries allow for commands that are sent to chat when the indicated event
happens. These are run once for a token
entering or exiting the aura or every time it moves but stays inside the aura
for chatActionWhileInside) . The actions taken can be simple emotes or chat messages, API
calls, or anything else you can send to chat, including ScriptCards code if you
have ScriptCards installed. Examples: [
{
"name": "Blessing Field",
"color": "#00ff00",
"icon": "angel-outfit",
"toLayers": ["map", "objects"]
}
] This simple aura definition triggers if either Aura1_Color
or Aura2_Color matches #00ff00 (Green). Any token passing into the aura that is a PC or
NPC (meaning that the graphics object has a “represents” (for NPCs) or the
represented character has a “controlledby” filled in for PCs), will receive the
“angel-outfit” status marker. When the token exits the aura (or the aura is
deactivated, or the aura token is moved/removed/etc.) the status marker will be
removed. Here is a MUCH more complex example courtesy of Si on
the ScriptCards discord channel:
[
{
"color": "#9900ff00",
"name": "Paladin Aura",
"icon": "angel-outfit",
"toNPCs": false,
"toPCs": true,
"toGraphics": false,
"removeOnExit": true,
"toLayers": "objects,gmlayer",
"chatActionOnEnter": "!script {{ +++5Elib;snlib+++ --#targettoken|[TID] --#sourcetoken|[ATID] --&CharID|[*T:character_id] --&PalID|[*S:character_id] -->Lib5E_FIND_CLASS_LEVEL|[&PalID];paladin;PLevel --?[&PLevel] -le 9|&Courage;.|&Courage; and the Aura of Courage makes you immune to the Frightened Condition --#emoteText|[TNAME] enters the protection of Paladin [ATNAME] --#hideTitleCard|1 --vtoken|[TID] shield-holy -->Lib5E_SET_GLOBAL_MOD_STATUS|[&CharID]; save; Paladin Aura; 1 --!a:[&CharID]|global_save_mod_flag:1 -->Lib5E_GET_GLOBAL_MOD_STATUS|[&CharID]; save; [ANAME];Aura --?[&Aura] -eq 0|>Create|>Exists --X| --:Exists| --Rfind|[&CharID];Paladin Aura;repeating_savemod;global_save_name --!a:[&CharID]|[*R>global_save_roll]:[*S:charisma_mod] --+|[c]Your saving throws will now receive an additional +[*S:charisma_mod] bonus[&Courage][/c] -->Lib5E_FIND_ACTIVE_GLOBAL_SAVE_MODS|[&CharID];Mods --+Global Save Modifiers|[&Mods] -->End| --X| --:Create| --!or:[&CharID]:savemod|global_save_name:Paladin Aura|global_save_active_flag:1|global_save_roll:[*S:charisma_mod] --+|[c]Your saving throws will now receive an additional +[*S:charisma_mod] bonus[&Courage][/c] -->Lib5E_FIND_ACTIVE_GLOBAL_SAVE_MODS|[&CharID];Mods --+Global Save Modifiers|[&Mods] Paladin Level --:End| --X|}}",
"chatActionWhileInside": "!script {{ +++5Elib;snlib+++ --#targettoken|[TID] --#sourcetoken|[ATID] --#emoteText|[TNAME] remains protected by Paladin [ATNAME] --#hideTitleCard|1}}",
"chatActionOnExit": "!script {{ +++5Elib;snlib+++ --#targettoken|[TID] --#sourcetoken|[ATID] --&CharID|[*T:character_id] --#emoteText|[TNAME] leaves the protection of Paladin [ATNAME] --#hideTitleCard|1 --vtoken|[TID] shield-death -->Lib5E_SET_GLOBAL_MOD_STATUS|[&CharID]; save; Paladin Aura; 0}}"
}
]
This D&D 5E sample runs actual ScriptCards scripts (that use the 5ELib and snlib libraries) on
the enter/exit events and turns on/off Global Save Modifiers for a paladin’s
saving throw aura. It will even create the GSM on the target character if it
doesn’t already exist. Note that in this case, the color is set to #9900ff00 and
since the extra “00” is appended as the alpha channel, it means the color is fully transparent, this
aura won’t show visibly but the effect will still take place. You set this
color through the normal Roll20 token interface. Aura Triggers just reads the
color to determine if an aura should be active. Aura Triggers registers with both Token Mod and ScriptCards
to listen for events if they are present (so moving a token/changing aura
colors, etc. from a !token-mod or !script will be watched by Aura Triggers).
I’ve created a channel on my Discord server for discussion
and support of Aura Triggers. It can be found here: <a href="https://discord.gg/exT3mDKvbs" rel="nofollow">https://discord.gg/exT3mDKvbs</a> There are a couple of additional features planned (most notably triggers for "Ends turn in Aura" and "Begins Turn in Aura" since these are frequent triggers for some effects. As always, I'm open to suggestions.