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

How to roll with advantage using an attribute call

I understand how to use this  : [[ [$Atk]  ?{Attack Type|Standard, 1d20|Advantage, 2d20kh1|Disadvantage, 2d20kl1} ]] I have a homebrew game going that uses a lot of my own material, as the PC gets stronger their Hit Dice changes so I use an attribute to keep track of it Power Cards and Alter Bars 2 work great with my homebrew but I wanted to add Advantage and Disadvantage, I cannot figure out how to make it work when it has to call for an Attribute instead of a static 1d20.  I use that number to determine if the PC hits the enemy and then Alter bars 2 goes to work. I seen this /roll {4d6,3d8}kh1 in the help section, with the two different dices and selected the higher one but I did not figure out how to make it work with option to choose advantage or not.  The final result needs to be saved as [$Atk] for Alter bars to know what their attack dice rolled.  Is there a way for this to happen?  Run Down:  [[ [$Atk]  ?{Attack Type|Standard, 1d20|Advantage, 2d20kh1|Disadvantage, 2d20kl1} ]] Attribute name is @{Selected|HitDice} and I want it to be rolled for advantage or disadvantage and be saved to [$Atk]  for Alter Bars.
1623090504
timmaugh
Pro
API Scripter
Meta-scripts can do this for you. Specifically you'll need ZeroFrame, SelectManager, and possibly Fetch. Can you be more specific about when/how you would replace the 1d20 with your attribute call? Is there a set of conditions that would cause that, or is it a choice that you want to make at the time of rolling? With a few more details I can give you an example to start from.
1623093685

Edited 1623096491
!power {{   --bgcolor|Blue   --name|**Frost Spear**   --leftsub|***@{Frost Spear|Element}***   --rightsub|***@{Frost Spear|Range}***   --Mana:| @{Frost Spear|MP}   --Damage Info:| @{Frost Spear|Damage}   --Information:| @{Frost Spear|Information}   --Hit Dice:| [[ [$Atk] @{Selected|HitDice} ]] Vs. [[@{target|MC}]]   --?? $Atk >= @{target|MC} ?? ***Successful Hit***:| [[ [$dmg]  @{Frost Spear|Damage}+@{Selected|Magic Modifier} ]] Damage   --?? $Atk < @{target|MC} ?? Fumbled the attack!|   --?? $Atk < @{target|MC} ??  alterbar3|_target|@{Selected|token_id} _bar|2 _amount|-@{Frost Spear|MP} _show|all   --?? $Atk >= @{target|MC} ?? alterbar1|_target|@{target|token_id} _bar|1 _amount|-[^dmg]   --?? $Atk >= @{target|MC} ?? alterbar2|_target|@{Selected|token_id} _bar|2 _amount|-@{Frost Spear|MP} _show|all   --?? @{target|bar1} >= 0 ?? api_token-mod|_ids @{target|token_id} _ignore-selected _set statusmarkers|Alive }} This is my macro for a spell named Frost Spear, it tells info and does damage to the target if it hits and takes MP away. The condition at the end triggers the AutoDeath API when their HP is at 0.  The bolded area is where the hit dice is rolled and saved to a variable, Everything here works, Im just trying to add a Roll for Advantage/Disadvantage.  The option is a choice at the beginning of the attack
1623098006

Edited 1623121089
timmaugh
Pro
API Scripter
OK, you're leaving a lot for me to assume... let's hope I fill in the gaps well enough. Let's take your example, above, where you have {4d6,3d8}. If we put that into the HitDice attribute, then you can retrieve this by use of Fetch, and defer the inline roll resolution using ZeroFrame until after Fetch has done its retrieval: [\][\] [$Atk]  ?{Attack Type|Standard, 1d20|Advantage, @(selected.HitDice)kh1|Disadvantage, @(selected.HitDice)kl1} \]\] Scripts required: ZeroFrame, SelectManager, Fetch (all available in the one-click) I left the "standard" roll as a 1d20, because I don't know what a standard roll would look like for *that* particular kind of roll. I could see if you had 2 attributes... one for standard and one for ad/disad. If you stored the standard roll in "HitDice" and the advantage roll in "AdvantageDice", then the above could change to: [\][\]?{Attack Type|Standard, @(selected.HitDice)|Advantage, @(selected.AdvantageDice)kh1|Disadvantage, @(selected.AdvantageDice)kl1} [$Atk] \]\] EDIT: Corrected the roll label placement. In an API-generated message containing a roll, the label cannot be the first thing the Roll20 parser sees. Moving it later avoids the problem without interfering with PowerCards identifying the roll. Obviously, this would deeply depend on all of your AdvantageDice attributes looking like the example I am assuming them to be. If the dice were listed as 4d6 (only)... well the following gives very different results: 4d6kh1 => MIN: 1, MAX: 6, PROBABILISTIC SPREAD: even; straight line {4d6,3d8}kh1 => MIN: 4, MAX: 24, PROBABILISTIC SPREAD: bell In any case, all of this is finished before PowerCards receives the message, so it never knows anything changed about the message's command line. It will just see the finished product, with the [$Atk] inline roll eventually resolved.
1623104726

