Difference between revisions of "IRCDiceScript"

From Exalted - Unofficial Wiki
Jump to: navigation, search
m
 
m
Line 1: Line 1:
== mIRC Dice Script == http://hammerand.com/IRCDiceScript.jpg
+
== mIRC Dice Script ==
  
 
Has functionality for nWod, Exalted, WOTG, and any sided dice rolls.
 
Has functionality for nWod, Exalted, WOTG, and any sided dice rolls.

Revision as of 11:07, 5 July 2005

mIRC Dice Script

Has functionality for nWod, Exalted, WOTG, and any sided dice rolls. make sure to copy this from the Modify Page screen, as wiki formatting may cause some odd behavior in displaying the script.

Currently at Version 1.0


Add this to aliases



/nwod { 

  var %display = $null

  %2 = $calc($2)

  if (%2 > 200) { 
    if ($chan != $null) /msg $chan $nick: 200 dice or less. example: !ex 5 
    if ($chan == $null) { 
      if ($nick == $me) /say $nick : 200 dice or less. example: !ex 5 
      if ($nick != $me) /msg $nick $nick : 200 dice or less. example: !ex 5 
    } 
    goto end 
  } 
  var %iter = 0 
  var %tot = 0 
  var %tens = 0

  var %target = 8
  %display = %display $nick ( $+ %2 $+ )

  :next1 

  inc %iter 

  var %die = $rand(1,10) 
  %display = %display $+ , %die 

  if (%die >= %target) var %tot = %tot + 1 
  if (%die == 10) var %iter = %iter - 1

  if (%iter < %2) goto next1 

  if (+ isin $3) { 
    var %p = $len($3) - 1 
    var %add = $right($3,%p) 
    if (%add > 0) && (%add < 30) var %tot = %tot + %add 
  } 
  if (+ isin $4) { 
    var %p = $len($4) - 1 
    var %add = $right($4,%p) 
    if (%add > 0) && (%add < 30) var %tot = %tot + %add 
  } 
  if (- isin $3) { 
    var %p = $len($3) - 1 
    var %add = $right($3,%p) 
    if (%add > 0) && (%add < 30) var %tot = %tot - %add 
  } 
  if (- isin $4) { 
    var %p = $len($4) - 1 
    var %add = $right($4,%p) 
    if (%add > 0) && (%add < 30) var %tot = %tot - %add 
  } 

  if (%tot < 0) %tot = 0

  %display = %display $+ , Successes : %tot 

  if ($chan != $null) /msg $chan %display 
  if ($chan == $null) { 
    if ($nick == $me) /say %display
    if ($nick != $me) /msg $nick %display
  } 
  :end 
}

/statistics {

  /clear @Statistics
  /window -depR +t @Statistics 1 1 600 400

  var %all = $calc(%statsone + %statstwo + %statsthree + %statsfour + %statsfive + %statssix + %statsseven + %statseight + %statsnine + %statsten)
  var %mult = $calc(2000/%all)

  /drawline @Statistics 3 5 50 $calc(50 + (%mult * %statsone )) 50 50
  /drawtext @Statistics 2 fixedsys 9 30 50 1
  /drawline @Statistics 3 5 100 $calc(50 + (%mult * %statstwo )) 100 50
  /drawtext @Statistics 2 fixedsys 9 80 50 2
  /drawline @Statistics 3 5 150 $calc(50 + (%mult * %statsthree )) 150 50
  /drawtext @Statistics 2 fixedsys 9 130 50 3
  /drawline @Statistics 3 5 200 $calc(50 + (%mult * %statsfour )) 200 50
  /drawtext @Statistics 2 fixedsys 9 180 50 4
  /drawline @Statistics 3 5 250 $calc(50 + (%mult * %statsfive)) 250 50
  /drawtext @Statistics 2 fixedsys 9 230 50 5
  /drawline @Statistics 3 5 300 $calc(50 + (%mult * %statssix)) 300 50
  /drawtext @Statistics 2 fixedsys 9 280 50 6
  /drawline @Statistics 3 5 350 $calc(50 + (%mult * %statsseven)) 350 50
  /drawtext @Statistics 2 fixedsys 9 330 50 7
  /drawline @Statistics 3 5 400 $calc(50 + (%mult * %statseight)) 400 50
  /drawtext @Statistics 2 fixedsys 9 380 50 8
  /drawline @Statistics 3 5 450 $calc(50 + (%mult * %statsnine)) 450 50
  /drawtext @Statistics 2 fixedsys 9 430 50 9
  /drawline @Statistics 3 5 500 $calc(50 + (%mult * %statsten)) 500 50
  /drawtext @Statistics 2 fixedsys 9 480 50 10

}


