Dice Attack Roller
A dice rolling command that accounts for various modifications, such as miss percentage and armor class.
Functions:
add(),
after(),
ansi(),
before(),
bound(),
cand(),
cor(),
dec(),
die(),
div(),
edit(),
elements(),
emit(),
eq(),
extract(),
fdiv(),
firstof(),
fold(),
gt(),
gte(),
if(),
inc(),
iter(),
itext(),
ljust(),
lmath(),
lnum(),
localize(),
lt(),
match(),
max(),
min(),
mod(),
modulo(),
mul(),
nor(),
null(),
parse(),
pemit(),
power(),
rand(),
regeditall(),
regeditalli(),
regmatch(),
regraballi(),
remainder(),
remit(),
repeat(),
rest(),
rjust(),
s(),
setq(),
setr(),
shuffle(),
sort(),
space(),
spellnum(),
stripansi(),
strlen(),
sub(),
switch(),
u(),
v(),
val(),
words().
Features:
regexp commands.
Instructions
Copy and paste the below code into a compatible MUSH or MUX.
MUSHCode for Dice Attack Roller
@create Dice Attack Roller (DAR)
@lock Dice Attack Roller (DAR)==me
@set Dice Attack Roller (DAR) = !NO_COMMAND
&ALIAS Dice Attack Roller (DAR)=DAR
@set Dice Attack Roller (DAR)/ALIAS=no_command visual prefixmatch
&CMD Dice Attack Roller (DAR)=
&CMD`CHANCE Dice Attack Roller (DAR)=$^\+Chance (\d+)d(\d+) ?= ?(\d+)$:@pemit %#=firstof(setr(0,lmath(add,iter(lnum(0,div(sub(%3,%1),%2)),mul(power(-1,##),u(Fun`Combination,%1,##),u(Fun`Combination,sub(sub(%3,mul(%2,##)),1),sub(%1,1))))))/(%2^%1),Error!)
@set Dice Attack Roller (DAR)/CMD`CHANCE=regexp
&CMD`PARSE Dice Attack Roller (DAR)=$^\+Parse(?\:/(\w+))?(?\:/(\w+))? (.+)$:think [setq(match(0 Silent Private,%1*),1)][setq(match(0 Silent Private,%2*),1)][setq(0,%va %~ rolls [setr(i,([edit(%3,%B,)]))])][if(%q3,pemit(%#,%q0),emit(%q0))][u(Fun`Parse)]
@set Dice Attack Roller (DAR)/CMD`PARSE=regexp
&CMD_DAMAGE Dice Attack Roller (DAR)=$^\+Damage(/S(?\:ilent?|ile?|i)?)? (.*)$:@break u(Err_1,%2,Test2)[u(Err_2,%2)];@[if(%1,p,r)]emit/silent if(%1,%#,%L)=%N rolls up %2: [u(Fun_Damg,%2)]
@set Dice Attack Roller (DAR)/CMD_DAMAGE=regexp
&CMD_DDROLL Dice Attack Roller (DAR)=$^\+DDR(?\:ol?l?)?(/S(?\:ilent?|ile?|i)?)? (.*)$:@break u(Err_1,%2,Test1)[u(Err_2,after(%0,=))];@[if(%1,p,r)]emit/silent if(%1,%#,%L)=u(Fun_Header)[iter(%2,u(Fun_QReg,itext(0))[u(Fun_Show)]%R[if(eq(#@,words(%2,&)),ansi(hr,repeat(=,75)),%qz)],&,)]
@set Dice Attack Roller (DAR)/CMD_DDROLL=regexp
&CMD_DICE Dice Attack Roller (DAR)=$^(?\:\+|`)(Rol?l?|Fl(?\:ip?)?|Di(?\:ce?)?)(/S(?\:ilent?|ile?|i)?)?(?\: (\d+)(?\: |d)(\d+)(?\:(?\: )?(\+|-)(?\: )?([0-9]+))?)?$:@break if(cand(gt(%3,0),lt(%3,306),gte(%4,0)),,if(nor(strlen(%3),strlen(%4)),remit(%L,%N performs a [switch(%1,F*,coin flip,generic roll)].%R[if(rand(2),Success!,Failure!)])1,pemit(%#,Invalid imput.)1));@[if(%2,p,r)]emit/silent if(%2,%#,%L)=if(%2,You roll,%N rolls) [switch(%3,1,a,spellnum(%3))] [spellnum(%4)]-sided [switch(%3,1,die,dice)]:%B[iter(if(gt(%3,20),iter(lnum(1,div(%3,20)),die(20,%4,1)) [switch(die(remainder(%3,20),%4,1),#-1 NUMBER OUT OF RANGE,,#$)],die(%3,%4,1)),<[setq(0,add(if(%q0,%q0,0),##))]##>)] = %q0 [if(%5,%5 %6 = [lmath(switch(%5,+,add,sub), %q0 %6)])]
@set Dice Attack Roller (DAR)/CMD_DICE=regexp
&CMD_STATS Dice Attack Roller (DAR)=$^\+Stats?(/Silent?|/Sile?|/Si?|/)?$:@[if(%1,p,r)]emit/silent if(%1,%#,%L)=%N rolls 5 6-sided dice six times:%R[iter(lnum(6),shuffle(ansi(hr,setr(1,elements(setr(0,sort(die(5,6,1),n)),1))) [ansi(hr,setr(2,elements(%q0,2)))] [setr(3,extract(%q0,3,3))]) = [ljust(lmath(add,%q0),2)] - [ljust(ansi(hr,add(%q1,%q2)),2)] = [ansi(hg,lmath(add,%q3))],,%R)]
@set Dice Attack Roller (DAR)/CMD_STATS=regexp
&CMD_VORPAL Dice Attack Roller (DAR)=$^\+Vorpal ((?\:\+|-)?\d+)\s*\|\s*(-?\d+)$:@pemit %#=Chance for a Vorpal Strike with an Attack Bonus of [ansi(hw,%1)] against an AC of [ansi(hw,%2)]: [bound(mul(setr(0,fdiv(sub(20,bound(sub(%2,%1),0,20)),20)),5),0,100)]%%%R(%q0 * 1/20)
@set Dice Attack Roller (DAR)/CMD_VORPAL=regexp
&DESCRIBE Dice Attack Roller (DAR)=+DDroll <Attack mods. Delimiter: /><@ Miss Percent><| Armor Class><= Damage>%RUsing '&' after damage allows for a new line, allowing for different mods, miss percent, armor class, or damage. Example:%R%R+ddroll +15 @ 20%% | 17 = 4d305 - 20d6 + 5 & -1/-2/-3/-4/-5/-6 @ 50%% | 20 = 1d3%R%RUse +parse <paranthesis, #d#, and/or * / + -> to calculate.%R +Parse accepts /Silent and /Private switches.%R /Silent quiets all the parsing normally seen.%R /Private pemits only to the enactor, instead of emitting.%R %B[ansi(hr,red)] numbers are lower than average for the roll,%R %B[ansi(hb,blue)] numbers are average,%R %Band [ansi(hg,green)] numbers are above average.%R%R+Chance xdy=n shows the probability of x dice with y sides totalling to n.
@set Dice Attack Roller (DAR)/DESCRIBE=no_command visual prefixmatch public nearby
&ERR_1 Dice Attack Roller (DAR)=if(regmatch(%0,v(reg_%1)),setq(0,O),pemit(%#,Invalid input.)[setq(0,Also\, o)]1)
&ERR_2 Dice Attack Roller (DAR)=if(lmath(add,iter(regraballi(edit(%0,-,%B,+,%B),\\d+d\\d+),gt(before(##,d),20) [gt(after(##,d),250)])),pemit(%#,%q0ne of the dice was too high. 20d250 is the limit.)1)
&FUN Dice Attack Roller (DAR)=
&FUN`AVERAGE Dice Attack Roller (DAR)=mul(fdiv(add(%1,1),2),%0)
&FUN`BRACKET_DEPTH Dice Attack Roller (DAR)=[setq(0,0)][lmath(max,regeditall(%0,\[^\(\)\],,(\\\(|\\\)),[setq(z,$1)][setr(0,add(%q0,switch(%qz,\(,1,\),-1)))]%B))]
&FUN`COLOR_DICE Dice Attack Roller (DAR)=setq(y,u(Fun`Average,stripansi(%0),stripansi(%1)))[switch(u(Fun`Dice,stripansi(%0),stripansi(%1)),>%qy,ansi(hg,#$),%qy,ansi(hb,#$),<%qy,ansi(hr,#$))]
&FUN`COMBINATION Dice Attack Roller (DAR)=switch(1,cor(eq(%1,0),eq(%1,%0)),1,cor(lt(%0,0),lt(%1,0),lt(%0,%1)),0,div(lmath(mul,lnum(%0,inc(max(%1,sub(%0,%1))))),lmath(mul,lnum(min(%1,sub(%0,%1)),1))))
&FUN`DICE Dice Attack Roller (DAR)=lmath(add,iter(rest(lnum(0,div(%0,20))),die(20,%1)) [if(modulo(%0,20),die(modulo(%0,20),%1))])
&FUN`ECHO Dice Attack Roller (DAR)=if(%q2,,if(%q3,pemit(%#,%va %qa)[pemit(%#,%va %qi)],emit(%va %qa)[emit(%va %qi)]))
&FUN`MAX_CALLS_NEEDED Dice Attack Roller (DAR)=localize([setq(i,0)][setq(f,1)][setq(r,regeditall(%qb,%B,$,\\$,|))][lmath(add,12)][pemit(#3,setr(x,regeditall(\(%0\),(\\d+|\\s+),,\\\(\\\),,(%qr),1,\[\\\(1\\\)\],switch($0,\(,%qf [setr(i,inc(%qi))]_,1,[setq(f,inc(%qf))],\),%qf [setq(f,1)][setr(i,dec(%qi))]_))0))][lmath(add,regeditall(sort(%qx,n),((\\d+)_\\d+(%B\\2_\\d+)*),[lmath(add,regeditall($1,\\d+_(\\d+),$1))]))]
&FUN`PARSE Dice Attack Roller (DAR)=[setq(n,-?\\d+)][iter(lnum(u(Fun`Bracket_Depth,%qi)),[setq(a,regeditalli(%qi,v(Reg`With),u(Fun`Parse_Dice,$1)))][setq(i,regeditall(stripansi(%qa),v(Reg`Without),u(Fun`Parse_Inner,$1)))][u(Fun`Echo)],,)][if(%q2,if(%q3,pemit(%#,%va %qi),emit(%va %qi)))]
&FUN`PARSE_DICE Dice Attack Roller (DAR)=regeditalli(%0,\\d+(d\\d+)+,fold(Fun`Color_Dice,edit($0,d,%B)))
&FUN`PARSE_INNER Dice Attack Roller (DAR)=regeditall(%0,(%qn(\\\*%qn)+),lmath(mul,$1,*),(%qn(/%qn)+),lmath(div,$1,/),(%qn(\\\+%qn)+),lmath(add,$1,+),(%qn(-%qn)+),lmath(sub,$1,-))
&FUN_ATKR Dice Attack Roller (DAR)=<[rjust(ansi(hm,setr(x,die(1,20))),3)][rjust(ansi(hc,if(gt(%0,-1),+)[val(%0)]),6)] | [rjust(ansi(hr,%q2),4)] = [if(setr(y,gt(add(%qx,%0),%q2)),ansi(hg,Hit%B),ansi(hr,Miss))]>
&FUN_AVRG Dice Attack Roller (DAR)=mul(fdiv(add(%1,1),2),%0)
&FUN_CLRN Dice Attack Roller (DAR)=setq(y,u(Fun_Avrg,%0,%1))[switch(die(%0,%1),>%qy,ansi(hg,#$),%qy,ansi(hb,#$),<%qy,ansi(hr,#$))]
&FUN_DAMG Dice Attack Roller (DAR)=<[setr(x,regeditalli(%0,(\\d+)d(\\d+),u(Fun_Clrn,$1,$2)))] = [null(regmatch(setr(x,stripansi(%qx)),\\d+,a))][setq(b,0)][null(regeditall(%qx,((\\+|-)\\d+),setq(a,add(%qa,$1))))]%qa>
&FUN_HEADER Dice Attack Roller (DAR)=%R[ansi(hw,Dice Throws)]%R[setr(z,ansi(hb,repeat(-,75))%R)] %B 1d100 Vs. Miss %%[space(7)]Attack Roll Vs. AC[space(14)]Damage[space(10)]%R[ansi(hr,repeat(=,22) [repeat(=,25)] [repeat(=,26)])]%R
&FUN_MISS Dice Attack Roller (DAR)=<[rjust(ansi(hm,setr(x,die(1,100))),4)] | [rjust(ansi(hr,%q1)[ansi(nr,%%)],5)] = [if(setr(y,gt(%qx,%q1)),ansi(hg,Hit%B),ansi(hr,Miss))] >
&FUN_QREG Dice Attack Roller (DAR)=setq(0,before(before(before(%0,=),|),@))[null(regmatch(%0,@\\s*(\\d\{1,3\})%%?,-1 1))][setq(1,switch(%q1,,0,#$))][null(regmatch(%0,\\|\\s*(\\d+),-1 2))][setq(2,switch(%q2,,0,#$))][setq(3,edit(after(%0,=),%B,))]
&FUN_SHOW Dice Attack Roller (DAR)=iter(%q0,u(Fun_Miss) [if(%qy,u(Fun_Atkr,##))] [if(%qy,u(Fun_Damg,%q3))],/,%R)
® Dice Attack Roller (DAR)=
®`WITH Dice Attack Roller (DAR)=(\([^\(\)]*\))
®`WITHOUT Dice Attack Roller (DAR)=\(([^\(\)]*)\)
®_TEST1 Dice Attack Roller (DAR)=((/?((\+|-)\d+)?(/((\+|-)\d+)?)*)\s*(@\s*\d\{1,3\}\%?)?\s*(\|\s*\d+\s*)?=\s*(\d+d\d+|\d+)(\s*(\+|-)\s*(\d+d\d+|\d+))*)(\s*&\s*((/?((\+|-)\d+)?(/((\+|-)\d+)?)*)\s*(@\s*\d\{1,3\}\%?)?\s*(\|\s*\d+\s*)?=\s*(\d+d\d+|\d+)(\s*(\+|-)\s*(\d+d\d+|\d+))*))*
®_TEST2 Dice Attack Roller (DAR)=\s*(\d+d\d+|\d+)(\s*(\+|-)\s*(\d+d\d+|\d+))*
&REM Dice Attack Roller (DAR)=%%q0 = Attack mod(s)%R%%q1 = Miss Percentage%R%%q2 = Armor Class%R%%q3 = Damage%R%%qx = Temporary die roll storage%R%%qy = Continue?%R%%qa = Positive number total%R%%qb = Negative number total%R%%qz = Breakline
&VA Dice Attack Roller (DAR)=DAR:
look Dice Attack Roller (DAR)
@lock Dice Attack Roller (DAR)==me
@set Dice Attack Roller (DAR) = !NO_COMMAND
&ALIAS Dice Attack Roller (DAR)=DAR
@set Dice Attack Roller (DAR)/ALIAS=no_command visual prefixmatch
&CMD Dice Attack Roller (DAR)=
&CMD`CHANCE Dice Attack Roller (DAR)=$^\+Chance (\d+)d(\d+) ?= ?(\d+)$:@pemit %#=firstof(setr(0,lmath(add,iter(lnum(0,div(sub(%3,%1),%2)),mul(power(-1,##),u(Fun`Combination,%1,##),u(Fun`Combination,sub(sub(%3,mul(%2,##)),1),sub(%1,1))))))/(%2^%1),Error!)
@set Dice Attack Roller (DAR)/CMD`CHANCE=regexp
&CMD`PARSE Dice Attack Roller (DAR)=$^\+Parse(?\:/(\w+))?(?\:/(\w+))? (.+)$:think [setq(match(0 Silent Private,%1*),1)][setq(match(0 Silent Private,%2*),1)][setq(0,%va %~ rolls [setr(i,([edit(%3,%B,)]))])][if(%q3,pemit(%#,%q0),emit(%q0))][u(Fun`Parse)]
@set Dice Attack Roller (DAR)/CMD`PARSE=regexp
&CMD_DAMAGE Dice Attack Roller (DAR)=$^\+Damage(/S(?\:ilent?|ile?|i)?)? (.*)$:@break u(Err_1,%2,Test2)[u(Err_2,%2)];@[if(%1,p,r)]emit/silent if(%1,%#,%L)=%N rolls up %2: [u(Fun_Damg,%2)]
@set Dice Attack Roller (DAR)/CMD_DAMAGE=regexp
&CMD_DDROLL Dice Attack Roller (DAR)=$^\+DDR(?\:ol?l?)?(/S(?\:ilent?|ile?|i)?)? (.*)$:@break u(Err_1,%2,Test1)[u(Err_2,after(%0,=))];@[if(%1,p,r)]emit/silent if(%1,%#,%L)=u(Fun_Header)[iter(%2,u(Fun_QReg,itext(0))[u(Fun_Show)]%R[if(eq(#@,words(%2,&)),ansi(hr,repeat(=,75)),%qz)],&,)]
@set Dice Attack Roller (DAR)/CMD_DDROLL=regexp
&CMD_DICE Dice Attack Roller (DAR)=$^(?\:\+|`)(Rol?l?|Fl(?\:ip?)?|Di(?\:ce?)?)(/S(?\:ilent?|ile?|i)?)?(?\: (\d+)(?\: |d)(\d+)(?\:(?\: )?(\+|-)(?\: )?([0-9]+))?)?$:@break if(cand(gt(%3,0),lt(%3,306),gte(%4,0)),,if(nor(strlen(%3),strlen(%4)),remit(%L,%N performs a [switch(%1,F*,coin flip,generic roll)].%R[if(rand(2),Success!,Failure!)])1,pemit(%#,Invalid imput.)1));@[if(%2,p,r)]emit/silent if(%2,%#,%L)=if(%2,You roll,%N rolls) [switch(%3,1,a,spellnum(%3))] [spellnum(%4)]-sided [switch(%3,1,die,dice)]:%B[iter(if(gt(%3,20),iter(lnum(1,div(%3,20)),die(20,%4,1)) [switch(die(remainder(%3,20),%4,1),#-1 NUMBER OUT OF RANGE,,#$)],die(%3,%4,1)),<[setq(0,add(if(%q0,%q0,0),##))]##>)] = %q0 [if(%5,%5 %6 = [lmath(switch(%5,+,add,sub), %q0 %6)])]
@set Dice Attack Roller (DAR)/CMD_DICE=regexp
&CMD_STATS Dice Attack Roller (DAR)=$^\+Stats?(/Silent?|/Sile?|/Si?|/)?$:@[if(%1,p,r)]emit/silent if(%1,%#,%L)=%N rolls 5 6-sided dice six times:%R[iter(lnum(6),shuffle(ansi(hr,setr(1,elements(setr(0,sort(die(5,6,1),n)),1))) [ansi(hr,setr(2,elements(%q0,2)))] [setr(3,extract(%q0,3,3))]) = [ljust(lmath(add,%q0),2)] - [ljust(ansi(hr,add(%q1,%q2)),2)] = [ansi(hg,lmath(add,%q3))],,%R)]
@set Dice Attack Roller (DAR)/CMD_STATS=regexp
&CMD_VORPAL Dice Attack Roller (DAR)=$^\+Vorpal ((?\:\+|-)?\d+)\s*\|\s*(-?\d+)$:@pemit %#=Chance for a Vorpal Strike with an Attack Bonus of [ansi(hw,%1)] against an AC of [ansi(hw,%2)]: [bound(mul(setr(0,fdiv(sub(20,bound(sub(%2,%1),0,20)),20)),5),0,100)]%%%R(%q0 * 1/20)
@set Dice Attack Roller (DAR)/CMD_VORPAL=regexp
&DESCRIBE Dice Attack Roller (DAR)=+DDroll <Attack mods. Delimiter: /><@ Miss Percent><| Armor Class><= Damage>%RUsing '&' after damage allows for a new line, allowing for different mods, miss percent, armor class, or damage. Example:%R%R+ddroll +15 @ 20%% | 17 = 4d305 - 20d6 + 5 & -1/-2/-3/-4/-5/-6 @ 50%% | 20 = 1d3%R%RUse +parse <paranthesis, #d#, and/or * / + -> to calculate.%R +Parse accepts /Silent and /Private switches.%R /Silent quiets all the parsing normally seen.%R /Private pemits only to the enactor, instead of emitting.%R %B[ansi(hr,red)] numbers are lower than average for the roll,%R %B[ansi(hb,blue)] numbers are average,%R %Band [ansi(hg,green)] numbers are above average.%R%R+Chance xdy=n shows the probability of x dice with y sides totalling to n.
@set Dice Attack Roller (DAR)/DESCRIBE=no_command visual prefixmatch public nearby
&ERR_1 Dice Attack Roller (DAR)=if(regmatch(%0,v(reg_%1)),setq(0,O),pemit(%#,Invalid input.)[setq(0,Also\, o)]1)
&ERR_2 Dice Attack Roller (DAR)=if(lmath(add,iter(regraballi(edit(%0,-,%B,+,%B),\\d+d\\d+),gt(before(##,d),20) [gt(after(##,d),250)])),pemit(%#,%q0ne of the dice was too high. 20d250 is the limit.)1)
&FUN Dice Attack Roller (DAR)=
&FUN`AVERAGE Dice Attack Roller (DAR)=mul(fdiv(add(%1,1),2),%0)
&FUN`BRACKET_DEPTH Dice Attack Roller (DAR)=[setq(0,0)][lmath(max,regeditall(%0,\[^\(\)\],,(\\\(|\\\)),[setq(z,$1)][setr(0,add(%q0,switch(%qz,\(,1,\),-1)))]%B))]
&FUN`COLOR_DICE Dice Attack Roller (DAR)=setq(y,u(Fun`Average,stripansi(%0),stripansi(%1)))[switch(u(Fun`Dice,stripansi(%0),stripansi(%1)),>%qy,ansi(hg,#$),%qy,ansi(hb,#$),<%qy,ansi(hr,#$))]
&FUN`COMBINATION Dice Attack Roller (DAR)=switch(1,cor(eq(%1,0),eq(%1,%0)),1,cor(lt(%0,0),lt(%1,0),lt(%0,%1)),0,div(lmath(mul,lnum(%0,inc(max(%1,sub(%0,%1))))),lmath(mul,lnum(min(%1,sub(%0,%1)),1))))
&FUN`DICE Dice Attack Roller (DAR)=lmath(add,iter(rest(lnum(0,div(%0,20))),die(20,%1)) [if(modulo(%0,20),die(modulo(%0,20),%1))])
&FUN`ECHO Dice Attack Roller (DAR)=if(%q2,,if(%q3,pemit(%#,%va %qa)[pemit(%#,%va %qi)],emit(%va %qa)[emit(%va %qi)]))
&FUN`MAX_CALLS_NEEDED Dice Attack Roller (DAR)=localize([setq(i,0)][setq(f,1)][setq(r,regeditall(%qb,%B,$,\\$,|))][lmath(add,12)][pemit(#3,setr(x,regeditall(\(%0\),(\\d+|\\s+),,\\\(\\\),,(%qr),1,\[\\\(1\\\)\],switch($0,\(,%qf [setr(i,inc(%qi))]_,1,[setq(f,inc(%qf))],\),%qf [setq(f,1)][setr(i,dec(%qi))]_))0))][lmath(add,regeditall(sort(%qx,n),((\\d+)_\\d+(%B\\2_\\d+)*),[lmath(add,regeditall($1,\\d+_(\\d+),$1))]))]
&FUN`PARSE Dice Attack Roller (DAR)=[setq(n,-?\\d+)][iter(lnum(u(Fun`Bracket_Depth,%qi)),[setq(a,regeditalli(%qi,v(Reg`With),u(Fun`Parse_Dice,$1)))][setq(i,regeditall(stripansi(%qa),v(Reg`Without),u(Fun`Parse_Inner,$1)))][u(Fun`Echo)],,)][if(%q2,if(%q3,pemit(%#,%va %qi),emit(%va %qi)))]
&FUN`PARSE_DICE Dice Attack Roller (DAR)=regeditalli(%0,\\d+(d\\d+)+,fold(Fun`Color_Dice,edit($0,d,%B)))
&FUN`PARSE_INNER Dice Attack Roller (DAR)=regeditall(%0,(%qn(\\\*%qn)+),lmath(mul,$1,*),(%qn(/%qn)+),lmath(div,$1,/),(%qn(\\\+%qn)+),lmath(add,$1,+),(%qn(-%qn)+),lmath(sub,$1,-))
&FUN_ATKR Dice Attack Roller (DAR)=<[rjust(ansi(hm,setr(x,die(1,20))),3)][rjust(ansi(hc,if(gt(%0,-1),+)[val(%0)]),6)] | [rjust(ansi(hr,%q2),4)] = [if(setr(y,gt(add(%qx,%0),%q2)),ansi(hg,Hit%B),ansi(hr,Miss))]>
&FUN_AVRG Dice Attack Roller (DAR)=mul(fdiv(add(%1,1),2),%0)
&FUN_CLRN Dice Attack Roller (DAR)=setq(y,u(Fun_Avrg,%0,%1))[switch(die(%0,%1),>%qy,ansi(hg,#$),%qy,ansi(hb,#$),<%qy,ansi(hr,#$))]
&FUN_DAMG Dice Attack Roller (DAR)=<[setr(x,regeditalli(%0,(\\d+)d(\\d+),u(Fun_Clrn,$1,$2)))] = [null(regmatch(setr(x,stripansi(%qx)),\\d+,a))][setq(b,0)][null(regeditall(%qx,((\\+|-)\\d+),setq(a,add(%qa,$1))))]%qa>
&FUN_HEADER Dice Attack Roller (DAR)=%R[ansi(hw,Dice Throws)]%R[setr(z,ansi(hb,repeat(-,75))%R)] %B 1d100 Vs. Miss %%[space(7)]Attack Roll Vs. AC[space(14)]Damage[space(10)]%R[ansi(hr,repeat(=,22) [repeat(=,25)] [repeat(=,26)])]%R
&FUN_MISS Dice Attack Roller (DAR)=<[rjust(ansi(hm,setr(x,die(1,100))),4)] | [rjust(ansi(hr,%q1)[ansi(nr,%%)],5)] = [if(setr(y,gt(%qx,%q1)),ansi(hg,Hit%B),ansi(hr,Miss))] >
&FUN_QREG Dice Attack Roller (DAR)=setq(0,before(before(before(%0,=),|),@))[null(regmatch(%0,@\\s*(\\d\{1,3\})%%?,-1 1))][setq(1,switch(%q1,,0,#$))][null(regmatch(%0,\\|\\s*(\\d+),-1 2))][setq(2,switch(%q2,,0,#$))][setq(3,edit(after(%0,=),%B,))]
&FUN_SHOW Dice Attack Roller (DAR)=iter(%q0,u(Fun_Miss) [if(%qy,u(Fun_Atkr,##))] [if(%qy,u(Fun_Damg,%q3))],/,%R)
® Dice Attack Roller (DAR)=
®`WITH Dice Attack Roller (DAR)=(\([^\(\)]*\))
®`WITHOUT Dice Attack Roller (DAR)=\(([^\(\)]*)\)
®_TEST1 Dice Attack Roller (DAR)=((/?((\+|-)\d+)?(/((\+|-)\d+)?)*)\s*(@\s*\d\{1,3\}\%?)?\s*(\|\s*\d+\s*)?=\s*(\d+d\d+|\d+)(\s*(\+|-)\s*(\d+d\d+|\d+))*)(\s*&\s*((/?((\+|-)\d+)?(/((\+|-)\d+)?)*)\s*(@\s*\d\{1,3\}\%?)?\s*(\|\s*\d+\s*)?=\s*(\d+d\d+|\d+)(\s*(\+|-)\s*(\d+d\d+|\d+))*))*
®_TEST2 Dice Attack Roller (DAR)=\s*(\d+d\d+|\d+)(\s*(\+|-)\s*(\d+d\d+|\d+))*
&REM Dice Attack Roller (DAR)=%%q0 = Attack mod(s)%R%%q1 = Miss Percentage%R%%q2 = Armor Class%R%%q3 = Damage%R%%qx = Temporary die roll storage%R%%qy = Continue?%R%%qa = Positive number total%R%%qb = Negative number total%R%%qz = Breakline
&VA Dice Attack Roller (DAR)=DAR:
look Dice Attack Roller (DAR)