Advanced Dice

By LIQUID_NiTrO on Jan 23, 2005

This is a customizable dice rolling script ideal for RPing and use in "Pen-and-Paper" type RPGs, such as D&D and stuff. The syntax is a bit complicated:
/advdice {Number}!{Sides}[+|-][Modifier] [c|r|a]
{Number} is the number of dice to roll, {Sides} is the number of sides per dice, [Modifier] is the number to be added or subtracted to the outcome of each roll, [+|-] specifies whether [Modifier] should be added or subtracted. [c|r|a] determines what should be done with the dice once they have all been rolled, if c is specified it will add all of the rolls together, if r is specified it will randomly select one roll, and if a is selected it will average all the rolls together. If nothing is specified it defaults to c.
This thing took me forever to make. And a thanks to Sigh_ for helping me with muh variables.

alias advdice {
  if ( !$1 ) {
    var %d = $rand(1,6)
    echo $colour(info) -a * You rolled %d
    halt
  }
  elseif ( $chr(33) !isin $1 ) || ( $gettok($1,1,33) < 1 ) || ( $gettok($1,1,33) !isnum ) {
    echo $colour(info) -a * ERR: Syntax: /advdice [dicemod] [c|r|a]
    halt
  }
  if ( $chr(43) isin $1 ) {
    var %op = +
  }
  elseif ( $chr(45) isin $1 ) {
    var %op = -
  }
  var %x = 1
  while ( %x <= $gettok($1,1,33) ) {
    if ( %op ) {
      set -l %dr. $+ %x $calc($rand(1,$gettok($gettok($1,2,33),1,$asc(%op))) $(%op) $gettok($gettok($1,2,33),2,$asc(%op))))
    }
    else {
      set -l %dr. $+ %x $rand(1,$gettok($1,2,33))
    }
    inc %x 1
  }
  window -do @DiceResults
  var %a = 1
  while (* iswm $($+(%,dr.,%a),2)) {
    aline @DiceResults *  $+ %a $+ : $v2
    inc %a
  } 
  if ( !$2 ) || ( $2 == c ) {
    var %f = 0,%g = 1
    while ( * iswm $($+(%,dr.,%g),2) ) {
      %f = $calc(%f + $($+(%,dr.,%g),2))
      inc %g 1
    }
    echo $colour(info) -a * Cumulative Dice Total: %f
  }
  elseif ( $2 == r ) {
    var %g = 1

    while ( * iswm $($+(%,dr.,%g),2) ) {
      inc %g
    }
    var %se = $rand(1,%g)
    echo $colour(info) -a * Randomly Selected Dice: $($+(%,dr.,%se),2)
  }
  elseif ( $2 == a ) {
    var %g = 1,%f = 0
    while ( * iswm $($+(%,dr.,%g),2) ) {
      %f = $calc(%f + $($+(%,dr.,%g),2))
      inc %g 1
    }
    var %avg = $calc(%f / %g)
    if ( $chr(46) isin %avg ) {
      if ( 3333* iswm $gettok(%avg,2,46) ) {
        echo $colour(info) -a * Average of all rolled dice: $gettok(%avg,1,46) 1/3
      }
      elseif ( 6666* iswm $gettok(%avg,2,46) ) {
        echo $colour(info) -a * Average of all rolled dice: $gettok(%avg,1,46) 2/3
      }
      else {
        echo $colour(info) -a * Average of all rolled dice: $round(%avg,2)
      }
    }
    else {
      echo $colour(info) -a * Average of all rolled dice: %avg
    }
  }
  else {
    echo $colour(info) * This case should not have triggered
  }
}

Comments

Sign in to comment.
Purplebeard   -  Jul 15, 2009

tsueg i was gonna come in to take you on that socks off dice thing... but i couldn't connect said "connected refused"

Tsueg  -  Mar 15, 2014

Wow. Last login was in 2006 for me. Not just to Hawkee.com but to an IRC server. The online role-play-gaming has sort of gone in a different direction and I stopped gaming. I'm still willing to have a go if you are interested. My scripts are a bit dusty though. Send me a message.

Sign in to comment

Tsueg   -  Sep 09, 2006

multiple set rolling just allows more dice rolls in the same command, for example a ful set of stats in a single roll instead of 6.

but then, sometimes life is easier when its less complicated. It\'s a nice clean dice roller.

 Respond  
LIQUID_NiTrO   -  Apr 15, 2006

What exactly do you mean? I can think of no reason why you would use regex for a dice script... also what\'s \"multiple set rolling\"?

 Respond  
splatted   -  Feb 18, 2005

Tsueg: what, are you saying mIRC\'s rand isn\'t random enough for you?

 Respond  
Tsueg   -  Feb 17, 2005

right off the top -- the wish would be for a better mIRC random. After that, a full regular expression pattern match for dice syntax that can roll any number of dice sides requested, and multiple set rolling. those two are pretty important. From there, it depends on the particular game system. i can think of more than different and unique dice systems off the top of my head that all have different rolling rules and syntaxes. I\'ve looked through dozens of dice scripts - the happiest ive been with have been privatly written unix scripts shrugs

 Respond  
LIQUID_NiTrO   -  Jan 30, 2005

What other features could RPing dice have...? I haven\'t seen anything else...

 Respond  
Tsueg   -  Jan 29, 2005

not bad. I\'d consider it extremly simple for role-plaiyng dice though. nothing really advanced. the C|R|E thing after the roll is a nice touchl. where on irc do you game? come visit me in irc://irc.serenity-irc.net/rpg-hub/ and i\'ll give you some dice that\'ll knock your socks off, just ask for Tsueg.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.