-+-+-+-+-+-+-+-+ START OF PART 55 -+-+-+-+-+-+-+-+ X`09 else if (j & holder) X#else X`09 else if (j & CM_SPECIAL) X#endif X`09 roff(", "); X`09 else X`09 roff(" and "); X`09 roff(desc_move`5Bi`5D); X`09`7D X `7D X if (!k) X roff("."); X /* Do we know its special weaknesses? Most cdefense flags. */ X k = TRUE; X j = rcdefense; X for (i = 0; j & CD_WEAKNESS; i++) X `7B X if (j & (CD_FROST << i)) X`09`7B X`09 j &= `7E(CD_FROST << i); X`09 if (k) X`09 `7B X`09 roff(" It is susceptible to "); X`09 k = FALSE; X`09 `7D X`09 else if (j & CD_WEAKNESS) X`09 roff(", "); X`09 else X`09 roff(" and "); X`09 roff(desc_weakness`5Bi`5D); X`09`7D X `7D X if (!k) X roff("."); X if (rcdefense & CD_INFRA) X roff(" It is warm blooded"); X if (rcdefense & CD_NO_SLEEP) X `7B X if (rcdefense & CD_INFRA) X`09roff(", and"); X else X`09roff(" It"); X roff(" cannot be charmed or slept"); X `7D X if (rcdefense & (CD_NO_SLEEP`7CCD_INFRA)) X roff("."); X /* Do we know how aware it is? */ X if (((mp->r_wake * mp->r_wake) > cp->sleep) `7C`7C mp->r_ignore == MAX_UCH VAR `7C`7C X (cp->sleep == 0 && mp->r_kills >= 10)) X `7B X roff(" It "); X if(cp->sleep > 200) X`09roff("prefers to ignore"); X else if(cp->sleep > 95) X`09roff("pays very little attention to"); X else if(cp->sleep > 75) X`09roff("pays little attention to"); X else if(cp->sleep > 45) X`09roff("tends to overlook"); X else if(cp->sleep > 25) X`09roff("takes quite a while to see"); X else if(cp->sleep > 10) X`09roff("takes a while to see"); X else if(cp->sleep > 5) X`09roff("is fairly observant of"); X else if(cp->sleep > 3) X`09roff("is observant of"); X else if(cp->sleep > 1) X`09roff("is very observant of"); X else if(cp->sleep != 0) X`09roff("is vigilant for"); X else X`09roff("is ever vigilant for"); X (void) sprintf(temp, " intruders, which it may notice from %d feet.", X`09`09 10 * cp->aaf); X roff(temp); X `7D X /* Do we know what it might carry? */ X#ifdef ATARIST_MWC X holder = CM_CARRY_OBJ`7CCM_CARRY_BOLD; X if (rcmove & holder) X#else X if (rcmove & (CM_CARRY_OBJ`7CCM_CARRY_GOLD)) X#endif X `7B X roff(" It may"); X#ifdef ATARIST_MWC X j = (rcmove & (holder = CM_TREASURE)) >> CM_TR_SHIFT; X#else X j = (rcmove & CM_TREASURE) >> CM_TR_SHIFT; X#endif X if (j == 1) X`09`7B X#ifdef ATARIST_MWC X`09 if ((cp->cmove & (holder = CM_TREASURE)) == CM_60_RANDOM) X#else X`09 if ((cp->cmove & CM_TREASURE) == CM_60_RANDOM) X#endif X`09 roff(" sometimes"); X`09 else X`09 roff(" often"); X`09`7D X#ifdef ATARIST_MWC X else if ((j == 2) && ((cp->cmove & (holder = CM_TREASURE)) == X#else X else if ((j == 2) && ((cp->cmove & CM_TREASURE) == X#endif X`09`09`09 (CM_60_RANDOM`7CCM_90_RANDOM))) X`09roff (" often"); X roff(" carry"); X p = " objects"; X if (j == 1) X`09p = " an object"; X else if (j == 2) X`09roff(" one or two"); X else X`09`7B X`09 (void) sprintf(temp, " up to %ld", j); X`09 roff(temp); X`09`7D X#ifdef ATARIST_MWC X if (rcmove & (holder = CM_CARRY_OBJ)) X#else X if (rcmove & CM_CARRY_OBJ) X#endif X`09`7B X`09 roff(p); X#ifdef ATARIST_MWC X`09 if (rcmove & (holder = CM_CARRY_GOLD)) X#else X`09 if (rcmove & CM_CARRY_GOLD) X#endif X`09 `7B X`09 roff(" or treasure"); X`09 if (j > 1) X`09`09roff("s"); X`09 `7D X`09 roff("."); X`09`7D X else if (j != 1) X`09roff(" treasures."); X else X`09roff(" treasure."); X `7D X X /* We know about attacks it has used on us, and maybe the damage they do. V */ X /* k is the total number of known attacks, used for punctuation */ X k = 0; X for (j = 0; j < 4; j++) X /* Turbo C needs a 16 bit int for the array index. */ X if (mp->r_attacks`5B(int)j`5D) X k++; X pu = cp->damage; X /* j counts the attacks as printed, used for punctuation */ X j = 0; X for (i = 0; *pu != 0 && i < 4; pu++, i++) X `7B X int att_type, att_how, d1, d2; X X /* don't print out unknown attacks */ X if (!mp->r_attacks`5Bi`5D) X`09continue; X X att_type = monster_attacks`5B*pu`5D.attack_type; X att_how = monster_attacks`5B*pu`5D.attack_desc; X d1 = monster_attacks`5B*pu`5D.attack_dice; X d2 = monster_attacks`5B*pu`5D.attack_sides; X X j++; X if (j == 1) X`09roff(" It can "); X else if (j == k) X`09roff(", and "); X else X`09roff(", "); X X if (att_how > 19) X`09att_how = 0; X roff(desc_amethod`5Batt_how`5D); X if (att_type != 1 `7C`7C d1 > 0 && d2 > 0) X`09`7B X`09 roff(" to "); X`09 if (att_type > 24) X`09 att_type = 0; X`09 roff(desc_atype`5Batt_type`5D); X`09 if (d1 && d2) X`09 `7B X`09 if (knowdamage(cp->level, mp->r_attacks`5Bi`5D, d1*d2)) X`09`09`7B X`09`09 if (att_type == 19)`09/* Loss of experience */ X`09`09 roff(" by"); X`09`09 else X`09`09 roff(" with damage"); X`09`09 (void) sprintf(temp, " %dd%d", d1, d2 ); X`09`09 roff(temp); X`09`09`7D X`09 `7D X`09`7D X `7D X if (j) X roff("."); X else if (k > 0 && mp->r_attacks`5B0`5D >= 10) X roff(" It has no physical attacks."); X else X roff(" Nothing is known about its attack."); X /* Always know the win creature. */ X#ifdef ATARIST_MWC X if (cp->cmove & (holder = CM_WIN)) X#else X if (cp->cmove & CM_WIN) X#endif X roff(" Killing one of these wins the game!"); X roff("\n"); X prt("--pause--", roffpline, 0); X if (wizard) X *mp = save_mem; X return inkey(); X`7D X X/* Print out strings, filling up lines as we go. */ Xstatic void roff(p) Xregister char *p; X`7B X register char *q, *r; X X while (*p) X `7B X *roffp = *p; X if (*p == '\n' `7C`7C roffp >= roffbuf + sizeof(roffbuf)-1) X`09`7B X`09 q = roffp; X`09 if (*p != '\n') X`09 while (*q != ' ') X`09 q--; X`09 *q = 0; X`09 prt(roffbuf, roffpline, 0); X`09 roffpline++; X`09 r = roffbuf; X`09 while (q < roffp) X`09 `7B X`09 q++; X`09 *r = *q; X`09 r++; X`09 `7D X`09 roffp = r; X`09`7D X else X`09roffp++; X p++; X `7D X`7D $ CALL UNPACK RECALL.C;1 493169903 $ create 'f' X/* source/rnd.c: random number generator X X Copyright (c) 1989-92 James E. Wilson X X This software may be copied and distributed for educational, research, an Vd X not for profit purposes provided that this copyright and statement are X included in all such copies. */ X X#include "config.h" X#include "constant.h" X#include "types.h" X X/* Define this to compile as a standalone test */ X/* #define TEST_RNG */ X X/* This alg uses a prime modulus multiplicative congruential generator X (PMMLCG), also known as a Lehmer Grammer, which satisfies the following X properties X X (i)`09 modulus: m - a large prime integer X (ii)`09 multiplier: a - an integer in the range 2, 3, ..., m - 1 X (iii) z`5Bn+1`5D = f(z`5Bn`5D), for n = 1, 2, ... X (iv)`09 f(z) = az mod m X (v)`09 u`5Bn`5D = z`5Bn`5D / m, for n = 1, 2, ... X X The sequence of z's must be initialized by choosing an initial seed X z`5B1`5D from the range 1, 2, ..., m - 1. The sequence of z's is a pseud Vo- X random sequence drawn without replacement from the set 1, 2, ..., m - 1. X The u's form a psuedo-random sequence of real numbers between (but not X including) 0 and 1. X X Schrage's method is used to compute the sequence of z's. X Let m = aq + r, where q = m div a, and r = m mod a. X Then f(z) = az mod m = az - m * (az div m) = X`09 = gamma(z) + m * delta(z) X Where gamma(z) = a(z mod q) - r(z div q) X and`09 delta(z) = (z div q) - (az div m) X X If r < q, then for all z in 1, 2, ..., m - 1: X (1) delta(z) is either 0 or 1 X (2) both a(z mod q) and r(z div q) are in 0, 1, ..., m - 1 X (3) absolute value of gamma(z) <= m - 1 X (4) delta(z) = 1 iff gamma(z) < 0 X X Hence each value of z can be computed exactly without overflow as long X as m can be represented as an integer. X */ X X/* a good random number generator, correct on any machine with 32 bit X integers, this algorithm is from: X XStephen K. Park and Keith W. Miller, "Random Number Generators: X`09Good ones are hard to find", Communications of the ACM, October 1988, X`09vol 31, number 10, pp. 1192-1201. X X If this algorithm is implemented correctly, then if z`5B1`5D = 1, then X z`5B10001`5D will equal 1043618065 X X Has a full period of 2`5E31 - 1. X Returns integers in the range 1 to 2`5E31-1. X */ X X#define RNG_M 2147483647L /* m = 2`5E31 - 1 */ X#define RNG_A 16807L X#define RNG_Q 127773L`09 /* m div a */ X#define RNG_R 2836L`09 /* m mod a */ X X/* 32 bit seed */ Xstatic int32u rnd_seed; X Xint32u get_rnd_seed () X`7B X return rnd_seed; X`7D X Xvoid set_rnd_seed (seedval) Xint32u seedval; X`7B X /* set seed to value between 1 and m-1 */ X X rnd_seed = (seedval % (RNG_M - 1)) + 1; X`7D X X/* returns a pseudo-random number from set 1, 2, ..., RNG_M - 1 */ Xint32 rnd () X`7B X register long low, high, test; X X high = rnd_seed / RNG_Q; X low = rnd_seed % RNG_Q; X test = RNG_A * low - RNG_R * high; X if (test > 0) X rnd_seed = test; X else X rnd_seed = test + RNG_M; X return rnd_seed; X`7D X X#ifdef TEST_RNG X Xmain () X`7B X long i, random; X X set_rnd_seed (0L); X X for (i = 1; i < 10000; i++) X (void) rnd (); X X random = rnd (); X printf ("z`5B10001`5D = %ld, should be 1043618065\n", random); X if (random == 1043618065L) X printf ("success!!!\n"); X`7D X X#endif $ CALL UNPACK RND.C;1 121253953 $ create 'f' XCommand summary: (@ is optional count, `7E is direction, `5ER redraws, ESC a Vborts) X c `7E Close a door. `7C C Character player descrip Vtion. X d Drop an item. `7C @ D `7E Disarm a trap/chest. X e Equipment list. `7C E Eat some food. X@ f `7E Force (bash) item or mons.`7C F Fill lamp with oil. X i Inventory list. `7C G Gain new magic spells. X m magic spell casting. `7C M Map, show reduced size. X@ o `7E Open a door/chest. `7C P Peruse a book. X p Pray. `7C Q Quit the game. X q Quaff a potion. `7C @ R Rest (Count or *=restore). X r Read a scroll. `7C @ S `7E Spike a door. X@ s Search for traps or doors.`7C T Take off an item. X t Throw an item. `7C V View scores. X v Version info `7C W Where: locate self. X w Wear/Wield an item. `7C X Exchange weapon. X x `7E Examine surroundings `7C Z Zap a staff. X z Zap a wand. `7C # Search Mode. X = Set options. `7C < Go up an up-staircase. X / Identify a character. `7C > Go down a down-staircase. X@ CTRL-P Previous message review `7C `7B Inscribe an object. X@ - `7E Move without pickup. `7C ? Type this page. X@ CTRL `7E Tunnel in a direction. `7C CTRL-X Save character and exit. X@ SHIFT `7E Run in direction. `7C @ `7E For movement. XDirections: y k u X h . l `5B. is stay`5D X b j n X XTo give a count to a command, type the number in digits, then the command. XA count of 0 defaults to a count of 99. Counts only work with some commands, Xand will be terminated by the same things that end a rest or a run. In Xparticular, typing any character during the execution of a counted command Xwill terminate the command. Counted searches or tunnels will terminate on Xsuccess, or if you are attacked. A count with control-P will specify the Xnumber of previous messages to display. X XControl-R will redraw the screen whenever it is input, not only at command Xlevel. Control commands may be entered with a single key stroke, or with two Xkey strokes by typing `5E and then a letter. X XType ESCAPE to abort the look command at any point. X XSome commands will prompt for a spell, or an inventory item. Selection is Xby an alphabetic character - entering a capital causes a desription to be Xprinted, and the selection may be aborted. X XTyping `60R*' will make you rest until both your mana and your hp reach thei Vr Xmaximum values. X XUsing repeat counts with the tunnel left command does not work well, because Xtunnel left is the backspace character, and will delete the number you have Xjust typed in. To avoid this, you can either enter `5EH as two characters X(`5E and then H), or you can type ' ' (i.e. the space character) after the Xnumber at which point you will get a command prompt and backspace will Xwork correctly. $ CALL UNPACK ROGLCMDS.HLP;1 51828139 $ create 'f' X* - Wizard light. X: - Map area. X\ - Wizard Help. X`5EA - Remove Curse and Cure all maladies. X`5ED - Down/Up n levels. X`5EE - Change character. X`5EF - Delete monsters. X`5EG - Allocate treasures. X`5EI - Identify. X`5EO - Print random objects sample. X`5ET - Teleport player. X`5EW - Wizard password on/off. X@ - Create any object *CAN CAUSE FATAL ERROR* X+ - Gain experience. X& - Summon monster. $ CALL UNPACK RWIZCMDS.HLP;1 1010713587 $ create 'f' X/* source/save.c: save and restore games and monster memory info X X Copyright (c) 1989-92 James E. Wilson, Robert A. Koeneke X X This software may be copied and distributed for educational, research, an Vd X not for profit purposes provided that this copyright and statement are X included in all such copies. */ X X/* For debugging the savefile code on systems with broken compilers. */ X#if 0 X#define DEBUG(x)`09x X#else X#define DEBUG(x) X#endif X X#include X X#ifndef STDIO_LOADED X#define STDIO_LOADED X#endif X X#ifdef __TURBOC__ X#include`09 X#endif /* __TURBOC__ */ X`20 X#include "config.h" X#include "constant.h" X#include "types.h" X X#ifndef USG X/* stuff only needed for Berkeley UNIX */ X#include X#include X#include X#endif X X#ifdef VMS X#include X#include X#else X#ifdef USG X#ifndef ATARIST_MWC X#include X#ifndef ATARIST_TC +-+-+-+-+-+-+-+- END OF PART 55 +-+-+-+-+-+-+-+-