Chat Fighter Game

By Majishine on Oct 12, 2010

I've been making games for my Justin.tv bot recently and this is one the first few that I coded completely from scratch. It should work just fine with IRC.

Game Info


The game has an on|off function using !setchatfighter on|off, turning the game off also unsets all the vars. Can only be used by Ops.
The game also has a timer function to prevent spam, set to 300 by default.
The game allows Player 1 to challenge Player 2(!chatfighter ). Player 2 is given a 60- sec time limit to choose to accept(!acceptfight), if not accepted game resets.
Players are given 100 HP to start
Players will take turns using one of six moves to attack their opponent.(!move
Six moves are set to randomly generate damage from 10 to 40.
Players will take turns using moves. When a move is used it is rerandomized for damage.
All moves have a 25% possibility to be countered. A Player that is countered will take 10 to 20 damage.
When one player's HP reaches 0, the game is over. The loser is kicked from channel for 2mins.


*****************************************************
Chat Fighter created by MajiShine
*****************************************************

*****************************************************
Alias Area
*****************************************************
alias cfover {
unset %chatf | unset %P1 | unset %P2 | unset %turn | unset %P1HP | unset %P2HP | unset %hadouken | unset %shoryuken |  unset   %psychocrusher | unset %tigershot | unset %sonicboom | unset %yogafire | unset %counter | unset %super | unset %superfail |  unset %super win }
alias sethadouken { unset %kadouken | set %hadouken $rand(10,40) }
alias setshoryuken { unset %shoryuken | set %shoryukenken $rand(10,40) }
alias setpsychocrusher { unset %psychocrusher | set %psychocrusher $rand(10,40) }
alias settigershot { unset %tigershot | set %tigershot $rand(10,40) }
alias setsonicboom { unset %sonicboom | set %sonicboom $rand(10,40) }
alias setyogafire { unset %yogafire | set %yogafire $rand(10,40) }
alias setcounter.chance { unset %counter.chance | set %counter.chance $rand(1,4) }

*****************************************************
GAME
*****************************************************
on *:TEXT:!chatfighter*:#: {
  if (%on.off == $null) { .timer1 .msg $chan Chat Fighter is currently set to off. Please as a moderator to turn it on using    !setchatfighter on. }

  elseif (%on.off == on) {
    if ($2 == $null) { .msg $chan $nick you must specify someone to fight (EX. !chatfighter majishine) | halt }
    if ($nick == $2) { .msg $chan $nick you cannot challenge yourself to fight. | halt }
    if ($2 !ison $chan) { .msg $chan $2 is not on $chan. | halt }
    if (%f) { .msg $chan $nick there is still %f until another Chat Fight can begin. | halt }
    elseif (!%f) {
      set %P1 $nick
      set %turn $nick
      set %P2 $2
      .timer 1 1 describe $chan $nick has challenged $2 to Chat Fighter! $2 type !acceptfight to fight!
      timerchatfight 1 60 .msg $chan $2 wussed out and would not fight against $nick $+.
      timerchatfight2 1 60 cfover
    }
  }
}
on *:TEXT:!acceptfight*:#: {
  if (( %P2 == $nick )) {
    if (!%f) {
      set -z %f 300
      set %chatf on
      set %P1HP 100
      set %P2HP 100
      set %hadouken $rand(10,40)
      set %shoryuken $rand(10,40)
      set %psychocrusher $rand(10,40)
      set %tigershot $rand(10,40)
      set %sonicboom $rand(10,40)
      set %yogafire $rand(10,40)
      set %counter $rand(10,20)
      set %counter.chance $rand(1,4)
      .timer 1 2 .msg $chan $nick joins %P1 in a match of Chat Fighter! %P1 will go first. Use !move to fight 
      .timer 1 3 .describe $chan moves are  hadouken / shoryuken / psycho / tiger / sonicboom / yogafire . (EX.  !move  hadouken)
      timerchatfight off
      timerchatfight2 off
    }
    elseif (%f) { .timer 1 1 .msg $chan $nick there is still %f seconds left until another game of Chat Fighter can be played, please try again later }
  }
  elseif (( %P2 != $nick )) { .timer 1 1 .msg $chan $nick you were not challenged by %P1 }
}

