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

[API request] 5th edition d&d the mob attack table.

So in the 5th edition dmg for d&d is a small.table called mob attack this is what it is roughly. The principle is that it speeds up gameplay for lots of mobs by forgoing rolling and just giving a rough estimate of how many hit. The formula for it is attackers attack bonus minus targets current ac. The final ac number is compared to the table and it tells you how many attacks it takes to hit a target. I wanted to automate this a little better. ac to hit  How many hit 1 - 5 1 6 - 12 2 13-14 3 15 - 16 4 17-18 5 19 10 20 20 Basically what im asking for is a script ( or clever macro )which simply sums up the value of attributes I give it, and compare it to the table above. For example ! Mob-Attack [[@{selected|strength_mod}+@{selected|pb}-@{target|ac}]]   
1476277292

Edited 1591389497
The Aaron
Pro
API Scripter
Here ya go!  !mob-attack [[@{selected|strength_mod}+@{selected|pb}-@{target|ac}]]  on('ready',function(){     "use strict";     var mobLookup=function(num){         switch(parseInt(num,10)){             case 1:             case 2:             case 3:             case 4:             case 5:                 return 1;             case 6:             case 7:             case 8:             case 9:             case 10:             case 11:             case 12:                 return 2;             case 13:             case 14:                 return 3;             case 15:             case 16:                 return 4;             case 17:             case 18:                 return 5;             case 19:                 return 10;             case 20:                 return 20;             default:                 return 0;         }     };     on('chat:message',function(msg){         var args,cmds,who,number;         if('api' === msg.type && msg.content.match(/^!mob-attack\b/) && playerIsGM(msg.playerid) ){             if(_.has(msg,'inlinerolls')){                 msg.content = _.chain(msg.inlinerolls)                     .reduce(function(m,v,k){                         var ti=_.reduce(v.results.rolls,function(m2,v2){                             if(_.has(v2,'table')){                                 m2.push(_.reduce(v2.results,function(m3,v3){                                     m3.push(v3.tableItem.name);                                     return m3;                                 },[]).join(', '));                             }                             return m2;                         },[]).join(', ');                         m['$[['+k+']]']= (ti.length && ti) || v.results.total || 0;                         return m;                     },{})                     .reduce(function(m,v,k){                         return m.replace(k,v);                     },msg.content)                     .value();             }             args = msg.content.split(/\s+/);             args.shift();             number=args.shift();             who=getObj('player',msg.playerid).get('_displayname');             sendChat('Mob-Attack',`/w "${who}" <div style="padding:1px 3px;border: 1px solid #8B4513;background: #eeffee; color: #8B4513; font-size: 80%;"><div style="background-color: #ffeeee;">Every ${mobLookup(number)} enemies is a hit.</div></div>`);         }     }); }); Here's an updated Macro from   NeilGiraffeTyson : !mob-attack [[@{target|Defender|ac}-[[[[{@{target|Attackers|dexterity_mod},@{target|Attackers|strength_mod}}KH1]]+ @{target|Attackers|pb}]]]] It fixes cases where negative numbers would come up in the prior macro.
The Aaron said: Here ya go!  !mob-attack [[@{selected|strength_mod}+@{selected|pb}-@{target|ac}]]  on('ready',function(){     "use strict";     var mobLookup=function(num){         $d(num);         switch(parseInt(num,10)){             case 1:             case 2:             case 3:             case 4:             case 5:                 return 1;             case 6:             case 7:             case 8:             case 9:             case 10:             case 11:             case 12:                 return 2;             case 13:             case 14:                 return 3;             case 15:             case 16:                 return 4;             case 17:             case 18:                 return 5;             case 19:                 return 10;             case 20:                 return 20;             default:                 return 0;         }     };     on('chat:message',function(msg){         var args,cmds,who,number;         if('api' === msg.type && msg.content.match(/^!mob-attack\b/) && playerIsGM(msg.playerid) ){             if(_.has(msg,'inlinerolls')){                 msg.content = _.chain(msg.inlinerolls)                     .reduce(function(m,v,k){                         var ti=_.reduce(v.results.rolls,function(m2,v2){                             if(_.has(v2,'table')){                                 m2.push(_.reduce(v2.results,function(m3,v3){                                     m3.push(v3.tableItem.name);                                     return m3;                                 },[]).join(', '));                             }                             return m2;                         },[]).join(', ');                         m['$[['+k+']]']= (ti.length && ti) || v.results.total || 0;                         return m;                     },{})                     .reduce(function(m,v,k){                         return m.replace(k,v);                     },msg.content)                     .value();             }             args = msg.content.split(/\s+/);             args.shift();             number=args.shift();             who=getObj('player',msg.playerid).get('_displayname');             sendChat('Mob-Attack',`/w "${who}" <div style="padding:1px 3px;border: 1px solid #8B4513;background: #eeffee; color: #8B4513; font-size: 80%;"><div style="background-color: #ffeeee;">Every ${mobLookup(number)} enemies is a hit.</div></div>`);         }     }); }); He isnt the hero we deserve.. But the hero we need... A silent coder... Our sexy  bearded scriptomancer...
1476281338
The Aaron
Pro
API Scripter
BWHAHAHAHAHAH!!!
ReferenceError: $d is not defined ReferenceError: $d is not defined at mobLookup (apiscript.js:18465:9) at apiscript.js:18529:204 at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:143:34), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:143:34), <anonymous>:70:8) at /home/node/d20-api-server/api.js:1393:12 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489) at Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425) at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:111:400 I'm getting this error for some reason :( Not sure why. Even if I use regular numbers instead of substituting numbers. It just prints this error.
1476295192
The Aaron
Pro
API Scripter
Whoops... sorry.. left some debugging code in there.. Grab the copy from top again (or take out the line that says $d(num);)