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

Reroll If Attribute Average < 12

December 19 (5 years ago)

Folks,

Is there a way to accomplish the following:

Roll six sets of 3d6, sum the results, reroll if the average of the 6 rolls < 12 (sum of all < 72).

# Doesn;t work, but I am trying to reroll is sum < 72

{3d6,3d6,3d6,3d6,3d6,3d6}r<72


Thanks,

Chrissy

December 19 (5 years ago)
Mike deBoston
Compendium Curator

I don't know of a way to automate that, but you could make a macro something like this:

6-rolls-under-72

Your attributes are [[ [[3d6]] + [[3d6]] + [[3d6]] + [[3d6]] + [[3d6]] + [[3d6]] ]]. [Reroll](!&13;#6-rolls-under-72 )


You'd have to hover the total to see the individual rolls. Maybe someone else has a more complete solution.

December 19 (5 years ago)

Edited December 19 (5 years ago)
GiGs
Pro
Sheet Author
API Scripter

There's no way to do this without using the API. 

Since you're a pro user, I tweaked an old script I posted a while back for a similar question. If you want to use it, it will give output like this

or this

It will roll your six stats, show the outcome, and if the average is below 12, will give you a button to click to reroll them. (Rather than doing it automatically - i find this is more fun for players.)


To use it, set up a universal macro, call it roll-6-stats (you can change this name, but you'd need to edit the script below).

Put your desired stat layout in the macro, as if using the default rolltemplate. The two layouts above were created with this:

!sumstatrolls --{{name= Stat Rolls 4d6k3}} {{Rolls=**[[4d6k3]] [[4d6k3]] [[4d6k3]] [[4d6k3]] [[4d6k3]] [[4d6k3]]**}}

and

!sumstatrolls --{{name= Stat Rolls 4d6k3}} {{Strength= [[4d6k3]]}} {{Dexterity= [[4d6k3]]}} {{Constitution= [[4d6k3]]}} {{Intelligence= [[4d6k3]]}} {{Wisdom= [[4d6k3]]}} {{Charisma= [[4d6k3]]}}

Basically its just a default rolltemplate, but the &{template:default} at the start is replaced by !sumstatrolls --

Then in your campaigns API scripts section, paste the sumstatsroll script, from below:

/*
    Roll a bunch of stats and total them. Use syntax like this:
    !sumstatrolls --{{name= Stat Rolls 4d6k3}} {{Strength= [[4d6k3]]}} {{Dexterity= [[4d6k3]]}} {{Constitution= [[4d6k3]]}} {{Intelligence= [[4d6k3]]}} {{Wisdom= [[4d6k3]]}} {{Charisma= [[4d6k3]]}}
    or
    !sumstatrolls --{{name= Stat Rolls 4d6k3}} {{Rolls=**[[4d6k3]] [[4d6k3]] [[4d6k3]] [[4d6k3]] [[4d6k3]] [[4d6k3]]**}}
    
*/
on("ready", () => { 
    const template = '&{template:default}',
    sumheader = 'Average Score',
    macroname = 'roll-6-stats',
    processInlinerolls = function (msg) {
        if (_.has(msg, 'inlinerolls')) {
            return _.chain(msg.inlinerolls)
                .reduce(function(previous, current, index) {
                    previous['$[[' + index + ']]'] = current.results.total || 0;
                    return previous;
                },{})
                .reduce(function(previous, current, index) {
                    return previous.replace(index, current);
                }, msg.content)
                .value();
        } else {
            return msg.content;
        }
    },
    totalInlinerolls = function(msg) {
        let total = 0;
        if (_.has(msg, 'inlinerolls')) {
            total = msg.inlinerolls.reduce((total,current) => total + current.results.total ||0,0);
        };
        return total > 0 ? Math.floor((total / msg.inlinerolls.length)*10)/10 : total;
    };
    
    on("chat:message", msg_orig => {
        if(msg_orig.type == "api" && (msgMatch = msg_orig.content.match('!sumstatrolls --'))){
            const msg = processInlinerolls(msg_orig);
            const sum = totalInlinerolls(msg_orig); 
            let output = msg.split('--')[1].trim();
            output = `${template} ${output} {{${sumheader}=${sum >= 12 ? sum : `[${sum}: Reroll](!&13;#${macroname})`}}}`;
            sendChat("", output);
        }
    });
});

Once the script is installed, you can use your macro and have fun!

Hope this helps!

December 19 (5 years ago)

Very cool thx