this is my first script. use !roll X Y Z where X is how many times you roll, Y is how many sides there is. and Z is bonus/penalty. example: !roll 2 20 +2 will roll 2D20 +2.
also the script wont say uneeded lines. if you just say !roll 1 20 it will say 1 line, or 2 with !roll 2 20 or !roll 1 20 +2, and 3 with !roll 2 20 -2 for example.
also !dc X Y will roll against X 20 sided die with Y bonus and tell you if you succeed or fail.
!dx X Y will roll against a random roll with X bonus while you have Y bonus.
on *:TEXT:!roll*:#: {
if ($2- == $null) {
msg # $nick rolled a 1d6: $rand(1,6)
}
else {
/set -l %dice $2
set -l %bonus $4
set -l %sides $3
set -l %i 0
set -l %total 0
set -l %average 0
set -l %line rolled %dice $+ d $+ %sides $+ :
set -l %line1 after bonuses:
if ($2 !isnum) || ($3 !isnum) {
msg # INVALID PARAMETERS!
halt
}
if (%dice <= 0) || %sides <= 0) {
msg # INVALID PARAMETERS!
halt
}
while (%i < %dice) {
inc %i 1
%s = $calc(%s + 1)
%roll = $rand(1,%sides)
%rollb = $calc(%roll + %bonus)
%line = %line %roll
%line1 = %line1 %rollb
%total = $calc(%total + %rollb)
%totaln = $calc(%totaln + %roll)
}
%avarage = $calc(%totaln / %dice)
msg $chan $nick %line
if ($4 != $null) msg $chan %line1
if ($2 >= 2 ) msg # $nick $+ , Total: %total $+ , before bonus: %totaln $+ , avarage: %avarage
unset %total
unset %totaln
}
}
on *:text:!dc*:#: {
set -l %against $2
set -l %bonus $3
%roll = $rand(1,20)
%rollb = $calc(%roll + %bonus)
%margin = $calc(%rollb - %against)
{
if (%margin >= 1 ) msg $chan $nick $+ , against DC $+ %against and succeded by %margin (rolled: %rollb $+ )
elseif (-1 >= %margin ) { %margin = $calc(%margin * -1) | msg $chan $nick $+ , against DC $+ %against you faild by %margin (rolled: %rollb $+ )
elseif (%margin == 0 ) msg $chan $nick $+ , you tied with DC $+ %against
}
}
}
on *:text:!dx*:#: {
set -l %bonus $3
set -l %bonush $2
%roll = $rand(1,20)
%rollb = $calc(%roll + %bonus)
%rollh = $rand(1,20)
%rollhb = $calc(%rollh + %bonush)
%margin = $calc(%rollb - %rollhb)
{
if (%margin >= 1 ) msg $chan against DC $+ %rollhb and succeded by %margin (rolled: %rollb $+ )
elseif (-1 >= %margin ) { %margin = $calc(%margin * -1) | msg $chan against DC $+ %rollhb you faild by %margin (rolled: %rollb $+ )
elseif (%margin == 0 ) msg $chan you tied with DC $+ %rollhb
}
}