/*************************************************************************** * God Wars Mud copyright (C) 1994, 1995, 1996 by Richard Woolcock * * * * Legend of Chrystancia copyright (C) 1999, 2000, 2001 by Matthew Little * * This mud is NOT to be copied in whole or in part, or to be run without * * the permission of Matthew Little. Nobody else has permission to * * authorise the use of this code. * ***************************************************************************/ /************************************************************************************ * Arena.c. An attempt to make an ARENA work on A God Wars MUD. Allows players to * * challenge other players to a SAFE spar. * * * * do_decline - Lets players decline from challenge * * do_arenaagree - Lets players agree to the challenged * * do_abet - allow players to bet on arena fights * * do_giveup - allows the player to retire from an arena fight before end * * * * undo_arena/undo_arena2/clean_arena/clean_arena2 - functions to clean up after a * * fight in arena is over. * * do_ainfo - reports all Arena Info to the mud. * * * * If you wish to use this code please email Tijer@godwars.net * * * * (C) Tijer, 2001. * ************************************************************************************/ #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)); NCLANS_DATA *nclans_table; bool is_inarena (CHAR_DATA * ch) { if (IS_SET (ch->flag2, AFF2_INARENA)) { stc ("You cannot do that while in the arena!\n\r", ch); return TRUE; } else return FALSE; } void do_spectate (CHAR_DATA * ch, char *argument) { char buf[MAX_STRING_LENGTH]; DESCRIPTOR_DATA *d; int hp_stats = 0; int mana_stats = 0; int move_stats = 0; if (IS_NPC (ch)) return; if (arena != FIGHT_START) { stc ("There is no one currently fighting in the arena!\n\r", ch); return; } if (is_inarena (ch)) return; send_to_char ("#b----------------------------------------------#n\n\r", ch); send_to_char ("#wName Hitpoints Mana Move#n\n\r", ch); send_to_char ("#b----------------------------------------------#n\n\r", ch); for (d = first_descriptor; d != NULL; d = d->next) { if (d->character != NULL) { if (d->character->in_room != NULL) { if (!IS_SET (d->character->flag2, AFF2_INARENA)) continue; if (d->character->max_hit > 0) hp_stats = 100 * d->character->hit / d->character->max_hit; if (d->character->max_move > 0) move_stats = 100 * d->character->move / d->character->max_move; if (d->character->max_mana > 0) mana_stats = 100 * d->character->mana / d->character->max_mana; sprintf (buf, "#w%-15s %3d/100 %3d/100 %3d/100\n\r", d->character->name, hp_stats, mana_stats, move_stats); send_to_char (buf, ch); } } } send_to_char ("#b----------------------------------------------#n\n\r", ch); return; } void do_autodecline (CHAR_DATA * ch, char *argument) { CHAR_DATA *victim; char buf[MAX_STRING_LENGTH]; if (IS_NPC (ch)) return; if (ch->challenged == NULL) { stc ("You have not been challenged.\n\r", ch); return; } if (!IS_SET (ch->flag2, AFF2_CHALLENGED)) { stc ("You have not been challenged.\n\r", ch); return; } victim = ch->challenged; ch->arena_timer = 0; victim->arena_timer = 0; do_ainfo (ch, buf); arena = FIGHT_CLEAR; undo_arena2 (ch); return; } void do_decline (CHAR_DATA * ch, char *argument) { CHAR_DATA *victim; char buf[MAX_STRING_LENGTH]; if (IS_NPC (ch)) return; if (ch->challenged == NULL) { stc ("You have not been challenged.\n\r", ch); return; } if (!IS_SET (ch->flag2, AFF2_CHALLENGED)) { stc ("You have not been challenged.\n\r", ch); return; } if IS_SET (ch->flag2, AFF2_INARENA) { stc ("You cannot decline. The fight has started.\n\r", ch); return; } REMOVE_BIT (ch->flag2, AFF2_SAFE); victim = ch->challenged; sprintf (buf, "%s has declined %s's challenge.", ch->name, victim->name); do_ainfo (ch, buf); send_to_char ("Challenge declined!\n\r", ch); act ("$n has declined your challenge.", ch, NULL, victim, TO_VICT); if (IS_SET(ch->flag2, AFF2_RANKFIGHT) && IS_SET(victim->flag2, AFF2_RANKFIGHT) && ch->pcdata->stats[UNI_GEN] == 1) { sprintf(buf,"%s has declined %s's RANK challenge, so %s is the new class leader.",ch->name,victim->name,victim->name); do_ainfo (ch, buf); ch->pcdata->stats[UNI_GEN]++; victim->pcdata->stats[UNI_GEN]--; } ch->arena_timer = 0; victim->arena_timer = 0; arena = FIGHT_CLEAR; undo_arena (ch); undo_arena (victim); return; } void do_giveup (CHAR_DATA * ch, char *argument) { CHAR_DATA *victim; char buf[MAX_STRING_LENGTH]; if (IS_NPC (ch)) return; if (ch->challenged == NULL) { stc ("You have not been challenged.\n\r", ch); return; } if (ch->position == POS_FIGHTING) { stc ("Not While you are fighting.\n\r", ch); return; } if (!IS_SET (ch->flag2, AFF2_INARENA)) { stc ("You cannot giveup you arent in the arena\n\r", ch); return; } if (ch->hit < (ch->max_hit / 2)) { stc ("The Fight is almost over, you are unable to give up\n\r", ch); return; } if (IS_SET (ch->flag2, AFF2_STATUSFIGHT)) { stc ("You can't give up in a status fight!\n\r", ch); return; } if (IS_SET (ch->flag2, AFF2_RANKFIGHT)) { stc ("You can't give up in a rank fight!\n\r", ch); return; } if (IS_SET (ch->flag2, AFF2_LEADERFIGHT)) { stc ("You can't give up in a leader fight!\n\r", ch); return; } REMOVE_BIT (ch->flag2, AFF2_SAFE); victim = ch->challenged; sprintf (buf, "%s has retired from %s's challenge.", ch->name, victim->name); do_ainfo (ch, buf); arena = FIGHT_CLEAR; undo_arena2 (ch); undo_arena2 (victim); return; } void do_ainfo (CHAR_DATA * ch, char *argument) { DESCRIPTOR_DATA *d; char buf[MAX_STRING_LENGTH]; if (argument[0] == '\0') { return; } if (!IS_NPC (ch) && IS_IMMORTAL (ch) && IS_SET (ch->act, PLR_WIZINVIS)) return; for (d = first_descriptor; d != NULL; d = d->next) { if (d->connected == CON_PLAYING && !IS_SET (d->character->deaf, CHANNEL_INFO)) { sprintf (buf, "#r[<Arena>] #y%s #r[<Arena>]#n", argument); cent_to_char (buf, d->character); } } return; } void do_challenge (CHAR_DATA * ch, char *argument) { CHAR_DATA *victim; char arg[MAX_INPUT_LENGTH]; char buf[MAX_STRING_LENGTH]; char aratio[MSL]; extern int copycount; bool status = FALSE; bool rank = FALSE; bool leader = FALSE; argument = one_argument (argument, arg); if (IS_NPC (ch)) return; if (IS_IMMORTAL (ch)) { stc ("You failed!\n\r", ch); return; } if (copycount > 0) { stc("Not while there is a copyover active\n\r",ch); return; } if (get_hours (ch) < 10 && !IS_SET (ch->extra2, PKREADY)) { stc ("You need atleast 10 hrs before you can challenge\n\r", ch); return; } if (ch->pcdata->login_timer > 0) { stc("Not with a login timer!\n\r",ch); return; } if (ch->fight_timer > 0) { stc("Not with a fight timer!\n\r",ch); return; } if (IS_CLASS (ch, CLASS_NINJA) && IS_AFFECTED (ch, AFF_HIDE)) { stc ("You emerge from the shadows!\n\r", ch); REMOVE_BIT (ch->affected_by, AFF_HIDE); } if (arena != FIGHT_CLEAR) { stc ("The arena is not ready for a fight at the moment.\n\r", ch); return; } if (arena == FIGHT_LOCK) { send_to_char ("Sorry, the arena is currently locked from use.\n\r", ch); return; } if (arg[0] == '\0') { stc ("Who do you want to challenge?\n\r", ch); return; } if ((victim = get_char_world (ch, arg)) == NULL) { stc ("They aren't even on the mud.\n\r", ch); return; } REMOVE_BIT (ch->flag2, AFF2_STATUSFIGHT); REMOVE_BIT (victim->flag2, AFF2_STATUSFIGHT); if (IS_IMMORTAL (victim)) { stc ("You dont wanna do that!\n\r", ch); return; } if (IS_SET (ch->war, JOINING) || IS_SET (ch->war, WARRING)) { stc ("Not while in a war!\n\r", ch); return; } if (IS_SET (victim->war, JOINING) || IS_SET (victim->war, WARRING)) { stc ("Not while in a war!\n\r", ch); return; } if (IS_NPC (victim)) { stc ("Challenge a mobile? You're pathetic.\n\r", ch); return; } if (ch->fight_timer > 0) { stc("Not with a fight timer!\n\r", ch); return; } if (victim->fight_timer > 0) { stc("Not while they have a fight timer!\n\r", ch); return; } if (get_hours (victim) < 10 && !IS_SET (victim->extra2, PKREADY)) { stc ("You are unable to challenge them to an arena fight until they have 10 hrs.\n\r", ch); return; } if (victim == ch) { stc ("Oh, kill yourself. Fun.\n\r", ch); return; } if (victim->pcdata->login_timer > 0) { stc("They have a login timer!\n\r",ch); return; } if (victim->fight_timer > 0) { stc("They have a fight timer!\n\r",ch); return; } if (victim->desc == NULL) { send_to_char ("That player is linkdead at the moment, try them later.\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->fighting != NULL) { send_to_char ("That person is engaged in battle right now.\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->flag2, AFF2_CHALLENGED) || IS_SET (ch->flag2, AFF2_CHALLENGER)) { stc ("Uh. You're already involved in an arena fight.\n\r", ch); return; } if (IS_SET (victim->flag2, AFF2_CHALLENGED) || IS_SET (victim->flag2, AFF2_CHALLENGER)) { stc ("They are already involved in an arena fight.\n\r", ch); return; } if (!str_cmp (argument, "rank")) { if (ch->class != victim->class) { send_to_char("They are not of the same class.\n\r",ch); return; } if (ch->pcdata->stats[UNI_GEN] == 2 && victim->pcdata->stats[UNI_GEN] == 1) { rank = TRUE; } else { send_to_char("You can't challenge them for their rank.\n\r",ch); return; } } if (!str_cmp (argument, "leader")) { if (ch->class != victim->class) { stc("But they are not of your class!\n\r",ch); return; } if (victim->clannum != 0) { send_to_char("It might help if they HAD a clan!\n\r",ch); return; } if (ch->clannum != victim->clannum && ch->clannum != 0) { send_to_char("But you must be either in the clan or unclanned!\n\r",ch); return; } //if (ch->clannum != victim->clannum) { send_to_char("They are not of your clan.\n\r",ch); return; } if (!str_cmp(ch->name, nclans_table[ch->clannum].leader)) { send_to_char("But you are already the leader!\n\r",ch); return; } if (!str_cmp(victim->name, nclans_table[victim->clannum].leader)) { leader = TRUE; } else { send_to_char("You can't challenge them for their leader position.\n\r",ch); return; } } if (!str_cmp (argument, "status")) { if ((ch->race - victim->race) > WizConfig->paradoxlimit && victim->race < 50) send_to_char ("They are not within the status window. Normal challenge issued.\n\r", ch); else if ((victim->race - ch->race) > WizConfig->paradoxlimit && ch->race < 50) send_to_char ("You are not within the status window. Normal challenge issued.\n\r", ch); else if (ch->race <= 0) send_to_char ("You don't have any status! Normal challenge issued.\n\r", ch); else if (victim->race <= 0) send_to_char ("They don't have any status! Normal challenge issued.\n\r", ch); else if (ch->pcdata->schallenge > 0) stc ("You cant for STATUS, as you have a status challenge timer. Normal challenge issued. n\n\r", ch); else if (victim->pcdata->schallenge > 0) stc ("They have a status challenge timer. Normal challenge issued.\n\r", ch); else { ch->pcdata->schallenge = 900; victim->pcdata->schallenge = 900; status = TRUE; } } if (IS_SET (ch->extra2, NHELPER) && (status)) { stc ("You cannot challenge people to status fights, you are a Newbie Helper\n\r", ch); return; } if (IS_SET (victim->extra2, NHELPER) && (status)) { stc ("You cannot challenge Newbie Helpers to status fights.\n\r", ch); return; } ch->challenged = victim; victim->challenged = ch; sprintf (buf, "%s has challenged you to an arena fight.\n\rTo accept type arenaagree.\n\rTo decline type decline.\n\r", ch->name); stc (buf, victim); if (status == TRUE) { send_to_char ("#rThis challenge is for STATUS.#n\n\r", ch); } if (leader == TRUE) { send_to_char ("#rThis challenge is for THE CLANLEADER SPOT.#n\n\r", ch); } if (victim->awins > 0) { if (100 * victim->awins / (victim->awins + victim->alosses) < 100) sprintf (aratio, "0.%-2d", (100 * victim->awins / (victim->awins + victim->alosses))); else sprintf (aratio, "1.00"); } else sprintf (aratio, "0.00"); { send_to_char ("\n\r#r----------------------------------------------------------------------------------\n\r", victim); sprintf (buf, "#r%s #chas #r%d #carena wins and #c%d #warena losses, with an arena ratio of #r%s#n\n\r", ch->name, ch->awins, ch->alosses, aratio); stc (buf, victim); send_to_char ("#r----------------------------------------------------------------------------------#n\n\r\n\r", victim); } sprintf (buf, "%s has challenged %s to a death match%s%s%s.", ch->name, victim->name, status == TRUE ? "#r for status#y" : "", rank == TRUE ? "#r#F for rank#n#y" : "", leader == TRUE ? "#r for the leader spot#y" : ""); do_ainfo (ch, buf); SET_BIT (ch->flag2, AFF2_SAFE); SET_BIT (victim->flag2, AFF2_SAFE); SET_BIT (ch->flag2, AFF2_CHALLENGER); SET_BIT (victim->flag2, AFF2_CHALLENGED); if (status == TRUE) { SET_BIT (ch->flag2, AFF2_STATUSFIGHT); SET_BIT (victim->flag2, AFF2_STATUSFIGHT); } if (rank == TRUE) { SET_BIT (ch->flag2, AFF2_RANKFIGHT); SET_BIT (victim->flag2, AFF2_RANKFIGHT); } if (leader == TRUE) { SET_BIT (ch->flag2, AFF2_LEADERFIGHT); SET_BIT (victim->flag2, AFF2_LEADERFIGHT); } victim->arena_timer = 30; 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[MAX_STRING_LENGTH]; extern int copycount; float odd1, odd2; float lvl1, lvl2; char buf1[MAX_STRING_LENGTH]; char buf2[MAX_STRING_LENGTH]; char buf3[MAX_STRING_LENGTH]; OBJ_DATA *obj; if (IS_NPC (ch)) return; if (ch->pcdata->login_timer > 0) { stc("Not with a login timer!\n\r",ch); return; } if (ch->fight_timer > 0) { stc("Not with a fight timer!\n\r",ch); return; } if (copycount > 0) { do_decline(ch, ""); return; } if (!IS_SET (ch->flag2, AFF2_CHALLENGED)) { stc ("You weren't even challenged.\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->flag2, AFF2_CHALLENGED); arena = FIGHT_CLEAR; sprintf (buf, "The Arena is Clear.\n"); do_ainfo (ch, buf); } victim = ch->challenged; if (IS_SET (ch->flag2, AFF2_INARENA)) { stc ("You have already agreed to the fight!\n\r", ch); return; } if (IS_AFFECTED (ch, AFF_SHADOWPLANE)) REMOVE_BIT (ch->affected_by, AFF_SHADOWPLANE); if (IS_AFFECTED (victim, AFF_SHADOWPLANE)) REMOVE_BIT (victim->affected_by, AFF_SHADOWPLANE); /* * Stop the Gladiators from taking people in OBJECT FORM * with them to the ARENA */ 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; } } for (obj = victim->carrying; obj != NULL; obj = obj->next_content) { if (obj->chobj != NULL) { send_to_char ("They cannot enter the arena carrying living objects.\n\r", victim); return; } } send_to_char ("You have accepted the challenge!\n\r", ch); act ("$n accepts your challenge!", ch, NULL, victim, TO_VICT); sprintf (buf, "%s has accepted %s's challenge.", ch->name, victim->name); do_ainfo (ch, buf); /* * Announce the up and coming event */ lvl1 = ch->hit; lvl2 = victim->hit; odd1 = (lvl1 / lvl2); odd2 = (lvl2 / lvl1); sprintf (buf1, "%s (%d wins) (%d losses) Payoff odds %f", victim->name, victim->awins, victim->alosses, odd1); sprintf (buf2, "%s (%d wins) (%d losses) Payoff odds %f", ch->name, ch->awins, ch->alosses, odd2); sprintf (buf3, "To wager on the fight, type: abet (amount) (player name)"); do_ainfo (ch, buf1); do_ainfo (ch, buf2); do_ainfo (ch, buf3); ch->arena_timer = 0; arena = FIGHT_START; REMOVE_BIT (ch->flag2, AFF2_SAFE); REMOVE_BIT (victim->flag2, AFF2_SAFE); SET_BIT (ch->flag2, AFF2_INARENA); SET_BIT (victim->flag2, AFF2_INARENA); char_from_room (ch); char_from_room (victim); chroom = get_room_index (number_range (12000, 12010)); victroom = get_room_index (number_range (12000, 12010)); if (victroom == chroom) chroom = get_room_index (number_range (12000, 12010)); 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, ""); return; } void clean_arena (CHAR_DATA * loser, CHAR_DATA * winner) { char buf[MAX_STRING_LENGTH]; DESCRIPTOR_DATA *d; /* needed for Arena bet checking */ float odds; float lvl1, lvl2; int payoff; if (loser == winner) { CHAR_DATA *player; for (player = char_list; player != NULL; player = player->next) if (!IS_NPC(player) && player != loser && player->in_room != NULL && is_inarena(player)) { winner = player; break; } } if (IS_SET (winner->flag2, AFF2_STATUSFIGHT) && IS_SET (loser->flag2, AFF2_STATUSFIGHT)) { winner->race++; loser->race--; sprintf (buf, "%s has lost status... and %s has found it!", loser->name, winner->name); do_ainfo (winner, buf); log_string (buf, winner); wiznet (winner, WIZ_DEATHS, 7, buf); } if (IS_SET (winner->flag2, AFF2_LEADERFIGHT) && IS_SET (loser->flag2, AFF2_LEADERFIGHT)) { if ( !str_cmp(winner->name, nclans_table[winner->clannum].leader)) { sprintf (buf, "%s defends their title as the leader of the %s clan!", winner->name, nclans_table[winner->clannum].display); do_ainfo (winner, buf); } else { if (winner->clannum == 0) {winner->clannum = loser->clannum; nclans_table[winner->clannum].members++;} nclans_table[winner->clannum].leader = str_dup(winner->name); save_clans(); sprintf(buf, "%s is the new leader of the clan!", winner->name); do_claninfo(winner,buf); sprintf (buf, "%s renounces leadership of the %s clan, leaving %s in charge!", loser->name, nclans_table[loser->clannum].display, winner->name); do_ainfo (winner, buf); } save_clans(); log_string (buf, winner); wiznet (winner, WIZ_DEATHS, 7, buf); } if (IS_SET (winner->flag2, AFF2_RANKFIGHT) && IS_SET (loser->flag2, AFF2_RANKFIGHT) && winner->pcdata->stats[UNI_GEN] > loser->pcdata->stats[UNI_GEN]) { winner->pcdata->stats[UNI_GEN]--; loser->pcdata->stats[UNI_GEN]++; sprintf (buf, "%s has lost his class rank to %s", loser->name, winner->name); do_ainfo (winner, buf); log_string (buf, winner); wiznet (winner, WIZ_DEATHS, 7, buf); } stop_fighting (winner, TRUE); stop_fighting (loser, TRUE); // loser->pcdata->pkill_timer = 100; // winner->pcdata->pkill_timer = 100; REMOVE_BIT (loser->flag2, AFF2_STATUSFIGHT); REMOVE_BIT (winner->flag2, AFF2_STATUSFIGHT); REMOVE_BIT (loser->flag2, AFF2_LEADERFIGHT); REMOVE_BIT (winner->flag2, AFF2_LEADERFIGHT); REMOVE_BIT (loser->flag2, AFF2_RANKFIGHT); REMOVE_BIT (winner->flag2, AFF2_RANKFIGHT); REMOVE_BIT (loser->flag2, AFF2_CHALLENGED); REMOVE_BIT (loser->flag2, AFF2_CHALLENGER); REMOVE_BIT (loser->flag2, AFF2_INARENA); if IS_SET (loser->flag2, AFF2_SAFE) REMOVE_BIT (loser->flag2, AFF2_SAFE); loser->challenged = NULL; loser->hit = loser->max_hit; loser->move = loser->max_move; loser->mana = loser->max_mana; loser->fight_timer = 0; if (loser->disquiet_counter > 0) loser->disquiet_counter = 0; if (IS_SET(winner->newbits, NEW_CALM)) REMOVE_BIT (winner->newbits, NEW_CALM); char_from_room (loser); char_to_room (loser, get_room_index (ROOM_VNUM_ALOSER)); REMOVE_BIT (winner->flag2, AFF2_CHALLENGED); REMOVE_BIT (winner->flag2, AFF2_CHALLENGER); REMOVE_BIT (winner->flag2, AFF2_INARENA); if IS_SET (winner->flag2, AFF2_SAFE) REMOVE_BIT (winner->flag2, AFF2_SAFE); sprintf (buf, "%s has defeated %s with %d#+ health remaining!", winner->name, loser->name, (winner->hit * 100) / winner->max_hit ); do_ainfo (winner, buf); winner->challenged = NULL; winner->hit = winner->max_hit; winner->mana = winner->max_mana; winner->move = winner->max_move; winner->fight_timer = 0; if (winner->disquiet_counter > 0) winner->disquiet_counter = 0; if (IS_SET(winner->newbits, NEW_CALM)) REMOVE_BIT (winner->newbits, NEW_CALM); char_from_room (winner); char_to_room (winner, get_room_index (ROOM_VNUM_AWINNER)); do_restore (winner, "self"); do_restore (loser, "self"); do_look (winner, ""); do_look (loser, ""); winner->awins++; loser->alosses++; winner->fight_timer = 0; loser->fight_timer = 0; if (number_range(1,10) == 10) { do_istoken (winner,NULL); sprintf (buf, "%s has received a status token for winning!", winner->name); do_ainfo (winner, buf); } if (loser->disquiet_counter > 0) loser->disquiet_counter = 0; if (winner->disquiet_counter > 0) winner->disquiet_counter = 0; if (IS_SET(loser->newbits, NEW_CALM)) REMOVE_BIT (loser->newbits, NEW_CALM); if (IS_SET(winner->newbits, NEW_CALM)) REMOVE_BIT (winner->newbits, NEW_CALM); lvl1 = winner->hit; lvl2 = loser->hit; odds = (lvl2 / lvl1); for (d = first_descriptor; d; d = d->next) { if (d->connected == CON_PLAYING && d->character && !IS_NPC (d->character)) { if (d->character->gladiator == winner) { payoff = d->character->pcdata->plr_wager * (odds + 1); sprintf (buf, "You won! Your wager: %d, payoff: %d\n\r", d->character->pcdata->plr_wager, payoff); send_to_char (buf, d->character); d->character->pcdata->quest += payoff; /* * reset the betting info */ d->character->gladiator = NULL; d->character->pcdata->plr_wager = 0; payoff = 0; } if (d->character->gladiator != d->character && d->character->pcdata->plr_wager >= 1) { int tmp = 0; sprintf (buf, "You lost! Your wager: %d\n\r", d->character->pcdata->plr_wager); send_to_char (buf, d->character); if (d->character->pcdata->plr_wager > d->character->pcdata->quest) { tmp = d->character->pcdata->plr_wager; d->character->pcdata->plr_wager -= tmp; } if (tmp > 0) d->character->pcdata->quest -= tmp; d->character->pcdata->quest -= d->character->pcdata->plr_wager; /* * reset the betting info */ d->character->gladiator = NULL; d->character->pcdata->plr_wager = 0; } } } arena = FIGHT_CLEAR; return; } void clean_arena2 (CHAR_DATA * loser, CHAR_DATA * winner) { DESCRIPTOR_DATA *d; if (loser == winner) { CHAR_DATA *player; for (player = char_list; player != NULL; player = player->next) if (!IS_NPC(player) && player != loser && player->in_room != NULL && is_inarena(player)) { winner = player; break; } } REMOVE_BIT (loser->flag2, AFF2_STATUSFIGHT); REMOVE_BIT (winner->flag2, AFF2_STATUSFIGHT); REMOVE_BIT (loser->flag2, AFF2_LEADERFIGHT); REMOVE_BIT (winner->flag2, AFF2_LEADERFIGHT); REMOVE_BIT (loser->flag2, AFF2_CHALLENGED); REMOVE_BIT (loser->flag2, AFF2_CHALLENGER); REMOVE_BIT (loser->flag2, AFF2_INARENA); if IS_SET (loser->flag2, AFF2_SAFE) REMOVE_BIT (loser->flag2, AFF2_SAFE); loser->challenged = NULL; loser->hit = loser->max_hit; loser->move = loser->max_move; loser->mana = loser->max_mana; loser->fight_timer = 0; char_from_room (loser); char_to_room (loser, get_room_index (ROOM_VNUM_ALTAR)); REMOVE_BIT (winner->flag2, AFF2_CHALLENGED); REMOVE_BIT (winner->flag2, AFF2_CHALLENGER); REMOVE_BIT (winner->flag2, AFF2_INARENA); if IS_SET (winner->flag2, AFF2_SAFE) REMOVE_BIT (winner->flag2, AFF2_SAFE); winner->challenged = NULL; winner->fight_timer = 0; winner->hit = winner->max_hit; winner->mana = winner->max_mana; winner->move = winner->max_move; char_from_room (winner); char_to_room (winner, get_room_index (ROOM_VNUM_ALTAR)); winner->awins++; loser->alosses++; do_restore (winner, "self"); do_restore (loser, "self"); do_look (winner, ""); do_look (loser, ""); for (d = first_descriptor; d; d = d->next) { if (d->connected == CON_PLAYING && d->character && !IS_NPC (d->character)) { if (d->character->pcdata->plr_wager > 0) { d->character->pcdata->plr_wager = 0; d->character->gladiator = NULL; } } } arena = FIGHT_CLEAR; return; } void undo_arena (CHAR_DATA * ch) { CHAR_DATA *victim; char name[MAX_STRING_LENGTH]; if (ch->challenged != NULL) { victim = ch->challenged; sprintf (name, "%s", victim->name); if ((victim = get_char_finger (ch, name)) == NULL) { REMOVE_BIT (ch->flag2, AFF2_CHALLENGED); REMOVE_BIT (ch->flag2, AFF2_CHALLENGER); REMOVE_BIT (ch->flag2, AFF2_INARENA); REMOVE_BIT (ch->flag2, AFF2_STATUSFIGHT); REMOVE_BIT (ch->flag2, AFF2_LEADERFIGHT); REMOVE_BIT (ch->flag2, AFF2_RANKFIGHT); ch->challenged = NULL; } else { REMOVE_BIT (ch->flag2, AFF2_CHALLENGED); REMOVE_BIT (ch->flag2, AFF2_CHALLENGER); REMOVE_BIT (ch->flag2, AFF2_INARENA); REMOVE_BIT (ch->flag2, AFF2_STATUSFIGHT); ch->challenged = NULL; REMOVE_BIT (victim->flag2, AFF2_CHALLENGED); REMOVE_BIT (victim->flag2, AFF2_CHALLENGER); REMOVE_BIT (victim->flag2, AFF2_INARENA); REMOVE_BIT (victim->flag2, AFF2_STATUSFIGHT); REMOVE_BIT (victim->flag2, AFF2_LEADERFIGHT); REMOVE_BIT (victim->flag2, AFF2_RANKFIGHT); if (victim->in_room->vnum >= 12000 && victim->in_room->vnum <= 12010) clean_arena (ch, victim); victim->challenged = NULL; } } else { if (IS_SET (ch->flag2, AFF2_CHALLENGED)) REMOVE_BIT (ch->flag2, AFF2_CHALLENGED); if (IS_SET (ch->flag2, AFF2_CHALLENGER)) REMOVE_BIT (ch->flag2, AFF2_CHALLENGER); if (IS_SET (ch->flag2, AFF2_INARENA)) REMOVE_BIT (ch->flag2, AFF2_INARENA); if (IS_SET (ch->flag2, AFF2_STATUSFIGHT)) REMOVE_BIT (ch->flag2, AFF2_STATUSFIGHT); if (IS_SET (ch->flag2, AFF2_LEADERFIGHT)) REMOVE_BIT (ch->flag2, AFF2_LEADERFIGHT); } if (ch->in_room->vnum >= 12000 && ch->in_room->vnum <= 12010) { char_from_room (ch); char_to_room (ch, get_room_index (ROOM_VNUM_TEMPLE)); } return; } void undo_arena2 (CHAR_DATA * ch) { CHAR_DATA *victim; char name[MAX_STRING_LENGTH]; if (ch->challenged != NULL) { victim = ch->challenged; sprintf (name, "%s", victim->name); if ((victim = get_char_finger (ch, name)) == NULL) { REMOVE_BIT (ch->flag2, AFF2_CHALLENGED); REMOVE_BIT (ch->flag2, AFF2_CHALLENGER); REMOVE_BIT (ch->flag2, AFF2_INARENA); REMOVE_BIT (ch->flag2, AFF2_STATUSFIGHT); REMOVE_BIT (ch->flag2, AFF2_LEADERFIGHT); ch->challenged = NULL; } else { REMOVE_BIT (ch->flag2, AFF2_CHALLENGED); REMOVE_BIT (ch->flag2, AFF2_CHALLENGER); REMOVE_BIT (ch->flag2, AFF2_INARENA); REMOVE_BIT (ch->flag2, AFF2_STATUSFIGHT); ch->challenged = NULL; REMOVE_BIT (victim->flag2, AFF2_CHALLENGED); REMOVE_BIT (victim->flag2, AFF2_CHALLENGER); REMOVE_BIT (victim->flag2, AFF2_INARENA); REMOVE_BIT (victim->flag2, AFF2_STATUSFIGHT); REMOVE_BIT (victim->flag2, AFF2_LEADERFIGHT); if (victim->in_room->vnum >= 12000 && victim->in_room->vnum <= 12010) clean_arena2 (ch, victim); victim->challenged = NULL; } } else { if (IS_SET (ch->flag2, AFF2_CHALLENGED)) REMOVE_BIT (ch->flag2, AFF2_CHALLENGED); if (IS_SET (ch->flag2, AFF2_CHALLENGER)) REMOVE_BIT (ch->flag2, AFF2_CHALLENGER); if (IS_SET (ch->flag2, AFF2_INARENA)) REMOVE_BIT (ch->flag2, AFF2_INARENA); REMOVE_BIT (ch->flag2, AFF2_STATUSFIGHT); REMOVE_BIT (ch->flag2, AFF2_LEADERFIGHT); } if (ch->in_room->vnum >= 12000 && ch->in_room->vnum <= 12010) { char_from_room (ch); char_to_room (ch, get_room_index (ROOM_VNUM_TEMPLE)); } return; } void do_aclear (CHAR_DATA * ch, char *argument) { char buf[MAX_STRING_LENGTH]; arena = FIGHT_CLEAR; send_to_char ("Arena now set [CLEARED]\n\r", ch); sprintf (buf, "The arena has been opened."); do_ainfo (ch, buf); return; } void do_alock (CHAR_DATA * ch, char *argument) { char buf[MAX_STRING_LENGTH]; arena = FIGHT_LOCK; send_to_char ("Arena now set [LOCKED]\n\r", ch); sprintf (buf, "The arena has been locked."); do_ainfo (ch, buf); return; } void do_astat (CHAR_DATA * ch, char *argument) { if (arena == FIGHT_CLEAR) send_to_char ("Arena is [CLEAR]\n\r", ch); if (arena == FIGHT_START) send_to_char ("A challenge has been started.\n\r", ch); if (arena == FIGHT_LOCK) send_to_char ("Arena is [LOCKED]\n\r", ch); return; } void do_abet (CHAR_DATA * ch, char *argument) { char arg[MAX_INPUT_LENGTH]; char buf[MAX_STRING_LENGTH]; CHAR_DATA *fighter; int wager; argument = one_argument (argument, arg); if (argument[0] == '\0' || !is_number (arg)) { send_to_char ("Syntax: ABET [amount] [player]\n\r", ch); return; } if (ch->gladiator != NULL) { send_to_char ("You have already placed a bet on this fight.\n\r", ch); return; } /* * Disable the Gladiators from betting */ if (IS_SET (ch->flag2, AFF2_CHALLENGER) || IS_SET (ch->flag2, AFF2_CHALLENGED)) { send_to_char ("You can't bet on this battle.\n\r", ch); return; } fighter = get_char_finger (ch, argument); /* * Make sure the choice is VALID */ if (fighter == NULL) { send_to_char ("That player is not logged in.\n\r", ch); return; } if (IS_NPC (fighter)) { send_to_char ("Why bet on a mob? They aren't fighting...\n\r", ch); return; } if (!IS_SET (fighter->flag2, AFF2_INARENA)) { send_to_char ("That player is not in the arena.\n\r", ch); return; } /* * Stop any form of negative betting cheating */ if (!str_prefix ("-", arg)) { send_to_char ("Error: Invalid argument!\n\r", ch); return; } wager = atoi (arg); if (wager > 500 || wager < 1) { send_to_char ("Wager range is between 1 and 500\n\r", ch); return; } /* * Make sure they have enough quest points to cover * the bet */ if (wager > ch->pcdata->quest) { send_to_char ("You don't have that much qps to wager!\n\r", ch); return; } /* * Set the info */ ch->gladiator = fighter; ch->pcdata->plr_wager = wager; sprintf (buf, "You have placed a %d quest wager on %s\n\r", wager, fighter->name); send_to_char (buf, ch); return; }