on *:TEXT:!move*:#: {
  if  (( %chatf == on )) {
    if  (( %turn == $nick )) && (( %P1 == $nick )) {
      ***************************************************
      Player 1 attack
      ***************************************************
      if  (( $2 == hadouken )) {
        ***************************************************
        Player 1 hadouken
        ***************************************************
        set %turn %P2
        if (( %counter.chance == 1 )) {
          dec %p1hp %counter
          .timer 1 1 .describe $chan %p2 has countered! $nick takes %counter damage
          .timer 1 2 .msg $chan %p1 has %p1hp HP/ %p2 has %p2hp HP 
          .timer 1 3 .msg $chan it is now %p2 turn
          unset %counter.chance
          set %counter.chance $rand(1,4)
        }
        else {
          dec %P2HP %hadouken
          .timer 1 1 .msg $chan HADOUKEN!
          .timer 1 2 .describe $chan $nick uses hadouken! %P2 takes %hadouken damage.
          if (%p2hp <= 0) {
            .timer 2 3 .msg $chan K.O.! %p1 has owned %p2 in Chat Fighter
            /kick $chan %p2
            /timer 1 120 /mode -b %p2
            cfover 
          }
          else {
            .timer 1 3 .msg $chan %P1 has %p1hp HP/ %p2 has %p2hp HP, it is now %p2 turn
            sethadouken
            setcounter.chance
          }
        }
      }
      if  (( $2 == shoryuken )) {
        ***************************************************
        Player 1 shoryuken
        ***************************************************
        set %turn %P2
        if (( %counter.chance == 1 )) {
          dec %p1hp %counter
          .timer 1 1 .describe $chan %p2 has countered! $nick takes %counter damage
          .timer 1 2 .msg $chan %p1 has %p1hp HP/ %p2 has %p2hp HP 
          .timer 1 3 .msg $chan it is now %p2 turn
          unset %counter.chance
          set %counter.chance $rand(1,4)
        }
        else {
          dec %P2HP %shoryuken
          .timer 1 1 .msg $chan SHORYUKEN!
          .timer 1 2 .describe $chan $nick uses shoryuken! %P2 takes %shoryuken damage.
          if (%p2hp <= 0) {
            .timer 2 3 .msg $chan K.O.! %p1 has owned %p2 in Chat Fighter
            /kick $chan %p2
            /timer 1 120 /mode -b %p2
            cfover 
          }
          else {
            .timer 1 3 .msg $chan %P1 has %p1hp HP/ %p2 has %p2hp HP, it is now %p2 turn
            setshoryuken
            setcounter.chance
          }
        }
      }
      if  (( $2 == psycho )) {
        ***************************************************
        Player 1 psychocrusher
        ***************************************************
        set %turn %P2
        if (( %counter.chance == 1 )) {
          dec %p1hp %counter
          .timer 1 1 .describe $chan %p2 has countered! $nick takes %counter damage
          .timer 1 2 .msg $chan %p1 has %p1hp HP/ %p2 has %p2hp HP 
          .timer 1 3 .msg $chan it is now %p2 turn
          unset %counter.chance
          set %counter.chance $rand(1,4)
        }
        else {
          dec %P2HP %psychocrusher
          .timer 1 1 .msg $chan PSYKO CRUSHA!
          .timer 1 2 .describe $chan $nick uses psycho crusher! %P2 takes %psychocrusher damage.
          if (%p2hp <= 0) {
            .timer 2 3 .msg $chan K.O.! %p1 has owned %p2 in Chat Fighter
            /kick $chan %p2
            /timer 1 120 /mode -b %p2
            cfover 
          }
          else {
            .timer 1 3 .msg $chan %P1 has %p1hp HP/ %p2 has %p2hp HP, it is now %p2 turn
            setpsychocrusher
            setcounter.chance
          }
        }
      }
      if  (( $2 == tiger )) {
        ***************************************************
        Player 1 tigershot
        ***************************************************
        set %turn %P2
        if (( %counter.chance == 1 )) {
          dec %p1hp %counter
          .timer 1 1 .describe $chan %p2 has countered! $nick takes %counter damage
          .timer 1 2 .msg $chan %p1 has %p1hp HP/ %p2 has %p2hp HP 
          .timer 1 3 .msg $chan it is now %p2 turn
          unset %counter.chance
          set %counter.chance $rand(1,4)
        }
        else {
          dec %P2HP %tigershot
          .timer 1 1 .msg $chan TIGER!
          .timer 1 2 .describe $chan $nick uses tiger shot! %P2 takes %tigershot damage.
          if (%p2hp <= 0) {
            .timer 2 3 .msg $chan K.O.! %p1 has owned %p2 in Chat Fighter
            /kick $chan %p2
            /timer 1 120 /mode -b %p2
            cfover 
          }
          else {
            .timer 1 3 .msg $chan %P1 has %p1hp HP/ %p2 has %p2hp HP, it is now %p2 turn
            settigershot
            setcounter.chance
          }
        }
      }
      if  (( $2 == sonicboom )) {
        ***************************************************
        Player 1 sonicboom
        ***************************************************
        set %turn %P2
        if (( %counter.chance == 1 )) {
          dec %p1hp %counter
          .timer 1 1 .describe $chan %p2 has countered! $nick takes %counter damage
          .timer 1 2 .msg $chan %p1 has %p1hp HP/ %p2 has %p2hp HP 
          .timer 1 3 .msg $chan it is now %p2 turn
          unset %counter.chance
          set %counter.chance $rand(1,4)
        }
        else {
          dec %P2HP %sonicboom
          .timer 1 1 .msg $chan SONIC BOOM!
          .timer 1 2 .describe $chan $nick uses sonic boom! %P2 takes %sonicboom damage.
          if (%p2hp <= 0) {
            .timer 2 3 .msg $chan K.O.! %p1 has owned %p2 in Chat Fighter
            /kick $chan %p2
            /timer 1 120 /mode -b %p2
            cfover 
          }
          else {
            .timer 1 3 .msg $chan %P1 has %p1hp HP/ %p2 has %p2hp HP, it is now %p2 turn
            setsonicboom
            setcounter.chance
          }
        }
      }
      if  (( $2 == yogafire )) {
        ***************************************************
        Player 1 yogafire
        ***************************************************
        set %turn %P2
        if (( %counter.chance == 1 )) {
          dec %p1hp %counter
          .timer 1 1 .describe $chan %p2 has countered! $nick takes %counter damage
          .timer 1 2 .msg $chan %p1 has %p1hp HP/ %p2 has %p2hp HP 
          .timer 1 3 .msg $chan it is now %p2 turn
          unset %counter.chance
          set %counter.chance $rand(1,4)
        }
        else {
          dec %P2HP %yogafire
          .timer 1 1 .msg $chan YOGA FIRE!
          .timer 1 2 .describe $chan $nick uses yoga fire! %P2 takes %yogafire damage.
          if (%p2hp <= 0) {
            .timer 2 3 .msg $chan K.O.! %p1 has owned %p2 in Chat Fighter
            /kick $chan %p2
            /timer 1 120 /mode -b %p2
            cfover 
          }
          else {
            .timer 1 3 .msg $chan %P1 has %p1hp HP/ %p2 has %p2hp HP, it is now %p2 turn
            setyogafire
            setcounter.chance
          }
        }
      }

      ****************************************************
      Player 1 no move set
      ****************************************************
      if (( $2 == $null )) {
        set %turn %p2
        dec %P1HP %counter
        .timer 1 1 .describe $chan %p2 has countered! $nick takes %counter damage
        .timer 1 2 .msg $chan %p1 has %p1hp / %p2 has %p2hp
        unset %counter.chance
        set %counter.chance $rand(1,4)
        if (%p1hp <= 0) {
          .timer 2 3 .msg $chan K.O.!  %p2 has owned %p1 in Chat Fighter
          /kick $chan %p1
          /timer 1 120 /mode -b %p1
          cfover 
        }
      }
    } 

    if  (( %turn == $nick )) && (( %P2 == $nick )) {
      ***************************************************
      Player 2 attack
      ***************************************************
      if  (( $2 == hadouken )) {
        ***************************************************
        Player 2 hadouken
        ***************************************************
        set %turn %P1
        if (( %counter.chance == 1 )) {
          dec %p2hp %counter
          .timer 1 1 .describe $chan %p1 has countered! $nick takes %counter damage
          .timer 1 2 .msg $chan %p1 has %p1hp HP/ %p2 has %p2hp HP 
          .timer 1 3 .msg $chan it is now %p1 turn
          unset %counter.chance
          set %counter.chance $rand(1,4)
        }
        else {
          dec %P1HP %hadouken
          .timer 1 1 .msg $chan HADOUKEN!
          .timer 1 2 .describe $chan $nick uses hadouken! %P1 takes %hadouken damage.
          if (%p1hp <= 0) {
            .timer 2 3 .msg $chan K.O.! %p2 has owned %p1 in Chat Fighter
            /kick $chan %p1
            /timer 1 120 /mode -b %p1
            cfover 
          }
          else {
            .timer 1 3 .msg $chan %P1 has %p1hp HP/ %p2 has %p2hp HP, it is now %p1 turn
            sethadouken
            setcounter.chance
          }  
        }
      }
      if  (( $2 == shoryuken )) {
        ***************************************************
        Player 2 shoryuken
        ***************************************************
        set %turn %P1
        if (( %counter.chance == 1 )) {
          dec %p2hp %counter
          .timer 1 1 .describe $chan %p1 has countered! $nick takes %counter damage
          .timer 1 2 .msg $chan %p1 has %p1hp HP/ %p2 has %p2hp HP 
          .timer 1 3 .msg $chan it is now %p1 turn
          unset %counter.chance
          set %counter.chance $rand(1,4)
        }
        else {
          dec %P1HP %shoryuken
          .timer 1 1 .msg $chan SHORYUKEN!
          .timer 1 2 .describe $chan $nick uses shoryuken! %P1 takes %shoryuken damage.
          if (%p1hp <= 0) {
            .timer 2 3 .msg $chan K.O.! %p2 has owned %p1 in Chat Fighter
            /kick $chan %p1
            /timer 1 120 /mode -b %p1
            cfover 
          }
          else {
            .timer 1 3 .msg $chan %P1 has %p1hp HP/ %p2 has %p2hp HP, it is now %p1 turn
            setshoryuken
            setcounter.chance
          }  
        }
      }
      if  (( $2 == psycho )) {
        ***************************************************
        Player 2 psychocrusher
        ***************************************************
        set %turn %P1
        if (( %counter.chance == 1 )) {
          dec %p2hp %counter
          .timer 1 1 .describe $chan %p1 has countered! $nick takes %counter damage
          .timer 1 2 .msg $chan %p1 has %p1hp HP/ %p2 has %p2hp HP 
          .timer 1 3 .msg $chan it is now %p1 turn
          unset %counter.chance
          set %counter.chance $rand(1,4)
        }
        else {
          dec %P1HP %psychocrusher
          .timer 1 1 .msg $chan PSYKO CRUSHA!
          .timer 1 2 .describe $chan $nick uses psycho crusher! %P1 takes %psychocrusher damage.
          if (%p1hp <= 0) {
            .timer 2 3 .msg $chan K.O.! %p2 has owned %p1 in Chat Fighter
            /kick $chan %p1
            /timer 1 120 /mode -b %p1
            cfover 
          }
          else {
            .timer 1 3 .msg $chan %P1 has %p1hp HP/ %p2 has %p2hp HP, it is now %p1 turn
            setpsychocrusher
            setcounter.chance
          }  
        }
      }
      if  (( $2 == tiger )) {
        ***************************************************
        Player 2 tigershot
        ***************************************************
        set %turn %P1
        if (( %counter.chance == 1 )) {
          dec %p2hp %counter
          .timer 1 1 .describe $chan %p1 has countered! $nick takes %counter damage
          .timer 1 2 .msg $chan %p1 has %p1hp HP/ %p2 has %p2hp HP 
          .timer 1 3 .msg $chan it is now %p1 turn
          unset %counter.chance
          set %counter.chance $rand(1,4)
        }
        else {
          dec %P1HP %tigershot
          .timer 1 1 .msg $chan TIGER!
          .timer 1 2 .describe $chan $nick uses tiger shot! %P1 takes %tigershot damage.
          if (%p1hp <= 0) {
            .timer 2 3 .msg $chan K.O.! %p2 has owned %p1 in Chat Fighter
            /kick $chan %p1
            /timer 1 120 /mode -b %p1
            cfover 
          }
          else {
            .timer 1 3 .msg $chan %P1 has %p1hp HP/ %p2 has %p2hp HP, it is now %p1 turn
            settigershot
            setcounter.chance
          }  
        }
      }
      if  (( $2 == sonicboom )) {
        ***************************************************
        Player 2 sonicboom
        ***************************************************
        set %turn %P1
        if (( %counter.chance == 1 )) {
          dec %p2hp %counter
          .timer 1 1 .describe $chan %p1 has countered! $nick takes %counter damage
          .timer 1 2 .msg $chan %p1 has %p1hp HP/ %p2 has %p2hp HP 
          .timer 1 3 .msg $chan it is now %p1 turn
          unset %counter.chance
          set %counter.chance $rand(1,4)
        }
        else {
          dec %P1HP %sonicboom
          .timer 1 1 .msg $chan SONIC BOOM!
          .timer 1 2 .describe $chan $nick uses sonic boom! %P1 takes %sonicboom damage.
          if (%p1hp <= 0) {
            .timer 2 3 .msg $chan K.O.! %p2 has owned %p1 in Chat Fighter
            /kick $chan %p1
            /timer 1 120 /mode -b %p1
            cfover 
          }
          else {
            .timer 1 3 .msg $chan %P1 has %p1hp HP/ %p2 has %p2hp HP, it is now %p1 turn
            setsonicboom
            setcounter.chance
          }  
        }
      }
      if  (( $2 == yogafire )) {
        ***************************************************
        Player 2 yogafire
        ***************************************************
        set %turn %P1
        if (( %counter.chance == 1 )) {
          dec %p2hp %counter
          .timer 1 1 .describe $chan %p1 has countered! $nick takes %counter damage
          .timer 1 2 .msg $chan %p1 has %p1hp HP/ %p2 has %p2hp HP 
          .timer 1 3 .msg $chan it is now %p1 turn
          unset %counter.chance
          set %counter.chance $rand(1,4)
        }
        else {
          dec %P1HP %yogafire
          .timer 1 1 .msg $chan YOGA FIRE!
          .timer 1 2 .describe $chan $nick uses yoga fire! %P1 takes %yogafire damage.
          if (%p1hp <= 0) {
            .timer 2 3 .msg $chan K.O.! %p2 has owned %p1 in Chat Fighter
            /kick $chan %p1
            /timer 1 120 /mode -b %p1
            cfover 
          }
          else {
            .timer 1 3 .msg $chan %P1 has %p1hp HP/ %p2 has %p2hp HP, it is now %p1 turn
            setyogafire
            setcounter.chance
          }  
        }
      }

      ******************************************************
      Player 2 no move set
      ******************************************************
      elseif (( $2 == $null )) {
        set %turn %p1
        dec %P2HP %counter
        .timer 1 1 .describe $chan %p1 has countered! $nick takes %counter damage
        .timer 1 2 .msg $chan %p1 has %p1hp / %p2 has %p2hp
        unset %counter.chance
        set %counter.chance $rand(1,4)
        if (%p1hp <= 0) {
          .timer 2 1 .msg $chan K.O.! %p1 has owned %p2 in Chat Fighter
          /kick $chan %p2
          /timer 1 120 /mode -b %p2
          cfover 
        }
      }
    }
  }
}

