Annotation of early-roguelike/xrogue/init.c, Revision 1.1
1.1 ! rubenllo 1: /*
! 2: init.c - global variable initializaton
! 3:
! 4: XRogue: Expeditions into the Dungeons of Doom
! 5: Copyright (C) 1991 Robert Pietkivitch
! 6: All rights reserved.
! 7:
! 8: Based on "Advanced Rogue"
! 9: Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
! 10: All rights reserved.
! 11:
! 12: Based on "Rogue: Exploring the Dungeons of Doom"
! 13: Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
! 14: All rights reserved.
! 15:
! 16: See the file LICENSE.TXT for full copyright and licensing information.
! 17: */
! 18:
! 19: #include <curses.h>
! 20: #include <ctype.h>
! 21: #include <string.h>
! 22: #include "rogue.h"
! 23: #include "mach_dep.h"
! 24:
! 25: /*
! 26: * If there is any news, put it in a character string and assign it to
! 27: * rogue_news. Otherwise, assign NULL to rogue_news.
! 28: */
! 29:
! 30: static char *rogue_news = "Enter a number within the minimum and maximum \
! 31: range. When satisfied with your choices, enter a 'y'. For help at any \
! 32: other time enter a '?' or a '='.";
! 33:
! 34: /* replace the above line with this when descriptions are done */
! 35: /* other time enter a '?' or a '='. For character and item descriptions \
! 36: enter a '\\' on any other screen.";
! 37: */
! 38:
! 39: struct words rainbow[NCOLORS] = {
! 40: { "Amber" }, { "Aquamarine" }, { "Beige" },
! 41: { "Black" }, { "Blue" }, { "Brown" },
! 42: { "Clear" }, { "Crimson" }, { "Ecru" },
! 43: { "Gold" }, { "Green" }, { "Grey" },
! 44: { "Indigo" }, { "Khaki" }, { "Lavender" },
! 45: { "Magenta" }, { "Orange" }, { "Pink" },
! 46: { "Plaid" }, { "Purple" }, { "Red" },
! 47: { "Silver" }, { "Saffron" }, { "Scarlet" },
! 48: { "Tan" }, { "Tangerine" }, { "Topaz" },
! 49: { "Turquoise" }, { "Vermilion" }, { "Violet" },
! 50: { "White" }, { "Yellow" }
! 51: };
! 52:
! 53: struct words sylls[NSYLLS] = {
! 54: {"a"}, {"ae"}, {"ak"}, {"an"}, {"ax"}, {"ach"}, {"ano"}, {"ars"},
! 55: {"bha"}, {"bar"}, {"bre"}, {"cha"}, {"cre"}, {"cum"}, {"cow"}, {"duh"},
! 56: {"dha"}, {"e"}, {"ea"}, {"em"}, {"et"}, {"ey"}, {"eck"}, {"etk"},
! 57: {"egg"}, {"exl"}, {"fu"}, {"fen"}, {"fid"}, {"gan"}, {"gle"}, {"h"},
! 58: {"ha"}, {"hr"}, {"ht"}, {"how"}, {"hex"}, {"hip"}, {"hoc"}, {"i"},
! 59: {"ia"}, {"ig"}, {"it"}, {"iz"}, {"ion"}, {"ink"}, {"ivi"}, {"iss"},
! 60: {"je"}, {"jin"}, {"jha"}, {"jyr"}, {"ka"}, {"kho"}, {"kal"}, {"kli"},
! 61: {"lu"}, {"lre"}, {"lta"}, {"lri"}, {"m"}, {"ma"}, {"mh"}, {"mi"},
! 62: {"mr"}, {"mar"}, {"myr"}, {"moh"}, {"mul"}, {"nep"}, {"nes"}, {"o"},
! 63: {"oc"}, {"om"}, {"oq"}, {"ox"}, {"orn"}, {"oxy"}, {"olm"}, {"ode"},
! 64: {"po"}, {"pie"}, {"pod"}, {"pot"}, {"qar"}, {"que"}, {"ran"}, {"rah"},
! 65: {"rok"}, {"sa"}, {"sat"}, {"sha"}, {"sol"}, {"sri"}, {"ti"}, {"tem"},
! 66: {"tar"}, {"tki"}, {"tch"}, {"tox"}, {"u"}, {"ub"}, {"uh"}, {"ur"},
! 67: {"uv"}, {"unk"}, {"uwh"}, {"ugh"}, {"uyr"}, {"va"}, {"vil"}, {"vit"},
! 68: {"vom"}, {"vux"}, {"wah"}, {"wex"}, {"xu"}, {"xed"}, {"xen"}, {"ya"},
! 69: {"yep"}, {"yih"}, {"zef"}, {"zen"}, {"zil"}, {"zym"}, {"-"}
! 70: };
! 71:
! 72: struct words stones[NSTONES] = {
! 73: { "Agate" }, { "Alexandrite" }, { "Amethyst" },
! 74: { "Azurite" }, { "Bloodstone" }, { "Cairngorm" },
! 75: { "Carnelian" }, { "Chalcedony" }, { "Chrysoberyl" },
! 76: { "Chrysolite" }, { "Chrysoprase" }, { "Citrine" },
! 77: { "Coral" }, { "Diamond" }, { "Emerald" },
! 78: { "Garnet" }, { "Heliotrope" }, { "Hematite" },
! 79: { "Hyacinth" }, { "Jacinth" }, { "Jade" },
! 80: { "Jargoon" }, { "Jasper" }, { "Kryptonite" },
! 81: { "Lapis lazuli" }, { "Malachite" }, { "Mocca stone" },
! 82: { "Moonstone" }, { "Obsidian" }, { "Olivine" },
! 83: { "Onyx" }, { "Opal" }, { "Pearl" },
! 84: { "Peridot" }, { "Quartz" }, { "Rhodochrosite" },
! 85: { "Rhodolite" }, { "Ruby" }, { "Sapphire" },
! 86: { "Sardonyx" }, { "Serpentine" }, { "Spinel" },
! 87: { "Tiger eye" }, { "Topaz" }, { "Tourmaline" },
! 88: { "Turquoise" }, { "Zircon" }
! 89: };
! 90:
! 91: struct words wood[NWOOD] = {
! 92: {"Avocado wood"}, {"Balsa"}, {"Banyan"}, {"Birch"},
! 93: {"Cedar"}, {"Cherry"}, {"Cinnabar"}, {"Dogwood"},
! 94: {"Driftwood"}, {"Ebony"}, {"Eucalyptus"}, {"Hemlock"},
! 95: {"Ironwood"}, {"Mahogany"}, {"Manzanita"}, {"Maple"},
! 96: {"Oak"}, {"Pine"}, {"Redwood"}, {"Rosewood"},
! 97: {"Teak"}, {"Walnut"}, {"Aloe"}, {"Sandalwood"}
! 98: };
! 99:
! 100: struct words metal[NMETAL] = {
! 101: {"Aluminium"}, {"Bone"}, {"Brass"}, {"Bronze"},
! 102: {"Copper"}, {"Chromium"}, {"Iron"}, {"Lead"},
! 103: {"Magnesium"}, {"Pewter"}, {"Platinum"}, {"Silver"},
! 104: {"Steel"}, {"Tin"}, {"Titanium"}, {"Zinc"}
! 105: };
! 106:
! 107: /*
! 108: * make sure all the percentages specified in the tables add up to the
! 109: * right amounts
! 110: */
! 111:
! 112: void
! 113: badcheck(char *name, struct magic_item *magic, int bound)
! 114: {
! 115: register struct magic_item *end;
! 116:
! 117: if (magic[bound - 1].mi_prob == 1000)
! 118: return;
! 119: printf("\nBad percentages for %s:\n", name);
! 120: for (end = &magic[bound] ; magic < end ; magic++)
! 121: printf("%4d%% %s\n", magic->mi_prob, magic->mi_name);
! 122: printf(retstr);
! 123: fflush(stdout);
! 124: while (getchar() != '\n')
! 125: continue;
! 126: }
! 127:
! 128: /*
! 129: * init_colors:
! 130: * Initialize the potion color scheme for this time
! 131: */
! 132:
! 133: void
! 134: init_colors(void)
! 135: {
! 136: register int i;
! 137: register char *str;
! 138:
! 139: for (i = 0 ; i < MAXPOTIONS ; i++)
! 140: {
! 141: do
! 142: str = rainbow[rnd(NCOLORS)].w_string;
! 143: until (isupper(*str));
! 144: *str = tolower(*str);
! 145: p_colors[i] = str;
! 146: p_know[i] = FALSE;
! 147: p_guess[i] = NULL;
! 148: if (i > 0)
! 149: p_magic[i].mi_prob += p_magic[i-1].mi_prob;
! 150: }
! 151: badcheck("potions", p_magic, MAXPOTIONS);
! 152: }
! 153:
! 154: /*
! 155: * do any initialization for food
! 156: */
! 157:
! 158: void
! 159: init_foods(void)
! 160: {
! 161: register int i;
! 162:
! 163: for (i=0; i < MAXFOODS; i++) {
! 164: if (i > 0)
! 165: foods[i].mi_prob += foods[i-1].mi_prob;
! 166: }
! 167: badcheck("foods", foods, MAXFOODS);
! 168: }
! 169:
! 170: /*
! 171: * init_materials:
! 172: * Initialize the construction materials for wands and staffs
! 173: */
! 174:
! 175: void
! 176: init_materials(void)
! 177: {
! 178: register int i;
! 179: register char *str;
! 180:
! 181: for (i = 0 ; i < MAXSTICKS ; i++)
! 182: {
! 183: do
! 184: if (rnd(100) > 50)
! 185: {
! 186: str = metal[rnd(NMETAL)].w_string;
! 187: if (isupper(*str))
! 188: ws_type[i] = "wand";
! 189: }
! 190: else
! 191: {
! 192: str = wood[rnd(NWOOD)].w_string;
! 193: if (isupper(*str))
! 194: ws_type[i] = "staff";
! 195: }
! 196: until (isupper(*str));
! 197: *str = tolower(*str);
! 198: ws_made[i] = str;
! 199: ws_know[i] = FALSE;
! 200: ws_guess[i] = NULL;
! 201: if (i > 0)
! 202: ws_magic[i].mi_prob += ws_magic[i-1].mi_prob;
! 203: }
! 204: badcheck("sticks", ws_magic, MAXSTICKS);
! 205: }
! 206:
! 207: /*
! 208: * do any initialization for miscellaneous magic
! 209: */
! 210:
! 211: void
! 212: init_misc(void)
! 213: {
! 214: register int i;
! 215:
! 216: for (i=0; i < MAXMM; i++) {
! 217: m_know[i] = FALSE;
! 218: m_guess[i] = NULL;
! 219: if (i > 0)
! 220: m_magic[i].mi_prob += m_magic[i-1].mi_prob;
! 221: }
! 222: badcheck("miscellaneous magic", m_magic, MAXMM);
! 223: }
! 224:
! 225: /*
! 226: * init_names:
! 227: * Generate the names of the various scrolls
! 228: */
! 229:
! 230: void
! 231: init_names(void)
! 232: {
! 233: register int nsyl;
! 234: register char *cp, *sp;
! 235: register int i, nwords;
! 236:
! 237: for (i = 0 ; i < MAXSCROLLS ; i++)
! 238: {
! 239: cp = prbuf;
! 240: nwords = rnd(cols/20) + 1 + (cols > 40 ? 1 : 0);
! 241: while(nwords--)
! 242: {
! 243: nsyl = rnd(5)+1;
! 244: while(nsyl--)
! 245: {
! 246: sp = sylls[rnd(NSYLLS)].w_string;
! 247: while(*sp)
! 248: *cp++ = *sp++;
! 249: }
! 250: *cp++ = ' ';
! 251: }
! 252: *--cp = '\0';
! 253: s_names[i] = (char *) new(strlen(prbuf)+1);
! 254: s_know[i] = FALSE;
! 255: s_guess[i] = NULL;
! 256: strcpy(s_names[i], prbuf);
! 257: if (i > 0)
! 258: s_magic[i].mi_prob += s_magic[i-1].mi_prob;
! 259: }
! 260: badcheck("scrolls", s_magic, MAXSCROLLS);
! 261: }
! 262:
! 263: /*
! 264: * init_player:
! 265: * roll up the rogue
! 266: */
! 267:
! 268: void
! 269: init_player(void)
! 270: {
! 271: int stat_total, round = 0, minimum, maximum, ch, i, j = 0;
! 272: short do_escape, *our_stats[NUMABILITIES-1];
! 273: struct linked_list *weap_item, *armor_item, *food_item;
! 274: struct object *obj;
! 275:
! 276: weap_item = armor_item = food_item = NULL;
! 277:
! 278: if (char_type == -1) { /* not set via options */
! 279: /* See what type character will be */
! 280: wclear(hw);
! 281: touchwin(hw);
! 282: wmove(hw,2,0);
! 283: for(i=1; i<=NUM_CHARTYPES-1; i++) {
! 284: wprintw(hw,"[%d] %s\n",i,char_class[i-1].name);
! 285: }
! 286: mvwaddstr(hw, 0, 0, "What character class do you desire? ");
! 287: draw(hw);
! 288: char_type = (wgetch(hw) - '0');
! 289: while (char_type < 1 || char_type > NUM_CHARTYPES-1) {
! 290: wmove(hw,0,0);
! 291: wprintw(hw,"Please enter a character type between 1 and %d: ",
! 292: NUM_CHARTYPES-1);
! 293: draw(hw);
! 294: char_type = (wgetch(hw) - '0');
! 295: }
! 296: char_type--;
! 297: }
! 298: player.t_ctype = char_type;
! 299: player.t_quiet = 0;
! 300: pack = NULL;
! 301:
! 302: /* Select the gold */
! 303: purse = 3000;
! 304: switch (player.t_ctype) {
! 305: case C_FIGHTER:
! 306: purse += 200;
! 307: when C_MAGICIAN:
! 308: case C_CLERIC:
! 309: case C_DRUID:
! 310: purse += 100;
! 311: when C_THIEF:
! 312: case C_ASSASSIN:
! 313: purse += 0;
! 314: when C_RANGER:
! 315: case C_PALADIN:
! 316: purse -= 100;
! 317: when C_MONK:
! 318: purse -= 200;
! 319: }
! 320: /*
! 321: * allow me to describe a super character
! 322: */
! 323: /* let's lessen the restrictions on this okay? */
! 324: if (wizard && strcmp(getenv("SUPER"),"YES") == 0) {
! 325: pstats.s_str = MAXATT;
! 326: pstats.s_intel = MAXATT;
! 327: pstats.s_wisdom = MAXATT;
! 328: pstats.s_dext = MAXATT;
! 329: pstats.s_const = MAXATT;
! 330: pstats.s_charisma = MAXATT;
! 331: pstats.s_exp = 10000000L;
! 332: pstats.s_lvl = 1;
! 333: pstats.s_lvladj = 0;
! 334: pstats.s_hpt = 500;
! 335: pstats.s_carry = totalenc(&player);
! 336: strcpy(pstats.s_dmg,"4d8");
! 337: check_level();
! 338: wmove(hw,0,0);
! 339: wclrtoeol(hw);
! 340: draw(hw);
! 341: mpos = 0;
! 342:
! 343: /* set quest item */
! 344: if(player.t_ctype == C_FIGHTER) quest_item = AXE_AKLAD;
! 345: if(player.t_ctype == C_RANGER) quest_item = BRIAN_MANDOLIN;
! 346: if(player.t_ctype == C_PALADIN) quest_item = HEIL_ANKH;
! 347: if(player.t_ctype == C_MAGICIAN) quest_item = STONEBONES_AMULET;
! 348: if(player.t_ctype == C_CLERIC) quest_item = GERYON_HORN;
! 349: if(player.t_ctype == C_THIEF) quest_item = MUSTY_DAGGER;
! 350: if(player.t_ctype == C_ASSASSIN) quest_item = EYE_VECNA;
! 351: if(player.t_ctype == C_DRUID) quest_item = QUILL_NAGROM;
! 352: if(player.t_ctype == C_MONK) quest_item = EMORI_CLOAK;
! 353:
! 354: /* armor */
! 355: if (player.t_ctype == C_THIEF || player.t_ctype == C_ASSASSIN)
! 356: j = STUDDED_LEATHER;
! 357: else if (player.t_ctype == C_MONK) {
! 358: armor_item = spec_item(MM, MM_BRACERS, 20, 0);
! 359: obj = OBJPTR(armor_item);
! 360: obj->o_weight = things[TYP_MM].mi_wght;
! 361: whatis (armor_item); /* identify it */
! 362: obj->o_flags |= (ISKNOW | ISPROT);
! 363: add_pack(armor_item, TRUE);
! 364: cur_misc[WEAR_BRACERS] = obj;
! 365: goto w_armorjmp;
! 366: }
! 367: else j = PLATE_ARMOR;
! 368:
! 369: armor_item = spec_item(ARMOR, j, 20, 0);
! 370: obj = OBJPTR(armor_item);
! 371: obj->o_weight = armors[j].a_wght;
! 372: obj->o_flags |= (ISKNOW | ISPROT);
! 373: add_pack(armor_item, TRUE);
! 374: cur_armor = obj;
! 375:
! 376: w_armorjmp: /* monk doesn't wear armor */
! 377:
! 378: /* weapons */
! 379: if (player.t_ctype == C_THIEF || player.t_ctype == C_ASSASSIN ||
! 380: player.t_ctype == C_MONK)
! 381: j = BASWORD;
! 382: else if (player.t_ctype == C_FIGHTER || player.t_ctype == C_RANGER ||
! 383: player.t_ctype == C_PALADIN)
! 384: j = TWOSWORD;
! 385: else j = TRIDENT;
! 386:
! 387: weap_item = spec_item(WEAPON, j, 20, 20);
! 388: obj = OBJPTR(weap_item);
! 389: obj->o_flags |= (ISKNOW | ISPROT);
! 390: obj->o_weight = weaps[j].w_wght;
! 391: add_pack(weap_item, TRUE);
! 392: cur_weapon = obj;
! 393:
! 394: /* food */
! 395: food_item = spec_item(FOOD, E_RATION, 0, 0);
! 396: obj = OBJPTR(food_item);
! 397: obj->o_flags |= ISKNOW;
! 398: obj->o_weight = foods[TYP_FOOD].mi_wght;
! 399: add_pack(food_item, TRUE); /* just one */
! 400:
! 401: /* give wizard plenty gold */
! 402: purse = 50000;
! 403: }
! 404: else
! 405: /* default attributes checked */
! 406: {
! 407: if (def_attr == TRUE) { /* "default" option used in ROGUEOPTS */
! 408: switch(player.t_ctype) {
! 409: /* set "default attributes" option and quest items here */
! 410: case C_FIGHTER:
! 411: case C_MONK:
! 412: pstats.s_intel = 7;
! 413: pstats.s_dext = 16;
! 414: pstats.s_charisma = 11;
! 415: if (player.t_ctype == C_FIGHTER) {
! 416: pstats.s_str = 16;
! 417: pstats.s_wisdom = 7;
! 418: pstats.s_const = 17;
! 419: quest_item = AXE_AKLAD;
! 420: }
! 421: else {
! 422: pstats.s_str = 11;
! 423: pstats.s_wisdom = 11;
! 424: pstats.s_const = 18;
! 425: quest_item = EMORI_CLOAK;
! 426: }
! 427: when C_RANGER:
! 428: case C_PALADIN:
! 429: pstats.s_str = 11;
! 430: pstats.s_dext = 16;
! 431: pstats.s_const = 16;
! 432: pstats.s_charisma = 13;
! 433: /* intelligence or wisdom */
! 434: if (player.t_ctype == C_RANGER) {
! 435: pstats.s_intel = 11;
! 436: pstats.s_wisdom = 7;
! 437: quest_item = BRIAN_MANDOLIN;
! 438: }
! 439: else {
! 440: pstats.s_intel = 7;
! 441: pstats.s_wisdom = 11;
! 442: quest_item = HEIL_ANKH;
! 443: }
! 444: when C_THIEF:
! 445: case C_ASSASSIN:
! 446: pstats.s_intel = 7;
! 447: pstats.s_str = 14;
! 448: pstats.s_wisdom = 7;
! 449: pstats.s_dext = 18;
! 450: pstats.s_const = 17;
! 451: pstats.s_charisma = 11;
! 452: if (player.t_ctype == C_THIEF)
! 453: quest_item = MUSTY_DAGGER;
! 454: else
! 455: quest_item = EYE_VECNA;
! 456: when C_MAGICIAN:
! 457: case C_CLERIC:
! 458: case C_DRUID:
! 459: pstats.s_str = 10;
! 460: pstats.s_dext = 16;
! 461: pstats.s_const = 15;
! 462: pstats.s_charisma = 12;
! 463: /* intelligence & wisdom */
! 464: if (player.t_ctype == C_MAGICIAN) {
! 465: pstats.s_intel = 14;
! 466: pstats.s_wisdom = 7;
! 467: }
! 468: else {
! 469: pstats.s_intel = 7;
! 470: pstats.s_wisdom = 14;
! 471: }
! 472: if (player.t_ctype == C_MAGICIAN)
! 473: quest_item = STONEBONES_AMULET;
! 474: else if (player.t_ctype == C_CLERIC)
! 475: quest_item = GERYON_HORN;
! 476: else
! 477: quest_item = QUILL_NAGROM;
! 478: }
! 479: /* Intialize */
! 480: pstats.s_exp = 0L;
! 481: pstats.s_lvl = 1;
! 482: pstats.s_lvladj = 0;
! 483: pstats.s_exp = 0L;
! 484: strcpy(pstats.s_dmg,"2d4");
! 485: pstats.s_carry = totalenc(&player);
! 486: check_level();
! 487: wmove(hw,0,0);
! 488: wclrtoeol(hw);
! 489: draw(hw);
! 490: mpos = 0;
! 491:
! 492: /* Get the hit points. */
! 493: pstats.s_hpt = 12 + const_bonus(); /* Base plus bonus */
! 494:
! 495: /* Add in the component that varies according to class */
! 496: pstats.s_hpt += char_class[player.t_ctype].hit_pts;
! 497:
! 498: /* dole out some armor */
! 499: if (player.t_ctype == C_THIEF || player.t_ctype == C_ASSASSIN)
! 500: j = STUDDED_LEATHER;
! 501: else if (player.t_ctype == C_FIGHTER || player.t_ctype == C_RANGER ||
! 502: player.t_ctype == C_PALADIN) {
! 503: switch (rnd(4)) {
! 504: case 0: j = PLATE_ARMOR;
! 505: when 1: j = PLATE_MAIL;
! 506: when 2: case 3: j = BANDED_MAIL;
! 507: }
! 508: }
! 509: else if (player.t_ctype == C_MONK) {
! 510: if (rnd(3) == 0) j = MM_PROTECT;
! 511: else j = MM_BRACERS;
! 512: armor_item = spec_item(MM, j, rnd(125)/60+3, 0);
! 513: obj = OBJPTR(armor_item);
! 514: obj->o_weight = things[TYP_MM].mi_wght;
! 515: whatis (armor_item); /* identify it */
! 516: obj->o_flags |= ISKNOW;
! 517: add_pack(armor_item, TRUE);
! 518: goto p_armorjmp;
! 519: }
! 520: else { /* other characters */
! 521: switch (rnd(7)) {
! 522: case 0: j = PLATE_MAIL;
! 523: when 1: case 2: j = BANDED_MAIL;
! 524: when 3: case 4: j = SPLINT_MAIL;
! 525: when 5: case 6: j = PADDED_ARMOR;
! 526: }
! 527: }
! 528: armor_item = spec_item(ARMOR, j, rnd(100)/85, 0);
! 529: obj = OBJPTR(armor_item);
! 530: obj->o_weight = armors[j].a_wght;
! 531: obj->o_flags |= ISKNOW;
! 532: add_pack(armor_item, TRUE);
! 533:
! 534: p_armorjmp: /* monk doesn't wear armor */
! 535:
! 536: /* give him a weapon */
! 537: if (player.t_ctype == C_THIEF || player.t_ctype == C_ASSASSIN ||
! 538: player.t_ctype == C_MONK) {
! 539: switch (rnd(5)) {
! 540: case 0: j = BASWORD;
! 541: when 1: case 2: j = TRIDENT;
! 542: when 3: case 4: j = BARDICHE;
! 543: }
! 544: }
! 545: else if (player.t_ctype == C_FIGHTER || player.t_ctype == C_RANGER ||
! 546: player.t_ctype == C_PALADIN) {
! 547: switch (rnd(5)) {
! 548: case 0: j= TWOSWORD;
! 549: when 1: case 2: j= TRIDENT;
! 550: when 3: case 4: j= SWORD;
! 551: }
! 552: }
! 553: else {
! 554: switch (rnd(7)) {
! 555: case 0: j = TRIDENT;
! 556: when 1: case 2: j = SWORD;
! 557: when 3: case 4: j = BARDICHE;
! 558: when 5: j = MACE;
! 559: when 6: j = SPETUM;
! 560: }
! 561: }
! 562: weap_item = spec_item(WEAPON, j, rnd(155)/75, rnd(165)/80);
! 563: obj = OBJPTR(weap_item);
! 564: obj->o_weight = weaps[j].w_wght;
! 565: obj->o_flags |= ISKNOW;
! 566: add_pack(weap_item, TRUE);
! 567:
! 568: /* food rations */
! 569: food_item = spec_item(FOOD, E_RATION, 0, 0);
! 570: obj = OBJPTR(food_item);
! 571: obj->o_weight = foods[TYP_FOOD].mi_wght;
! 572: obj->o_flags |= ISKNOW;
! 573: add_pack(food_item, TRUE);
! 574:
! 575: /* give him some fruit - coose from those w/o special effects */
! 576: switch (rnd(6)) {
! 577: case 0: j = E_BANANA;
! 578: when 1: j = E_BLUEBERRY;
! 579: when 2: j = E_ELDERBERRY;
! 580: when 3: j = E_GUANABANA;
! 581: when 4: j = E_CAPRIFIG;
! 582: when 5: j = E_GOOSEBERRY;
! 583: }
! 584: food_item = spec_item(FOOD, j, 0, 0);
! 585: obj = OBJPTR(food_item);
! 586: obj->o_weight = foods[TYP_FOOD].mi_wght;
! 587: obj->o_flags |= ISKNOW;
! 588: add_pack(food_item, TRUE);
! 589:
! 590: /* adjust purse */
! 591: purse = 2000;
! 592: }
! 593: else { /* select attibutes */
! 594: switch(player.t_ctype) {
! 595: case C_FIGHTER: round = A_STRENGTH;
! 596: when C_RANGER: round = A_CHARISMA;
! 597: when C_PALADIN: round = A_CHARISMA;
! 598: when C_MAGICIAN: round = A_INTELLIGENCE;
! 599: when C_CLERIC: round = A_WISDOM;
! 600: when C_THIEF: round = A_DEXTERITY;
! 601: when C_ASSASSIN: round = A_DEXTERITY;
! 602: when C_DRUID: round = A_WISDOM;
! 603: when C_MONK: round = A_CONSTITUTION;
! 604: }
! 605:
! 606: do {
! 607: wclear(hw);
! 608:
! 609: /* If there is any news, display it */
! 610: if (rogue_news) {
! 611: register int i;
! 612:
! 613: /* Print a separator line */
! 614: wmove(hw, 12, 0);
! 615: for (i=0; i<cols; i++) waddch(hw, '-');
! 616:
! 617: /* Print the news */
! 618: mvwaddstr(hw, 14, 0, rogue_news);
! 619: }
! 620:
! 621: stat_total = MAXSTATS;
! 622: do_escape = FALSE; /* No escape seen yet */
! 623:
! 624: /* Initialize abilities */
! 625: pstats.s_intel = 0;
! 626: pstats.s_str = 0;
! 627: pstats.s_wisdom = 0;
! 628: pstats.s_dext = 0;
! 629: pstats.s_const = 0;
! 630: pstats.s_charisma = 0;
! 631:
! 632: /* Initialize pointer into abilities */
! 633: our_stats[A_INTELLIGENCE] = &pstats.s_intel;
! 634: our_stats[A_STRENGTH] = &pstats.s_str;
! 635: our_stats[A_WISDOM] = &pstats.s_wisdom;
! 636: our_stats[A_DEXTERITY] = &pstats.s_dext;
! 637: our_stats[A_CONSTITUTION] = &pstats.s_const;
! 638:
! 639: /* Let player distribute attributes */
! 640: for (i=0; i<NUMABILITIES-1; i++) {
! 641: wmove(hw, 2, 0);
! 642: wprintw(hw, "You are creating a %s with %2d attribute points.",
! 643: char_class[player.t_ctype].name, stat_total);
! 644:
! 645: /*
! 646: * Player must have a minimum of 7 in any attribute and 11 in
! 647: * the player's primary attribute.
! 648: */
! 649: minimum = (round == i ? 11 : 7);
! 650:
! 651: /* Subtract out remaining minimums */
! 652: maximum = stat_total - (7 * (NUMABILITIES-1 - i));
! 653:
! 654: /* Subtract out remainder of profession minimum (11 - 7) */
! 655: if (round > i) maximum -= 4;
! 656:
! 657: /* Maximum can't be greater than 18 */
! 658: if (maximum > 18) maximum = 18;
! 659:
! 660: wmove(hw, 4, 0);
! 661: wprintw(hw,
! 662: "Minimum: %2d; Maximum: %2d (%s corrects previous entry)",
! 663: minimum, maximum, unctrl('\b'));
! 664:
! 665: wmove(hw, 6, 0);
! 666: wprintw(hw, " Int: %-2d", pstats.s_intel);
! 667: wprintw(hw, " Str: %-2d", pstats.s_str);
! 668: wprintw(hw, " Wis: %-2d", pstats.s_wisdom);
! 669: wprintw(hw, " Dex: %-2d", pstats.s_dext);
! 670: wprintw(hw, " Con: %-2d", pstats.s_const);
! 671: wprintw(hw, " Cha: %-2d", pstats.s_charisma);
! 672: wclrtoeol(hw);
! 673: wmove(hw, 6, 11*i + 9);
! 674: if (do_escape == FALSE) draw(hw);
! 675:
! 676: /* Get player's input */
! 677: if (do_escape || maximum == minimum) {
! 678: *our_stats[i] = maximum;
! 679: stat_total -= maximum;
! 680: }
! 681: else for (;;) {
! 682: ch = wgetch(hw);
! 683: if (ch == '\b') { /* Backspace */
! 684: if (i == 0) continue; /* Can't move back */
! 685: else {
! 686: stat_total += *our_stats[i-1];
! 687: *our_stats[i] = 0;
! 688: *our_stats[i-1] = 0;
! 689: i -= 2; /* Back out */
! 690: break;
! 691: }
! 692: }
! 693: if (ch == '\033') { /* Escape */
! 694: /*
! 695: * Escape will result in using all maximums for
! 696: * remaining abilities.
! 697: */
! 698: do_escape = TRUE;
! 699: *our_stats[i] = maximum;
! 700: stat_total -= maximum;
! 701: break;
! 702: }
! 703:
! 704: /* Do we have a legal digit? */
! 705: if (ch >= '0' && ch <= '9') {
! 706: ch -= '0'; /* Convert it to a number */
! 707: *our_stats[i] = 10 * *our_stats[i] + ch;
! 708:
! 709: /* Is the number in range? */
! 710: if (*our_stats[i] >= minimum &&
! 711: *our_stats[i] <= maximum) {
! 712: stat_total -= *our_stats[i];
! 713: break;
! 714: }
! 715:
! 716: /*
! 717: * If it's too small, get more - 1x is the only
! 718: * allowable case.
! 719: */
! 720: if (*our_stats[i] < minimum && *our_stats[i] == 1) {
! 721: /* Print the player's one */
! 722: waddch(hw, '1');
! 723: draw(hw);
! 724: continue;
! 725: }
! 726: }
! 727:
! 728: /* Error condition */
! 729: putchar('\007');
! 730: *our_stats[i] = 0;
! 731: i--; /* Rewind */
! 732: break;
! 733: }
! 734: }
! 735:
! 736: /* Discard extra points over 18 */
! 737: if (stat_total > 18) stat_total = 18;
! 738:
! 739: /* Charisma gets what's left */
! 740: pstats.s_charisma = stat_total;
! 741:
! 742: /* Intialize constants */
! 743: pstats.s_lvl = 1;
! 744: pstats.s_lvladj = 0;
! 745: pstats.s_exp = 0L;
! 746: strcpy(pstats.s_dmg,"2d4");
! 747: pstats.s_carry = totalenc(&player);
! 748:
! 749: /* Get the hit points. */
! 750: pstats.s_hpt = 12 + const_bonus(); /* Base plus bonus */
! 751:
! 752: /* Add in the component that varies according to class */
! 753: pstats.s_hpt += char_class[player.t_ctype].hit_pts;
! 754:
! 755: /* Display the character */
! 756: wmove(hw, 2, 0);
! 757: wprintw(hw,"You are creating a %s.",
! 758: char_class[player.t_ctype].name);
! 759: wclrtoeol(hw);
! 760:
! 761: /* Get rid of max/min line */
! 762: wmove(hw, 4, 0);
! 763: wclrtoeol(hw);
! 764:
! 765: wmove(hw, 6, 0);
! 766: wprintw(hw, " Int: %2d", pstats.s_intel);
! 767: wprintw(hw, " Str: %2d", pstats.s_str);
! 768: wprintw(hw, " Wis: %2d", pstats.s_wisdom);
! 769: wprintw(hw, " Dex: %2d", pstats.s_dext);
! 770: wprintw(hw, " Con: %2d", pstats.s_const);
! 771: wprintw(hw, " Cha: %2d", pstats.s_charisma);
! 772: wclrtoeol(hw);
! 773:
! 774: wmove(hw, 8, 0);
! 775: wprintw(hw, " Hp: %2d", pstats.s_hpt);
! 776: wclrtoeol(hw);
! 777:
! 778: wmove(hw, 10, 0);
! 779: wprintw(hw, " Gold: %ld", purse);
! 780:
! 781: mvwaddstr(hw, 0, 0, "Is this character okay? ");
! 782: draw(hw);
! 783: } while(wgetch(hw) != 'y');
! 784: }
! 785: }
! 786: pstats.s_arm = 10;
! 787: max_stats = pstats;
! 788: /* Set up initial movement rate */
! 789: player.t_action = A_NIL;
! 790: player.t_movement = 6;
! 791: player.t_no_move = 0;
! 792: player.t_using = NULL;
! 793: wclear(hw);
! 794: }
! 795:
! 796: /*
! 797: * init_stones:
! 798: * Initialize the ring stone setting scheme for this time
! 799: */
! 800:
! 801: void
! 802: init_stones(void)
! 803: {
! 804: register int i;
! 805: register char *str;
! 806:
! 807: for (i = 0 ; i < MAXRINGS ; i++)
! 808: {
! 809: do
! 810: str = stones[rnd(NSTONES)].w_string;
! 811: until (isupper(*str));
! 812: *str = tolower(*str);
! 813: r_stones[i] = str;
! 814: r_know[i] = FALSE;
! 815: r_guess[i] = NULL;
! 816: if (i > 0)
! 817: r_magic[i].mi_prob += r_magic[i-1].mi_prob;
! 818: }
! 819: badcheck("rings", r_magic, MAXRINGS);
! 820: }
! 821:
! 822: /*
! 823: * init_things
! 824: * Initialize the probabilities for types of things
! 825: */
! 826:
! 827: void
! 828: init_things(void)
! 829: {
! 830: register struct magic_item *mp;
! 831:
! 832: for (mp = &things[1] ; mp < &things[NUMTHINGS] ; mp++)
! 833: mp->mi_prob += (mp-1)->mi_prob;
! 834: badcheck("things", things, NUMTHINGS);
! 835: }
! 836:
CVSweb