Rolls a number of
dice with a number of sides, and adds a
modifier. In
standard gamer dice notation (
SGDN), a roll of 3d8+2 looks like:
RollDice(8, 3, 2)
Single-die rolls are
oh-so-simple: a d100 is
RollDice(100).
Function RollDice(DiceSides As Integer, Optional DiceNum As Integer, Optional DiceMod As Integer)
If IsMissing(DiceNum) Or DiceNum = 0 Then DiceNum = 1
If IsMissing(DiceMod) Then DiceMod = 0
If DiceNum < 1 Or DiceSides < 2 Then
RollDice = 0
GoTo RollDiceEnd
End If
RollDice = (DiceNum * Int(Rnd * DiceSides + 1)) + DiceMod
RollDiceEnd:
End Function