Advertisement
SierraAR

Dice Rolling mIRC alias

Nov 25th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 1.56 KB | None | 0 0
  1. ; Assumes $1 uses the standard #d# format (I..e, 1d6 = Roll 1 six sided die; 2d4 = roll 2 four sided die. $2 can be ##, +##, or -## (## is converted to +##))
  2. ; $1 can also be 'percentile' or 'p' to simulate the rolling of percentile dice (2d10, where one d10 is ones (0-9), the other is tens (00-90). 0+00 = 100)
  3. alias diceroll {
  4.   var %parDice = $1
  5.   var %parMod = $2
  6.  
  7.  
  8.   var %rollTotal = 0
  9.   var %rollList = $null
  10.  
  11.    ; Percentile (Only checks if first letter is p)
  12.   if ($left(%parDice, 1) == p) {
  13.     ; Roll tens
  14.     var %tmpRoll = $calc($rand(0, 9) * 10)
  15.     inc %rollTotal %tmpRoll
  16.     var %rollList = %rollList ( $+ %tmpRoll $+ )
  17.    
  18.     ; Roll ones
  19.     var %tmpRoll = $rand(0, 9)
  20.     inc %rollTotal %tmpRoll
  21.     var %rollList = %rollList ( $+ %tmpRoll $+ )
  22.    
  23.      ; If total is 0, roll is 100
  24.     if (%rollTotal = 0) {
  25.       var %rollTotal = 100
  26.     }
  27.   }
  28.  
  29.    ; Standard dice notation (#d#)
  30.   else {
  31.     var %diceCount = $gettok(%parDice, 1, 100)
  32.     var %diceSides = $gettok(%parDice, 2, 100)
  33.    
  34.      ; Roll each dice
  35.     var %count = 1
  36.     while (%count <= %diceCount) {
  37.       var %tmpRoll = $rand(1, %diceSides)
  38.       inc %rollTotal %tmpRoll
  39.       var %rollList = %rollList ( $+ %tmpRoll $+ )
  40.    
  41.       inc %count
  42.     }
  43.   }
  44.  
  45.    ; Add modifier
  46.   if (%parMod) {
  47.     inc %rollTotal %parMod
  48.     var %rollList = %rollList %parMod
  49.   }
  50.  
  51.   return %rollTotal %rollList
  52. }
  53.  
  54. alias doTest {
  55.   echo t $diceRoll(Percentile, +3)
  56.   echo t $diceRoll(Percentile)
  57.   echo t $diceRoll(Percentile, -3)
  58.   echo t $diceRoll(Percentile, 1)
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement