Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents NumericUpDown1 As System.Windows.Forms.NumericUpDown Friend WithEvents NumericUpDown2 As System.Windows.Forms.NumericUpDown Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button() Me.TextBox1 = New System.Windows.Forms.TextBox() Me.NumericUpDown1 = New System.Windows.Forms.NumericUpDown() Me.NumericUpDown2 = New System.Windows.Forms.NumericUpDown() Me.Label1 = New System.Windows.Forms.Label() Me.Label2 = New System.Windows.Forms.Label() CType(Me.NumericUpDown1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.NumericUpDown2, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(32, 16) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Calculate" ' 'TextBox1 ' Me.TextBox1.AcceptsReturn = True Me.TextBox1.Location = New System.Drawing.Point(152, 16) Me.TextBox1.Multiline = True Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(100, 152) Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = "" ' 'NumericUpDown1 ' Me.NumericUpDown1.ForeColor = System.Drawing.SystemColors.WindowText Me.NumericUpDown1.Location = New System.Drawing.Point(104, 88) Me.NumericUpDown1.Name = "NumericUpDown1" Me.NumericUpDown1.Size = New System.Drawing.Size(40, 20) Me.NumericUpDown1.TabIndex = 2 Me.NumericUpDown1.Value = New Decimal(New Integer() {1, 0, 0, 0}) ' 'NumericUpDown2 ' Me.NumericUpDown2.Location = New System.Drawing.Point(104, 112) Me.NumericUpDown2.Name = "NumericUpDown2" Me.NumericUpDown2.Size = New System.Drawing.Size(40, 20) Me.NumericUpDown2.TabIndex = 3 Me.NumericUpDown2.Value = New Decimal(New Integer() {6, 0, 0, 0}) ' 'Label1 ' Me.Label1.Location = New System.Drawing.Point(16, 88) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(88, 23) Me.Label1.TabIndex = 4 Me.Label1.Text = "Number of Dice" ' 'Label2 ' Me.Label2.Location = New System.Drawing.Point(16, 112) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(88, 23) Me.Label2.TabIndex = 5 Me.Label2.Text = "Difficulty" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(264, 181) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label2, Me.Label1, Me.NumericUpDown2, Me.NumericUpDown1, Me.TextBox1, Me.Button1}) Me.Name = "Form1" Me.Text = "White Wolf System Probabilities" CType(Me.NumericUpDown1, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.NumericUpDown2, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) End Sub #End Region Dim iLoop1, iLoop2 As Integer Dim iBotch, iFail, iSuccess(1) As Integer Dim iBotchChance, iFailChance, iSuccessChance(1) As Single Dim iDie(1), iDiePosition As Integer Dim iBotchRolls, iFailRolls, iSuccessRolls As Integer Dim sOutput As String Dim iSubsumed As Integer Dim iWarned As Integer Private Sub NumericUpDown2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown2.ValueChanged If NumericUpDown2.Value > 10 Then NumericUpDown2.Value = 10 End If If NumericUpDown2.Value < 2 Then NumericUpDown2.Value = 2 End If End Sub Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged If NumericUpDown1.Value < 1 Then NumericUpDown1.Value = 1 End If If NumericUpDown1.Value > 9 Then If iWarned = 0 Then MsgBox("Die pools over 9 dice will cause overflow errors." & vbCrLf & "Number of dice set to 9.", , "Warning") End If NumericUpDown1.Value = 9 iWarned = 1 End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ReDim iSuccess(NumericUpDown1.Value) ReDim iSuccessChance(NumericUpDown1.Value) ReDim iDie(NumericUpDown1.Value) iBotch = 0 iFail = 0 iSubsumed = 1 'Initialize all dice to 1 For iLoop1 = 1 To NumericUpDown1.Value iDie(iLoop1) = 1 Next For iLoop1 = 1 To 3 ^ NumericUpDown1.Value iSubsumed = 1 iBotchRolls = 0 iFailRolls = 0 iSuccessRolls = 0 For iLoop2 = 1 To NumericUpDown1.Value If iDie(iLoop2) = 1 Then iBotchRolls = iBotchRolls + 1 End If If iDie(iLoop2) = 2 Then iFailRolls = iFailRolls + 1 iSubsumed = iSubsumed * (NumericUpDown2.Value - 2) End If If iDie(iLoop2) = 3 Then iSuccessRolls = iSuccessRolls + 1 iSubsumed = iSubsumed * (11 - NumericUpDown2.Value) End If Next If iBotchRolls > iSuccessRolls Then iBotch = iBotch + iSubsumed End If If iBotchRolls = iSuccessRolls Then iFail = iFail + iSubsumed End If If iSuccessRolls > iBotchRolls Then iSuccess(iSuccessRolls - iBotchRolls) = _ iSuccess(iSuccessRolls - iBotchRolls) + iSubsumed End If 'Increment dice iDiePosition = 1 iDie(1) = iDie(1) + 1 While iDie(iDiePosition) > 3 'break loop if maxed If iDiePosition = NumericUpDown1.Value Then Exit For End If iDie(iDiePosition) = 1 iDiePosition = iDiePosition + 1 iDie(iDiePosition) = iDie(iDiePosition) + 1 End While Next 'Calcs and create output string iBotchChance = (iBotch / (10 ^ NumericUpDown1.Value)) * 100 iFailChance = (iFail / (10 ^ NumericUpDown1.Value)) * 100 For iLoop1 = 1 To NumericUpDown1.Value iSuccessChance(iLoop1) = (iSuccess(iLoop1) / (10 ^ NumericUpDown1.Value)) _ * 100 Next sOutput = Nothing sOutput = sOutput & "Botch = " & CStr(iBotchChance) & "%" & vbCrLf sOutput = sOutput & "Fail = " & CStr(iFailChance) & "%" & vbCrLf For iLoop1 = 1 To NumericUpDown1.Value sOutput = sOutput & CStr(iLoop1) & " = " & CStr(iSuccessChance(iLoop1)) & "%" If iLoop1 < NumericUpDown1.Value Then sOutput = sOutput & vbCrLf End If Next TextBox1.Text = sOutput End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load iWarned = 0 End Sub End Class