Character Vault
Any Concept / Any System
Compendium
Your System Come To Life
Roll20 for Android
Streamlined for your Tablet
Roll20 for iPad
Streamlined for your Tablet

Personal tools

Script:Exalted Successes

From Roll20 Wiki

Revision as of 01:36, 31 August 2013 by Brian (Talk | contribs)

Jump to: navigation, search

After posting a message with a roll (either regular or inline) which uses d10s, the script will echo the number of successes (or botches) using the dice system in Exalted. This script does not take into account Sidereal Astrology modifying the target number, nor does it try to filter players posting a roll with modifiers and the like. This script does not scrutinize based on normal die rolls (10s count double) vs. damage rolls (10s don't count double).

If this script is in the campaign, every roll which uses d10s will be reported.

Code

var exalted = exalted || {};
 
exalted.sendChat = function(name, id, msg)
{
    var characters = findObjs({_type: 'character'});
    var speaking;
    characters.forEach(function(chr) { if(chr.get('name') == name) speaking = chr; });
    if(speaking) sendChat('character|'+speaking.id, msg);
    else sendChat('player|'+id, msg);
};
 
on('chat:message', function(msg) {
    var json;
    var inline = false;
    try { json = JSON.parse(msg.content); }
    catch(e)
    {
        if(msg.inlinerolls) inline = true;
        else return;
    }
    
    var results = [];
    if(!inline)
    {
        json.rolls.forEach(function(j) {
            if(j.sides != 10) return;
            results.push(j.results);
        });
    }
    else
    {
        json = msg.inlinerolls;
        json.forEach(function(j) {
            var rolls = j.results.rolls;
            rolls.forEach(function(r) {
                if(r.sides != 10) return;
                results.push(r.results);
            });
        });
    }
    
    var successes = 0;
    var botches = 0;
    results.forEach(function(r) {
        r.forEach(function(d) {
            var die = d['v'];
            successes += die >= 7 ? 1 : 0
            successes += die == 10 ? 1 : 0;
            botches += die == 1 ? 1 : 0;
        });
    });
    
    if(successes == 0 && botches != 0)
    {
        exalted.sendChat(msg.who, msg.playerid, botches+' botch'+(botches>1?'es':''));
    }
    else if(successes == 0)
    {
        exalted.sendChat(msg.who, msg.playerid, 'Failure');
    }
    else
    {
        exalted.sendChat(msg.who, msg.playerid, successes+' success'+(successes>1?'es':''));
    }
});

Notes

You can achieve similar results with rollable tables, without resorting to the scripts that require mentor-level accounts.

Name Weight
0 b 1
0 5
1 3
2 1

Assuming the table is named exalted, you can then roll on it with something like /roll 8t[exalted]. This solution won't accurately report botches, but you can check the roll itself after the fact if no successes were garnered.

For bonus points, you can make alternate tables for damage (1 weighted 4 and no 2) and for Sidereal shenaniganry. It also doesn't require any scripting to achieve.