PDA

View Full Version : 5E Extension - Chat Effects & NPC Variables



GEONE
August 9th, 2022, 18:42
Forge Page:
https://forge.fantasygrounds.com/shop/items/741/view

Description:
This D&D 5E extension does a few unique yet semi-related things. It parses effects outputted to chat from any source and converts them into a draggable effect. It also parses effects in NPC text blocks and adds them to the relevant Combat Tracker field. And finally, it allows math and variables to be used within NPC spells, traits, and actions.

(As a small aside, this extension also automatically fixes NPC's Mage Armor spell to give the correct amount of AC, instead of always just giving a +3 bonus to AC regardless of the creature's current AC and DEX as it does in the base 5E ruleset)

Effect Parsing:
This extension parses effects outputted to chat from any source and converts them into a draggable effect. The most common uses would be through a table output or /roll 0 {message} or /die 0 {message} chat commands.

https://i.imgur.com/VYveFgO.gif

This also works for table results that are outputted to chat, NPC spell/action entries in the Combat Tracker, and more.

https://i.imgur.com/armJ3ej.gif
(A table result being parsed into a draggable effect)

Syntax:
The syntax is a little bit custom. All effects are prefaced with "[EFFECT]" followed by whatever effects you want using the regular effect syntax. Each effect must end with a semicolon (even the final effect). After the final effect, the following tags can be provided to alter the default behaviour (words surrounded by <> need to be replaced and # is any number. Do not include the <WORD> or # in the actual effect)

Tags:
"[D: # <UNIT>]" - sets the duration of the effect and optionally the units of duration (min, hour, day. Defaults to rounds).
"[UNITS: <UNIT>]" - sets units of duration (min, hour, day) if for some reason you don't want to do so in the duration tag.
"[ROLL]" or "[ACTION]" or "[SINGLE] or [DUSE] (BCE only)" - sets the action expiry.
"[ATS] or [DTS] or [RTS] or [AS] or [DS] or [RS] or [AE] or [DE], or [RE], or [SAS] or [SDS] or [SRS] or [SAE] or [SDE], or [SRE]" - sets the BCE change state (BCE only).

Non-functional tags:
The following tags are implemented, but due to how Fantasy grounds handles untargetted effects, do nothing since their values are cleared on untargetted drops (which all from-chat effects are).
"[T: <TARGET>]" - Sets the targeting.
"" - Sets the source of the effect.
"[INIT: #]" - Sets the initiative order to expire the effect on.

All of these tags can only be provided for the whole [EFFECT] tag, meaning it isn't possible to define duration for individual effects within the effect text. Additionally, only one [EFFECT] tag can be defined per text box. The space after the colons are optional.

Examples:

[EFFECT] Stunned;


[EFFECT] RESIST: all; ADVATK; [D: 5 mins]


[EFFECT] DMG: 2d6 fire [D: 1] [ROLL]

Limitations:
This currently does not work for direct-to-chat messages, something must output a message to chat for it to parse effects within it. Using /roll 0 {message} or /die 0 {message} are the simplest ways to do this.

---

NPC Action Effect Parsing:
In addition to parsing effects in chat, this extension also parses effects in NPC stat block actions and spells. If a spell or action does not give you a draggable effect on the NPC record or CT entry, you can simply add an [EFFECT] tag to the bottom of that action and not only will it be highlighted and draggable, but it will also show up in that action's entry on the Combat Tracker.

You must use the Combat Tracker effect syntax for effects in the Combat Tracker. This means doing something like this "[EFFECT] AC: 5; (D:3 MIN)" to set the duration and "[EFFECT] AC: 5; (A:ROLL)" to set the expiry, as the above tags are ignored in the Combat Tracker (no space after the colon on these CT-specific tags, and they are positioned before the final semicolon of the last effect)

https://i.imgur.com/0H9g2bL.png
(A custom weapon effect in a NPC action being parsed to the Combat Tracker)

MATH tag:
In NPC records and effects, you can also use a new tag [MATH:] which will parse simple mathematical equations inside the tag, like [MATH: 4+6]. It also supports some mathematical functions like floor(), ceil(), abs(), log(), min(), max(), sin() and others. This tag uses LuaXP to parse these math equations, so go checkout the github for more information: https://github.com/toggledbits/luaxp.

Note: If the final value of a math operation is a non-whole number, fantasy grounds will treat it as a 0, so it's best to round down the numbers (specifically CR) using floor() inside the MATH tag.

Variables:
There is also support for certain variables of creatures. Adding any of these variables anywhere in an NPC action or in any effect will replace the variable with the creature's corresponding stat. The available variables are as follows:

[AC] - The creature's Armor Class.
[HP] - The creature's maximum Hit Points.
[CURHP] - The creature's current Hit Points.
[CR] or [LVL] - The creature's Challenge Rating (converted to decimal form) or total level if it's a player. Both variables do the same thing regardless of PC or NPC.
[PRF] - The creature's Proficiency Bonus.
[STR], [DEX], [CON], [INT], [WIS], or [CHA] - The creature's ability modifier for the specified ability. Works with extensions that add new abilities.

These variables do not update in real-time and require the NPC record to be closed and reopened to reflect any changes to the base stat, or for the effect to be re-applied if the variable is inside an effect.

https://i.imgur.com/9bHhN3h.gif
(Variables being used inside an effect. Notice how the effect has different values when applied to different creatures. If this effect was applied from a PC character sheet, it would always use the player's stats instead of the target's.)

Examples:
This example is a weapon attack that adds the NPC's proficiency bonus to the attack roll, and rolls a number of d6 damage dice equal to the NPC's Challenge Rating with it's Dexterity modifier added to the damage.
https://i.imgur.com/PV1x1RY.png
For this particular NPC, the game treats this action as if it instead says "Melee Weapon Attack:+3 to hit, reach 5 ft., one target. Hit: 5d6 + 2 slashing damage." since the creature's CR is 5, Proficiency bonus is +3, and Dexterity modifier is +2.

This example is a breath weapon that adds five times the NPC's proficiency bonus to the DC of the Dexterity saving throw, and rolls a number of d6 damage dice equal to half the NPC's Challenge Rating rounded down, with it's Proficiency Bonus added to the damage.
https://i.imgur.com/SulpMG0.png
For this particular NPC, the game treats this action as if it instead says "Each creature in that area must make a DC 15 Dexterity saving throw, taking 2d6 + 3 fire damage on a failed save." since the creature's CR is 5 and its Proficiency bonus is +3.

---

[B]New Effect: REDUCE (Undo Damage/Heal extension only)
The REDUCE: x effect will reduce the last damage you took by x after you apply the effect. This can be used for things like Stone's Endurance to reduce the last damage you took when applying the effect by 1d12 (i.e. REDUCE: 1d12). The effect is automatically removed after applying it.

Limitations:
The text-highlighting when hovering over draggable text is not always the correct size, and ends up underlapping or overlapping other text when used with variables and the MATH tag.
MATH tags with variables inside them do not work as expected when used in a PC's power/spell effects on the abilities tab of their character sheet; it applies variables based on the target's stats, not the caster's.

Compatibility:
This extension should be fully compatible with almost any extension. Unless another extension modifies PowerManager.parseNPCPower (which this extension overrides).

Changelog:
- Updated to v1.1.2
-- More bug fixes related to BCE integration.
- Updated to v1.1.1
-- Bug fixes related to BCE integration.
- Updated to v1.1.0
-- Many bug fixes. Added support for BCE extension (Thanks rhagelstrom), Added support for Undo Damage/Heal extension.
- Updated to v1.0.7
-- Updated Mage Armor effect to use new tag format.
- Updated to v1.0.6
-- Hidden table rolls will now be parsed for effects.
- Hotfix to v1.0.5.1
-- Nil chat message text will no longer throw an error.
- Updated to v1.0.5
-- NPCs can now have multiple EFFECT tags per line.
- Updated to v1.0.4
-- Added CURHP variable.
- Hotfix v1.0.3.1
-- Fixed issue with duration units.
- Updated to v1.0.3
-- All variables now work inside PC character sheets. The variables use the player's stats instead of the recipients', as per default FGU effect tag behavior.
- Updated to v1.0.2
-- Changed variable syntax to better match FGU player effect tags.
- Updated to v1.0.1
-- Added support for variables and math in effects.

GEONE
August 12th, 2022, 15:12
Updated to v1.0.3
- All variables now work inside PC character sheets. The variables use the player's stats instead of the recipients', as per default FGU effect tag behavior.

GEONE
August 17th, 2022, 02:52
Updated to v1.0.4
- Added CURHP variable. Removed chat debug.

GEONE
August 26th, 2022, 07:35
Updated to v1.0.5
- NPCs can now have multiple [EFFECT] tags per line.

https://i.imgur.com/1ywXjbd.png

rocketvaultgames
September 14th, 2022, 16:31
Is there any way to use the MATH function to cause an attack to deal double damage (not just double dice like a normal crit)?

My current workaround is to give the target a VULN: all effect before processing damage.

MeAndUnique
September 15th, 2022, 14:30
Is there any way to use the MATH function to cause an attack to deal double damage (not just double dice like a normal crit)?

My current workaround is to give the target a VULN: all effect before processing damage.

MATH seems like it would be able to cause the attack to do something like double strength as a damage bonus, rather than modifying the result after the roll. However, the Blissful Ignorance (https://forge.fantasygrounds.com/shop/items/429/view) extension provides the DMGMULT effect to multiply the bearer's damage totals.

rocketvaultgames
September 15th, 2022, 16:00
Thank you so much. That's exactly what I'm looking for (and already have it). There are so many great extensions out there... it's hard to remember which does what sometimes.

charmov
September 21st, 2022, 03:38
Hi there! I'm getting an error with this extension. The error is thrown when I try to advance the initiative with the "next actor" button. It doesn't seem to break the game otherwise. I use many other extensions and haven't tested this with a fresh campaign. When I turn this extension off and run all the other ones the error does not appear when advancing the initiative.

Thanks very much for making this!
54442

GEONE
September 21st, 2022, 09:17
Hi there! I'm getting an error with this extension. The error is thrown when I try to advance the initiative with the "next actor" button. It doesn't seem to break the game otherwise. I use many other extensions and haven't tested this with a fresh campaign. When I turn this extension off and run all the other ones the error does not appear when advancing the initiative.

Thanks very much for making this!
54442

Thanks for the report. One of those extensions must be outputting a chat message with no text whenever a new turn starts. I've added a nil check to rMessage.text for this extension, so it should no longer be an issue.

charmov
September 21st, 2022, 15:05
Thanks for the report. One of those extensions must be outputting a chat message with no text whenever a new turn starts. I've added a nil check to rMessage.text for this extension, so it should no longer be an issue.

Yup, just tested with your update. Error message gone! thanks!

obo
October 2nd, 2022, 16:46
Hi! Thanks for the great work! I am having a hard time using output from a table to generate an effect. I have made a simple table with the text (including the line break) like this:


Blah blah blah.
[EFFECT] Stunned;

Unfortunately it seems like the extension does not parse this:
https://www.fantasygrounds.com/forums/attachment.php?attachmentid=54566&stc=1&d=1664725149

Typing "/roll 0 [EFFECT] Stunned;" works as intended, and I can drag and drop the effect without problems:
https://www.fantasygrounds.com/forums/attachment.php?attachmentid=54567&stc=1&d=1664725167

What am I doing wrong here? :)

GEONE
October 2nd, 2022, 18:07
Hi! Thanks for the great work! I am having a hard time using output from a table to generate an effect. I have made a simple table with the text (including the line break) like this:


Blah blah blah.
[EFFECT] Stunned;

Unfortunately it seems like the extension does not parse this:
https://www.fantasygrounds.com/forums/attachment.php?attachmentid=54566&stc=1&d=1664725149

Typing "/roll 0 [EFFECT] Stunned;" works as intended, and I can drag and drop the effect without problems:
https://www.fantasygrounds.com/forums/attachment.php?attachmentid=54567&stc=1&d=1664725167

What am I doing wrong here? :)

It must be another extension that you have that's overriding the table output code. What extensions are you using?

obo
October 3rd, 2022, 18:14
It must be another extension that you have that's overriding the table output code. What extensions are you using?

This is probably the reason as we use about 20 extensions in total. That means my syntax was correct with the table output, so I will start the elimination process ;)

helarion
November 30th, 2022, 20:53
I'm having the same issue with my table effects and I seem to have found where it comes from.
Everything works fine if my table is in "Show roll results" but stops finding the effects when the results are hidden.

55307

I suppose it's not how it's supposed to work, I tested it without any other extension loaded and keep having the same results.

GEONE
December 1st, 2022, 22:34
I'm having the same issue with my table effects and I seem to have found where it comes from.
Everything works fine if my table is in "Show roll results" but stops finding the effects when the results are hidden.

55307

I suppose it's not how it's supposed to work, I tested it without any other extension loaded and keep having the same results.

Good catch! I've updated the extension so that hidden table results are also parsed now. The update should be available as soon as it's approved on the forge.

helarion
December 2nd, 2022, 11:07
Glad if I could help :D
Thanks for such a quick fix, i'll be sure to try it out once it's updated !

GEONE
January 21st, 2023, 18:43
Updated to v1.0.7
- Updated Mage Armor effect to use new tag format.
- Actually set the live build to the correct version on the Forge (derp).

