games-request@tekred.TEK.COM (11/05/87)
Submitted by: "James E. Wilson" <wilson@ji.berkeley.edu> Comp.sources.games: Volume 2, Issue 74 Archive-name: umoria/Part09 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 9 (of 16)." # Contents: help.c misc2.c # Wrapped by billr@tekred on Wed Nov 4 09:59:55 1987 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f help.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"help.c\" else echo shar: Extracting \"help.c\" \(11885 characters\) sed "s/^X//" >help.c <<'END_OF_help.c' X#include "constants.h" X#include "types.h" X#include "externs.h" X X Xident_char() X{ X char command; X X if (get_com("Enter character to be identified :", &command)) X switch(command) X { X case ' ': prt(" - An open pit.", 0, 0); break; X case '!': prt("! - A potion.", 0, 0); break; X case '"': prt("\" - An amulet, periapt, or necklace.", 0, 0); break; X case '#': prt("# - A stone wall.", 0, 0); break; X case '$': prt("$ - Treasure.", 0, 0); break; X /* case '%': prt("% - Not used.", 0, 0); break; */ X case '&': prt("& - Treasure chest.", 0, 0); break; X case '\'': prt("' - An open door.", 0, 0); break; X case '(': prt("( - Soft armor.", 0, 0); break; X case ')': prt(") - A shield.", 0, 0); break; X case '*': prt("* - Gems.", 0, 0); break; X case '+': prt("+ - A closed door.", 0, 0); break; X case ',': prt(", - Food or mushroom patch.", 0, 0); break; X case '-': prt("- - A wand", 0, 0); break; X case '.': prt(". - Floor.", 0, 0); break; X case '/': prt("/ - A pole weapon.", 0, 0); break; X /* case '0': prt("0 - Not used.", 0, 0); break; */ X case '1': prt("1 - Entrance to General Store.", 0, 0); break; X case '2': prt("2 - Entrance to Armory.", 0, 0); break; X case '3': prt("3 - Entrance to Weaponsmith.", 0, 0); break; X case '4': prt("4 - Entrance to Temple.", 0, 0); break; X case '5': prt("5 - Entrance to Alchemy shop.", 0, 0); break; X case '6': prt("6 - Entrance to Magic-Users store.", 0, 0); break; X /* case '7': prt("7 - Not used.", 0, 0); break; */ X /* case '8': prt("8 - Not used.", 0, 0); break; */ X /* case '9': prt("9 - Not used.", 0, 0); break;*/ X case ':': prt(": - Rubble.", 0, 0); break; X case ';': prt("; - A loose rock.", 0, 0); break; X case '<': prt("< - An up staircase.", 0, 0); break; X case '=': prt("= - A ring.", 0, 0); break; X case '>': prt("> - A down staircase.", 0, 0); break; X case '?': prt("? - A scroll.", 0, 0); break; X case '@': prt(py.misc.name, 0, 0); break; X case 'A': prt("A - Giant Ant Lion.", 0, 0); break; X case 'B': prt("B - The Balrog.", 0, 0); break; X case 'C': prt("C - Gelatinous Cube.", 0, 0); break; X case 'D': prt("D - An Ancient Dragon (Beware).", 0, 0); break; X case 'E': prt("E - Elemental.", 0, 0); break; X case 'F': prt("F - Giant Fly.", 0, 0); break; X case 'G': prt("G - Ghost.", 0, 0); break; X case 'H': prt("H - Hobgoblin.", 0, 0); break; X case 'I': prt("I - Invisible Stalker.", 0, 0); break; X case 'J': prt("J - Jelly.", 0, 0); break; X case 'K': prt("K - Killer Beetle.", 0, 0); break; X case 'L': prt("L - Lich.", 0, 0); break; X case 'M': prt("M - Mummy.", 0, 0); break; X /* case 'N': prt("N - Not used.", 0, 0); break; */ X case 'O': prt("O - Ooze.", 0, 0); break; X case 'P': prt("P - Giant humanoid.", 0, 0); break; X case 'Q': prt("Q - Quylthulg (Pulsing Flesh Mound).", 0, 0); break; X case 'R': prt("R - Reptile.", 0, 0); break; X case 'S': prt("S - Giant Scorpion.", 0, 0); break; X case 'T': prt("T - Troll.", 0, 0); break; X case 'U': prt("U - Umber Hulk.", 0, 0); break; X case 'V': prt("V - Vampire.", 0, 0); break; X case 'W': prt("W - Wight or Wraith.", 0, 0); break; X case 'X': prt("X - Xorn.", 0, 0); break; X case 'Y': prt("Y - Yeti.", 0, 0); break; X /* case 'Z': prt("Z - Not used.", 0, 0); break; */ X case '[': prt("[ - Hard armor.", 0, 0); break; X case '\\': prt("\\ - A hafted weapon.", 0, 0); break; X case ']': prt("] - Misc. armor.", 0, 0); break; X case '^': prt("^ - A trap.", 0, 0); break; X case '_': prt("_ - A staff.", 0, 0); break; X /* case '`': prt("` - Not used.", 0, 0); break; */ X case 'a': prt("a - Giant Ant.", 0, 0); break; X case 'b': prt("b - Giant Bat.", 0, 0); break; X case 'c': prt("c - Giant Centipede.", 0, 0); break; X case 'd': prt("d - Dragon.", 0, 0); break; X case 'e': prt("e - Floating Eye.", 0, 0); break; X case 'f': prt("f - Giant Frog", 0, 0); break; X case 'g': prt("g - Golem.", 0, 0); break; X case 'h': prt("h - Harpy.", 0, 0); break; X case 'i': prt("i - Icky Thing.", 0, 0); break; X case 'j': prt("j - Jackal.", 0, 0); break; X case 'k': prt("k - Kobold.", 0, 0); break; X case 'l': prt("l - Giant Lice.", 0, 0); break; X case 'm': prt("m - Mold.", 0, 0); break; X case 'n': prt("n - Naga.", 0, 0); break; X case 'o': prt("o - Orc or Ogre.", 0, 0); break; X case 'p': prt("p - Person (Humanoid).", 0, 0); break; X case 'q': prt("q - Quasit.", 0, 0); break; X case 'r': prt("r - Rodent.", 0, 0); break; X case 's': prt("s - Skeleton.", 0, 0); break; X case 't': prt("t - Gaint tick.", 0, 0); break; X /* case 'u': prt("u - Not used.", 0, 0); break; */ X /* case 'v': prt("v - Not used.", 0, 0); break; */ X case 'w': prt("w - Worm(s).", 0, 0); break; X /* case 'x': prt("x - Not used.", 0, 0); break; */ X case 'y': prt("y - Yeek.", 0, 0); break; X case 'z': prt("z - Zombie.", 0, 0); break; X case '{': prt("{ - Arrow, bolt, or bullet.", 0, 0); break; X case '|': prt("| - A sword or dagger.", 0, 0); break; X case '}': prt("} - Bow, crossbow, or sling.", 0, 0); break; X case '~': prt("~ - Miscellaneous item.", 0, 0); break; X default: prt("Not Used.", 0, 0); break; X } X} X X/* Help for available original commands */ Xoriginal_help() X{ X clear_screen(0, 0); X prt("B <Dir> Bash (object/creature)| q Quaff a potion.", 0, 0); X prt("C Display character. | r Read a scroll.", 1, 0); X prt("D <Dir> Disarm a trap/chest. | s Search for hidden doors.", X 2, 0); X prt("E Eat some food. | t Take off an item.", 3, 0); X prt("F Fill lamp with oil. | u Use a staff.", 4, 0); X prt("L Current location. | v Version and credits.", 5, 0); X prt("P Print map. | w Wear/Wield an item.", 6, 0); X prt("R Rest for a period. | x Exchange weapon.", 7, 0); X prt("S Search Mode. | / Identify a character.", 8,0); X prt("T <Dir> Tunnel. | ? Display this panel.", 9, 0); X prt("a Aim and fire a wand. |", 10, 0); X prt("b Browse a book. | ^M Repeat the last message.", X 11, 0); X prt("c <Dir> Close a door. | ^R Redraw the screen.", 12, 0); X prt("d Drop an item. | ^K Quit the game.", 13, 0); X prt("e Equipment list. | ^X Save character and quit.", X 14, 0); X prt("f Fire/Throw an item. | $ Shell out of game.", 15, 0); X/* prt("h Help on key commands. |", 16, 0); */ X prt("i Inventory list. | < Go up an up-staircase.", 17, 0); X prt("j <Dir> Jam a door with spike.| > Go down a down-staircase.", 18, 0); X prt("l <Dir> Look given direction. | . <Dir> Move in direction.", 19, 0); X prt("m Cast a magic spell. | Movement: 7 8 9", 20, 0); X prt("o <Dir> Open a door/chest. | 4 6 5 == Rest", X 21, 0); X prt("p Read a prayer. | 1 2 3", 22, 0); X pause_line(23); X draw_cave(); X} X X X/* Help for available rogue_like commands */ Xrogue_like_help() X{ X clear_screen(0, 0); X prt("f <Dir> Bash (object/creature)| q Quaff a potion.", 0, 0); X prt("C Display character. | r Read a scroll.", 1, 0); X prt("D <Dir> Disarm a trap/chest. | s Search for hidden doors.", X 2, 0); X prt("E Eat some food. | T Take off an item.", 3, 0); X prt("F Fill lamp with oil. | Z Use a staff.", 4, 0); X prt("W Current location. | v Version and credits.", 5, 0); X prt("M Print map. | w Wear/Wield an item.", 6, 0); X prt("R Rest for a period. | X Exchange weapon.", 7, 0); X prt("# Search Mode. | / Identify a character.", 8,0); X prt("CTRL <dir> Tunnel | ? Display this panel.", 9, 0); X prt("z Aim and fire a wand. |", 10, 0); X prt("P Browse a book. | ^P Repeat the last message.", X 11, 0); X prt("c <Dir> Close a door. | ^R Redraw the screen.", 12, 0); X prt("d Drop an item. | Q Quit the game.", 13, 0); X prt("e Equipment list. | ^X Save character and quit.", X 14, 0); X prt("t Fire/Throw an item. | ! Shell out of game.", 15, 0); X/* prt("h Help on key commands. |", 16, 0); */ X prt("i Inventory list. | < Go up an up-staircase.", 17, 0); X prt("S <Dir> Jam a door with spike.| > Go down a down-staircase.", 18, 0); X prt("x <Dir> Look given direction. | SHIFT <Dir> Move in direction.", 19, 0); X prt("m Cast a magic spell. | Movement: y k u", 20, 0); X prt("o <Dir> Open a door/chest. | h l . == Rest", X 21, 0); X prt("p Read a prayer. | b j n", 22, 0); X pause_line(23); X draw_cave(); X} X X X/* Help for available wizard commands */ Xoriginal_wizard_help() X{ X clear_screen(0, 0); X if (wizard2) X { X prt("^A - Remove Curse and Cure all maladies.", 0, 0); X prt("^B - Print random objects sample.", 1, 0); X prt("^D - Down/Up n levels.", 2, 0); X prt("^E - Change character.", 3, 0); X prt("^F - Delete monsters.", 4, 0); X prt("^G - Allocate treasures.", 5, 0); X prt("^H - Wizard Help.", 6, 0); X prt("^I - Identify.", 7, 0); X prt("^J - Gain experience.", 8, 0); X prt("^U - Summon monster.", 9, 0); X prt("^L - Wizard light.", 10, 0); X prt("^N - Print monster dictionary.", 11, 0); X prt("^P - Wizard password on/off.", 12, 0); X prt("^T - Teleport player.", 13, 0); X prt("^V - Restore lost character.", 14, 0); X prt("^W - Create any object *CAN CAUSE FATAL ERROR*", 15, 0); X } X else X { X prt("^A - Remove Curse and Cure all maladies.", 0, 0); X prt("^B - Print random objects sample.", 1, 0); X prt("^D - Down/Up n levels.", 2, 0); X prt("^H - Wizard Help.", 3, 0); X prt("^I - Identify.", 4, 0); X prt("^L - Wizard light.", 5, 0); X prt("^N - Print monster dictionary.", 6, 0); X prt("^P - Wizard password on/off.", 7, 0); X prt("^T - Teleport player.", 8, 0); X prt("^V - Restore lost character.", 9, 0); X } X pause_line(23); X draw_cave(); X} X X X/* Help for available wizard commands */ Xrogue_like_wizard_help() X{ X clear_screen(0, 0); X if (wizard2) X { X prt("^A - Remove Curse and Cure all maladies.", 0, 0); X prt("^O - Print random objects sample.", 1, 0); X prt("^D - Down/Up n levels.", 2, 0); X prt("^E - Change character.", 3, 0); X prt("^F - Delete monsters.", 4, 0); X prt("^G - Allocate treasures.", 5, 0); X prt("^? - Wizard Help.", 6, 0); X prt("^I - Identify.", 7, 0); X prt("+ - Gain experience.", 8, 0); X prt("^U - Summon monster.", 9, 0); X prt("* - Wizard light.", 10, 0); X prt("^M - Print monster dictionary.", 11, 0); X prt("^W - Wizard password on/off.", 12, 0); X prt("^T - Teleport player.", 13, 0); X prt("^V - Restore lost character.", 14, 0); X prt("^Q - Create any object *CAN CAUSE FATAL ERROR*", 15, 0); X } X else X { X prt("^A - Remove Curse and Cure all maladies.", 0, 0); X prt("^O - Print random objects sample.", 1, 0); X prt("^D - Down/Up n levels.", 2, 0); X prt("^? - Wizard Help.", 3, 0); X prt("^I - Identify.", 4, 0); X prt("* - Wizard light.", 5, 0); X prt("^M - Print monster dictionary.", 6, 0); X prt("^W - Wizard password on/off.", 7, 0); X prt("^T - Teleport player.", 8, 0); X prt("^V - Restore lost character.", 9, 0); X } X pause_line(23); X draw_cave(); X} END_OF_help.c if test 11885 -ne `wc -c <help.c`; then echo shar: \"help.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f misc2.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"misc2.c\" else echo shar: Extracting \"misc2.c\" \(40587 characters\) sed "s/^X//" >misc2.c <<'END_OF_misc2.c' X#include <stdio.h> X#ifdef USG X#include <string.h> X#else X#include <strings.h> X#endif X#include <sys/types.h> X X#include "config.h" X#include "constants.h" X#include "types.h" X#include "externs.h" X X#ifdef sun /* correct SUN stupidity in the stdio.h file */ Xchar *sprintf(); X#endif X X#if defined(ultrix) || defined(sun) || defined(USG) Xint getuid(); X#else Xuid_t getuid(); X#endif X X/* Places a particular trap at location y, x -RAK- */ Xplace_trap(y, x, typ, subval) Xint y, x, typ, subval; X{ X int cur_pos; X treasure_type cur_trap; X X if (typ == 1) X cur_trap = trap_lista[subval]; X else X cur_trap = trap_listb[subval]; X popt(&cur_pos); X cave[y][x].tptr = cur_pos; X t_list[cur_pos] = cur_trap; X} X X X/* Places rubble at location y, x -RAK- */ Xplace_rubble(y, x) Xint y, x; X{ X int cur_pos; X cave_type *cave_ptr; X X popt(&cur_pos); X cave_ptr = &cave[y][x]; X cave_ptr->tptr = cur_pos; X cave_ptr->fopen = FALSE; X t_list[cur_pos] = rubble; X} X X Xplace_open_door(y, x) Xint y, x; X{ X int cur_pos; X cave_type *cave_ptr; X X popt(&cur_pos); X cave_ptr = &cave[y][x]; X cave_ptr->tptr = cur_pos; X t_list[cur_pos] = door_list[0]; X cave_ptr->fval = corr_floor3.ftval; X cave_ptr->fopen = TRUE; X} X X Xplace_broken_door(y, x) Xint y, x; X{ X int cur_pos; X cave_type *cave_ptr; X X popt(&cur_pos); X cave_ptr = &cave[y][x]; X cave_ptr->tptr = cur_pos; X t_list[cur_pos] = door_list[0]; X cave_ptr->fval = corr_floor3.ftval; X cave_ptr->fopen = TRUE; X t_list[cur_pos].p1 = 1; X} X X Xplace_closed_door(y, x) Xint y, x; X{ X int cur_pos; X cave_type *cave_ptr; X X popt(&cur_pos); X cave_ptr = &cave[y][x]; X cave_ptr->tptr = cur_pos; X t_list[cur_pos] = door_list[1]; X cave_ptr->fval = corr_floor3.ftval; X cave_ptr->fopen = FALSE; X} X X Xplace_locked_door(y, x) Xint y, x; X{ X int cur_pos; X cave_type *cave_ptr; X X popt(&cur_pos); X cave_ptr = &cave[y][x]; X cave_ptr->tptr = cur_pos; X t_list[cur_pos] = door_list[1]; X cave_ptr->fval = corr_floor3.ftval; X cave_ptr->fopen = FALSE; X t_list[cur_pos].p1 = randint(10) + 10; X} X X Xplace_stuck_door(y, x) Xint y, x; X{ X int cur_pos; X cave_type *cave_ptr; X X popt(&cur_pos); X cave_ptr = &cave[y][x]; X cave_ptr->tptr = cur_pos; X t_list[cur_pos] = door_list[1]; X cave_ptr->fval = corr_floor3.ftval; X cave_ptr->fopen = FALSE; X t_list[cur_pos].p1 = -randint(10) - 10; X} X X Xplace_secret_door(y, x) Xint y, x; X{ X int cur_pos; X cave_type *cave_ptr; X X popt(&cur_pos); X cave_ptr = &cave[y][x]; X cave_ptr->tptr = cur_pos; X t_list[cur_pos] = door_list[2]; X cave_ptr->fval = corr_floor4.ftval; X cave_ptr->fopen = FALSE; X} X X Xplace_door(y, x) Xint y, x; X{ X switch(randint(3)) X { X case 1: X switch(randint(4)) X { X case 1: X place_broken_door(y, x); X break; X default: X place_open_door(y, x); X break; X } X break; X case 2: X switch(randint(12)) X { X case 1: case 2: X place_locked_door(y, x); X break; X case 3: X place_stuck_door(y, x); X break; X default: X place_closed_door(y, x); X break; X } X case 3: X place_secret_door(y, x); X break; X } X} X X X/* Place an up staircase at given y, x -RAK- */ Xplace_up_stairs(y, x) Xint y, x; X{ X int cur_pos; X cave_type *cave_ptr; X X cave_ptr = &cave[y][x]; X if (cave_ptr->tptr != 0) X { X pusht((int)cave_ptr->tptr); X cave_ptr->tptr = 0; X cave_ptr->fopen = TRUE; X } X popt(&cur_pos); X cave[y][x].tptr = cur_pos; X t_list[cur_pos] = up_stair; X} X X X/* Place a down staircase at given y, x -RAK- */ Xplace_down_stairs(y, x) Xint y, x; X{ X int cur_pos; X cave_type *cave_ptr; X X cave_ptr = &cave[y][x]; X if (cave_ptr->tptr != 0) X { X pusht((int)cave_ptr->tptr); X cave_ptr->tptr = 0; X cave_ptr->fopen = TRUE; X } X popt(&cur_pos); X cave[y][x].tptr = cur_pos; X t_list[cur_pos] = down_stair; X} X X/* Places a staircase 1==up, 2==down -RAK- */ Xplace_stairs(typ, num, walls) Xint typ, num, walls; X{ X int i, j, y1, x1, y2, x2; X int flag; X cave_type *cave_ptr; X X for (i = 0; i < num; i++) X { X flag = FALSE; X do X { X j = 0; X do X { X y1 = randint(cur_height - 12) - 1; X x1 = randint(cur_width - 12) - 1; X y2 = y1 + 12; X x2 = x1 + 12; X do X { X do X { X cave_ptr = &cave[y1][x1]; X if ((cave_ptr->fval == 1) || (cave_ptr->fval == 2) || X (cave_ptr->fval == 4)) X if (cave_ptr->tptr == 0) X if (next_to4(y1, x1, 10, 11, 12) >= walls) X { X flag = TRUE; X switch(typ) X { X case 1: X place_up_stairs(y1, x1); X break; X case 2: X place_down_stairs(y1, x1); X break; X } X } X x1++; X } X while ((x1 != x2) && (!flag)); X x1 = x2 - 12; X y1++; X } X while ((y1 != y2) && (!flag)); X j++; X } X while ((!flag) && (j <= 30)); X walls--; X } X while (!flag); X } X} X X X/* Places a treasure (Gold or Gems) at given row, column -RAK- */ Xplace_gold(y, x) Xint y, x; X{ X int cur_pos, i; X treasure_type *t_ptr; X X popt(&cur_pos); X i = ((randint(dun_level+2)+2)/2.0) - 1; X if (randint(OBJ_GREAT) == 1) X i += randint(dun_level+1); X if (i >= MAX_GOLD) X i = MAX_GOLD - 1; X cave[y][x].tptr = cur_pos; X t_list[cur_pos] = gold_list[i]; X t_ptr = &t_list[cur_pos]; X t_ptr->cost += randint(8*t_ptr->cost); X} X X X/* Returns the array number of a random object -RAK- */ Xint get_obj_num(level) Xint level; X{ X int i; X X if (level >= MAX_OBJ_LEVEL) X level = MAX_OBJ_LEVEL - 1; X if (randint(OBJ_GREAT) == 1) X level = MAX_OBJ_LEVEL - 1; X if (level == 0) X i = randint(t_level[0]) - 1; X else X i = randint(t_level[level]) - 1; X return(i); X} X X X/* Places an object at given row, column co-ordinate -RAK- */ Xplace_object(y, x) Xint y, x; X{ X int cur_pos; X X popt(&cur_pos); X cave[y][x].tptr = cur_pos; X t_list[cur_pos] = object_list[get_obj_num(dun_level)]; X magic_treasure(cur_pos, dun_level); X} X X X/* Allocates an object for tunnels and rooms -RAK- */ Xalloc_object(alloc_set, typ, num) Xint (*alloc_set)(); Xint typ, num; X{ X int i, j, k; X X for (k = 0; k < num; k++) X { X do X { X i = randint(cur_height) - 1; X j = randint(cur_width) - 1; X } X while ((!(*alloc_set)(cave[i][j].fval)) || X (cave[i][j].tptr != 0)); X switch(typ) X { X case 1: X place_trap(i, j, 1, randint(MAX_TRAPA)-1); X break; X case 2: X place_trap(i, j, 2, randint(MAX_TRAPB)-1); X break; X case 3: X place_rubble(i, j); X break; X case 4: X place_gold(i, j); X break; X case 5: X place_object(i, j); X break; X } X } X} X X X/* Creates objects nearby the coordinates given -RAK- */ Xrandom_object(y, x, num) Xint y, x, num; X{ X int i, j, k; X cave_type *cave_ptr; X X do X { X i = 0; X do X { X j = y - 3 + randint(5); X k = x - 4 + randint(7); X cave_ptr = &cave[j][k]; X if ((cave_ptr->fval <= 7) && (cave_ptr->fval >= 1)) X if (cave_ptr->tptr == 0) X { X if (randint(100) < 75) X place_object(j, k); X else X place_gold(j, k); X i = 9; X } X i++; X } X while(i <= 10); X num--; X } X while (num != 0); X} X X X/* Converts stat num into string -RAK- */ Xcnv_stat(stat, out_val) Xbyteint stat; Xchar *out_val; X{ X vtype tmp_str; X int part1, part2; X X if (stat > 18) X { X part1 = 18; X part2 = stat - 18; X if (part2 == 100) X (void) strcpy(tmp_str, "18/100"); X else if (part2 < 10) X (void) sprintf(tmp_str, " %2d/0%d", part1, part2); X else X (void) sprintf(tmp_str, " %2d/%2d", part1, part2); X } X else X (void) sprintf(tmp_str, "%6d", stat); X if (strlen(tmp_str) < 6) X (void) strcpy(tmp_str, pad(tmp_str, " ", 6)); X (void) strcpy(out_val, tmp_str); X} X X X/* Print character stat in given row, column -RAK- */ Xprt_stat(stat_name, stat, row, column) Xvtype stat_name; Xbyteint stat; Xint row, column; X{ X stat_type out_val1; X vtype out_val2; X X cnv_stat(stat, out_val1); X (void) strcpy(out_val2, stat_name); X (void) strcat(out_val2, out_val1); X put_buffer(out_val2, row, column); X} X X X/* Print character info in given row, column -RAK- */ Xprt_field(info, row, column) Xvtype info; Xint row, column; X{ X put_buffer(pad(info, " ", 14), row, column); X} X X X/* Print number with header at given row, column -RAK- */ Xprt_num(header, num, row, column) Xvtype header; Xint num, row, column; X{ X vtype out_val; X X (void) sprintf(out_val, "%s%6d ", header, num); X put_buffer(out_val, row, column); X} X X X/* Adjustment for wisdom -JWT- */ Xint wis_adj() X{ X if (py.stats.cwis > 117) X return(7); X else if (py.stats.cwis > 107) X return(6); X else if (py.stats.cwis > 87) X return(5); X else if (py.stats.cwis > 67) X return(4); X else if (py.stats.cwis > 17) X return(3); X else if (py.stats.cwis > 14) X return(2); X else if (py.stats.cwis > 7) X return(1); X else X return(0); X} X X/* adjustment for intelligence -JWT- */ Xint int_adj() X{ X if (py.stats.cint > 117) X return(7); X else if (py.stats.cint > 107) X return(6); X else if (py.stats.cint > 87) X return(5); X else if (py.stats.cint > 67) X return(4); X else if (py.stats.cint > 17) X return(3); X else if (py.stats.cint > 14) X return(2); X else if (py.stats.cint > 7) X return(1); X else X return(0); X} X X X/* Adjustment for charisma -RAK- */ X/* Percent decrease or increase in price of goods */ Xdouble chr_adj() X{ X if (py.stats.cchr > 117) X return(-0.10); X else if (py.stats.cchr > 107) X return(-0.08); X else if (py.stats.cchr > 87) X return(-0.06); X else if (py.stats.cchr > 67) X return(-0.04); X else if (py.stats.cchr > 18) X return(-0.02); X else X switch(py.stats.cchr) X { X case 18: return(0.00); break; X case 17: return(0.01); break; X case 16: return(0.02); break; X case 15: return(0.03); break; X case 14: return(0.04); break; X case 13: return(0.06); break; X case 12: return(0.08); break; X case 11: return(0.10); break; X case 10: return(0.12); break; X case 9: return(0.14); break; X case 8: return(0.16); break; X case 7: return(0.18); break; X case 6: return(0.20); break; X case 5: return(0.22); break; X case 4: return(0.24); break; X case 3: return(0.25); break; X default: return(0.00); break; /* Error trap */ X } X return(0.00); X} X X X/* Returns a character's adjustment to hit points -JWT- */ Xint con_adj() X{ X if (py.stats.ccon == 3) X return(-4); X else if (py.stats.ccon == 4) X return(-3); X else if (py.stats.ccon == 5) X return(-2); X else if (py.stats.ccon == 6) X return(-1); X else if (py.stats.ccon < 17) X return(0); X else if (py.stats.ccon == 17) X return(1); X else if (py.stats.ccon < 94) X return(2); X else if (py.stats.ccon < 117) X return(3); X else X return(4); X} X X X/* Calculates hit points for each level that is gained. -RAK- */ Xint get_hitdie() X{ X return(randint((int)py.misc.hitdie) + con_adj()); X} X X X/* Prints title of character -RAK- */ Xprt_title() X{ X prt_field(py.misc.title, 4, stat_column); X} X X X/* Prints strength -RAK- */ Xprt_strength() X{ X prt_stat("\0", py.stats.cstr, 6, stat_column+6); X} X X X/* Prints intelligence -RAK- */ Xprt_intelligence() X{ X prt_stat("\0", py.stats.cint, 7, stat_column+6); X} X X X/* Prints wisdom -RAK- */ Xprt_wisdom() X{ X prt_stat("\0", py.stats.cwis, 8, stat_column+6); X} X X X/* Prints dexterity -RAK- */ Xprt_dexterity() X{ X prt_stat("\0", py.stats.cdex, 9, stat_column+6); X} X X X/* Prints constitution -RAK- */ Xprt_constitution() X{ X prt_stat("\0", py.stats.ccon, 10, stat_column+6); X} X X X/* Prints charisma -RAK- */ Xprt_charisma() X{ X prt_stat("\0", py.stats.cchr, 11, stat_column+6); X} X X X/* Prints level -RAK- */ Xprt_level() X{ X prt_num("\0", (int)py.misc.lev, 13, stat_column+6); X} X X X/* Prints players current mana points (a real number...) -RAK- */ Xprt_cmana() X{ X prt_num("\0", (int)(py.misc.cmana), 15, stat_column+6); X} X X X/* Prints Max hit points -RAK- */ Xprt_mhp() X{ X prt_num("\0", py.misc.mhp, 16, stat_column+6); X} X X X/* Prints players current hit points (a real number...) -RAK- */ Xprt_chp() X{ X prt_num("\0", (int)(py.misc.chp), 17, stat_column+6); X} X X X/* prints current AC -RAK- */ Xprt_pac() X{ X prt_num("\0", py.misc.dis_ac, 19, stat_column+6); X} X X X/* Prints current gold -RAK- */ Xprt_gold() X{ X prt_num("\0", py.misc.au, 20, stat_column+6); X} X X X/* Prints depth in stat area -RAK- */ Xprt_depth() X{ X vtype depths; X int depth; X X depth = dun_level*50; X if (depth == 0) X (void) strcpy(depths, "Town level"); X else X (void) sprintf(depths, "Depth: %d (feet)", depth); X prt(depths, 23, 60); X} X X X/* Prints status of hunger -RAK- */ Xprt_hunger() X{ X if (0x000002 & py.flags.status) X put_buffer("Weak ", 23, 0); X else if (0x000001 & py.flags.status) X put_buffer("Hungry ", 23, 0); X else X put_buffer(" ", 23, 0); X} X X X/* Prints Blind status -RAK- */ Xprt_blind() X{ X if (0x000004 & py.flags.status) X put_buffer("Blind ", 23, 8); X else X put_buffer(" ", 23, 8); X} X X X/* Prints Confusion status -RAK- */ Xprt_confused() X{ X if (0x000008 & py.flags.status) X put_buffer("Confused ", 23, 15); X else X put_buffer(" ", 23, 15); X} X X X/* Prints Fear status -RAK- */ Xprt_afraid() X{ X if (0x000010 & py.flags.status) X put_buffer("Afraid ", 23, 25); X else X put_buffer(" ", 23, 25); X} X X X/* Prints Poisoned status -RAK- */ Xprt_poisoned() X{ X if (0x000020 & py.flags.status) X put_buffer("Poisoned ", 23, 33); X else X put_buffer(" ", 23, 33); X} X X X/* Prints Searching status -RAK- */ Xprt_search() X{ X if (0x000100 & py.flags.status) X put_buffer("Searching ", 23, 43); X else X put_buffer(" ", 23, 43); X} X X X/* Prints Resting status -RAK- */ Xprt_rest() X{ X if (0x000200 & py.flags.status) X put_buffer("Resting ", 23, 43); X else X put_buffer(" ", 23, 43); X} X X X/* Prints winner status on display -RAK- */ Xprt_winner() X{ X put_buffer("*Winner*", 22, 0); X} X X X/* Increases a stat by one randomized level -RAK- */ Xbyteint in_statp(stat) Xbyteint stat; X{ X if (stat < 18) X stat++; X else if (stat < 88) X stat += randint(25); X else if (stat < 108) X stat += randint(10); X else X stat++; X if (stat > 118) X stat = 118; X return(stat); X} X X X/* Decreases a stat by one randomized level -RAK- */ Xbyteint de_statp(stat) Xbyteint stat; X{ X if (stat < 19) X stat--; X else if (stat < 109) X { X stat += -randint(10) - 5; X if (stat < 18) X stat = 18; X } X else X stat -= randint(3); X if (stat < 3) X stat = 3; X return(stat); X} X X X/* Increases a stat by one true level -RAK- */ Xbyteint in_statt(stat) Xbyteint stat; X{ X if (stat < 18) X stat++; X else X { X stat += 10; X if (stat > 118) X stat = 118; X } X return(stat); X} X X X/* Decreases a stat by true level -RAK- */ Xbyteint de_statt(stat) Xbyteint stat; X{ X if (stat > 27) X stat -= 10; X else if (stat > 18) X stat = 18; X else X { X stat--; X if (stat < 3) X stat = 3; X } X return(stat); X} X X X/* Returns a character's adjustment to hit. -JWT- */ Xint tohit_adj() X{ X int total; X X if (py.stats.cdex < 4) total = -3; X else if (py.stats.cdex < 6) total = -2; X else if (py.stats.cdex < 8) total = -1; X else if (py.stats.cdex < 16) total = 0; X else if (py.stats.cdex < 17) total = 1; X else if (py.stats.cdex < 18) total = 2; X else if (py.stats.cdex < 69) total = 3; X else if (py.stats.cdex < 118) total = 4; X else total = 5; X if (py.stats.cstr < 4) total -= 3; X else if (py.stats.cstr < 5) total -= 2; X else if (py.stats.cstr < 7) total -= 1; X else if (py.stats.cstr < 18) total -= 0; X else if (py.stats.cstr < 94) total += 1; X else if (py.stats.cstr < 109) total += 2; X else if (py.stats.cstr < 117) total += 3; X else total += 4; X return(total); X} X X X/* Returns a character's adjustment to armor class -JWT- */ Xint toac_adj() X{ X if (py.stats.cdex < 4) return(-4); X else if (py.stats.cdex == 4) return(-3); X else if (py.stats.cdex == 5) return(-2); X else if (py.stats.cdex == 6) return(-1); X else if (py.stats.cdex < 15) return( 0); X else if (py.stats.cdex < 18) return( 1); X else if (py.stats.cdex < 59) return( 2); X else if (py.stats.cdex < 94) return( 3); X else if (py.stats.cdex < 117) return( 4); X else return( 5); X} X X X/* Returns a character's adjustment to disarm -RAK- */ Xint todis_adj() X{ X if (py.stats.cdex == 3) return(-8); X else if (py.stats.cdex == 4) return(-6); X else if (py.stats.cdex == 5) return(-4); X else if (py.stats.cdex == 6) return(-2); X else if (py.stats.cdex == 7) return(-1); X else if (py.stats.cdex < 13) return( 0); X else if (py.stats.cdex < 16) return( 1); X else if (py.stats.cdex < 18) return( 2); X else if (py.stats.cdex < 59) return( 4); X else if (py.stats.cdex < 94) return( 5); X else if (py.stats.cdex < 117) return( 6); X else return( 8); X} X X X/* Returns a character's adjustment to damage -JWT- */ Xint todam_adj() X{ X if (py.stats.cstr < 4) return(-2); X else if (py.stats.cstr < 5) return(-1); X else if (py.stats.cstr < 16) return( 0); X else if (py.stats.cstr < 17) return( 1); X else if (py.stats.cstr < 18) return( 2); X else if (py.stats.cstr < 94) return( 3); X else if (py.stats.cstr < 109) return( 4); X else if (py.stats.cstr < 117) return( 5); X else return( 6); X} X X X/* Prints character-screen info -RAK- */ Xprt_stat_block() X{ X prt_field(py.misc.race, 2, stat_column); X prt_field(py.misc.tclass, 3, stat_column); X prt_field(py.misc.title, 4, stat_column); X prt_stat("STR : ", py.stats.cstr, 6, stat_column); X prt_stat("INT : ", py.stats.cint, 7, stat_column); X prt_stat("WIS : ", py.stats.cwis, 8, stat_column); X prt_stat("DEX : ", py.stats.cdex, 9, stat_column); X prt_stat("CON : ", py.stats.ccon, 10, stat_column); X prt_stat("CHR : ", py.stats.cchr, 11, stat_column); X prt_num( "LEV : ", (int)py.misc.lev, 13, stat_column); X prt_num( "EXP : ", py.misc.exp, 14, stat_column); X prt_num( "MANA: ", (int)(py.misc.cmana), 15, stat_column); X prt_num( "MHP : ", py.misc.mhp, 16, stat_column); X prt_num( "CHP : ", (int)(py.misc.chp), 17, stat_column); X prt_num( "AC : ", py.misc.dis_ac, 19, stat_column); X prt_num( "GOLD: ", py.misc.au, 20, stat_column); X if (total_winner) prt_winner(); X if (0x000003 & py.flags.status) X prt_hunger(); X if (0x000004 & py.flags.status) X prt_blind(); X if (0x000008 & py.flags.status) X prt_confused(); X if (0x000010 & py.flags.status) X prt_afraid(); X if (0x000020 & py.flags.status) X prt_poisoned(); X if (0x000100 & py.flags.status) X prt_search(); X if (0x000200 & py.flags.status) X prt_rest(); X} X X X/* Draws entire screen -RAK- */ Xdraw_cave() X{ X clear_screen(0, 0); X prt_stat_block(); X prt_map(); X prt_depth(); X} X X X/* Prints the following information on the screen. -JWT- */ Xput_character() X{ X char tmp_str[80]; X X clear_screen(0, 0); X prt(strcat(strcpy(tmp_str, "Name : "), py.misc.name), 2, 2); X prt(strcat(strcpy(tmp_str, "Race : "), py.misc.race), 3, 2); X prt(strcat(strcpy(tmp_str, "Sex : "), py.misc.sex), 4, 2); X prt(strcat(strcpy(tmp_str, "Class : "), py.misc.tclass), 5, 2); X} X X X/* Prints the following information on the screen. -JWT- */ Xput_stats() X{ X prt_stat("STR : ", py.stats.cstr, 2, 64); X prt_stat("INT : ", py.stats.cint, 3, 64); X prt_stat("WIS : ", py.stats.cwis, 4, 64); X prt_stat("DEX : ", py.stats.cdex, 5, 64); X prt_stat("CON : ", py.stats.ccon, 6, 64); X prt_stat("CHR : ", py.stats.cchr, 7, 64); X prt_num("+ To Hit : ", py.misc.dis_th, 9, 3); X prt_num("+ To Damage: ", py.misc.dis_td, 10, 3); X prt_num("+ To AC : ", py.misc.dis_tac, 11, 3); X prt_num(" Total AC : ", py.misc.dis_ac, 12, 3); X} X X X/* Returns a rating of x depending on y -JWT- */ Xchar *likert(x, y) Xint x, y; X{ X switch((x/y)) X { X case -3: case -2: case -1: return("Very Bad"); X case 0: case 1: return("Bad"); X case 2: return("Poor"); X case 3: case 4: return("Fair"); X case 5: return("Good"); X case 6: return("Very Good"); X case 7: case 8: return("Superb"); X default: return("Excellent"); X } X} X X X/* Prints age, height, weight, and SC -JWT- */ Xput_misc1() X{ X prt_num("Age : ", (int)py.misc.age, 2, 39); X prt_num("Height : ", (int)py.misc.ht, 3, 39); X prt_num("Weight : ", (int)py.misc.wt, 4, 39); X prt_num("Social Class : ", (int)py.misc.sc, 5, 39); X} X X X/* Prints the following information on the screen. -JWT- */ Xput_misc2() X{ X prt_num("Level : ", (int)py.misc.lev, 9, 30); X prt_num("Experience : ", py.misc.exp, 10, 30); X prt_num("Gold : ", py.misc.au, 11, 30); X prt_num("Max Hit Points : ", py.misc.mhp, 9, 53); X prt_num("Cur Hit Points : ", (int)py.misc.chp, 10, 53); X prt_num("Max Mana : ", py.misc.mana, 11, 53); X prt_num("Cur Mana : ", (int)py.misc.cmana, 12, 53); X} X X X/* Prints ratings on certain abilities -RAK- */ Xput_misc3() X{ X int xbth, xbthb, xfos, xsrh, xstl, xdis, xsave, xdev; X vtype xinfra; X struct misc *p_ptr; X char tmp_str[80]; X X clear_screen(13, 0); X p_ptr = &py.misc; X xbth = p_ptr->bth + p_ptr->lev*BTH_LEV_ADJ + p_ptr->ptohit*BTH_PLUS_ADJ; X xbthb = p_ptr->bthb + p_ptr->lev*BTH_LEV_ADJ + p_ptr->ptohit*BTH_PLUS_ADJ; X xfos = 27 - p_ptr->fos; X if (xfos < 0) xfos = 0; X xsrh = p_ptr->srh + int_adj(); X xstl = p_ptr->stl; X xdis = p_ptr->disarm + p_ptr->lev + 2*todis_adj() + int_adj(); X xsave = p_ptr->save + p_ptr->lev + wis_adj(); X xdev = p_ptr->save + p_ptr->lev + int_adj(); X (void) sprintf(xinfra, "%d feet", py.flags.see_infra*10); X X prt("(Miscellaneous Abilities)", 15, 23); X put_buffer(strcat(strcpy(tmp_str, "Fighting : "), X likert(xbth, 12)), 16, 1); X put_buffer(strcat(strcpy(tmp_str, "Bows/Throw : "), X likert(xbthb, 12)), 17, 1); X put_buffer(strcat(strcpy(tmp_str, "Saving Throw: "), X likert(xsave, 6)), 18, 1); X put_buffer(strcat(strcpy(tmp_str, "Stealth : "), X likert(xstl, 1)), 16, 26); X put_buffer(strcat(strcpy(tmp_str, "Disarming : "), X likert(xdis, 8)), 17, 26); X put_buffer(strcat(strcpy(tmp_str, "Magic Device: "), X likert(xdev, 7)), 18, 26); X put_buffer(strcat(strcpy(tmp_str, "Perception : "), X likert(xfos, 3)), 16, 51); X put_buffer(strcat(strcpy(tmp_str, "Searching : "), X likert(xsrh, 6)), 17, 51); X put_buffer(strcat(strcpy(tmp_str, "Infra-Vision: "), xinfra), 18, 51); X} X X X/* Used to display the character on the screen. -RAK- */ Xdisplay_char() X{ X put_character(); X put_misc1(); X put_stats(); X put_misc2(); X put_misc3(); X} X X X/* Gets a name for the character -JWT- */ Xget_name() X{ X prt("Enter your player's name [press <RETURN> when finished]", 21, 2); X (void) get_string(py.misc.name, 2, 14, 24); X clear_screen(20, 0); X} X X X/* Chances the name of the character -JWT- */ Xchange_name() X{ X char c; X int flag; X X flag = FALSE; X display_char(); X do X { X prt("<c>hange character name. <ESCAPE> to continue.", 21, 2); X inkey(&c); X switch(c) X { X case 99: X get_name(); X break; X case 0: case 27: X flag = TRUE; X break; X default: X break; X } X } X while (!flag); X} X X X/* Builds passwords -RAK- */ Xbpswd() X{ X (void) strcpy(password1, PASSWD1); X (void) strcpy(password2, PASSWD2); X} X X X/* Destroy an item in the inventory -RAK- */ Xinven_destroy(item_val) Xint item_val; X{ X int j; X treasure_type *i_ptr; X X inventory[INVEN_MAX] = inventory[item_val]; X i_ptr = &inventory[item_val]; X if ((i_ptr->number > 1) && (i_ptr->subval < 512)) X { X i_ptr->number--; X inven_weight -= i_ptr->weight; X inventory[INVEN_MAX].number = 1; X } X else X { X inven_weight -= i_ptr->weight*i_ptr->number; X for (j = item_val; j < inven_ctr-1; j++) X inventory[j] = inventory[j+1]; X inventory[inven_ctr-1] = blank_treasure; X inven_ctr--; X } X} X X X/* Drops an item from inventory to given location -RAK- */ Xinven_drop(item_val, y, x) Xint item_val, y, x; X{ X int i; X cave_type *cave_ptr; X X cave_ptr = &cave[y][x]; X if (cave_ptr->tptr != 0) X pusht((int)cave_ptr->tptr); X inven_destroy(item_val); X popt(&i); X t_list[i] = inventory[INVEN_MAX]; X cave_ptr->tptr = i; X} X X X/* Destroys a type of item on a given percent chance -RAK- */ Xint inven_damage(typ, perc) Xint (*typ)(); Xint perc; X{ X int i, j; X X j = 0; X for (i = 0; i < inven_ctr; i++) X if ((*typ)(inventory[i].tval)) X if (randint(100) < perc) X { X inven_destroy(i); X j++; X } X return(j); X} X X X/* Computes current weight limit -RAK- */ Xint weight_limit() X{ X int weight_cap; X X weight_cap = py.stats.cstr * PLAYER_WEIGHT_CAP + py.misc.wt; X if (weight_cap > 3000) weight_cap = 3000; X return(weight_cap); X} X X X/* Check inventory for too much weight -RAK- */ Xint inven_check_weight() X{ X int item_wgt, max_weight; X int check_weight; X X check_weight = FALSE; X max_weight = weight_limit(); X item_wgt = inventory[INVEN_MAX].number*inventory[INVEN_MAX].weight; X /* Now, check to see if player can carry object */ X if ((inven_weight + item_wgt) <= max_weight) X check_weight = TRUE; /* Can carry weight */ X return(check_weight); X} X X X/* Check to see if he will be carrying too many objects -RAK- */ Xint inven_check_num() X{ X int i; X int check_num; X X check_num = FALSE; X if (inven_ctr < 22) X check_num = TRUE; X else if (inventory[INVEN_MAX].subval > 255) X for (i = 0; i < inven_ctr; i++) X if (inventory[i].tval == inventory[INVEN_MAX].tval) X if (inventory[i].subval == inventory[INVEN_MAX].subval) X check_num = TRUE; X return(check_num); X} X X X/* Insert INVEN_MAX at given location */ Xinsert_inv(pos, wgt) Xint pos, wgt; X{ X int i; X X for (i = inven_ctr-1; i >= pos; i--) X inventory[i+1] = inventory[i]; X inventory[pos] = inventory[INVEN_MAX]; X inven_ctr++; X inven_weight += wgt; X} X X X/* Add the item in INVEN_MAX to players inventory. Return the */ X/* item position for a description if needed... -RAK- */ Xinven_carry(item_val) Xint *item_val; X{ X int item_num, wgt; X int typ, subt; X int flag; X treasure_type *i_ptr; X X /* Now, check to see if player can carry object */ X *item_val = 0; X flag = FALSE; X i_ptr = &inventory[INVEN_MAX]; X item_num = i_ptr->number; X typ = i_ptr->tval; X subt = i_ptr->subval; X wgt = i_ptr->number*i_ptr->weight; X X do X { X i_ptr = &inventory[*item_val]; X if (typ == i_ptr->tval) X { X if (subt == i_ptr->subval) /* Adds to other item */ X if (subt > 255) X { X i_ptr->number += item_num; X inven_weight += wgt; X flag = TRUE; X } X } X else if (typ > i_ptr->tval) X { /* Insert into list */ X insert_inv(*item_val, wgt); X flag = TRUE; X } X (*item_val)++; X } X while ((*item_val < inven_ctr) && (!flag)); X if (!flag) /* Becomes last item in list */ X { X insert_inv(inven_ctr, wgt); X *item_val = inven_ctr - 1; X } X else X (*item_val)--; X} X X X/* Returns spell chance of failure for spell -RAK- */ Xspell_chance(spell) Xspl_rec *spell; X{ X spell_type *s_ptr; X X s_ptr = &magic_spell[py.misc.pclass][spell->splnum]; X spell->splchn = s_ptr->sfail - 3*(py.misc.lev-s_ptr->slevel); X if (class[py.misc.pclass].mspell) X spell->splchn -= 3*(int_adj()-1); X else X spell->splchn -= 3*(wis_adj()-1); X if (s_ptr->smana > py.misc.cmana) X spell->splchn += 5*(s_ptr->smana-(int)py.misc.cmana); X if (spell->splchn > 95) X spell->splchn = 95; X else if (spell->splchn < 5) X spell->splchn = 5; X} X X X/* Print list of spells -RAK- */ Xprint_new_spells(spell, num, redraw) Xspl_type spell; Xint num; Xint *redraw; X{ X int i; X vtype out_val; X spell_type *s_ptr; X X *redraw = TRUE; X clear_screen(0, 0); X prt(" Name Level Mana %Failure", 1, 0); X for (i = 0; i < num; i++) X { X s_ptr = &magic_spell[py.misc.pclass][spell[i].splnum]; X spell_chance(&spell[i]); X (void) sprintf(out_val, "%c) %s%d %d %d", 97+i, X pad(s_ptr->sname, " ", 30), X s_ptr->slevel, s_ptr->smana, spell[i].splchn); X prt(out_val, 2+i, 0); X } X} X X X/* Returns spell pointer -RAK- */ Xint get_spell(spell, num, sn, sc, prompt, redraw) Xspl_type spell; Xint num; Xint *sn, *sc; Xvtype prompt; Xint *redraw; X{ X int flag; X char choice; X vtype out_val1; X X *sn = -1; X flag = TRUE; X (void) sprintf(out_val1, "(Spells a-%c, *==List, <ESCAPE>=exit) %s", X num+96, prompt); X while (((*sn < 0) || (*sn >= num)) && (flag)) X { X prt(out_val1, 0, 0); X inkey(&choice); X *sn = (choice); X switch(*sn) X { X case 0: case 27: X flag = FALSE; X reset_flag = TRUE; X break; X case 42: X print_new_spells(spell, num, redraw); X break; X default: X *sn -= 97; X break; X } X } X msg_flag = FALSE; X if (flag) X { X spell_chance(&spell[*sn]); X *sc = spell[*sn].splchn; X *sn = spell[*sn].splnum; X } X return(flag); X} X X X/* Learn some magic spells (Mage) -RAK- */ Xint learn_spell(redraw) Xint *redraw; X{ X unsigned int j; X int i, k, sn, sc; X int new_spells; X unsigned int spell_flag; X spl_type spell; X int learn; X spell_type *s_ptr; X X learn = FALSE; X switch(int_adj()) X { X case 0: new_spells = 0; break; X case 1: new_spells = 1; break; X case 2: new_spells = 1; break; X case 3: new_spells = 1; break; X case 4: new_spells = randint(2); break; X case 5: new_spells = randint(2); break; X case 6: new_spells = randint(3); break; X case 7: new_spells = randint(2)+1; break; X default: new_spells = 0; break; X } X i = 0; X spell_flag = 0; X do X { X if (inventory[i].tval == 90) X spell_flag |= inventory[i].flags; X i++; X } X while (i < inven_ctr); X while ((new_spells > 0) && (spell_flag != 0)) X { X i = 0; X j = spell_flag; X do X { X k = bit_pos(&j); X s_ptr = &magic_spell[py.misc.pclass][k]; X if (s_ptr->slevel <= py.misc.lev) X if (!s_ptr->learned) X { X spell[i].splnum = k; X i++; X } X } X while(j != 0); X if (i > 0) X { X print_new_spells(spell, i, redraw); X if (get_spell(spell, i, &sn, &sc, "Learn which spell?", redraw)) X { X magic_spell[py.misc.pclass][sn].learned = TRUE; X learn = TRUE; X if (py.misc.mana == 0) X { X py.misc.mana = 1; X py.misc.cmana = 1.0; X } X } X else X new_spells = 0; X } X else X new_spells = 0; X new_spells--; X } X return(learn); X} X X X/* Learn some prayers (Priest) -RAK- */ Xint learn_prayer() X{ X int i, j, k, l, new_spell; X int test_array[32]; X unsigned int spell_flag; X int learn; X spell_type *s_ptr; X X i = 0; X spell_flag = 0; X do X { X if (inventory[i].tval == 91) X spell_flag |= inventory[i].flags; X i++; X } X while(i < inven_ctr); X i = 0; X while (spell_flag != 0) X { X j = bit_pos(&spell_flag); X s_ptr = &magic_spell[py.misc.pclass][j]; X if (s_ptr->slevel <= py.misc.lev) X if (!s_ptr->learned) X { X test_array[i] = j; X i++; X } X } X switch(wis_adj()) X { X case 0: j = 0; break; X case 1: j = 1; break; X case 2: j = 1; break; X case 3: j = 1; break; X case 4: j = randint(2); break; X case 5: j = randint(2); break; X case 6: j = randint(3); break; X case 7: j = randint(2)+1; break; X } X new_spell = 0; X while ((i > 0) && (j > 0)) X { X k = randint(i) - 1; X magic_spell[py.misc.pclass][test_array[k]].learned = TRUE; X new_spell++; X for (l = k; l <= i-1; l++) X test_array[l] = test_array[l+1]; X i--; /* One less spell to learn */ X j--; /* Learned one */ X } X if (new_spell > 0) X { X if (new_spell > 1) X msg_print("You learned new prayers!"); X else X msg_print("You learned a new prayer!"); X if (py.misc.exp == 0) msg_print(" "); X if (py.misc.mana == 0) X { X py.misc.mana = 1; X py.misc.cmana = 1.0; X } X learn = TRUE; X } X else X learn = FALSE; X return(learn); X} X X X/* Gain some mana if you knows at least one spell -RAK- */ Xgain_mana(amount) Xint amount; X{ X int i, new_mana; X int knows_spell; X X knows_spell = FALSE; X for (i = 0; i < 31; i++) X if (magic_spell[py.misc.pclass][i].learned) X knows_spell = TRUE; X if (knows_spell) X { X if (0x1 & py.misc.lev) X switch(amount) X { X case 0: new_mana = 0; break; X case 1: new_mana = 1; break; X case 2: new_mana = 1; break; X case 3: new_mana = 1; break; X case 4: new_mana = 2; break; X case 5: new_mana = 2; break; X case 6: new_mana = 3; break; X case 7: new_mana = 4; break; X default: new_mana = 0; break; X } X else X switch(amount) X { X case 0: new_mana = 0; break; X case 1: new_mana = 1; break; X case 2: new_mana = 1; break; X case 3: new_mana = 2; break; X case 4: new_mana = 2; break; X case 5: new_mana = 3; break; X case 6: new_mana = 3; break; X case 7: new_mana = 4; break; X default: new_mana = 0; break; X } X py.misc.mana += new_mana; X py.misc.cmana += new_mana; X } X} X X X/* Increases hit points and level -RAK- */ Xgain_level() X{ X int nhp, dif_exp, need_exp; X int redraw; X vtype out_val; X struct misc *p_ptr; X class_type *c_ptr; X X p_ptr = &py.misc; X nhp = get_hitdie(); X p_ptr->mhp += nhp; X p_ptr->chp += (double)nhp; X p_ptr->lev++; X need_exp = (player_exp[p_ptr->lev]*p_ptr->expfact); X if (py.misc.exp > need_exp) X { X dif_exp = py.misc.exp - need_exp; X py.misc.exp = need_exp + (dif_exp / 2); X } X (void) strcpy(p_ptr->title, player_title[p_ptr->pclass][p_ptr->lev-1]); X (void) sprintf(out_val, "Welcome to level %d.", (int)p_ptr->lev); X msg_print(out_val); X msg_print(" "); X msg_flag = FALSE; X prt_mhp(); X prt_chp(); X prt_level(); X prt_title(); X c_ptr = &class[p_ptr->pclass]; X if (c_ptr->mspell) X { X redraw = FALSE; X (void) learn_spell(&redraw); X if (redraw) draw_cave(); X gain_mana(int_adj()); X prt_cmana(); X } X else if (c_ptr->pspell) X { X (void) learn_prayer(); X gain_mana(wis_adj()); X prt_cmana(); X } X} X X/* Prints experience -RAK- */ Xprt_experience() X{ X struct misc *p_ptr; X X p_ptr = &py.misc; X if (p_ptr->exp > player_max_exp) X p_ptr->exp = player_max_exp; X if (p_ptr->lev < MAX_PLAYER_LEVEL) X { X while ((player_exp[p_ptr->lev]*p_ptr->expfact) <= p_ptr->exp) X gain_level(); X if (p_ptr->exp > p_ptr->max_exp) X p_ptr->max_exp = p_ptr->exp; X } X prt_num("", py.misc.exp, 14, stat_column+6); X} X X X/* Inserts a string into a string */ Xinsert_str(object_str, mtc_str, insert) Xchar *object_str, *mtc_str, *insert; X{ X int mtc_len, obj_len; X int bound, pc, i; X char *temp_obj, *temp_mtc; X char out_val[80]; X X mtc_len = strlen(mtc_str); X obj_len = strlen(object_str); X bound = (int)object_str + obj_len - mtc_len; X for (pc = (int)object_str; pc <= bound; pc++) X { X temp_obj = (char *)pc; X temp_mtc = mtc_str; X for (i = 0; i < mtc_len; i++) X if (*temp_obj++ != *temp_mtc++) X break; X if (i == mtc_len) X break; X } X X if (pc <= bound) X { X (void) strncpy(out_val, object_str, (pc-(int)object_str)); X out_val[(pc-(int)object_str)] = '\0'; X (void) strcat(out_val, insert); X (void) strcat(out_val, (char *)(pc+mtc_len)); X (void) strcpy(object_str, out_val); X } X} X X X/* Inserts a number into a string */ Xinsert_num(object_str, mtc_str, number, show_sign) Xchar *object_str; Xchar *mtc_str; Xint number; Xint show_sign; X{ X int pos, mlen; X vtype str1, str2; X char *string, *tmp_str; X int flag; X X flag = 1; X tmp_str = object_str; X do X { X string = index(tmp_str, mtc_str[0]); X if (string == 0) X flag = 0; X else X { X flag = strncmp(string, mtc_str, strlen(mtc_str)); X if (flag) X tmp_str = string+1; X } X } X while (flag); X if (string) X pos = strlen(object_str) - strlen(string); X else X pos = -1; X if (pos >= 0) X { X mlen = strlen(mtc_str); X (void) strncpy(str1, object_str, pos); X str1[pos] = '\0'; X (void) strcpy(str2, &object_str[pos+mlen]); X if ((number >= 0) && (show_sign)) X (void) sprintf(object_str, "%s+%d%s", str1, number, str2); X else X (void) sprintf(object_str, "%s%d%s", str1, number, str2); X } X} X X X/* Checks to see if user is a wizard -RAK- */ Xint check_pswd() X{ X int i; X char x; X char tpw[12]; X int check; X X check = FALSE; X if (getuid() != UID) X return(FALSE); X i = 0; X (void) strcpy(tpw, " "); X prt("Password : ", 0, 0); X do X { X inkey(&x); X switch(x) X { X case 13: X break; X default: X tpw[i] = x; X i++; X break; X } X } X while ((i != 12) && (x != 13)); X tpw[i] = '\0'; X if (!strcmp(tpw, password1)) X { X wizard1 = TRUE; X check = TRUE; X } X else if (!strcmp(tpw, password2)) X { X wizard1 = TRUE; X wizard2 = TRUE; X check = TRUE; X } X msg_flag = FALSE; X erase_line(msg_line, msg_line); X return(check); X} X X X/* Weapon weight VS strength and dexterity -RAK- */ Xint attack_blows(weight, wtohit) Xint weight; Xint *wtohit; X{ X int adj_weight, blows; X struct stats *p_ptr; X X blows = 1; X *wtohit = 0; X p_ptr = &py.stats; X if ((p_ptr->cstr*15) < weight) X *wtohit = p_ptr->cstr*15 - weight; X else X { X if (p_ptr->cdex < 10) blows = 1; X else if (p_ptr->cdex < 19) blows = 2; X else if (p_ptr->cdex < 68) blows = 3; X else if (p_ptr->cdex < 108) blows = 4; X else if (p_ptr->cdex < 118) blows = 5; X else blows = 6; X adj_weight = ((p_ptr->cstr*10)/weight); X if (adj_weight < 2) blows = 1; X else if (adj_weight < 3) blows = (blows/3.0) + 1; X else if (adj_weight < 4) blows = (blows/2.5) + 1; X else if (adj_weight < 5) blows = (blows/2.25) + 1; X else if (adj_weight < 7) blows = (blows/2.00) + 1; X else if (adj_weight < 9) blows = (blows/1.75) + 1; X else blows = (blows/1.50) + 1; X } X return(blows); X} X X X/* Critical hits, Nasty way to die... -RAK- */ Xint critical_blow(weight, plus, dam) Xint weight, plus, dam; X{ X int critical; X X critical = dam; X /* Weight of weapon, plusses to hit, and character level all */ X /* contribute to the chance of a critical */ X if (randint(5000) <= (int)(weight+5*plus+3*py.misc.lev)) X { X weight += randint(650); X if (weight < 400) X { X critical = 2*dam + 5; X msg_print("It was a good hit! (x2 damage)"); X } X else if (weight < 700) X { X critical = 3*dam + 10; X msg_print("It was an excellent hit! (x3 damage)"); X } X else if (weight < 900) X { X critical = 4*dam + 15; X msg_print("It was a superb hit! (x4 damage)"); X } X else X { X critical = 5*dam + 20; X msg_print("It was a *GREAT* hit! (x5 damage)"); X } X } X return(critical); X} X X X/* Given direction "dir", returns new row, column location -RAK- */ Xint move(dir, y, x) Xint dir; Xint *y, *x; X{ X int new_row, new_col; X int bool; X X switch(dir) X { X case 1: X new_row = *y + 1; X new_col = *x - 1; X break; X case 2: X new_row = *y + 1; X new_col = *x; X break; X case 3: X new_row = *y + 1; X new_col = *x + 1; X break; X case 4: X new_row = *y; X new_col = *x - 1; X break; X case 5: X new_row = *y; X new_col = *x; X break; X case 6: X new_row = *y; X new_col = *x + 1; X break; X case 7: X new_row = *y - 1; X new_col = *x - 1; X break; X case 8: X new_row = *y - 1; X new_col = *x; X break; X case 9: X new_row = *y - 1; X new_col = *x + 1; X break; X } X bool = FALSE; X if ((new_row >= 0) && (new_row < cur_height)) X if ((new_col >= 0) && (new_col < cur_width)) X { X *y = new_row; X *x = new_col; X bool = TRUE; X } X return(bool); X} X X/* Saving throws for player character... -RAK- */ Xint player_saves(adjust) Xint adjust; X{ X if (randint(100) <= (py.misc.save + adjust)) X return(TRUE); X else X return(FALSE); X} X X X/* Init players with some belongings -RAK- */ Xchar_inven_init() X{ X int i, j, dummy; X X /* this is needed for bash to work right, it can't hurt anyway */ X for (i = 0; i < INVEN_ARRAY_SIZE; i++) X inventory[i] = blank_treasure; X X for (i = 0; i < 5; i++) X { X j = player_init[py.misc.pclass][i]; X inventory[INVEN_MAX] = inventory_init[j]; X inven_carry(&dummy); X } X} END_OF_misc2.c if test 40587 -ne `wc -c <misc2.c`; then echo shar: \"misc2.c\" unpacked with wrong size! fi # end of overwriting check fi echo shar: End of archive 9 \(of 16\). cp /dev/null ark9isdone MISSING="" for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 16 archives. rm -f ark[1-9]isdone ark[1-9][0-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0