132689Sbostic /* 2*36704Sbostic * Copyright (c) 1988 The Regents of the University of California. 3*36704Sbostic * All rights reserved. 4*36704Sbostic * 5*36704Sbostic * This code is derived from software contributed to Berkeley by 6*36704Sbostic * Timothy C. Stoehr. 7*36704Sbostic * 8*36704Sbostic * Redistribution and use in source and binary forms are permitted 9*36704Sbostic * provided that the above copyright notice and this paragraph are 10*36704Sbostic * duplicated in all such forms and that any documentation, 11*36704Sbostic * advertising materials, and other materials related to such 12*36704Sbostic * distribution and use acknowledge that the software was developed 13*36704Sbostic * by the University of California, Berkeley. The name of the 14*36704Sbostic * University may not be used to endorse or promote products derived 15*36704Sbostic * from this software without specific prior written permission. 16*36704Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17*36704Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18*36704Sbostic * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19*36704Sbostic */ 20*36704Sbostic 21*36704Sbostic #ifndef lint 22*36704Sbostic static char sccsid[] = "@(#)object.c 5.2 (Berkeley) 02/07/89"; 23*36704Sbostic #endif /* not lint */ 24*36704Sbostic 25*36704Sbostic /* 2632689Sbostic * object.c 2732689Sbostic * 2832689Sbostic * This source herein may be modified and/or distributed by anybody who 2932689Sbostic * so desires, with the following restrictions: 3032689Sbostic * 1.) No portion of this notice shall be removed. 3132689Sbostic * 2.) Credit shall not be taken for the creation of this source. 3232689Sbostic * 3.) This code is not to be traded, sold, or used for personal 3332689Sbostic * gain or profit. 3432689Sbostic * 3532689Sbostic */ 3632689Sbostic 3732689Sbostic #include "rogue.h" 3832689Sbostic 3932689Sbostic object level_objects; 4032689Sbostic unsigned short dungeon[DROWS][DCOLS]; 4132689Sbostic short foods = 0; 4232689Sbostic object *free_list = (object *) 0; 4332689Sbostic char *fruit = (char *) 0; 4432689Sbostic 4532689Sbostic fighter rogue = { 4632689Sbostic INIT_AW, /* armor, weapon */ 4732689Sbostic INIT_RINGS, /* rings */ 4832689Sbostic INIT_HP, /* Hp current,max */ 4932689Sbostic INIT_STR, /* Str current,max */ 5032689Sbostic INIT_PACK, /* pack */ 5132689Sbostic INIT_GOLD, /* gold */ 5232689Sbostic INIT_EXP, /* exp level,points */ 5332689Sbostic 0, 0, /* row, col */ 5432689Sbostic INIT_CHAR, /* char */ 5532689Sbostic INIT_MOVES /* moves */ 5632689Sbostic }; 5732689Sbostic 5832689Sbostic struct id id_potions[POTIONS] = { 5932689Sbostic {100, "blue \0 ", "of increase strength ", 0}, 6032689Sbostic {250, "red \0 ", "of restore strength ", 0}, 6132689Sbostic {100, "green \0 ", "of healing ", 0}, 6232689Sbostic {200, "grey \0 ", "of extra healing ", 0}, 6332689Sbostic {10, "brown \0 ", "of poison ", 0}, 6432689Sbostic {300, "clear \0 ", "of raise level ", 0}, 6532689Sbostic {10, "pink \0 ", "of blindness ", 0}, 6632689Sbostic {25, "white \0 ", "of hallucination ", 0}, 6732689Sbostic {100, "purple \0 ", "of detect monster ", 0}, 6832689Sbostic {100, "black \0 ", "of detect things ", 0}, 6932689Sbostic {10, "yellow \0 ", "of confusion ", 0}, 7032689Sbostic {80, "plaid \0 ", "of levitation ", 0}, 7132689Sbostic {150, "burgundy \0 ", "of haste self ", 0}, 7232689Sbostic {145, "beige \0 ", "of see invisible ", 0} 7332689Sbostic }; 7432689Sbostic 7532689Sbostic struct id id_scrolls[SCROLS] = { 7632689Sbostic {505, " ", "of protect armor ", 0}, 7732689Sbostic {200, " ", "of hold monster ", 0}, 7832689Sbostic {235, " ", "of enchant weapon ", 0}, 7932689Sbostic {235, " ", "of enchant armor ", 0}, 8032689Sbostic {175, " ", "of identify ", 0}, 8132689Sbostic {190, " ", "of teleportation ", 0}, 8232689Sbostic {25, " ", "of sleep ", 0}, 8332689Sbostic {610, " ", "of scare monster ", 0}, 8432689Sbostic {210, " ", "of remove curse ", 0}, 8532689Sbostic {80, " ", "of create monster ",0}, 8632689Sbostic {25, " ", "of aggravate monster ",0}, 8732689Sbostic {180, " ", "of magic mapping ", 0}, 8832689Sbostic {90, " ", "of confuse monster ", 0} 8932689Sbostic }; 9032689Sbostic 9132689Sbostic struct id id_weapons[WEAPONS] = { 9232689Sbostic {150, "short bow ", "", 0}, 9332689Sbostic {8, "darts ", "", 0}, 9432689Sbostic {15, "arrows ", "", 0}, 9532689Sbostic {27, "daggers ", "", 0}, 9632689Sbostic {35, "shurikens ", "", 0}, 9732689Sbostic {360, "mace ", "", 0}, 9832689Sbostic {470, "long sword ", "", 0}, 9932689Sbostic {580, "two-handed sword ", "", 0} 10032689Sbostic }; 10132689Sbostic 10232689Sbostic struct id id_armors[ARMORS] = { 10332689Sbostic {300, "leather armor ", "", (UNIDENTIFIED)}, 10432689Sbostic {300, "ring mail ", "", (UNIDENTIFIED)}, 10532689Sbostic {400, "scale mail ", "", (UNIDENTIFIED)}, 10632689Sbostic {500, "chain mail ", "", (UNIDENTIFIED)}, 10732689Sbostic {600, "banded mail ", "", (UNIDENTIFIED)}, 10832689Sbostic {600, "splint mail ", "", (UNIDENTIFIED)}, 10932689Sbostic {700, "plate mail ", "", (UNIDENTIFIED)} 11032689Sbostic }; 11132689Sbostic 11232689Sbostic struct id id_wands[WANDS] = { 11332689Sbostic {25, " ", "of teleport away ",0}, 11432689Sbostic {50, " ", "of slow monster ", 0}, 11532689Sbostic {8, " ", "of invisibility ",0}, 11632689Sbostic {55, " ", "of polymorph ",0}, 11732689Sbostic {2, " ", "of haste monster ",0}, 11832689Sbostic {20, " ", "of magic missile ",0}, 11932689Sbostic {20, " ", "of cancellation ",0}, 12032689Sbostic {0, " ", "of do nothing ",0}, 12132689Sbostic {35, " ", "of drain life ",0}, 12232689Sbostic {20, " ", "of cold ",0}, 12332689Sbostic {20, " ", "of fire ",0} 12432689Sbostic }; 12532689Sbostic 12632689Sbostic struct id id_rings[RINGS] = { 12732689Sbostic {250, " ", "of stealth ",0}, 12832689Sbostic {100, " ", "of teleportation ", 0}, 12932689Sbostic {255, " ", "of regeneration ",0}, 13032689Sbostic {295, " ", "of slow digestion ",0}, 13132689Sbostic {200, " ", "of add strength ",0}, 13232689Sbostic {250, " ", "of sustain strength ",0}, 13332689Sbostic {250, " ", "of dexterity ",0}, 13432689Sbostic {25, " ", "of adornment ",0}, 13532689Sbostic {300, " ", "of see invisible ",0}, 13632689Sbostic {290, " ", "of maintain armor ",0}, 13732689Sbostic {270, " ", "of searching ",0}, 13832689Sbostic }; 13932689Sbostic 14032689Sbostic extern short cur_level, max_level; 14132689Sbostic extern short party_room; 14232689Sbostic extern char *error_file; 14332689Sbostic extern boolean is_wood[]; 14432689Sbostic 14532689Sbostic put_objects() 14632689Sbostic { 14732689Sbostic short i, n; 14832689Sbostic object *obj; 14932689Sbostic 15032689Sbostic if (cur_level < max_level) { 15132689Sbostic return; 15232689Sbostic } 15332689Sbostic n = coin_toss() ? get_rand(2, 4) : get_rand(3, 5); 15432689Sbostic while (rand_percent(33)) { 15532689Sbostic n++; 15632689Sbostic } 15732689Sbostic if (party_room != NO_ROOM) { 15832689Sbostic make_party(); 15932689Sbostic } 16032689Sbostic for (i = 0; i < n; i++) { 16132689Sbostic obj = gr_object(); 16232689Sbostic rand_place(obj); 16332689Sbostic } 16432689Sbostic put_gold(); 16532689Sbostic } 16632689Sbostic 16732689Sbostic put_gold() 16832689Sbostic { 16932689Sbostic short i, j; 17032689Sbostic short row,col; 17132689Sbostic boolean is_maze, is_room; 17232689Sbostic 17332689Sbostic for (i = 0; i < MAXROOMS; i++) { 17432689Sbostic is_maze = (rooms[i].is_room & R_MAZE) ? 1 : 0; 17532689Sbostic is_room = (rooms[i].is_room & R_ROOM) ? 1 : 0; 17632689Sbostic 17732689Sbostic if (!(is_room || is_maze)) { 17832689Sbostic continue; 17932689Sbostic } 18032689Sbostic if (is_maze || rand_percent(GOLD_PERCENT)) { 18132689Sbostic for (j = 0; j < 50; j++) { 18232689Sbostic row = get_rand(rooms[i].top_row+1, 18332689Sbostic rooms[i].bottom_row-1); 18432689Sbostic col = get_rand(rooms[i].left_col+1, 18532689Sbostic rooms[i].right_col-1); 18632689Sbostic if ((dungeon[row][col] == FLOOR) || 18732689Sbostic (dungeon[row][col] == TUNNEL)) { 18832689Sbostic plant_gold(row, col, is_maze); 18932689Sbostic break; 19032689Sbostic } 19132689Sbostic } 19232689Sbostic } 19332689Sbostic } 19432689Sbostic } 19532689Sbostic 19632689Sbostic plant_gold(row, col, is_maze) 19732689Sbostic short row, col; 19832689Sbostic boolean is_maze; 19932689Sbostic { 20032689Sbostic object *obj; 20132689Sbostic 20232689Sbostic obj = alloc_object(); 20332689Sbostic obj->row = row; obj->col = col; 20432689Sbostic obj->what_is = GOLD; 20532689Sbostic obj->quantity = get_rand((2 * cur_level), (16 * cur_level)); 20632689Sbostic if (is_maze) { 20732689Sbostic obj->quantity += obj->quantity / 2; 20832689Sbostic } 20932689Sbostic dungeon[row][col] |= OBJECT; 21032689Sbostic (void) add_to_pack(obj, &level_objects, 0); 21132689Sbostic } 21232689Sbostic 21332689Sbostic place_at(obj, row, col) 21432689Sbostic object *obj; 21532689Sbostic { 21632689Sbostic obj->row = row; 21732689Sbostic obj->col = col; 21832689Sbostic dungeon[row][col] |= OBJECT; 21932689Sbostic (void) add_to_pack(obj, &level_objects, 0); 22032689Sbostic } 22132689Sbostic 22232689Sbostic object * 22332689Sbostic object_at(pack, row, col) 22432689Sbostic register object *pack; 22532689Sbostic short row, col; 22632689Sbostic { 22732689Sbostic object *obj = (object *) 0; 22832689Sbostic 22932689Sbostic if (dungeon[row][col] & (MONSTER | OBJECT)) { 23032689Sbostic obj = pack->next_object; 23132689Sbostic 23232689Sbostic while (obj && ((obj->row != row) || (obj->col != col))) { 23332689Sbostic obj = obj->next_object; 23432689Sbostic } 23532689Sbostic if (!obj) { 23632689Sbostic message("object_at(): inconsistent", 1); 23732689Sbostic } 23832689Sbostic } 23932689Sbostic return(obj); 24032689Sbostic } 24132689Sbostic 24232689Sbostic object * 24332689Sbostic get_letter_object(ch) 24432689Sbostic { 24532689Sbostic object *obj; 24632689Sbostic 24732689Sbostic obj = rogue.pack.next_object; 24832689Sbostic 24932689Sbostic while (obj && (obj->ichar != ch)) { 25032689Sbostic obj = obj->next_object; 25132689Sbostic } 25232689Sbostic return(obj); 25332689Sbostic } 25432689Sbostic 25532689Sbostic free_stuff(objlist) 25632689Sbostic object *objlist; 25732689Sbostic { 25832689Sbostic object *obj; 25932689Sbostic 26032689Sbostic while (objlist->next_object) { 26132689Sbostic obj = objlist->next_object; 26232689Sbostic objlist->next_object = 26332689Sbostic objlist->next_object->next_object; 26432689Sbostic free_object(obj); 26532689Sbostic } 26632689Sbostic } 26732689Sbostic 26832689Sbostic char * 26932689Sbostic name_of(obj) 27032689Sbostic object *obj; 27132689Sbostic { 27232689Sbostic char *retstring; 27332689Sbostic 27432689Sbostic switch(obj->what_is) { 27532689Sbostic case SCROL: 27632689Sbostic retstring = obj->quantity > 1 ? "scrolls " : "scroll "; 27732689Sbostic break; 27832689Sbostic case POTION: 27932689Sbostic retstring = obj->quantity > 1 ? "potions " : "potion "; 28032689Sbostic break; 28132689Sbostic case FOOD: 28232689Sbostic if (obj->which_kind == RATION) { 28332689Sbostic retstring = "food "; 28432689Sbostic } else { 28532689Sbostic retstring = fruit; 28632689Sbostic } 28732689Sbostic break; 28832689Sbostic case WAND: 28932689Sbostic retstring = is_wood[obj->which_kind] ? "staff " : "wand "; 29032689Sbostic break; 29132689Sbostic case WEAPON: 29232689Sbostic switch(obj->which_kind) { 29332689Sbostic case DART: 29432689Sbostic retstring=obj->quantity > 1 ? "darts " : "dart "; 29532689Sbostic break; 29632689Sbostic case ARROW: 29732689Sbostic retstring=obj->quantity > 1 ? "arrows " : "arrow "; 29832689Sbostic break; 29932689Sbostic case DAGGER: 30032689Sbostic retstring=obj->quantity > 1 ? "daggers " : "dagger "; 30132689Sbostic break; 30232689Sbostic case SHURIKEN: 30332689Sbostic retstring=obj->quantity > 1?"shurikens ":"shuriken "; 30432689Sbostic break; 30532689Sbostic default: 30632689Sbostic retstring = id_weapons[obj->which_kind].title; 30732689Sbostic } 30832689Sbostic break; 30932689Sbostic case ARMOR: 31032689Sbostic retstring = "armor "; 31132689Sbostic break; 31232689Sbostic case RING: 31332689Sbostic retstring = "ring "; 31432689Sbostic break; 31532689Sbostic case AMULET: 31632689Sbostic retstring = "amulet "; 31732689Sbostic break; 31832689Sbostic default: 31932689Sbostic retstring = "unknown "; 32032689Sbostic break; 32132689Sbostic } 32232689Sbostic return(retstring); 32332689Sbostic } 32432689Sbostic 32532689Sbostic object * 32632689Sbostic gr_object() 32732689Sbostic { 32832689Sbostic object *obj; 32932689Sbostic 33032689Sbostic obj = alloc_object(); 33132689Sbostic 33232689Sbostic if (foods < (cur_level / 3)) { 33332689Sbostic obj->what_is = FOOD; 33432689Sbostic foods++; 33532689Sbostic } else { 33632689Sbostic obj->what_is = gr_what_is(); 33732689Sbostic } 33832689Sbostic switch(obj->what_is) { 33932689Sbostic case SCROL: 34032689Sbostic gr_scroll(obj); 34132689Sbostic break; 34232689Sbostic case POTION: 34332689Sbostic gr_potion(obj); 34432689Sbostic break; 34532689Sbostic case WEAPON: 34632689Sbostic gr_weapon(obj, 1); 34732689Sbostic break; 34832689Sbostic case ARMOR: 34932689Sbostic gr_armor(obj); 35032689Sbostic break; 35132689Sbostic case WAND: 35232689Sbostic gr_wand(obj); 35332689Sbostic break; 35432689Sbostic case FOOD: 35532689Sbostic get_food(obj, 0); 35632689Sbostic break; 35732689Sbostic case RING: 35832689Sbostic gr_ring(obj, 1); 35932689Sbostic break; 36032689Sbostic } 36132689Sbostic return(obj); 36232689Sbostic } 36332689Sbostic 36432689Sbostic unsigned short 36532689Sbostic gr_what_is() 36632689Sbostic { 36732689Sbostic short percent; 36832689Sbostic unsigned short what_is; 36932689Sbostic 37032689Sbostic percent = get_rand(1, 91); 37132689Sbostic 37232689Sbostic if (percent <= 30) { 37332689Sbostic what_is = SCROL; 37432689Sbostic } else if (percent <= 60) { 37532689Sbostic what_is = POTION; 37632689Sbostic } else if (percent <= 64) { 37732689Sbostic what_is = WAND; 37832689Sbostic } else if (percent <= 74) { 37932689Sbostic what_is = WEAPON; 38032689Sbostic } else if (percent <= 83) { 38132689Sbostic what_is = ARMOR; 38232689Sbostic } else if (percent <= 88) { 38332689Sbostic what_is = FOOD; 38432689Sbostic } else { 38532689Sbostic what_is = RING; 38632689Sbostic } 38732689Sbostic return(what_is); 38832689Sbostic } 38932689Sbostic 39032689Sbostic gr_scroll(obj) 39132689Sbostic object *obj; 39232689Sbostic { 39332689Sbostic short percent; 39432689Sbostic 39532689Sbostic percent = get_rand(0, 91); 39632689Sbostic 39732689Sbostic obj->what_is = SCROL; 39832689Sbostic 39932689Sbostic if (percent <= 5) { 40032689Sbostic obj->which_kind = PROTECT_ARMOR; 40132689Sbostic } else if (percent <= 10) { 40232689Sbostic obj->which_kind = HOLD_MONSTER; 40332689Sbostic } else if (percent <= 20) { 40432689Sbostic obj->which_kind = CREATE_MONSTER; 40532689Sbostic } else if (percent <= 35) { 40632689Sbostic obj->which_kind = IDENTIFY; 40732689Sbostic } else if (percent <= 43) { 40832689Sbostic obj->which_kind = TELEPORT; 40932689Sbostic } else if (percent <= 50) { 41032689Sbostic obj->which_kind = SLEEP; 41132689Sbostic } else if (percent <= 55) { 41232689Sbostic obj->which_kind = SCARE_MONSTER; 41332689Sbostic } else if (percent <= 64) { 41432689Sbostic obj->which_kind = REMOVE_CURSE; 41532689Sbostic } else if (percent <= 69) { 41632689Sbostic obj->which_kind = ENCH_ARMOR; 41732689Sbostic } else if (percent <= 74) { 41832689Sbostic obj->which_kind = ENCH_WEAPON; 41932689Sbostic } else if (percent <= 80) { 42032689Sbostic obj->which_kind = AGGRAVATE_MONSTER; 42132689Sbostic } else if (percent <= 86) { 42232689Sbostic obj->which_kind = CON_MON; 42332689Sbostic } else { 42432689Sbostic obj->which_kind = MAGIC_MAPPING; 42532689Sbostic } 42632689Sbostic } 42732689Sbostic 42832689Sbostic gr_potion(obj) 42932689Sbostic object *obj; 43032689Sbostic { 43132689Sbostic short percent; 43232689Sbostic 43332689Sbostic percent = get_rand(1, 118); 43432689Sbostic 43532689Sbostic obj->what_is = POTION; 43632689Sbostic 43732689Sbostic if (percent <= 5) { 43832689Sbostic obj->which_kind = RAISE_LEVEL; 43932689Sbostic } else if (percent <= 15) { 44032689Sbostic obj->which_kind = DETECT_OBJECTS; 44132689Sbostic } else if (percent <= 25) { 44232689Sbostic obj->which_kind = DETECT_MONSTER; 44332689Sbostic } else if (percent <= 35) { 44432689Sbostic obj->which_kind = INCREASE_STRENGTH; 44532689Sbostic } else if (percent <= 45) { 44632689Sbostic obj->which_kind = RESTORE_STRENGTH; 44732689Sbostic } else if (percent <= 55) { 44832689Sbostic obj->which_kind = HEALING; 44932689Sbostic } else if (percent <= 65) { 45032689Sbostic obj->which_kind = EXTRA_HEALING; 45132689Sbostic } else if (percent <= 75) { 45232689Sbostic obj->which_kind = BLINDNESS; 45332689Sbostic } else if (percent <= 85) { 45432689Sbostic obj->which_kind = HALLUCINATION; 45532689Sbostic } else if (percent <= 95) { 45632689Sbostic obj->which_kind = CONFUSION; 45732689Sbostic } else if (percent <= 105) { 45832689Sbostic obj->which_kind = POISON; 45932689Sbostic } else if (percent <= 110) { 46032689Sbostic obj->which_kind = LEVITATION; 46132689Sbostic } else if (percent <= 114) { 46232689Sbostic obj->which_kind = HASTE_SELF; 46332689Sbostic } else { 46432689Sbostic obj->which_kind = SEE_INVISIBLE; 46532689Sbostic } 46632689Sbostic } 46732689Sbostic 46832689Sbostic gr_weapon(obj, assign_wk) 46932689Sbostic object *obj; 47032689Sbostic int assign_wk; 47132689Sbostic { 47232689Sbostic short percent; 47332689Sbostic short i; 47432689Sbostic short blessing, increment; 47532689Sbostic 47632689Sbostic obj->what_is = WEAPON; 47732689Sbostic if (assign_wk) { 47832689Sbostic obj->which_kind = get_rand(0, (WEAPONS - 1)); 47932689Sbostic } 48032689Sbostic if ((obj->which_kind == ARROW) || (obj->which_kind == DAGGER) || 48132689Sbostic (obj->which_kind == SHURIKEN) | (obj->which_kind == DART)) { 48232689Sbostic obj->quantity = get_rand(3, 15); 48332689Sbostic obj->quiver = get_rand(0, 126); 48432689Sbostic } else { 48532689Sbostic obj->quantity = 1; 48632689Sbostic } 48732689Sbostic obj->hit_enchant = obj->d_enchant = 0; 48832689Sbostic 48932689Sbostic percent = get_rand(1, 96); 49032689Sbostic blessing = get_rand(1, 3); 49132689Sbostic 49232689Sbostic if (percent <= 16) { 49332689Sbostic increment = 1; 49432689Sbostic } else if (percent <= 32) { 49532689Sbostic increment = -1; 49632689Sbostic obj->is_cursed = 1; 49732689Sbostic } 49832689Sbostic if (percent <= 32) { 49932689Sbostic for (i = 0; i < blessing; i++) { 50032689Sbostic if (coin_toss()) { 50132689Sbostic obj->hit_enchant += increment; 50232689Sbostic } else { 50332689Sbostic obj->d_enchant += increment; 50432689Sbostic } 50532689Sbostic } 50632689Sbostic } 50732689Sbostic switch(obj->which_kind) { 50832689Sbostic case BOW: 50932689Sbostic case DART: 51032689Sbostic obj->damage = "1d1"; 51132689Sbostic break; 51232689Sbostic case ARROW: 51332689Sbostic obj->damage = "1d2"; 51432689Sbostic break; 51532689Sbostic case DAGGER: 51632689Sbostic obj->damage = "1d3"; 51732689Sbostic break; 51832689Sbostic case SHURIKEN: 51932689Sbostic obj->damage = "1d4"; 52032689Sbostic break; 52132689Sbostic case MACE: 52232689Sbostic obj->damage = "2d3"; 52332689Sbostic break; 52432689Sbostic case LONG_SWORD: 52532689Sbostic obj->damage = "3d4"; 52632689Sbostic break; 52732689Sbostic case TWO_HANDED_SWORD: 52832689Sbostic obj->damage = "4d5"; 52932689Sbostic break; 53032689Sbostic } 53132689Sbostic } 53232689Sbostic 53332689Sbostic gr_armor(obj) 53432689Sbostic object *obj; 53532689Sbostic { 53632689Sbostic short percent; 53732689Sbostic short blessing; 53832689Sbostic 53932689Sbostic obj->what_is = ARMOR; 54032689Sbostic obj->which_kind = get_rand(0, (ARMORS - 1)); 54132689Sbostic obj->class = obj->which_kind + 2; 54232689Sbostic if ((obj->which_kind == PLATE) || (obj->which_kind == SPLINT)) { 54332689Sbostic obj->class--; 54432689Sbostic } 54532689Sbostic obj->is_protected = 0; 54632689Sbostic obj->d_enchant = 0; 54732689Sbostic 54832689Sbostic percent = get_rand(1, 100); 54932689Sbostic blessing = get_rand(1, 3); 55032689Sbostic 55132689Sbostic if (percent <= 16) { 55232689Sbostic obj->is_cursed = 1; 55332689Sbostic obj->d_enchant -= blessing; 55432689Sbostic } else if (percent <= 33) { 55532689Sbostic obj->d_enchant += blessing; 55632689Sbostic } 55732689Sbostic } 55832689Sbostic 55932689Sbostic gr_wand(obj) 56032689Sbostic object *obj; 56132689Sbostic { 56232689Sbostic obj->what_is = WAND; 56332689Sbostic obj->which_kind = get_rand(0, (WANDS - 1)); 56432689Sbostic obj->class = get_rand(3, 7); 56532689Sbostic } 56632689Sbostic 56732689Sbostic get_food(obj, force_ration) 56832689Sbostic object *obj; 56932689Sbostic boolean force_ration; 57032689Sbostic { 57132689Sbostic obj->what_is = FOOD; 57232689Sbostic 57332689Sbostic if (force_ration || rand_percent(80)) { 57432689Sbostic obj->which_kind = RATION; 57532689Sbostic } else { 57632689Sbostic obj->which_kind = FRUIT; 57732689Sbostic } 57832689Sbostic } 57932689Sbostic 58032689Sbostic put_stairs() 58132689Sbostic { 58232689Sbostic short row, col; 58332689Sbostic 58432689Sbostic gr_row_col(&row, &col, (FLOOR | TUNNEL)); 58532689Sbostic dungeon[row][col] |= STAIRS; 58632689Sbostic } 58732689Sbostic 58832689Sbostic get_armor_class(obj) 58932689Sbostic object *obj; 59032689Sbostic { 59132689Sbostic if (obj) { 59232689Sbostic return(obj->class + obj->d_enchant); 59332689Sbostic } 59432689Sbostic return(0); 59532689Sbostic } 59632689Sbostic 59732689Sbostic object * 59832689Sbostic alloc_object() 59932689Sbostic { 60032689Sbostic object *obj; 60132689Sbostic 60232689Sbostic if (free_list) { 60332689Sbostic obj = free_list; 60432689Sbostic free_list = free_list->next_object; 60532689Sbostic } else if (!(obj = (object *) md_malloc(sizeof(object)))) { 60632689Sbostic message("cannot allocate object, saving game", 0); 60732689Sbostic save_into_file(error_file); 60832689Sbostic } 60932689Sbostic obj->quantity = 1; 61032689Sbostic obj->ichar = 'L'; 61132689Sbostic obj->picked_up = obj->is_cursed = 0; 61232689Sbostic obj->in_use_flags = NOT_USED; 61332689Sbostic obj->identified = UNIDENTIFIED; 61432689Sbostic obj->damage = "1d1"; 61532689Sbostic return(obj); 61632689Sbostic } 61732689Sbostic 61832689Sbostic free_object(obj) 61932689Sbostic object *obj; 62032689Sbostic { 62132689Sbostic obj->next_object = free_list; 62232689Sbostic free_list = obj; 62332689Sbostic } 62432689Sbostic 62532689Sbostic make_party() 62632689Sbostic { 62732689Sbostic short n; 62832689Sbostic 62932689Sbostic party_room = gr_room(); 63032689Sbostic 63132689Sbostic n = rand_percent(99) ? party_objects(party_room) : 11; 63232689Sbostic if (rand_percent(99)) { 63332689Sbostic party_monsters(party_room, n); 63432689Sbostic } 63532689Sbostic } 63632689Sbostic 63732689Sbostic show_objects() 63832689Sbostic { 63932689Sbostic object *obj; 64032689Sbostic short mc, rc, row, col; 64132689Sbostic object *monster; 64232689Sbostic 64332689Sbostic obj = level_objects.next_object; 64432689Sbostic 64532689Sbostic while (obj) { 64632689Sbostic row = obj->row; 64732689Sbostic col = obj->col; 64832689Sbostic 64932689Sbostic rc = get_mask_char(obj->what_is); 65032689Sbostic 65132689Sbostic if (dungeon[row][col] & MONSTER) { 65232689Sbostic if (monster = object_at(&level_monsters, row, col)) { 65332689Sbostic monster->trail_char = rc; 65432689Sbostic } 65532689Sbostic } 65632689Sbostic mc = mvinch(row, col); 65732689Sbostic if (((mc < 'A') || (mc > 'Z')) && 65832689Sbostic ((row != rogue.row) || (col != rogue.col))) { 65932689Sbostic mvaddch(row, col, rc); 66032689Sbostic } 66132689Sbostic obj = obj->next_object; 66232689Sbostic } 66332689Sbostic 66432689Sbostic monster = level_monsters.next_object; 66532689Sbostic 66632689Sbostic while (monster) { 66732689Sbostic if (monster->m_flags & IMITATES) { 66832689Sbostic mvaddch(monster->row, monster->col, (int) monster->disguise); 66932689Sbostic } 67032689Sbostic monster = monster->next_monster; 67132689Sbostic } 67232689Sbostic } 67332689Sbostic 67432689Sbostic put_amulet() 67532689Sbostic { 67632689Sbostic object *obj; 67732689Sbostic 67832689Sbostic obj = alloc_object(); 67932689Sbostic obj->what_is = AMULET; 68032689Sbostic rand_place(obj); 68132689Sbostic } 68232689Sbostic 68332689Sbostic rand_place(obj) 68432689Sbostic object *obj; 68532689Sbostic { 68632689Sbostic short row, col; 68732689Sbostic 68832689Sbostic gr_row_col(&row, &col, (FLOOR | TUNNEL)); 68932689Sbostic place_at(obj, row, col); 69032689Sbostic } 69132689Sbostic 69232689Sbostic c_object_for_wizard() 69332689Sbostic { 69432689Sbostic short ch, max, wk; 69532689Sbostic object *obj; 69632689Sbostic char buf[80]; 69732689Sbostic 69832689Sbostic if (pack_count((object *) 0) >= MAX_PACK_COUNT) { 69932689Sbostic message("pack full", 0); 70032689Sbostic return; 70132689Sbostic } 70232689Sbostic message("type of object?", 0); 70332689Sbostic 70432689Sbostic while (r_index("!?:)]=/,\033", (ch = rgetchar()), 0) == -1) { 70532689Sbostic sound_bell(); 70632689Sbostic } 70732689Sbostic check_message(); 70832689Sbostic 70932689Sbostic if (ch == '\033') { 71032689Sbostic return; 71132689Sbostic } 71232689Sbostic obj = alloc_object(); 71332689Sbostic 71432689Sbostic switch(ch) { 71532689Sbostic case '!': 71632689Sbostic obj->what_is = POTION; 71732689Sbostic max = POTIONS - 1; 71832689Sbostic break; 71932689Sbostic case '?': 72032689Sbostic obj->what_is = SCROL; 72132689Sbostic max = SCROLS - 1; 72232689Sbostic break; 72332689Sbostic case ',': 72432689Sbostic obj->what_is = AMULET; 72532689Sbostic break; 72632689Sbostic case ':': 72732689Sbostic get_food(obj, 0); 72832689Sbostic break; 72932689Sbostic case ')': 73032689Sbostic gr_weapon(obj, 0); 73132689Sbostic max = WEAPONS - 1; 73232689Sbostic break; 73332689Sbostic case ']': 73432689Sbostic gr_armor(obj); 73532689Sbostic max = ARMORS - 1; 73632689Sbostic break; 73732689Sbostic case '/': 73832689Sbostic gr_wand(obj); 73932689Sbostic max = WANDS - 1; 74032689Sbostic break; 74132689Sbostic case '=': 74232689Sbostic max = RINGS - 1; 74332689Sbostic obj->what_is = RING; 74432689Sbostic break; 74532689Sbostic } 74632689Sbostic if ((ch != ',') && (ch != ':')) { 74732689Sbostic GIL: 74832689Sbostic if (get_input_line("which kind?", "", buf, "", 0, 1)) { 74932689Sbostic wk = get_number(buf); 75032689Sbostic if ((wk >= 0) && (wk <= max)) { 75132689Sbostic obj->which_kind = (unsigned short) wk; 75232689Sbostic if (obj->what_is == RING) { 75332689Sbostic gr_ring(obj, 0); 75432689Sbostic } 75532689Sbostic } else { 75632689Sbostic sound_bell(); 75732689Sbostic goto GIL; 75832689Sbostic } 75932689Sbostic } else { 76032689Sbostic free_object(obj); 76132689Sbostic return; 76232689Sbostic } 76332689Sbostic } 76432689Sbostic get_desc(obj, buf); 76532689Sbostic message(buf, 0); 76632689Sbostic (void) add_to_pack(obj, &rogue.pack, 1); 76732689Sbostic } 768