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

Second Wind Ability Macro Help

I'm trying to create a second wind ability for my fighter (Patches O'Houlihan) to use. DND 5E 2014. I have an ability in the character sheet set up like so: [[1d10+@{base_level}]] @{Patches O'Houlihan|wtype} &{template:npcaction}  {{rname=Second Wind}}   !modbattr --name Patches O'Houlihan --silent --evaluate --hp|$[[0]] --class_resource|-1!!! {{description=Patches O'Houlihan  shrugs off his wounds and regains $[[0]] (1d10+fighter level) hit points. Patches has @{class_resource} uses left}} This works great and rolls health and yada yada. But now I want it to auto increase his health and also auto decrease his 'Second Wind' class resource. Is this possible? I tried having it call a 'tokenmod' macro at the end, but there's no way to pass the roll from the ability to the tokenmod macro (that I know of). Any ideas?
1728145674
timmaugh
Pro
API Scripter
I'm not sure what you have going wrong, because your ChatSetAttr command is already setup to add the value of the roll to your character's hp while deducting 1 from their class_resource attribute. A second point of confusion is that TokenMod only affects tokens. So unless the thing you want to affect is some sort of unlinked bar, I'm not sure what you would need TokenMod to do. As written, I don't think you need the --evaluate argument for ChatSetAttr, because I don't think you're dealing with attributes that would have references to other attributes in them (but I don't play this system, so I could admittedly be wrong). Finally, there *is* a way to use rolls in multiple commands if scripts are available, and you're using mods already, so.... The idea is to use the Metascript Toolbox, specifically ZeroFrame batching . One side benefit of this approach is that you no longer have to embed the ChatSetAttr command in your template statement. Batch Example Here's a basic example demonstrating how to use rolls in multiple commands... If you put these commands into a single macro or ability, this won't work to share the roll between lines: The roll is [[1d10]] The roll is still $[[0]] You'll get an output where the second message won't parse the rollmarker: But if you put those statement in a batch in that same macro or ability: !{{ The roll is [[1d10]] The roll is still $[[0]] }} And now all rolls are shared across all lines (in order left=>right, top=>bottom, inside=>out): Adapting Your Command So your command, converted to a batch, would start out as !{{   @{Patches O'Houlihan|wtype} &{template:npcaction}  ({)rname=Second Wind(}) ({)description=Patches O'Houlihan  shrugs off his wounds and regains  [[1d10+@{base_level}]]    (1d10+fighter level) hit points. Patches has @{class_resource} uses left(})    !modbattr --name Patches O'Houlihan --silent --evaluate --hp|$[[0]] --class_resource|-1 }} After that, you can add more lines in, if necessary... but... like I said, I *think* you're going to want to change an attribute, which means you're going to do it in the ChatSetAttr line (not needing another line), and I *think* you already have it included, there... so my question would be what -- specifically -- is supposed to be happening here (what do you expect), and what is happening, instead?
1728153320

Edited 1728153368
I've got that macro as an ability on the character sheet like this. That way, it shows up as a token action for my fighter and only my fighter. When that token action is clicked, the chat works correctly, like so:    but second-wind uses to not decrement, nor does his health auto-regain. I guess I would expect his hp to increase by 10, in this case, and his class_resource, second wind, to go down to 0
1728166031

Edited 1728166709
You have a "B" embedded in the middle of your ModAttr command.  You may want to set class_resource to 0 instead of subtracting 1 and modify your roll calculation to [[(1d10+base_level)*class_resource]].  That way if you have already used your second wind and try to apply it a second time you won't end up with -1 second wind and more HP than you should have. Also, you'll need some kind of check to make sure you don't exceed max HP.
1728183222
timmaugh
Pro
API Scripter
The "modbattr" handle is a shortcut handle specifically for modifying (rather than setting an attribute), where it is bound ("b") to not exceed the maximum, so I think the usage here is correct. I will mock this up in my game and give it a run.
1728343948

Edited 1728344852
Hmm the problem is it doesn't work at all. Nothing subtracts from the class resource and nothing is added to his hp. You can see in the text shot above it is still saying he has 1 use left. Timmaugh, did you have any luck? Is the problem the npcaction template? Because this is a PC? edit: also I should add that it will still allow use if he has 0 uses left, which I would also like to prevent
1728355067

Edited 1728355109
timmaugh
Pro
API Scripter
First, this is working for me in a non-Jumpgate, 2014 sheet game. So that's the first thing to check. Also, if this is a character built on the 2024 sheet, this approach isn't going to work... mostly because that sheet doesn't work. OK, ok... specifically this wouldn't work on a 2024 sheet because the data model backing the sheet is completely different, and ChatSetAttr has not been updated to match. It's built to access data the way the legacy sheets (like 2014) store data. That said, in my game, the class resource decrements, but it doesn't *report* as decremented because of when it is resolving. Basically: 1) message is sent to Roll20 2) Roll20 parses message for attributes, rolls, etc., and turns the class_resource attribute into the number that it is currently 3) scripts get a chance at the message, and ChatSetAttr sees something it needs to do 4) CSA decrements the class_resourse (so if you look on the sheet, it has gone down by one), but the value to be included in the output was already resolved -- so you see the value as if it didn't decrement. We can fix that with metascripts (we could also fix it with a roll that did the math of subtracting 1 from the resource, but that wouldn't be actually reporting what was on the sheet; that would just be reporting the result of subtracting 1 from the resource, and hoping that the modification went through). Since we're going to fix that with metascripts, how about we include a limiter that this shouldn't run if the class_resource is already 0? Let's do it. !{{ (^)   {&if @(selected.class_resource[0]) > 0}      !modbattr --sel --silent --evaluate --hp| [[1d10+@{base_level}]]  --class_resource|-1     @{wtype} {^&template:npcaction}  ({)rname=Second Wind(})  ({)description=Patches shrugs off his wounds and regains $[[0]] (1d10+fighter level) hit points. Patches has @^(selected.class_resource) uses left(}) {^&delay .3}   {&else}      @{wtype} {^&template:npcaction}  ({)rname=Second Wind - Failed!(})    ({)description=Patches must rest before using Second Wind again.(})   {&end} }} {&select Patches*} That works for me in my game. Here are 2 back-to-back runs where I only had 1 use remaining (so the first worked, and the second reported that Patches has to rest before using it again): REQUIRED SCRIPTS Metascript Toolbox ChatSetAttr
1728410919

Edited 1728411018
I'll try your way of doing it when I get a chance. I am in a jumpgate game so maybe that's my problem. Using 2014 sheet though. My problem isn't the reporting necessarily, it's the fact that the character sheet resource or health doesn't actually change. I don't have meta scripts, but I don't think that would solve my problem if the macro is working as intended for you but not for me
1728411270

Edited 1728411311
*sigh* I'm so sorry Tim, I'm a dumb person. Your "required scripts" section made me go take a look. I never added ChatSetAttr script to this game. Completely missed that. Once I added that script everything worked as intended. sorry for wasting your time and thanks for the help. It doesn't report 0 uses correctly, but I don't necessarily need it to report that.  Do I need metascripts to prevent the ability from running if he is already at 0 uses?
1728412546
timmaugh
Pro
API Scripter
What Metascripts Do For You - Part 1 Your original posting of this command line will always erroneously report 1 usage MORE than what the character has. Start with a known quantity and you can see for yourself. Character has 8 uses. Run the command ChatSetAttr reduces the value You get your report... showing that the Character has 8 uses. That report should show the Character has 7 uses, but, like I said, the syntax resolves before ChatSetAttr runs, so the value is already written into the command line by the time the template is shown to you. Metascripts will fix that. What Metascripts Do For Your - Part The Second Your original command line will let the effect work even if there are 0 usages left on the character sheet (especially a problem if the report you got the last time you used it told you you had one more use left when, in fact, you did not). Metascripts let you institute a conditional IF/ELSE structure to preempt the running of the command if there are no uses. In that case (in my suggested version of the command), you instead get a message alerting you that there are no usages. No attribute modification happens. What Metascripts Do For You - Part Triple In your version, you had to manually select the token. Maybe you're used to that because you've had this as a Token Action for the character. In my version, I select the token via a {&select} syntax, allowing me to agnosticize most other things to refer to the "selected" token rather than explicitly to Patches (there is still a reference to Patches in the template report, but that could be removed and converted to a Fetch reference to the name of the character). The point of this agnosticization isn't to make the metascripts dance just because they can dance, but to give you the ability to use this same command for multiple characters without having to select them. For instance, replace the explicit reference to Patches in the {&select} tag with a query for all your Second-Wind-eligible characters, and this one command will service them all: {& select ?{Which character|Patches|Bozo|Puddles|Pennywise}* } Video Explanation If you want to understand metascripts better, I put this video together explaining how metascripts work and how they help other scripts.
You're the man, thanks for making this community better.