This repository has been archived on 2025-02-12. You can view files and clone it, but cannot push or open issues or pull requests.
NeoStats-gameserv/bomb.c

126 lines
4.3 KiB
C
Raw Permalink Normal View History

/* GamesServ - Small Games Service - NeoStats Addon Module
2006-01-26 15:33:00 +00:00
** Copyright (c) 2006 Justin Hammond, Mark Hetherington, DeadNotBuried
**
** 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,
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
/*
* Start Bomb Game
*/
2005-10-13 22:39:49 +00:00
int startbomb(const CmdParams *cmdparams) {
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-05-26 02:29:33 +00:00
irc_chanprivmsg (gs_bot, gameroom[GS_GAME_CHANNEL_BOMB], "\0037A 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);
return NS_SUCCESS;
}
/*
* Throw Bomb
*/
2005-10-13 22:39:49 +00:00
int throwbomb(const CmdParams *cmdparams) {
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 ) ) {
u = FindUser (cmdparams->av[0]);
if (!u) {
2005-05-25 17:41:26 +00:00
stopbomb( cmdparams->av[0], STOP_NOT_ONLINE );
} else {
2005-05-26 02:29:33 +00:00
c = FindChannel(gameroom[GS_GAME_CHANNEL_BOMB]);
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;
}
switch (ttto) {
case 1:
2005-05-26 02:29:33 +00:00
irc_chanprivmsg (gs_bot, gameroom[GS_GAME_CHANNEL_BOMB], "\0037%s places the bomb in %s's pocket.", gameplayernick[GS_GAME_CHANNEL_BOMB], u->name);
break;
case 2:
2005-05-26 02:29:33 +00:00
irc_chanprivmsg (gs_bot, gameroom[GS_GAME_CHANNEL_BOMB], "\0037%s sneaks the bomb next to %s.", gameplayernick[GS_GAME_CHANNEL_BOMB], u->name);
break;
case 3:
2005-05-26 02:29:33 +00:00
irc_chanprivmsg (gs_bot, gameroom[GS_GAME_CHANNEL_BOMB], "\0037%s throws the bomb at %s, who now has a large bruise.", gameplayernick[GS_GAME_CHANNEL_BOMB], u->name);
break;
default:
2005-05-26 02:29:33 +00:00
irc_chanprivmsg (gs_bot, gameroom[GS_GAME_CHANNEL_BOMB], "\0037%s passes the Bomb to %s.", gameplayernick[GS_GAME_CHANNEL_BOMB], u->name);
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], "\0037the Bomb Bounces off an invisible Force Field, and returns to %s.", gameplayernick[GS_GAME_CHANNEL_BOMB]);
} else {
2005-05-26 02:29:33 +00:00
strlcpy (gameplayernick[GS_GAME_CHANNEL_BOMB], u->name, MAXNICK);
}
2005-05-26 02:29:33 +00:00
SetTimerInterval("bombcountdown", countdowntime[GS_GAME_CHANNEL_BOMB]);
} else {
2005-05-25 17:41:26 +00:00
stopbomb( cmdparams->av[0], STOP_NOT_INCHANNEL );
}
}
}
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], "\0037%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], "\0037%s must be blind, %s isn''t in the channel.", gameplayernick[GS_GAME_CHANNEL_BOMB], nic);
DelTimer ("bombcountdown");
2005-05-25 17:41:26 +00:00
break;
default:
break;
}
2005-05-26 02:29:33 +00:00
irc_kick(gs_bot, gameroom[GS_GAME_CHANNEL_BOMB], gameplayernick[GS_GAME_CHANNEL_BOMB], "\0034BOOOOOM !!!!!!");
CheckPartGameChannel(GS_GAME_CHANNEL_BOMB);
}