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

[Scriptlet] 5e OGL NPC Action Damage Autoroller

1508890440

Edited 1508891756
So using the 5e OGL sheet there are often actions (including legendary actions) such as a Dragon's breath weapon that don't output an actual damage roll when the action is rolled: With this scriptlet, it will listen for such cases and autoroll the damage for you: Code: on('chat:message', function(msg) { // ROLL LISTENER if(msg.playerid.toLowerCase() != "api" && msg.rolltemplate) { if (msg.rolltemplate === "npcaction"){ let desc = ((msg.content.split("{{description=")[1]||'').split("}}")[0]||''); if (desc.match(/\(\d+(d)\d+.*\)/g)) { let output =[]; let roll = desc.match(/\(\d+(d)\d+.*\)/g); let type = desc.match(/\)\s\w+/g); for (let n = 0; n < roll.length; n++) { output[n] = {die: roll[n].replace(/\(/g, "[[").replace(/\)/g, "]]"), type: type[n].replace(") ", "")}; } for (let x of output) { sendChat(msg.who, "&{template:npcdmg} {{damage=1}} {{dmg1=" + x.die + "}} {{dmg1flag=1}} {{dmg1type=" + x.type + "}}"); } } } } });
Very cool, I usually just go through and put [[]] around the damage rolls in the description.
Kyle G. said: Very cool, I usually just go through and put [[]] around the damage rolls in the description. haha, yeah that is what I have been doing as well, but figured there had to be a better way.