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

Help with conditional Macros

So I am still trying to figure out conditional macros.  I have been trying to find answer in in forums but I cant seem to find what I am looking for. TIA in advance if you can help with this.  Here is an example of what I am looking for. In DCC and in a class for OSE there is a mechanic called a "Deed Die" which is a D6. When you have a deed die you roll 1d20 for your regular and to start to roll a d6 for your deed die. On a 1-2 on the deed die you add +1 to both your "to Hit" roll and damage roll.  How would you add a conditional d6 (or an other die for that manner) to another "combo" to hit / damage roll? Then if there are specific numbers (or a range) rolled on the conditional  die (Say 1-2, 1-3, etc) then it will add a bonus to the to hit and damage dice and also display some sort of notation of that this happened, such as "Joe succeeds withs deed roll"? I would appreciate help with this specific macro need, but if you cared to explain the theory and the code perhaps that would help others create their own conditional macros when they stumble upon this post in the future. 
1682539913
timmaugh
Forum Champion
API Scripter
I find this much easier if scripts are available. If they are, I can give a quick example using a couple of existing metascripts (and with a better looking output). For a non-script environment, you're limited on the types of "conditional" checks you can do. If you can render the checks into a binary value mathematically, you can pull off conditional-based-math. That works for the math you want to do, but not displaying the text. There might be more clever solutions to this, but here's what I came up with: [[1d20 + ([[{[[abs({[[1d6-3]],0}kl1)]],1}kl1]]*1)]] I'll start from the inside out. At any point you should be able to roll what I call out and see the result. Roll Component Roll Individually (to check value) Like This [[1d6-3]] [[1d6-3]] This is just giving us a break point where a 1 or a 2 will arrive at a negative number, while anything else will remain positive. We're going to flatten this into using a keep low; that will give us a negative or a 0: Roll Component Roll Individually (to check value) Like This {[[1d6-3]],0}kl1 [[{[[1d6-3]],0}kl1]] Now we have values of -2, -1, or 0. Eventually we're going to do multiplication and we want to make something larger, so we'll take the absolute value of whatever we have now: Roll Component Roll Individually (to check value) Like This abs({[[1d6-3]],0}kl1) [[abs({[[1d6-3]],0}kl1)]] Now we have a 0, 1, or 2, where really the 1 and the 2 are the same result: we want to add 1. So if we do a "keep low", comparing whatever value we have now against 1, we should get a 0 for Deed rolls that do not give a +1 boost, and a 1 for rolls that should give the boost. Note that you have to enclose the current value as its own roll in order to continue to use it in a further keep high/low comparison: Roll Component Roll Individually (to check value) Like This {[[abs({[[1d6-3]],0}kl1)]],1}kl1 [[{[[abs({[[1d6-3]],0}kl1)]],1}kl1]] Now we have either a 0 (for all rolls of 3-6), or a 1 (for a 1 or a 2). That gives us our binary, which we can then multiply by our modifier value (a +1) to see if it applies: Roll Component Roll Individually (to check value) Like This ([[{[[abs({[[1d6-3]],0}kl1)]],1}kl1]]*1) [[([[{[[abs({[[1d6-3]],0}kl1)]],1}kl1]]*1)]] In your case, we didn't really have to do this step, because you're already at the 0 or 1 value for your outcome, and this renders... another 0 or 1 outcome. But I included this step so you could see where we would include a larger modifier, if we wanted. So if a deed roll of 1 or 2 should yield a +3 to your d20 roll, we would multiply by 3 instead of 1, above. At this point, all that is left is to add this to our existing roll, which is the example at the top of the message.
1682541083

