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

TORG Classic dice roller!

1598556811
Senjak
Pro
Sheet Author
I just wanted to give something back to this wonderful community, as I dived deep in and found the answer to my group's current desire -- A die roller for TORG Classic.  It has a weird scheme where you roll a D20 and if you're skilled in the area 10s and 20s explode.  If you're unskilled, then only the 10s explode, and keep exploding as necessary.  And then once you get done with that, you take your final die roll and compare it to a little chart at the bottom of your character sheet for an effect number which is added to your skill + your stat. Don't worry about it if you don't play TORG, I don't think anyone else uses that system :-) But if you do play TORG, and you have a PRO level account, I give you the TORG Classic Die Roller! There are two ways to call it: !torg [modifier] !torg-noskill [modifier] The modifier can be ignored if you don't need one. The code follows the sample outputs. Note that this is in very verbose mode because that's how I like to see die rolls. on("chat:message", function(msg) { // Exit if not an api command if (msg.type != "api") return; // Get the API Chat Command // Strip out args[0] and args[1] if no arg[1] then modifier is 0. var args = msg.content.split(' ') var command = args[0]; if (args[1] == null) { var modifier = 0; } else { var modifier = parseInt(args[1]); } // Determine how the script was called. if (command == "!torg") { var skilled = 1; } else if (command == "!torg-noskill") { var skilled = 0; } // Define some useful variables. var count = 0; var roll = 0; var total = 0; var explode = 1; var output = ""; var effect = 0; while (explode > 0) { roll = randomInteger(20); output = output + " " + roll; total = total + roll; if (roll === 10) { explode = 1; count = 1; } else if ((roll === 20) && (skilled == 1)) { explode = 1; count = 1; } else { explode = 0; } } total = total + modifier; // calculate the effect number if (total <= 1) { effect = -12; } else if (total == 2) { effect = -10; } else if (total <= 4) { effect = -8; } else if (total <= 6) { effect = -5; } else if (total <= 8) { effect = -2; } else if (total <= 10) { effect = -1; } else if (total <= 12) { effect = 0; } else if (total <= 14) { effect = 1; } else if (total <= 20) { effect = total - 13; } else { effect = Math.ceil(((total + 15)/5)); // effect = (total + 15) / 5; // effect = parseInt() + 15; } output = "&{template:default} {{name=TORG Dice Roller}} {{modifier= " + modifier + "}} {{dice rolled= " + output + "}} {{Total= " + total + "}} {{Skill Effect= " + effect + "}}"; sendChat(msg.who, output); });
I only know Torg Eternity, but shouldn't the modifier add to the effect instead of the die total? Was it possible to have a modifier to the die roll in Original Torg?
1599082046
Senjak
Pro
Sheet Author
I'll have to check with the woman running the game. I was under the impression that a modifier would add to the die rolls. Here is a revised version of the program based upon feedback I was sent. I also added a bunch of comments. // script to roll dice the TORG Classic way. // // this has two modes, one for trained skills and one for untrained skills. // each mode uses the same arguments. Right now it expects the first argument  // to be a die roll modifier. The second and all further arguments are used // as the character's name. // // It returns a nicely formatted string with all of the information wrapped up. // There isn't currently a way to take it out of debug mode, but that is because // I always like to see the information that the numbers were based upon. // // USAGE: // !torg MODIFIER CHARACTER NAME // !torg-noskill MODIFIER CHARACTER NAME // // Safety Wrapper // on('ready', function() {     // isolate the effect calculations. // function calculateEffect(total) { let effect = 0; if (total <= 1) { effect = -12; } else if (total == 2) { effect = -10; } else if (total <= 4) { effect = -8; } else if (total <= 6) { effect = -5; } else if (total <= 8) { effect = -2; } else if (total <= 10) { effect = -1; } else if (total <= 12) { effect = 0; } else if (total <= 14) { effect = 1; } else if (total <= 20) { effect = total - 13; } else { effect = Math.ceil(((total + 15)/5)); } return effect; } // end of isolating the effect calculation. // start of main section on("chat:message", function(msg) { // Exit if not an api command // if (msg.type != "api") return; // Get the API Chat Command // Strip out args[0] and args[1] if no arg[1] then modifier is 0. // let args = msg.content.split(' '); let command = args[0] let name = " "; let modifier = parseInt(args[1]) || 0; if (args[2] != null) { let i = 2; while (args[i] != null) { name = name + " " + args[i]; i++; } } // Determine how the script was called. // exit if we've gotten here with the wrong command. // // Hello Mrs. Rossow! (she used to do this in the 70s.) // if(command !== "!torg" && command !== "!torg-noskill") { return; } let skilled = (command === "!torg") ? 1 : 0; // Define some useful variables. // Note that 'let' is the preferred method in javascript. let roll = 0; let total = 0; let explode = 1; let output = ""; let effect = 0; // loop through this at least once. Keep looping  // as long as we have exploding dice. // while (explode > 0) { roll = randomInteger(20); output = output + " " + roll; total = total + roll; // See if we need to have the dice  // explode and roll again. // explode = (roll === 10 || (roll === 20 && skilled == 1)) ? 1 : 0; } total = total + modifier; // pass the total off to a function to  // calculate the effect number. // effect = calculateEffect(total); // generate the return message to go to  // chat as the default output. // output = "&{template:default} {{name=" + name + ": TORG roll}} {{modifier= " + modifier + "}} {{dice rolled= " + output + "}} {{Total= " + total + "}} {{Skill Effect= " + effect + "}}"; // pass it back up for output. // sendChat(msg.who, output); }); // end of main section }); // end of safety wrapper.