/roll {

  var %display = $null

  var %atim = $pos($1,+,0)
  var %stim = $pos($1,-,0)
  var %dtim = $pos($1,d,0)
  var %len = $len($1)

  if (%len < 3) goto error

  var %ops = %atim + %stim

  var %dlef = $pos($1,d,1)

  /dec %dlef 1

  var %dnum = $mid($1,0,%dlef)

  if (%dnum < 1) || (%dnum > 100) goto error

  /inc %dlef 2

  if ($pos($1,+,1) == $null) var %pos = $len($1)
  else var %pos = $pos($1,+,1)



  if ($pos($1,-,1) == $null) var %sub = $len($1)
  else var %sub = $pos($1,-,1)

  if (%atim == 0) && (%stim == 0) {
    %drig = $len($1)
    /inc %drig 1
  }
  else {
    if (%pos < %sub) var %drig = $pos($1,+,1)
    if (%sub < %pos) var %drig = $pos($1,-,1)
  }

  %dlen = %drig - %dlef

  var %dsid = $mid($1,%dlef,%dlen)

  if (%dsid < 1) || (%dsid > 1000) goto error

  var %tot = 0
  var %iter = 0

  if (%ops = 0) goto adde
  var %text = $replace($1,-,+-)


  :add
  /inc %iter 1
  if (%iter = %ops) var %rig = $len(%text)
  else {
    var %iter2 = %iter + 1
    var %rig = $pos(%text,+,%iter2)
    /dec %rig 1
  }
  var %lef = $pos(%text,+,%iter)
  %len = %rig - %lef
  /inc %lef 1
  var %ad = $mid(%text,%lef,%len)

  if (%ad < -30) || (%ad > 30) goto error

  %tot = %tot + %ad

  if (%iter < %ops) goto add

  :adde

  %iter = 0
  var %display = %display $nick $+ : $1-

  :next

  var %die = $rand(1,%dsid)

  %display = %display $+ , %die

  var %tot = %tot + %die
  inc %iter

  if (%iter < %dnum) goto next

  if ($chan != $null) /msg $chan $nick: %display $+ , Total: %tot
  if ($chan == $null) {
    if ($nick == $me) /say $nick : %display $+ , Total: %tot
    if ($nick != $me) /msg $nick $nick : %display $+ , Total: %tot
  }

  goto end

  :error

  if ($chan != $null) /msg $chan $nick : Can only have 1 to 1000 sides and 1 to 100
  dice and may only add or subtract up to 30. Example: !roll 100d1000+30-30
  if ($chan == $null) {
    if ($nick == $me) /say $nick : Can only have 1 to 1000 sides and 1 to 100
    dice and may only add or subtract up to 30. Example: !roll 100d1000+30-30
    if ($nick != $me) /msg $nick $nick : Can only have 1 to 1000 sides and 1 to 100 
    dice and may only add or subtract up to 30. Example: !roll 100d1000+30-30
  }
  :end

}



