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