home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume1 / rogue / part02 / object.c < prev    next >
C/C++ Source or Header  |  1987-05-12  |  16KB  |  771 lines

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