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

Query that results in a template response

April 08 (4 months ago)

Hey folks!  I guess what I have is complex.  It's a D&D character with a few modifiers that may or may not apply to his attacks.  Dndbeyond doesn't handle it.  The Beyond20 extension doesn't handle it.  So, I need a macro solution to prevent me from always having to manually type these rolls.

I think I'm finding myself resigned in three separate macros.  One for the attack roll.  One for the damage roll without critical hits. One for the damage roll with critical hits.

The attack roll needs to recognize halfling reroll, and have modifiers for advantage or disadvantage.  I don't feel like this is an issue.

  • 1d20ro1cs>20+6
  • {1d20ro1, 1d20ro1}kh1cs>20+6
  • {1d20ro1, 1d20ro1}kl1cs>20+6

The damage portion is much harder.  There are 3 modifiers which lead to 8 combinations that need to be accounted for.  And, technically this is doubled because there is a version of each without critical hit damage, and there's a version of each WITH critical hit damage.

  • with rage, with savage attacker, with magic weapon
  • with rage, with savage attacker, without magic weapon 
  • with rage, without savage attacker, with magic weapon
  • with rage, without savage attacker, without magic weapon
  • without rage, with savage attacker, with magic weapon
  • without rage, with savage attacker, without magic weapon
  • without rage, without savage attacker, with magic weapon
  • without rage, without savage attacker, without magic weapon

Each of those results needs a die roll, or a series of dice rolls each with a different damage type.  After a couple hours of looking into this I'm EXTREMELY content letting it always assume the rage damage is radiant and anytime that would instead be necrotic I'll make a verbal note of it and let the macro be wrong.  I don't need 4 more options to account for both types of rage outcomes.

I really don't want to have 17 separate templated macros for this (or even 25 separate ones to account for both types of rage damage).  That feels obscenely cumbersome.


I built this out and it will do drop downs for the three options and output some text for which outcome I've got.  What I'd like to do is replace that simple text output with a template

?{Bingo Damage|
   With Rage,?{With Rage|

      With Savage Attacker,?{With Savage Attacker|
         With Magic, yes rage yes savage yes magic |
         
         Without Magic, yes rage yes savage no magic } |
      
      Without Savage Attacker,?{Without Savage Attacker|
        With Magic, yes rage no savage yes magic |
         
        Without Magic, yes rage no savage no magic
      }
   } |

      Without Rage,?{Without Rage|

      With Savage Attacker,?{With Savage Attacker|
         With Magic, No rage yes savage yes magic |
         
         Without Magic, no rage yes savage no magic } |
      
      Without Savage Attacker,?{Without Savage Attacker|
         With Magic, no rage no savage yes magic |
         Without Magic, no rage no savage no magic
      }
   }
}


A simple template would do fine.