/e { 

  var %display = $null

  %2 = $calc($2)

  if (%2 > 200) { 
    if ($chan != $null) /msg $chan $nick: 200 dice or less. example: !ex 5 
    if ($chan == $null) { 
      if ($nick == $me) /say $nick : 200 dice or less. example: !ex 5 
      if ($nick != $me) /msg $nick $nick : 200 dice or less. example: !ex 5 
    } 
    goto end 
  } 
  var %iter = 0 
  var %tot = 0 

  ; force botch 
  var %bot = 0 
  var %when = $rand(1,%two) 

  var %target = 7 

  if (s isin $1) %target = $3 
  %display = %display $nick ( $+ %2 $+ )
  :next1 

  inc %iter 

  ; force botch 
  if (b isin $1) { 
    var %die = $rand(1,6) 
    if (%iter == %when) var %die = 1 
  } 
  elseif (o isin $1) {
    var %die = $rand(1,10) 
    var %die = %die + $rand(1,10)
    if (%die > 10) var %die = %die - 10
  }
  elseif (a isin $1) { 
    var %die = $rand(1,10) 
    if (%die > 5) var %die = %die - 5 
    else var %die = %die + 5 
  } 
  else { 
    var %die = $rand(1,11) 

    if (%die == 2) var %die = 1
    else if (%die == 1) var %die = 2
    else if (%die == 3) var %die = 9
    else if (%die == 9) var %die = 3
    else if (%die == 4) var %die = 10
    else if (%die == 10) {
      if ($calc($rand(1,2) - 1)) var %die = 2
      else var %die = 4
    }
    else if (%die == 11) var %die = 4

    if (%die == 3) var %die = 10
    else if (%die == 10) var %die = 3
  } 

  %display = %display $+ , %die 

  if (%die == 1) var %bot = %bot + 1 
  if (%die >= %target) var %tot = %tot + 1 
  if (m isin $1) var %tot = %tot 
  else if (%die == 10) var %tot = %tot + 1 

  if (%die == 1) inc %statsone  
  else if (%die == 2) inc %statstwo
  else if (%die == 3) inc %statsthree  
  else if (%die == 4) inc %statsfour
  else if (%die == 5) inc %statsfive 
  else if (%die == 6) inc %statssix 
  else if (%die == 7) inc %statsseven  
  else if (%die == 8) inc %statseight
  else if (%die == 9) inc %statsnine
  else if (%die == 10) inc %statsten 


  if (%iter < %2) goto next1 

  if (+ isin $3) { 
    var %p = $len($3) - 1 
    var %add = $right($3,%p) 
    if (%add > 0) && (%add < 30) var %tot = %tot + %add 
  } 
  if (+ isin $4) { 
    var %p = $len($4) - 1 
    var %add = $right($4,%p) 
    if (%add > 0) && (%add < 30) var %tot = %tot + %add 
  } 
  if (- isin $3) { 
    var %p = $len($3) - 1 
    var %add = $right($3,%p) 
    if (%add > 0) && (%add < 30) var %tot = %tot - %add 
  } 
  if (- isin $4) { 
    var %p = $len($4) - 1 
    var %add = $right($4,%p) 
    if (%add > 0) && (%add < 30) var %tot = %tot - %add 
  } 
  if (+WP isin $3) { 
    var %tot = %tot + 1
  } 

  if (%tot < 0) %tot = 0

  %display = %display $+ , Successes : %tot 
  if (%bot > 0) if (%tot == 0) %display = %display $+ , Botch 

  if ($chan != $null) /msg $chan %display 
  if ($chan == $null) { 
    if ($nick == $me) /say %display
    if ($nick != $me) /msg $nick %display
  } 
  :end 
} 

