|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1988 The Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * This code is derived from software contributed to Berkeley by ! 6: * Timothy C. Stoehr. ! 7: * ! 8: * Redistribution and use in source and binary forms are permitted ! 9: * provided that: (1) source distributions retain this entire copyright ! 10: * notice and comment, and (2) distributions including binaries display ! 11: * the following acknowledgement: ``This product includes software ! 12: * developed by the University of California, Berkeley and its contributors'' ! 13: * in the documentation or other materials provided with the distribution ! 14: * and in all advertising materials mentioning features or use of this ! 15: * software. Neither the name of the University nor the names of its ! 16: * contributors may be used to endorse or promote products derived ! 17: * from this software without specific prior written permission. ! 18: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 19: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 20: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 21: */ ! 22: ! 23: #ifndef lint ! 24: static char sccsid[] = "@(#)object.c 5.3 (Berkeley) 6/1/90"; ! 25: #endif /* not lint */ ! 26: ! 27: /* ! 28: * object.c ! 29: * ! 30: * This source herein may be modified and/or distributed by anybody who ! 31: * so desires, with the following restrictions: ! 32: * 1.) No portion of this notice shall be removed. ! 33: * 2.) Credit shall not be taken for the creation of this source. ! 34: * 3.) This code is not to be traded, sold, or used for personal ! 35: * gain or profit. ! 36: * ! 37: */ ! 38: ! 39: #include "rogue.h" ! 40: ! 41: object level_objects; ! 42: unsigned short dungeon[DROWS][DCOLS]; ! 43: short foods = 0; ! 44: object *free_list = (object *) 0; ! 45: char *fruit = (char *) 0; ! 46: ! 47: fighter rogue = { ! 48: INIT_AW, /* armor, weapon */ ! 49: INIT_RINGS, /* rings */ ! 50: INIT_HP, /* Hp current,max */ ! 51: INIT_STR, /* Str current,max */ ! 52: INIT_PACK, /* pack */ ! 53: INIT_GOLD, /* gold */ ! 54: INIT_EXP, /* exp level,points */ ! 55: 0, 0, /* row, col */ ! 56: INIT_CHAR, /* char */ ! 57: INIT_MOVES /* moves */ ! 58: }; ! 59: ! 60: struct id id_potions[POTIONS] = { ! 61: {100, "blue \0 ", "of increase strength ", 0}, ! 62: {250, "red \0 ", "of restore strength ", 0}, ! 63: {100, "green \0 ", "of healing ", 0}, ! 64: {200, "grey \0 ", "of extra healing ", 0}, ! 65: {10, "brown \0 ", "of poison ", 0}, ! 66: {300, "clear \0 ", "of raise level ", 0}, ! 67: {10, "pink \0 ", "of blindness ", 0}, ! 68: {25, "white \0 ", "of hallucination ", 0}, ! 69: {100, "purple \0 ", "of detect monster ", 0}, ! 70: {100, "black \0 ", "of detect things ", 0}, ! 71: {10, "yellow \0 ", "of confusion ", 0}, ! 72: {80, "plaid \0 ", "of levitation ", 0}, ! 73: {150, "burgundy \0 ", "of haste self ", 0}, ! 74: {145, "beige \0 ", "of see invisible ", 0} ! 75: }; ! 76: ! 77: struct id id_scrolls[SCROLS] = { ! 78: {505, " ", "of protect armor ", 0}, ! 79: {200, " ", "of hold monster ", 0}, ! 80: {235, " ", "of enchant weapon ", 0}, ! 81: {235, " ", "of enchant armor ", 0}, ! 82: {175, " ", "of identify ", 0}, ! 83: {190, " ", "of teleportation ", 0}, ! 84: {25, " ", "of sleep ", 0}, ! 85: {610, " ", "of scare monster ", 0}, ! 86: {210, " ", "of remove curse ", 0}, ! 87: {80, " ", "of create monster ",0}, ! 88: {25, " ", "of aggravate monster ",0}, ! 89: {180, " ", "of magic mapping ", 0}, ! 90: {90, " ", "of confuse monster ", 0} ! 91: }; ! 92: ! 93: struct id id_weapons[WEAPONS] = { ! 94: {150, "short bow ", "", 0}, ! 95: {8, "darts ", "", 0}, ! 96: {15, "arrows ", "", 0}, ! 97: {27, "daggers ", "", 0}, ! 98: {35, "shurikens ", "", 0}, ! 99: {360, "mace ", "", 0}, ! 100: {470, "long sword ", "", 0}, ! 101: {580, "two-handed sword ", "", 0} ! 102: }; ! 103: ! 104: struct id id_armors[ARMORS] = { ! 105: {300, "leather armor ", "", (UNIDENTIFIED)}, ! 106: {300, "ring mail ", "", (UNIDENTIFIED)}, ! 107: {400, "scale mail ", "", (UNIDENTIFIED)}, ! 108: {500, "chain mail ", "", (UNIDENTIFIED)}, ! 109: {600, "banded mail ", "", (UNIDENTIFIED)}, ! 110: {600, "splint mail ", "", (UNIDENTIFIED)}, ! 111: {700, "plate mail ", "", (UNIDENTIFIED)} ! 112: }; ! 113: ! 114: struct id id_wands[WANDS] = { ! 115: {25, " ", "of teleport away ",0}, ! 116: {50, " ", "of slow monster ", 0}, ! 117: {8, " ", "of invisibility ",0}, ! 118: {55, " ", "of polymorph ",0}, ! 119: {2, " ", "of haste monster ",0}, ! 120: {20, " ", "of magic missile ",0}, ! 121: {20, " ", "of cancellation ",0}, ! 122: {0, " ", "of do nothing ",0}, ! 123: {35, " ", "of drain life ",0}, ! 124: {20, " ", "of cold ",0}, ! 125: {20, " ", "of fire ",0} ! 126: }; ! 127: ! 128: struct id id_rings[RINGS] = { ! 129: {250, " ", "of stealth ",0}, ! 130: {100, " ", "of teleportation ", 0}, ! 131: {255, " ", "of regeneration ",0}, ! 132: {295, " ", "of slow digestion ",0}, ! 133: {200, " ", "of add strength ",0}, ! 134: {250, " ", "of sustain strength ",0}, ! 135: {250, " ", "of dexterity ",0}, ! 136: {25, " ", "of adornment ",0}, ! 137: {300, " ", "of see invisible ",0}, ! 138: {290, " ", "of maintain armor ",0}, ! 139: {270, " ", "of searching ",0}, ! 140: }; ! 141: ! 142: extern short cur_level, max_level; ! 143: extern short party_room; ! 144: extern char *error_file; ! 145: extern boolean is_wood[]; ! 146: ! 147: put_objects() ! 148: { ! 149: short i, n; ! 150: object *obj; ! 151: ! 152: if (cur_level < max_level) { ! 153: return; ! 154: } ! 155: n = coin_toss() ? get_rand(2, 4) : get_rand(3, 5); ! 156: while (rand_percent(33)) { ! 157: n++; ! 158: } ! 159: if (party_room != NO_ROOM) { ! 160: make_party(); ! 161: } ! 162: for (i = 0; i < n; i++) { ! 163: obj = gr_object(); ! 164: rand_place(obj); ! 165: } ! 166: put_gold(); ! 167: } ! 168: ! 169: put_gold() ! 170: { ! 171: short i, j; ! 172: short row,col; ! 173: boolean is_maze, is_room; ! 174: ! 175: for (i = 0; i < MAXROOMS; i++) { ! 176: is_maze = (rooms[i].is_room & R_MAZE) ? 1 : 0; ! 177: is_room = (rooms[i].is_room & R_ROOM) ? 1 : 0; ! 178: ! 179: if (!(is_room || is_maze)) { ! 180: continue; ! 181: } ! 182: if (is_maze || rand_percent(GOLD_PERCENT)) { ! 183: for (j = 0; j < 50; j++) { ! 184: row = get_rand(rooms[i].top_row+1, ! 185: rooms[i].bottom_row-1); ! 186: col = get_rand(rooms[i].left_col+1, ! 187: rooms[i].right_col-1); ! 188: if ((dungeon[row][col] == FLOOR) || ! 189: (dungeon[row][col] == TUNNEL)) { ! 190: plant_gold(row, col, is_maze); ! 191: break; ! 192: } ! 193: } ! 194: } ! 195: } ! 196: } ! 197: ! 198: plant_gold(row, col, is_maze) ! 199: short row, col; ! 200: boolean is_maze; ! 201: { ! 202: object *obj; ! 203: ! 204: obj = alloc_object(); ! 205: obj->row = row; obj->col = col; ! 206: obj->what_is = GOLD; ! 207: obj->quantity = get_rand((2 * cur_level), (16 * cur_level)); ! 208: if (is_maze) { ! 209: obj->quantity += obj->quantity / 2; ! 210: } ! 211: dungeon[row][col] |= OBJECT; ! 212: (void) add_to_pack(obj, &level_objects, 0); ! 213: } ! 214: ! 215: place_at(obj, row, col) ! 216: object *obj; ! 217: { ! 218: obj->row = row; ! 219: obj->col = col; ! 220: dungeon[row][col] |= OBJECT; ! 221: (void) add_to_pack(obj, &level_objects, 0); ! 222: } ! 223: ! 224: object * ! 225: object_at(pack, row, col) ! 226: register object *pack; ! 227: short row, col; ! 228: { ! 229: object *obj = (object *) 0; ! 230: ! 231: if (dungeon[row][col] & (MONSTER | OBJECT)) { ! 232: obj = pack->next_object; ! 233: ! 234: while (obj && ((obj->row != row) || (obj->col != col))) { ! 235: obj = obj->next_object; ! 236: } ! 237: if (!obj) { ! 238: message("object_at(): inconsistent", 1); ! 239: } ! 240: } ! 241: return(obj); ! 242: } ! 243: ! 244: object * ! 245: get_letter_object(ch) ! 246: { ! 247: object *obj; ! 248: ! 249: obj = rogue.pack.next_object; ! 250: ! 251: while (obj && (obj->ichar != ch)) { ! 252: obj = obj->next_object; ! 253: } ! 254: return(obj); ! 255: } ! 256: ! 257: free_stuff(objlist) ! 258: object *objlist; ! 259: { ! 260: object *obj; ! 261: ! 262: while (objlist->next_object) { ! 263: obj = objlist->next_object; ! 264: objlist->next_object = ! 265: objlist->next_object->next_object; ! 266: free_object(obj); ! 267: } ! 268: } ! 269: ! 270: char * ! 271: name_of(obj) ! 272: object *obj; ! 273: { ! 274: char *retstring; ! 275: ! 276: switch(obj->what_is) { ! 277: case SCROL: ! 278: retstring = obj->quantity > 1 ? "scrolls " : "scroll "; ! 279: break; ! 280: case POTION: ! 281: retstring = obj->quantity > 1 ? "potions " : "potion "; ! 282: break; ! 283: case FOOD: ! 284: if (obj->which_kind == RATION) { ! 285: retstring = "food "; ! 286: } else { ! 287: retstring = fruit; ! 288: } ! 289: break; ! 290: case WAND: ! 291: retstring = is_wood[obj->which_kind] ? "staff " : "wand "; ! 292: break; ! 293: case WEAPON: ! 294: switch(obj->which_kind) { ! 295: case DART: ! 296: retstring=obj->quantity > 1 ? "darts " : "dart "; ! 297: break; ! 298: case ARROW: ! 299: retstring=obj->quantity > 1 ? "arrows " : "arrow "; ! 300: break; ! 301: case DAGGER: ! 302: retstring=obj->quantity > 1 ? "daggers " : "dagger "; ! 303: break; ! 304: case SHURIKEN: ! 305: retstring=obj->quantity > 1?"shurikens ":"shuriken "; ! 306: break; ! 307: default: ! 308: retstring = id_weapons[obj->which_kind].title; ! 309: } ! 310: break; ! 311: case ARMOR: ! 312: retstring = "armor "; ! 313: break; ! 314: case RING: ! 315: retstring = "ring "; ! 316: break; ! 317: case AMULET: ! 318: retstring = "amulet "; ! 319: break; ! 320: default: ! 321: retstring = "unknown "; ! 322: break; ! 323: } ! 324: return(retstring); ! 325: } ! 326: ! 327: object * ! 328: gr_object() ! 329: { ! 330: object *obj; ! 331: ! 332: obj = alloc_object(); ! 333: ! 334: if (foods < (cur_level / 3)) { ! 335: obj->what_is = FOOD; ! 336: foods++; ! 337: } else { ! 338: obj->what_is = gr_what_is(); ! 339: } ! 340: switch(obj->what_is) { ! 341: case SCROL: ! 342: gr_scroll(obj); ! 343: break; ! 344: case POTION: ! 345: gr_potion(obj); ! 346: break; ! 347: case WEAPON: ! 348: gr_weapon(obj, 1); ! 349: break; ! 350: case ARMOR: ! 351: gr_armor(obj); ! 352: break; ! 353: case WAND: ! 354: gr_wand(obj); ! 355: break; ! 356: case FOOD: ! 357: get_food(obj, 0); ! 358: break; ! 359: case RING: ! 360: gr_ring(obj, 1); ! 361: break; ! 362: } ! 363: return(obj); ! 364: } ! 365: ! 366: unsigned short ! 367: gr_what_is() ! 368: { ! 369: short percent; ! 370: unsigned short what_is; ! 371: ! 372: percent = get_rand(1, 91); ! 373: ! 374: if (percent <= 30) { ! 375: what_is = SCROL; ! 376: } else if (percent <= 60) { ! 377: what_is = POTION; ! 378: } else if (percent <= 64) { ! 379: what_is = WAND; ! 380: } else if (percent <= 74) { ! 381: what_is = WEAPON; ! 382: } else if (percent <= 83) { ! 383: what_is = ARMOR; ! 384: } else if (percent <= 88) { ! 385: what_is = FOOD; ! 386: } else { ! 387: what_is = RING; ! 388: } ! 389: return(what_is); ! 390: } ! 391: ! 392: gr_scroll(obj) ! 393: object *obj; ! 394: { ! 395: short percent; ! 396: ! 397: percent = get_rand(0, 91); ! 398: ! 399: obj->what_is = SCROL; ! 400: ! 401: if (percent <= 5) { ! 402: obj->which_kind = PROTECT_ARMOR; ! 403: } else if (percent <= 10) { ! 404: obj->which_kind = HOLD_MONSTER; ! 405: } else if (percent <= 20) { ! 406: obj->which_kind = CREATE_MONSTER; ! 407: } else if (percent <= 35) { ! 408: obj->which_kind = IDENTIFY; ! 409: } else if (percent <= 43) { ! 410: obj->which_kind = TELEPORT; ! 411: } else if (percent <= 50) { ! 412: obj->which_kind = SLEEP; ! 413: } else if (percent <= 55) { ! 414: obj->which_kind = SCARE_MONSTER; ! 415: } else if (percent <= 64) { ! 416: obj->which_kind = REMOVE_CURSE; ! 417: } else if (percent <= 69) { ! 418: obj->which_kind = ENCH_ARMOR; ! 419: } else if (percent <= 74) { ! 420: obj->which_kind = ENCH_WEAPON; ! 421: } else if (percent <= 80) { ! 422: obj->which_kind = AGGRAVATE_MONSTER; ! 423: } else if (percent <= 86) { ! 424: obj->which_kind = CON_MON; ! 425: } else { ! 426: obj->which_kind = MAGIC_MAPPING; ! 427: } ! 428: } ! 429: ! 430: gr_potion(obj) ! 431: object *obj; ! 432: { ! 433: short percent; ! 434: ! 435: percent = get_rand(1, 118); ! 436: ! 437: obj->what_is = POTION; ! 438: ! 439: if (percent <= 5) { ! 440: obj->which_kind = RAISE_LEVEL; ! 441: } else if (percent <= 15) { ! 442: obj->which_kind = DETECT_OBJECTS; ! 443: } else if (percent <= 25) { ! 444: obj->which_kind = DETECT_MONSTER; ! 445: } else if (percent <= 35) { ! 446: obj->which_kind = INCREASE_STRENGTH; ! 447: } else if (percent <= 45) { ! 448: obj->which_kind = RESTORE_STRENGTH; ! 449: } else if (percent <= 55) { ! 450: obj->which_kind = HEALING; ! 451: } else if (percent <= 65) { ! 452: obj->which_kind = EXTRA_HEALING; ! 453: } else if (percent <= 75) { ! 454: obj->which_kind = BLINDNESS; ! 455: } else if (percent <= 85) { ! 456: obj->which_kind = HALLUCINATION; ! 457: } else if (percent <= 95) { ! 458: obj->which_kind = CONFUSION; ! 459: } else if (percent <= 105) { ! 460: obj->which_kind = POISON; ! 461: } else if (percent <= 110) { ! 462: obj->which_kind = LEVITATION; ! 463: } else if (percent <= 114) { ! 464: obj->which_kind = HASTE_SELF; ! 465: } else { ! 466: obj->which_kind = SEE_INVISIBLE; ! 467: } ! 468: } ! 469: ! 470: gr_weapon(obj, assign_wk) ! 471: object *obj; ! 472: int assign_wk; ! 473: { ! 474: short percent; ! 475: short i; ! 476: short blessing, increment; ! 477: ! 478: obj->what_is = WEAPON; ! 479: if (assign_wk) { ! 480: obj->which_kind = get_rand(0, (WEAPONS - 1)); ! 481: } ! 482: if ((obj->which_kind == ARROW) || (obj->which_kind == DAGGER) || ! 483: (obj->which_kind == SHURIKEN) | (obj->which_kind == DART)) { ! 484: obj->quantity = get_rand(3, 15); ! 485: obj->quiver = get_rand(0, 126); ! 486: } else { ! 487: obj->quantity = 1; ! 488: } ! 489: obj->hit_enchant = obj->d_enchant = 0; ! 490: ! 491: percent = get_rand(1, 96); ! 492: blessing = get_rand(1, 3); ! 493: ! 494: if (percent <= 16) { ! 495: increment = 1; ! 496: } else if (percent <= 32) { ! 497: increment = -1; ! 498: obj->is_cursed = 1; ! 499: } ! 500: if (percent <= 32) { ! 501: for (i = 0; i < blessing; i++) { ! 502: if (coin_toss()) { ! 503: obj->hit_enchant += increment; ! 504: } else { ! 505: obj->d_enchant += increment; ! 506: } ! 507: } ! 508: } ! 509: switch(obj->which_kind) { ! 510: case BOW: ! 511: case DART: ! 512: obj->damage = "1d1"; ! 513: break; ! 514: case ARROW: ! 515: obj->damage = "1d2"; ! 516: break; ! 517: case DAGGER: ! 518: obj->damage = "1d3"; ! 519: break; ! 520: case SHURIKEN: ! 521: obj->damage = "1d4"; ! 522: break; ! 523: case MACE: ! 524: obj->damage = "2d3"; ! 525: break; ! 526: case LONG_SWORD: ! 527: obj->damage = "3d4"; ! 528: break; ! 529: case TWO_HANDED_SWORD: ! 530: obj->damage = "4d5"; ! 531: break; ! 532: } ! 533: } ! 534: ! 535: gr_armor(obj) ! 536: object *obj; ! 537: { ! 538: short percent; ! 539: short blessing; ! 540: ! 541: obj->what_is = ARMOR; ! 542: obj->which_kind = get_rand(0, (ARMORS - 1)); ! 543: obj->class = obj->which_kind + 2; ! 544: if ((obj->which_kind == PLATE) || (obj->which_kind == SPLINT)) { ! 545: obj->class--; ! 546: } ! 547: obj->is_protected = 0; ! 548: obj->d_enchant = 0; ! 549: ! 550: percent = get_rand(1, 100); ! 551: blessing = get_rand(1, 3); ! 552: ! 553: if (percent <= 16) { ! 554: obj->is_cursed = 1; ! 555: obj->d_enchant -= blessing; ! 556: } else if (percent <= 33) { ! 557: obj->d_enchant += blessing; ! 558: } ! 559: } ! 560: ! 561: gr_wand(obj) ! 562: object *obj; ! 563: { ! 564: obj->what_is = WAND; ! 565: obj->which_kind = get_rand(0, (WANDS - 1)); ! 566: obj->class = get_rand(3, 7); ! 567: } ! 568: ! 569: get_food(obj, force_ration) ! 570: object *obj; ! 571: boolean force_ration; ! 572: { ! 573: obj->what_is = FOOD; ! 574: ! 575: if (force_ration || rand_percent(80)) { ! 576: obj->which_kind = RATION; ! 577: } else { ! 578: obj->which_kind = FRUIT; ! 579: } ! 580: } ! 581: ! 582: put_stairs() ! 583: { ! 584: short row, col; ! 585: ! 586: gr_row_col(&row, &col, (FLOOR | TUNNEL)); ! 587: dungeon[row][col] |= STAIRS; ! 588: } ! 589: ! 590: get_armor_class(obj) ! 591: object *obj; ! 592: { ! 593: if (obj) { ! 594: return(obj->class + obj->d_enchant); ! 595: } ! 596: return(0); ! 597: } ! 598: ! 599: object * ! 600: alloc_object() ! 601: { ! 602: object *obj; ! 603: ! 604: if (free_list) { ! 605: obj = free_list; ! 606: free_list = free_list->next_object; ! 607: } else if (!(obj = (object *) md_malloc(sizeof(object)))) { ! 608: message("cannot allocate object, saving game", 0); ! 609: save_into_file(error_file); ! 610: } ! 611: obj->quantity = 1; ! 612: obj->ichar = 'L'; ! 613: obj->picked_up = obj->is_cursed = 0; ! 614: obj->in_use_flags = NOT_USED; ! 615: obj->identified = UNIDENTIFIED; ! 616: obj->damage = "1d1"; ! 617: return(obj); ! 618: } ! 619: ! 620: free_object(obj) ! 621: object *obj; ! 622: { ! 623: obj->next_object = free_list; ! 624: free_list = obj; ! 625: } ! 626: ! 627: make_party() ! 628: { ! 629: short n; ! 630: ! 631: party_room = gr_room(); ! 632: ! 633: n = rand_percent(99) ? party_objects(party_room) : 11; ! 634: if (rand_percent(99)) { ! 635: party_monsters(party_room, n); ! 636: } ! 637: } ! 638: ! 639: show_objects() ! 640: { ! 641: object *obj; ! 642: short mc, rc, row, col; ! 643: object *monster; ! 644: ! 645: obj = level_objects.next_object; ! 646: ! 647: while (obj) { ! 648: row = obj->row; ! 649: col = obj->col; ! 650: ! 651: rc = get_mask_char(obj->what_is); ! 652: ! 653: if (dungeon[row][col] & MONSTER) { ! 654: if (monster = object_at(&level_monsters, row, col)) { ! 655: monster->trail_char = rc; ! 656: } ! 657: } ! 658: mc = mvinch(row, col); ! 659: if (((mc < 'A') || (mc > 'Z')) && ! 660: ((row != rogue.row) || (col != rogue.col))) { ! 661: mvaddch(row, col, rc); ! 662: } ! 663: obj = obj->next_object; ! 664: } ! 665: ! 666: monster = level_monsters.next_object; ! 667: ! 668: while (monster) { ! 669: if (monster->m_flags & IMITATES) { ! 670: mvaddch(monster->row, monster->col, (int) monster->disguise); ! 671: } ! 672: monster = monster->next_monster; ! 673: } ! 674: } ! 675: ! 676: put_amulet() ! 677: { ! 678: object *obj; ! 679: ! 680: obj = alloc_object(); ! 681: obj->what_is = AMULET; ! 682: rand_place(obj); ! 683: } ! 684: ! 685: rand_place(obj) ! 686: object *obj; ! 687: { ! 688: short row, col; ! 689: ! 690: gr_row_col(&row, &col, (FLOOR | TUNNEL)); ! 691: place_at(obj, row, col); ! 692: } ! 693: ! 694: c_object_for_wizard() ! 695: { ! 696: short ch, max, wk; ! 697: object *obj; ! 698: char buf[80]; ! 699: ! 700: if (pack_count((object *) 0) >= MAX_PACK_COUNT) { ! 701: message("pack full", 0); ! 702: return; ! 703: } ! 704: message("type of object?", 0); ! 705: ! 706: while (r_index("!?:)]=/,\033", (ch = rgetchar()), 0) == -1) { ! 707: sound_bell(); ! 708: } ! 709: check_message(); ! 710: ! 711: if (ch == '\033') { ! 712: return; ! 713: } ! 714: obj = alloc_object(); ! 715: ! 716: switch(ch) { ! 717: case '!': ! 718: obj->what_is = POTION; ! 719: max = POTIONS - 1; ! 720: break; ! 721: case '?': ! 722: obj->what_is = SCROL; ! 723: max = SCROLS - 1; ! 724: break; ! 725: case ',': ! 726: obj->what_is = AMULET; ! 727: break; ! 728: case ':': ! 729: get_food(obj, 0); ! 730: break; ! 731: case ')': ! 732: gr_weapon(obj, 0); ! 733: max = WEAPONS - 1; ! 734: break; ! 735: case ']': ! 736: gr_armor(obj); ! 737: max = ARMORS - 1; ! 738: break; ! 739: case '/': ! 740: gr_wand(obj); ! 741: max = WANDS - 1; ! 742: break; ! 743: case '=': ! 744: max = RINGS - 1; ! 745: obj->what_is = RING; ! 746: break; ! 747: } ! 748: if ((ch != ',') && (ch != ':')) { ! 749: GIL: ! 750: if (get_input_line("which kind?", "", buf, "", 0, 1)) { ! 751: wk = get_number(buf); ! 752: if ((wk >= 0) && (wk <= max)) { ! 753: obj->which_kind = (unsigned short) wk; ! 754: if (obj->what_is == RING) { ! 755: gr_ring(obj, 0); ! 756: } ! 757: } else { ! 758: sound_bell(); ! 759: goto GIL; ! 760: } ! 761: } else { ! 762: free_object(obj); ! 763: return; ! 764: } ! 765: } ! 766: get_desc(obj, buf); ! 767: message(buf, 0); ! 768: (void) add_to_pack(obj, &rogue.pack, 1); ! 769: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.