NEWS

VBscript Dice Roller I came up with

  • 6 Replies
  • 3400 Views

calicojack73

  • *
  • Newb
  • *
  • Posts: 10
« on: <12-13-12/1341:18> »
As a GM I don't really care about the exact rolls for my NPCs, I just want to quickly know how many hits and glitches I got.
That being said, I created this vbscript to automate dice rolling for SR4.
Simply copy and save the code into a blank txt file on your Windows PC and change the file extension from .txt to .vbs
Double click it and it will handle the rest.

Code: [Select]
Y = 6
Do Until Y <> 6
D = inputbox("Enter the number of dice you want to roll","SR4 Dice Roller 1.0",0)
If D = "" or D = "0" then
wscript.quit
End If
Set objRandom = CreateObject( "System.Random" )
Hits = 0
Glitches = 0
For i = 1 to D
x = objRandom.Next_2( 1, 6 )
If x > 4 then
Hits = Hits + 1
End If
If x = 1 then
Glitches = Glitches + 1
End If
Next
If Hits = 0 AND Glitches >= D/2 Then
msgbox"YOU GOT A CRITICAL FAILURE!!!" & vbcrlf & Glitches & " Glitches rolled!",,"SR4 Dice Roller 1.0"
Else
msgbox"You got " & Hits & " Hits and " & Glitches & " Glitches.",,"SR4 Dice Roller 1.0"
End If

Y = msgbox("Do you want to roll again?",vbYesNo,"SR4 Dice Roller 1.0")

Xzylvador

  • *
  • Prime Runner
  • *****
  • Posts: 3666
  • Ask me about NERPS! 30% Sales!
« Reply #1 on: <12-13-12/1651:48> »
Might want to change to 
Code: [Select]
If Glitches >= Int(D/2 + 0.5) AND Hits > 0 Then
      msgbox"GLITCH!" & vbcrlf & Hits & " Hits " & Glitches & " Glitches rolled." ,,"SR4 Dice Roller 1.01"
else
           If Hits = 0 AND Glitches >= D/2 Then
              msgbox"YOU GOT A CRITICAL FAILURE!!!" & vbcrlf & Glitches & " Glitches rolled!",,"SR4 Dice Roller 1.01"
            Else
                 msgbox"You got " & Hits & " Hits and " & Glitches & " Glitches.",,"SR4 Dice Roller 1.01"
            End If
End If

Unless being drunk and not having coded in a decade or so screwed up my writing.
« Last Edit: <12-13-12/1657:53> by Xzylvador »

calicojack73

  • *
  • Newb
  • *
  • Posts: 10
« Reply #2 on: <12-14-12/0713:29> »
Thats nice... I didn't really figure on needing to specify a normal glitch since it is possible to still succeed at a task while rolling a glitch.  That is a nice addition though.  Did you try the code out and see if it worked?

Xzylvador

  • *
  • Prime Runner
  • *****
  • Posts: 3666
  • Ask me about NERPS! 30% Sales!
« Reply #3 on: <12-14-12/0732:20> »
Android tablet, so no.

JustADude

  • *
  • Prime Runner
  • *****
  • Posts: 3043
  • Madness? This! Is! A FORUM!
« Reply #4 on: <12-15-12/0520:34> »
Android tablet, so no.

Try Simple DiceRoller, which is a free Android App, if you want to do something similar on a Tablet.

It lets you create formulae to check for various statuses. I've never messed around with them too much, but I think it should work just fine for what you need.
“What is right is not always popular and what is popular is not always right.”
― Albert Einstein

"Being average just means that half of everyone you meet is better than you."
― Me

Xzylvador

  • *
  • Prime Runner
  • *****
  • Posts: 3666
  • Ask me about NERPS! 30% Sales!
« Reply #5 on: <12-15-12/0546:42> »
I've got a small pouch with 20 d6's which I carry around in the same bag I use for my tablet, so thanks, but I'm good ;)
Invisible Castle works great too.

Next tablet I buy just might be a windows 8 tablet so I can use Chummer, too.

Redmercury

  • *
  • Omae
  • ***
  • Posts: 251
« Reply #6 on: <12-15-12/1339:08> »
Nice Xzylvador, always ready to play classy.