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

To hit roll table

Hi I want to make a tight roll table to compare two numbers and give a number that you need to roll above is this possible 
1485190343
The Aaron
Pro
API Scripter
Can you give a little more specific data about what you need?   You can't compare two numbers, but if you have a finite and sufficiently small problem space, you could build a table with the same probabilities and information.
Want to compare weapon skill stats which then give a dice throw required to hit. Currently have a chart with details on
1485196613
The Aaron
Pro
API Scripter
Ok, so you're looking for a way to take an attribute and use it to find the right dice to roll.  Is the lookup chart something you can share?
As example if your weapon skill was 3 and target weapon skill was 5 you look up and need a 4 or more to hit 
1485205617
The Aaron
Pro
API Scripter
Hmm... it's not a very regular table.  Silvyre might be able to come up with formulas to recreate it, but I'm stumped.  I think API is the only easy way.
1485206514

Edited 1485206734
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I can see a non-API way, but it'll require A LOT of   tables. The idea would be to take advantage of the fact that roll queries (or attribute calls) resolve before inline rolls, including rollable table rolls. So, with roll queries it would look like this: [[1d20>1t[?{Attacker's Skill}v?{Defender's Skill] ]] With attribute calls it would look like: [[1d20>1t[@{target|Attacker|SkillName}v@{target|Defender|SkillName}] ]] Each table would only have a single table entry in it, the numerical value of that intersection of the table without any spaces or other characters (or at least other characters would have to be after the numerical result). This is because rollable table entries that start with a number resolve to that number when evaluated in a roll regardless of what other characters might be in the returned table entry. And if you have a different table for each skill (requires different target numbers for any combination), you would need to make multiple sets of tables like "Weapon1v1" through "Weapon10v10" and "Magic1v1" through "Magic10v10" (no idea what the setting for the game is, but you get the idea). Note this is 100 tables per skill(assuming they all have a different set of target numbers and that I did my math right).
1485206928
The Aaron
Pro
API Scripter
Can you build table names with attributes?
1485207118

Edited 1485207207
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Yep, at least I've done it with roll queries which resolve after attributes, so I would assume.
How would I do it in api
1485215152
The Aaron
Pro
API Scripter
It would kind of depend what you intended to then do with it.  Here's a simple example that just does the lookup: on('ready',function(){     "use strict";     var lookup = [         [4,4,5,6,6,6,6,6,6,6],         [3,4,4,4,5,5,6,6,6,6],         [2,3,4,4,4,4,5,5,5,6],         [2,3,3,4,4,4,4,5,5,5],         [2,3,3,3,4,4,4,4,4,4],         [2,3,3,3,3,4,4,4,4,4],         [2,3,3,3,3,3,4,4,4,4],         [2,2,3,3,3,3,3,4,4,4],         [2,2,2,3,3,3,3,3,4,4],         [2,2,2,2,3,3,3,3,3,4]     ] ;     on('chat:message',function(msg){         var args,cmds;         if('api' === msg.type && msg.content.match(/^!lookup\b/) && playerIsGM(msg.playerid) ){             args=msg.content.split(/\s+/);             if(args.length<3){                 sendChat('','Lookup requires 2 parameters<br><code>!lookup @{attacker skill} @{defender skill}');             } else {                 let attackerSkill = Math.min(10,Math.max(1,parseInt(args[1],10)||0)),                     defenderSkill = Math.min(10,Math.max(1,parseInt(args[2],10)||0)),                     minToSucceed = lookup[defenderSkill-1][attackerSkill-1];                 sendChat('',`Attacker: <b>${attackerSkill}</b><br>Defender: <b>${defenderSkill}</b><br>Minimum to hit: <b>${minToSucceed}</b>`);             }         }     }); });
1485220423

Edited 1485245123
Silvyre
Forum Champion
Here's a non-API macro: <a href="https://gist.github.com/Silvyre/fa1f460833321c28f94d0f940c652f91" rel="nofollow">https://gist.github.com/Silvyre/fa1f460833321c28f94d0f940c652f91</a> [[ [[2 + {3 - ?{Weapon Skill|1|2|3|4|5|6|7|8|9|10}, 0}kh1]] + {[[2 + [[{-1, 1}=?{Weapon Skill}]] + {?{Weapon Skill} - 7, 0}kh1]], [[3 + [[{1, 2, 2}=?{Weapon Skill}]] + {?{Weapon Skill} - 3, 0}kh1]], [[11 - 2 * {2, 2, 3, 3, 4}=?{Weapon Skill}]], [[11 - {-1, 3}=?{Weapon Skill}]]}&lt;?{Defender's Weapon Skill|1|2|3|4|5|6|7|8|9|10} ]] To acquire the above, I first wrote out a macro for each row of the table (as a function of Defender's Weapon Skill): Row 1:&nbsp; [[ 4 + {3, 4}&lt;?{D} ]] Row 2:&nbsp; [[ 3 + {2, 5, 7}&lt;?{D} ]] Row 3:&nbsp; [[ 2 + {2, 3, 7, 10}&lt;?{D} ]] Row 4:&nbsp; [[ 2 + {2, 4, 9}&lt;?{D} ]] Row 5:&nbsp; [[ 2 + {2, 5}&lt;?{D} ]] Row 6:&nbsp; [[ 2 + {2, 6}&lt;?{D} ]] Row 7:&nbsp; [[ 2 + {2, 7}&lt;?{D} ]] Row 8:&nbsp; [[ 2 + {3, 8}&lt;?{D} ]] Row 9:&nbsp; [[ 2 + {4, 9}&lt;?{D} ]] Row 10: [[ 2 + {5, 10}&lt;?{D} ]] Then, I filled out the macros to form 5 'columns' of numbers: Row 1:&nbsp; [[ 4 + {3,&nbsp; 4,&nbsp; 11,&nbsp; 11}&lt;?{D} ]] Row 2:&nbsp; [[ 3 + {2,&nbsp; 5,&nbsp; 7,&nbsp;&nbsp; 11}&lt;?{D} ]] Row 3:&nbsp; [[ 2 + {2,&nbsp; 3,&nbsp; 7,&nbsp;&nbsp; 10}&lt;?{D} ]] Row 4:&nbsp; [[ 2 + {2,&nbsp; 4,&nbsp; 9,&nbsp;&nbsp; 11}&lt;?{D} ]] Row 5:&nbsp; [[ 2 + {2,&nbsp; 5,&nbsp; 11,&nbsp; 11}&lt;?{D} ]] Row 6:&nbsp; [[ 2 + {2,&nbsp; 6,&nbsp; 11,&nbsp; 11}&lt;?{D} ]] Row 7:&nbsp; [[ 2 + {2,&nbsp; 7,&nbsp; 11,&nbsp; 11}&lt;?{D} ]] Row 8:&nbsp; [[ 2 + {3,&nbsp; 8,&nbsp; 11,&nbsp; 11}&lt;?{D} ]] Row 9:&nbsp; [[ 2 + {4,&nbsp; 9,&nbsp; 11,&nbsp; 11}&lt;?{D} ]] Row 10: [[ 2 + {5,&nbsp; 10, 11,&nbsp; 11}&lt;?{D} ]] Then, I rewrote each of these 'columns' as a function of Weapon Skill, allowing me to amalgamate them into the final macro: [[ [[2 + {3 - ?{W}, 0}kh1]]&nbsp; + &nbsp;{[[2 + [[{-1, 1}=?{W}]] + {?{W} - 7, 0}kh1]],&nbsp; &nbsp; [[3 + [[{1, 2, 2}=?{W}]] + {?{W} - 3, 0}kh1]],&nbsp; &nbsp; [[11 - 2 * {2, 2, 3, 3, 4}=?{W}]],&nbsp;&nbsp; [[11 - {-1, 3}=?{W}]]}&lt;?{D} ]]
1485222529
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
damn Silvyre
1485223537
vÍnce
Pro
Sheet Author
Scott C. said: damn Silvyre You can say that again.
1485224141
The Aaron
Pro
API Scripter
He's ALWAYS doing that! &nbsp;=D
1485226041
Silvyre
Forum Champion
:D Hopefully the write-up proves helpful to aspiring macromancers!
1485245323
Andrew C
Marketplace Creator
For those in the cheap seats.... that looks like a warhammer Fantasy table