Witness
Mar 20 2006, 02:51 PM
I thought GMs might find this useful if they like to try and keep order with Excel (as I do)...
It's a user-defined dice-roller function, so you can put the following formula structure into the cell of a spreadsheet...
=ROLL(number of dice,[number of edge dice])
...and this returns the number of hits determined at random.
If the roll is a glitch, the result is returned as a decimal with the number of ones after the point (e.g. 2.03 means a glitch with 2 hits but 3 ones). If it is a critical glitch, the number returned is the number of dice rolled, but negative.
The number refreshes every time the spreadsheet is recalculated (e.g. when you hit delete on an empty cell)
If the edge dice argument is included, the Rule of Six is implemented as it should be.
To use this formula you first have to create a spreadsheet, go to Tools>Macro>Visual Basic Editor, then Insert>Module, and paste in the following code. (Tools>Macro>Security has to be set low enough to allow macros to run)
QUOTE |
Public Function Roll(dice As Integer, Optional edge As Integer = 0) Application.Volatile Dim hits As Integer hits = 0 Dim sixes As Integer sixes = 0 Dim ones As Integer ones = 0 For i = 1 To dice + edge d = Int(Rnd * 6) + 1 Select Case d Case 1 ones = ones + 1 Case 5 hits = hits + 1 Case 6 hits = hits + 1 sixes = sixes + 1 End Select Next If edge > 0 Then Do rerolls = sixes sixes = 0 For i = 1 To rerolls d = Int(Rnd * 6) + 1 Select Case d Case 1 ones = ones + 1 Case 5 hits = hits + 1 Case 6 hits = hits + 1 sixes = sixes + 1 End Select Next Loop While sixes > 0 End If If ones * 2 >= dice + edge Then If hits > 0 Then Roll = hits + (ones * 0.01) Else Roll = -(dice + edge + (ones * 0.01)) End If Else Roll = hits End If End Function |
You could, for example, use this to build NPC character spreadsheets that do the dice rolling for you, or create a spreadsheet that can do those hidden tests for the party at the touch of a button.
Maybe Blakkie et al could use it in their excellent excel character generator?
Apologies if somebody else has already thought of this or implemented it better. Or if it's buggy.
Or just for being such an unbelievable geek!
GrinderTheTroll
Mar 20 2006, 05:56 PM
Prove your inner geek... I want recursion!
Witness
Mar 20 2006, 06:19 PM

First thing I ever coded in VB. Now if it was Python, would be a bit more elegant perhaps.
TinkerGnome
Mar 20 2006, 08:47 PM
I wrote a die roller program in excel that's a little more useful for online play.
Clicky. It's certainly no massive feat of excellent code, though.
My method would work well in a character spreadsheet if you went through the trouble of creating pull down lists for every slot so that you could autopopulate the dice numbers.