rhagelstrom
April 27th, 2023, 17:48
I had a user request to have this extension have more harmony with Better Combat Effects cyclers. I've modded it to do that, attached. User Documentation is as follows


Syntax:
The syntax is a little bit custom. All effects are prefaced with "[EFFECT]" followed by whatever effects you want using the regular effect syntax. Each effect must end with a semicolon (even the final effect). After the final effect, the following tags can be provided to alter the default behaviour (words surrounded by <> need to be replaced and # is any number. Do not include the <WORD> or # in the actual effect)

Tags:
"[D: # <UNIT>]" - sets the duration of the effect and optionally the units of duration (min, hour, day. Defaults to rounds).
"[UNITS: <UNIT>]" - sets units of duration (min, hour, day) if for some reason you don't want to do so in the duration tag.
"[ROLL]" or "[ACTION]" or "[SINGLE] or [DUSE]" - sets the action expiry.
"[ATS] or [DTS] or [RTS] or [AS] or [DS] or [RS] or [AE] or [DE], or [RE], or [SAS] or [SDS] or [SRS] or [SAE] or [SDE], or [SRE]" - sets the BCE/G change state

NPC Action Effect Parsing:
In addition to parsing effects in chat, this extension also parses effects in NPC stat block actions and spells. If a spell or action does not give you a draggable effect on the NPC record or CT entry, you can simply add an [EFFECT] tag to the bottom of that action and not only will it be highlighted and draggable, but it will also show up in that action's entry on the Combat Tracker.

You must use the Combat Tracker effect syntax for effects in the Combat Tracker. This means doing something like this "[EFFECT] AC: 5; (D:3 MIN)" to set the duration and "[EFFECT] AC: 5; (A:ROLL)" to set the expiry, as the above tags are ignored in the Combat Tracker (no space after the colon on these CT-specific tags, and they are positioned before the final semicolon of the last effect). To set the BCE/G change state the format must be "(S:x)" where x is any of the change state shorthands listed above

GEONE
April 27th, 2023, 19:36
I had a user request to have this extension have more harmony with Better Combat Effects cyclers. I've modded it to do that, attached. User Documentation is as follows


Syntax:/[B]
The syntax is a little bit custom. All effects are prefaced with "[EFFECT]" followed by whatever effects you want using the regular effect syntax. Each effect must end with a semicolon (even the final effect). After the final effect, the following tags can be provided to alter the default behaviour (words surrounded by <> need to be replaced and # is any number. Do not include the <WORD> or # in the actual effect)

[B]Tags:
"[D: # <UNIT>]" - sets the duration of the effect and optionally the units of duration (min, hour, day. Defaults to rounds).
"[UNITS: <UNIT>]" - sets units of duration (min, hour, day) if for some reason you don't want to do so in the duration tag.
"[ROLL]" or "[ACTION]" or "[SINGLE] or [DUSE]" - sets the action expiry.
"[ATS] or [DTS] or [RTS] or [AS] or [DS] or [RS] or [AE] or [DE], or [RE], or [SAS] or [SDS] or [SRS] or [SAE] or [SDE], or [SRE]" - sets the BCE/G change state

NPC Action Effect Parsing:
In addition to parsing effects in chat, this extension also parses effects in NPC stat block actions and spells. If a spell or action does not give you a draggable effect on the NPC record or CT entry, you can simply add an [EFFECT] tag to the bottom of that action and not only will it be highlighted and draggable, but it will also show up in that action's entry on the Combat Tracker.

You must use the Combat Tracker effect syntax for effects in the Combat Tracker. This means doing something like this "[EFFECT] AC: 5; (D:3 MIN)" to set the duration and "[EFFECT] AC: 5; (A:ROLL)" to set the expiry, as the above tags are ignored in the Combat Tracker (no space after the colon on these CT-specific tags, and they are positioned before the final semicolon of the last effect). To set the BCE/G change state the format must be "(S:x)" where x is any of the change state shorthands listed above

Amazing! I've integrated these changed (along with a host of bug fixes, compatibility, and new features) into the latest update.

BlazingAzureCrow
August 5th, 2023, 11:51
I'm having some trouble getting the Better Combat Effects Gold cycler effects (like SRS) to work when making [EFFECT] tags on NPC sheets. Could someone give me an example of how one of those might be coded to change the cycler?

rhagelstrom
August 6th, 2023, 16:47
I'm having some trouble getting the Better Combat Effects Gold cycler effects (like SRS) to work when making [EFFECT] tags on NPC sheets. Could someone give me an example of how one of those might be coded to change the cycler?

Example:

/roll 0 [EFFECT] AC: 5; [D: 4] (S:AS)

BlazingAzureCrow
August 9th, 2023, 22:14
Example:

/roll 0 [EFFECT] AC: 5; [D: 4] (S:AS)

This didn't work either. When put into an action on an NPC sheet and then dropping that onto the Combat Tracker, the effect produced on the CT is just "[EFF: AC: 5 (D:4)" - the cycler state doesn't make it onto it. Just to be clear, this formatting is intended for the trait/action/bonus action/etc sections of an NPC sheet and not intended to just be dropped into the chat?

GEONE
August 9th, 2023, 23:14
This didn't work either. When put into an action on an NPC sheet and then dropping that onto the Combat Tracker, the effect produced on the CT is just "[EFF: AC: 5 (D:4)" - the cycler state doesn't make it onto it. Just to be clear, this formatting is intended for the trait/action/bonus action/etc sections of an NPC sheet and not intended to just be dropped into the chat?

I can't reproduce this issue, but I'm not exactly using the most up-to-date version of BCE. Both using "/roll 0 [EFFECT] AC: 5; [D: 4] (S:AS)" and putting "[EFFECT] AC: 5; [D: 4] (S:AS)" in a NPC record correctly add the effect "AC: 5" with a duration of 4. Try replacing (S:AS) with [AS] and see if that works for you.

rhagelstrom
August 9th, 2023, 23:47
I can confirm

It looks like this
58476

It should look like this
58477

BlazingAzureCrow
August 10th, 2023, 01:55
I can confirm

It looks like this
58476

It should look like this
58477

This is the issue. No arrangement properly produces the cycler state and the duration. Hopefully this gets fixed, because having these in NPC records in a game-changer.

GEONE
August 11th, 2023, 08:05
I've updated the extension to implement suggested changes by rhagelstrom.

BlazingAzureCrow
August 11th, 2023, 09:07
That seemed to fix the cycler issue! I do notice that if I have a duration in the effect, it's adding +1 round to it now. For example, "RESIST: all; [D:1]" is producing an effect with a duration of 2 rounds, [D:5] is producing one with 6 rounds, etc. Is this intentional?

GEONE
August 11th, 2023, 09:47
That seemed to fix the cycler issue! I do notice that if I have a duration in the effect, it's adding +1 round to it now. For example, "RESIST: all; [D:1]" is producing an effect with a duration of 2 rounds, [D:5] is producing one with 6 rounds, etc. Is this intentional?

No that's not intended

rhagelstrom
August 11th, 2023, 20:13
That seemed to fix the cycler issue! I do notice that if I have a duration in the effect, it's adding +1 round to it now. For example, "RESIST: all; [D:1]" is producing an effect with a duration of 2 rounds, [D:5] is producing one with 6 rounds, etc. Is this intentional?

If you are also using a BCE?G change state then maybe.. It depends. If everything that is the issue and change state is being added by this extension, then probably best to move over to the BCE/G thread(s)

BlazingAzureCrow
August 11th, 2023, 21:51
If you are also using a BCE?G change state then maybe.. It depends. If everything that is the issue and change state is being added by this extension, then probably best to move over to the BCE/G thread(s)

The duration issue happens when effects are added from the NPC sheets as per this extension, so I presume it has something to do with this extension's update. I'll play around and see if I can reproduce it without this extension and get back to you guys.

EDIT: After some testing, it only happens on effects applied using the "[EFFECT] etc; etc" format on NPC records, so I still presume it's this extension.

SECOND EDIT: It's happening sometimes and not other times. It's probably something on my end.

THIRD AND FINAL EDIT: It's working as intended. I'm just dumb.