2005-02-23 15:33:40 +00:00
/* GamesServ - Small Games Service - NeoStats Addon Module
2006-01-26 15:33:00 +00:00
* * Copyright ( c ) 2006 Justin Hammond , Mark Hetherington , DeadNotBuried
2005-02-23 15:33:40 +00:00
* *
* * This program is free software ; you can redistribute it and / or modify
* * it under the terms of the GNU General Public License as published by
* * the Free Software Foundation ; either version 2 of the License , or
* * ( at your option ) any later version .
* *
* * This program is distributed in the hope that it will be useful ,
* * but WITHOUT ANY WARRANTY ; without even the implied warranty of
* * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* * GNU General Public License for more details .
* *
* * You should have received a copy of the GNU General Public License
* * along with this program ; if not , write to the Free Software
* * Foundation , Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307
* * USA
* *
* * GamesServ CVS Identification
* * $ Id $
*/
# include "neostats.h" /* Required for bot support */
# include "gamesserv.h"
2005-05-25 17:41:26 +00:00
typedef enum STOP_REASON
{
STOP_NONE ,
STOP_NOT_ONLINE ,
2005-10-18 21:31:47 +00:00
STOP_NOT_INCHANNEL
2005-05-25 17:41:26 +00:00
} STOP_REASON ;
/* Prototypes */
2005-10-18 22:13:38 +00:00
static void stopbomb ( char * nic , STOP_REASON reason ) ;
/*
* Bomb Timer Finished
*/
int timerupstopbomb ( void * userptr )
{
stopbomb ( NULL , STOP_NONE ) ;
return NS_SUCCESS ;
}
2005-05-25 17:41:26 +00:00
2005-02-23 15:33:40 +00:00
/*
* Start Bomb Game
*/
2005-10-13 22:39:49 +00:00
int startbomb ( const CmdParams * cmdparams ) {
2005-10-18 22:25:50 +00:00
if ( CheckGameStart ( cmdparams - > source , cmdparams - > av [ 0 ] , GS_GAME_CHANNEL_BOMB , TS_ONE_MINUTE , NS_TRUE , NS_TRUE ) ! = NS_SUCCESS ) {
2005-03-31 02:33:10 +00:00
return NS_SUCCESS ;
2005-02-23 15:33:40 +00:00
}
2005-05-26 02:29:33 +00:00
irc_chanprivmsg ( gs_bot , gameroom [ GS_GAME_CHANNEL_BOMB ] , " \003 7A Bomb has been brought into the channel by %s. Don''t be the last one with it. " , cmdparams - > source - > name ) ;
2005-08-09 12:17:31 +00:00
AddTimer ( TIMER_TYPE_COUNTDOWN , timerupstopbomb , " bombcountdown " , countdowntime [ GS_GAME_CHANNEL_BOMB ] , NULL ) ;
2005-02-23 15:33:40 +00:00
return NS_SUCCESS ;
}
/*
* Throw Bomb
*/
2005-10-13 22:39:49 +00:00
int throwbomb ( const CmdParams * cmdparams ) {
2005-02-23 15:33:40 +00:00
Client * u ;
Channel * c ;
int ttto ;
2005-05-26 02:29:33 +00:00
if ( ! ircstrcasecmp ( cmdparams - > source - > name , gameplayernick [ GS_GAME_CHANNEL_BOMB ] ) & & ( gamestatus [ GS_GAME_CHANNEL_BOMB ] = = GS_GAME_CHANNEL_PLAYING ) ) {
2005-02-23 15:33:40 +00:00
u = FindUser ( cmdparams - > av [ 0 ] ) ;
if ( ! u ) {
2005-05-25 17:41:26 +00:00
stopbomb ( cmdparams - > av [ 0 ] , STOP_NOT_ONLINE ) ;
2005-02-23 15:33:40 +00:00
} else {
2005-05-26 02:29:33 +00:00
c = FindChannel ( gameroom [ GS_GAME_CHANNEL_BOMB ] ) ;
2005-02-23 15:33:40 +00:00
if ( IsChannelMember ( c , u ) ) {
ttto = ( ( rand ( ) % 5 ) + 1 ) ;
2005-05-26 02:29:33 +00:00
if ( ttto < countdowntime [ GS_GAME_CHANNEL_BOMB ] ) {
countdowntime [ GS_GAME_CHANNEL_BOMB ] - = ttto ;
2005-02-23 15:33:40 +00:00
}
switch ( ttto ) {
case 1 :
2005-05-26 02:29:33 +00:00
irc_chanprivmsg ( gs_bot , gameroom [ GS_GAME_CHANNEL_BOMB ] , " \003 7%s places the bomb in %s's pocket. " , gameplayernick [ GS_GAME_CHANNEL_BOMB ] , u - > name ) ;
2005-02-23 15:33:40 +00:00
break ;
case 2 :
2005-05-26 02:29:33 +00:00
irc_chanprivmsg ( gs_bot , gameroom [ GS_GAME_CHANNEL_BOMB ] , " \003 7%s sneaks the bomb next to %s. " , gameplayernick [ GS_GAME_CHANNEL_BOMB ] , u - > name ) ;
2005-02-23 15:33:40 +00:00
break ;
case 3 :
2005-05-26 02:29:33 +00:00
irc_chanprivmsg ( gs_bot , gameroom [ GS_GAME_CHANNEL_BOMB ] , " \003 7%s throws the bomb at %s, who now has a large bruise. " , gameplayernick [ GS_GAME_CHANNEL_BOMB ] , u - > name ) ;
2005-02-23 15:33:40 +00:00
break ;
default :
2005-05-26 02:29:33 +00:00
irc_chanprivmsg ( gs_bot , gameroom [ GS_GAME_CHANNEL_BOMB ] , " \003 7%s passes the Bomb to %s. " , gameplayernick [ GS_GAME_CHANNEL_BOMB ] , u - > name ) ;
2005-02-23 15:33:40 +00:00
break ;
}
if ( IsExcluded ( u ) | | IsMe ( u ) | | IsBot ( u ) | | IsAway ( u ) ) {
2005-05-26 02:29:33 +00:00
irc_chanprivmsg ( gs_bot , gameroom [ GS_GAME_CHANNEL_BOMB ] , " \003 7the Bomb Bounces off an invisible Force Field, and returns to %s. " , gameplayernick [ GS_GAME_CHANNEL_BOMB ] ) ;
2005-02-23 15:33:40 +00:00
} else {
2005-05-26 02:29:33 +00:00
strlcpy ( gameplayernick [ GS_GAME_CHANNEL_BOMB ] , u - > name , MAXNICK ) ;
2005-02-23 15:33:40 +00:00
}
2005-05-26 02:29:33 +00:00
SetTimerInterval ( " bombcountdown " , countdowntime [ GS_GAME_CHANNEL_BOMB ] ) ;
2005-02-23 15:33:40 +00:00
} else {
2005-05-25 17:41:26 +00:00
stopbomb ( cmdparams - > av [ 0 ] , STOP_NOT_INCHANNEL ) ;
2005-02-23 15:33:40 +00:00
}
}
}
return NS_SUCCESS ;
}
/*
* Stop Bomb Game
*/
2005-10-18 22:13:38 +00:00
static void stopbomb ( char * nic , STOP_REASON reason )
2005-05-25 17:41:26 +00:00
{
switch ( reason )
{
case STOP_NOT_ONLINE :
2005-05-26 02:29:33 +00:00
irc_chanprivmsg ( gs_bot , gameroom [ GS_GAME_CHANNEL_BOMB ] , " \003 7%s must be blind there is no %s on the network. " , gameplayernick [ GS_GAME_CHANNEL_BOMB ] , nic ) ;
2005-05-25 17:41:26 +00:00
DelTimer ( " bombcountdown " ) ;
break ;
case STOP_NOT_INCHANNEL :
2005-05-26 02:29:33 +00:00
irc_chanprivmsg ( gs_bot , gameroom [ GS_GAME_CHANNEL_BOMB ] , " \003 7%s must be blind, %s isn''t in the channel. " , gameplayernick [ GS_GAME_CHANNEL_BOMB ] , nic ) ;
2005-02-23 15:33:40 +00:00
DelTimer ( " bombcountdown " ) ;
2005-05-25 17:41:26 +00:00
break ;
default :
break ;
2005-02-23 15:33:40 +00:00
}
2005-05-26 02:29:33 +00:00
irc_kick ( gs_bot , gameroom [ GS_GAME_CHANNEL_BOMB ] , gameplayernick [ GS_GAME_CHANNEL_BOMB ] , " \003 4BOOOOOM !!!!!! " ) ;
CheckPartGameChannel ( GS_GAME_CHANNEL_BOMB ) ;
2005-02-23 15:33:40 +00:00
}