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] SpellMaster - 5e OGL Spell Handling Script (Thread 2)

1572178842

Edited 1579963794
GM Michael
API Scripter
I've had a campaign running for almost two years now, and at least at my table, I use a large number of house ruled spells.  The 5e SRD has 319.  Stock 5e has 456.  My table has 724.  Over time, this had led to frustration again and again as my players have been forced to manually import spells rather than just pulling them in from the compendium.  Furthermore, the OGL sheet can't filter spells by any criteria at all, leaving my players frustrated whenever they blank on the name of a spell or want to know what they can cast while silenced. We could have switched to the  Shaped Sheet , but in my experience, its performance under load is much worse than OGL.  External tools like  Donjon  are great, but don't support homebrew. Roll20  claims  to be hard at work securing the rights for more elaborate compendiums, but this only addresses part of the problem, and certainly not the homebrew aspect. That's what led to this script.  (Special thanks to people in the  other thread  for your help!) SpellMaster SpellMaster is an  Airbag -compatible script specifically built to be expandable and to allow DMs to add homebrew content.  The SRD spells are all provided.  To add additional spells, make use of the Export feature (or manually edit the SRD.js file). SpellMaster is intended as a  total replacement  for the Spells page of the OGL character sheet in normal play with several additional key features that go beyond the default spells page. Features Instant Import : Instantly add any spell (even homebrew!) in your master spell list to a character's spellbook.  Additionally, you can import a class's entire spell list to a spellbook during setup so your poor Druids and Clerics don't die of old age in Session 0. Class List Perusing : Peruse all spells your character  could  know and easily swap them in and out. Filtering : filter by VSM, Ritual, Concentration, Preparedness, Slots Remaining, and the inverse of all of these.  General string search and cast time filtering are also provided. Preparation Lists : Create and configure independent lists of prepared spells for every scenario. Locking : Supports spells that are both conditionally prepared and always prepared, even those that can be used a finite number of times a day without expending slots. Performance : SpellMaster is built to support games with hundreds of spells in play without slowing to a crawl. Compendium Interface : SpellMaster has a automated system to allow you to import spells from your purchased compendium expansions and then export them into your private spell list. Homebrew Support : Utilizing the same export system, you can add or update house spells. Macro Support : Macros of the commands SpellMaster uses are valid. Casting & Slot Tracking : This would hardly be a spell manager if you couldn't cast or track slots. Sorcery Point Tracking : This tool handles sorcery point conversions. Setup 1. Install  SRD.js  (contains the SRD spell list) and  SpellMaster.js  (contains the logic) as API scripts in your game. 2. If you have a lot of homebrew or purchased compendium spells, skip down to the  Export  section of this post and return here when you're done. 3. Create a Handout with a unique name of your choice such as "Tazeka's Spells."  Give Tazeka's player access to the handout.  This handout will become Tazeka's spellbook, fully replacing all need for the 5e OGL sheet's Spells page. 4. Run the command below to bring up the chat menu. !SpellMaster --Menu 5. In the chat window, a simple menu will appear.  Press [Create Spellbook].  You will be prompted for a couple fields.  Fill them out. 6. Navigate to the handout and see that it's been populated!  Tazeka now has a dedicated spellbook! 7. I recommend going to Tazeka's character sheet and adding the below to the Bio & Info tab, replacing it of course with your own spellbook name.  (SpellMaster automatically generates the link from spellbook to character sheet.  The below is an example link from character sheet to spellbook.) [Tazeka's Spells] Operation Filtering At the top of the sheet, you'll see the ability to filter by presence (or absence!) of VSM components, as well as concentration, ritual, preparedness, slots remaining, cast time, and a general string search.  String search checks spell names, descriptions, notes, range, and classes for the provided string.  Regex strings are not supported at this time. Tools Long Rest : It will refill all slots and sorcery points to their maximum. Level Up : This flushes the cache and reconstructs the maximum slot count.  Press this once upon level-up.  It supports full casters, half-casters, third-casters, pact magic, and any combination of the above.  Note that this does NOT update current slots, only maximum.  Some GMs allow level-up immediately after combat, so I didn't want to prevent that from working. Refresh Cache : SpellMaster relies heavily on internal data caching to keep things running as smoothly as possible for you.  This means the first time you load your sheet per session, you can expect a little hitch as it pulls in all the data so it never has to again.  Well, mostly.  If you hit this button, you'll force it to dump its cache and build a new one.  You shouldn't need to do this except in cases like acquiring an item that changes your spellcasting ability modifier. Sorcery Points By default this is 0/0, but you can click the links of the numbers to update them.  Then, once you have done so, you may use the Compose Slot link here to generate spell slots, as well as the Decompose button that will appear down by the spell levels. Prepared This counter takes the form of... [Currently Prepared] / [Class1 MaxPreparation] ([Class1 Name]) / [Class2 MaxPreparation]... This counter does not include Locked spells (see below).  It also does not restrict a user from over-preparing as there are simply too many ways that could be legitimate, so it simply marks how many are prepared and its best guess for how many you should have prepared at most. Spells Spells appear within their level in alphabetical order.  What a given spell looks like will make more sense with an example, so here's a spell I wrote. Level 1 Spells - [4] / [4] - [...] : The initial line denotes the spell level and current spell slots.  Click on a number to change it.  Currents can be higher than maximums, but Long Rest will set everything back to the maximum.  The  [...]  displays all knowable spells for you for the specified level.  They appear as a list ihe chat menu where you can add or remove knowledge of them. [_] Azdregath's Opulent Ooze (R) - [-] : The line with the spell's name on it has several features. [_] : Clicking on this empty checkbox will mark it as prepared.  Prepared spells are marked with  [X] .  Cantrips are always checked. Azdregath's Opulent Ooze : Clicking this link will attempt to cast the spell.  See casting details below. (R) : SpellMaster flags any Rituals or Concentration spells with tags at this location. [-] : Pressing this will collapse the details of the spell and turn it into  [+]  instead. [0] / [0] : Should you have a spell you can cast a finite number of times a day without expending a spell slot (such as certain racial features or possession of a magical item), you can edit its current slots and maximum slots here.  If these are non-zero, they will appear in the name line of a spell instead of only being visible when you expand the spell. Description : The next several lines simply provide the details for the spell, just as you'd expect. Ability : Clicking on this will allow you to choose the spellcasting ability for this spell.  If you select "Manual DC," you will see an option appear below this to set that to whatever you like.  If you do so, any spell attack for this spell will have a modifier 8 less than the DC. Notes : Clicking on this allows you to edit the notes for a spell.  I recommend things like "From Artificer" for multiclassing or "Utility" so that the Search function can find this spell easier.  There's usually no need to specify things like "VS Undead" because of prepared spell lists (below). Classes : This is the list of classes that a spell belongs to.  Because of the way my parsers work, SRD also shows up as a class. [Delete] : This brings up a confirmation box to delete the spell from this spellbook. [Lock] : This Locks a spell as permanently prepared, handy for classes with permanently prepared spells like Sorcerers, Druids, or Clerics.  I also use it for items.  If a spell is locked, its preparedness checkbox will show up not as  [_]  or  [X] , but rather  [O]  and it will not count toward the preparedness counter at the top of the page.  However, if you filter by preparedness, a Locked spell is counted as prepared and will show up. The plus button at the end of a spell level allows you to import a new spell from the master spell list by name. Preparation Lists As before, it's easier with a picture. These function as radio buttons: press the checkbox for one and the others are unchecked.  Any preparedness changes you make to a spell on one preparation list are unique to that list.  Locked spells are global to the spellbook and do not change between preparedness lists.  The parenthetical number is the number of prepared spells in that list. Click on a list's name to change it, the  [-]  to delete it, or the  [+]  to add a new one. Casting Spells with SpellMaster When you cast a spell with SpellMaster, you'll first be presented (if needed) with a list of spell levels you can cast the spell at.  If you have per-spell slots, it will automatically consume them before taking up your main slots. Upon selecting a level, the spell card will be sent according to the character sheet's whisper options.  Rolls within the table are automatically calculated.  If there is a spell attack, it will appear at the top (otherwise defaulting to 0), and the caster's relevant spellcasting ability DC will be posted in all cases. Spell Export If you have homebrew or purchased compendium content, the steps below show you how to replace SRD.js with a list specifically for your table. Create a character sheet.  I'll call it  House Spells . Open your Compendium.  Filter by spells. Begin the arduous process of dragging and dropping all those spells into House Spells.  For each, you must manually fill out the Class field with a list of classes (ie "Druid, Warlock, Wizard") because the character sheet doesn't autopopulate that for some reason.  You can skip any that are already in the SRD. Add any additional homebrew spells you allow at your table.  If you have any special alterations to existing spells, include them as well.  Just make sure the name is unchanged and the exporter will take your new version and ignore the stock version.  If you wish to rename or ban a spell at your table, name the spell either  RENAME|Old Name|New Name  or  DELETE|Banned Spell Name . Once you're done with that, bring up the chat menu with  !SpellMaster --Menu  and press  [Export Homebrew] .  This will bring up a dialog option in which you will type the character sheet name (in the example case, House Spells).  Begin export. After waiting for a while (this could be a few seconds or a few minutes, depending on how much homebrew and compendium content you have), the export will finish and you can navigate over to House Spells'  Bio & Info  tab where you'll find yourself face-to-face with a spell list file just for your table.  I'll call it HouseSpells.js. Copy HouseSpells.js's text and create a new API script for it and paste it in there.  Save the new file to trigger an automatic API restart.   The API will likely crash at this point.  This is fine. After the API comes back up or crashes, disable SRD.js.  (Theoretically, you could delete it, but I'd recommend holding onto the original version in case you need it.)  This will trigger an automatic API restart. After it comes back up, your players will be able to import your homebrew and purchased compendium content just as they would any SRD spell. Performance Part of what influenced my decision to do this was I wanted a solution that could be performant at all levels of play.  For this reason... The master spell list is stored in an API script (to avoid sucking up a surprising amount of the 2 MB cap of state and not cause a performance hitch from trying to parse it out of something like gmnotes).  Expensive operations are cached, so that only part of the page has to be regenerated at a time. Spellbooks are in handouts rather than the main character sheet because loading a character sheet can take a painfully long time at higher levels.  However, for your convenience, the top of a spellbook contains an automatically-generated link to the character sheet. Known Bugs Roll Clone Roll is cloned and clones do not match. Summary : When whispering rolls to both the GM and the player, the rolls sent to the recipients may not match.  Detailed in  this  thread. Workaround : Configure player rolls to not be whispered to GM or give the GM ownership of all player characters. Resolution : To fix this, I will likely need to build a full-blown Roll20 roll parser, something I am  not  looking forward to.  On the upside, if I go for broke, I imagine I can get my code to run faster than Roll20's because I won't be using quantum rolls anymore. Roadmap : Because this change would require manual construction of a lot of HTML in any event, I suspect I would fix this the same time I fix the Zero-Zero bug. Zero-Zero When spells are cast that do not have an attack roll, they have 0|0 on them. Summary : The HTML template used does not work correctly. Workaround : Ignore it.  It's not hurting anything except your eyes. Resolution : I'll need to build my own roll template, which I am  not  looking forward to, but it should mean somewhat better performance. Roadmap : This'll be a pretty big change in practice, and it is liable to include the Roll Clone fix as well. Releases See the setup step above for downloads instructions.  The files can be found on my github . SpellMaster.js 1.0: Initial Release 1.1: Add whisper inheritance, add manual DCs 1.2: Advanced Caching and Homebrew Export are in. 1.3: Export now handles all levels automatically for you. .1: Fixed a minor spell preparation bug for Druids and Clerics. 1.4: Add cast time filtering, add rename and delete to export .1: Rituals now count as non-combat, even if they otherwise wouldn't 1.5: Add knowables printing, improve spell slot count algorithm 1.6: Add support for sorcery points. 1.7: Fix sorcery migration bug 1.8: Add auto-population support for paladins 1.9: Add range searching to general string search SRD.js 1.0: Initial Release 1.1: Fix assorted errors 1.2: Fix invalid character errors 2.0: Finally sustainably fixed the stupid invalid characters, add Enthrall (which I'd missed) Future Work A few things I'd like to add in the future... Usability Bug Fixes : Obviously bug fixes improve things. Regex Searching : It's a handy feature.  Unfortunately, i'd have to make my own syntax because I can't use certain characters on roll20. String Proximity Correction : When a user mistypes a spell, calculate the Levenshtein Distance to suggest what they probably meant to type. Shaped Sheet Compatibility : This is a looooong way off, but it'd be nice to have. One-Click Install : I think I may have to make SRD.js a standalone and have it be the dependency of this script, or perhaps merge it all and have it be overridable by another script a user adds. Features Short Rest Recharge : Certainly, I can't  fully  support every conceivable thing that happens on short rest, but I can at least add  something.   Most notably, I would like to support pact magic recharging. Variable Recharge Rates : allow certain things (like items) to regenerate non-standard amounts. Improved NPC Support : Devise some system to support unnamed NPC casters. Ritual Casting : Allow ritual spells to be cast as rituals to not consume slots. Slotless Casting : Allow users to "cast" a spell without consuming resources, such as when you want another tick of damage. Previous Threads Thread 1
1572190466
Ziechael
Forum Champion
Sheet Author
API Scripter
Awesome to see this still evolving, the Cleric in my current game uses it and LOVES it. The planned features look awesome too. Will let you know of any issues we encounter :)
Not too much has changed since the last thread, just the sorcery points and more SRD.js fixes.  Unfortunately, the thread had been asleep for too long, so here we are!
1573307463
Ziechael
Forum Champion
Sheet Author
API Scripter
I think my install was a couple of versions old since it didn't have the level up feature and a couple of other bells and whistles. Just deleted and recreated the spell books for the Cleric and Paladin and it seemed a lot easier, cleaner and user friendly. I know those players will appreciate it! Would be handy to have all the Paladin spells add themselves by default but wasn't a huge chore to add them in.
Ah lol...  Well, full disclosure, i've never played as, with, or even fully read the paladin section of the PHB, so... didn't actually realize they were a preparation caster...  whoops... The change should be quite trivial (add 27 characters to one line), and I can try pushing it, but right now I'm getting hit with this bug , so I'm holding off releasing until I can test it.
1573319279

Edited 1573319291
GM Michael
API Scripter
...and, API is back up and running, so I tested and pushed 1.8 which includes auto-population for paladins.