Edited 1682542689
Gauss
Forum Champion
For a 1d6 with a specific range resulting in a certain bonus it should be as simple as a [[1d6<2]]*desired bonus.  Example: +(1d6<2)*2 will give you a +2 bonus if the d6 is a 1 or 2.  The problem you have is that you want this to apply to two separate rolls, the 1d20 and then the damage roll. That generally cannot be done without a Mod (API script) which requires the Campaign Owner (probably your GM) to have a Pro account. However, if you want to report the roll at a later time you can do that via reusing rolls and a template .  Other relevant information: Target successes and Grouping Rolls  (used for a comparison version of target successes) Example: (Note: you didn't report what kind of dice are used in damage so I used a d8) &{template:default} {{name=test}} {{Attack=[[1d20+[[({[[1d6]],7}<2)*2 ]]]] }} {{Deed roll=$[[0]]}} {{Damage=[[1d8]]+$[[1]]}} Here is what it looks like (note: I changed "D6 roll" to "Deed roll" after I did the test):   To break this down a bit:  * [[ ( { [[1d6]] ,7}<2 ) *2 ]] is the section I am addressing * [[1d6]] = the 1d6 roll. I have enclosed it in inline brackets so that it can be reported via the $[[0]] in the deed roll. * {[[1d6]],7}<2 = the check for success/failure. If the 1d6 is a 1 or 2 it is a success. The reason for the {X,7} is because of the inline brackets around the 1d6 prevents 1d6<2 from working. So I had to use Grouping Rolls instead of the simpler Target Number Success option. 7 is outside the range of the 1d6 so there is no chance it will trigger the <2 or any other target number you use.  * By enclosing the entire thing in inline brackets " [[ ( { [[1d6]] ,7}<2 ) *2 ]]" I am enabling it to be picked up by $[[1]] in the Damage section. 
1682541946

Edited 1682542712
timmaugh
Forum Champion
API Scripter
Leave it to me to get caught up in the long-winded explanation! Gauss reminds me that there is a much simpler way to render a 0/1 result out of your roll, and that's to start with a base roll of [[1d6<2]]. That would leave you a final roll more like: [[1d20 + [[1d6<2]]*1]] Again, leaving the modifier multiplication in there just to show where it would be. Since it's a *1 for this case, it really isn't necessary. EDIT: The original version (previous post) follows a method that you might need if your roll is not so nicely expressed by a neat roll equation as what Gauss noted. A lot of times when you want a conditional math operation this is the case, so my brain went to the place of "create it" rather than "you already have it." I'm leaving it just because it does illustrate some of the other considerations you might need to include if your roll is more elaborate.
1682542298
timmaugh
Forum Champion
API Scripter
Gauss' example with the roll template gets you about as close as you can without a script. The gap that a script can fill is specifically reusing rolls in multiple different locations (so the math would be finished for the Damage roll, instead of providing you 2 numbers that you have to add, yourself), and in showing text as a conditional result of a particular outcome. Here's a script example using a pair of metascripts (ZeroFrame and APILogic) . !&{template:default}{{name=Deed Die Proof of Concept}}{{Deed Die=[[1d6]]}}{{Deed Mod={&if $[[0]] < 3}Success! @{selected|token_name} earns a +1{&else}0 (no success){&end}}}{{To Hit=[\][\]1d20 {&if $[[0]] < 3}+1{&end}\]\]}}{{Damage= [\][\]1d20 {&if $[[0]] < 3}+1{&end}\]\]}}{&simple} Or, for readability, this works exactly the same*: !{{   (^)&^{template:default} ({)name=Deed Die Proof of Concept(}) ({) Deed Die=[[1d6]] (}) ({) Deed Mod=     {&if $[[0]] < 3}       Success! @{selected|token_name} earns a +1     { &else}       0 (no success)     {&end} (}) ({) To Hit=[\][\]1d20      {&if $[[0]] < 3}       +1     {&end}   \]\] (}) ({) Damage= [\][\]1d20      {&if $[[0]] < 3}       +1     {&end}   \]\] (}) }} * - the results are exactly the same with ZeroFrame v1.1.5, which is in process of getting pushed to the 1-click and will be available next week; on version 1.1.4 and before, there would be a few extra blank lines included, but the logic/numbers are all the same.
Thank you everyone! I am gonna need a little time to figure this out. Will update when I get a better handle on all of this! Thanks again community! 
Is there any way to add in "Succeeds with Deed Dice" to the output in chats w/o scripts?
1682550159
Gauss
Forum Champion
Dante Faustus said: Is there any way to add in "Succeeds with Deed Dice" to the output in chats w/o scripts? If you mean the template where I had "Deed roll" then the answer is...yes, but then you would need to add the Deed Roll modifier to your attack roll manually, like I have above with the damage roll. 
1682550802

Edited 1682612753
Gauss
Forum Champion
This is what that macro looks like:  &{template:default} {{name=test}} {{Deed Roll=[[1t[[[({[[1d6]],7}<2)*1]]Deed]]]}} {{Deed Roll result=$[[0]]}} {{Attack=[[1d20]]+$[[1]]}} {{Damage=[[1d8]]+$[[1]]}}  And here is the output:  Note: this is just an approximation, I used an existing binary Rollable Table I had for this purpose. Yours will not say "Damage!" In addition to the macro code above you will need to create a couples Rollable Tables named "0Deed" and "1Deed" (without quotes).  Note: if the modifier is not a "1" then you will need to change the table accordingly. Example: for a modifier of "2" you would need "0Deed" and "2Deed" instead.  Next, create a single item in each Rollable table. Name the 0Deed item something like "Deed failed!" or whatever you'd like. Name the 1Deed item "Succeeds with Deed Dice" or whatever you'd like.
&{template:default} {{name=test}} {{Deed Roll= [[1t [[ ( { [[1d6]],7} <2 )*1 ]] Deed ]] }} {{ Deed Roll result=$[[0]] }} {{ Attack=[[1d20]]+$[[1]] }} {{ Damage=[[1d8]]+$[[1]] }} Cette macro n'affiche aucun réusltat et j'ai pourtant créer les deux tables ???
1682612688

Edited 1682612930
Gauss
Forum Champion
Stephen 7r  said: &{template:default} {{name=test}} {{Deed Roll= [[1t [[ ( { [[1d6]],7} <2 )*1 ]] Deed ]] }} {{ Deed Roll result=$[[0]] }} {{ Attack=[[1d20]]+$[[1]] }} {{ Damage=[[1d8]]+$[[1]] }} This macro does not display any results and yet I have created the two tables??? You added some spaces which are probably causing issues. I suggest copying the macro I posted and trying again, or remove the spaces manually.  Also, could you edit and screenshot the tables you created?
&{template:default} {{name=test}} {{Deed Roll=[[1t[[[({[[1d6]],7}<2)*1]]Deed]]]}} {{Deed Roll result=$[[0]]}} {{Attack=[[1d20]]+$[[1]]}} {{Damage=[[1d8]]+$[[1]]}} OK c'est bon, les 3[ me surprenait
1682628501
Gauss
Forum Champion
Rollable tables use a format of: 1t[tablename] So if you want to have a rollable table roll via an inline roll it is: [[1t[tablename]]] Next, this:  [[1t[[[({[[1d6]],7}<2)*1]]Deed]]] has several levels of inline rolls. One for the 1d6, a second for the deed success calculation, and a third for the rollable table. The sub-inline rolls are for the reusing rolls elements (such as $[[0]] ) later in the template.