DDO style dice

Published  Jun 13, 2012
Updated  Jun 13, 2012
0  5

Description

;--- DDO style dice ---
on *:TEXT:!Roll*:# {
  if (%quote.flood == $null) {
    if ($$2- == help) {
      /notice $nick * The syntax almost mirrors the in-game syntax with the only difference being that
      /notice $nick * you use "!roll" instead or "/roll" like:  !Roll {Number}d{Sides}[+|-][Modifier]
      /notice $nick * {Number} is the number of dice to roll.
      /notice $nick ** Defaults to 1 if omitted.
      /notice $nick * {Sides} is the number of sides per dice.
      /notice $nick ** Current acceptable range is 2 - 10000000000
      /notice $nick ** If {Number} * {Sides} > 9999999999 !roll will overflow (you will roll a 0).
      /notice $nick * [+|-][Modifier] is the number to be added or subtracted to the outcome of the roll total.
      /notice $nick ** Ommitted if not a number.
    }
    else {
      /set %DT_DiceRolled 0
      /set %DT_length $len($$2-)
      /set %DT_oneD $count($$2-,d)
      if (%DT_oneD != 1) {
        /notice $nick $$2- is an invalid roll attempt. Please try again. If you need directions, type: !Roll help
        goto CleanUp
      }
      /set %DT_dPos $pos($$2-,d,1)
      /set %DT_oneP $count($$2-,+)
      if (%DT_oneP == 1) { /set %DT_pPos $pos($$2-,+,1) }
      else { /unset %DT_oneP }
      /set %DT_oneM $count($$2-,-)
      if (%DT_oneM == 1) { /set %DT_mPos $pos($$2-,-,1)  }
      else { /unset %DT_oneM }
      /set %DT_dice $left($$2-,$calc(%DT_dPos - 1))
      if (%DT_dice == $null) { /set %DT_dice 1 }
      if (%DT_dice !isnum 1-10000000000) {
        /notice $nick " $+ %DT_dice $+ " is NOT a valid number of dice.  Please try again.
        goto CleanUp
      }
      /set %DT_sides $right($$2,$calc(%DT_length - %DT_dPos))
      if (%DT_sides !isnum 2-10000000000) {
        if (%DT_oneP == 1) {
          /set %DT_mod $right($$2-,$calc(%DT_length - %DT_pPos))
          /set %DT_sides $mid($$2-,$calc(%DT_dPos + 1),$calc(%DT_pPos - (%DT_dPos + 1)))
          /set %DT_modSign +
          if  (%DT_sides !isnum 2-10000000000) {
            /notice $nick " $+ %DT_sides $+ " is NOT a valid number of sides.  Please try again.
            goto CleanUp
          }
          if (%DT_mod !isnum) {
            /notice $nick " $+ %DT_modSign $+ %DT_mod $+ " is not a valid modifier -- it will be ignored from the result.
            /unset %DT_mod %DT_modSign
          }
          if (%DT_mod > 9999999998) {
            /notice $nick " $+ %DT_modSign $+ %DT_mod $+ " is too large of a modifier -- it will be ignored from the result.
            /unset %DT_mod %DT_modSign
          }
        }
        elseif (%DT_oneM == 1) {
          /set %DT_mod $right($$2-,$calc(%DT_length - %DT_mPos)) 
          /set %DT_sides $mid($$2-,$calc(%DT_dPos + 1),$calc(%DT_mPos - (%DT_dPos + 1)))
          /set %DT_modSign -
          if (%DT_sides !isnum 2-10000000000) {
            /notice $nick " $+ %DT_sides $+ " is NOT a valid number of sides.  Please try again.
            goto CleanUp
          }
          if (%DT_mod !isnum) {
            /notice $nick " $+ %DT_modSign $+ %DT_mod $+ " is not a valid modifier -- it will be ignored from the result.
            /unset %DT_mod %DT_modSign
          }
        }
        else {
          /notice $nick " $+ %DT_sides $+ " is NOT a valid number of sides.  Please try again.
          goto CleanUp
        }
      }
      if ($calc(%DT_dice * %DT_sides) >= 10000000000) {
        /set %DT_RollSum 0
      }
      else {
        while (%DT_DiceRolled < %DT_dice) {
          set %DT_roll $rand(1,%DT_sides)
          set %DT_RollSum $calc(%DT_RollSum + %DT_roll)
          inc %DT_DiceRolled
        }
      }
      /set %DT_TotalRollPreComma $calc(%DT_RollSum %DT_modSign %DT_mod)
      $regsub($ticks,%DT_TotalRollPreComma,/\G([+-]?\d+?)(?=(?:\d{3})++(?=\.\d++$|$))/g,\1 $+ $chr(44),%DT_TotalRoll)
      if ((%DT_TotalRoll == 11) || (%DT_TotalRoll == 18) || ($left(%DT_TotalRoll,1) == 8)) {
        /set %DT_anA an
      }
      else {
        /set %DT_anA a
      }
      msg $chan $nick rolled %DT_anA %DT_TotalRoll ( $+ %DT_dice $+ d $+ %DT_sides $+ %DT_modSign $+ %DT_mod $+ ).
      /notice $nick You rolled %DT_anA %DT_TotalRoll ( $+ %DT_dice $+ d $+ %DT_sides $+ %DT_modSign $+ %DT_mod $+ ).
      /set %DT_Users $nick($chan,0)
      /set %DT_UserCounter 1
      while (%DT_UserCounter < %DT_Users) {
        if ($nick != $nick($chan,%DT_UserCounter)) {
          /notice $nick($chan,%DT_UserCounter) $nick rolled %DT_anA %DT_TotalRoll ( $+ %DT_dice $+ d $+ %DT_sides $+ %DT_modSign $+ %DT_mod $+ ).
        }
        inc %DT_UserCounter
      }
      :CleanUp
      /unset %DT_*
    }
  }
  ;  set -u2 %quote.flood on
}

Download

Filename
Size
Date
Downloads
1.56 KB
Jun 13, 2012
10

Comments

Sign in to comment.
KilllerX   -  Nov 10, 2013

Might I ask what all the
are for?

Meta  -  Nov 11, 2013

I suspect those were caused by a glitch in the code highlighter at some point, rather than added by Technical_13.

Sign in to comment

MoshMage   -  Aug 05, 2012

Unless he is thinking of updating the code, then there's a purpose for a script entry. Still, he could remove de code and add a descriptiong to make it script-entry-like ^^'

 Respond  
Stewie1k94   -  Jun 14, 2012

No problem, just for future reference. :)

 Respond  
Technical_13   -  Jun 13, 2012

This is my first post here... Still learning the ropes... Apparently I can't move it... Can the admins move it, or should I repost it in snippits and remove it here?

 Respond  
Stewie1k94   -  Jun 13, 2012

This should of been posted as an mIRC snippet.

 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.