RPTools.net

Discussion and Support

Skip to content

It is currently Sat Jun 24, 2017 5:32 pm 






Reply to topic  [ 3 posts ] 

Previous topic | Next topic 

  Print view

Author Message
 Offline
Kobold
 
Joined: Wed May 08, 2013 10:35 pm
Posts: 2
 Post subject: World of Darkness Roller
PostPosted: 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;
}



Top
 Profile  
 
 Offline
Kobold
 
Joined: Wed May 08, 2013 10:35 pm
Posts: 2
 Post subject: Re: World of Darkness Roller
PostPosted: 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;
}


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9250
Location: Netherlands
 Post subject: Re: World of Darkness Roller
PostPosted: 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

My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent and
DPI.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 3 posts ] 

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

Search for:

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





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman