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

[5e Shaped] Macro for Charges

I've been trying to figure out how to make a macro that will use the charges based on resources from a magical Item. Like the Staff of Life has 3 different uses for it and I don't know how to make it use the uses and track them on resources. Help will be appreciated. I'm sure once I know how to make the Staff of life calculate the uses I'll be able to make a wand of magic missiles do the same based on level in which you cast the spell at. Also thinking about how to incorporate the recharge feature into the uses of magical items.
1483906946

Edited 1483906957
You could accomplish this by using the ChatSetAttr script and either adding a new resource item in the characters inventory for the charges with the quantity being the number of charges remaining, or you could create an attribute for the character for the charges.
I have the script but I'm not sure how to accomplish it.
1483908630

Edited 1483908700
For example magic missiles would be  To use: (the first line rolls the damage for the wand, the second reduces the attribute containing the number of charges by the amount used) [[ [[ [[2+?{Charges|1}]]d4]] + [[2+?{Charges}]] ]] force damage !setattr --charid <characterid for the person with the wand> --mod --<resource for the charges>|-?{Charges} --silent To recharge: (rolls the recharge quantity and adds the result to the resource for the charges. It does not ensure a maximum of 7 charges) !setattr --charid <characterid for the person with the wand> --mod --<resource for the charges>|-[[1d6+1]] --silent
Hmmm, this is not working for me for some reason.
1483915937

Edited 1483915973
Jakob
Sheet Author
API Scripter
Kyle G. said: To recharge: (rolls the recharge quantity and adds the result to the resource for the charges. It does not ensure a maximum of 7 charges) You can use --modb instead of --mod to keep the value of the attribute between 0 and its maximum. Jerry F. said: Hmmm, this is not working for me for some reason. What part exactly isn't working?
I get the damage to work, but the actual setting of the attribute isn't happening.
1483955053
Jakob
Sheet Author
API Scripter
What's the name of the attribute you are using for the charges, i.e. what is the precise command you are entering? Remove the --silent for testing purposes, what's the output that ChatSetAttr gives you?
I'm using the other_resource. The code I use in the attack is: [[ [[ [[2+?{Charges|1}]]d4]] + [[2+?{Charges}]] ]] force damage !setattr –-PC Template --mod –-other_resource|-?{Charges} I haven't even begun to mess with recharging because I can't get this to work. I know that I'm completely doing something wrong but I guess that is all part of learning.
1483986280

Edited 1483986400
So the issue here is that you are trying to make an attack that uses macro commands. This won't work. Instead you will need to create an ability in the Attributes and Abilities section for the command. Also, --PC doesn't work, you must use --charid or --name. I find --charid is simple enough and you don't have to worry about spaces in the name. You can also easily reference it by using the @{character name|character_id} call. Here is the code in the ability (updated to refernce this character and also allows you to hover over the result and see the individual rolls). @{wtype} [[ [[2+?{Charges|1}]]d4 + [[2+?{Charges}]] ]] force damage !setattr --charid @{Testing|character_id} --mod --other_resource|-?{Charges}
1483986775

