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

Spell Feats (5th Ed D&D)

I am running into an issue where a player utilizes the twinspell feat, utilizing sorcerer points instead of a spell slot. Is there an API script for handling spells like this?
1612998652
Oosh
Sheet Author
API Scripter
Are you using the Companion API for spell tracking, and trying to avoid the automatic deduction of a spell slot? Or you just want a macro/reactive script to automatically deduct the Sorcery Points? Or both?
1613073398

Edited 1613073452
GM
Pro
Correct, I am using the companion API and trying to find a way around them having to spend the additional spell slots besides using them, then adding them back. I do have a macro workaround, but it is a band-aid and will probably not work as well as the PC gets higher in level.  Ideally an API script if one exists would be idea as I can load it into other games.
1613088862
Oosh
Sheet Author
API Scripter
I think I could cobble something together that stores the last spell for a registered player and gives an option to twin. I don't have time right now though. Timmaugh might have a suggestion for passing it through APILogic, maybe? I still need to dig in to that, so not sure if it's all possible, but basically, it needs to: - add {{innate= }} to the end before it's passed to chat (this will stop 5e Companion from deducting a spellslot) - grab the spelllevel with a regexp /{{spelllevel=(\d+|cantrip)/i - if spelllevel > 0, deduct that many points from Sorcery Points resource attribute. If spelllevel === cantrip, deduct 1 SP If no one else has come up with a solution when I get some time, I'll knock something together.
Appreciate it
1613102023

Edited 1613102118
timmaugh
Pro
API Scripter
I think APIL could manage a good part of it... I'm just not familiar enough with the mechanics of the game system to write it cold. If you post what the command might otherwise look like for a normal roll and what it might look like for a twinned roll, I could be more specific. I'm going to lay out what I think it needs to do in the hopes that it can combine with Oosh's understanding of where we need to end up. It looks like we're talking about a roll template that needs to be modified on the fly, right? What you have to be careful of is that the Roll20 parsers will eat that roll template before it reaches the scripts, so you have to defer the recognition of it with backslashes. !?\{template:...}.... {&simple} I think that a slash in that one position should be enough to delay the recognition. We start it with the exclamation mark to engage it as an API call. The SIMPLE tag tells APIL to release the message as a flat chat message (not an API call) at the very end of the process... which is what a normal roll template would be. It would be a single command for either the normal spell or the twinned version. You would need a trigger to know when to use the twinned version. That could be a query or some sheet item status. Here is the roll query version, wrapped around the end of the template: {& if ?{Use twinned?|yes|no} = yes } {{innate= }}{& end} That way, if you are twinning it, you append that portion to the command line (which will eventually be recognized as a roll template). As for the sorcery points, if there is a way to decrement the sorcery points in the roll template (like I said, I don't know the system well enough), I would use a definition, referencing the spell in question: {& define ([spelllvl] *|Thornbald the Wanderer|spells|[spell_name = "Fire Doom"]|spelllevel) } (Note that the defined term is uniquely spelled so that you don't overwrite instances of "spelllevel" later in the command line.) Obviously that has to be adjusted to match the character's name, repeating list name, sub-attributes names, and spell name. But once you have all of that, you now have the level of the spell. You can use that in an IF block, later, embedded in whatever language handles the deduction of SP. {& if spelllvl = cantrip }1{& elseif spelllvl > 0}spelllvl{& else}0{&end} If it's cantrip, leave a 1. If it is greater than  0, leave what it is. Otherwise, leave a 0. (If, instead of having a '0' there for a spell level of 0 or less, you wanted to have no deduction language at all, just include that language in the IF block. One caveat... if there isn't language in the roll template that deducts the points for the spell, then APIL would have to engage a plugin to handle that. Plugins are currently in beta, but this would be a good test case for one.