&{template:default} {{name=Test With Ability}} {{attack= %{Character_Name|attack} }} {{damage= #damagemacro }}

Is it just a matter of replacing all of those syntax characters?  Is it even possible to conclude a query with a template?


I'm assuming I can readily replace that text with a die roll.  But, each outcome of that query to result in up to three separate dice rolls that may each have a different damage type.  And, with all of that information being needed a template feels like the right response.

Thanks for any help!


April 08 (4 months ago)
Gauss
Forum Champion

Hi Sihr, 

Before diving into this, could you cite the rule that you are trying to replicate? 

You stated Halfling reroll, but afaik that is only applicable to d20 checks, not damage rolls. 

April 08 (4 months ago)
timmaugh
Forum Champion
API Scripter

Are scripts available, or no?

BTW, you can include template things in a query with the proper HTML substitutions, no problem. Script availability might just make this easier, though.

April 08 (4 months ago)


Gauss said:

Hi Sihr, 

Before diving into this, could you cite the rule that you are trying to replicate? 

You stated Halfling reroll, but afaik that is only applicable to d20 checks, not damage rolls. 


The rule I'm trying to replicate?  It's not a singular rule.  It's a the series of rules I outlined.  Was anything unclear?  I'm happy to try to outline anything in more detail.  I'm not trying to apply halfling's accuracy reroll to damage.

I'm not really trying to worry about the game logic.  Just the macro details.


There are three things that can be on or off.  This leads to 8 outcomes.

I'd like the results of each of these 8 outcomes to be a template.

For example:

This would work well enough and I could replace things like "SOMEDICE" with the actual dice rolls.

?{Bingo Damage|
   With Rage,?{With Rage|

      With Savage Attacker,?{With Savage Attacker|
         With Magic, &{template:default} {{name=Attack Results}} {{bludgeoning= SOMEDICE }} {{radiant= SOMEDICE}} {{fire= SOMEDICE}} |
         
         Without Magic, yes rage yes savage no magic } |
      
      Without Savage Attacker,?{Without Savage Attacker|
        With Magic, yes rage no savage yes magic |
         
        Without Magic, yes rage no savage no magic
      }
   } |

      Without Rage,?{Without Rage|

      With Savage Attacker,?{With Savage Attacker|
         With Magic, No rage yes savage yes magic |
         
         Without Magic, no rage yes savage no magic } |
      
      Without Savage Attacker,?{Without Savage Attacker|
         With Magic, no rage no savage yes magic |
         Without Magic, no rage no savage no magic
      }
   }
}
April 08 (4 months ago)


timmaugh said:

Are scripts available, or no?

BTW, you can include template things in a query with the proper HTML substitutions, no problem. Script availability might just make this easier, though.


I have no idea what you're referring to with scripts.  If there's a better way to do this, I'm all ears.  

You're saying I can insert a template into the query with no problem.  Well, I've found problems.  Lots of problems.  Are you sure that it would work?

in this instance I have inserted the default template into the first text result of that query.  I've tried to just replace the syntax with the results from here: https://wiki.roll20.net/Roll_Query

The results become absolutely unintelligible.  I totally may have made mistakes writing it out.  I picked a single character, I replaced every instance of that character.  Then repeated the process until it was done, then copy pasted it into place.

?{Bingo Damage|
   With Rage,?{With Rage|

      With Savage Attacker,?{With Savage Attacker|
         With Magic, &{template:default} {{name=Attack Results}} {{bludgeoning= SOMEDICE }} {{radiant= SOMEDICE}} {{fire= SOMEDICE}} |
         
         Without Magic, yes rage yes savage no magic } |
      
      Without Savage Attacker,?{Without Savage Attacker|
        With Magic, yes rage no savage yes magic |
         
        Without Magic, yes rage no savage no magic
      }
   } |

      Without Rage,?{Without Rage|

      With Savage Attacker,?{With Savage Attacker|
         With Magic, No rage yes savage yes magic |
         
         Without Magic, no rage yes savage no magic } |
      
      Without Savage Attacker,?{Without Savage Attacker|
         With Magic, no rage no savage yes magic |
         Without Magic, no rage no savage no magic
      }
   }
}


April 08 (4 months ago)

Edited April 08 (4 months ago)


timmaugh said:

Are scripts available, or no?

BTW, you can include template things in a query with the proper HTML substitutions, no problem. Script availability might just make this easier, though.

It seemed like you said it was no problem.  So, here's the original bit with the dropdowns.  The dropdowns themselves worked and would output placeholder text at each outcome.

Then I went to the first outcome and I copy/pasted the default template with some minor modifications to track three kinds of damage.  I separately verified that the modifications work in another macro and that it will print and looks exactly like what I want for a proof of concept macro.

Then once it was pasted into place, I went through the syntax replacements here: https://wiki.roll20.net/Roll_Query

I replaced the ampersand at the start of the template.  I replaced each equals sign.  I replaced each open brace.  I replaced each closing brace.

The result is pretty unintelligible (to me .. that's a jumble of nonsense).  But, logically, the replacement of those characters was straightforward.

Then I tried to run the macro and it's breaking the dropdowns and things are just not working at all.


?{Bingo Damage|

   With Rage,?{With Rage|


      With Savage Attacker,?{With Savage Attacker|

         With Magic, &{template:default} {{name=Attack Results}} {{bludgeoning= SOMEDICE }} {{radiant=SOMEDICE}} {{fire=SOMEDICE}} |

         

         Without Magic, yes rage yes savage no magic } |

      

      Without Savage Attacker,?{Without Savage Attacker|

        With Magic, yes rage no savage yes magic |

         

        Without Magic, yes rage no savage no magic

      }

   } |


      Without Rage,?{Without Rage|


      With Savage Attacker,?{With Savage Attacker|

         With Magic, No rage yes savage yes magic |

         

         Without Magic, no rage yes savage no magic } |

      

      Without Savage Attacker,?{Without Savage Attacker|

         With Magic, no rage no savage yes magic |

         Without Magic, no rage no savage no magic

      }

   }

}

April 08 (4 months ago)
Gauss
Forum Champion


Sihr said:


Gauss said:

Hi Sihr, 

Before diving into this, could you cite the rule that you are trying to replicate? 

You stated Halfling reroll, but afaik that is only applicable to d20 checks, not damage rolls. 


The rule I'm trying to replicate?  It's not a singular rule.  It's a the series of rules I outlined.  Was anything unclear?  I'm happy to try to outline anything in more detail.  I'm not trying to apply halfling's accuracy reroll to damage.

I'm not really trying to worry about the game logic.  Just the macro details.


There are three things that can be on or off.  This leads to 8 outcomes.

I'd like the results of each of these 8 outcomes to be a template.

Often the best way to approach this is to find out the underlying rule or thing you are trying to perform. That is why I ask that. 

The approach you are attempting at the start, that of nested queries, may not be the best approach. It gets quite convoluted quickly and prone to breaking.

Some examples of damage rolls under each condition would also help. I am not seeing that in your query outline above. 

Are the dice you need to roll actually interdependant? Do the magic dice change based on rage or savage attacker for example?

If not you may be able to simplify the macro down considerably.

Consider this as a template-

&{template:default} {{name=Attack Results}} {{?{Rage?|
With Rage,With Rage=[[0+SOMEDICE]] damage type|
Without Rage,Without Rage}}} {{?{Savage Attacker?|
With Savage Attacker,With Savage Attacker=[[0+SOMEDICE]] damage type|
Without Savage Attacker,Without Savage Attacker}}} {{?{Magic?|
With Magic,With Magic=[[0+SOMEDICE]] damage type|
Without Magic,Without Magic}}}

Without any of the nesting the queries can be much simpler and don't need their content repeated

April 09 (4 months ago)


Gauss said:


Sihr said:


Gauss said:

Hi Sihr, 

Before diving into this, could you cite the rule that you are trying to replicate? 

You stated Halfling reroll, but afaik that is only applicable to d20 checks, not damage rolls. 


The rule I'm trying to replicate?  It's not a singular rule.  It's a the series of rules I outlined.  Was anything unclear?  I'm happy to try to outline anything in more detail.  I'm not trying to apply halfling's accuracy reroll to damage.

I'm not really trying to worry about the game logic.  Just the macro details.


There are three things that can be on or off.  This leads to 8 outcomes.

I'd like the results of each of these 8 outcomes to be a template.

Often the best way to approach this is to find out the underlying rule or thing you are trying to perform. That is why I ask that. 

The approach you are attempting at the start, that of nested queries, may not be the best approach. It gets quite convoluted quickly and prone to breaking.

Some examples of damage rolls under each condition would also help. I am not seeing that in your query outline above. 


I'm not concerned with the damage rolls at this point.  I've tried about 4 or 5 different versions of this. Fundamentally none of these approaches work.  I write software professionally.  I just don't have experience with roll20.

I started by trying to get an all in one solution.  I wanted to handle the attack roll.  Then I handled some of the damage.  Then I realized I needed to go back and add in logic for the critical hits.  Then I realized I needed an option for when attacks happened when there was no rage in effect.

Then I took a step back to diagram out the full problem.  This is how I found the 25 options in this decision tree.  If this was a more robust language with if logic and the ability to recognize state and state changes (yes, it can recognize things like ability score modifiers on a sheet which technically is state ... but you get what I'm saying ... it can't know if rage is currently active, or if a weapon that can be activated or deactivated has is on or not) then this wouldn't be an issue.

I feel very confident with my ability to write out the damage logic.  I believe I've found all the modifiers I need.  But, if I don't have a format for all of this to fit into ... then understanding how to use kh, kl, cs, ro ... none of that stuff matters.

I don't want to write 25 separate macros to handle each combination.

If there's something better than a drop down list to work your way through a list of 3 options ... I'm SUPER up for suggestions!

I need an attack roll.  I'm fine with this its own macro.  The logic for how to handle the d20 rolls with ro1 and kh1 and kl1 ... that doesn't seem like any kind of a problem to me.  This attack roll needs to handle:

  • advantage with halfling luck
  • disadvantage with halfling luck
  • neither advantage nor disadvantage, but still include halfling luck

I need either one damage roll, or a series of damage rolls.  These need to handle:

  • 2d6 maul.  This part is bludgeoning damage.
  • 4 strength modifier.  This part is bludgeoning damage.
  • 2 rage damage modifier, but only sometimes so it needs to be active or inactive.  This part is bludgeoning damage.
  • 1d6+2 damage that may be radiant or necrotic.  I'm super good with ignoring the damage split and always using the same. This is only active with rage so sometimes it's active and sometimes inactive.
  • 2d6 fire damage.  But this isn't always on so sometimes it's active and sometimes inactive.
  • the savage attacker feat which only rerolls weapon damage which would include the maul and the magic weapon damage because those are weapon damage, but wouldn't include the damage from the radiant or necrotic divine fury part.  But this only happens once per turn so sometimes this is active and sometimes it isn't.
  • the critical hit which would double all the dice including the dice which may get rolled twice from savage attacker.
  • this is three separate sources of damage
  • technically, there is also a topple effect with a saving throw and a DC.  But, I'm super good with ignoring that for the sake of simplicity.   It's easy enough to add another line into the default template if there's a way to use that.

And to be super clear ... I don't have any issues with the nuts and bolts of how to roll a 2D6 maul attack and add in the strength modifier, and also roll that twice because of the savage attacker feat and take the higher result, and also add in a modifier for rage, and also do a separate 1D6+2 damage from rage with a different damage type (that technically could be one of two options), and also how to handle an extra 2D6 weapon damage from a magic weapon which because it's weapon damage would also be impacted by savage attacker.  And ALSO double dice if a critical hit happens.  This is the easy part.  None of this feels challenging.  It's a small handful of syntax for these functionalities, and I've identified them.  THE problem, is how to make all of this presentable.


I need to know if the attack has rage or not.
I need to know if the attack has savage attacker active or not.
I need to know if the attack has the magic weapon active or not.
I may need to know if the attack was a critical hit or not.
I can ignore if the rage will chose to use radiant or necrotic damage and just always display one damage type and ignore one choice modifier.

I need to know all of those things before I roll dice.  Otherwise, I'll be rolling things step by step.  And, I could set up separate template macros to JUST handle each part of a single roll.  And, I could set up separate template macros to handle each eventuality and just click on the one that represents the current state.

I would rather have a single macro that asks me for the current state of the attack, and then outputs the right details.  I would happily settle for:

  • One macro to handle rolling to hit
  • One macro to handle each eventuality with no critical hits.  The drop down I have above ALMOST done this.  It just needs to have a template thrown in instead of the raw statement of what kind of attack has happened.
  • One macro to handle each eventuality WITH critical hits.  I'd rather have this inserted above ...but I'm just trying to simplify stuff.  I've already spent several hours on this (trying to research multiple possible solution paths and working through them until I find they don't work) and that feels like a stupid amount of time.

So, really ... what I need is to know if I CAN insert a template into that query as I've outlined above.  I already tried it.  I replaced all the syntax with the nonsense from the roll_query page to replace a single symbol with HTML entities.  This didn't work.  But, it didn't work in a way that still leads me to believe this may be the best solution path and I may be doing something wrong.  That's why I'm here, asking the experts.  And, thank you for the help.

April 09 (4 months ago)

Edited April 09 (4 months ago)


RainbowEncoder said:

Are the dice you need to roll actually interdependant? Do the magic dice change based on rage or savage attacker for example?

If not you may be able to simplify the macro down considerably.

Consider this as a template-

&{template:default} {{name=Attack Results}} {{?{Rage?|
With Rage,With Rage=[[0+SOMEDICE]] damage type|
Without Rage,Without Rage}}} {{?{Savage Attacker?|
With Savage Attacker,With Savage Attacker=[[0+SOMEDICE]] damage type|
Without Savage Attacker,Without Savage Attacker}}} {{?{Magic?|
With Magic,With Magic=[[0+SOMEDICE]] damage type|
Without Magic,Without Magic}}}

Without any of the nesting the queries can be much simpler and don't need their content repeated

Great question.

Some of them are interdependent. This must be super hard if you're not familiar with the rules set and aren't sure how to best achieve a person's goals.

If savage attacker is active it will change the root damage.
If savage attacker is active AND if the magic weapon it will change the damage from the magic weapon.

Rage adds things in, but it's separate.  Though, a critical hit would change this.

The magic weapon just adds in more damage.  It would be modified by savage attacker (as above), and it would be modified by a critical hit.

I absolutely LOVE the look of that template!  The output isn't quite right.  Savage attacker doesn't do it's own damage. It allows you to reroll other damage.  There are three potential sources for damage.  The core weapon, the rage, and the magic weapon.  Because targets can be resistant or immune to specific damage types each of these things needs to be tracked separately.  So, if something is immune to fire damage then that part is negated but the bludgeoning damage and radiant damage still apply.  This is why I can't just add it all up.

The modifiers for that damage would be savage attacker, and if it's a critical hit.

I really, really like your template!  I'm just not sure how to work through the logic for it.  It's asking the three questions.  That's outstanding.  But, each portion needs to adjust the outcome in different ways, and I'm just seeing one straight output for each yes/no question.

I don't see how to "activate" savage attacker based on your template.  If the magic damage is active because we've said yes, THEN we roll 2d6 damage.  No problem!  But, if I ALSO said yes to savage attacker now that needs to be {2d6,2d6}kh1, and if savage attacker is active then I ALSO need to adjust the base damage.

Does that make sense?  Savage attacker isn't just a dice roll that applies when it's active.  It changes no fields if it's off.  It always changes one field if it's on.  It MAY change another field if that other field is on and savage attacker is also on.  And, nothing savage attacker will do will change the damage from rage.

This is why I feel like I need that full tree.

  • with rage, with savage attacker, with magic weapon
  •     [[{2d6,2d6}kh1+6]] bludgeoning, [[1d6+2]] radiant, [[{2d6,2d6}kh1]] fire
  • with rage, with savage attacker, without magic weapon
  •     [[{2d6,2d6}kh1+6]] bludgeoning, [[1d6+2]] radiant
  • with rage, without savage attacker, with magic weapon
  •     [[2d6+6]] bludgeoning, [[1d6+2 radiant, [[2d6]] fire
  • with rage, without savage attacker, without magic weapon
  •     [[2d6+6]] bludgeoning, [[1d6+2]] radiant
  • without rage, with savage attacker, with magic weapon
  •     [[{2d6,2d6}kh1+4]] bludgeoning, [[2d6]] fire
  • without rage, with savage attacker, without magic weapon
  •     [[{2d6,2d6}kh1+4]] bludgeoning
  • without rage, without savage attacker, with magic weapon
  •     [[2d6+4]] bludgeoning, [[2d6]] fire
  • without rage, without savage attacker, without magic weapon
  •     [[2d6+4]] bludgeoning

Each of these outcomes does a different thing.  And, that's still the simplified version.  That ignores the fact that rage can chose damage type which really adds 4 more variants (let's forget that though).  And, all of this ignores critical hits which I'm fine doing a whole separate macro for.  If you include critical hits and the rage variation technically there are 24 separate variations to handle here.  If I can do all of those eventualities ... SWEET!  And, I'm fine handling the attack roll in a separate macro.  What I don't want to do is make the 25 separate super simple macros and try to keep track of how much space that takes up and how cumbersome it would be.


This is for everyone, not just you (though, definitely you also!).  I really like how kind and helpful people are on these forums!  It's super rare! The community here seems great.  I appreciate your time and help! 

April 09 (4 months ago)

Edited April 09 (4 months ago)
Gauss
Forum Champion

So a bit about Roll20, it unpacks everything before running it. 

So if you put in 

&{template:default} {{name=Test With Ability}} {{attack= %{Character_Name|attack} }} {{damage= #damagemacro }}

It sees the entire contents of %{Character_Name|attack} and #damagemacro before running the template, thus probably breaking the template depending on the contents of that command and macro. 

Honestly, everything you have stated can be easily handled via the D&D 5e 2014 by Roll20 character sheet. 

Rage: this is a switch in the sheet. 
Savage Attacker: this can also be a switch in the sheet. 
Magic Weapon: this is built into the attack, unless you mean the spell? 
Critical Hit: this is automated in the attack. 
Radiant or Necrotic damage doesn't need to be a switch, both damage types can be displayed and then called out. 

If you are willing to go that route I can walk you through the setup involved. Note: it requires that your group is using that sheet in their game. I don't *think* that the D&D 5e 2024 by Roll20 sheet is compatible with Beyond20, but I could be mistaken on that. 

Even if you would like to not use those switches, I would still recommend using the D&D 5e 2014 by Roll20 attack template because it resolves the Critical Hit problem in a simple way. 

As for the "full tree", that really shouldn't be necessary. With the right switches it can be boiled down a lot. 
An example: 
[[{2d6,2d6}kh1+6]] bludgeoning, [[1d6+2]] radiant, [[{2d6,2d6}kh1]] fire

Can have 0's and 1's queries built in to turn elements on and off. 

If your group does have the D&D 5e 2014 character sheet loaded, please let me know and we can proceed with that template. 

April 09 (4 months ago)

Really appreciative for the help so far!

Trying to put in as much information as I can.  I feel like I've said a whole lot (it feels like too much).  But, I'm (slowly ... sorry) realizing that roll20 is used for lots of games and this is still a pretty abstract problem for most folks.

So, here are some more details:

If I just wanted to separate each portion into its own thing....

The magic weapon would require 5 outcomes. One macro that handled all of that would work.  But, I would need to tell it if it's on or off and if there's a crit or not and if there's savage attacker or not.  I could separate that into two separate macros and have one for non crits and one for crits.  That would still be 3 each.  And, if I wrote separate macros for each of these things that would be four macros (I don't need a macro to run to tell me that nothing is going to happen).

  • off.  No magic weapon bonus damage.
  • on.  2d6 fire damage.
  • on with crit.  4d6 fire damage
  • on with savage attacker.  {2d6,2d6}kh1 fire damage
  • on with savage attacker and crit.  {4d6,4d6}kh1 fire damage

the core damage.  This is 8 options.  If it was easy to group these, I'd be fine grouping the regular hits into a single macro and grouping the critical hits into a separate macro.  Doing each of these as a separate macro would be too cumbersome.

  • 2d6+4 bludgeoning damage
  • critical hit 4d6+4 bludgeoning damage
  • regular hit with savage attacker {2d6, 2d6}kh1 bludgeoning damage
  • critical hit with savage attacker {4d6, 4d6}kh1 bludgeoning damage
  • regular hit with rage 2d6+6 bludgeoning damage
  • critical hit with rage 4d6+6 bludgeoning damage
  • regular hit with savage attacker and rage {2d6,2d6}kh1+6
  • critical hit with savage attacker and rage {4d6,4d6}kh1+6

the radiant damage is the easiest part (though, it's turned on by rage which also modifies the core damage above).  Technically, these would give the option to do radiant damage or necrotic damage.  That's a level of detail. I don't really care about.

  • regular hit 1d6+2 radiant damage
  • critical hit 2d6+2 radiant damage


So, if these were separated out into one macro for each damage type

  • 1 macro with 5 options
  • 1 macro with 8 options
  • 1 macro with 2 option
  • technically, also one macro for the roll to hit

It looks like if these were written up into totally unique macro for each individual action that would only take up 14 macros (8+4+2), plus a macro to handle the attack roll.

I can totally be convinced there's another approach to the problem.  The original approach I had still seems right to me.

  • one macro for the roll to hit
  • one macro with the 8 options for regular hits
  • one macro with 8 options for the critical hits which is basically a copy/paste of the previous macro (this feels sloppy, but I just want to get it done)


If a template can be used at the end of a query ... this is it, right?  THIS would do exactly what I need.  All of the HTML in that template would need to be replaced.  But, when I do that I'm still getting problems and it either means it's NOT actually possible, or I've done it incorrectly about 5 times (I may have totally done it incorrectly 5 separate times starting from scratch each time ... this is a nightmare of illegible nonsense as you start to replace the characters).

I can readily replace each line of output text with the template.  And, I can readily replace each "SOMEDICE" with the correct dice roll for that outcome.

I just need the template to actually work, and so far it doesn't seem to be possible.

?{Bingo Damage|
   With Rage,?{With Rage|

      With Savage Attacker,?{With Savage Attacker|
         With Magic, &{template:default} {{name=Attack Results}} {{bludgeoning= SOMEDICE }} {{radiant= SOMEDICE}} {{fire= SOMEDICE}} |
         
         Without Magic, yes rage yes savage no magic } |
      
      Without Savage Attacker,?{Without Savage Attacker|
        With Magic, yes rage no savage yes magic |
         
        Without Magic, yes rage no savage no magic
      }
   } |

      Without Rage,?{Without Rage|

      With Savage Attacker,?{With Savage Attacker|
         With Magic, No rage yes savage yes magic |
         
         Without Magic, no rage yes savage no magic } |
      
      Without Savage Attacker,?{Without Savage Attacker|
         With Magic, no rage no savage yes magic |
         Without Magic, no rage no savage no magic
      }
   }
}


April 09 (4 months ago)

Edited April 09 (4 months ago)
Gauss
Forum Champion

So one of the major pitfalls in Roll20 is trying to build macros the way you are trying to. Building them with every possibility as its own query isn't necessary. 

Instead, put the switches on the inside of one line. 

[[{2d6,?{Savage Attacker?|Off,0|On,1}*2d6}kh1+?{Rage?|Off,0|On,1}*6]] bludgeoning, [[1d6+2]] radiant, [[{2d6,?{Savage Attacker?}*2d6}kh1]] fire

One line, does everything you need except for criticals, and frankly even that can be done.

Note I didn't put every switch in because I don't know what is causing the radiant damage or the fire damage. I also don't know how much of the bonus damage is due to Rage vs not rage, but that can be easily dealt with. 

That is why I asked at the start for details on the elements. The more specific you get as to the math the easier it is for us to come up with solutions. 

April 09 (4 months ago)


Gauss said:

So a bit about Roll20, it unpacks everything before running it. 

So if you put in 

&{template:default} {{name=Test With Ability}} {{attack= %{Character_Name|attack} }} {{damage= #damagemacro }}

It sees the entire contents of %{Character_Name|attack} and #damagemacro before running the template, thus probably breaking the template depending on the contents of that command and macro. 

Honestly, everything you have stated can be easily handled via the D&D 5e 2014 by Roll20 character sheet. 

Rage: this is a switch in the sheet. 
Savage Attacker: this can also be a switch in the sheet. 
Magic Weapon: this is built into the attack, unless you mean the spell? 
Critical Hit: this is automated in the attack. 
Radiant or Necrotic damage doesn't need to be a switch, both damage types can be displayed and then called out. 

If you are willing to go that route I can walk you through the setup involved. Note: it requires that your group is using that sheet in their game. I don't *think* that the D&D 5e 2024 by Roll20 sheet is compatible with Beyond20, but I could be mistaken on that. 

Even if you would like to not use those switches, I would still recommend using the D&D 5e 2014 by Roll20 attack template because it resolves the Critical Hit problem in a simple way. 

As for the "full tree", that really shouldn't be necessary. With the right switches it can be boiled down a lot. 
An example: 
[[{2d6,2d6}kh1+6]] bludgeoning, [[1d6+2]] radiant, [[{2d6,2d6}kh1]] fire

Can have 0's and 1's queries built in to turn elements on and off. 

If your group does have the D&D 5e 2014 character sheet loaded, please let me know and we can proceed with that template. 


Thank you for your input, your suggestions, and your time.


I don't care for the roll20 character sheet system.  I think the roll20 map product is outstanding.  I'm super happy with roll20 as a service.  I think the macro functionality ... exists, and it's more useful than not having the ability to write macros.  The character sheet system I'm not a big fan of.


I'll spend some time to create the character in roll20 and give it a try there and see if things just work.  I have a very strong preference to keep my characters in dndbeyond.  With the beyond20 extension I find that MOST of the things you want to do work just fine!  

I'll take your advice and try building out the character and see if that is recognizing all of the states and doing all of the rolls correctly.  I would still be using the dndbeyond character sheet (the UX and UI is just .... so much better), but triggering the attack roll on a separate secondary character sheet ... isn't the end of the world.  Not my preference though.

If there's a way to make that template work within the query that would be my preference.

But, I'm happy to look at alternatives.  Especially after hours of trying to solve the macro issue.  Without the template ... that query works and spits out the temporary text just fine.  I just need to replace each bit of temporary text with a template.

?{Bingo Damage|
   With Rage,?{With Rage|

      With Savage Attacker,?{With Savage Attacker|
         With Magic, &{template:default} {{name=Attack Results}} {{bludgeoning= SOMEDICE }} {{radiant= SOMEDICE}} {{fire= SOMEDICE}} |
         
         Without Magic, yes rage yes savage no magic } |
      
      Without Savage Attacker,?{Without Savage Attacker|
        With Magic, yes rage no savage yes magic |
         
        Without Magic, yes rage no savage no magic}
    } |

      Without Rage,?{Without Rage|

      With Savage Attacker,?{With Savage Attacker|
         With Magic, No rage yes savage yes magic |
         
         Without Magic, no rage yes savage no magic } |
      
      Without Savage Attacker,?{Without Savage Attacker|
         With Magic, no rage no savage yes magic |
         Without Magic, no rage no savage no magic}
   }
}


April 09 (4 months ago)

Edited April 09 (4 months ago)
Gauss
Forum Champion


Sihr said:


I don't care for the roll20 character sheet system.  I think the roll20 map product is outstanding.  I'm super happy with roll20 as a service.  I think the macro functionality ... exists, and it's more useful than not having the ability to write macros.  The character sheet system I'm not a big fan of.



Completely ok to not use the character sheet. TBH, I wasn't actually suggesting you use it full-stop. More of a means to gain access to some tricks it has. Such as on-off switches or the template. 

Part of the problem you are facing is macros cannot do quite everything smoothly. There is a lot of work going on behind the scenes in the character sheet templates. 
You don't need to use the character sheet itself, but if it is loaded into the game it can provide all the magic of the templates. 

Particularly the D&D 5e 2014 template for attacks, it automatically does critical hits. Without that it is much more difficult to automate critical hits. 

Of course, we can still do that via queries like what I outlined a moment ago. It is just that I try to actively avoid doing more than 1-2 queries in a single macro. It is ugly and slow. 

Chat Menus are pretty good for breaking that down, but require more setup work at the start. 

April 09 (4 months ago)


Gauss said:

So one of the major pitfalls in Roll20 is trying to build macros the way you are trying to. Building them with every possibility as its own query isn't necessary. 

Instead, put the switches on the inside of one line. 

[[{2d6,?{Savage Attacker?|Off,0|On,1}*2d6}kh1+?{Rage?|Off,0|On,1}*6]] bludgeoning, [[1d6+2]] radiant, [[{2d6,?{Savage Attacker?}*2d6}kh1]] fire

One line, does everything you need except for criticals, and frankly even that can be done.

Note I didn't put every switch in because I don't know what is causing the radiant damage or the fire damage. I also don't know how much of the bonus damage is due to Rage vs not rage, but that can be easily dealt with. 

That is why I asked at the start for details on the elements. The more specific you get as to the math the easier it is for us to come up with solutions. 


That one line solution is dope!  I did a bunch of searches online and spent a lot of time going through macro documentation.  I didn't see anything that lead me to this as a solution path.  There isn't a lot of roll20 macro content on youtube, but I looked through some of that, too.

I'm going to spend some time messing around with this solution and try to get it to do all the things I need it to do.  This looks promising.  I've never seen anything like this.


A concern I have is the lack of status output.  It's stating the damage.  That's the most important.  I can cursor over things and think about it for a moment to breakdown what was selected.  But, it may not be readily apparent if I misclick an option.  This will be a thing I'll try to solve for as well.  Something to just plainly state "this is what these numbers mean, I'm not trying to cheat anyone or roll any extra dice" or whatever.  Something to make it clear that rage is on, savage attacker is on, and the magic weapon is on (for example).  From what I see it looks like I set the state of a variable, and then I can later check the status of that variable for a binary check.  That should mean I can include simple text with a binary check to output the status of those 3 major checks.

Anyway ... LOVE this.  Will spend some time diving into it and looking for details about it in the documentation to learn more about how to create one myself in the future.


April 09 (4 months ago)

Edited April 09 (4 months ago)
Gauss
Forum Champion

Here you go: 


&{template:default} {{name=Damage roll}} [[[[{(?{Critical?|No,1|Yes,2}*2)d6,(?{Critical?}*?{Savage Attacker?|Off,0|On,2})d6}kh1+?{Rage|Off,0|On,2}+4]] +[[(?{Critical?}*1)d6+2]] +[[{(?{Critical?}*2)d6,(?{Critical?}*?{Savage Attacker?})d6}kh1}]]]] {{Total=$[[3]]}} {{Bludgeoning=$[[0]]}} {{Radiant=$[[1]]}} {{Fire=$[[2]]}} {{Report=Crit [[?{Critical?}-1]]%NEWLINE%Rage [[?{Rage}]]%NEWLINE%Savage Attacker [[?{Savage Attacker?}]]}}

I tested it and it works. The reporting section can probably use some work. I'd combine that with Rollable Tables if your GM will give you temporary GM status to write Rollable Tables, but for now a "0" is off and a non-zero is on. 


Personally, i'd still reduce the number of queries by leveraging Chat Menus, but that is just personal preference. Three queries isn't terrible. 

Edit - what this macro does: 
Asks if it is a Critical. If it is not it multiplies all dice by "1". (Ie: no critical). If it is, it multiplies all dice by 2. 

Asks if there is rage. No = 0, Yes = 2 (Rage being +2). Note, if you'd like you can have it multiply an attribute instead for easier modification down the road. 
Example: Instead of ?{Rage?|No,0|Yes,2} we use:
?{Rage?|No,0|Yes,1}*@{charactername|Rage}

Asks if you are using Savage Attacker. If no, it plugs in a 0. If yes it spits out a 2. This is because both instances are 2d6. 
If you switch to a different weapon, instead use the following: 
(?{Savage Attacker?|No,0|Yes,1}*X)dY
Where X is the number of dice and Y is the size of the die. 

A note about Queries, you do not need to reproduce the entire query every time it is used. Only the name on subsequent uses. 

?{Savage Attacker?|No,0|Yes,2} is for the first use. The second only needs ?{Savage Attacker?} because it will output the same output as the first instance.

You can add labels into inline rolls - to adjust what Gauss wrote -

[[{2d6,?{Savage Attacker?|Off,0d0|On,2d6[SAVAGE ATTACKER]}}kh1?{Rage?|Off, |On,+6[RAGE]}]] bludgeoning, [[1d6+2]] radiant, [[{2d6,?{Savage Attacker?|Off,0d0|On,2d6[SAVAGE ATTACKER]}}kh1]] fire

This will show you the source if if the effect is selected active.

April 09 (4 months ago)

Edited April 09 (4 months ago)
Gauss
Forum Champion

Yes, but that requires hovering over each output. It is easier to just see an on/off answer in the template. 
I had those initially but pulled them. 
(Note: the one you quoted was an off the cuff example, not fully fleshed out. I posted a full version in my previous post.)

Tuo said:

You can add labels into inline rolls - to adjust what Gauss wrote -

[[{2d6,?{Savage Attacker?|Off,0d0|On,2d6[SAVAGE ATTACKER]}}kh1?{Rage?|Off, |On,+6[RAGE]}]] bludgeoning, [[1d6+2]] radiant, [[{2d6,?{Savage Attacker?|Off,0d0|On,2d6[SAVAGE ATTACKER]}}kh1]] fire

This will show you the source if if the effect is selected active.




April 09 (4 months ago)

Edited April 09 (4 months ago)


Gauss said:

Here you go: 


&{template:default} {{name=Damage roll}} [[[[{(?{Critical?|No,1|Yes,2}*2)d6,(?{Critical?}*?{Savage Attacker?|Off,0|On,2})d6}kh1+?{Rage|Off,0|On,2}+4]] +[[(?{Critical?}*1)d6+2]] +[[{(?{Critical?}*2)d6,(?{Critical?}*?{Savage Attacker?})d6}kh1}]]]] {{Total=$[[3]]}} {{Bludgeoning=$[[0]]}} {{Radiant=$[[1]]}} {{Fire=$[[2]]}} {{Report=Crit [[?{Critical?}-1]]%NEWLINE%Rage [[?{Rage}]]%NEWLINE%Savage Attacker [[?{Savage Attacker?}]]}}

I tested it and it works. The reporting section can probably use some work. I'd combine that with Rollable Tables if your GM will give you temporary GM status to write Rollable Tables, but for now a "0" is off and a non-zero is on. 


Personally, i'd still reduce the number of queries by leveraging Chat Menus, but that is just personal preference. Three queries isn't terrible. 


You're awesome, man!  Thank you for putting so much work into this to help! 

I'm still trying to understand the first one you sent me.  Where can I find this stuff in the docs?

The logic on this needs some tweaks (there's no magic weapon check to see if any fire damage would be output).

I'm still trying to work backwards to figure out what's going on.  I spent some time looking for this stuff in the documentation without knowing what anything is called or how to find it (it wasn't fruitful).



I'm going to try and break down this.  It seems like another language.  It's not a part of any of the syntax I've seen so far in the docs.

(?{Critical?|No,1|Yes,2}*2)d6,(?{Critical?}*?{Savage Attacker?|Off,0|On,2})d6}kh1+?{Rage|Off,0|On,2}+4]]

So, it's doing a yes/no check to see if there is a critical hit.

?{Critical?|No,1|Yes,2}

So, if Critical was answered with a true, then this has a value of 2 and if it was false this has a value of 1.

These are being used as multipliers.  multiply dice by 1 for no critical hit.  Multiply dice by 2 for a critical hit to double them.

So, if critical was true then 2*2 is equal to 4, and 4d6 gets rolled.

And, if critical was false, then 1*2 is equal to 2 and 2d6 gets rolled.


It looks like the trick being used for the double roll is to always use {XdY, XdY}kh1

But, sometimes one of those two dice rolls is negated.  Leaving this with a single XdY and picking the highest result out of 1.

So, it opens the curly brace, then checks to see if savage attacker is true, then checks to see if critical is true and this determines if the first set of dice get rolled (and how many).  Regardless of how that turns out, it then checks to see if critical is true to modify the second set of dice.  then picks the highest of those results.

With this all in one line and the syntax being a bit of a mystery it's hard to tell where one section ends and another begins.



This stuff is awesome, man.  It's not ... exact.  But, it's really close!  And, it's got a lot going on and it's fun to look at.  This is going to take me some time to digest.  I love that you even went in to add the critical part AND threw in some kind of output.

I don't understand it well enough yet to know if the first parts are accurate.  There isn't a check to see if fire damage should be included or not, which would also need a check to see the variable status of critical to know how many dice get rolled, and savage attacker to know if a second set of dice get rolled.

I think once I do understand what's going on I'm going to try and use some whitespace to split this up into multiple lines.  There are a couple different sections here.  I think it would help me visually to see them as separate and distinct.  To visually be able to see where a section of code ends.

When I can rewrite it from scratch I'll feel like I understand it.  Will work on it on a whiteboard for a bit and make sure the syntax and logic are making sense.

I'm not sure if this is remotely right.  I'm trying to do it without looking at what you had.

I don't like the usage of Rage I'm using.  The logic is it will add +2 to bludgeoning damage if true.  And, also it will add 1d6+2 radiant damage later if true.  The same silly multiply by 0 trick can be used over and over.  That feels ... bad/embarrassing/terrible.  But, it's been like 6+ hours of me trying to add a template into a query.  I'm good with less than ideal.

The pseudocode I need basically works out to

 {     (1 or 2)         *          (0 or 2)          d6,   (1 or 2)*2 d6}kh1  +         (0 or 1) * 2     + 4

{(Crit?No,1|Yes,2)*(Savage?Off,0|On,2)d6,(Crit?)*2d6}kh1 + (Rage?No,0|Yes,1)*2+ 4      this handles the bludgeoning damage logic

(0 or 1) * (1 or 2)* 1d6+ ((0 or 1) * 2)

(Rage?)*(Crit?) * 1 d6+ ((Rage?)* 2)         this handles the radiant damage logic


        {(0 or 1)          *  (1 or 2) * (0 or 2)  d6, (1or 2)*(0 or 1)  *2 d6}kh1

{(Magic?Off,0|On,1) * (Crit?)*(Savage?)d6, (Crit?)*(Magic?)*2 d6}kh1     this should handle the fire damage



This is going to make me want to jump off a bridge.  Gonna call it a night for now.

I think that pseudocode should handle the logic with ... whatever this method for macros is called.  I'll look further into the syntax tomorrow to make the adjustments so it will work correctly.

April 09 (4 months ago)

Edited April 09 (4 months ago)
Gauss
Forum Champion


You keep referencing Magic Weapon, but I haven't seen a Magic Weapon bonus here. Do you mean Fire damage? 

The reason this is probably not part of any document is that this is simple boolean algebra. My background is electronics so I am used to 0s and 1s being used as off and on switches. 

In certain cases (such as critical hit multipliers) so we don't want a 0, we want a "1" to represent "no change". But it is still the same basic concept. 

Breaking down what you have (quotes are used for clarity, they are not code): 
* Base damage = "2d6"
* Savage Attack applied to base damage = roll base damage twice and take the best. That is "{2d6, 2d6}kh1"
Now we need a switch. "?{Savage Attack|No,0|Yes,1}" That give us our boolean switch. 
* Savage Attack applied to base damage complete with the switch = "{2d6, (?{Savage Attack|No,0|Yes,1}*2)d6}kh1"
Note: there are several ways I could have done the query portion. 
It could be "?{Savage Attack|No,0|Yes,2}d6" or it could be "(?{Savage Attack|No,0|Yes,1}*2)d6" or it could be "?{Savage Attack|No,0|Yes,1}*2d6

All are generally valid and are just how one feels like writing it at the time. Warning though, the third one will get you into trouble sometimes because of the following: 
"?{queryname|No,0|Yes,2}*2d6" is NOT the same as "(?{queryname|No,0|Yes,2}*2)d6"
The first one gives you 2*2d6 and the second one gives you 4d6. Those are not identical. 2*2d6 will result in multiplying 2d6 after rolling. 

Because of this I try to stick to the first two options. 

Next, Rage damage.
Again, simple boolean switch. "?{Rage|No,0|Yes,2}" OR "?{Rage|No,0|Yes,1}*2"
Either work and are simply preference. Personally I'd opt for the second one multiplying an Attribute instead of "2". That makes it easier to update when Rage increases. 

Next, Fire damage. I did not realize this also needed a switch. I think that is because I never understood you were defining "Magic Weapon" as fire damage. Usually "Magic Weapon" in D&D means the spell, or a + bonus to attack/damage. 

In any case, Magic Weapon (Fire Damage) can be controlled via another query. The fixed macro is below.

&{template:default} {{name=Damage roll}} [[[[{(?{Critical?|No,1|Yes,2}*2)d6,(?{Critical?}*?{Savage Attacker?|Off,0|On,2})d6}kh1+?{Rage|Off,0|On,2}+4]] +[[(?{Critical?}*?{Magic Weapon?|No,0|Yes,1})d6+2]] +[[{(?{Critical?}*2)d6,(?{Critical?}*?{Savage Attacker?})d6}kh1}]]]] {{Total=$[[3]]}} {{Bludgeoning=$[[0]]}} {{Radiant=$[[1]]}} {{Fire=$[[2]]}} {{Report=Crit [[?{Critical?}-1]]%NEWLINE%Rage [[?{Rage}]]%NEWLINE%Savage Attacker [[?{Savage Attacker?}]]%NEWLINE%Magic Weapon [[?{Magic Weapon?}]]}}


Fire damage section is: [[(?{Critical?}*?{Magic Weapon?|No,0|Yes,1})d6+2]]
Again, it is checking for Critical (No = 1, Yes = 2), multiplying that by Magic Weapon's 0 or 1, and then that is the number of d6s rolled.

Does the Radiant damage also only apply if Raging? If so we can use the same query for that. 
Which part of the Radiant damage comes from the Rage? The entire thing? The +2?

As for this being less than ideal, people have been using Boolean algebra queries on Roll20 for a very long time. Boolean algebra works wonders in Roll20 macro code when you need on/off switches.
And it is often simpler to write a query that way than the nested query method you were attempting. Nesting queries is something many of us have moved away from because there are better tools and options that are less....brain burning. 

Chat Menus for example, they make the whole process a lot more streamlined and less difficult to work with. 

Found a Roll20 wiki article referencing using Boolean Math in the Pathfinder sheet. Obviously not D&D 5e, but the concept is the same. 

The way you're using queries for the controls, might I suggest using simple overwrite to display the reports only when they're active?

&{template:default} {{name=Damage roll
}} [[[[{(?{Critical?|No,1|Yes,2}*2)d6,(?{Critical?}*?{Savage Attacker?|Off,0|On,2})d6}kh1+?{Rage|Off,0|On,2}+4]] +[[(?{Critical?}*?{Magic Weapon?|No,0|Yes,1})d6+2]] +[[{(?{Critical?}*2)d6,(?{Critical?}*?{Savage Attacker?})d6}kh1}]]]] {{Total=$[[3]]
}} {{Bludgeoning=$[[0]]
}} {{Radiant=$[[1]]
}} {{Fire=$[[2]][ ](#" hidden null=)
}} {{[0](#" hidden)=
}} {{[[[?{Critical?}-1]]](#" hidden)=Critical!
}} {{[[[?{Rage}]]](#" hidden)=Raging!
}} {{[[[?{Savage Attacker?}*1.5]]](#" hidden)=Attacking savagely!
}} {{[[[?{Magic Weapon?}*4]]](#" hidden)=Magic weapon active!
}} {{[0](#" hidden)=
}}

Also, I didn't alter the math at all here, and it's too early for me to read... all of that, up there. Is the fire damage supposed to be there when the magic weapon is not active? Or the radiant damage to always add 2, regardless of the options? Because the way it's set up now, it adds +2 radiant damage always, and the magic weapon damage relies entirely on Savage Attack.

I'm not entirely sure how that's supposed to be or if that's wrong in the first place (the descriptions above are hardly concise), but assuming I have the right idea, this would be the corrected version:


&{template:default} {{name=Damage roll
}} [[[[{(?{Critical?|No,1|Yes,2}*2)d6,(?{Critical?}*?{Savage Attacker?|Off,0|On,2})d6}kh1+?{Rage|Off,0|On,2}+4]] +[[?{Magic Weapon?|No,0|Yes,1}*(?{Critical?}d6+2)]] +[[{(?{Magic Weapon?}*?{Critical?}*2)d6,(?{Magic Weapon?}*?{Critical?}*?{Savage Attacker?})d6}kh1}]]]] {{Total=$[[3]]
}} {{Bludgeoning=$[[0]]
}} {{Radiant=$[[1]]
}} {{Fire=$[[2]][ ](#" hidden null=)
}} {{[0](#" hidden)=
}} {{[[[?{Critical?}-1]]](#" hidden)=Critical!
}} {{[[[?{Rage}]]](#" hidden)=Raging!
}} {{[[[?{Savage Attacker?}*1.5]]](#" hidden)=Attacking savagely!
}} {{[[[?{Magic Weapon?}*4]]](#" hidden)=Magic weapon active!
}} {{[0](#" hidden)=
}}

I could probably hide the radiant and fire damage when they're zero, too, but that would change the layout a bunch and I need to eat something first.

Using some more complicated query toggles I was able to construct this

&{template:default} {{name=

?{Crit|
No,1|
Yes,2{}

?{Rage|
With,2{|
Without,0}

?{Savage Attacker|
With,1[{|
Without,0[} ]

?{Magic|
With,1{|
Without,0}

Go Faster Stripe [[0]][[0]]
[[ [[ {[[2*?{Crit}]]d6,[[2* ?{Savage Attacker} ] *?{Crit}]]d6}k1 + 4[str] +[[?{Rage}]][rage] ]] [Bludgeoning
] +[[ [[ [[?{Crit}]]d6 + 2 ]]/2*?{Rage} ]] [Rad/Nec
] +[[ [[ {[[2*?{Crit}]]d6,[[2* ?{Savage Attacker} ]*?{Crit}]]d6}k1 ]]*?{Magic}]] [Fire] ]]

}} {{name=Attack Results}}?{Crit}{Critical!}} {{Rage=Inactive
}} {{Savage Attacker=Inactive
}} {{Magic=Inactive
}} {{Bludgeoning=$[[7]]
}} ?{Rage}{Rage=**Active**}} ?{Rage}{Radiant/Necrotic=$[[8]]}} ?{Magic}{Magic=**Active**}} ?{Magic}{Fire=$[[10]]}} ?{Savage Attacker}{Savage Attacker=**Active**}} ?{Rage}{Total=$[[13]]}} ?{Magic}{Total=$[[13]]}}

This will show when you have selected critical and if rage/savage attacker/magic are inactive/active and only show the damage sections as appropriate as well as a total if there is more than one damage type.

It works by the queries ending with a { when a toggle is active, which can be ignored in rolls with careful construction, but used to start a template section outside of rolls. So that template section is only parsed when the query toggle is active. This allows the active version of a field to override the inactive version or show/hide a field all together.


I should probably do a write up on this technique.

And here's my refined version (still built off what Gauss wrote), I also realized that the radiant damage came from the rage, so I fixed that

&{template:default} {{name=Damage roll
}} [[[[{(?{Critical?|No,1|Yes,2}*2)d6,(?{Critical?}*?{Savage Attacker?|Off,0|On,2})d6}kh1+?{Rage|Off,0|On,2}+4]] +[[?{Rage|No,0|Yes,1}*(?{Critical?}d6+2)]] +[[{(?{Magic Weapon?|No,0|Yes,1}*?{Critical?}*2)d6,(?{Magic Weapon?}*?{Critical?}*?{Savage Attacker?})d6}kh1}]]]] {{Total=$[[3]]
}} {{$[[0]]=Bludgeoning [ ](#" hidden null=)
}} {{[0](#" hidden)=
}} {{[[[?{Magic Weapon?}*4]]](#" hidden)=Magic weapon active!
$[[2]] Fire damage
}} {{[[[?{Rage}]]](#" hidden)=Raging!
$[[1]] Radiant damage
}} {{[[[?{Critical?}-1]]](#" hidden)=Critical!
}} {{[[[?{Savage Attacker?}*1.5]]](#" hidden)=Attacking savagely!
}} {{[0](#" hidden)=
}}
April 09 (4 months ago)

Edited April 09 (4 months ago)
Gauss
Forum Champion


Tuo said:

And here's my refined version (still built off what Gauss wrote), I also realized that the radiant damage came from the rage, so I fixed that

&{template:default} {{name=Damage roll
}} [[[[{(?{Critical?|No,1|Yes,2}*2)d6,(?{Critical?}*?{Savage Attacker?|Off,0|On,2})d6}kh1+?{Rage|Off,0|On,2}+4]] +[[?{Rage|No,0|Yes,1}*(?{Critical?}d6+2)]] +[[{(?{Magic Weapon?|No,0|Yes,1}*?{Critical?}*2)d6,(?{Magic Weapon?}*?{Critical?}*?{Savage Attacker?})d6}kh1}]]]] {{Total=$[[3]]
}} {{$[[0]]=Bludgeoning [ ](#" hidden null=)
}} {{[0](#" hidden)=
}} {{[[[?{Magic Weapon?}*4]]](#" hidden)=Magic weapon active!
$[[2]] Fire damage
}} {{[[[?{Rage}]]](#" hidden)=Raging!
$[[1]] Radiant damage
}} {{[[[?{Critical?}-1]]](#" hidden)=Critical!
}} {{[[[?{Savage Attacker?}*1.5]]](#" hidden)=Attacking savagely!
}} {{[0](#" hidden)=
}}


Tuo, the first instance of Rage query needs to be modified to accomodate the second instance of Rage. Instead of ?{Rage|Off,0|On,2} it should be ?{Rage|Off,0|On,1}*2

Also, I suspect that the second instance of Rage also needs to be applied to the entirety of 1d6+2, but I am still waiting for confirmation from Sihr.

April 09 (4 months ago)

Edited April 09 (4 months ago)
timmaugh
Forum Champion
API Scripter

Sihr said:


timmaugh said:

Are scripts available, or no?

BTW, you can include template things in a query with the proper HTML substitutions, no problem. Script availability might just make this easier, though.


I have no idea what you're referring to with scripts.  If there's a better way to do this, I'm all ears.  

You're saying I can insert a template into the query with no problem.  Well, I've found problems.  Lots of problems.  Are you sure that it would work?

Hey, Sihr. I may have mispoke about the template parts in a query. I can't find any of my former examples of what I thought I'd been able to do, so I'll have to dig into this more to remember where the boundaries are and what the tricks are to get around them.

However.

You've gotten a lot of help on the template front, so I want to concentrate on some of the other deficits you've alluded to.

Scripts

First "scripts" (or, "mod scripts") are community-written add-ons that you can implement in your game. They are a perk of being a Pro subscriber, but they are available for everyone in a game created by a Pro-sub. In other words, if your game's creator is a Pro subscriber, then scripts are available to you; a GM will just have to install them in the game for you.

You may have heard of some of the more popular scripts if you've been around the forums or discord for long, or if you've watched some of Nick Olivo's YouTube videos. Names like TokenMod, ChatSetAttr, GroupInit, GroupCheck, ScriptCards, SmartAoE, and the MetascriptToolbox (among others) are all system-agnostic scripts, so you can use them no matter the system you're running. Other scripts are more specifically tailored to some particular rule of a particular system, and so don't necessarily make sense to use in other games.

I mentioned scripts because the MetascriptToolbox and ScriptCards both offer ways to implement logical constructions in your command line and output contingent result panels... they just do it in slightly different ways. Being a software dev, yourself, you might enjoy ScriptCards, as it is built to emulate a command language you can input directly from chat (ie, from an ability or macro). However, the Toolbox was written to interact with (and augment) other scripts (or to just output panels directly to chat without the need of other scripts), so the two packages are fundamentally different.

As the author of the Toolbox, I'll explain how it can help with what you're trying to do.

Timing

If you're new to writing macros for Roll20 and especially if you're new to using scripts on Roll20, I'd recommend watching this video. Well, if you're going to go on to use metascripts, watch the whole thing. If you're only going to be using standard macro syntax and standard scripts, you only have to watch the first ~15 minutes (the first 2 parts). That explains how things generally work.

Metascript Trinkets and Doodads

You mentioned wanting logical IF structures and decision tree mapping. Metascripts can do this for you. They can let you reuse queries for multiple purposes, reuse rolls even outside of nested roll structures, run batches of commands together to share rolls across the messages, build templates out of looped output, implement global variables to let you re-reference data later, directly access game data beyond what Roll20 native syntax structures expose for you... lots of things.

And, since it can do all of this, you don't have to necessarily nest queries (unless you wanted to in order to limit the number of things you have to answer).

For instance, a simple IF logical structure:

{&if ?{Rage} = yes}Raging{&else}Not raging{&end}

Now put it in a message that will hit the chat:

!You answered the query with ?{Rage|Yes|No}. The IF block resolves to: {&if ?{Rage} = yes}Raging{&else}Not raging{&end}.{&simple}

A simple reference to a sheet attribute for the selected token:

@(selected.Rage)

Put into a message that will hit the chat:

!The selected character has a Rage value of @(selected.Rage).{&simple}

And combine the methods to drive a logical evaluation based on the result being a 0 or 1:

!The selected character is {&if @(selected.Rage) = 0}NOT {&end}raging. {&simple}

IF structures allow ELSEIF and ELSE cases, as well as chaining logical tests for more complex trees:

{&if a = b || b = c || (a = c && d != e)}True case{&elseif a > b && a > c}Else if case{&else}Else case{&end}

They also allow nesting:

{&if a = b} {&if c > d}Nested true case{&else}Nested else case{&end} {&else}Outer Else case{&end}

A lookup on a mule ability:

get.MuleCharacter.MuleAbility.variableName/get

...which could be a number:

get.MuleCharacter.MuleAbility.1/get

...which means it could be the result of a roll:

get.MuleCharacter.MuleAbility.$[[0]].value/get

...and the same can be done from a rollable table:

@(table.TableName.$[[0]].value)

How it helps you

You can use any/all of these structures in a template command that you output to chat. And you can use these tricks (and more) to manipulate rolls, repackage values, and build outcome sets. For instance, you could use queries to drive usage case, then have nested IF structures or chained-evaluation to drive results. Chained evaluation:

!&{template:default}{{name=Proof of Concept}} {{Rage Query=?{Rage|Yes|No} }} {{Savage Attacker Query=?{Savage|Yes|No} }} {{Magic Weapon Query=?{Magic Weapon|Yes|No} }} {{Result={&if ?{Rage} = Yes && ?{Savage} = Yes && ?{Magic Weapon} = Yes}All 'Yes' result{&elseif ?{Rage} = Yes && ?{Savage} = Yes && ?{Magic Weapon} = No}Yes for Rage and Savage, No to Magic Weapon{&else}Delineate/expand other cases here{&end} }}{&simple}

Nested structures:

!&{template:default}{{name=Proof of Concept}} {{Rage Query=?{Rage|Yes|No} }} {{Savage Attacker Query=?{Savage|Yes|No} }} {{Magic Weapon Query=?{Magic Weapon|Yes|No} }} {{Result=
  {&if ?{Rage} = Yes}
    {&if ?{Savage} = Yes}
      {&if ?{Magic Weapon} = Yes}
        All 'Yes' result
      {&else}
        Yes for Rage and Savage, No to Magic Weapon
      {&end}
    {&else}
      {&if ?{Magic Weapon} = Yes}
        Yes for Rage and Magic Weapon, No to Savage
      {&else}
        Yes for Rage, No to Savage and Magic Weapon
      {&end}
    {&end}
  {&else}
    Duplicate/delineate results now for the No response to Rage query
  {&end}
}}{&simple}

(That one may include extra line breaks since I wrote it to span multiple lines.)

If it were me...

If I was dealing with this, I think I would use exponential binaries to represent my cases: 

CONDITIONBINARY EXPONENTVALUE
Rage2^01
Savage Attacker2^12
Magical Weapon2^24

(If you wanted another case in there—ie, necrotic vs radiant—you'd just have another on/off and adjust your exponent assignments as necessary.)

At this point, you'd only have to total your condition values to know your case:

0=None
1=Rage
2=Savage Attacker
3=Rage + Savage Attacker
4=Magical Weapon
5=Rage + Magical Weapon
6=Savage Attacker + Magical Weapon
7=Rage + Savage Attacker + Magical Weapon

So you could have a mule ability setup to represent those cases, including the verbiage you need. Just copying from a previous post of yours, I think that would look like:

0=[[2d6+4]] bludgeoning
1=[[2d6+6]] bludgeoning, [[1d6+2]] radiant
2=[[{2d6,2d6}kh1+4]] bludgeoning
3=[[{2d6,2d6}kh1+6]] bludgeoning, [[1d6+2]] radiant
4=[[2d6+4]] bludgeoning, [[2d6]] fire
5=[[2d6+6]] bludgeoning, [[1d6+2 radiant, [[2d6]] fire
6=[[{2d6,2d6}kh1+4]] bludgeoning, [[2d6]] fire
7=[[{2d6,2d6}kh1+6]] bludgeoning, [[1d6+2]] radiant, [[{2d6,2d6}kh1]] fire

Enter that text into an ability called (let's say) DamageCase on a character named TableMule. Now you can produce your output as:

!&{template:default} {{name=Test With Ability}} {{attack= %{Character_Name|attack} }} {{damage= get.TableMule.DamageCase.[[?{Rage|No,0|Yes,1} + ?{Savage|No,0|Yes,2} + ?{Magical Weapon|No,0|Yes,4}]].value/get }}{&simple}

Now with 100% less queries

The same thing can be obtained from character sheet attributes (if they are available). Since you can create attributes for each of these if they don't exist, let's just say they're available.

If the attributes are named "Rage", "Savage", and "MagicWeapon" (to represent if these cases are in use/equipped)...

...AND...

...if the attributes are valued at a 0 or 1 (the default for checkboxes on a sheet)...

Then your case derivation can be changed to:

get.TableMule.DamageCase.[[@{CharacterName|Rage} + (@{CharacterName|Savage} * 2) + (@{CharacterName|MagicalWeapon} * 4)]].value/get

Swap that into the command line, above, and you'll get the same thing, just without having to answer queries.

Other Approaches

If the attributes on the sheet are not 0/1 based but are instead governed by what you put there (for instance, with another script like ChatSetAttr), then all of that can be combined into a set of control macros that set the appropriate values as they would occur in the course of the game (or even at the moment that the attack is made). For instance, you could be putting 0/1, 0/2, and 0/4 for the values as appropriate. All of this can be combined into the single, metascript-powered command line...

...but...

Since you have purposefully reduced this to an x/y problem, and since it is really an x^z/y problem (where I have no way of knowing all of the potential x-cases that could arise which could conceivably be described as a "it's generally y" situation), I'm not going to get crazy with the Cheez Whiz and try to solve them all.

You asked for a better way. This is a better way. I'll leave it to you to ask more elucidating questions at this point, if scripts are available.

REQUIRED SCRIPTS:

MetascriptToolbox

April 09 (4 months ago)

Everyone is trying to rewrite it from scratch with different methods.  I think that's really nice of folks.

I'm going to assume that this also means that my original question just isn't possible.  I've posted the query that 100% works and output the correct unique basic text output repeatedly.  I've posted the first plain text result replaced with a template that does NOT work, but does demonstrate what I've been trying to get to work.

No one has tried to pick up that torch and just ... insert a template there.  Any template ... saying anything to demonstrate that a template CAN be placed there.

I'm going to assume that means it isn't possible and I need a new approach.  That's fine.

I was hoping to just get some suggestions and links to docs maybe for where to look.  Everyone is trying to write a version of it.  This is REALLY nice and definitely above and beyond.  Most of the logic being used is accurate.  Still nice of folks to try!  But, none of it works for my purposes and since I'm unfamiliar with these other options it'll take me time to learn how they work and fix them, especially without links to anything in the documentation explaining the syntax.

RainbowEncoder!  Ding ding ding!  What you have works! Not only is the logic correct, it's also clearly outlining the output so it's clear which options have been selected which makes it easy to know if a mistake was made while clicking through the macro.  Thank you!  It's also written in a way that doesn't make me want to gouge my eyes out!  It's written like a normal function would be written with some helper variables defined at the top which get called later, and I appreciate that.  It's much easier to see what is going on, and if I need to make changes in the future it seems easy to adjust due to the formatting and style.  This is REALLY well written, man! I love the way you display critical in the results if it was a critical but don't waste space with it otherwise.  I also love the way you don't provide a total if there's a single number result, and if there are multiple number results an extra field appears to provide the sum.  This is art, not just functionality.  This is WILDLY superior to what I would have been able to get with an incomprehensible mess of syntax replacement with a template in line with the query as per my original request.  Even just in terms of readability and future maintenance. 

If this is how folks work that's fine.  I don't feel comfortable asking for strangers to build templates for me.  But, if that's how you (wonderful) people do things, I can outline the rules. 

  • The basic attack is 2d6+4 bludgeoning damage.  That is the core attack with no modifiers.
  • Rage adds +2 damage to the basic attack.
  • Rage also adds 1d6+2 radiant damage.
  • The magic weapon adds 2d6 fire damage.
  • Savage attacker takes weapon damage and rolls it twice and takes the higher result.  This will impact the basic attack, and it will impact the magic weapon's damage (if the magic weapon is also active at the same time that savage attacker is active).
  • A critical hit doubles all dice rolled.



These are the core eventualities broken out:

  • with rage, with savage attacker, with magic weapon
  •     [[{2d6,2d6}kh1+6]] bludgeoning, [[1d6+2]] radiant, [[{2d6,2d6}kh1]] fire
  • with rage, with savage attacker, without magic weapon
  •     [[{2d6,2d6}kh1+6]] bludgeoning, [[1d6+2]] radiant
  • with rage, without savage attacker, with magic weapon
  •     [[2d6+6]] bludgeoning, [[1d6+2 radiant, [[2d6]] fire
  • with rage, without savage attacker, without magic weapon
  •     [[2d6+6]] bludgeoning, [[1d6+2]] radiant
  • without rage, with savage attacker, with magic weapon
  •     [[{2d6,2d6}kh1+4]] bludgeoning, [[2d6]] fire
  • without rage, with savage attacker, without magic weapon
  •     [[{2d6,2d6}kh1+4]] bludgeoning
  • without rage, without savage attacker, with magic weapon
  •     [[2d6+4]] bludgeoning, [[2d6]] fire
  • without rage, without savage attacker, without magic weapon
  •     [[2d6+4]] bludgeoning


What RainbowEncoder created does 100% of the things I was hoping to have done, and has all of the correct logic.  I'm probably going to move forward with what he presented.  I'm INCREDIBLY appreciative of the time people took to respond and try to give an answer.  Thank you all! 

April 09 (4 months ago)


timmaugh said:


Thank you!  Will dive into this today!  It's a lot to go over.  I appreciate the time you took to write it.  I'll read it and do my best to learn from it! 

April 09 (4 months ago)

Edited April 09 (4 months ago)


Gauss said:


Tuo said:

And here's my refined version (still built off what Gauss wrote), I also realized that the radiant damage came from the rage, so I fixed that

&{template:default} {{name=Damage roll
}} [[[[{(?{Critical?|No,1|Yes,2}*2)d6,(?{Critical?}*?{Savage Attacker?|Off,0|On,2})d6}kh1+?{Rage|Off,0|On,1}+4]] +[[?{Rage|No,0|Yes,1}*(?{Critical?}d6+2)]] +[[{(?{Magic Weapon?|No,0|Yes,1}*?{Critical?}*2)d6,(?{Magic Weapon?}*?{Critical?}*?{Savage Attacker?})d6}kh1}]]]] {{Total=$[[3]]
}} {{$[[0]]=Bludgeoning [ ](#" hidden null=)
}} {{[0](#" hidden)=
}} {{[[[?{Magic Weapon?}*4]]](#" hidden)=Magic weapon active!
$[[2]] Fire damage
}} {{[[[?{Rage}*2]]](#" hidden)=Raging!
$[[1]] Radiant damage
}} {{[[[?{Critical?}-1]]](#" hidden)=Critical!
}} {{[[[?{Savage Attacker?}*1.5]]](#" hidden)=Attacking savagely!
}} {{[0](#" hidden)=
}}


Tuo, the first instance of Rage query needs to be modified to accomodate the second instance of Rage. Instead of ?{Rage|Off,0|On,2} it should be ?{Rage|Off,0|On,1}*2

Also, I suspect that the second instance of Rage also needs to be applied to the entirety of 1d6+2, but I am still waiting for confirmation from Sihr.

Oops, you're right, I missed that part - it's exactly as you say, the first instance should be ?{Rage|Off,0|On,1}*2.

&{template:default} {{name=Damage roll
}} [[[[{(?{Critical?|No,1|Yes,2}*2)d6,(?{Critical?}*?{Savage Attacker?|Off,0|On,1}*2)d6}kh1+?{Rage|Off,0|On,1}+4]] +[[?{Rage}*(?{Critical?}d6+2)]] +[[{(?{Magic Weapon?|No,0|Yes,1}*?{Critical?}*2)d6,(?{Magic Weapon?}*?{Critical?}*?{Savage Attacker?})d6}kh1}]]]] {{Total=$[[3]]
}} {{$[[0]]=Bludgeoning [ ](#" hidden null=)
}} {{[0](#" hidden)=
}} {{[[[?{Magic Weapon?}*4]]](#" hidden)=Magic weapon active!
$[[2]] Fire damage
}} {{[[[?{Rage}]]](#" hidden)=Raging!
$[[1]] Radiant damage
}} {{[[[?{Critical?}-1]]](#" hidden)=Critical!
}} {{[[[?{Savage Attacker?}*1.5]]](#" hidden)=Attacking savagely!
}} {{[0](#" hidden)=
}}

I wanted to simplify it, but forgot to check what else it affected. Elsewise, it should be fine. Shows the options selected on, and if they add new damage types, it shows those damage types. All options not selected on are hidden.

EDIT: aaand then I needed to put the *2 on the third instance too, so that Rage wouldn't be hidden by critical. Ah well, now it should be right. 

April 15 (4 months ago)

Just following up.  I think the responses from everyone were fantastic!  I ended up using two separate macros.  One for the attack roll.  One for the damage roll.  Each has dropdowns for modifiers. 

I don't know if these are the best possible solutions, but they are what I'm going to use and I'm happy with them.

This handles regular attacks, advantage attacks, and disadvantage attacks.  It will reroll a result of 1 for halfling, and it will recognize a critical hit.  It will also provide a minor note to make it clear which option was selected which will make it easier to identify any misclicks.

With a couple of minor modifications which would work as an attack roll for any 5E character that needed one.

&{template:default} {{ Bingo Attack = 
  ?{Attack Type|
    Regular, Regular [[ 1d20rocs>20 + 4 [STR] + 2 [PROF] ]] |
    Advantage, Advantage [[ 2d20rocs>20kh1 + 4 [STR] + 2 [PROF] ]] |
    Disadvantage, Disadvantage [[ 2d20rocs>20kl1 + 4 [STR] + 2 [PROF] ]] } 
  }} {{ Attack roll= ?{Attack Type}
  }} {{ Bingo Attack = Joyous Occasion }}


This is absurdly/wonderfully complex.  This is RainbowEncoder's solution.  I couldn't do this if I had to.  It does everything I asked for and even stuff I didn't ask for and everything was accurate and each extra thing made it a little better.  This is too specific to my character to do other people a ton of good besides showing what can be done.

It will visually identify when a critical hit was rolled for some visual flair.  It will also note if an attack is adding in modifiers for rage, savage attacker, and for the magic weapon the character has.  Lastly, in addition to listing each type of damage individually, it will also provide a total and sum up each of the damage types (unless only one damage type is done, in which case it doesn't duplicate that information with a sum).

&{template:default} {{name=

?{Crit|
No,1|
Yes,2{}

?{Rage|
With,2{|
Without,0}

?{Savage Attacker|
With,1[{|
Without,0[} ]

?{Magic|
With,1{|
Without,0}

Go Faster Stripe [[0]][[0]]
[[ [[ {[[2*?{Crit}]]d6,[[2* ?{Savage Attacker} ] *?{Crit}]]d6}k1 + 4[str] +[[?{Rage}]][rage] ]] [Bludgeoning
] +[[ [[ [[?{Crit}]]d6 + 2 ]]/2*?{Rage} ]] [Rad/Nec
] +[[ [[ {[[2*?{Crit}]]d6,[[2* ?{Savage Attacker} ]*?{Crit}]]d6}k1 ]]*?{Magic}]] [Fire] ]]

}} {{name=Attack Results}}?{Crit}{Critical!}} {{Rage=Inactive
}} {{Savage Attacker=Inactive
}} {{Magic=Inactive
}} {{Bludgeoning=$[[7]]
}} ?{Rage}{Rage=**Active**}} ?{Rage}{Radiant/Necrotic=$[[8]]}} ?{Magic}{Magic=**Active**}} ?{Magic}{Fire=$[[10]]}} ?{Savage Attacker}{Savage Attacker=**Active**}} ?{Rage}{Total=$[[13]]}} ?{Magic}{Total=$[[13]]}}


Can't thank everyone enough for their insight, their input, and their time!