warfare WARNING: LONG EMAIL

mud-dev mud-dev at aardmud.org
Mon Jan 2 18:56:17 New Zealand Daylight Time 2006


It is stolen code anyway.

----- Original Message ----- 
From: "Maurice Visser" <pos190 at yahoo.com>
To: <rom at rom.org>
Sent: Monday, January 02, 2006 12:53 AM
Subject: warfare WARNING: LONG EMAIL


>I came across one of the warfare code pieces on the archives and tried to 
>install it tonight. I managed to go from about 2 pages of errors down to 
>half a screen. I just can't get the rest of these errors. I've been at this 
>for the better part of the day. Any insight or help would be greatly 
>appreciated.
>
> Thanks,
> Mo
>
> --
>
> // Compiler errors:
> //
>
> gcc -Wall -O -ggdb -DNOCRYPT -DQMFIXES -c -o obj/war.o war.c
> war.c: In function `auto_war':
> war.c:229: warning: assignment from incompatible pointer type
> war.c:191: warning: `ch' might be used uninitialized in this function
> war.c: In function `do_war':
> war.c:468: parse error before `abort_race_war'
> war.c:477: `vict' undeclared (first use in this function)
> war.c:477: (Each undeclared identifier is reported only once
> war.c:477: for each function it appears in.)
> war.c:484: warning: `return' with a value, in function returning void
> war.c:489: warning: `return' with a value, in function returning void
> war.c: In function `abort_class_war':
> war.c:505: warning: implicit declaration of function `is_same_class'
> war.c: In function `war_wait':
> war.c:543: warning: `ch' might be used uninitialized in this function
> war.c: In function `war_update':
> war.c:624: warning: `ch' might be used uninitialized in this function
> war.c: In function `check_war':
> war.c:674: warning: `wch' might be used uninitialized in this function
> war.c: In function `war_talk':
> war.c:846: parse error at end of input
> make: *** [obj/war.o] Error 1
>
> // war.c
> //
>
> 1:/**************************************************************************
> 2:*  Devil's Lament MUD is copyright (c) 1999-2001 by Ryan Jennings 
> *
> 3:*  Telnet : <spaceservices.net:3778> 
> *
> 4:*  E-Mail : <markanth#spaceservices,net> 
> *
> 5:*  Website: <http://spaceservices.net/~markanth/> 
> *
> 6:***************************************************************************/
> 7:
> 8:
> 9:#if defined(macintosh)
> 10:#include <types.h>
> 11:#include <time.h>
> 12:#else
> 13:#include <sys/types.h>
> 14:#include <sys/time.h>
> 15:#endif
> 16:
> 17:#include <dirent.h>
> 18:#include <ctype.h>
> 19:#include <sys/stat.h>
> 20:#include <sys/resource.h>
> 21:#include <time.h>
> 22:#include <stdio.h>
> 23:#include <string.h>
> 24:#include <stdlib.h>
> 25:#include <unistd.h>
> 26:
> 27:#include "merc.h"
> 28:#include "interp.h"
> 29:#include "recycle.h"
> 30:#include "tables.h"
> 31:#include "lookup.h"
> 32:#include "db.h"
> 33:#include "magic.h"
> 34:
> 35:// #include <ctype.h>
> 36:// #include <stdio.h>
> 37:// #include <stdlib.h>
> 38:// #include <string.h>
> 39:// #include "merc.h"
> 40:
> 41:char *wartype_name(int type)
> 42:{
> 43:    switch (type)
> 44:    {
> 45:    case 1:
> 46: return "Race";
> 47:    case 2:
> 48: return "Class";
> 49:    case 3:
> 50: return "Genocide";
> 51:    case 4:
> 52: return "Clan";
> 53:    default:
> 54: return "Unknown";
> 55:    }
> 56:}
> 57:
> 58:bool start_war(CHAR_DATA * ch, char *argument)
> 59:{
> 60:    char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
> 61:    char arg3[MAX_INPUT_LENGTH];
> 62:    char buf[MAX_STRING_LENGTH];
> 63:    CHAR_DATA *wch, *warmaster = NULL;
> 64:    int blevel, elevel, type;
> 65:
> 66:    for (warmaster = ch->in_room->people; warmaster != NULL;
> 67:  warmaster = warmaster->next_in_room)
> 68:    {
> 69: if (!IS_NPC(warmaster))
> 70:     continue;
> 71: if (warmaster->spec_fun == spec_lookup("spec_warmaster"))
> 72:     break;
> 73:    }
> 74:
> 75:    if (!IS_IMMORTAL(ch) &&
> 76: (warmaster == NULL ||
> 77:  warmaster->spec_fun != spec_lookup("spec_warmaster")))
> 78:    {
> 79: send_to_char("You can't do that here.\n\r", ch);
> 80: return FALSE;
> 81:    }
> 82:
> 83:    if (!IS_IMMORTAL(ch) && warmaster->fighting != NULL)
> 84:    {
> 85: send_to_char("Wait until the fighting stops.\n\r", ch);
> 86: return FALSE;
> 87:    }
> 88:
> 89:    argument = one_argument(argument, arg1);
> 90:    argument = one_argument(argument, arg2);
> 91:    argument = one_argument(argument, arg3);
> 92:
> 93:    if (IS_NULLSTR(arg1) || IS_NULLSTR(arg2) || IS_NULLSTR(arg3))
> 94:    {
> 95: send_to_char("Syntax: war start <min_level> <max_level> <type>\n\r"
> 96:        "where <type> is either:\n\r"
> 97:        "1 - race war,\n\r2 - class war,\n\r3 - genocide war,\n\r4 clan 
> war\n\r",
> 98:        ch);
> 99: return FALSE;
> 100:    }
> 101:
> 102:    blevel = atoi(arg1);
> 103:    elevel = atoi(arg2);
> 104:    type = atoi(arg3);
> 105:
> 106:    if (blevel <= 0 || blevel > MAX_LEVEL)
> 107:    {
> 108: sprintf(buf, "Level must be between 1 and %d.\n\r", MAX_LEVEL);
> 109: send_to_char(buf, ch);
> 110: return FALSE;
> 111:    }
> 112:
> 113:    if (blevel <= 0 || elevel > MAX_LEVEL)
> 114:    {
> 115: sprintf(buf, "Level must be between 1 and %d.\n\r", MAX_LEVEL);
> 116: send_to_char(buf, ch);
> 117: return FALSE;
> 118:    }
> 119:
> 120:    if (elevel < blevel)
> 121:    {
> 122: send_to_char("Max level must be greater than the min level.\n\r", 
> ch);
> 123: return FALSE;
> 124:    }
> 125:
> 126:    if (elevel - blevel < 5)
> 127:    {
> 128: send_to_char("Levels must have a difference of at least 5.\n\r", ch);
> 129: return FALSE;
> 130:    }
> 131:
> 132:    if (type < 1 || type > 4)
> 133:    {
> 134: send_to_char
> 135:   ("The type either has to be 1 (race), 2 (class), 3 (genocide) or 4 
> (clan).\n\r",
> 136:    ch);
> 137: return FALSE;
> 138:    }
> 139:
> 140:    if (war_info.iswar != WAR_OFF)
> 141:    {
> 142: send_to_char("There is already a war going!\n\r", ch);
> 143: return FALSE;
> 144:    }
> 145:
> 146:    if (!IS_IMMORTAL(ch))
> 147:    {
> 148: int cost = 5000;
> 149:
> 150: if (ch->gold < cost)
> 151: {
> 152:     sprintf(buf,
> 153:       "$N tells you 'It costs %d gold coins to start a %s war.'", 
> cost,
> 154:       wartype_name(type));
> 155:  act(buf, ch, NULL, warmaster, TO_CHAR);
> 156:     return FALSE;
> 157: }
> 158: else
> 159: {
> 160:     sprintf(buf,
> 161:       "$N tells you 'Thank you $n, %s war started, you are %d gold 
> coins lighter.'",
> 162:       wartype_name(type), cost);
> 163:  act(buf, ch, NULL, warmaster, TO_CHAR);
> 164:     ch->gold -= cost;
> 165: }
> 166:    }
> 167:
> 168:    war_info.iswar = WAR_WAITING;
> 169:    free_string(war_info.who);
> 170:    war_info.who = str_dup(ch->name);
> 171:    war_info.min_level = blevel;
> 172:    war_info.max_level = elevel;
> 173:    war_info.wartype = type;
> 174:
> 175:    sprintf(buf, "$n announces a %s war for levels %d to %d.  Type 
> 'WAR' to kill or be killed.",
> 176:      wartype_name(war_info.wartype), war_info.min_level, 
> war_info.max_level);
> 177:    war_channel(ch, buf);
> 178:    war_info.timer = 3;
> 179:    war_info.next = 0;
> 180:    for (wch = char_list; wch != NULL; wch = wch->next)
> 181:    {
> 182: if (!IS_NPC(wch) && IS_SET(wch->act, PLR_WAR))
> 183:     REMOVE_BIT(wch->act, PLR_WAR);
> 184:    }
> 185:    return TRUE;
> 186:}
> 187:
> 188:void auto_war(void)
> 189:{
> 190:    char buf[MSL];
> 191:    CHAR_DATA *ch, *wch, *wch_last, *warmaster;
> 192:    int maxlvl = 0, minlvl = MAX_LEVEL, middle = 50;
> 193:    int clan = 0, count = 0, lbonus = 0, half = 0;
> 194:
> 195:    if (war_info.iswar != WAR_OFF)
> 196: return;
> 197:
> 198:    for (wch = char_list; wch != NULL; wch = wch->next)
> 199:    {
> 200: if ((!IS_NPC(wch)) && (!IS_IMMORTAL(wch)))
> 201: {
> 202:     count++;
> 203:     maxlvl = UMAX(maxlvl, wch->level);
> 204:     minlvl = UMIN(minlvl, wch->level);
> 205:     if (is_clan(wch))
> 206:     {
> 207:  for (wch_last = char_list; wch_last != NULL; wch_last = 
> wch_last->next)
> 208:  {
> 209:      if (!IS_NPC(wch_last) && !IS_IMMORTAL(wch_last) && 
> is_clan(wch_last) &&
> 210:   !is_same_clan(wch, wch_last))
> 211:   clan++;
> 212:  }
> 213:     }
> 214: }
> 215:    }
> 216:    if (count < 2)
> 217:    {
> 218: end_war();
> 219: return;
> 220:    }
> 221:
> 222:    lbonus = number_range(5, 10);
> 223:    minlvl = UMAX(1, minlvl - lbonus);
> 224:    maxlvl = UMIN(100, maxlvl + lbonus);
> 225:    half = ((maxlvl - minlvl) / 2);
> 226:    middle = URANGE(minlvl, maxlvl - half, maxlvl);
> 227:    minlvl = number_range(minlvl, middle - lbonus);
> 228:    maxlvl = number_range(middle + lbonus, maxlvl);
> 229:    warmaster = get_mob_index(MOB_VNUM_WARMASTER);
> 230:    war_info.iswar = WAR_WAITING;
> 231:    free_string(war_info.who);
> 232:    war_info.who =
> 233:      !warmaster ? str_dup("AutoWar (tm)") : 
> str_dup(warmaster->short_descr);
> 234:    war_info.min_level = minlvl;
> 235:    war_info.max_level = maxlvl;
> 236:
> 237:    if (clan >= 2)
> 238: war_info.wartype = number_range(1, 4);
> 239:    else
> 240: war_info.wartype = number_range(1, 3);
> 241:
> 242:    sprintf(buf,
> 243:      "%s %s war for levels %d to %d%s.  Type 'WAR' to kill or be 
> killed.",
> 244:      !warmaster ? "A" : "$n announces a",
> 245:      wartype_name(war_info.wartype), war_info.min_level,
> 246:      war_info.max_level, !warmaster ? " has started" : "");
> 247:    war_channel(ch, buf);
> 248:    war_info.timer = 3;
> 249:    war_info.next = 0;
> 250:    for (wch = char_list; wch != NULL; wch = wch->next)
> 251:    {
> 252: if (!IS_NPC(wch) && IS_SET(wch->act, PLR_WAR))
> 253:     REMOVE_BIT(wch->act, PLR_WAR);
> 254:    }
> 255:}
> 256:
> 257:void end_war(void)
> 258:{
> 259:    CHAR_DATA *wch;
> 260:
> 261:    free_string(war_info.who);
> 262:    war_info.who = str_dup("");
> 263:    war_info.wartype = 0;
> 264:    war_info.min_level = 0;
> 265:    war_info.max_level = 0;
> 266:    war_info.iswar = WAR_OFF;
> 267:    war_info.inwar = 0;
> 268:    war_info.timer = 0;
> 269:    war_info.next = number_range(30, 60);
> 270:    for (wch = char_list; wch != NULL; wch = wch->next)
> 271:    {
> 272: if (!IS_NPC(wch) && IS_SET(wch->act, PLR_WAR))
> 273: {
> 274:     stop_fighting(wch, TRUE);
> 275:     REMOVE_BIT(wch->act, PLR_WAR);
> 276:     if (IS_SET(wch->in_room->room_flags, ROOM_ARENA) ||
> 277:  wch->in_room->vnum == ROOM_VNUM_WAITROOM)
> 278:     {
> 279:  char_from_room(wch);
> 280:  char_to_room(wch, get_room_index(ROOM_VNUM_TEMPLE));
> 281:     }
> 282:     wch->hit = wch->max_hit;
> 283:     wch->mana = wch->max_mana;
> 284:     wch->move = wch->max_move;
> 285:     update_pos(wch);
> 286:     do_look(wch, "auto");
> 287: }
> 288:    }
> 289:}
> 290:
> 291:void do_war(CHAR_DATA *ch, char *argument)
> 292:{
> 293:    char arg[MAX_INPUT_LENGTH];
> 294:    char buf[MAX_STRING_LENGTH];
> 295:    ROOM_INDEX_DATA *location;
> 296:    int i = 0;
> 297:
> 298:    if (IS_NPC(ch))
> 299:    {
> 300: send_to_char("Mobiles not supported yet.\n\r", ch);
> 301: return;
> 302:    }
> 303:
> 304:    argument = one_argument(argument, arg);
> 305:
> 306:    if (arg[0] == '\0')
> 307:    {
> 308: send_to_char("{gSyntax:{R  war {Wstart <minlev> <maxlev> 
> <#type>\n\r", ch);
> 309: send_to_char("         {Rwar {Wtalk <message>\n\r", ch);
> 310: send_to_char("         {Rwar {Wstatus\n\r", ch);
> 311: send_to_char("         {Rwar {Winfo\n\r", ch);
> 312: send_to_char("         {Rwar {Wjoin{x\n\r", ch);
> 313: if (IS_IMMORTAL(ch))
> 314:    {
> 315:     send_to_char("         {Rwar {Wend{x\n\r", ch);
> 316:     send_to_char("         {Rwar {Wnext{x\n\r", ch);
> 317:
> 318: return;
> 319:    }
> 320:    else if (!str_cmp(arg, "start"))
> 321:    {
> 322: if (ch->gold < 10000 && !IS_IMMORTAL(ch))
> 323: {
> 324:     send_to_char("It costs 10000 gold coins to start a war.\n\r", 
> ch);
> 325:     return;
> 326: }
> 327: if (start_war(ch, argument) && !IS_IMMORTAL(ch))
> 328:     ch->gold -= 10000;
> 329: return;
> 330:    }
> 331:
> 332:    else if (!str_cmp(arg, "talk"))
> 333:    {
> 334: war_talk(ch, argument);
> 335: return;
> 336:    }
> 337:    else if (!str_cmp(arg, "next") && IS_IMMORTAL(ch))
> 338:    {
> 339: if (war_info.iswar == TRUE)
> 340: {
> 341:     send_to_char("Not while a war is running.\n\r", ch);
> 342:     return;
> 343: }
> 344:
> 345: i = is_number(argument) ? atoi(argument) : number_range(30, 100);
> 346: war_info.next = i;
> 347: sprintf(buf, "The next war will start in %d minutes.\n\r",
> 348:   war_info.next);
> 349:    send_to_char(buf, ch);
> 350: return;
> 351:    }
> 352:
> 353:    if (war_info.iswar != TRUE)
> 354:    {
> 355: sprintf(buf,
> 356:   "There is no war going! The next war will start in %d 
> minutes.\n\r",
> 357:   war_info.next);
> 358:    send_to_char(buf, ch);
> 359: return;
> 360:    }
> 361:
> 362:    if (!str_cmp(arg, "end") && IS_IMMORTAL(ch))
> 363:    {
> 364: end_war();
> 365: sprintf(buf, "You end the war. Next war in %d minutes.\n\r",
> 366:   war_info.next);
> 367:    send_to_char(buf, ch);
> 368: sprintf(buf,
> 369:   "$n has ended the war. The next autwar will start in %d minutes.",
> 370:   war_info.next);
> 371: war_channel(ch, buf);
> 372: return;
> 373:    }
> 374:    else if (!str_cmp(arg, "info"))
> 375:    {
> 376: send_to_char( "{g[ {WWAR INFO{g ]{x\n\r", ch);
> 377: sprintf(buf, "{RStarted by  : {W%s\n\r",
> 378:   IS_NULLSTR(war_info.who) ? "Unknown" : war_info.who);
> 379:    send_to_char(buf, ch);
> 380: sprintf(buf, "{RFighting    : {W%d player%s.\n\r", war_info.inwar,
> 381:   war_info.inwar == 1 ? "" : "s");
> 382:    send_to_char(buf, ch);
> 383: sprintf(buf, "{RLevels      : {W%d - %d{x\n\r", war_info.min_level,
> 384:   war_info.max_level);
> 385:    send_to_char(buf, ch);
> 386: sprintf(buf, "{RStatus      : {W%s for %d minutes.{x\n\r",
> 387:   war_info.iswar == WAR_WAITING ? "Waiting" : "Running",
> 388:   war_info.timer);
> 389:    send_to_char(buf, ch);
> 390: sprintf(buf, "{RType        : {W%s war.{x\n\r",
> 391:   wartype_name(war_info.wartype));
> 392:    send_to_char(buf, ch);
> 393: return;
> 394:    }
> 395:    else if (!str_cmp(arg, "check"))
> 396:    {
> 397: CHAR_DATA *wch;
> 398: bool found = FALSE;
> 399:
> 400: send_to_char("[ {WWAR COMBATENTS{g ]\n\r", ch);
> 401: for (wch = char_list; wch != NULL; wch = wch->next)
> 402: {
> 403:     if (!IS_NPC(wch) && IS_SET(wch->act, PLR_WAR))
> 404:     {
> 405:  sprintf(buf,
> 406:    "{W%-12s : [{R%d%% hit{W] [{M%d%% mana{W] [Pos: {GN/A{W]{x\n\r",
> 407:    wch == ch ? "You" : wch->name,
> 408:    wch->hit * 100 / wch->max_hit,
> 409:    wch->mana * 100 / wch->max_mana);
> 410:     send_to_char(buf, ch);
> 411:  found = TRUE;
> 412:     }
> 413: }
> 414: if (!found)
> 415:     send_to_char("No one in the war yet.\n\r", ch);
> 416: return;
> 417:    }
> 418:    else if (!str_cmp(arg, "join"))
> 419:    {
> 420: if (war_info.iswar == WAR_RUNNING)
> 421: {
> 422:     send_to_char("The war has allready started, your too late.\n\r", 
> ch);
> 423:     return;
> 424: }
> 425:
> 426: if ((ch->level < war_info.min_level) || (ch->level > 
> war_info.max_level))
> 427: {
> 428:     sprintf(buf, "Sorry, you may not join this war.\n\r");
> 429:     send_to_char(buf, ch);
> 430:     return;
> 431: }
> 432:
> 433: if (IS_SET(ch->act, PLR_WAR))
> 434: {
> 435:     send_to_char("You are already in the war.\n\r", ch);
> 436:     return;
> 437: }
> 438:
> 439: if (war_info.wartype == 4 && !is_clan(ch))
> 440: {
> 441:     send_to_char("You aren't in a clan, you can't jon this war.\n\r", 
> ch);
> 442:     return;
> 443: }
> 444:
> 445: if ((location = get_room_index(ROOM_VNUM_WAITROOM)) == NULL)
> 446: {
> 447:     send_to_char("Arena is not yet completed, sorry.\n\r", ch);
> 448:     return;
> 449: }
> 450: else
> 451: {
> 452:     act("$n goes to get $s ass whipped in war!", ch, NULL, 
> NULL,TO_ROOM);
> 453:     char_from_room(ch);
> 454:     char_to_room(ch, location);
> 455:     SET_BIT(ch->act, PLR_WAR);
> 456:     sprintf(buf, "%s Level %d joins the war!", ch->name,ch->level);
> 457:     war_channel(ch, buf);
> 458:     act("$n arrives to get $s ass whipped!", ch, NULL, NULL, 
> TO_ROOM);
> 459:     war_info.inwar++;
> 460:     do_look(ch, "auto");
> 461: }
> 462: return;
> 463:    }
> 464:    do_war(ch, "");
> 465:    return;
> 466:}
> 467:
> 468:bool abort_race_war(void)
> 469:{
> 470:    CHAR_DATA *ch;
> 471:    CHAR_DATA *vict;
> 472:
> 473:    for (ch = char_list; ch != NULL; ch = ch->next)
> 474:    {
> 475: if (!IS_NPC(ch) && IS_SET(ch->act, PLR_WAR))
> 476: {
> 477:     for (vict = char_list; vict != NULL; vict = vict->next)
> 478:     {
> 479:  if (!IS_NPC(vict) && IS_SET(vict->act, PLR_WAR))
> 480:  {
> 481:      if (ch->race == vict->race)
> 482:   continue;
> 483:      else
> 484:   return FALSE;
> 485:  }
> 486:     }
> 487: }
> 488:    }
> 489:    return TRUE;
> 490:}
> 491:
> 492:bool abort_class_war(void)
> 493:{
> 494:    CHAR_DATA *ch;
> 495:    CHAR_DATA *vict;
> 496:
> 497:    for (ch = char_list; ch != NULL; ch = ch->next)
> 498:    {
> 499: if (!IS_NPC(ch) && IS_SET(ch->act, PLR_WAR))
> 500: {
> 501:     for (vict = char_list; vict != NULL; vict = vict->next)
> 502:     {
> 503:  if (!IS_NPC(vict) && IS_SET(vict->act, PLR_WAR))
> 504:  {
> 505:      if (is_same_class(ch, vict))
> 506:   continue;
> 507:      else
> 508:   return FALSE;
> 509:  }
> 510:     }
> 511: }
> 512:    }
> 513:    return TRUE;
> 514:}
> 515:
> 516:bool abort_clan_war(void)
> 517:{
> 518:    CHAR_DATA *ch;
> 519:    CHAR_DATA *vict;
> 520:
> 521:    for (ch = char_list; ch != NULL; ch = ch->next)
> 522:    {
> 523: if (!IS_NPC(ch) && IS_SET(ch->act, PLR_WAR) && is_clan(ch))
> 524: {
> 525:     for (vict = char_list; vict != NULL; vict = vict->next)
> 526:     {
> 527:  if (!IS_NPC(vict) && IS_SET(vict->act, PLR_WAR) && is_clan(vict))
> 528:  {
> 529:      if (is_same_clan(ch, vict))
> 530:   continue;
> 531:      else
> 532:   return FALSE;
> 533:  }
> 534:     }
> 535: }
> 536:    }
> 537:    return TRUE;
> 538:}
> 539:
> 540:void war_wait(void)
> 541:{
> 542:    int randm = 0;
> 543:    CHAR_DATA *wch, *ch;
> 544:    char buf[MSL];
> 545:
> 546:    if (war_info.iswar != WAR_WAITING)
> 547: return;
> 548:
> 549:    if (war_info.timer > 0)
> 550:    {
> 551: sprintf(buf,
> 552:   "%d minute%s left to join the war. (Levels %d - %d, %s War)",
> 553:   war_info.timer, war_info.timer == 1 ? "" : "s",
> 554:   war_info.min_level, war_info.max_level,
> 555:   war_info.wartype == 1 ? "Race" : war_info.wartype ==
> 556:   2 ? "Class" : war_info.wartype == 3 ? "Genocide" : "Clan");
> 557: war_channel(ch, buf);
> 558: war_info.timer--;
> 559: return;
> 560:    }
> 561:    else
> 562:    {
> 563: if (war_info.inwar <= 1)
> 564: {
> 565:     end_war();
> 566:     sprintf(buf,
> 567:       "Not enough people for war.  Next autowar in %d minutes.",
> 568:       war_info.next);
> 569:     war_channel(ch, buf);
> 570:     return;
> 571: }
> 572: else if (war_info.wartype == 1 && abort_race_war())
> 573: {
> 574:     end_war();
> 575:     sprintf(buf,
> 576:       "Not enough races for war.  Next autowar in %d minutes.",
> 577:       war_info.next);
> 578:     war_channel(ch, buf);
> 579:     return;
> 580: }
> 581: else if (war_info.wartype == 2 && abort_class_war())
> 582: {
> 583:     end_war();
> 584:     sprintf(buf,
> 585:       "Not enough classes for war.  Next autowar in %d minutes.",
> 586:       war_info.next);
> 587:     war_channel(ch, buf);
> 588:     return;
> 589: }
> 590: else if (war_info.wartype == 4 && abort_clan_war())
> 591: {
> 592:     end_war();
> 593:     sprintf(buf,
> 594:       "Not enough clans for war.  Next autowar in %d minutes.",
> 595:       war_info.next);
> 596:     war_channel(ch, buf);
> 597:     return;
> 598: }
> 599: else
> 600: {
> 601:     sprintf(buf,
> 602:       "The battle begins! %d players are fighting!",
> 603:       war_info.inwar);
> 604:     war_channel(ch, buf);
> 605:     war_info.timer =
> 606:       number_range(3 * war_info.inwar, 5 * war_info.inwar);
> 607:     for (wch = char_list; wch != NULL; wch = wch->next)
> 608:     {
> 609:  if (!IS_NPC(wch) && IS_SET(wch->act, PLR_WAR))
> 610:  {
> 611:      /* replace #### with the begining and end vnums of an arena area 
> */
> 612:      randm = number_range(251, 261);
> 613:      char_from_room(wch);
> 614:      char_to_room(wch, get_room_index(randm));
> 615:      do_look(wch, "auto");
> 616:  }
> 617:     }
> 618: }
> 619:    }
> 620:}
> 621:
> 622:void war_update(void)
> 623:{
> 624:    CHAR_DATA *ch;
> 625:    char buf[MSL];
> 626:
> 627:    if (war_info.next > 0 && war_info.iswar == WAR_OFF)
> 628:    {
> 629: if (--war_info.next == 0)
> 630:     auto_war();
> 631:    }
> 632:
> 633:    if (war_info.iswar == WAR_RUNNING)
> 634:    {
> 635: if (war_info.inwar == 0)
> 636: {
> 637:     end_war();
> 638:     sprintf(buf,
> 639:       "No one left in the War, next war will start in %d minutes.",
> 640:       war_info.next);
> 641:     war_channel(ch, buf);
> 642:     return;
> 643: }
> 644:
> 645: switch (war_info.timer)
> 646: {
> 647: case 0:
> 648:     end_war();
> 649:     sprintf(buf,
> 650:       "Time has run out on the War, next war will start in %d 
> minutes.",
> 651:       war_info.next);
> 652:     war_channel(ch, buf);
> 653:     return;
> 654: case 1:
> 655: case 2:
> 656: case 3:
> 657: case 4:
> 658: case 5:
> 659: case 10:
> 660: case 15:
> 661:     sprintf(buf, "%d minute%s remaining in the war.",
> 662:       war_info.timer, war_info.timer > 1 ? "s" : "");
> 663:     war_channel(ch, buf);
> 664: default:
> 665:     war_info.timer--;
> 666:     break;
> 667: }
> 668: return;
> 669:    }
> 670:}
> 671:
> 672:void check_war(CHAR_DATA * ch, CHAR_DATA * victim)
> 673:{
> 674:    CHAR_DATA *wch;
> 675:    char buf[MAX_STRING_LENGTH];
> 676:    int reward = number_range(500, 1500);
> 677:    int qreward = number_range(50, 150);
> 678:
> 679:    if (IS_NPC(ch) || IS_NPC(victim))
> 680: return;
> 681:
> 682:    REMOVE_BIT(victim->act, PLR_WAR);
> 683:    war_info.inwar--;
> 684:    stop_fighting(victim, TRUE);
> 685:    char_from_room(victim);
> 686:    char_to_room(victim, get_room_index(ROOM_VNUM_ALTAR));
> 687: victim->hit = UMAX(1, victim->hit);
> 688: victim->mana = UMAX(1, victim->hit);
> 689: victim->move = UMAX(1, victim->hit);
> 690:    update_pos(victim);
> 691:    do_look(victim, "auto");
> 692:    send_to_char("\n\r", ch);
> 693:    send_to_char("\n\r", victim);
> 694:    sprintf(buf, "%s was killed in combat by %s!{x",
> 695:      victim->name, ch->name);
> 696:    war_channel(ch, buf);
> 697:    switch (war_info.wartype)
> 698:    {
> 699:    case 1:
> 700: if (abort_race_war())
> 701: {
> 702:     sprintf(buf, "The %s have won the War!",
> 703:       pc_race_table[ch->race].name);
> 704:     war_channel(ch, buf);
> 705:     for (wch = char_list; wch != NULL; wch = wch->next)
> 706:     {
> 707:  if (!IS_NPC(wch) && IS_SET(wch->act, PLR_WAR))
> 708:      continue;
> 709:
> 710:  if (wch->race == ch->race)
> 711:  {
> 712:      wch->gold += reward;
> 713:      wch->questpoints += qreward;
> 714:      sprintf(buf,
> 715:        "You recieve %d gold and %d questpoints from the war 
> tribunal!\n\r",
> 716:        reward, qreward);
> 717:   send_to_char(buf, wch);
> 718:  }
> 719:
> 720:     }
> 721:     end_war();
> 722:     return;
> 723: }   // end abort
> 724: break;
> 725:    case 2:
> 726: if (abort_class_war())
> 727: {
> 728:     sprintf(buf, "The %s have won the War!{x",
> 729:       class_table[ch->class].name);
> 730:     war_channel(ch, buf);
> 731:     for (wch = char_list; wch != NULL; wch = wch->next)
> 732:     {
> 733:  if (!IS_NPC(wch) && IS_SET(wch->act, PLR_WAR))
> 734:      continue;
> 735:  if (wch->class == ch->class)
> 736:  {
> 737:      wch->gold += reward;
> 738:      wch->questpoints += qreward;
> 739:      sprintf(buf,
> 740:        "You recieve %d gold and %d questpoints from the war 
> tribunal!\n\r",
> 741:        reward, qreward);
> 742:   send_to_char(buf, wch);
> 743:  }
> 744:     }
> 745:     end_war();
> 746:     return;
> 747: }
> 748: break;
> 749:    case 4:
> 750: if (abort_clan_war())
> 751: {
> 752:     sprintf(buf, "%s has won the War!{x",
> 753:       clan_table[ch->clan].who_name);
> 754:     war_channel(ch, buf);
> 755:     for (wch = char_list; wch != NULL; wch = wch->next)
> 756:     {
> 757:  if (!IS_NPC(wch) && IS_SET(wch->act, PLR_WAR))
> 758:      continue;
> 759:  if (is_same_clan(ch, wch))
> 760:  {
> 761:      wch->gold += reward;
> 762:      wch->questpoints += qreward;
> 763:      sprintf(buf,
> 764:        "You recieve %d gold and %d questpoints from the war 
> tribunal!\n\r",
> 765:        reward, qreward);
> 766:   send_to_char(buf, wch);
> 767:  }
> 768:     }
> 769:     end_war();
> 770:     return;
> 771: }
> 772: break;
> 773:    case 3:
> 774: if (war_info.inwar == 1)
> 775: {
> 776:     sprintf(buf, "%s has won the War!{x", ch->name);
> 777:     war_channel(ch, buf);
> 778:     ch->gold += reward;
> 779:     ch->questpoints += qreward;
> 780:      sprintf(buf,
> 781:        "You recieve %d gold and %d questpoints from the war 
> tribunal!\n\r",
> 782:        reward, qreward);
> 783:   send_to_char(buf, wch);
> 784:     end_war();
> 785:     return;
> 786: }
> 787: break;
> 788:    }
> 789:    return;
> 790:}
> 791:
> 792:bool is_safe_war(CHAR_DATA * ch, CHAR_DATA * wch)
> 793:{
> 794:    if (war_info.iswar == WAR_OFF)
> 795: return FALSE;
> 796:
> 797:    if ((!IS_IN_WAR(ch)) || (!IS_IN_WAR(wch)))
> 798: return FALSE;
> 799:
> 800:    if (war_info.wartype == 3)
> 801: return FALSE;
> 802:
> 803:    if (war_info.wartype == 1 && ch->race == wch->race)
> 804: return TRUE;
> 805:
> 806:    if (war_info.wartype == 2 && ch->class == wch->class)
> 807: return TRUE;
> 808:
> 809:    if (war_info.wartype == 4 && is_same_clan(ch, wch))
> 810: return TRUE;
> 811:
> 812:    return FALSE;
> 813:}
> 814:
> 815:void war_talk(CHAR_DATA *ch, char *argument)
> 816:{
> 817:    DESCRIPTOR_DATA *d;
> 818:    char buf[MAX_STRING_LENGTH];
> 819:
> 820:    if (IS_NULLSTR(argument))
> 821:    {
> 822: send_to_char
> 823:   ("Wartalk what?\n\r",
> 824:    ch);
> 825: return;
> 826:    }
> 827:    sprintf(buf, "{Y({RWarTalk{Y) {gYou drum: %s{x\n\r", argument);
> 828: send_to_char(buf, ch);
> 829:
> 830:    for (d = descriptor_list; d != NULL; d = d->next)
> 831:    {
> 832: CHAR_DATA *victim;
> 833:
> 834: if( d->connected == CON_PLAYING
> 835:     && ((victim = d->character) != ch)
> 836:     && !IS_SET(victim->comm, COMM_QUIET)
> 837:     && !IS_NPC(ch)
> 838:     && IS_SET(ch->act, PLR_WAR)
> 839:     && IS_SET(ch->in_room->room_flags, ROOM_ARENA) )
> 840: {
> 841:     sprintf(buf, "{Y({RWarTalk{Y) {g%s drums: %s{w\n\r", ch->name, 
> argument);
> 842:     send_to_char(buf, victim);
> 843: }
> 844:    return;
> 845:}
> -- 
> ROM mailing list
> ROM at rom.org
> Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom
> 


-- 
ROM mailing list
ROM at rom.org
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom


More information about the MUD-Dev mailing list