BotGames Collection

By IllogicTC on Dec 26, 2011

This is a small collection of snippets I decided to make. This code is intended for a bot, and provides some games for channel use.

So far it has three games:
Bomb Game
Number Guess Game

I will add more here and there as I make them. The commands used to use each snippet are in comments above each game's code.

Do note that I have NOT included flood protection. If you would like flood protection, you will have to devise your own scheme until I have implemented one.

Likewise goes with usable channels, these scripts are currently set up to work on ALL channels your bot is in (though when activated, it will set the channel it was activated in as the channel it will work in temporarily, and all other channels are locked out of the game until the game is done. I'll improve on this later).

If you have any other SIMPLE game ideas, comment them here and I may look into implementing it.

;By IllogicTC
;1st Edition, 3 games. (12/26/2011 release)
;To use: Load this whole script into your bot and enjoy!
;NOTE: I have NOT included flood protection yet. Please exercise caution with unknown users.
;Feel free to edit any parameters to better suit your needs.

;Bomb Game, BotGames Edition
;By IllogicTC
;v1.0 12/26/2011
;To trigger a game, use !bombgame. To cut a wire, use !cutwire <wire>

on *:text:!bombgame:#: {
  if ($timer(bomb) != $null) return
  set %bgames_bomb_wires
  set %bgames_bomb_chan $chan
  var %t = $rand(15,45), %w = $rand(3,5), %wpick =
  while (%w) {
    var %g $rand(1,$numtok(%wpick,46))
    set %bgames_bomb_wires %bgames_bomb_wires $gettok(%wpick,%g,46)
    var %wpick $deltok(%wpick,%g,46)
    dec %w
  set %bgames_bomb_goodwire $gettok(%bgames_bomb_wires,$rand(1,$numtok(%bgames_bomb_wires,32)),32)
  msg $chan A bomb has been planted in the cookie factory! The wires are: %bgames_bomb_wires
  msg $chan Choose wisely, you only get one chance! You have %t seconds.
  .timerbomb 1 %t bombboom

on *:text:!cutwire*:#: {
  if ($chan == %bgames_bomb_chan) && ($timer(bomb) != $null) && ($2 isin %bgames_bomb_wires) {
    if ($2 == %bgames_bomb_goodwire) {
      msg %bgames_bomb_chan Congratulations! The bomb has been defused. Good job, $nick $+ $chr(33)
      .timerbomb off
      unset %bgames_bomb*
    else {
      .timerbomb off

alias bombboom {
  msg %bgames_bomb_chan The bomb has exploded! $rand(10000,100000) cookies are lost in the explosion.
  unset %bgames_bomb*


;Number Guess Game, BotGames Edition
;By IllogicTC
;v1.0 12/26/2011
;To start, use !numberguess. To make a guess, use !ngguess <number>. Only one guess is allowed per person, and they cannot guess the same number.

on *:text:!numberguess:#: {
  if ($timer(nggame) != $null) return
  set %bgames_ng_closest 101
  set %bgames_ng_cguesser
  set %bgames_ng_chan $chan
  set %bgames_ng_guesses
  set %bgames_ng_guessnicks
  set %bgames_ng_number $rand(1,100)
  msg %bgames_ng_chan I'm thinking of a number between 1 and 100! Use !ngguess <number> to make a guess! Closest to my number wins!
  .timernggame 1 60 ng_results

on *:text:!ngguess*:#: {
  if ($timer(nggame) != $null) && ($chan == %bgames_ng_chan) && ($2 isnum 1-100) {
    if ($istok(%bgames_ng_guessnicks,$nick,32) == $false) {
      if ($istok(%bgames_ng_guesses,$2,32) == $true) {
        msg %bgames_ng_guesses Please pick a different number, $nick $+ .
      set %bgames_ng_guesses %bgames_ng_guesses $2
      set %bgames_ng_guessnicks %bgames_ng_guessnicks $nick
      if ($2 == %bgames_ng_number) {
        msg %bgames_ng_chan $nick got it dead on! The number was %bgames_ng_number $+ .
        .timernggame off
        unset %bgames_ng*
      else {
        if ($calc($2 - %bgames_ng_number) > 0) var %a $calc($2 - %bgames_ng_number)
        else var %a $calc(%bgames_ng_number - $2)
        if (%a < %bgames_ng_closest) {
          set %bgames_ng_closest %a
          set %bgames_ng_cguesser $nick

alias ng_results {
  msg %bgames_ng_chan The numbers game is up!
  if ($numtok(%bgames_ng_guessnicks,32) == 0) msg %bgames_ng_chan Nobody made a guess! Bummer.
  elseif ($numtok(%bgames_ng_guessnicks,32) == 1) msg %bgames_ng_chan %bgames_ng_cguesser wins by default, being the only guesser! They were off by %bgames_ng_closest $+ .
  else msg %bgames_ng_chan Out of $numtok(%bgames_ng_guessnicks,32) people with guesses, %bgames_ng_cguesser reigns supreme! They were %bgames_ng_closest off. My number was: %bgames_ng_number
  unset %bgames_ng*


;Blackjack, BotGames Edition
;By IllogicTC
;v1.0 12/26/2011
;To start, type !blackjack. To hit, use !bhit.

on *:text:!blackjack:#: {
  if ($timer(bj) != $null) return
  set %bgames_bj_deck A.
  set %bgames_bj_chan $chan
  set %bgames_bj_nick $nick
  .timerbj 1 30 bj_results
  var %x $gettok(%bgames_bj_deck,$rand(1,52),46)
  set %bgames_bj_deck $deltok(%bgames_bj_deck,%x,46)
  var %y $gettok(%bgames_bj_deck,$rand(1,51),46)
  set %bgames_bj_deck $deltok(%bgames_bj_deck,%y,46)
  set %bgames_bj_phand %x %y
  if (%x == A) set %bgames_bj_total 11
  else set %bgames_bj_total $replace(%x,J,10,Q,10,K,10)
  if (%y == A) {
    if (%x == A) inc %bgames_bj_total
    else inc %bgames_bj_total 11
  else inc %bgames_bj_total $replace(%y,J,10,Q,10,K,10)
  if (%bgames_bj_total != 21) msg $chan Your cards: %x %y $+($chr(40),%bgames_bj_total,$chr(41),$chr(46)) Use !bhit to try getting as close to 21 as possible without going over! You have 30 seconds. Dealer stands at 17!
  else {
    msg $chan You have a blackjack!
    .timerbj off

on *:text:!bhit:#: {
  if ($timer(bj) != $null) && ($nick == %bgames_bj_nick) {
    var %x $rand(1,$numtok(%bgames_bj_deck,46))
    var %y $gettok(%bgames_bj_deck,%x,46)
    set %bgames_bj_phand %bgames_bj_phand %y
    set %bgames_bj_deck $deltok(%bgames_bj_deck,%x,46)
    var %t = $numtok(%bgames_bj_phand,32), %n = 0, %a = 0
    while (%t) {
      if ($gettok(%bgames_bj_phand,%t,32) == A) inc %a
      else inc %n $replace($gettok(%bgames_bj_phand,%t,32),J,10,Q,10,K,10)
      dec %t
    if (%a > 0) {
      while (%a) {
        if ($calc(11 + %n) > 21) inc %n
        else inc %n 11
        dec %a
    set %bgames_bj_total %n
    if (%bgames_bj_total > 21) {
      msg %bgames_bj_chan You have busted! Automatic loss :( Your hand: %bgames_bj_phand $+($chr(40),%bgames_bj_total,$chr(41),$chr(46))
      .timerbj off
    elseif (%bgames_bj_total == 21) {
      msg %bgames_bj_chan You have reached 21! Now let's see how the dealer fared.
      .timerbj off
    else msg %bgames_bj_chan Your hand: %bgames_bj_phand $+($chr(40),%bgames_bj_total,$chr(41),$chr(46)) To stay, just wait for the round to end!

alias bj_results {
  var %dh $rand(17,24)
  if (%dh <= 21) {
    if (%dh < %bgames_bj_total) msg %bgames_bj_chan You've won! Your hand: %bgames_bj_phand $+($chr(40),%bgames_bj_total,$chr(41),$chr(46)) The dealer's hand: %dh
    elseif (%dh == %bgames_bj_total) msg %bgames_bj_chan Your hands are a tie! Your hand: %bgames_bj_phand $+($chr(40),%bgames_bj_total,$chr(41),$chr(46)) The dealer's hand: %dh
    else msg %bgames_bj_chan You've lost! Your hand: %bgames_bj_phand $+($chr(40),%bgames_bj_total,$chr(41),$chr(46)) The dealer's hand: %dh
  else msg %bgames_bj_chan The dealer has busted with %dh $+ ! You've won!
  unset %bgames_bj*



Sign in to comment.
dma   -  Dec 06, 2015

not bad at all ..i seen the one where the picture cards were 11.12.13 and the ace was only used for #1 nothing else

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.