Edited 1623104823
So by making a 3 Attributes one for normal, adv and dis  I can call for them and it'll complete. This is what they look like in the Attribute tab HitDice             4d6 Advantage       [[{4d6,4d6}kh1]] Disadvantage  [[{4d6,4d6}kl1]] I can call them with @{Selected|Advantage} and it will roll two sets of 4d6 and pick the highest dice. Is there a way at the begginng of the attack it will ask for Standard/Advan/Disa and just place the rolled attribute ? 3 options to the player  Standard/Advantage/Disadvantage  So if I pick advantage it'll roll the @{Selected|Advantage} attribute that looks like [[{4d6,4d6}kh1]] and put that number down ? so I can save it as [$Atk]  This also have to work with Power Cards/Alter bar/Token Mod. Because the hit dice is not static and is a changing number + the modifier.  I also tried the above mentioned and API just crashes and I have to restart it.
1623122877

Edited 1623123572
timmaugh
Pro
API Scripter
First, let me apologize that the ZeroFrame in the 1-click doesn't have the proper designation of a script dependency. ZeroFrame requires a script called libInline in order to function properly, and since the dependency wasn't set up properly, you wouldn't get it when you installed ZeroFrame from the one-click. I will correct this and submit it for tomorrow's merge, at which point you should get libInline. If you don't, you can delete ZeroFrame and reinstall it (or add libInline from the 1-click). Second, I'll apologize, too, that I didn't notice that your roll label has to be later in the inline roll. By utilizing ZeroFrame, we are sending this roll through in an API-generated message, which has a few more requirements about syntax, and roll labels found right at the start break the sandbox. The label can come after the roll equation without interfering with PowerCards. To PC, the roll label will still be in the same place as it always was in the message. Lastly, I would structure your 3 attributes the same way as each other, either including the inline-roll, double-bracket notation or not. If you're going to include the brackets, include the [$Atk] label, too. I had chosen to not include it because I was trying to minimize the amount of typing that would have to be done in the character attributes (more chance of mistyping something). It can work either way; I'll show both options. Option 1 - Attributes DON'T Include Double Brackets ATTRIBUTES: HitDice => 4d6 Advantage => {4d6, 3d8}kh1 Disadvantage => {4d6, 3d8}kl1 ROLL SYNTAX: [\][\]?{Attack Type|Standard, @(selected.HitDice)|Advantage, @(selected.Advantage)|Disadvantage, @(selected.Disadvantage)} [$Atk]\]\] POWERCARDS MACRO LINE: --Hit Dice:| [\][\]?{Attack Type|Standard, @(selected.HitDice)|Advantage, @(selected.Advantage)|Disadvantage, @(selected.Disadvantage)} [$Atk]\]\] Vs. [[@{target|MC}]] Optional variation... since you're only picking among three attributes on the same character, you could put the roll query inside the Fetch construction for a shorter overall statement: ALTERNATE ROLL SYNTAX: [\][\]@(selected.?{Attack Type|Standard,HitDice|Advantage,Advantage|Disadvantage,Disadvantage} [$Atk]\]\] Option 2 - Attributes DO Include Double Brackets ATTRIBUTES: HitDice => [[4d6 [$Atk]]] Advantage => [[{4d6, 3d8}kh1 [$Atk]]] Disadvantage => [[{4d6, 3d8}kl1 [$Atk]]] ROLL SYNTAX: ?{Attack Type|Standard, @(selected.HitDice)|Advantage, @(selected.Advantage)|Disadvantage, @(selected.Disadvantage)} POWERCARDS MACRO LINE: --Hit Dice:| ?{Attack Type|Standard, @(selected.HitDice)|Advantage, @(selected.Advantage)|Disadvantage, @(selected.Disadvantage)} Vs. [[@{target|MC}]] These worked for me, once I made sure to have all of the scripts installed.
1623155287
timmaugh
Pro
API Scripter
...aaaaaaaaand apparently they do the merge on Monday nights, now, so I missed the deadline to get the updated JSON (with the dependency) merged to update the one-click. For now, you can just grab libInline from the one-click to make this work. My apologies.
1623164992

Edited 1623168548
Thanks timmaugh I got it working, I really apricate that you took time to figure this out with me.
1623171355
timmaugh
Pro
API Scripter
Excellent! Good to hear!