All pastes #751680 Raw Edit

LM11

public text v1 · immutable
#751680 ·published 2007-10-27 16:50 UTC
rendered paste body
; 4-square Game

alias num {
  tokenize 32 $1-
  return $0
}

on *:TEXT:!4square:#:{
  set %4sq.players $nick
  if (%4sq.game == on) { msg $chan There is already a 4-square game in place, please wait until the next round, or until this game has stopped to create/join a new game }
  else { set %4sq.game on | msg $chan $nick has started and joined a 4-square game, the next three players to type !join get to play this round! }
  set %4sq.starter $nick 
  set %4sq.ball $nick
  set %4sq.nplayers 1
  set %4sq.king $nick
}

on *:TEXT:!join:#:{
  if ($nick isin %4sq.players) {
    msg $chan You have already joined a game, please invite more players to join
  }
  elseif ($num(%4sq.players) == 4) {
    msg $chan There are already 4 players in this game, please wait until the round is finished
  }
  else {
    set %4sq.players %4sq.players $nick
    set %4sq.nplayers $calc(%4sq.nplayers + 1)
    if (%4sq.nplayers == 2) { set %4sq.3 $nick }
    elseif (%4sq.nplayers == 3) { set %4sq.2 $nick }
    elseif (%4sq.nplayers == 4) { set %4sq.1 $nick }
    msg $chan $nick has joined the game!
  }
}

on *:TEXT:!hit*:#:{
  timer* off
  set %4sq.hit $rand(1,2)
  if (%4sq.game == off) { msg $chan There is no game in place, please type !4square to begin a game | unset %4sq.hit }
  elseif (%4sq.ball != $nick) { msg $chan $nick $+ , you do not have the ball. }
  elseif ($2 !isin %4sq.players) { msg $chan $2 is not apart of this game | unset %4sq.hit }
  elseif ($2 == $nick) { msg $chan You cannot hit the ball into your own square | unset %4sq.hit }
  elseif (%4sq.hit == 1) { set %4sq.time $rand(14,15) 
    msg $chan $nick hits it at $2 $+ 's square. $2 has %4sq.time seconds to hit the ball. 
    set %4sq.ball $2 
    dec -z %4sq.time
    timer 1 %4sq.time $iif(%4sq.time == $null, msg $chan halting, msg $chan %4sq.ball has failed to hit the ball and moves back to the first square)
  }
  elseif (%4sq.hit == 2) { set %4sq.time $rand(14,15) 
    msg $chan $nick slams it at $2 $+ 's square. $2 has %4sq.time seconds to hit the ball.
    set %4sq.ball $2 
    dec -z %4sq.time
    timer 1 %4sq.time $iif(%4sq.time == $null, msg $chan halting, msg $chan %4sq.ball has failed to hit the ball and moves back to the first square)
  }
} 

on *:TEXT:!ball:#:{
  if ($nick == LordMan11) { set %4sq.ball LordMan11 | describe $chan gives LordMan11 the ball so he can test some more }
  else { msg $chan You do not have permission to use this command }
}

; End 4-square Game