on *:TEXT:!setchatfighter*:#: {
  if ($nick isop $chan) {
    if ($2 == on) {
      set %on.off on | .msg $chan Chat Fighter is now on.
    }
    elseif ($2 == off) {
      unset %on.off | unset %f | cfover | .msg $chan Chat Fighter is now off.
    }
  }
}

Comments

Sign in to comment.
simants   -  Oct 03, 2011

when I get it to fight it always counters a K.O's

 Respond  
Majishine   -  Oct 12, 2010

I was thinking about making it write to on ini file for record keeping.
Also, since my bot is hosted on Justin.tv IRC servers. They have it set so that when someone is kicked, by default their servers ban that person from talking in the room for 10 minutes(They call it a TimeOut), so without the unban timer, users would suffer an entire 10 minutes of not being able to chat.
A HP bar would be cool, but another reason this is all text based is because once again since it's on Justin.tv IRC servers, most users will be using a javabased applet to access the chat room which does not allow for color coding of texts.
Thanks though.

 Respond  
Lucius   -  Oct 12, 2010

I like the kick on K.O., the hp and counter are also good.
Would be nice to see a win lose record for yourself, or other players though. and instead of having the kick with a timed ban, just a kick would be better, and add in the possibility of a ring-out instead for the temp ban, maybe only once down to 25% or less hp.

I have a hpbar script which might be useful for you, let me know if you want a look but it does use colours more than text.

 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.