Common request: Simple dice games.
These mIRC dice scripts allow you to roll a 100-sided die against a host or have a dice duel against an opponent by rolling two six-sided dice each.
Syntax:
!(2-9)dd nick1 nick2 bet_amount
!stopdd nick
!55x2 nick bet_amount
55x2 games are always against the host. The bettor rolls over 55 to win 2x the bet, and under 56 to lose it.
Dice duel -
Two players pay the host and then roll against each other. The winner receives the pot from the host.
(2-9) - Optionally specify the number of dice for the dice duel.
alias -l whitelist return #chan1,#chan2,#chanN | ;Set allowed channels here.
alias -l mynicks return nick1,nick2,nick3 | ;Set the nicknames this script can be used with in the same format as the channel list
alias -l canhost return ohv | ;Who can host: 'ohvr' (op, halfop, voice, regular) are the only valid options
alias -l dd_pot_multiplier return 1.9 | ;[Host's cut] - Winner gets (bet_amount * pot_multiplier)
;**************************************************************
;* Written by Travis (Yawhatnever) - irc.swiftirc.net #mSL *
;* This script goes in an empty remotes file. *
;**************************************************************
on *:text:$($allowed):#:noop
on $*:text:/^[!@.]55x2\b/Si:$($whitelist):{
if (!$ishost($nick)) msg.format ! $nick # [Error] You must be a host to use that command.
elseif (!$3) msg.format ! $nick # [Error] Syntax: &c3;!55x2/dice &norm;<&c1;Name of player&norm;> <&c4;Amount of bet&norm;>
elseif ($2 == $nick) msg.format ! $nick # [Error] You can't bet against yourself!
elseif ($2 == $me) msg.format ! $nick # [Error] You can't roll against me!
elseif ($2 !ison #) msg.format ! $nick # [Error] Player must be on the channel.
elseif (!$isformat($3)) msg.format ! $nick # [Error] Invalid bet amount. Input must be a cash amount in GP/K/M/B.
else {
var %roll $rand(1, 100),%w $iif(%roll < 56, $nick, $2)
msg.format @ $nick # [55x2]&c2; $nick &norm;vs&c1; $2 &norm;- Pot:&c4; $pot($3).full
msg.format @ $nick # [55x2]&c2; $nick &norm;rolled a&c5; %roll &norm;on the percentile die!
msg.format @ $nick # [55x2]&c1; $2 $iif($2 == %w, 03won, 04lost) &norm;the&c4; $iif($2 == %w, $pot($3).full pot,$kmb.to($kmb.from($3)) bet) &norm;as&c2; $nick &norm;rolled $iif($2 == %w, 03over, 04under) &norm;55.
}
}
on $*:text:/^[!@.]([2-9])?dd\b/Si:$($whitelist):{
var %dice $iif($regml(1), $v1, 2)
if (!$ishost($nick)) msg.format ! $nick # [Error] You must be a &c2;host &norm;to use that command.
elseif ($2 == $3) || ($dd_info($2)) || ($dd_info($3)) || (!$4) msg.format ! $nick # [Error] Syntax: &c3;!dd &norm;<&c1;Player1&norm;> <&c1;Player2&norm;> <&c4;Amount of Pot&norm;> $!(|) Both players must be on the channel and may only be in one duel at a time.&c2; $iif($dd_info($2).vs || $dd_info($3).vs,&c1; $+ $ifmatch &norm;is already in a duel with&c1; $dd_info($ifmatch).vs $+ &norm;.)
elseif ($2 !ison #) || ($3 !ison #) msg.format ! $nick # [Error]&c1; $v1 &norm;is not on the channel.
elseif ($2 == $me) || ($3 == $me) msg.format ! $nick # [Error] I can't enter a duel!
elseif (!$isformat($4)) msg.format ! $nick # [Error] Invalid bet amount. Input must be a cash amount in GP/K/M/B.
else {
inc -e %dd_id
set -e %dd_ $+ # $+ $2 $+($3, /, $kmb.from($4), /, $nick, /, %dice, /, %dd_id)
set -e %dd_ $+ # $+ $3 $+($2, /, $kmb.from($4), /, $nick, /, %dice, /, %dd_id)
msg.format @ $nick # [Dice Duel]&c1; $2 &norm;vs.&c1; $3 &norm;- Pot:&c4; $dd_info($2).pot &norm;- Please type&c3; !roll &norm;now!
.timerdd_end $+ $dd_info($2).id -o 1 600 dd_end $safe(#) $2 Duel between&c1; $2 &norm;and&c1; $dd_info($2).vs &norm;has been forcibly ended after 10 minutes of inactivity &c4;[[ Hosted By&c2; $dd_info($2).host &c4;]]
}
}
on $*:text:/^[!@.]roll\b/Si:$($whitelist):{
if (!$dd_info($nick)) msg.format ! $nick # [Error] You are not in a dice duel.
elseif ($dd_info($nick).roll) msg.format ! $nick # [Error] You have already rolled! It's &c1; $+ $dd_info($nick).vs $+ &norm;'s turn.
else {
set %dd_ $+ # $+ $nick $instok($dd_info($nick), $regsubex($left($str(@ -, $dd_info($nick).dice), -1), /@/g,$chr(32) $+ $die), 6, 47)
msg.format @ $nick # [Dice Duel]&c1; $nick &norm;rolled&c5; $dd_info($nick).roll &norm;(&c5; $+ $dd_info($nick).rollsum $+ &norm;) on $replace($dd_info($nick).dice, 2, two, 3, three, 4, four, 5, five, 6, six, 7, seven, 8, eight, 9, nine) 6-sided dice.
if ($dd_info($dd_info($nick).vs).rollsum && $dd_info($nick).rollsum) {
if ($dd_info($dd_info($nick).vs).rollsum == $dd_info($nick).rollsum) {
msg.format @ $nick # [Dice Duel] Duel between&c1; $dd_info($nick).vs &norm;and&c1; $nick &norm;was a draw, both having rolled&c5; $dd_info($nick).rollsum $+ &norm;. Please type &c3;!roll &norm;again.
set -e %dd_ $+ # $+ $dd_info($nick).vs $deltok($dd_info($dd_info($nick).vs), 6-, 47)
set -e %dd_ $+ # $+ $nick $deltok($dd_info($nick), 6-, 47)
}
else {
var %w $iif($dd_info($dd_info($nick).vs).rollsum > $dd_info($nick).rollsum, $dd_info($nick).vs, $nick)
dd_end # $nick &c1; $+ %w &norm;wins the&c4; $dd_info($nick).pot &norm;Pot with rolls:&c5; $dd_info(%w).rollsum - $dd_info($dd_info(%w).vs).rollsum &norm;against&c1; $dd_info(%w).vs &c4;[[ Hosted By&c2; $dd_info($nick).host &c4;]]
}
}
}
}
on $*:text:/^[!@.](ddend|(stop|end)dd)\b/Si:$($whitelist):{
if (!$2) msg.format ! $nick # [Error] No player entered.
elseif (!$dd_info($2)) msg.format ! $nick # [Error]&c1; $2 &norm;is not in a duel.
elseif ($nick != $dd_info($2).host) && ($dd_info($2).host ison #) msg.format ! $nick # [Error] Only the host (&c2; $v1 &norm;) can stop this dice duel.
elseif ($ishost($nick)) && ($dd_info($2)) {
dd_end # $2 Duel between&c1; $2 &norm;and&c1; $dd_info($2).vs &norm;has been forcibly ended by&c2; $nick $+ &norm;.
}
}
alias -l msg.format {
;!@. $nick #channel [title] <msg>
;c1 nicks
;c2 hosts
;c3 commands
;c4 pot
;c5 rolls
if ($left($1, 1) == @) var %out msg $safe($3)
else var %out notice $2
inc -z %msgs
.timer 1 %msgs %out $replacex($regsubex($4-,/^\[([^]]+)\]/,**°°°04\t7«&norm;), &c1;, 10, &c2;, 02, &c3;, 04, &c4;, 07, &c5;, 06,[b], $chr(2), **, $chr(2), &norm;, $chr(15))
}
alias -l safe return $!decode( $encode($1-, m) ,m)
alias -l allowed if (!$istok($mynicks, $me, 44)) return *
alias -l isformat if ($regex($1, /^(?:[1-9](?:\d*)?(?:\.\d+)?[mkb]|[1-9]\d*gp)$/Si)) return $true
alias -l ishost if ($nick(#, $1, $canhost)) return $true
alias -l dd_info {
/*
* $dd_info([#chan,]nick).prop
* Properties: vs, bet, host, dice, id, rolls, rollsum, pot
*/
;nick2/bet/host/dice/id/rolls
if ($regex($1, /^#/)) var %chan $1, %nick $2
else var %chan #, %nick $1
if (!$prop) return $($+(%, dd_, %chan, %nick), 2)
tokenize 47 $($+(%, dd_, %chan, %nick), 2)
if ($prop == vs) return $1
elseif ($prop == bet) return $2
elseif ($prop == host) return $3
elseif ($prop == dice) return $4
elseif ($prop == id) return $5
elseif ($prop == roll) return $6
elseif ($prop == rollsum) return $calc($replace($6, -, +))
elseif ($prop == pot) return $pot($2)
}
alias -l pot return $kmb.to($ceil($calc($kmb.from($1) * $iif($prop == full, 2, $dd_pot_multiplier))))
alias -l die return $rand(1,6)
alias -l dd_end {
/*
* /dd_end #channel nick [message]
*/
if ($3) msg.format @ $2 $1 [Dice Duel] $3-
.timerdd_end $+ $dd_info($1, $2).id off
unset %dd_ $+ $1 $+ $dd_info($1,$2).vs
unset %dd_ $+ $1 $+ $2
}
alias -l kmb.from return $regsubex($remove($1,$chr(44)),/([\d.]+)([kmbt]|gp)/Si,$calc(\1 * 10 ^ (3 * $pos(kmbt,\2))))
alias -l kmb.to {
while (. !isin $1) && ($2 != 4) && ($1 >= 1000) tokenize 32 $calc($1 /$v2) $calc(1+$2)
return $1 $+ $gettok(GP K M B T, $calc(1+$2), 32)
}