Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Script] Condefinition

November 14 (2 years ago)

Edited July 07 (2 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

This is still in development, but it could be useful as is.

[Code]


Condefinition reads incoming roll templates and looks for imposed conditions and saving throws. It then spits out a short list of buttons.

  • If the roll template contains a saving throw, it gives a button for the saving throw. Press the button and click on a target to have it roll the appropriate save. If you have GroupCheck installed, it will run a groupcheck save. If you have Apply Damage installed, it will run through the steps to do a save and apply damage.
  • If the roll template contains an imposed condition, it will create a button to define the condition. If there is a cross reference in the definition of the condition, it  will create an inline link. You can also hover over the button for the text. You can use this button to whisper the text to yourself, or broadcast to the players.
  • You can also toggle that condition on any selected tokens. Assigning token markers requires installing TokenMod, and for greater facility, LibTokenMarkers. It comes with the default Status Markers assigned, but can be edited to use custom token markers. Instructions are in the post below.

Currently, there are some limitations:

  • This is built for GMs to facilitate running NPCs. It doesn't do saves for PCs, and doesn't read some roll templates that are unique to PCs. It is designed to parse the D&D 5th Edition by Roll20 Sheet.
  • I have tried to catch every variation of condition wording, but I have probably missed a few incidences, particularly in products which do not adhere well to the WotC style.
  • In this iteration, all buttons and definitions are whispered to the controller of the NPC, typically the GM. If there is interest, I may change this to obey the whisper settings of the NPC, but I did not want to spam the chat. 
  • It does not yet handle spells, only attacks, actions and traits.

Demo (click for animation):



Condefinitions can produce a reference palette of all buttons. Type !condef-all  to display this.


Condefintion will monitor if the token taking damage has a defined concentration marker on it. If you reduce the hit point bar of a concentrating token, the script will prompt you to make the appropriate Constitution save. You can set this Concentration marker on this line:

    // SET STATUS CONDITIONS OR TOKEN MARKERS HERE 
    const condefConcetrationMarker = "status_" + "Concentrating::35390";

Example. "Random" just took 40 hp of damage while concentrating on a spell:



Condefintions now allows you to select any number of tokens and run !condef-report. The script produces a set of report buttons for each selected token that has a defined condition marker on it.The sub-buttons that toggle token markers will only affect the respective token, and that token does not need to be selected.


November 14 (2 years ago)

Edited November 18 (8 months ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Reserved for future editing.

  • 0.0.0b2 Condefinition now supports spells.
  • 0.0.0b3 Checks for installation of GroupCheck and Apply Damage and modifies Saving Throw buttons accordingly. Minor cosmetic changes to make the display a little more compact. Thanks to Oosh for help on formatting.
  • 0.0.0b4 Created button tabs for each button to send the definition publicly or whisper to the sender. Save buttons only display for GM, but players receive condition buttons for appropriate roll templates they generate.
  • 0.0.0b5 Bug Fixes, better matching for Group Check and Apply Damage, Cosmetic changes to reports. Output is not saved to Chat Archive.
  • 0.0.0b6 Adding Token-Mod and LibTokenMarkers features to apply the appropriate token marker to any selected tokens. Thses markers are use configurable, but do require some simple code editing.
  • 0.0.b7 Added ability to produce a reference palette of all condition buttons. Added Concentration monitoring and saving. 
  • 0.0.b8 Registered Concentration Monitoring for events caused by Token Mod, and hence Autobuttons, and anything else that depends on Token-mod for hit point alteration.
  • 0.0.b9 Added the !condef-report command
  • 0.0.b10 Added player friendly behavior. [see here]
  • 0.0.b11 Corrected typos in descriptions that were found by Jarren, confirmed that id numbers are not needed in marker names, fixed
  • 0.0.b12 Added partial support for 2024 sheet
  • some special case grep matching.
November 14 (2 years ago)

Looks like a great tool!

1. Is this specifically written for D&D 5th Edition? (And more specifically for the D&D 5E by Roll20 sheet?) Or would this work as-is with other systems like Pathfinder?

2. Are the buttons configured to apply status markers? Or could they easily be configured to add a Token-Mod command?

November 14 (2 years ago)

Edited November 14 (2 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Good questions!

1. Yes, it is sheet specific to the D&D 5th Edition by Roll20 Sheet, because the language and templates are very specific. It could be ported with a mall amount of effort to anyone familiar with the other sheets. It checks for the existence of specific roll templates in the incoming chat messages. (easy change), and then parses out the conditions with some regex (moderate to difficult change, depending on how formal and regular the language is in another sheet.) Each condition has its own regex in an array, so it might be easy enough to target. (example: creatures "become charmed" but are "knocked prone". The whole saving throw section would probably need re-writing.

2. They are not. I did consider it, but I did not want to make it dependent on the existence of token-mod or a particular set of custom token markers. On my own copy in my own game, the saving throw button calls a Group Check save, since that is more robust, but the released version just uses the sheet action. If you want to test groupcheck, then line 167 changes from:

saveButton = `<a href="!&#13;&#37;{target|npc_${theAbility}}" style=${saveButtonstyle}>DC${saveDC} ${theAbility}</a>`;
to:
 saveButton = `<a href="!group-check --${theAbility} Save" style=${saveButtonstyle}>DC${saveDC} ${theAbility}</a>`;
I think it would also be cool to somehow roll it into Autobuttons, to save chat space if nothing else.

Edit: I put that changed line in, with instructions to comment out one or the other.
November 14 (2 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

For the addition of Tokenmod buttons, I would add buttons to the definition of the condition, again, to avoid cluttering the interface.

November 15 (2 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

The script now checks to see if GroupCheck and Apply damage have been installed. If they are available the Saving Throw button will instead use those scripts. Also in this case, there will be separate buttons to roll the saves and to do damage. 

Base Behavior:

With GroupCheck and ApplyDamage:


The latter buttons will use DC and Save Ability, but will ask for the damage and whether it is normal, halved or none on a success.



Also, I made some minor cosmetic changes to make the display a little more compact. Thanks to Oosh for help on formatting.

November 15 (2 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Created button tabs for each button to send the definition publicly or whisper to the sender. Press the name of the condition to whisper it to yourself, or the word balloon 


November 23 (2 years ago)

Edited January 22 (2 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

New feature.

Code updated in top post

This requires Token-Mod and LibTokenMarkers to be installed. Both are available in One-click. The scrip will now produce a button to apply a token marker for the given condition to any selected tokens. As-is the script is set to use the limited choices available from the Status Marker set:


  • bleeding-eye
     blinded 

    chained-heart
      charmed

    overdrive
     deafened
     
    half-haze
     exhaustion

    screaming
     frightened

    grab
     grappled

    interdiction
     incapacitated",
     
    ninja-mask
     invisible
     
    aura
     paralyzed

    chemical-bolt
     petrified

    skull
     poisoned

    back-pain
     prone

    cobweb
     restrained

    broken-skull
     stunned

    death-zone
     unconscious


    The full list is at the bottom of the post if you want to redefine. The definitions are stored in the last entry for each condition in the conditionsArray object, currently starting at line 40. note that the names go between backticks: ` not single quotes: '. 
    You can also use custom token markers if you wish. You can find the complete list of custom token markers in your game in the help handout created by token-mod. Note that they must include the name and the id number, separated by double semicolons, not double colons. (this is to prevent breakage from being inserted into an html link. So for example, to use my own custom token marker for "blinded" I replace:
    `bleeding-eye`
    with:
    `Blinded;;30980`

    ID numbers are no longer required. You can simply replace:
    `bleeding-eye`
    with:
    `Blinded;;30980`


    Here is an example of what the output looks like with the base Status Markers:


    For each condition:
    • the lefthand end of the button posts the definition for all players
    • the middle portion (the name) whispers the definition to the GM and displays it on hover
    • the right hand end toggles that condition on all selected tokens.


Token Mod is required for the condition to be toggled on the token. If it is not installed, the button is non functional.

LibTokenMarkers is required to make the image of the condition to display on the button. If it is not installed, a simple circle is displayed in the button, but the condition will still toggle via token-mod.


Base status markers, for reference:

skull

sleepy
half-heart
half-haze
interdiction
snail
lightning-helix
spanner
chained-heart
chemical-bolt
death-zone
drink-me
edge-crack
ninja-mask
stopwatch
fishing-net
overdrive
strong
fist
padlock
three-leaves
fluffy-wing
pummeled
tread
arrowed
aura
back-pain
black-flag
bleeding-eye
bolt-shield
broken-heart
cobweb
broken-shield
flying-flag
radioactive
trophy
broken-skull
frozen-orb
rolling-bomb
white-tower
grab
screaming
grenade
sentry-gun
all-for-one
angel-outfit
archery-target


November 23 (2 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

The images for each token marker did not display in the post above, because Roll20 text editor.


November 26 (2 years ago)

Hey Keith, this is pretty dang great!  I was able to define the custom markers I use, but the buttons don't apply the markers to selected tokens (they're not clickable like the save button and the description buttons).  I'm brand-spankin' new to mods and it's super late, so I'm certain it's a user error.  I just don't know what to look for at this point.  Both Token-Mod and LibTokenMarkers are installed.

November 26 (2 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Hi Eponymous!

When you put in the token marker names, did you include the id code, using semicolons instead of colons?

`blinded;;123456`


Neither of these will work for a custom token marker definition:

`blinded::123456`
`blinded`

and the marks on either side must be backtics, not single quotes.


Here is an example of that part of the code from my own game:

        ["blinded",
            /(be|and|is|magically|become|becomes) blinded|blinded condition/,
            "• A blinded creature can’t see and automatically fails any ability check that requires sight.<BR>• Attack rolls against the creature have advantage, and the creature’s attack rolls have disadvantage.",
            `Blinded;;30980`
        ],
        [
            "charmed",
            /(be|and|is|magically|become|becomes) charmed|charmed condition/,
            "A charmed creature can’t attack the charmer or target the charmer with harmful bilities or magical Effects.<BR>The charmer has advantage on any ability check to interact socially with the creature.",
            `Charmed;;30982`
        ],
        [
            "deafened",
            /(be|and|is|magically|become|becomes) deafened|deafened condition/,
            "A deafened creature can’t hear and automatically fails any ability check that requires hearing.",
            `Deafened;;30987`
        ],


If you can post a section of your edits, I'll take a peek. If you need the marker IDs, you can get them from the TokenMod help handout.

November 26 (2 years ago)


keithcurtis said:

Hi Eponymous!

When you put in the token marker names, did you include the id code, using semicolons instead of colons?

`blinded;;123456`


Of course I didn't.  I read the instructions, got excited, copy/pasted, and completely forgot about the instructions I read.

All good now, thanks!

November 26 (2 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Whew! Excellent!

If I get enough interest, I might write in some config routines, but that's practically a whole other script.

December 13 (2 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Added new command:

!condef-all

Produces a dialog box listing all condition buttons, for reference.


December 13 (2 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Condefintion will now monitor if the token taking damage has a defined concentration marker on it. If you reduces the hit point bar of a concentrating token, the script will prompt you to make the appropriate Constitution save.

Example. "Random" just took 40 hp of damage while concentrating on a spell:


December 14 (2 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Condefintions now allows you to select any number of tokens and run !condef-report The script produces a set of report buttons for each selected token that has a defined condition marker on it.The sub-buttons that toggle token markers will only affect the respective token, and that token does not need to be selected.


December 16 (2 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Added player-friendly behavior.


When a DM sends a roll template that triggers a condition, the players will not see the buttons.

When a player sends a roll template that triggers a condition Both GM and that player only will see the buttons. Only the DM will see the save and damage buttons, since typically those are used on monsters, and it is usually the DM's job to make monster saves and record damage.


In order to allow players to assign conditions when appropriate they can now use the token marker button. If they control the character and have selected it, they can assign it normally. If they cannot select the target, or they have no token selected, they will be prompted to select a target for the condition. They can assign token markers to creatures they cannot control. Note that this behavior requires the GM to have set token-mod to allow players to use ids. See token-mod help for more information.

This behavior is also granted to the DM. The condition assigning button will automatically assign the condition to any selected token(s), or will prompt for a target if no tokens are selected.


Players can now use !condef-report to get a report of all conditions on a token they control. This command cannot be used in target mode.

January 22 (2 years ago)

Edited January 22 (2 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Minor changes to code.

• Jarren has found and corrected some typos in my transcription of conditions

• He has also pointed out (and I have verified) that the use of ";;" or "::" followed by the id in a condition name is not required. Apparently Token Mod takes care of this for changing, and it is not needed for setting the images.

Code has been updated in the top post.

Thanks Jarren!

January 22 (2 years ago)
The Aaron
Roll20 Production Team
API Scripter


keithcurtis said:

•  Apparently Token Mod takes care of this for changing, and it is not needed for setting the images.

Yup.  It's only required if there are spaces in the name, or the name is ambiguous with other status markers.

January 22 (2 years ago)

Edited November 18 (8 months ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

There's a Very Important Reason why this script requires Token-Mod, rather than just setting the markers internally...





EDIT: The code in the top link has been updated to allow for partial support of the D&D 5e 2024 Sheet.