arena.c
demise/src/arena.c · 16.5 KB
From the archive dodbackup-final.tar.gz
Download the archive « Back to the archive contents
/* Hmm. An attempt..
At a godwars battle arena
Da dun dun dun da..
*/
/***************************************************************************
* God Wars Mud originally written by KaVir aka Richard Woolcock. *
* Changes done to the code done by Sage aka Walter Howard, this mud is *
* for the public, however if you run this code it means you agree *
* to the license.low, license.gw, and license.merc have fun. :) *
***************************************************************************/
#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#endif
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "merc.h"
#include "arena.h"
void clean_arena args ((CHAR_DATA * loser, CHAR_DATA * winner));
void do_ainfo args ((CHAR_DATA * ch, char *argument));
bool
is_inarena (CHAR_DATA * ch)
{
if (IS_SET (ch->corbits, COR_INARENA))
{
stc ("You cannot do that while in the arena!\n\r", ch);
return TRUE;
}
else if (IS_SET (ch->xxbits, XX_ROYALRUMBLE))
{
stc ("You cannot do that while in the arena!\n\r", ch);
return TRUE;
}
else if (ch->in_room->vnum >= 50 && ch->in_room->vnum <= 70)
{
stc ("You cannot do that while in the arena!\n\r", ch);
return TRUE;
}
else if (ch->in_room->vnum >= 25024 && ch->in_room->vnum <= 25090)
return TRUE;
else
return FALSE;
}
bool
inarena (CHAR_DATA * ch)
{
if (IS_SET (ch->corbits, COR_INARENA))
{
return TRUE;
}
else if (IS_SET (ch->xxbits, XX_ROYALRUMBLE))
{
return TRUE;
}
else if (ch->in_room->vnum >= 50 && ch->in_room->vnum <= 70)
{
return TRUE;
}
else if (ch->in_room->vnum >= 25024 && ch->in_room->vnum <= 25090)
return TRUE;
else
return FALSE;
}
bool
is_asafe (CHAR_DATA * ch, CHAR_DATA * victim)
{
if (inarena (ch) && !inarena (victim))
{
stc
("You cannot affect someone outside of the arena while in the arena!\n\r",
ch);
return TRUE;
}
else if (!inarena (ch) && inarena (victim))
{
stc
("You cannot affect someone in the arena when your not in the arena!\n\r",
ch);
return TRUE;
}
else
return FALSE;
}
void
do_decline (CHAR_DATA * ch, char *argument)
{
CHAR_DATA *victim;
char buf[MSL];
if (IS_NPC (ch))
return;
if (ch->challenged == NULL)
{
stc ("You have not been challenged.\n\r", ch);
return;
}
if (!IS_SET (ch->corbits, COR_CHALLENGED))
{
stc ("You have not been challenged.\n\r", ch);
return;
}
if (is_inarena (ch))
return;
victim = ch->challenged;
sprintf (buf, "#c%s#7 has declined#c %s#7'#cs#7 challenge.#n", ch->name,
victim->name);
do_ainfo (ch, buf);
arena = FIGHT_CLEAR;
undo_arena (ch);
return;
}
void
do_ainfo (CHAR_DATA * ch, char *argument)
{
DESCRIPTOR_DATA *d;
if (argument[0] == '\0')
{
return;
}
if (!IS_NPC (ch) && IS_IMMORTAL (ch) && IS_SET (ch->act, PLR_WIZINVIS))
return;
for (d = descriptor_list; d != NULL; d = d->next)
{
if (d->connected == CON_PLAYING &&
!IS_SET (d->character->deaf, CHANNEL_INFO))
{
send_to_char ("#r[#c<#yArena#c>#r]#7 ", d->character);
send_to_char (argument, d->character);
send_to_char (" #r[#c<#yArena#c>#r]#n\n\r", d->character);
}
}
return;
}
void
do_challenge (CHAR_DATA * ch, char *argument)
{
CHAR_DATA *victim;
char arg[MIL];
char buf[MSL];
argument = one_argument (argument, arg);
if (IS_NPC (ch))
return;
if (arena != FIGHT_CLEAR)
{
stc ("The arena is not ready for a fight at the moment.\n\r", ch);
return;
}
if (arg[0] == '\0')
{
stc ("Who do you want to challenge?\n\r", ch);
return;
}
if ((victim = find_pc_mud (ch, arg)) == NULL)
{
stc ("They aren't even on the mud.\n\r", ch);
return;
}
if (IS_NPC (victim))
{
stc ("Challenge a mobile? You're pathetic.\n\r", ch);
return;
}
if (IS_NEWBIE (victim))
{
stc ("Challenge a newbie.... how low can you get, damn pussy!.\n\r",
ch);
return;
}
if (IS_NEWBIE (ch))
{
stc ("Grow up before you try to play with the big kids.\n\r", ch);
return;
}
if (IS_IMMORTAL (ch))
return;
if (IS_IMMORTAL (victim))
return;
if (victim == ch)
{
stc ("Oh, kill yourself. Fun.\n\r", ch);
return;
}
if (ch->hit < ch->max_hit)
{
stc ("You must be fully healed to use the arena.\n\r", ch);
return;
}
if (victim->hit < victim->max_hit)
{
stc ("Your victim isn't fully healed.\n\r", ch);
return;
}
if (victim->level < 3 || ch->level < 3)
{
stc ("Only avatars may use the Arena.\n\r", ch);
return;
}
if (IS_SET (ch->corbits, COR_CHALLENGED)
|| IS_SET (ch->corbits, COR_CHALLENGER))
{
stc ("Uh. You're already involved in an arena fight.\n\r", ch);
return;
}
if (IS_SET (victim->corbits, COR_CHALLENGED)
|| IS_SET (victim->corbits, COR_CHALLENGER))
{
stc ("They are already involved in an arena fight.\n\r", ch);
return;
}
ch->challenged = victim;
victim->challenged = ch;
ch->arena_timer = 240;
victim->arena_timer = 240;
sprintf (buf, "#c%s#7 has challenged#c %s#7 to a death match.#n", ch->name,
victim->name);
do_ainfo (ch, buf);
stc
("\n\rYou have been challenged to an arena dual.\n\r\n\rTo fight type ARENAAGREE, to wimp out type DECLINE.\n\r",
victim);
SET_BIT (ch->corbits, COR_CHALLENGER);
SET_BIT (victim->corbits, COR_CHALLENGED);
arena = FIGHT_PRE;
return;
}
void
do_arenaagree (CHAR_DATA * ch, char *argument)
{
CHAR_DATA *victim;
ROOM_INDEX_DATA *chroom;
ROOM_INDEX_DATA *victroom;
char buf[MSL];
OBJ_DATA *obj;
if (IS_NPC (ch))
return;
if (!IS_SET (ch->corbits, COR_CHALLENGED))
{
stc ("You weren't even challenged.\n\r", ch);
return;
}
if (is_inarena (ch))
return;
for (obj = ch->carrying; obj != NULL; obj = obj->next_content)
{
if (obj->chobj != NULL)
{
send_to_char
("You cannot enter the arena carrying living objects.\n\r", ch);
return;
}
}
if (ch->challenged == NULL)
{
stc
("Oddly enough, You have been challenged by someone, yet.. You haven't.\n\r",
ch);
REMOVE_BIT (ch->corbits, COR_CHALLENGED);
arena = FIGHT_CLEAR;
sprintf (buf, "The Arena is Clear.\n");
do_ainfo (ch, buf);
}
victim = ch->challenged;
sprintf (buf, "#c%s#7 has accepted#c %s#7'#cs#7 challenge.", ch->name,
victim->name);
arena = FIGHT_START;
SET_BIT (ch->corbits, COR_INARENA);
SET_BIT (victim->corbits, COR_INARENA);
ch->embrace = NULL;
ch->embraced = ARE_NONE;
victim->embrace = NULL;
victim->embraced = ARE_NONE;
ch->deadplane = ch->in_room->area->plane;
victim->deadplane = victim->in_room->area->plane;
char_from_room (ch);
char_from_room (victim);
victim->arena_timer = 0;
ch->arena_timer = 0;
if (ch->hit != ch->max_hit)
ch->hit = ch->max_hit;
if (victim->hit != victim->max_hit)
victim->hit = victim->max_hit;
chroom = get_room_index (number_range (50, 70));
victroom = get_room_index (number_range (50, 70));
if (victroom == chroom)
chroom = get_room_index (number_range (50, 70));
char_to_room (ch, chroom);
char_to_room (victim, victroom);
stc ("The fight has begun! Good luck!\n\r", ch);
stc ("The fight has begun! Good luck!\n\r", victim);
do_look (ch, "");
do_look (victim, "");
do_ainfo (ch, buf);
return;
}
void
clean_arena (CHAR_DATA * loser, CHAR_DATA * winner)
{
int vnum;
char buf[MSL];
REMOVE_BIT (loser->corbits, COR_CHALLENGED);
REMOVE_BIT (loser->corbits, COR_CHALLENGER);
REMOVE_BIT (loser->corbits, COR_INARENA);
if (is_affected (loser, gsn_tracer))
{
affect_strip (loser, gsn_tracer);
}
if (IS_AFFECTED (loser, AFF_TRACER))
{
REMOVE_BIT (loser->affected_by, AFF_TRACER);
}
loser->challenged = NULL;
loser->hit = loser->max_hit;
loser->move = loser->max_move;
loser->mana = loser->max_mana;
loser->agg = 0;
update_pos (loser);
do_call (loser, "all");
do_save (loser, "");
loser->alosses++;
loser->fight_timer = 0;
if (IS_XX (loser, XX_ADVPOISON))
REMOVE_BIT (loser->xxbits, XX_ADVPOISON);
if (IS_XX (winner, XX_ADVPOISON))
REMOVE_BIT (winner->xxbits, XX_ADVPOISON);
if (loser->deadplane == PLANE_NEXUS)
{
vnum = ROOM_VNUM_ALTAR;
}
else if (loser->deadplane == PLANE_PAND)
{
vnum = number_range (45701, 45800);
}
else if (loser->deadplane == PLANE_TRANQ)
{
vnum = 45842;
}
else if (loser->deadplane == PLANE_OMNI)
{
vnum = ROOM_VNUM_ALTAR;
}
else if (loser->deadplane == PLANE_HEAVEN)
{
vnum = ROOM_VNUM_HEAVEN;
}
else if (loser->deadplane == PLANE_HELL)
{
vnum = ROOM_VNUM_HELL;
}
else if (loser->deadplane == PLANE_LIMBO)
{
vnum = number_range (45901, 45911);
}
else if (loser->deadplane == PLANE_VALHALLA)
{
vnum = number_range (25, 49);
}
else
{
vnum = ROOM_VNUM_ALTAR;
}
loser->deadplane = 0;
char_from_room (loser);
char_to_room (loser, get_room_index (vnum));
REMOVE_BIT (winner->corbits, COR_CHALLENGED);
REMOVE_BIT (winner->corbits, COR_CHALLENGER);
REMOVE_BIT (winner->corbits, COR_INARENA);
if (is_affected (winner, gsn_tracer))
{
affect_strip (winner, gsn_tracer);
}
if (IS_AFFECTED (winner, AFF_TRACER))
{
REMOVE_BIT (winner->affected_by, AFF_TRACER);
}
winner->challenged = NULL;
winner->hit = winner->max_hit;
winner->mana = winner->max_mana;
winner->move = winner->max_move;
winner->agg = 0;
update_pos (winner);
do_call (winner, "all");
do_save (winner, "");
winner->awins++;
winner->fight_timer = 0;
if (winner->deadplane == PLANE_NEXUS)
{
vnum = ROOM_VNUM_ALTAR;
}
else if (winner->deadplane == PLANE_PAND)
{
vnum = number_range (45701, 45800);
}
else if (winner->deadplane == PLANE_TRANQ)
{
vnum = 45842;
}
else if (winner->deadplane == PLANE_OMNI)
{
vnum = ROOM_VNUM_ALTAR;
}
else if (winner->deadplane == PLANE_HEAVEN)
{
vnum = ROOM_VNUM_HEAVEN;
}
else if (winner->deadplane == PLANE_HELL)
{
vnum = ROOM_VNUM_HELL;
}
else if (winner->deadplane == PLANE_LIMBO)
{
vnum = number_range (45901, 45911);
}
else if (winner->deadplane == PLANE_VALHALLA)
{
vnum = number_range (25, 49);
}
else
{
vnum = ROOM_VNUM_ALTAR;
}
winner->deadplane = 0;
char_from_room (winner);
char_to_room (winner, get_room_index (vnum));
do_look (winner, "");
do_look (loser, "");
sprintf (buf, "#c%s#7 has defeated#c %s#7!", winner->name, loser->name);
do_ainfo (winner, buf);
arena = FIGHT_CLEAR;
return;
}
void
undo_arena (CHAR_DATA * ch)
{
CHAR_DATA *victim;
CHAR_DATA *avictim;
char name[MSL];
int vnum;
if (ch->challenged != NULL)
{
victim = ch->challenged;
sprintf (name, "%s", victim->name);
if ((avictim = get_char_world (ch, name)) == NULL)
{
REMOVE_BIT (ch->corbits, COR_CHALLENGED);
REMOVE_BIT (ch->corbits, COR_CHALLENGER);
REMOVE_BIT (ch->corbits, COR_INARENA);
ch->challenged = NULL;
}
else
{
REMOVE_BIT (ch->corbits, COR_CHALLENGED);
REMOVE_BIT (ch->corbits, COR_CHALLENGER);
REMOVE_BIT (ch->corbits, COR_INARENA);
ch->challenged = NULL;
REMOVE_BIT (avictim->corbits, COR_CHALLENGED);
REMOVE_BIT (avictim->corbits, COR_CHALLENGER);
REMOVE_BIT (avictim->corbits, COR_INARENA);
avictim->challenged = NULL;
if (avictim->in_room->vnum >= 50 && avictim->in_room->vnum <= 70)
{
if (avictim->deadplane == PLANE_NEXUS)
{
vnum = ROOM_VNUM_ALTAR;
}
else if (avictim->deadplane == PLANE_PAND)
{
vnum = number_range (45701, 45800);
}
else if (avictim->deadplane == PLANE_TRANQ)
{
vnum = 45842;
}
else if (avictim->deadplane == PLANE_OMNI)
{
vnum = ROOM_VNUM_ALTAR;
}
else if (avictim->deadplane == PLANE_HEAVEN)
{
vnum = ROOM_VNUM_HEAVEN;
}
else if (avictim->deadplane == PLANE_HELL)
{
vnum = ROOM_VNUM_HELL;
}
else if (avictim->deadplane == PLANE_LIMBO)
{
vnum = number_range (45901, 45911);
}
else if (avictim->deadplane == PLANE_VALHALLA)
{
vnum = number_range (25, 49);
}
else
{
vnum = ROOM_VNUM_ALTAR;
}
avictim->deadplane = 0;
char_from_room (avictim);
char_to_room (avictim, get_room_index (vnum));
}
}
}
else
{
REMOVE_BIT (ch->corbits, COR_CHALLENGED);
REMOVE_BIT (ch->corbits, COR_CHALLENGER);
REMOVE_BIT (ch->corbits, COR_INARENA);
}
if (ch->in_room->vnum >= 50 && ch->in_room->vnum <= 70)
{
if (ch->deadplane == PLANE_NEXUS)
{
vnum = ROOM_VNUM_ALTAR;
}
else if (ch->deadplane == PLANE_PAND)
{
vnum = number_range (45701, 45800);
}
else if (ch->deadplane == PLANE_TRANQ)
{
vnum = 45842;
}
else if (ch->deadplane == PLANE_OMNI)
{
vnum = ROOM_VNUM_ALTAR;
}
else if (ch->deadplane == PLANE_HEAVEN)
{
vnum = ROOM_VNUM_HEAVEN;
}
else if (ch->deadplane == PLANE_HELL)
{
vnum = ROOM_VNUM_HELL;
}
else if (ch->deadplane == PLANE_LIMBO)
{
vnum = number_range (45901, 45911);
}
else if (ch->deadplane == PLANE_VALHALLA)
{
vnum = number_range (25, 49);
}
else
{
vnum = ROOM_VNUM_ALTAR;
}
ch->deadplane = 0;
char_from_room (ch);
char_to_room (ch, get_room_index (vnum));
}
return;
}
void
killed_person (CHAR_DATA * ch, CHAR_DATA * victim)
{
if (IS_NPC (ch))
return;
if (IS_NPC (victim))
return;
bool last = FALSE;
char buf[MSL];
mudconfig->victimsleft--;
if (mudconfig->victimsleft <= 1)
last = TRUE;
ch->pcdata->quest += 5000;
ch->pcdata->crystal += 50;
if (!last)
sprintf (buf, "%s has defeated %s! %d victims remain...", ch->name,
victim->name, mudconfig->victimsleft);
else
sprintf (buf,
"%s has defeated %s! no victims remain... %s is the CHAMPION!",
ch->name, victim->name, ch->name);
do_ainfo (ch, buf);
char_from_room (victim);
char_to_room (victim, get_room_index (victim->pcdata->originalroom));
victim->fight_timer = 0;
ch->fight_timer = 0;
do_restore (ch, "self");
do_restore (victim, "self");
do_call (ch, "all");
do_call (victim, "all");
do_look (victim, "auto");
if (last)
{
char_from_room (ch);
char_to_room (ch, get_room_index (ch->pcdata->originalroom));
do_look (ch, "auto");
mudconfig->victimsleft = 0;
}
return;
}
void
join_arena (CHAR_DATA * ch)
{
if (IS_NPC (ch))
return;
if (is_inarena (ch))
return;
char buf[MSL];
ROOM_INDEX_DATA *pRoomIndex;
mudconfig->victimsleft++;
pRoomIndex = get_room_index (number_range (25024, 25090));
while (pRoomIndex == NULL)
pRoomIndex = get_room_index (number_range (25024, 25090));
ch->pcdata->originalroom = ch->in_room->vnum;
char_from_room (ch);
char_to_room (ch, pRoomIndex);
stc ("Die fast, We wish to get this over quickly...\n\r", ch);
do_look (ch, "auto");
sprintf (buf,
"%s has entered the arena in a vain attempt to prove their worth...",
ch->name);
do_ainfo (ch, buf);
return;
}
void
do_joinarena (CHAR_DATA * ch, char *argument)
{
if (IS_NEWBIE (ch))
{
stc ("No newbies in the arena...\n\r", ch);
return;
}
if (ch->pcdata->quest <= 2500)
{
stc ("You dont have enough credits!\n\r", ch);
return;
}
if (ch->pcdata->crystal <= 25)
{
stc ("You dont have enough crystals!\n\r", ch);
return;
}
ch->pcdata->quest -= 2500;
ch->pcdata->crystal -= 25;
join_arena (ch);
return;
}
void
leave_arena (CHAR_DATA * ch)
{
if (IS_NPC (ch))
return;
ROOM_INDEX_DATA *oldroom;
oldroom = get_room_index (ch->pcdata->originalroom);
if (oldroom == NULL)
oldroom = get_room_index (3001);
if (!is_inarena (ch))
return;
char buf[MSL];
mudconfig->victimsleft--;
if (mudconfig->victimsleft < 0)
mudconfig->victimsleft = 0;
char_from_room (ch);
char_to_room (ch, oldroom);
do_look (ch, "auto");
if (mudconfig->victimsleft < 1)
sprintf (buf, "%s has left the arena.", ch->name);
else
sprintf (buf, "%s has wimped out and left the arena.", ch->name);
do_ainfo (ch, buf);
return;
}
void
do_leavearena (CHAR_DATA * ch, char *argument)
{
if (IS_SET (ch->corbits, COR_INARENA))
{
stc ("You cannot do that while in the arena!\n\r", ch);
return;
}
leave_arena (ch);
return;
}