Edited 1483987260
Thank you. Ahh but I would rather it be an attack, I should have made that clear. But I suppose I could make it look like an attack. The thing is I already have a macro that players can click for attacks and then it will bring up the attacks available to them and they just click it I wanted to make items with charges also fall into the marco but I suppose I could reference another macro in that macro.  Can I make this look like a normal attack?
Also, how do I also apply this for an item with different uses for charges, like the Staff of Healing?
Of course by making use of  Roll Templates  . Change the first line of the macro to this and play around with it to make it look how you want @{wtype} &{template:atkdmg} {{rname=Wand of Magic Missiles}} {{attack=0}} {{range=120 feet}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[ [[2+?{Charges|1}]]d4 + [[2+?{Charges}]] ]]}} {{dmg1type=force}} {{damage=1}} {{desc=1}} {{desc=?{Charges} charge(s)}} {{charname=@{Testing|character_name}}}
For different uses, look into  Macro Queries .
Thank you, but upon further review and contemplation I actually like it better as an inline, it looks nicer and takes up less space. Does this work with the further down resources, the repeating left and right resources?
Yes, however it you will need to access the resources using the repeating resource name, including the _left/_right depending on the side. For example !setattr --charid @{Testing|character_id} --repeating_resource_$0_resource_right|1 --silent
Awesome thank you again. I can't believe I didn't think about the $0 portion of it.
This is as far as I can get on the Staff of Healing @{wtype} Staff of Healing [[ [[?{Cure Wounds|Lesser Restoration|Mass Cure Wounds}]] 
1483995767

Edited 1483996138
Here's what I would do for the Staff of Healing. I would break the Staff into 3 parts. This first part is to create 3 ability macros for the different options that the staff can be used for (Cure Wounds, Lesser Restoration, Mass Cure Wounds), and make sure that they not only roll the healing (or output the effect in the case for Lesser Restoration) but also subtract the correct number of charges (Cure Wounds can be a value between 1 and 4, while the others are static). Once those three are done You should convert all of the "|", ",", and "}" characters inside the ability macro that are not attached to a @{}, %{}, or #{} into their HTML equivalent "&# 124;", "&# 44;", and "&# 125;" respectively (I added a space between the &# and the number so that the roll20 forum didn't convert it into the symbol) (this is because you want to have these macros be called within a macro query. See  here for more information as to why). Finally create the macro that will prompt the player as to which action they want to use. In order to call the other ability macros, you will HAVE to use either the character's name or id in the call (For example, %{Testing|Cure-Wounds}, %{@{character_id}|Cure-Wounds} unfortunately is not possible. Here are the final products for the ability macros (I verified that they work in my campaign so it should work for you to just copy paste the macros) (I again added the space between the &# and the number so that you could see where they were needed, be sure to remove the space before testing  otherwise they will not work properly.) Query macro /em using Staff of Healing ?{Staff of Healing|Cure Wounds,%{Testing|Cure-Wounds}|Lesser Restoration,%{Testing|Lesser-Restoration}|Mass Cure Wounds,%{Testing|Mass-Cure-Wounds}} Cure Wounds macro @{wtype}&{template:dmg&# 125; {{rname=Cure Wounds&# 125;&# 125;{{range=Touch&# 125;&# 125;{{damage=1&# 125;&# 125;{{dmg1flag=1&# 125;&# 125; {{dmg1=[[1d8+[[@{spellcasting_ability}]]]]&# 125;&# 125; {{dmg1type=Healing&# 125;&# 125;{{hldmg=[[[[(1*{(?{Charges&# 124;1&# 124;2&# 124;3&# 124;4&# 125;-1)&# 44;@{other_resource}&# 125;kl1)]]d8]]&# 125;&# 125; !setattr --charid @{character_id} --modb --other_resource&# 124;-?{Charges&# 125; --silent Lesser Restoration macro @{wtype}&{template:spell&# 125; {{level=abjuration 2&# 125;&# 125;  {{name=Lesser Restoration&# 125;&# 125; {{castingtime=1 action&# 125;&# 125; {{range=Touch&# 125;&# 125;{{v=1&# 125;&# 125; {{s=1&# 125;&# 125;{{duration=Instantaneous&# 125;&# 125;{{description=You touch a creature and can end either one disease or one condition afflicting it. The condition can be blinded&# 44; deafened&# 44; paralyzed&# 44; or poisoned.&# 125;&# 125; !setattr --charid @{character_id} --modb --other_resource&# 124;-2 --silent Mass Cure Wounds macro @{wtype}&{template:dmg&# 125;{{rname=Mass Cure Wounds&# 125;&# 125;{{range=60 ft&# 125;&# 125;{{damage=1&# 125;&# 125;{{dmg1flag=1&# 125;&# 125;{{dmg1=[[3d8]]&# 125;&# 125;{{dmg1type=Healing&# 125;&# 125; !setattr --charid @{character_id} --modb --other_resource&# 124;-5 --silent
Wowsers, that seems like a lot of information I'm completely unfamiliar with. I will give it a try.
Thank you very much that works perfectly.
Glad I could help. 
I was wondering how I would convert all of this to the Shaped sheet?
1485126950

Edited 1485127018
Jerry F. said: I was wondering how I would convert all of this to the Shaped sheet? Mainly, you'd need to: locate the names of the OGL's sheet's Attributes (e.g. "other_resource") within all relevant macros; determine the names of equivalent Shaped sheet's Attributes ( the documentation will help, here ); replace the former with the latter. To make Roll Templates look nice, you'd need to: locate the names of the OGL's sheet's Roll Template special properties (e.g. "rname") within all relevant macros; determine the names of equivalent Shaped sheet's Roll Template special properties ( the documentation will also help, here ); replace the former with the latter.
Ok thank you Silvyre.
Completely lost how to get this work in Shaped like it did in OGL.
1485260250
Jakob
Sheet Author
API Scripter
Jerry F. said: Completely lost how to get this work in Shaped like it did in OGL. Okay, first you'll want to create a new item in the equipment section called "Staff of Healing". Give it some uses (however many charges the Staff of Healing has). Find out its row id (e.g. -KbFI1CvPYgpQEOMsWgZ - I'll use this for the remainder, although your id will be different). Then the macro for e.g. Mass Cure Wounds looks like this: @{output_option} &{template:5e-shaped&# 125;{{title=Mass Cure Wounds&# 125;&# 125;{{range=60 ft&# 125;&# 125;{{trait=1&# 125;&# 125;{{heal=[[3d8]]&# 125;&# 125; {{uses=@{repeating_equipment_-KbFI1CvPYgpQEOMsWgZ_uses}&# 125;&# 125;  {{uses_max=@{repeating_equipment_-KbFI1CvPYgpQEOMsWgZ_uses|max}&# 125;&# 125;  !setattr --charid @{character_id} --modb --repeating_equipment_-KbFI1CvPYgpQEOMsWgZ_uses&# 124;-5 --silent Basically, replace other_resource with repeating_equipment_-KbFI1CvPYgpQEOMsWgZ_uses and adapt to the roll template. Cure Wounds is analogous. For Lesser Restoration, since it is a full spell, I'd do something like @{output_option} &{template:5e-shaped&# 125; {{title=Lesser Restoration&# 125;&# 125; {{spell=1&# 125;&# 125; {{spell_level=^{2ND_LEVEL&# 125;&# 125;&# 125; {{school=^{ABJURATION&# 125;&# 125;&# 125; {{casting_time=^{1_ACTION&# 125;&# 125;&# 125;  {{range=Touch&# 125;&# 125; {{components=^{COMPONENTS_V_S&# 125;&# 125;&# 125; {{duration=^{INSTANTANEOUS&# 125;&# 125;&# 125; {{content=You touch a creature and can end either one disease or one condition afflicting it. The condition can be blinded&# 44; deafened&# 44; paralyzed&# 44; or poisoned.&# 125;&# 125; !setattr --charid @{character_id} --modb --repeating_equipment_-KbFI1CvPYgpQEOMsWgZ_uses&#  124;-2 --silent There's probably a typo or two in here. Make sure to remove the spaces like in Kyle's answer.
Thank you Jakob. I love how helpful everyone is. 
Could I create the Staff as an attack and then place the macros under the Extras/Freeform area?
I keep getting an error in when I try this, it just seems to not be working for me. I get the spell to work but when I add the ChatSetAttr to the macro it doesn't work and crashes the API.
I have been experiencing issues with CharSetAttr since the recent update for sheet workers. Is the error you are getting in the api something about charid?
Yes!!
For reference, the error message generated was: ReferenceError: charid is not defined ReferenceError: charid is not defined at _.each._.each._.chain.map._.chain.filter.charIDList (apiscript.js:10447:41) at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:146:34), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:146:34), <anonymous>:70:8) at /home/node/d20-api-server/api.js:1494:12 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489) at Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425) at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:111:400
I am running into the same error in my macros. From what I know (purely speculation as I have not had time to sift through Jakob's ChatSetAttr script) something changed in his script when it was updated to version 1.2 with the addition on sheet workers. My current workaround for you is to ensure that each of these macro's (or at least the selection macro) is a token macro. You will also need to change the "!setattr --charid @{character_id}" to "!setattr --sel" and use the selected token rather than passing a character id.
I can do that, I usually put these on the character it is for anyway.
I wonder if Jakob knows there is a problem with it?
1485884458
Kryx
Pro
Sheet Author
API Scripter
Equipment having "per use" will likely be a feature in 9.1.x of the Shaped sheet so I'm not sure how much effort I'd put into it now.
Kryx said: Equipment having "per use" will likely be a feature in 9.1.x of the Shaped sheet so I'm not sure how much effort I'd put into it now. Oh Kryx, so uses doesn't work well on equipment? Any suggestions on how to build usable magical items like wands and Staffs?
1485885208
Kryx
Pro
Sheet Author
API Scripter
Equipment will work like attacks, actions, etc work right now on my 9.0.0 test campaign where it has uses and an amount used per use. The script subtracts the amount used per use from the uses. I believe equipment on 7.12.2 only has uses, no per use. I may add it in 9.1.x, or maybe 9.2.x.
Ok, great I guess I'll just do it as generic and have my PCs keep up with the uses. Or should I create the magical item as a weapon?
1485887421
Kryx
Pro
Sheet Author
API Scripter
Attacks all have attacks so you should only use that section for things with an attack. I'd suggest waiting for me to revamp equipment. Though I'll need more info on the requirements there. I was just planning on doing uses and keeping content as it is. Not sure if all the toggles like heal, saving throw, etc are needed.
Well have you considered adding Magic Item capabilities to the sheet? Like Wand of Magic Missiles, or the Staff of Healing or even the mega Item Staff of the Magi? These are charge using items and I created them on the OGL sheet which took time, but currently how the Shaped sheet works I don't think you can recreate these items as I did on the OGL. I've been trying for 2 weeks and I still haven't figured it out.
1485890153

Edited 1485890178
Kryx
Pro
Sheet Author
API Scripter
The current equipment items which contain a freetext field (which will become a content field) and uses would cover all of those cases if "per_use" is added. Staff of Healing for example could reference spells in the spells list. Items are quite unique in their contents  and a general field to contain them is seemingly most fitting.
I like it, but will the reference subtract the right amount of uses and will there be a separate recharge system for them?
1485890550
Kryx
Pro
Sheet Author
API Scripter
If you'd like to see how it'll work feel free to join my test campaign which is linked on the main Shaped thread. On that test campaign you can see how attacks, traits, actions, etc function. The uses, recharge, per use, etc will mirror that setup.