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 introduce a critical success/failure thershold in rolls

Hello Community ! I’m struggling with a problem with the roll template of a custom character sheet I’m currently tweaking. As per now, the rolls work like this : Roll 1d100, apply modifiers from the sheet (like bonuses), apply modifier input, then if it’s under the character attribute it’s a success, and a failure if it’s over. What I would like to achieve, is to introduce more ways to display the result (changing color for example), according to the difference between the roll and the target number. For example, if the traget number is 50 (=50% success rate) any roll of 30 or less would be a special success, and any score above 70 would be a special failure. I think this is more or less the way CoC v7 works. I guess this can be achieved by introducing a kind of threshold in the rolltemplate, that will « trigger » special ways to display the result in the CSS, but I don't know how to code it neither if it has to be in the roll button code or the sheet rolltemplate. I would be grateful if someone could held me with this.   Here’s the way the combat   roll button is coded in the character sheet :   <button type="roll" class="atk" name="Attaque" title="Jet d'attaque" value="&{template:tmpl} {{pc=@{character_name}}} {{name=@{melee_nom} (COM)}} {{roll=[[1d100cs1cf100]]}} {{target=[[@{COM}+(@{melee_mod})[Mod.]+(?{Bonus(+)/Malus(-)|0})[Bonus/Malus]]]}} {{dmg=[[@{BF}[BF]+(@{melee_deg})[Arme]]]}} {{dmgmin=[[1]]}}"></button></div>   Heres’s the rolltemplate at the end of the sheet :   <rolltemplate class="sheet-rolltemplate-tmpl">     <div class="tplmain">         <div class="pc">{{name}}</div>         <div style="display: table;">             {{#target}}                 <div style="display: table-row;">                     <div class="jet"><span style="font-family: dicefontd10;font-size: x-large;">t</span> {{roll}} ≤ {{target}} <span style="font-size: larger;">◎</span></div>                     <div class="jet">                         {{#rollGreater() roll target}}                             <span class="failure">Échec</span>                         {{/rollGreater() roll target}}                         {{#rollTotal() roll target}}                            <span class="success">Réussite</span>                         {{/rollTotal() roll target}}                          {{#rollLess() roll target}}                             <span class="success">Réussite</span>                         {{/rollLess() roll target}}                     </div>                 </div>             {{/target}}             {{#dmg}}                 {{#^rollGreater() roll target}}                     <div style="display: table-row;">                         <div class="jet bordtop"><span>Dégâts de l'Arme</span></div>                         <div class="jet bordtop">                                 {{dmg}}                         </div>                     </div>                 {{/^rollGreater() roll target}}             {{/dmg}}         </div>         {{#desc}}             <div class="desc bordtop">{{desc}}</div>         {{/desc}}         <div class="jetnom">{{pc}}</div>     </div> </rolltemplate> Normal 0 21 false false false FR X-NONE X-NONE /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Tableau Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:8.0pt; mso-para-margin-left:0cm; line-height:107%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri",sans-serif; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;}
I will ask again for help. To put it in more simple words, I’m using a d100 roll-under system and I would like my character sheet to work this way  (the target score being the score to roll under depending on the character skill / attribute etc...) roll result < target score – 50 : critical success target score -50 < roll result < target score -30 : nice success target score -30 < roll result ≤ target score : success target score < roll result < target score +30 : fail target score +30 < roll result < target score +50 : hard fail roll result ≥ target score +50 : critical fail. Now here’s the way I tried to build the character sheet in roll20 : (COM below is the skill used for the roll) <div class="thead"><button type="roll" class="bcar" name="COM" title="combat" value="&{template:tmpl} {{pc=@{character_name}}} {{name=Combat (COM)}} {{roll=[[1d100]]}} {{target=[[@{COM}+(?{Bonus(+)/Malus(-)|0})[Bonus/Malus]]]}} {{E50=[[@{COM}+(50)+(?{Bonus(+)/Malus(-)|0})[Bonus/Malus]]]}} {{E30=[[@{COM}+(30)+(?{Bonus(+)/Malus(-)|0})[Bonus/Malus]]]}} {{R30=[[@{COM}-(30)+(?{Bonus(+)/Malus(-)|0})[Bonus/Malus]]]}} {{R50=[[@{COM}-(50)+(?{Bonus(+)/Malus(-)|0})[Bonus/Malus]]]}}">COM</button></div> And here’s the rolltemplate : <rolltemplate class="sheet-rolltemplate-tmpl"> <div class="tplmain"> <div class="pc">{{name}}</div> <div style="display: table;"> {{#target}} <div style="display: table-row;"> <div class="jet"><span style="font-family: dicefontd10;font-size: x-large;">t</span> {{roll}} ≤ {{target}} <span style="font-size: larger;">◎</span></div> <div class="jet"> {{#rollGreater() roll E50}} <span class="failure">Échec 50+</span> {{#rollBetween() roll E30 roll E50}} <span class="failure">Échec 30+</span> {{#rollBetween() roll target roll E30}} <span class="failure">Échec</span> {{#rollBetween() roll R30 roll target}} <span class="failure">Réussite</span> {{#rollBetween() roll R50 roll R30}} <span class="failure">Réussite 30+</span> {{#rollLess() roll R50}} <span class="failure">Réussite 50+</span> </div> </div> {{/target}} {{#dmg}} {{#^rollGreater() roll target}} <div style="display: table-row;"> <div class="jet bordtop"><span>Dégâts de l'Arme</span></div> <div class="jet bordtop"> {{dmg}} </div> </div> {{/^rollGreater() roll target}} {{/dmg}} </div> {{#desc}} <div class="desc bordtop">{{desc}}</div> {{/desc}} <div class="jetnom">{{pc}}</div> </div> </rolltemplate> It doesn’t work at all, the chat doesn’t display anything. Could someone help or give any hint please ?
1636992869
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
There's a few different ways to handle this. Unfortunately, they each have their own complications as we can't just use the crit/fumble detection of the roll parser itself. Custom Roll parsing (CRP) CRP is a powerful new feature of character sheets. It allows us to manipulate the results of the rolls via javascript after they've been parsed by the roller to achieve various things. Downside here is that it won't work with custom abilities/macros that users may make. Roll Template helper functions This method doesn't require any javascript, but may wind up requiring lots of html to handle the system. The upside is that it would work with custom macros. I think for your usecase, the roll template method is probably actually better and is what you're going with in your code, assuming that E30,E50,R30,and R50 are fields that contain an inline roll with the target +/- 30/50. I see two problems. 1) Your rollBetween() syntax is incorrect. the rollBetween() helper function requires 3 arguments in order; the field to check (roll), the minimum (E/R30/50), and the maximum (E/R30/50). And 2)  you haven't completed the helper functions. The content that is going to be displayed by a helper function must be wrapped in two declarations of the helper function as described in the wiki . So, fixing both of these issues would look like so: <rolltemplate class="sheet-rolltemplate-tmpl"> <div class="tplmain"> <div class="pc">{{name}}</div> <div style="display: table;"> {{#target}} <div style="display: table-row;"> <div class="jet"><span style="font-family: dicefontd10;font-size: x-large;">t</span> {{roll}} ≤ {{target}} <span style="font-size: larger;">◎</span></div> <div class="jet"> {{#rollGreater() roll E50}} <span class="failure">Échec 50+</span> {{/rollGreater() roll E50}} {{#rollBetween() roll E30 E50}} <span class="failure">Échec 30+</span> {{/rollBetween() roll E30 E50}} {{#rollBetween() roll target E30}} <span class="failure">Échec</span> {{/rollBetween() roll target E30}} {{#rollBetween() roll R30 target}} <span class="failure">Réussite</span> {{/rollBetween() roll R30 target}} {{#rollBetween() roll R50 R30}} <span class="failure">Réussite 30+</span> {{/rollBetween() roll R50 R30}} {{#rollLess() roll R50}} <span class="failure">Réussite 50+</span> {{/rollLess() roll R50}} </div> </div> {{/target}} {{#dmg}} {{#^rollGreater() roll target}} <div style="display: table-row;"> <div class="jet bordtop"><span>Dégâts de l'Arme</span></div> <div class="jet bordtop"> {{dmg}} </div> </div> {{/^rollGreater() roll target}} {{/dmg}} </div> {{#desc}} <div class="desc bordtop">{{desc}}</div> {{/desc}} <div class="jetnom">{{pc}}</div> </div> </rolltemplate>
Oh thank you so much Scott C, I would never have this work properly without your help !