RPTools.net

Discussion and Support

It is currently Thu Oct 19, 2017 9:36 am

 Page 1 of 1 [ 3 posts ]
Author Message
 hellfur   Kobold Joined: Wed May 08, 2013 10:35 pmPosts: 2
 Post subject: World of Darkness RollerPosted: Wed May 08, 2013 11:13 pm
First post, but if you're using the DiceTool and playing New World of Darkness, then I figured I should share this function.

To use, paste the code at end of this post into a "functions.js" file in the same directory as your dicetool-1.0*.jar file. This will give you a new function called wodRoll. The first argument is the number of dice, then the number to re-roll (in case you're playing 8/9/10 again), and finally a 'chance roll' boolean (where 0 is false, and anything else is true).

The total number of successes is given at the top, followed by each die roll. Blue rows are successes, green rows accrue an extra die (/reroll), and black rows show a Dramatic Failure (only in chance rolls).

This means you can put the following rolls in your tabs:

Code:
wodRoll(4)
This will roll 4d10, and reroll any 10s.
Code:
wodRoll(4, 8)
This will roll 4d10s, and reroll any 8s, 9s, or 10s.
Code:
wodRoll(1, 10, 1)
This will roll a chance roll, rerolling 10s (only a 10 is a success, 1s come out as black)
Code:
wodRoll(1, 8, 1)
This will roll a chance roll, but reroll 8s, 9s, or 10s (Still only 10 is success)
Code:
wodRoll(10, 8, 1)
As above. The number of dice are ignored on a chance roll.

You can also combine that function and some constants, if you'd like, by using:

Code:
wodRoll(4) + 4
Roll 4d10, reroll any 10s, add 4 to the total number of successes

The code to paste in your functions.js file follows. Enjoy!

Code:

function registerFunctions() {
var map = new java.util.HashMap();
map.put("wodRoll", wodRoll);

return map;
}

function wodRoll(numDice, rerollAt, isChanceRoll) {
row.setLabel("Successes:");

if (!rerollAt) {
rerollAt = 10;
}

// Can only roll one, regardless of what they way.
if (isChanceRoll) {
numDice = 1;
}

var originalDice = numDice;
var successes = 0;
for (var i = 0; i < numDice; i++) {
var value = rand.nextInt(10) + 1;

resultSet.addExpression("Die " + (i + 1) + (i >= originalDice ? ' (Extra die!)' : ''), value + '', null, value);
var innerRow = resultSet.getCurrentRow();

if (isChanceRoll) {
if (value == 10) {
// If chance roll, only 10s are successes.
//  10s give another chance.
successes++;
numDice++;
innerRow.setBackgroundColor(0, 0, 255);
innerRow.setForegroundColor(255, 255, 255);
}
if (value == 1) {
innerRow.setBackgroundColor(0, 0, 0);
innerRow.setForegroundColor(255, 255, 255);
}
} else {
if (value >= 8) {
successes++;
innerRow.setBackgroundColor(0, 0, 255);
innerRow.setForegroundColor(255, 255, 255);
}
if (value >= rerollAt) {
numDice++;
innerRow.setBackgroundColor(0, 255, 0);
innerRow.setForegroundColor(0, 0, 0);
}
}
innerRow.setTotal(successes);
}

return successes;
}

 hellfur   Kobold Joined: Wed May 08, 2013 10:35 pmPosts: 2
 Post subject: Re: World of Darkness RollerPosted: Fri May 10, 2013 12:57 pm
Oops. I pasted an older version of that file. It will work for most cases, but doesn't reroll on anything lower than 10 in chance rolls. The following fixes that.

Code:
function registerFunctions() {
var map = new java.util.HashMap();
map.put("wodRoll", wodRoll);

return map;
}

function wodRoll(numDice, rerollAt, isChanceRoll) {
row.setLabel("Successes:");

if (!rerollAt) {
rerollAt = 10;
}

// Can only roll one, regardless of what they want.
if (isChanceRoll) {
numDice = 1;
}

var originalDice = numDice;
var successes = 0;
for (var i = 0; i < numDice; i++) {
var value = rand.nextInt(10) + 1;

resultSet.addExpression("Die " + (i + 1) + (i >= originalDice ? ' (Extra die!)' : ''), value + '', null, value);
var innerRow = resultSet.getCurrentRow();

if (isChanceRoll) {
// Anything at or above rerollAt gives another die, but is not a success.
if (value >= rerollAt) {
numDice++;
}
if (value == 10) {
// If chance roll, only 10s are successes.
successes++;
innerRow.setBackgroundColor(0, 0, 255);
innerRow.setForegroundColor(255, 255, 255);
}
if (value == 1) {
innerRow.setBackgroundColor(0, 0, 0);
innerRow.setForegroundColor(255, 255, 255);
}
} else {
if (value >= 8) {
successes++;
innerRow.setBackgroundColor(0, 0, 255);
innerRow.setForegroundColor(255, 255, 255);
}
if (value >= rerollAt) {
numDice++;
innerRow.setBackgroundColor(0, 255, 0);
innerRow.setForegroundColor(0, 0, 0);
}
}
innerRow.setTotal(successes);
}

return successes;
}

 wolph42   Deity Joined: Fri Mar 20, 2009 4:40 amPosts: 9411Location: Netherlands
 Post subject: Re: World of Darkness RollerPosted: Fri May 10, 2013 3:49 pm
Hi, thanks for sharing. Note that you can always update the original post (op). Which is good practice to do here!

_________________
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 3 posts ]

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

 Search for: Jump to: Select a forum ------------------ General    Announcements    Ideas for New Applications    General Discussion    Developer Notes       Java Programming Info    User Creations       Requests for HELLLLP!       Tilesets, Token Libraries, and Complete Maps          Token Libraries          Tilesets/Graphics for Map-making          Complete Maps       Campaign Frameworks          D&D 5e Frameworks          D&D 4e Frameworks          [D&D3.5 + Pathfinder] Campaign Macros          Shadowrun 4e Frameworks          Savage Worlds Frameworks       Published Module Support       Tutorials          Graphics, Images, Tokens, Maps          Drop-In Macros and Scripts          Campaign Frameworks       Drop-In Macro Resources    Links & External Resources    Looking For Group       "Living" Campaigns       Dungeons and Dragons       Savage Worlds       WoD       Wargaming    Documentation Requests/Discussion    Session Report-Back Tools    MapTool       How To       Macros       Feature Requests          Resolved       Bug Reports          Resolved       WIP - User FAQ       Testing    MapTool 1.4    TokenTool    DiceTool    InitiativeTool    CharacterTool       Support: d20 D&D       Support: D&D 4e       Support: Hero System       Support: Savage Worlds       Support: GURPS Other    RPTools Sightings    Running Campaigns       Thiera's College of Adventurers       Age of Might       Scales of War       Renwold       Dead Men Walking       Dark Sun - 4th Edition       Warhammer Fantasy Roleplay       Return of Uchly Namen       Insert Campaign Here       Antium       The Mystic Moon       World of Lagal       GangerRun       FB Scales of War       Sellswords of Eberron          Archive       Orbs of Chaos       World of Omegus       Keep on the Shadowfell - 4E       Rise of the Runelords       Aurith In The Age Of Steam       Widdershins       Nos's Pathfinder Campaign       Falcons Hollow       Verwirrte Welten       With it or on it       Starter Set - Jeff

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 243 on Sun Nov 04, 2012 6:14 am

Users browsing this forum: No registered users and 1 guest