Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Roll()
- 'odds and probability values
- Dim total_rolls As Long: total_rolls = 100000000 'total rolls to simulate
- Dim perc4 As Single: perc4 = 0.051 'chance of 4 star
- Dim perc5 As Single: perc5 = 0.006 'chance of 5 star
- Dim pitynum4 As Integer: pitynum4 = 10 'pity threshold for 4 star
- Dim pitynum5 As Integer: pitynum5 = 90 'pity threshold for 5 star
- Dim rand As Single
- 'start counters at 0
- Dim count3 As Long: count3 = 0
- Dim count4 As Long: count4 = 0
- Dim count5 As Long: count5 = 0
- Dim streak4 As Integer: streak4 = 0
- Dim streak5 As Integer: streak5 = 0
- Dim nat4 As Long: nat4 = 0
- Dim nat5 As Long: nat5 = 0
- Dim pity4 As Long: pity4 = 0
- Dim pity5 As Long: pity5 = 0
- 'start rolling
- For i = 1 To total_rolls
- 'randomize roll
- rand = Rnd()
- 'if pity 5
- If streak5 >= pitynum5 - 1 Then
- pity5 = pity5 + 1
- count5 = count5 + 1
- streak5 = 0
- streak4 = 0
- 'if natural 5
- ElseIf rand <= perc5 Then
- nat5 = nat5 + 1
- count5 = count5 + 1
- streak5 = 0
- streak4 = 0
- 'if pity 4
- ElseIf streak4 >= pitynum4 - 1 Then
- pity4 = pity4 + 1
- count4 = count4 + 1
- streak5 = streak5 + 1
- streak4 = 0
- 'if natural 4
- ElseIf rand <= perc4 + perc5 Then
- nat4 = nat4 + 1
- count4 = count4 + 1
- streak5 = streak5 + 1
- streak4 = 0
- 'else 3 star
- Else
- count3 = count3 + 1
- streak5 = streak5 + 1
- streak4 = streak4 + 1
- End If
- 'next roll
- Next i
- 'export results into spreadsheet
- Cells(2, 3).Value = count3 'total 3* pulls
- Cells(2, 4).Value = count4 'total 4* pulls
- Cells(2, 5).Value = count5 'total 5* pulls
- Cells(3, 4).Value = nat4 'total natural 4* pulls
- Cells(3, 5).Value = nat5 'total natural 5* pulls
- Cells(4, 4).Value = pity4 'total pity 4* pulls
- Cells(4, 5).Value = pity5 'total pity 5* pulls
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement