simple !DICE game V2.0

By koekbliq on Jan 31, 2009

This is a (less) simple (by now) DICE game made by koekbliq and also my first big and more difficult script.

Commands for DICE are !dice, !dice , !points, !points , !status, !commands.

You can set it on for multiple channels and off when you want!

I've used Typo's trigger protection for the flood protection. (http://www.hawkee.com/snippet/4664/)

-I have changed it to v2.0-

updates:
-added duell-mode
-added watching someone else's points
-added !status displaying channels DICE active in and if DICE is on or off
-added a timer to set it off automatically after a certain period

Enjoy!

;########################################################################################
;########################################################################################
;####| DICE: the simple   |###| made by  |###| Use !dice, !dice <nick>, !commands   |####
;####| !trigger GAME V3.0 |###| koekbliq |###| and !points, !points <nick>, !status |####
;########################################################################################
;########################################################################################
; OPEN THE MENU ON RIGHT-CLICK IN A CHANNEL BEFORE USE !!

;;;;;;;;;;;;;
;;;[!DICE];;;
;;;;;;;;;;;;;

on *:TEXT:!dice*:#:{
  if (%DICEon == 1) && ($2 ison $chan) && ($2 != $nick) && ($TriggerPro($nick,$v2) == $true) && ($chan isin %DICEchan) {
    set %yt1 $rand(1,6)
    set %yt2 $rand(1,6)
    set %yt3 $rand(1,6)
    set %bt1 $rand(1,6)
    set %bt2 $rand(1,6)
    set %bt3 $rand(1,6)
    set %yTOT $calc((%yt1) + (%yt2) + (%yt3))
    set %bTOT $calc((%bt1) + (%bt2) + (%bt3))
    set %player2 $2
    timerplay1 1 1 notice $nick (Your throw) $chr(91) $+ %yt1 $+ $chr(93) $chr(91) $+ %yt2  $+ $chr(93) $chr(91) $+ %yt3 $+ $chr(93) = $chr(91) $+ %yTOT $+ $chr(93) 
    timerplay2 1 2 notice $nick ( $+ $2 $+ $chr(39) $+ s throw) $chr(91) $+ %bt1 $+ $chr(93) $chr(91) $+ %bt2 $+ $chr(93) $chr(91) $+ %bt3 $+ $chr(93) = $chr(91) $+ %bTOT $+ $chr(93) 
    timerplay3 1 1 notice $2 (Your throw) $chr(91) $+ %bt1 $+ $chr(93) $chr(91) $+ %bt2 $+ $chr(93) $chr(91) $+ %bt3 $+ $chr(93) = $chr(91) $+ %bTOT $+ $chr(93) 
    timerplay4 1 2 notice $2 ( $+  $+ $nick $+ $chr(39) $+ s throw) $chr(91) $+ %yt1 $+ $chr(93) $chr(91) $+ %yt2  $+ $chr(93) $chr(91) $+ %yt3 $+ $chr(93) = $chr(91) $+ %yTOT $+ $chr(93) 
    winner2
  }
  elseif (%DICEon == 1) && ($2 == $null) && ($2 != $nick) && ($TriggerPro($nick,$v2) == $true) && ($chan isin %DICEchan) {
    set %yt1 $rand(1,6)
    set %yt2 $rand(1,6)
    set %yt3 $rand(1,6)
    set %bt1 $rand(1,6)
    set %bt2 $rand(1,6)
    set %bt3 $rand(1,6)
    set %yTOT $calc((%yt1) + (%yt2) + (%yt3))
    set %bTOT $calc((%bt1) + (%bt2) + (%bt3))
    timerplay11 1 1 notice $nick (Your throw) $chr(91) $+ %yt1 $+ $chr(93) $chr(91) $+ %yt2  $+ $chr(93) $chr(91) $+ %yt3 $+ $chr(93) = $chr(91) $+ %yTOT $+ $chr(93) 
    timerplay12 1 2 notice $nick (Comp's throw) $chr(91) $+ %bt1 $+ $chr(93) $chr(91) $+ %bt2 $+ $chr(93) $chr(91) $+ %bt3 $+ $chr(93) = $chr(91) $+ %bTOT $+ $chr(93) 
    winner1
  }  
  elseif (%DICEon == 1) && ($2 == $nick) && ($TriggerPro($nick,$v2) == $true) && ($chan isin %DICEchan) {
    set %yt1 $rand(1,6)
    set %yt2 $rand(1,6)
    set %yt3 $rand(1,6)
    set %bt1 $rand(1,6)
    set %bt2 $rand(1,6)
    set %bt3 $rand(1,6)
    set %yTOT $calc((%yt1) + (%yt2) + (%yt3))
    set %bTOT $calc((%bt1) + (%bt2) + (%bt3))
    timerplay11 1 1 notice $nick (Your throw) $chr(91) $+ %yt1 $+ $chr(93) $chr(91) $+ %yt2  $+ $chr(93) $chr(91) $+ %yt3 $+ $chr(93) = $chr(91) $+ %yTOT $+ $chr(93) 
    timerplay12 1 2 notice $nick (Comp's throw) $chr(91) $+ %bt1 $+ $chr(93) $chr(91) $+ %bt2 $+ $chr(93) $chr(91) $+ %bt3 $+ $chr(93) = $chr(91) $+ %bTOT $+ $chr(93) 
    winner1
  }
  else {
    halt
  }
}

;;;;;;;;;;;;;;;;;;;;;;;
;;;[WINNER ALIASSES];;;
;;;;;;;;;;;;;;;;;;;;;;;

alias winner1 {
  if (%yTOT == %bTOT) { 
    timerplay13 1 3 notice $nick (Draw! 0 points)
    set %. $+ $nick $calc((%. [ $+ [ $nick ] ] ) + 0)
    unset %yt1 %yt2 %yt3 %bt1 %bt2 %bt3 %yTOT %bTOT
    halt
  }
  if (%yTOT < %bTOT) && (%bTOT != 18) { 
    timerplay13 1 3 notice $nick (You lose! -1 points)
    set %. $+ $nick $calc((%. [ $+ [ $nick ] ] ) - 1)
    unset %yt1 %yt2 %yt3 %bt1 %bt2 %bt3 %yTOT %bTOT
    halt
  }
  if (%yTOT > %bTOT) && (%yTOT != 18) { 
    timerplay13 1 3 notice $nick (You win! +1 points)
    set %. $+ $nick $calc((%. [ $+ [ $nick ] ] ) + 1)
    unset %yt1 %yt2 %yt3 %bt1 %bt2 %bt3 %yTOT %bTOT
    halt
  }
  if (%yTOT == 18) && (%bTOT != 18) {
    timerplay13 1 3 notice $nick (You win the jackpot for the highest throw possible! +4 points)
    set %. $+ $nick $calc((%. [ $+ [ $nick ] ] ) + 4)
    unset %yt1 %yt2 %yt3 %bt1 %bt2 %bt3 %yTOT %bTOT
    halt
  }
}

alias winner2 {
  if (%yTOT == %bTOT) { 
    timerplay11 1 5 notice $nick (Draw! 0 points)
    timerplay12 1 5 notice %player2 (Draw! 0 points)
    set %. $+ $nick $calc((%. [ $+ [ $nick ] ] ) + 0)
    set %. $+ %player2 $calc((%. [ $+ [ %player2 ] ] ) + 0)
    unset %yt1 %yt2 %yt3 %bt1 %bt2 %bt3 %yTOT %bTOT %player2
    halt
  }
  if (%yTOT < %bTOT) && (%bTOT != 18) { 
    timerplay13 1 5 notice $nick (You lose! -1 points)
    timerplay14 1 5 notice %player2 (You win! +1 points)
    set %. $+ $nick $calc((%. [ $+ [ $nick ] ] ) - 1)
    set %. $+ %player2 $calc((%. [ $+ [ %player2 ] ] ) + 1)
    unset %yt1 %yt2 %yt3 %bt1 %bt2 %bt3 %yTOT %bTOT %player2
    halt
  }
  if (%yTOT > %bTOT) && (%yTOT != 18) { 
    timerplay15 1 5 notice $nick (You win! +1 points)
    timerplay16 1 5 notice %player2 (You lose! -1 points)
    set %. $+ $nick $calc((%. [ $+ [ $nick ] ] ) + 1)
    set %. $+ %player2 $calc((%. [ $+ [ %player2 ] ] ) - 1)
    unset %yt1 %yt2 %yt3 %bt1 %bt2 %bt3 %yTOT %bTOT %player2
    halt
  }
  if (%yTOT == 18) && (%bTOT != 18) {
    timerplay17 1 5 notice $nick (You win the jackpot with the highest throw possible! +4 points)
    timerplay18 1 5 notice %player2 (You lose! -1 points)
    set %. $+ $nick $calc((%. [ $+ [ $nick ] ] ) + 4)
    set %. $+ %player2 $calc((%. [ $+ [ %player2 ] ] ) - 1)
    unset %yt1 %yt2 %yt3 %bt1 %bt2 %bt3 %yTOT %bTOT %player2
    halt
  }
  if (%bTOT == 18) && (%yTOT != 18) {
    timerplay19 1 5 notice $nick (You lose! -1 points)
    timerplay20 1 5 notice %player2 (You win the jackpot with the highest throw possible! +4 points)
    set %. $+ %player2 $calc((%. [ $+ [ %player2 ] ] ) + 4)    
    set %. $+ $nick $calc((%. [ $+ [ $nick ] ] ) - 1)
    unset %yt1 %yt2 %yt3 %bt1 %bt2 %bt3 %yTOT %bTOT %player2
    halt
  }
}

;;;;;;;;;;;;;;;
;;;[!STATUS];;;
;;;;;;;;;;;;;;;

on *:TEXT:!status*:#:{
  if (%DICEon == 1) && ($TriggerPro($nick,$v2) == $true) && ($chan isin %DICEchan) {
    notice $nick (DICE made by koekbliq) (Status:) %DICEstatus (Channels:) ( $+ %DICEchan $+ )
  }  
  elseif (%DICEon == 0) && ($TriggerPro($nick,$v2) == $true) && ($chan isin %DICEchan) {
    notice $nick (DICE made by koekbliq) (Status:) %DICEstatus
  }
  else {
    halt
  }
}

;;;;;;;;;;;;;;;;;
;;;[!COMMANDS];;;
;;;;;;;;;;;;;;;;;

on *:TEXT:!commands*:#:{
  if (%DICEon == 1) && ($TriggerPro($nick,$v2) == $true) && ($chan isin %DICEchan) {
    notice $nick (Commands for DICE are !dice, !dice <nickname>, !points, !points <nickname>, !status, !commands)
  }
  elseif (%DICEon == 0) && ($TriggerPro($nick,$v2) == $true) && ($chan isin %DICEchan) {
    notice $nick (Status:) %DICEstatus (Commands for DICE are !dice, !dice <nickname>, !points, !points <nickname>, !status, !commands)
  }
  else {
    halt    
  }
}

;;;;;;;;;;;;;;;
;;;[!POINTS];;;
;;;;;;;;;;;;;;;

on *:TEXT:!points*:#:{
  if (%DICEon == 1) && ($2 ison $chan) && ($TriggerPro($nick,$v2) == $true) && ($chan isin %DICEchan) {
    goto points2
  }
  elseif (%DICEon == 1) && ($TriggerPro($nick,$v2) == $true) && ($chan isin %DICEchan) {
    if ($2 == $null) {
      goto points1
    }
    elseif ($2 == $nick) {
      goto points1
    }
    else {
      goto huh
    }
    :points1
    timerpoints1 1 1 notice $nick  $+ $chr(40) $+  $+ You have %. [ $+ [ $nick ] ] point $+ $chr(40) $+ s $+ $chr(41) $+ ! $+  $+ $chr(41) $+ 
    halt
    :points2
    timerpoints2 1 1 notice $nick  $+ $chr(40) $+  $+ $2 has %. [ $+ [ $2 ] ] point $+ $chr(40) $+ s $+ $chr(41) $+ ! $+  $+ $chr(41) $+ 
    halt
    :huh
    halt
  }
}

;;;;;;;;;;;;;;
;;;;[MENU];;;;
;;;;;;;;;;;;;;

menu channel {
  [DICE]
  .control:
  ..on: {
    set %DICEon 1
    set %dicestatus (3ON)
    timerdiceON1 off
    timerdiceON2 off
    timerdiceON3 off
    unset %.diceminu %.dicetimer
    DICEchans
  }
  ..on with timer: { 
    set %DICEon 1
    set %dicestatus (3ON)
    set %.diceminu $?="How many minutes do you want DICE to be on?"
    set %.dicetimer $calc((%. [ $+ [ diceminu ] ] ) * 60)
    echo (DICE is now:) %dicestatus (For the next %.diceminu minutes)
    timerdiceON1 1 %.dicetimer set %dicestatus (4OFF)
    timerdiceON2 1 %.dicetimer echo (DICE is now:) (4OFF) (After %.diceminu minutes of being ON)
    timerdiceON4 1 %.dicetimer set %DICEon 0    
    timerdiceON3 1 %.dicetimer unset %.diceminu %.dicetimer
  }  
  ..off: {
    set %DICEon 0
    set %dicestatus (4OFF)
    timerdiceON1 off
    timerdiceON2 off
    timerdiceON3 off
    unset %.diceminu %.dicetimer
    DICEchans
  }
  .channel:
  ..set: {
    set %DICEchan $?="Channel(s)? i.e.: #chan1 #chan2 #chan3 etc:"
    DICEchans
  }
  ..set active: {
    set %DICEchan $active
    DICEchans 
  }
  ..unset: {
    unset %DICEchan
    echo (Channel(s) are now unset) (DICE status:) %dicestatus
  }
  ..show current: {
    DICEchans
  }
}

;;;;;;;;;;;;;;;;
;;;[ALIASSES];;;
;;;;;;;;;;;;;;;;

alias DICEchans {
  if (%DICEchan == $null) {
    echo (There are no channels set) (DICE status:) %dicestatus
  }
  else {
    echo (Channel(s): %DICEchan $+  $+ ) (DICE status:) %dicestatus
    halt 
  }
}

alias triggerpro {
  if (%triggerpro. [ $+ [ $nick ] $+  . $+ [ $address($1,4) ] $+ . $+ [ $cid ] ] >= 1) || (%trigger. [ $+ [ $nick ] ] == yes) { 
    $iif(%triggerpro. [ $+ [ $nick ] $+  . $+ [ $address($1,4) ] $+ . $+ [ $cid ] ] isnum 1,notice $nick  $+ $chr(40) $+ Flood protection $+ $chr(41) $+   $+ $chr(40) $+ Try again in about 30 seconds $+ $chr(41) $+  $iif(%triggerpro. [ $+ [ $nick ] $+  . $+ [ $address($1,4) ] $+ . $+ [ $cid ] ] == 2, $+ $chr(40) $+ Ignoring !triggers $+ $chr(41) $+   $+ $chr(40) $+ Until you wait for the 30 second period to end $+ $chr(41) $+ ))
    inc -u30 %triggerpro. $+ $nick $+ . $+ $address($1,4) $+ . $+ $cid
    return $false
  }
  inc -u30 %triggerpro. $+ $nick $+ . $+ $address($1,4) $+ . $+ $cid
  set -u3 %trigger. $+ $nick yes
  return $true
}

;END;

Comments

Sign in to comment.
Pangaea   -  Jan 20, 2010

Hi koekbliq
This is a wonderful little dice game, I have added to my Bot

Just one thing I was curious about tho, Is there any reason why the whole game system is conducted via private msgs?

I have played the game and looked at the code, and reslise in some instances a private messege would make more sence as to avoid confusion, but the game itself in theory has no need for privacy, its not like its a game that uses cards where you might not want other ppl seeing.

Great dice script tho, definatly one of the most interesting ive used over the years, good one :)

regards
pan

 Respond  
Quick   -  Sep 03, 2009

very nice, i had some problems with other dice games like the diceoff commands not working or 2 ppl would ingage a game and not finish and even after unloading the script and taking compleatly out of my bot still said a game was in progress i like this version much much more and the fact that it's not as spammy as the other. Very nice

 Respond  
bmann_420   -  Feb 04, 2009

This is incredibly nice =) The right click commands work, although the ! commands do not. (It is enabled) I have a few other things in remote also, is their a limit to what you have in their? (Somewhat noobish to mirc scripting) Even more noobish question, could those  have something to do with it not working properly? I wonder if i do not have the right type of "reader" for that, could mean nothing.

 Respond  
koekbliq   -  Jan 31, 2009
on *:TEXT:!test:#: {
  set %op
  if (%op) {
    msg $chan Done testing
    unset %op
  }
}

Not like that?

Thnx, changed it.

Edit: and changed it back again because it didn't work as well.

 Respond  
Aucun50   -  Jan 31, 2009

Np here an ex:

on *:TEXT:!test:#: {
  set %op
  if (%op) {
    msg $chan Done testing
  }
}
 Respond  
koekbliq   -  Jan 31, 2009

So it only goes forward when %DICEon = set?
Is so: thanks I didn't know that.

 Respond  
Aucun50   -  Jan 31, 2009

Looks nice

BTW if (%DICEon != $null) Why not if (%DICEon)

 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.