games@tekred.TEK.COM (07/29/88)
Submitted by: "James E. Wilson" <wilson@ji.berkeley.edu> Comp.sources.games: Volume 5, Issue 50 Archive-name: umoria2/Part16 #! /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 16 (of 18)." # Contents: constants.h death.c desc.c magic.c main.c wizard.c # Wrapped by billr@saab on Wed Jul 13 11:16:36 1988 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'constants.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'constants.h'\" else echo shar: Extracting \"'constants.h'\" \(8906 characters\) sed "s/^X//" >'constants.h' <<'END_OF_FILE' X/*Note to the Wizard: */ X/* Tweaking these constants can *GREATLY* change the game. */ X/* Two years of constant tuning have generated these */ X/* values. Minor adjustments are encouraged, but you must */ X/* be very careful not to unbalance the game. Moria was */ X/* meant to be challenging, not a give away. Many */ X/* adjustments can cause the game to act strangely, or even*/ X/* cause errors. */ X X/* Current version number of Moria */ X#define CUR_VERSION 4.87 X X#ifndef TRUE X#define TRUE 1 X#endif X#ifndef FALSE X#define FALSE 0 X#endif X X/* Changing values below this line may be hazardous to your health! */ X X/* key bindings option */ X#define ORIGINAL 0 /* uses keypad for directions */ X#define ROGUE_LIKE 1 /* uses 'rogue' style keys for directions */ X X/* message line location */ X#define MSG_LINE 0 X X/* number of messages to save in a buffer */ X#define SAVED_MSGS 20 X X/* Dungeon size parameters */ X#define MAX_HEIGHT 66 /* Multiple of 11; >= 22 */ X#define MAX_WIDTH 198 /* Multiple of 33; >= 66 */ X#define SCREEN_HEIGHT 22 X#define SCREEN_WIDTH 66 X#define QUART_HEIGHT (SCREEN_HEIGHT / 4) X#define QUART_WIDTH (SCREEN_WIDTH / 4) X X/* Output dungeon section sizes */ X#define OUTPAGE_HEIGHT 44 /* 44 lines of dungeon per section */ X#define OUTPAGE_WIDTH 99 /* 100 columns of dungeon per section */ X X/* Dungeon generation values */ X/* Note: The entire design of dungeon can be changed by only */ X/* slight adjustments here. */ X#define DUN_TUN_RND 36 /* Random direction (4 is min) */ X#define DUN_TUN_CHG 70 /* Chance of changing direction (99 max) */ X#define DUN_TUN_FND 12 /* Distance for auto find to kick in */ X#define DUN_TUN_CON 15 /* Chance of extra tunneling */ X#define DUN_ROO_MEA 32 /* Mean of # of rooms, standard dev2 */ X#define DUN_TUN_PEN 25 /* % chance of room doors */ X#define DUN_TUN_JCT 15 /* % chance of doors at tunnel junctions */ X#define DUN_STR_DEN 5 /* Density of streamers */ X#define DUN_STR_RNG 2 /* Width of streamers */ X#define DUN_STR_MAG 3 /* Number of magma streamers */ X#define DUN_STR_MC 95 /* 1/x chance of treasure per magma */ X#define DUN_STR_QUA 2 /* Number of quartz streamers */ X#define DUN_STR_QC 55 /* 1/x chance of treasure per quartz */ X#define DUN_UNUSUAL 300 /* Level/x chance of unusual room */ X X/* Store constants */ X#define MAX_OWNERS 18 /* Number of owners to choose from */ X#define MAX_STORES 6 /* Number of different stores */ X#define STORE_INVEN_MAX 24 /* Max number of discrete objs in inven */ X#define STORE_CHOICES 26 /* NUMBER of items to choice stock from */ X#define STORE_MAX_INVEN 20 /* Max diff objs in stock before auto sell*/ X#define STORE_MIN_INVEN 14 /* Min diff objs in stock before auto buy*/ X#define STORE_TURN_AROUND 3 /* Amount of buying and selling normally */ X#define INVEN_INIT_MAX 105 /* Size of store init array */ X#define COST_ADJ 1.00 /* Adjust prices for buying and selling */ X X/* Treasure constants */ X#define INVEN_ARRAY_SIZE 35 /* Size of inventory array(Do not change)*/ X#define INVEN_MAX 34 /* index of highest entry in inventory array */ X#define MAX_OBJ_LEVEL 50 /* Maximum level of magic in dungeon */ X#define OBJ_GREAT 20 /* 1/n Chance of item being a Great Item */ X#define MAX_OBJECTS 344 /* Number of objects for universe */ X#define MAX_GOLD 18 /* Number of different types of gold */ X#define MAX_TALLOC 225 /* Max objects per level */ X#define TREAS_ROOM_ALLOC 7 /* Amount of objects for rooms */ X#define TREAS_ANY_ALLOC 2 /* Amount of objects for corridors */ X#define TREAS_GOLD_ALLOC 2 /* Amount of gold (and gems) */ X X/* Magic Treasure Generation constants */ X/* Note: Number of special objects, and degree of enchantments */ X/* can be adjusted here. */ X#define OBJ_STD_ADJ 1.25 /* Adjust STD per level */ X#define OBJ_STD_MIN 7 /* Minimum STD */ X#define OBJ_TOWN_LEVEL 7 /* Town object generation level */ X#define OBJ_BASE_MAGIC 15 /* Base amount of magic */ X#define OBJ_BASE_MAX 70 /* Max amount of magic */ X#define OBJ_DIV_SPECIAL 6 /* magic_chance/# special magic */ X#define OBJ_DIV_CURSED 1.3 /* magic_chance/# cursed items */ X X/* Constants describing limits of certain objects */ X#define OBJ_LAMP_MAX 15000 /* Maximum amount that lamp can be filled*/ X#define OBJ_BOLT_RANGE 18 /* Maximum range of bolts and balls */ X#define OBJ_RUNE_PROT 3000 /* Rune of protection resistance */ X X/* Creature constants */ X#define MAX_CREATURES 279 /* Number of creatures defined for univ */ X#define MAX_MALLOC 100+1 /* Max that can be allocated */ X#define MAX_MALLOC_CHANCE 160 /* 1/x chance of new monster each round */ X#define MAX_MONS_LEVEL 40 /* Maximum level of creatures */ X#define MAX_SIGHT 20 /* Maximum dis a creature can be seen */ X#define MAX_SPELL_DIS 20 /* Maximum dis creat. spell can be cast */ X#define MAX_MON_MULT 75 /* Maximum reproductions on a level */ X#define MON_MULT_ADJ 7 /* High value slows multiplication */ X#define MON_NASTY 50 /* Dun_level/x chance of high level creat*/ X#define MIN_MALLOC_LEVEL 14 /* Minimum number of monsters/level */ X#define MIN_MALLOC_TD 4 /* Number of people on town level (day) */ X#define MIN_MALLOC_TN 8 /* Number of people on town level (night)*/ X#define WIN_MON_TOT 2 /* Total number of "win" creatures */ X#define WIN_MON_APPEAR 50 /* Level where winning creatures begin */ X#define MON_SUMMON_ADJ 2 /* Adjust level of summoned creatures */ X#define MON_DRAIN_LIFE 2 /* Percent of player exp drained per hit */ X X/* Trap constants */ X#define MAX_TRAPA 18 /* Number of defined traps */ X#define MAX_TRAPB 19 /* Includes secret doors */ X X/* Descriptive constants */ X#define MAX_COLORS 67 /* Used with potions */ X#define MAX_MUSH 29 /* Used with mushrooms */ X#define MAX_WOODS 41 /* Used with staffs */ X#define MAX_METALS 31 /* Used with wands */ X#define MAX_ROCKS 52 /* Used with rings */ X#define MAX_AMULETS 39 /* Used with amulets */ X#define MAX_SYLLABLES 153 /* Used with scrolls */ X X/* Player constants */ X#define MAX_PLAYER_LEVEL 40 /* Maximum possible character level */ X#define MAX_RACES 8 /* Number of defined races */ X#define MAX_CLASS 6 /* Number of defined classes */ X#define USE_DEVICE 3 /* x> Harder devices x< Easier devices */ X#define MAX_BACKGROUND 128 /* Number of types of histories for univ */ X#define PLAYER_FOOD_FULL 10000/* Getting full */ X#define PLAYER_FOOD_MAX 15000/* Maximum food value, beyond is wasted */ X#define PLAYER_FOOD_FAINT 300/* Character begins fainting */ X#define PLAYER_FOOD_WEAK 1000/* Warn player that he is getting very low*/ X#define PLAYER_FOOD_ALERT 2000/* Warn player that he is getting low */ X#define PLAYER_REGEN_FAINT 0.0005 /* Regen factor when fainting */ X#define PLAYER_REGEN_WEAK 0.0015 /* Regen factor when weak */ X#define PLAYER_REGEN_NORMAL 0.0030 /* Regen factor when full */ X#define PLAYER_REGEN_HPBASE 0.0220 /* Min amount hp regen */ X#define PLAYER_REGEN_MNBASE 0.0080 /* Min amount mana regen */ X#define PLAYER_WEIGHT_CAP 130 /* "#"*(1/10 pounds) per strength point */ X#define PLAYER_EXIT_PAUSE 2 /* Pause time before player can re-roll */ X X/* Base to hit constants */ X#define BTH_LEV_ADJ 3 /* Adjust BTH per level */ X#define BTH_PLUS_ADJ 3 /* Adjust BTH per plus-to-hit */ X#define BTH_HIT 12 /* Automatic hit; 1/bth_hit */ X X/* table size for random() */ X#define STATE_SIZE 128 X X/* magic numbers for players inventory array */ X#define INVEN_WIELD 22 X#define INVEN_HEAD 23 X#define INVEN_NECK 24 X#define INVEN_BODY 25 X#define INVEN_ARM 26 X#define INVEN_HANDS 27 X#define INVEN_RIGHT 28 X#define INVEN_LEFT 29 X#define INVEN_FEET 30 X#define INVEN_OUTER 31 X#define INVEN_LIGHT 32 X#define INVEN_AUX 33 END_OF_FILE if test 8906 -ne `wc -c <'constants.h'`; then echo shar: \"'constants.h'\" unpacked with wrong size! fi # end of 'constants.h' fi if test -f 'death.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'death.c'\" else echo shar: Extracting \"'death.c'\" \(11299 characters\) sed "s/^X//" >'death.c' <<'END_OF_FILE' X#include <stdio.h> X#include <pwd.h> X#include <time.h> X#include <ctype.h> X#include <sys/types.h> X#include <sys/file.h> X X#include "constants.h" X#include "config.h" X#include "types.h" X#include "externs.h" X X#ifdef USG X#include <string.h> X#include <fcntl.h> X#else X#include <strings.h> X#endif X X#define MIN(a, b) ((a < b) ? a : b) 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#if defined(sun) || defined(USG) || defined(ultrix) Xlong lseek(); X#else Xoff_t lseek(); X#endif X#ifdef USG X#define L_SET 0 X#endif X X#if defined(ultrix) || defined(USG) Xvoid perror(); Xvoid exit(); X#endif X X#ifdef USG Xstruct passwd *getpwuid(); X#endif X Xchar *getlogin(); Xlong time(); X Xdate(day) Xchar *day; X{ X register char *tmp; X long clock; X X clock = time((long *) 0); X tmp = ctime(&clock); X tmp[11] = '\0'; X (void) strcpy(day, tmp); X} X X/* Centers a string within a 31 character string -JWT- */ Xchar *fill_str(p1) Xchar *p1; X{ X vtype s1, s2; X int i; X X s1[0] = '\0'; X s2[0] = '\0'; X i = (strlen(p1) / 2); X (void) strcpy(s1, pad(s2, " ", 15 - i)); X (void) strcat(s1, pad(p1, " ", 31)); X s1[31] = '\0'; X return (s1); X} X X X/* Prints a line to the screen efficiently -RAK- */ Xdprint(str, row) Xchar *str; Xint row; X{ X register int i, j, nblanks, xpos; X vtype prt_str; X char tmp_str[2]; X X tmp_str[1] = '\0'; /* yes, this is supposed to be a one */ X prt_str[0] = '\0'; X nblanks = 0; X xpos = 0; X for (i = 0; i < strlen(str); i++) X { X if (str[i] == ' ') X { X if (xpos >= 0) X { X nblanks++; X if (nblanks > 5) X { X nblanks = 0; X put_buffer(prt_str, row, xpos); X prt_str[0] = '\0'; X xpos = -1; X } X } X } X else X { X if (xpos == -1) X xpos = i; X if (nblanks > 0) X { X for (j = 0; j < nblanks; j++) X (void) strcat(prt_str, " "); X nblanks = 0; X } X tmp_str[0] = str[i]; X (void) strcat(prt_str, tmp_str); X } X } X if (xpos >= 0) X put_buffer(prt_str, row, xpos); X} X Xdisplay_scores() X{ X register int i = 0, j; X int fd; X high_scores score; X char list[20][256]; X X if (1 > (fd = open(MORIA_TOP, O_RDONLY, 0644))) X { X prt("Error opening top twenty file\n", 0, 0); X return ; X } X X while (0 < read(fd, (char *)&score, sizeof(high_scores))) X { X (void) sprintf(list[i], "%-7d%-15.15s%-10.10s%-10.10s%-5d%-25.25s%5d", X (int)score.points, score.name, X race[score.prace].trace, class[score.pclass].title, X (int)score.lev, score.died_from, score.dun_level); X i++; X } X X controlz(); X put_buffer("Points Name Race Class Lv Killed By Dun Lv", 0, 0); X for (j = 0; j < i; j++) X put_buffer(list[j], j + 1, 0); X pause_line(23); X} X X/* Prints the gravestone of the character -RAK- */ Xprint_tomb() X{ X vtype str1, str2, str3, str4, str5, str6, str7, str8; X vtype dstr[20]; X vtype fnam; X char command; X FILE *f1; X register int i; X char day[11]; X int flag; X char tmp_str[80]; X X date(day); X (void) strcpy(str1, fill_str(py.misc.name)); X (void) strcpy(str2, fill_str(py.misc.title)); X (void) strcpy(str3, fill_str(py.misc.tclass)); X (void) sprintf(str4, "Level : %d", (int)py.misc.lev); X (void) strcpy(str4, fill_str(str4)); X (void) sprintf(str5, "%d Exp", py.misc.exp); X (void) strcpy(str5, fill_str(str5)); X (void) sprintf(str6, "%d Au", py.misc.au); X (void) strcpy(str6, fill_str(str6)); X (void) sprintf(str7, "Died on Level : %d", dun_level); X (void) strcpy(str7, fill_str(str7)); X (void) strcpy(str8, fill_str(died_from)); X dstr[0][0] = '\0'; X (void) strcpy(dstr[1], " _______________________"); X (void) strcpy(dstr[2], " / \\ ___"); X (void) strcpy(dstr[3], X " / \\ ___ / \\ ___"); X (void) strcpy(dstr[4], X " / RIP \\ \\ : : / \\"); X (void) strcpy(dstr[5], X " / \\ : _;,,,;_ : :"); X (void) sprintf(dstr[6], " /%s\\,;_ _;,,,;_", str1); X (void) strcpy(dstr[7], " | the | ___"); X (void) sprintf(dstr[8], " | %s | / \\", str2); X (void) strcpy(dstr[9], " | | : :"); X (void) sprintf(dstr[10], " | %s | _;,,,;_ ____", str3); X (void) sprintf(dstr[11], " | %s | / \\", str4); X (void) sprintf(dstr[12], " | %s | : :", str5); X (void) sprintf(dstr[13], " | %s | : :", str6); X (void) sprintf(dstr[14], " | %s | _;,,,,;_", str7); X (void) strcpy(dstr[15], " | killed by |"); X (void) sprintf(dstr[16], " | %s |", str8); X (void) sprintf(dstr[17], " | %s |", day); X (void) strcpy(dstr[18], " *| * * * * * * | *"); X (void) strcpy(dstr[19], X "________)/\\\\_)_/___(\\/___(//_\\)/_\\//__\\\\(/_|_)_______"); X clear_screen(0, 0); X for (i = 0; i <= 19; i++) X dprint(dstr[i], i); X flush(); X if (get_com("Print to file? (Y/N)", &command)) X switch (command) X { X case 'y': X case 'Y': X prt("Enter Filename:", 0, 0); X flag = FALSE; X do X { X if (get_string(fnam, 0, 16, 60)) X { X if (strlen(fnam) == 0) X (void) strcpy(fnam, "MORIACHR.DIE"); X f1 = fopen(fnam, "w"); X if (f1 == NULL) X { X (void) sprintf(tmp_str, "Error creating> %s", fnam); X prt(tmp_str, 1, 0); X } X else X { X flag = TRUE; X for (i = 0; i <= 19; i++) X (void) fprintf(f1, "%s\n", dstr[i]); X } X (void) fclose(f1); X } X else X flag = TRUE; X } X while (!flag); X break; X default: X break; X } X} X X X/* Calculates the total number of points earned -JWT- */ Xint total_points() X{ X return (py.misc.max_exp + (100 * py.misc.max_lev)); X} X X X/* Enters a players name on the top twenty list -JWT- */ Xtop_twenty() X{ X register int i, j, k; X high_scores scores[20], myscore; X char *tmp; X X clear_screen(0, 0); X X if (wizard1) X exit_game(); X X if (panic_save == 1) X { X msg_print("Sorry, scores for games restored from panic save files are not saved."); X /* make sure player sees message before display_scores erases it */ X msg_print (" "); X display_scores (); X exit_game(); X } X X myscore.points = (long)total_points(); X myscore.dun_level = dun_level; X myscore.lev = py.misc.lev; X myscore.max_lev = py.misc.max_lev; X myscore.mhp = py.misc.mhp; X myscore.chp = py.misc.chp; X myscore.uid = getuid(); X /* First character of sex, lower case */ X myscore.sex = tolower(py.misc.sex[0]); X myscore.prace = py.misc.prace; X myscore.pclass = py.misc.pclass; X (void) strcpy(myscore.name, py.misc.name); X tmp = died_from; X if ('a' == *tmp) X { X if ('n' == *(++tmp)) X { X tmp++; X } X while (isspace(*tmp)) X { X tmp++; X } X } X (void) strncpy(myscore.died_from, tmp, strlen(tmp) - 1); X myscore.died_from[strlen(tmp) - 1] = '\0'; X /* Get rid of '.' at end of death description */ X X /* First, get a lock on the high score file so no-one else tries */ X /* to write to it while we are using it */ X#ifdef USG X /* no flock sytem call, ignore the problem for now */ X#else X if (0 != flock(highscore_fd, LOCK_EX)) X { X perror("Error gaining lock for score file"); X exit(1); X } X#endif X X /* Check to see if this score is a high one and where it goes */ X i = 0; X#if defined(sun) || defined(ultrix) || defined(USG) X (void) lseek(highscore_fd, (long)0, L_SET); X#else X (void) lseek(highscore_fd, (off_t)0, L_SET); X#endif X while ((i < 20) X && (0 != read(highscore_fd, (char *)&scores[i], sizeof(high_scores)))) X { X i++; X } X X j = 0; X while (j < i && (scores[j].points >= myscore.points)) X { X j++; X } X /* i is now how many scores we have, and j is where we put this score */ X X /* If its the first score, or it gets appended to the file */ X if (0 == i || (i == j && j < 20)) X { X#if defined(sun) || defined(ultrix) || defined(USG) X (void) lseek(highscore_fd, (long)(j * sizeof(high_scores)), L_SET); X#else X (void) lseek(highscore_fd, (off_t)(j * sizeof(high_scores)), L_SET); X#endif X (void) write(highscore_fd, (char *)&myscore, sizeof(high_scores)); X } X else if (j < i) X { X /* If it gets inserted in the middle */ X /* Bump all the scores up one place */ X for (k = MIN(i, 19); k > j ; k--) X { X#if defined(sun) || defined(ultrix) || defined(USG) X (void) lseek(highscore_fd, (long)(k * sizeof(high_scores)), L_SET); X#else X (void) lseek(highscore_fd, (off_t)(k * sizeof(high_scores)), L_SET); X#endif X (void) write(highscore_fd, (char *)&scores[k - 1], sizeof(high_scores)); X } X /* Write out your score */ X#if defined(sun) || defined(ultrix) || defined(USG) X (void) lseek(highscore_fd, (long)(j * sizeof(high_scores)), L_SET); X#else X (void) lseek(highscore_fd, (off_t)(j * sizeof(high_scores)), L_SET); X#endif X (void) write(highscore_fd, (char *)&myscore, sizeof(high_scores)); X } X X#ifdef USG X /* no flock sytem call, ignore the problem for now */ X#else X (void) flock(highscore_fd, LOCK_UN); X#endif X (void) close(highscore_fd); X display_scores(); X} X X X/* Change the player into a King! -RAK- */ Xkingly() X{ X register struct misc *p_ptr; X X /* Change the character attributes... */ X dun_level = 0; X /* need dot on the end to be consistent with creature.c */ X (void) strcpy(died_from, "Ripe Old Age."); X p_ptr = &py.misc; X p_ptr->lev += MAX_PLAYER_LEVEL; X if (p_ptr->sex[0] == 'M') X { X (void) strcpy(p_ptr->title, "Magnificent"); X (void) strcpy(p_ptr->tclass, "*King*"); X } X else X { X (void) strcpy(p_ptr->title, "Beautiful"); X (void) strcpy(p_ptr->tclass, "*Queen*"); X } X p_ptr->au += 250000; X p_ptr->max_exp += 5000000; X p_ptr->exp = p_ptr->max_exp; X X /* Let the player know that he did good... */ X clear_screen(0, 0); X dprint(" #", 1); X dprint(" #####", 2); X dprint(" #", 3); X dprint(" ,,, $$$ ,,,", 4); X dprint(" ,,==$ \"$$$$$\" $==,,", 5); X dprint(" ,$$ $$$ $$,", 6); X dprint(" *> <*> <*", 7); X dprint(" $$ $$$ $$", 8); X dprint(" \"$$ $$$ $$\"", 9); X dprint(" \"$$ $$$ $$\"", 10); X dprint(" *#########*#########*", 11); X dprint(" *#########*#########*", 12); X dprint(" Veni, Vidi, Vici!", 15); X dprint(" I came, I saw, I conquered!", 16); X if (p_ptr->sex[0] == 'M') X dprint(" All Hail the Mighty King!", 17); X else X dprint(" All Hail the Mighty Queen!", 17); X flush(); X pause_line(23); X} X X X/* Handles the gravestone end top-twenty routines -RAK- */ Xupon_death() X{ X /* What happens upon dying... -RAK- */ X if (total_winner) X kingly(); X print_tomb(); X top_twenty(); X exit_game(); X} END_OF_FILE if test 11299 -ne `wc -c <'death.c'`; then echo shar: \"'death.c'\" unpacked with wrong size! fi # end of 'death.c' fi if test -f 'desc.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'desc.c'\" else echo shar: Extracting \"'desc.c'\" \(8357 characters\) sed "s/^X//" >'desc.c' <<'END_OF_FILE' X#include <stdio.h> X X#include "constants.h" X#include "config.h" X#include "types.h" X#include "externs.h" X X#ifdef USG X#include <string.h> X#else X#include <strings.h> X#endif X X#ifdef sun /* correct SUN stupidity in the stdio.h file */ Xchar *sprintf(); X#endif X X/* Object descriptor routines */ X Xint is_a_vowel(ch) Xchar ch; X{ X switch(ch) X { X case 'a': case 'e': case 'i': case 'o': case 'u': X case 'A': case 'E': case 'I': case 'O': case 'U': X return(TRUE); X default: X return(FALSE); X } X} X X X/* Randomize colors, woods, and metals */ Xrandes() X{ X register int i, j; X vtype tmp; X X for (i = 0; i < MAX_COLORS; i++) X { X j = randint(MAX_COLORS) - 1; X (void) strcpy(tmp, colors[i]); X (void) strcpy(colors[i], colors[j]); X (void) strcpy(colors[j], tmp); X } X for (i = 0; i < MAX_WOODS; i++) X { X j = randint(MAX_WOODS) - 1; X (void) strcpy(tmp, woods[i]); X (void) strcpy(woods[i], woods[j]); X (void) strcpy(woods[j], tmp); X } X for (i = 0; i < MAX_METALS; i++) X { X j = randint(MAX_METALS) - 1; X (void) strcpy(tmp, metals[i]); X (void) strcpy(metals[i], metals[j]); X (void) strcpy(metals[j], tmp); X } X for (i = 0; i < MAX_ROCKS; i++) X { X j = randint(MAX_ROCKS) - 1; X (void) strcpy(tmp, rocks[i]); X (void) strcpy(rocks[i], rocks[j]); X (void) strcpy(rocks[j], tmp); X } X for (i = 0; i < MAX_AMULETS; i++) X { X j = randint(MAX_AMULETS) - 1; X (void) strcpy(tmp, amulets[i]); X (void) strcpy(amulets[i], amulets[j]); X (void) strcpy(amulets[j], tmp); X } X for (i = 0; i < MAX_MUSH; i++) X { X j = randint(MAX_MUSH) - 1; X (void) strcpy(tmp, mushrooms[i]); X (void) strcpy(mushrooms[i], mushrooms[j]); X (void) strcpy(mushrooms[j], tmp); X } X} X X X/* Return random title */ Xrantitle(title) Xchar *title; X{ X register int i, j, k; X X k = randint(2) + 1; X (void) strcpy(title, "Titled \""); X for (i = 0; i < k; i++) X { X for (j = 0; j < randint(2); j++) X (void) strcat(title, syllables[randint(MAX_SYLLABLES) - 1]); X if (i < k-1) X (void) strcat(title, " "); X } X (void) strcat(title, "\""); X} X X X/* Initialize all Potions, wands, staves, scrolls, ect... */ Xmagic_init() X{ X register int i, tmpv; X vtype tmps; X X set_seed(randes_state, randes_seed); X randes(); X for (i = 0; i < MAX_OBJECTS; i++) X { X tmpv = (0xFF & object_list[i].subval); X switch(object_list[i].tval) X { X case 75: case 76: X if (tmpv < MAX_COLORS) X insert_str(object_list[i].name, "%C", colors[tmpv]); X break; X case 70: case 71: X rantitle(tmps); X insert_str(object_list[i].name, "%T", tmps); X break; X case 45: X if (tmpv < MAX_ROCKS) X insert_str(object_list[i].name, "%R", rocks[tmpv]); X break; X case 40: if (tmpv < MAX_AMULETS) X insert_str(object_list[i].name, "%A", amulets[tmpv]); X break; X case 65: X if (tmpv < MAX_METALS) X insert_str(object_list[i].name, "%M", metals[tmpv]); X break; X case 55: X if (tmpv < MAX_WOODS) X insert_str(object_list[i].name, "%W", woods[tmpv]); X break; X case 80: X if (tmpv < MAX_MUSH) X insert_str(object_list[i].name, "%M", mushrooms[tmpv]); X break; X case 60: X /*if (tmpv < MAX_RODS) X insert_str(object_list[i].name, "%D", rods[tmpv])*/; X break; X default: X break; X } X } X reset_seed(); X} X X X/* Remove "Secret" symbol for identity of object */ Xknown1(object_str) Xchar *object_str; X{ X register int pos; X vtype str1, str2; X register char *string; X X string = index(object_str, '|'); X if (string) X pos = strlen(object_str) - strlen(string); X else X pos = -1; X if (pos >= 0) X { X (void) strncpy(str1, object_str, pos); X str1[pos] = '\0'; X (void) strcpy(str2, &object_str[pos+1]); X (void) strcpy(object_str, strcat(str1, str2)); X } X} X X X/* Remove "Secret" symbol for identity of plusses */ Xknown2(object_str) Xchar *object_str; X{ X register int pos; X vtype str1, str2; X register char *string; X X string = index(object_str, '^'); X if (string) X pos = strlen(object_str) - strlen(string); X else X pos = -1; X if (pos >= 0) X { X (void) strncpy(str1, object_str, pos); X str1[pos] = '\0'; X (void) strcpy(str2, &object_str[pos+1]); X (void) strcpy(object_str, strcat(str1, str2)); X } X} X X X/* Return string without quoted portion */ Xunquote(object_str) Xchar *object_str; X{ X register int pos0, pos1, pos2; X vtype str1, str2; X register char *string; X X string = index(object_str, '\"'); X if (string) X pos0 = strlen(string) - strlen(object_str); X else X pos0 = -1; X if (pos0 >= 0) X { X string = index(object_str, '~'); X if (string) X pos1 = strlen(string) - strlen(object_str); X else X pos1 = 0; X string = index(object_str, '|'); X if (string) X pos2 = strlen(string) - strlen(object_str); X else X pos2 = 0; X (void) strncpy(str1, object_str, pos1); X str1[pos1] = '\0'; X (void) strcpy(str2, &object_str[pos2+1]); X (void) strcpy(object_str, strcat(str1, str2)); X } X} X X X/* Somethings been identified */ Xidentify(item) Xtreasure_type item; X{ X register int i, x1, x2; X register treasure_type *t_ptr; X char *string; X X x1 = item.tval; X x2 = item.subval; X if (index(item.name, '|') != 0) X { X for (i = 0; i < MAX_TALLOC; i++) X { X t_ptr = &t_list[i]; X if ((t_ptr->tval == x1) && (t_ptr->subval == x2)) X { X unquote(t_ptr->name); X known1(t_ptr->name); X } X } X for (i = 0; i <= INVEN_MAX; i++) X { X t_ptr = &inventory[i]; X if ((t_ptr->tval == x1) && (t_ptr->subval == x2)) X { X unquote(t_ptr->name); X known1(t_ptr->name); X } X } X i = 0; X do X { X t_ptr = &object_list[i]; X if ((t_ptr->tval == x1) && (t_ptr->subval == x2)) X if ((string = index(t_ptr->name, '%')) && (string[0] == 'T')) X { X insert_str(t_ptr->name, " %T|", ""); X object_ident[i] = TRUE; X } X else X { X unquote(t_ptr->name); X known1(t_ptr->name); X object_ident[i] = TRUE; X } X i++; X } X while (i != MAX_OBJECTS); X } X} X X X/* Returns a description of item for inventory */ X/* pref indicates that there should be an article added (prefix) */ Xobjdes(out_val, ptr, pref) Xchar *out_val; Xint ptr; Xint pref; X{ X register int pos; X vtype tmp_val; X register treasure_type *i_ptr; X register char *string; X X i_ptr = &inventory[ptr]; X (void) strcpy(tmp_val, i_ptr->name); X string = index(tmp_val, '|'); X if (string) X pos = strlen(tmp_val) - strlen(string); X else X pos = -1; X if (pos >= 0) X { X tmp_val[pos] = '\0'; X } X string = index(tmp_val, '^'); X if (string) X pos = strlen(tmp_val) - strlen(string); X else X pos = -1; X if (pos >= 0) X { X tmp_val[pos] = '\0'; X } X if (!pref) X { X string = index(tmp_val, '('); X if (string) X pos = strlen(tmp_val) - strlen(string); X else X pos = -1; X if (pos >= 0) X { X tmp_val[pos] = '\0'; X } X } X insert_num(tmp_val, "%P1", i_ptr->p1, TRUE); X insert_num(tmp_val, "%P2", i_ptr->tohit, TRUE); X insert_num(tmp_val, "%P3", i_ptr->todam, TRUE); X insert_num(tmp_val, "%P4", i_ptr->toac, TRUE); X insert_num(tmp_val, "%P5", i_ptr->p1, FALSE); X insert_num(tmp_val, "%P6", i_ptr->ac, FALSE); X if (i_ptr->number != 1) X { X insert_str(tmp_val, "ch~", "ches"); X insert_str(tmp_val, "~", "s"); X } X else X insert_str(tmp_val, "~", ""); X if (pref) X { X if (index(tmp_val, '&') != 0) X { X insert_str(tmp_val, "&", ""); X if (i_ptr->number > 1) X (void) sprintf(out_val, "%d%s", (int)i_ptr->number, tmp_val); X else if (i_ptr->number < 1) X (void) sprintf(out_val, "%s%s", "no more", tmp_val); X else if (is_a_vowel(tmp_val[1])) X (void) sprintf(out_val, "an%s", tmp_val); X else X (void) sprintf(out_val, "a%s", tmp_val); X } X /* handle 'no more' case specially */ X else if (i_ptr->number < 1) X { X /* check for "some" at start */ X if (!strncmp("some", tmp_val, 4)) X (void) sprintf(out_val, "no more %s", &tmp_val[5]); X /* here if no article */ X else X (void) sprintf(out_val, "no more %s", tmp_val); X } X else X (void) strcpy(out_val, tmp_val); X (void) strcat(out_val, "."); X } X else X { X insert_str(tmp_val, "& ", ""); X if (!strncmp("some", tmp_val, 4)) X (void) strcpy(out_val, &tmp_val[5]); X else X (void) strcpy(out_val, tmp_val); X } X} END_OF_FILE if test 8357 -ne `wc -c <'desc.c'`; then echo shar: \"'desc.c'\" unpacked with wrong size! fi # end of 'desc.c' fi if test -f 'magic.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'magic.c'\" else echo shar: Extracting \"'magic.c'\" \(5981 characters\) sed "s/^X//" >'magic.c' <<'END_OF_FILE' X#include "constants.h" X#include "config.h" X#include "types.h" X#include "externs.h" X X X/* Throw a magic spell -RAK- */ Xcast() X{ X int i, j, item_val, dir; X int choice, chance, result; X int dumy, y_dumy, x_dumy; X int redraw; X register struct flags *f_ptr; X register struct misc *p_ptr; X register treasure_type *i_ptr; X register spell_type *m_ptr; X X reset_flag = TRUE; X if (py.flags.blind > 0) X msg_print("You can't see to read your spell book!"); X else if (no_light()) X msg_print("You have no light to read by."); X else if (py.flags.confused > 0) X msg_print("You are too confused..."); X else if (class[py.misc.pclass].mspell) X if (inven_ctr > 0) X { X if (find_range(90, -1, &i, &j)) X { X redraw = FALSE; X if (get_item(&item_val, "Use which spell-book?", X &redraw, i, j)) X { X if ((result = cast_spell("Cast which spell?", item_val, X &choice, &chance, &redraw)) == TRUE) X { X m_ptr = &magic_spell[py.misc.pclass][choice]; X reset_flag = FALSE; X X if (randint(100) < chance) X msg_print("You failed to get the spell off!"); X else X { X y_dumy = char_row; X x_dumy = char_col; X /* Spells... */ X choice++; X switch(choice) X { X case 1: X if (get_dir("Which direction?", &dir, X &dumy, &y_dumy, &x_dumy)) X fire_bolt(0, dir, char_row, char_col, X damroll("2d6")+1, "Magic Missile"); X break; X case 2: X (void) detect_monsters(); X break; X case 3: X teleport(10); X break; X case 4: X (void) light_area(char_row, char_col); X break; X case 5: X (void) hp_player(damroll("4d4"), "a magic spell."); X break; X case 6: X (void) detect_sdoor(); X (void) detect_trap(); X break; X case 7: X if (get_dir("Which direction?", &dir, X &dumy, &y_dumy, &x_dumy)) X fire_ball(2, dir, char_row, char_col, 9, X "Stinking Cloud"); X break; X case 8: X if (get_dir("Which direction?", &dir, X &dumy, &y_dumy, &x_dumy)) X (void) confuse_monster(dir, char_row, char_col); X break; X case 9: X if (get_dir("Which direction?", &dir, X &dumy, &y_dumy, &x_dumy)) X fire_bolt(1, dir, char_row, char_col, X damroll("3d8")+1, "Lightning Bolt"); X break; X case 10: X (void) td_destroy(); X break; X case 11: X if (get_dir("Which direction?", &dir, X &dumy, &y_dumy, &x_dumy)) X (void) sleep_monster(dir, char_row, char_col); X break; X case 12: X (void) cure_poison(); X break; X case 13: X teleport((int)(py.misc.lev*5)); X break; X case 14: X for (i = 22; i < INVEN_MAX; i++) X { X i_ptr = &inventory[i]; X i_ptr->flags = (i_ptr->flags & 0x7FFFFFFF); X } X break; X case 15: X if (get_dir("Which direction?", &dir, X &dumy, &y_dumy, &x_dumy)) X fire_bolt(4, dir, char_row, char_col, X damroll("4d8")+1, "Frost Bolt"); X break; X case 16: X if (get_dir("Which direction?", &dir, X &dumy, &y_dumy, &x_dumy)) X (void) wall_to_mud(dir, char_row, char_col); X break; X case 17: X (void) create_food(); X break; X case 18: X (void) recharge(20); X break; X case 19: X (void) sleep_monsters1(char_row, char_col); X break; X case 20: X if (get_dir("Which direction?", &dir, X &dumy, &y_dumy, &x_dumy)) X (void) poly_monster(dir, char_row, char_col); X break; X case 21: X (void) ident_spell(); X break; X case 22: X (void) sleep_monsters2(); X break; X case 23: X if (get_dir("Which direction?", &dir, X &dumy, &y_dumy, &x_dumy)) X fire_bolt(5, dir, char_row, char_col, X damroll("6d8")+1, "Fire Bolt"); X break; X case 24: X if (get_dir("Which direction?", &dir, X &dumy, &y_dumy, &x_dumy)) X (void)speed_monster(dir, char_row, char_col, -1); X break; X case 25: X if (get_dir("Which direction?", &dir, X &dumy, &y_dumy, &x_dumy)) X fire_ball(4, dir, char_row, char_col, 33, X "Frost Ball"); X break; X case 26: X (void) recharge(60); X break; X case 27: X if (get_dir("Which direction?", &dir, X &dumy, &y_dumy, &x_dumy)) X (void) teleport_monster(dir, char_row, char_col); X break; X case 28: X f_ptr = &py.flags; X f_ptr->fast += randint(20) + py.misc.lev; X break; X case 29: X if (get_dir("Which direction?", &dir, X &dumy, &y_dumy, &x_dumy)) X fire_ball(5, dir, char_row, char_col, 49, X "Fire Ball"); X break; X case 30: X (void) destroy_area(char_row, char_col); X break; X case 31: X (void) genocide(); X default: X break; X } X /* End of spells... */ X if (!reset_flag) X { X p_ptr = &py.misc; X p_ptr->exp += m_ptr->sexp; X prt_experience(); X m_ptr->sexp = 0; X } X } X p_ptr = &py.misc; X if (!reset_flag) X { X if (m_ptr->smana > p_ptr->cmana) X { X msg_print("You faint from the effort!"); X py.flags.paralysis = X randint(5*(int)(m_ptr->smana-(int)p_ptr->cmana)); X p_ptr->cmana = 0.0; X if (randint(3) == 1) X { X msg_print("You have damaged your health!"); X py.stats.ccon = de_statp(py.stats.ccon); X prt_constitution(); X } X } X else X p_ptr->cmana -= (double)m_ptr->smana; X prt_cmana(); X } X } X else if (result == -1) X msg_print("You don't know any spells in that book."); X } X else X if (redraw) draw_cave(); X } X else X msg_print("But you are not carrying any spell-books!"); X } X else X msg_print("But you are not carrying any spell-books!"); X else X msg_print("You can't cast spells!"); X} END_OF_FILE if test 5981 -ne `wc -c <'magic.c'`; then echo shar: \"'magic.c'\" unpacked with wrong size! fi # end of 'magic.c' fi if test -f 'main.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'main.c'\" else echo shar: Extracting \"'main.c'\" \(5549 characters\) sed "s/^X//" >'main.c' <<'END_OF_FILE' X/* Moria Version 4.8 COPYRIGHT (c) Robert Alan Koeneke */ X/* */ X/* I lovingly dedicate this game to hackers and adventurers */ X/* everywhere... */ X/* */ X/* */ X/* Designer and Programmer : Robert Alan Koeneke */ X/* University of Oklahoma */ X/* */ X/* Assistant Programmers : Jimmey Wayne Todd */ X/* University of Oklahoma */ X/* */ X/* Gary D. McAdoo */ X/* University of Oklahoma */ X/* */ X/* UNIX Port : James E. Wilson */ X/* UC Berkeley */ X/* wilson@ernie.Berkeley.EDU */ X/* ucbvax!ucbernie!wilson */ X/* */ X/* Moria may be copied and modified freely as long as the above */ X/* credits are retained. No one who-so-ever may sell or market */ X/* this software in any form without the expressed written consent */ X/* of the author Robert Alan Koeneke. */ X/* */ X X#include <curses.h> X#include <sys/types.h> X X#include "constants.h" X#include "config.h" X#include "types.h" X#include "externs.h" X X#ifdef USG X#include <string.h> X#else X#include <strings.h> X#endif X X#if defined(ultrix) || defined(sun) || defined(USG) Xint getuid(); Xint getgid(); X#else Xuid_t getuid(); Xuid_t getgid(); X#endif X X#if defined(ultrix) || defined(USG) Xvoid perror(); Xvoid exit(); X#endif X Xextern int key_bindings; X X/* Initialize, restore, and get the ball rolling... -RAK- */ Xmain(argc, argv) Xint argc; Xchar *argv[]; X{ X /* call this routine to grab a file pointer to the highscore file * X /* and prepare things to relinquish setuid privileges */ X init_scorefile(); X X if (0 != setuid(getuid())) X { X perror("Gack! Can't set permissions correctly! Exiting!\n"); X exit(0); X } X if (0 != setgid(getgid())) X { X perror("Gack! Can't set group id correctly! Exiting!\n"); X exit(0); X } X X /* use curses */ X init_curses(); X X /* catch those nasty signals */ X /* must come after init_curses as some of the signal handlers use curses */ X init_signals(); X X /* Build the secret wizard and god passwords */ X bpswd(); X X /* check for user interface option */ X key_bindings = KEY_BINDINGS; X if (argc >= 2) X { X if (!strcmp(argv[1], "-r")) X { X key_bindings = ROGUE_LIKE; X argv[1][0] = '\0'; X } X if (!strcmp(argv[1], "-o")) X { X key_bindings = ORIGINAL; X argv[1][0] = '\0'; X } X if (!strcmp(argv[1], "-s")) X { X display_scores(); X exit_game(); X } X } X X /* Check operating hours */ X /* If not wizard No_Control_Y */ X /* Check or create hours.dat, print message */ X /* if last arg is ^ then start as wizard, can not restore game also */ X if (argc >= 2) X intro(argv[argc - 1]); X else X intro(""); X X /* Some necessary initializations */ X /* all made into constants or initialized in variables.c */ X X /* Grab a random seed from the clock */ X init_seeds(); X X /* Sort the objects by level */ X sort_objects(); X X /* Init monster and treasure levels for allocate */ X init_m_level(); X init_t_level(); X X /* Init the store inventories */ X store_init(); X if (COST_ADJ != 1.00) price_adjust(); X X /* Generate a character, or retrieve old one... */ X if ((argc > 1) && strlen(argv[argc-1])) X { /* Retrieve character */ X generate = get_char(argv[argc-1]); X change_name(); X magic_init(); X } X else X { /* Create character */ X create_character(); X char_inven_init(); X if (class[py.misc.pclass].mspell) X { /* Magic realm */ X (void) learn_spell(&msg_flag); X gain_mana(int_adj()); X } X else if (class[py.misc.pclass].pspell) X { /* Clerical realm*/ X (void) learn_prayer(); X gain_mana(wis_adj()); X } X py.misc.cmana = (double)py.misc.mana; X magic_init(); X generate = TRUE; X } X X /* Begin the game */ X /* This determines the maximum player level */ X /* must be one less than real value so that prt_experience will work X correctly, otherwise it is possible to reach level 41 */ X player_max_exp = player_exp[MAX_PLAYER_LEVEL-1] * py.misc.expfact - 1; X clear_screen(0, 0); X prt_stat_block(); X /* prevent ^c quit from entering score into scoreboard until this point */ X character_generated = 1; X X /* Loop till dead, or exit */ X while(!death) { X if (generate) generate_cave(); /* New level */ X dungeon(); /* Dungeon logic */ X generate = TRUE; X } X upon_death(); /* Character gets buried */ X /* should never reach here, but just in case */ X return (0); X} END_OF_FILE if test 5549 -ne `wc -c <'main.c'`; then echo shar: \"'main.c'\" unpacked with wrong size! fi # end of 'main.c' fi if test -f 'wizard.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'wizard.c'\" else echo shar: Extracting \"'wizard.c'\" \(11268 characters\) sed "s/^X//" >'wizard.c' <<'END_OF_FILE' X#include <stdio.h> X X#include "constants.h" X#include "config.h" X#include "types.h" X#include "externs.h" X X#ifdef USG X#include <string.h> X#else X#include <strings.h> X#endif X X#ifdef sun /* correct SUN stupidity in the stdio.h file */ Xchar *sprintf(); X#endif X X X/* Print Moria credits -RAK- */ Xgame_version() X{ X vtype tmp_str; X X clear_screen(0, 0); X (void) sprintf(tmp_str, " Moria Version %f", CUR_VERSION); X put_buffer(tmp_str, 0, 0); X put_buffer("Version 0.1 : 03/25/83", 1, 0); X put_buffer("Version 1.0 : 05/01/84", 2, 0); X put_buffer("Version 2.0 : 07/10/84", 3, 0); X put_buffer("Version 3.0 : 11/20/84", 4, 0); X put_buffer("Version 4.0 : 01/20/85", 5, 0); X put_buffer("Modules :", 7, 0); X put_buffer(" V1.0 Dungeon Generator - RAK", 8, 0); X put_buffer(" Character Generator - RAK & JWT", 9, 0); X put_buffer(" Moria Module - RAK", 10, 0); X put_buffer(" Miscellaneous - RAK & JWT", 11, 0); X put_buffer(" V2.0 Town Level & Misc - RAK", 12, 0); X put_buffer(" V3.0 Internal Help & Misc - RAK", 13, 0); X put_buffer(" V4.0 Source Release Version - RAK", 14, 0); X put_buffer("Robert Alan Koeneke Jimmey Wayne Todd Jr.", 16, 0); X put_buffer("Student/University of Oklahoma Student/University of Oklahoma", X 17, 0); X put_buffer("119 Crystal Bend 1912 Tiffany Dr.", 18, 0); X put_buffer("Norman, OK 73069 Norman, OK 73071", 19, 0); X put_buffer("(405)-321-2925 (405) 360-6792", 20, 0); X pause_line(23); X clear_screen(0, 0); X put_buffer("UNIX MORIA Port by James E. Wilson", 2, 0); X put_buffer(" wilson@ernie.Berkeley.EDU", 3, 0); X put_buffer(" ucbvax!ucbernie!wilson", 4, 0); X put_buffer("This version is based on the VMS version 4.8", 6, 0); X put_buffer("but is no longer identical to the original VMS program.", 7, 0); X put_buffer("Please use care when referring to this program.", 8, 0); X put_buffer("Please call it 'umoria' or 'UNIX MORIA' or something", 9, 0); X put_buffer("similar to avoid confusion.", 10, 0); X pause_line(23); X draw_cave(); X} X X X/* Light up the dungeon -RAK- */ Xwizard_light() X{ X register cave_type *c_ptr; X register int k, l, i, j; X int flag; X X if (cave[char_row][char_col].pl) X flag = FALSE; X else X flag = TRUE; X for (i = 0; i < cur_height; i++) X for (j = 0; j < cur_width; j++) X if (set_floor(cave[i][j].fval)) X for (k = i-1; k <= i+1; k++) X for (l = j-1; l <= j+1; l++) X { X c_ptr = &cave[k][l]; X c_ptr->pl = flag; X if (!flag) X c_ptr->fm = FALSE; X } X prt_map(); X} X X X/* Wizard routine for gaining on stats -RAK- */ Xchange_character() X{ X int tmp_val; X vtype tmp_str; X register struct stats *s_ptr; X register struct misc *m_ptr; X X s_ptr = &py.stats; X prt("(3 - 118) Strength == ", 0, 0); X (void) get_string(tmp_str, 0, 25, 10); X tmp_val = -999; X (void) sscanf(tmp_str, "%d", &tmp_val); X if ((tmp_val > 2) && (tmp_val < 119)) X { X s_ptr->str = tmp_val; X s_ptr->cstr = tmp_val; X prt_strength(); X } X prt("(3 - 118) Intelligence == ", 0, 0); X (void) get_string(tmp_str, 0, 25, 10); X tmp_val = -999; X (void) sscanf(tmp_str, "%d", &tmp_val); X if ((tmp_val > 2) && (tmp_val < 119)) X { X s_ptr->intel = tmp_val; X s_ptr->cint = tmp_val; X prt_intelligence(); X } X prt("(3 - 118) Wisdom == ", 0, 0); X (void) get_string(tmp_str, 0, 25, 10); X tmp_val = -999; X (void) sscanf(tmp_str, "%d", &tmp_val); X if ((tmp_val > 2) && (tmp_val < 119)) X { X s_ptr->wis = tmp_val; X s_ptr->cwis = tmp_val; X prt_wisdom(); X } X prt("(3 - 118) Dexterity == ", 0, 0); X (void) get_string(tmp_str, 0, 25, 10); X tmp_val = -999; X (void) sscanf(tmp_str, "%d", &tmp_val); X if ((tmp_val > 2) && (tmp_val < 119)) X { X s_ptr->dex = tmp_val; X s_ptr->cdex = tmp_val; X prt_dexterity(); X } X prt("(3 - 118) Constitution == ", 0, 0); X (void) get_string(tmp_str, 0, 25, 10); X tmp_val = -999; X (void) sscanf(tmp_str, "%d", &tmp_val); X if ((tmp_val > 2) && (tmp_val < 119)) X { X s_ptr->con = tmp_val; X s_ptr->ccon = tmp_val; X prt_constitution(); X } X prt("(3 - 118) Charisma == ", 0, 0); X (void) get_string(tmp_str, 0, 25, 10); X tmp_val = -999; X (void) sscanf(tmp_str, "%d", &tmp_val); X if ((tmp_val > 2) && (tmp_val < 119)) X { X s_ptr->chr = tmp_val; X s_ptr->cchr = tmp_val; X prt_charisma(); X } X X m_ptr = &py.misc; X prt("(1 - 32767) Hit points == ", 0, 0); X (void) get_string(tmp_str, 0, 25, 10); X tmp_val = -1; X (void) sscanf(tmp_str, "%d", &tmp_val); X if ((tmp_val > 0) && (tmp_val < 32768)) X { X m_ptr->mhp = tmp_val; X m_ptr->chp = (double)tmp_val; X prt_mhp(); X prt_chp(); X } X prt("(0 - 32767) Mana == ", 0, 0); X (void) get_string(tmp_str, 0, 25, 10); X tmp_val = -999; X (void) sscanf(tmp_str, "%d", &tmp_val); X if ((tmp_val > -1) && (tmp_val < 32768)) X { X m_ptr->mana = tmp_val; X m_ptr->cmana = (double)tmp_val; X prt_cmana(); X } X (void) sprintf(tmp_str, "Current==%d (0-200) Searching == ", m_ptr->srh); X tmp_val = strlen(tmp_str); X prt(tmp_str, 0, 0); X (void) get_string(tmp_str, 0, tmp_val, 10); X tmp_val = -999; X (void) sscanf(tmp_str, "%d", &tmp_val); X if ((tmp_val > -1) && (tmp_val < 201)) X m_ptr->srh = tmp_val; X (void) sprintf(tmp_str, "Current==%d (0-10) Stealth == ", m_ptr->stl); X tmp_val = strlen(tmp_str); X prt(tmp_str, 0, 0); X (void) get_string(tmp_str, 0, tmp_val, 10); X tmp_val = -999; X (void) sscanf(tmp_str, "%d", &tmp_val); X if ((tmp_val > -1) && (tmp_val < 11)) X m_ptr->stl = tmp_val; X (void) sprintf(tmp_str, "Current==%d (0-200) Disarming == ", m_ptr->disarm); X tmp_val = strlen(tmp_str); X prt(tmp_str, 0, 0); X (void) get_string(tmp_str, 0, tmp_val, 10); X tmp_val = -999; X (void) sscanf(tmp_str, "%d", &tmp_val); X if ((tmp_val > -1) && (tmp_val < 201)) X m_ptr->disarm = tmp_val; X (void) sprintf(tmp_str, "Current==%d (0-100) Save == ", m_ptr->save); X tmp_val = strlen(tmp_str); X prt(tmp_str, 0, 0); X (void) get_string(tmp_str, 0, tmp_val, 10); X tmp_val = -999; X (void) sscanf(tmp_str, "%d", &tmp_val); X if ((tmp_val > -1) && (tmp_val < 201)) X m_ptr->save = tmp_val; X (void) sprintf(tmp_str, "Current==%d (0-200) Base to hit == ", m_ptr->bth); X tmp_val = strlen(tmp_str); X prt(tmp_str, 0, 0); X (void) get_string(tmp_str, 0, tmp_val, 10); X tmp_val = -999; X (void) sscanf(tmp_str, "%d", &tmp_val); X if ((tmp_val > -1) && (tmp_val < 201)) X m_ptr->bth = tmp_val; X (void) sprintf(tmp_str, "Current==%d (0-200) Bows/Throwing == ", X m_ptr->bthb); X tmp_val = strlen(tmp_str); X prt(tmp_str, 0, 0); X (void) get_string(tmp_str, 0, tmp_val, 10); X tmp_val = -999; X (void) sscanf(tmp_str, "%d", &tmp_val); X if ((tmp_val > -1) && (tmp_val < 201)) X m_ptr->bthb = tmp_val; X (void) sprintf(tmp_str, "Current==%d Gold == ", m_ptr->au); X tmp_val = strlen(tmp_str); X prt(tmp_str, 0, 0); X (void) get_string(tmp_str, 0, tmp_val, 10); X tmp_val = -999; X (void) sscanf(tmp_str, "%d", &tmp_val); X if (tmp_val > -1) X { X m_ptr->au = tmp_val; X prt_gold(); X } X X erase_line(MSG_LINE, 0); X py_bonuses(blank_treasure, 0); X} X X X/* Wizard routine for creating objects -RAK- */ Xwizard_create() X{ X int tmp_val; X vtype tmp_str; X register int flag; X register treasure_type *i_ptr; X register cave_type *c_ptr; X char command; X X msg_print("Warning: This routine can cause fatal error."); X /* make sure player sees the message */ X msg_print(" "); X msg_flag = FALSE; X i_ptr = &inventory[INVEN_MAX]; X prt("Name : ", 0, 0); X if (get_string(tmp_str, 0, 9, 80)) X (void) strcpy(i_ptr->name, tmp_str); X else X (void) strcpy(i_ptr->name, "& Wizard Object!"); X do X { X prt("Tval : ", 0, 0); X (void) get_string(tmp_str, 0, 9, 10); X tmp_val = 0; X (void) sscanf(tmp_str, "%d", &tmp_val); X flag = TRUE; X switch(tmp_val) X { X case 1: case 13: case 15 : i_ptr->tchar = '~'; break; X case 2: i_ptr->tchar = '&'; break; X case 10: i_ptr->tchar = '{'; break; X case 11: i_ptr->tchar = '{'; break; X case 12: i_ptr->tchar = '{'; break; X case 20: i_ptr->tchar = '}'; break; X case 21: i_ptr->tchar = '/'; break; X case 22: i_ptr->tchar = '\\'; break; X case 23: i_ptr->tchar = '|'; break; X case 25: i_ptr->tchar = '\\'; break; X case 30: i_ptr->tchar = ']'; break; X case 31: i_ptr->tchar = ']'; break; X case 32: i_ptr->tchar = '('; break; X case 33: i_ptr->tchar = ']'; break; X case 34: i_ptr->tchar = ')'; break; X case 35: i_ptr->tchar = '['; break; X case 36: i_ptr->tchar = '('; break; X case 40: i_ptr->tchar = '\''; break; X case 45: i_ptr->tchar = '='; break; X case 55: i_ptr->tchar = '_'; break; X case 60: i_ptr->tchar = '-'; break; X case 65: i_ptr->tchar = '-'; break; X case 70: case 71: i_ptr->tchar = '?'; break; X case 75: case 76: case 77: i_ptr->tchar = '!'; break; X case 80: i_ptr->tchar = ','; break; X case 90: i_ptr->tchar = '?'; break; X case 91: i_ptr->tchar = '?'; break; X default: flag = FALSE; break; X } X } X while (!flag); X i_ptr->tval = tmp_val; X prt("Subval : ", 0, 0); X (void) get_string(tmp_str, 0, 9, 10); X tmp_val = 1; X (void) sscanf(tmp_str, "%d", &tmp_val); X i_ptr->subval = tmp_val; X prt("Weight : ", 0, 0); X (void) get_string(tmp_str, 0, 9, 10); X tmp_val = 1; X (void) sscanf(tmp_str, "%d", &tmp_val); X i_ptr->weight = tmp_val; X prt("Number : ", 0, 0); X (void) get_string(tmp_str, 0, 9, 10); X tmp_val = 1; X (void) sscanf(tmp_str, "%d", &tmp_val); X i_ptr->number = tmp_val; X prt("Damage : ", 0, 0); X (void) get_string(tmp_str, 0, 9, 5); X (void) strcpy(i_ptr->damage, tmp_str); X prt("+To hit: ", 0, 0); X (void) get_string(tmp_str, 0, 9, 10); X tmp_val = 0; X (void) sscanf(tmp_str, "%d", &tmp_val); X i_ptr->tohit = tmp_val; X prt("+To dam: ", 0, 0); X (void) get_string(tmp_str, 0, 9, 10); X tmp_val = 0; X (void) sscanf(tmp_str, "%d", &tmp_val); X i_ptr->todam = tmp_val; X prt("AC : ", 0, 0); X (void) get_string(tmp_str, 0, 9, 10); X tmp_val = 0; X (void) sscanf(tmp_str, "%d", &tmp_val); X i_ptr->ac = tmp_val; X prt("+To AC : ", 0, 0); X (void) get_string(tmp_str, 0, 9, 10); X tmp_val = 0; X (void) sscanf(tmp_str, "%d", &tmp_val); X i_ptr->toac = tmp_val; X prt("P1 : ", 0, 0); X (void) get_string(tmp_str, 0, 9, 10); X tmp_val = 0; X (void) sscanf(tmp_str, "%d", &tmp_val); X i_ptr->p1 = tmp_val; X prt("Flags (In HEX): ", 0, 0); X i_ptr->flags = get_hex_value(0, 16, 8); X prt("Cost : ", 0, 0); X (void) get_string(tmp_str, 0, 9, 10); X tmp_val = 0; X (void) sscanf(tmp_str, "%d", &tmp_val); X i_ptr->cost = tmp_val; X X prt("Level : ", 0, 0); X (void) get_string(tmp_str, 0, 10, 10); X tmp_val = 0; X (void) sscanf(tmp_str, "%d", &tmp_val); X i_ptr->level = tmp_val; X X if (get_com("Allocate? (Y/N)", &command)) X switch(command) X { X case 'y': case 'Y': X popt(&tmp_val); X t_list[tmp_val] = inventory[INVEN_MAX]; X c_ptr = &cave[char_row][char_col]; X if (c_ptr->tptr != 0) X (void) delete_object(char_row, char_col); X c_ptr->tptr = tmp_val; X msg_print("Allocated..."); X break; X default: X msg_print("Aborted..."); X break; X } X inventory[INVEN_MAX] = blank_treasure; X} END_OF_FILE if test 11268 -ne `wc -c <'wizard.c'`; then echo shar: \"'wizard.c'\" unpacked with wrong size! fi # end of 'wizard.c' fi echo shar: End of archive 16 \(of 18\). cp /dev/null ark16isdone MISSING="" for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 18 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