/wotg {
  var %reps = $2
  if ($left($3,1) == +) {
    var %sum = $3
    var %river = $4-
  }
  else {
    var %river = $3-
    var %sum = $null
  }

  if (%river) {

    var %tempriver = %river
    var %river = $null

    :riverrep
    var %match = $gettok(%tempriver,1,32)

    if ($match > 99) || ($match < 10) {
      echo 1 Error bad River, ignoring river
      var %river = $null
      goto riverabort
    }

    var %matchnum = $left(%match,1)
    var %matchdie = $right(%match,1)

    :matchrep
    var %river = %river %matchdie
    dec %matchnum
    if (%matchnum) goto matchrep

    var %tempriver = $deltok(%tempriver,1,32)
    if (%tempriver) goto riverrep

    :riverabort
  }


  var %inc = 1

  if (%reps > 150) {
    /msg $chan $nick : Warning! 150 dice maximum. Truncating.
    var %reps = 150
  }
  else if (%reps < 1) {
    /msg $chan $nick : Warning! 1 die minimum.
    var %reps = 1
  }


  var %die = $rand(1,10)
  var %dice = %die

  :reps

  if (%inc == %reps) goto end

  inc %inc

  var %die = $rand(1,10)
  var %dice = %dice %die

  goto reps

  :end

  var %display = $null 
  if ($findtok( %dice ,1,0,32)) var %display = %display $findtok( %dice ,1,0,32) $+ 1
  if ($findtok( %dice ,2,0,32)) var %display = %display $findtok( %dice ,2,0,32) $+ 2
  if ($findtok( %dice ,3,0,32)) var %display = %display $findtok( %dice ,3,0,32) $+ 3
  if ($findtok( %dice ,4,0,32)) var %display = %display $findtok( %dice ,4,0,32) $+ 4
  if ($findtok( %dice ,5,0,32)) var %display = %display $findtok( %dice ,5,0,32) $+ 5
  if ($findtok( %dice ,6,0,32)) var %display = %display $findtok( %dice ,6,0,32) $+ 6
  if ($findtok( %dice ,7,0,32)) var %display = %display $findtok( %dice ,7,0,32) $+ 7
  if ($findtok( %dice ,8,0,32)) var %display = %display $findtok( %dice ,8,0,32) $+ 8
  if ($findtok( %dice ,9,0,32)) var %display = %display $findtok( %dice ,9,0,32) $+ 9
  if ($findtok( %dice ,10,0,32)) var %display = %display $calc( $findtok( %dice ,10,0,32) * 10 )

  if (%display == $null) goto abort

  var %display = $sorttok( %display ,32,r)

  if (%sum) {
    var %tempdisp = %display
    var %display = $null
    var %stupid = -1
    :adding
    inc %stupid
    if (%stupid > 0) var %display = %display $+ , $gettok(%tempdisp,1,32) ( $+ $calc( $gettok(%tempdisp,1,32) + %sum) $+ )
    else var %display = %display $gettok(%tempdisp,1,32) ( $+ $calc( $gettok(%tempdisp,1,32) + %sum) $+ )
    if (%river != $null) {

      var %match = $gettok(%tempdisp,1,32)
      var %matchnum = $left(%match,1)
      var %matchdie = $right(%match,1)

      :rivermatchdie
      if ($findtok(%river,%matchdie,32)) {
        inc %matchnum
        var %river = $deltok(%river,$findtok(%river,%matchdie,1,32),32)
        if ($findtok(%river,%matchdie,32)) goto rivermatchdie

        var %display = %display �4 $+ ( $+ %matchnum $+ $calc( %matchdie + %sum ) $+ ) $+ �

      }
    }
    var %tempdisp = $deltok(%tempdisp,1,32)
    if (%tempdisp) goto adding
  }
  else if (%river != $null) {
    var %tempdisp = %display
    var %display = $null

    var %stupid = -1
    :riveradding
    inc %stupid

    var %match = $gettok(%tempdisp,1,32)
    var %matchnum = $left(%match,1)
    var %matchdie = $right(%match,1)

    :rivermatchdie2
    if ($findtok(%river,%matchdie,32)) {
      inc %matchnum
      var %river = $deltok(%river,$findtok(%river,%matchdie,1,32),32)
      if ($findtok(%river,%matchdie,32)) goto rivermatchdie2
      if (%stupid > 0) var %display = %display $+ , $gettok(%tempdisp,1,32) �4 $+ ( $+ %matchnum $+ %matchdie $+ ) $+ �
      else var %display = %display $gettok(%tempdisp,1,32) �4 $+ ( $+ %matchnum $+ %matchdie $+ ) $+ �

    }

    else if (%stupid > 0) var %display = %display $+ , $gettok(%tempdisp,1,32)    
    else var %display = %display $gettok(%tempdisp,1,32)
    var %tempdisp = $deltok(%tempdisp,1,32)
    if (%tempdisp) goto riveradding

  }

  if (o isin $1) var %display = %display - ( $+ %dice $+ )

  /msg $chan $nick ( $+ %reps $+ ): %display

  :abort

}


add this to Popups > 2 Channel



dice
.active: {
  /writeini ws.ini $network $chan on
  /msg $chan �6Dice Script Active
}
.deactive: {
  /writeini ws.ini $network $chan off
    /msg $chan �6Dice Script Deactivated
}


Add this to remote


on 1:TEXT:*Dice Script Active*:#: {  
  if ($readini(ws.ini, $network, $chan) != off) {
    /writeini ws.ini $network $chan off
    /msg $chan �6Dice Script Deactivated
  }
}

on 1:TEXT:!roll*:*: if ($readini(ws.ini, $network, $chan) != off) /roll $2-
on 1:TEXT:!e*:*: if ($readini(ws.ini, $network, $chan) != off) /e $1-
on 1:TEXT:!w*:*: if ($readini(ws.ini, $network, $chan) != off) /wotg $1-
on 1:TEXT:!n*:*: if ($readini(ws.ini, $network, $chan) != off) /nwod $1-

on 1:INPUT:* {
  var %length = $len($1-)
  if (%length > 400) {
    haltdef
    :say

    if ($len($1-) > 400) {
      var %lenny = $calc($pos($1-,$chr(32),$calc($count($left($1-,400),$chr(32)) -1))))

      if ($left($1-,3) == /me) $left($1-,%lenny)
      else /say $left($1-,%lenny)
      dec %length %lenny

      if (%length > 0) {
        if ($left($1-,3) == /me) { tokenize 32 $1 $mid($1-,$calc(%lenny + 1)) | goto say }
        else { tokenize 32 $mid($1-,$calc(%lenny + 1)) | goto say }
      }
      else halt   
    }
    else {
      if ($left($1-,3) == /me) $left($1-,%lenny)
      else /say $left($1-,%lenny)
    }
  }

  if ($readini(ws.ini, $network, $chan) == on) {
    if (!roll isin $1) /roll $2-
    if (!e isin $1) /e $1-
    if (!w isin $1) /wotg $1-
    if (!d isin $1) /sbs $1-
    if (!n isin $1) /nwod $1-
  }
}