home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume9 / umoria3 / part26 < prev    next >
Encoding:
Internet Message Format  |  1990-05-21  |  60.5 KB

  1. Path: uunet!zephyr.ens.tek.com!tekred!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v09i081:  umoria3 - single player dungeon simulation (ver. 5.2), Part26/31
  5. Message-ID: <5616@tekred.CNA.TEK.COM>
  6. Date: 17 May 90 16:29:21 GMT
  7. Sender: news@tekred.CNA.TEK.COM
  8. Lines: 1970
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: wilson@ernie.Berkeley.EDU (Jim Wilson)
  12. Posting-number: Volume 9, Issue 81
  13. Archive-name: umoria3/Part26
  14. Supersedes: umoria2: Volume 5, Issue 32-37,41-52,87
  15.  
  16.  
  17.  
  18. #! /bin/sh
  19. # This is a shell archive.  Remove anything before this line, then unpack
  20. # it by saving it into a file and typing "sh file".  To overwrite existing
  21. # files, type "sh file -c".  You can also feed this as standard input via
  22. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  23. # will see the following message at the end:
  24. #        "End of archive 26 (of 31)."
  25. # Contents:  ibmpc/CONFIG.DOC ibmpc/ms_misc.c mac/dumpres/MakeFile.hqx
  26. #   source/main.c util/showmon.c util/weapons/README
  27. # Wrapped by billr@saab on Wed May 16 11:54:43 1990
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'ibmpc/CONFIG.DOC' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'ibmpc/CONFIG.DOC'\"
  31. else
  32. echo shar: Extracting \"'ibmpc/CONFIG.DOC'\" \(10789 characters\)
  33. sed "s/^X//" >'ibmpc/CONFIG.DOC' <<'END_OF_FILE'
  34. X
  35. X                  The Dungeons of MORIA version 4.872
  36. X                   COPYRIGHT (c) Robert Alan Koeneke
  37. X
  38. X                      MSDOS port by D. G. Kneller
  39. X                             Nov 1, 1988 
  40. X
  41. X
  42. X
  43. X
  44. X
  45. X
  46. XTable of contents
  47. X1. USAGE ............................................................. 1
  48. X2. REQUIREMENTS ...................................................... 1
  49. X3. INSTALLATION ...................................................... 1
  50. X3.1. Hard drive systems .............................................. 1
  51. X3.2. High-density floppy systems ..................................... 2
  52. X3.3. 2 - 360K floppy systems ......................................... 2
  53. X4. OPTIONS ........................................................... 2
  54. X4.1. SAVE ............................................................ 2
  55. X4.2. SCORE ........................................................... 3
  56. X4.3. KEYBOARD ........................................................ 3
  57. X4.4. GRAPHICS ........................................................ 3
  58. X4.5. RAWIO ........................................................... 3
  59. X4.6. IBMBIOS ......................................................... 3
  60. X4.7. ANSI ............................................................ 4
  61. X5. ENVIRONMENT VARIABLES ............................................. 5
  62. X6. BUGS .............................................................. 5
  63. X7. AUTHOR'S ADDRESS .................................................. 5
  64. X
  65. X
  66. X
  67. X
  68. X
  69. X
  70. X
  71. X
  72. X
  73. X
  74. X
  75. X
  76. X
  77. X
  78. X
  79. X
  80. X
  81. X
  82. X
  83. X
  84. X
  85. X
  86. X
  87. X
  88. X
  89. X
  90. X
  91. X                                 - i -                                     
  92. X
  93. X
  94. X
  95. X
  96. XINTRODUCTION
  97. X
  98. XThis README file describes the requirements and setup necessary to get
  99. XMORIA running on your MSDOS computer.  The actual game documentation is
  100. Xin MORIA.DOC.  Some of the game documentation will be wrong if you
  101. Xchoose the Rogue-like command set.
  102. X
  103. X
  104. X1. USAGE
  105. X
  106. X     Usage:  moria [ -nors ] [ savefile ]
  107. X
  108. X     Where:  -n starts a new game, ignoring any existing save files.
  109. X             -o selects the original (VMS) command set.
  110. X             -r selects the Rogue-like command set.
  111. X             -s prints the score file and exits.
  112. X
  113. X2. REQUIREMENTS
  114. X
  115. X     640K ram (really!)
  116. X     DOS 2.x or higher
  117. X     2 - 360K floppy disk drives or 1 high density drive or 1 hard drive
  118. X     A 24 (or 25) line by 80 column monitor.  MORIA uses either BIOS calls
  119. X     or ANSI for video output so should work properly on most monitors. 
  120. X     It must use ANSI to work on DEC Rainbows.  It won't work in 43-line mode
  121. X     of an EGA.
  122. X
  123. X
  124. X3. INSTALLATION
  125. X
  126. XMORIA is very easy to configure.  The biggest problem is that there is
  127. Xnot enough room on a single 360K floppy disk to hold the DOS system
  128. Xfiles, MORIA.EXE (about 340K) and a MORIA save file (about 80K or so).
  129. XTo install MORIA, some files must be copied and 2 options in MORIA.CNF
  130. Xmust be set.  Options and the MORIA.CNF are described more fully in the
  131. Xsection entitled OPTIONS.  Here are a few methods of configuration.
  132. XThese methods are also described in the MORIA.CNF file.
  133. X
  134. X
  135. X3.1. Hard drive systems
  136. X
  137. XCreate a c:\games subdirectory on your hard disk and put c:\games on
  138. Xyour PATH (see the DOS manual if you need help with PATH). Copy
  139. XMORIA.EXE and MORIA.CNF to c:\games.  Edit MORIA.CNF and put in the
  140. Xoptions:
  141. X
  142. X     SAVE c:\games\moria.sav;n
  143. X     SCORE c:\games\moria.scr
  144. X
  145. X
  146. X
  147. X
  148. X
  149. X
  150. X                                 - 1 -                                     
  151. X
  152. X3.2. High-density floppy systems
  153. X
  154. XThis is about as easy as for a hard disk.  Format a diskette and put the
  155. XDOS system files on it (use FORMAT A:/S).  Copy MORIA.EXE and MORIA.CNF
  156. Xto that diskette.  Edit MORIA.CNF and put in the options:
  157. X
  158. X     SAVE a:\moria.sav
  159. X     SCORE a:\moria.scr
  160. X
  161. X
  162. X
  163. X3.3. 2 - 360K floppy systems
  164. X
  165. XYou will need to use 2 floppy diskettes.  Format a diskette and put the
  166. XDOS system files on it (use FORMAT A:/S).  Copy MORIA.CNF to this
  167. Xdiskette. This diskette will go in drive A when you want to play MORIA.
  168. XFormat a second diskette (no /S) and copy MORIA.EXE to it.  This
  169. Xdiskette will go in drive B.  Edit MORIA.CNF and put in the options:
  170. X
  171. X     SAVE a:moria.sav
  172. X     SCORE a:moria.scr
  173. X
  174. X
  175. XWhen you want to play MORIA, put both diskettes in and type "B:MORIA"
  176. X
  177. X
  178. X
  179. X4. OPTIONS
  180. X
  181. XWhen MORIA starts up it looks along your PATH for the file "MORIA.CNF".
  182. XMORIA.CNF contains configuration information for MORIA in the form of
  183. Xoptions.  Options have a name and perhaps a value.  If the option
  184. Xdoesn't have a value, simply mentioning its name selects that option.
  185. XHere are the options.
  186. X
  187. X4.1. SAVE
  188. X
  189. XThe SAVE option has 1 argument, the name of a file where saved games
  190. Xwill be stored.  Normally, when you start MORIA by typing "MORIA file",
  191. XMORIA will try to use "file" as the name of a saved game.  The SAVE
  192. Xoption allows you to give the name of the save file so you don't have to
  193. Xtype it in each time you save or restore a game.  A sample SAVE option
  194. Xis:
  195. X
  196. X     SAVE c:\games\moria.sav;n
  197. X
  198. X
  199. XThe ";n" is optional.  If given it means that MORIA should never prompt
  200. Xyou for the name of the save file.  If the SAVE option isn't given,
  201. XMORIA defaults to the file MORIA.SAV in the same directory as MORIA.CNF.
  202. XAlso, the SAVE option can be just ";n", which means use the default name
  203. Xwithout prompting.
  204. X
  205. X
  206. X
  207. X
  208. X
  209. X                                 - 2 -                                     
  210. X
  211. X4.2. SCORE
  212. X
  213. XThe SCORE option has 1 argument, the name of the file where the top
  214. Xscores are kept.  A sample SCORE option is:
  215. X
  216. X     SCORE c:\games\moria.scr
  217. X
  218. X
  219. XIf the SCORE option isn't given, MORIA defaults to the file MORIA.SCR in
  220. Xthe same directory as MORIA.CNF.
  221. X
  222. X
  223. X4.3. KEYBOARD
  224. X
  225. XMORIA can be played with either of 2 styles of commands.  There is the
  226. Xoriginal VMS-style commands and a Rogue-style set of commands. The
  227. Xchoice of command set affects the keyboard letters used for doing the
  228. Xvarious game commands.  The KEYBOARD value can be either "ROGUE" or
  229. X"VMS".  The default is to use the original VMS-style commands.
  230. X
  231. X
  232. X4.4. GRAPHICS
  233. X
  234. XThe GRAPHICS option takes 2 arguments, the ASCII number for the
  235. Xcharacter to be used for displaying the walls and floors.  For example,
  236. Xto use '#' for the walls and '.' for the floors, the GRAPHICS option
  237. Xwould be:
  238. X
  239. X     GRAPHICS 35 46
  240. X
  241. X
  242. XIncidentally, these also are the default characters that are used if the
  243. XGRAPHICS option is not specified.
  244. X
  245. X
  246. X4.5. RAWIO
  247. X
  248. XNormally DOS does some extra work whenever a character is input from the
  249. Xkeyboard.  One of the tasks is to interpret the special characters ^S
  250. X(control-S, which does a scroll lock) ^C (control-C, which acts like
  251. Xcontrol-Break) and ^P (control-P, which acts like control-PrtSc,
  252. Xtoggling output to your printer or giving an error message if you don't
  253. Xhave one). The RAWIO option will be used to tell DOS to not do this
  254. Xextra work by making the input (and output) operate in "raw" mode. This
  255. Xis good because ^P (a MORIA command) will now work. As well, screen
  256. Xoutput will be somewhat faster.
  257. X
  258. XURGENT!  RAWIO will not work on Dec Rainbows and will probably lock up
  259. Xthe computer.
  260. X
  261. X
  262. X4.6. IBMBIOS
  263. X
  264. XIBMBIOS enables the use of a BIOS call to read input from the keyboard.
  265. X
  266. X
  267. X
  268. X                                 - 3 -                                     
  269. X
  270. XThe advantage of this is that the numeric keypad will then be useable as
  271. Xdirection keys for moving around.  With this option the keypad keys map
  272. Xto the directions:
  273. X
  274. X             7 up & left      8 up        9 up & right
  275. X             4 left           5 nothing   6 right
  276. X             1 down & left    2 down      3 down & right
  277. X
  278. X     And other keypad keys map to:
  279. X
  280. X                                          -   rest
  281. X                                          +   previous message
  282. X             Ins inventory        Del rest
  283. X
  284. X
  285. XIf you are using the Rogue-style command set, the shift key and NumLock
  286. Xkey modify these commands. With the shift key down, 7 will be "run up
  287. Xand left", 8 will be "run up", etc.  The NumLock key is used as a toggle
  288. Xbetween moving and tunneling. With NumLock enabled, 7 will be "tunnel up
  289. Xand left", etc.
  290. X
  291. X
  292. X4.7. ANSI
  293. X
  294. XThe ANSI option tells MORIA to use ANSI sequences rather than using BIOS
  295. Xcalls for doing output.  You must use the ANSI option if you are playing
  296. XMORIA on a DEC Rainbow.  On IBM PCs, ATs and clones there should be no
  297. Xneed to use this option and you can safely ignore the rest of this
  298. Xsection.
  299. X
  300. XThe ANSI option takes three optional arguments:  check_ansi, move_opt and
  301. Xuse_tgoto.  If no arguments aren't given, they are assumed to be Y (yes),
  302. XY and N (no), respectively.  The usage is
  303. X
  304. X     ANSI [ check_ansi [ move_opt [ use_tgoto ] ] ]
  305. X
  306. XAn example is:
  307. X
  308. X     ANSI Y N
  309. X
  310. Xcheck_ansi tells MORIA to check for ANSI.SYS when starting up.  You may have
  311. Xto disable this check if MORIA insists you don't have ANSI installed, but you
  312. Xknow you do.  move_opt tries to reduce the amount of output being sent to the
  313. Xscreen.  use_tgoto tells MORIA to use the actual TERMCAP tgoto() routine.  The
  314. Xdefault is to use a faster routine which only works for ANSI-like terminals.
  315. X
  316. XWhen the ANSI option is chosen, MORIA looks for ANSI control strings in
  317. Xa file called TERMCAP, first in the current directory, then in directory
  318. XETC.  A sample TERMCAP file is supplied.  Basically, this file maps
  319. Xbetween logical cursor operations (eg. "cursor up") to ANSI sequences
  320. X(eg ESC [ A).  In the file, ESC (escape) is represented as \E.  MORIA
  321. Xuses the following logical operations:
  322. X
  323. X
  324. X
  325. X
  326. X
  327. X                                 - 4 -                                     
  328. X
  329. X     ce      clear to end of line
  330. X     cl      clear screen
  331. X     cm      cursor motion (only if use_tgoto is chosen)
  332. X     nd      cursor forward (non-destructive space)
  333. X     bc      cursor back
  334. X     up      cursor up
  335. X     xd      cursor down
  336. X     li      number of lines on the screen
  337. X
  338. XMORIA can also use:
  339. X
  340. X     ti      terminal initialization string
  341. X     te      terminal end string
  342. X
  343. X
  344. X5. ENVIRONMENT VARIABLES
  345. X
  346. XMORIA uses the environment variable USER to determine your real name (as
  347. Xopposed to your role playing name in the game).  The USER environment
  348. Xvariable can be set from DOS with:
  349. X
  350. X     set USER = kneller
  351. X
  352. XIf the USER variable isn't set, MORIA just uses the name "player".
  353. X
  354. XIf the ANSI option is chosen, MORIA uses the variable TERM to determine
  355. Xthe terminal information to extract from the TERMCAP file.  If the TERM
  356. Xvariable isn't set, MORIA assumes the value "ibmpc-mono".
  357. X
  358. X
  359. X
  360. X6. BUGS
  361. X
  362. XI have not played this game much so there may be bugs which I have not
  363. Xseen yet.  Please report them to me so I can fix them.
  364. X
  365. X
  366. X7. AUTHOR'S ADDRESS
  367. X
  368. XIf you have any questions or bug reports please contact me at:
  369. X
  370. X     D. G. Kneller
  371. X     1349  10th avenue
  372. X     San Francisco, CA 94122
  373. X     USA
  374. X
  375. X     or by electronic mail at:
  376. X
  377. X     ARPA:   kneller@cgl.ucsf.edu
  378. X     BITNET: kneller@ucsfcgl.bitnet
  379. X     UUCP:   ...ucbvax!ucsfcgl!kneller
  380. X
  381. X
  382. X
  383. X
  384. X
  385. X
  386. X                                 - 5 -                                     
  387. X
  388. END_OF_FILE
  389. if test 10789 -ne `wc -c <'ibmpc/CONFIG.DOC'`; then
  390.     echo shar: \"'ibmpc/CONFIG.DOC'\" unpacked with wrong size!
  391. fi
  392. # end of 'ibmpc/CONFIG.DOC'
  393. fi
  394. if test -f 'ibmpc/ms_misc.c' -a "${1}" != "-c" ; then 
  395.   echo shar: Will not clobber existing file \"'ibmpc/ms_misc.c'\"
  396. else
  397. echo shar: Extracting \"'ibmpc/ms_misc.c'\" \(10270 characters\)
  398. sed "s/^X//" >'ibmpc/ms_misc.c' <<'END_OF_FILE'
  399. X/* ms_misc.c: MSDOS dependant code
  400. X
  401. X   Copyright (c) 1989 James E. Wilson, Don Kneller
  402. X
  403. X   This software may be copied and distributed for educational, research, and
  404. X   not for profit purposes provided that this copyright and statement are
  405. X   included in all such copies. */
  406. X
  407. X#ifdef MSDOS
  408. X#include <curses.h>
  409. X#ifdef ANSI
  410. X#include "ms_ansi.h"
  411. X#endif
  412. X#include <string.h>
  413. X#include <ctype.h>
  414. X#include <time.h>
  415. X#include <fcntl.h>
  416. X#include <stdio.h>
  417. X#include "config.h"
  418. X#include "constant.h"
  419. X#include "types.h"
  420. X#include "externs.h"
  421. X
  422. X#ifdef LINT_ARGS
  423. Xvoid exit(int);
  424. Xstatic    unsigned int ioctl(int ,int ,unsigned int );
  425. Xstatic FILE *fopenp(char *, char *, char *);
  426. X#else
  427. Xvoid exit();
  428. Xstatic unsigned int ioctl();
  429. X#endif
  430. X
  431. X#define PATHLEN    80
  432. Xchar    moriatop[PATHLEN];
  433. Xchar    moriasav[PATHLEN];
  434. Xint    saveprompt = TRUE;
  435. Xint    ibmbios;
  436. Xstatic    int    rawio;
  437. Xint8u    floorsym = '.';
  438. Xint8u    wallsym = '#';
  439. X
  440. X/* UNIX compatability routines */
  441. Xvoid user_name(buf)
  442. Xchar *buf;
  443. X{
  444. X  strcpy(buf, getlogin());
  445. X}
  446. X
  447. Xchar    *
  448. Xgetlogin()
  449. X{
  450. X    char    *cp;
  451. X    char    *getenv();
  452. X
  453. X    if ((cp = getenv("USER")) == NULL)
  454. X        cp = "player";
  455. X    return cp;
  456. X}
  457. X
  458. Xunsigned int
  459. Xsleep(secs)
  460. Xint    secs;
  461. X{
  462. X    time_t    finish_time;
  463. X
  464. X    finish_time = time((long *) NULL) + secs;
  465. X    while (time((long *) NULL) < finish_time)
  466. X        /* nothing */;
  467. X    return 0;
  468. X}
  469. X
  470. Xvoid
  471. Xerror(fmt, a1, a2, a3, a4)
  472. Xchar    *fmt;
  473. Xint    a1, a2, a3, a4;
  474. X{
  475. X    fprintf(stderr, "MORIA error: ");
  476. X    fprintf(stderr, fmt, a1, a2, a3, a4);
  477. X    (void) sleep(2);
  478. X    exit(1);
  479. X}
  480. X
  481. Xvoid
  482. Xwarn(fmt, a1, a2, a3, a4)
  483. Xchar    *fmt;
  484. Xint    a1, a2, a3, a4;
  485. X{
  486. X    fprintf(stderr, "MORIA warning: ");
  487. X    fprintf(stderr, fmt, a1, a2, a3, a4);
  488. X    (void) sleep(2);
  489. X}
  490. X
  491. X/* Search the path for a file of name "name".  The directory is
  492. X * filled in with the directory part of the path.
  493. X */
  494. Xstatic FILE *
  495. Xfopenp(name, mode, directory)
  496. Xchar *name, *mode, directory[];
  497. X{
  498. X    char *dp, *pathp, *getenv(), lastch;
  499. X    FILE *fp;
  500. X
  501. X    /* Try the default directory first.  If the file can't be opened,
  502. X     * start looking along the path.
  503. X     */
  504. X    if (fp = fopen(name, mode)) {
  505. X        directory[0] = '\0';
  506. X        return fp;
  507. X    }
  508. X    pathp = getenv("PATH");
  509. X    while (pathp && *pathp) {
  510. X        dp = directory;
  511. X        while (*pathp && *pathp != ';')
  512. X            lastch = *dp++ = *pathp++;
  513. X        if (lastch != '\\' && lastch != '/' && lastch != ':')
  514. X            *dp++ = '\\';
  515. X        (void) strcpy(dp, name);
  516. X        if (fp = fopen(directory, mode)) {
  517. X            *dp = '\0';
  518. X            return fp;
  519. X        }
  520. X        if (*pathp)
  521. X            pathp++;
  522. X    }
  523. X    directory[0] = '\0';
  524. X    return NULL;
  525. X}
  526. X
  527. X/* Read the configuration.
  528. X */
  529. Xvoid
  530. Xmsdos_init()
  531. X{
  532. X    char    buf[BUFSIZ], *bp, opt[PATHLEN];
  533. X    int    arg1, arg2, cnt;
  534. X    FILE    *fp;
  535. X
  536. X    buf[0] = '\0';
  537. X    bp = MORIA_CNF_NAME;
  538. X    fp = fopenp(bp, "r", buf);
  539. X    (void) strcpy(moriatop, buf);
  540. X    (void) strcat(moriatop, MORIA_TOP_NAME);
  541. X    (void) strcpy(moriasav, buf);
  542. X    (void) strcat(moriasav, MORIA_SAV_NAME);
  543. X    if (fp == NULL) {
  544. X        warn("Can't find configuration file `%s'\n", bp);
  545. X        return;
  546. X    }
  547. X    printf("Reading configuration from %s%s\n", buf, bp);
  548. X    (void) sleep(1);
  549. X    while (fgets(buf, sizeof buf, fp)) {
  550. X        if (*buf == '#')
  551. X            continue;
  552. X
  553. X        cnt = sscanf(buf, "%s", opt);
  554. X        if (cnt == 0 || opt[0] == '\0')
  555. X            continue;
  556. X
  557. X        /* Go through possible variables
  558. X         */
  559. X        if (strcmpi(opt, "GRAPHICS") == 0) {
  560. X            cnt = sscanf(buf, "%*s%d%d\n", &arg1, &arg2);
  561. X            if (cnt != 2)
  562. X                warn("GRAPHICS did not contain 2 values\n");
  563. X            else {
  564. X                int i;
  565. X
  566. X                wallsym = (int8u) arg1;
  567. X                floorsym = (int8u) arg2;
  568. X
  569. X                /* Adjust lists that depend on '#' and '.' */
  570. X                object_list[OBJ_SECRET_DOOR].tchar = wallsym;
  571. X            }
  572. X        }
  573. X        else if (strcmpi(opt, "SAVE") == 0) {
  574. X            cnt = sscanf(buf, "%*s%s", opt);
  575. X            if (cnt == 0)
  576. X                warn("SAVE option requires a filename\n");
  577. X            else {
  578. X                if (bp = strchr(opt, ';')) {
  579. X                    *bp++ = '\0';
  580. X                    if (*bp == 'n' || *bp == 'N')
  581. X                        saveprompt = FALSE;
  582. X                }
  583. X                if (opt[0])
  584. X                    (void) strcpy(moriasav, opt);
  585. X            }
  586. X        }
  587. X        else if (strcmpi(opt, "SCORE") == 0) {
  588. X            cnt = sscanf(buf, "%*s%s", opt);
  589. X            if (cnt == 0)
  590. X                warn("SCORE option requires a filename\n");
  591. X            else
  592. X                (void) strcpy(moriatop, opt);
  593. X        }
  594. X        else if (strcmpi(opt, "KEYBOARD") == 0) {
  595. X            cnt = sscanf(buf, "%*s%s", opt);
  596. X            if (cnt == 0)
  597. X                warn("KEYBOARD option requires a value\n");
  598. X            else if (strcmpi(opt, "ROGUE") == 0)
  599. X                rogue_like_commands = TRUE;
  600. X            else if (strcmpi(opt, "VMS") == 0)
  601. X                rogue_like_commands = FALSE;
  602. X        }
  603. X        else if (strcmpi(opt, "IBMBIOS") == 0)
  604. X            ibmbios = TRUE;
  605. X        else if (strcmpi(opt, "RAWIO") == 0)
  606. X            rawio = TRUE;
  607. X#ifdef ANSI
  608. X        /* Usage: ANSI [ check_ansi [ domoveopt [ tgoto ] ] ]
  609. X         * where check_ansi and domoveopt are "Y"es unless explicitly
  610. X         * set to "N"o.     Tgoto is "N"o unless set to "Y"es.
  611. X         */
  612. X        else if (strcmpi(opt, "ANSI") == 0) {
  613. X            cnt=sscanf(buf, "%*s%1s%1s%1s",&opt[0],&opt[1],&opt[2]);
  614. X            ansi_prep(cnt < 1 || opt[0] == 'y' || opt[0] == 'Y',
  615. X                 cnt < 2 || opt[1] == 'y' || opt[1] == 'Y',
  616. X                 cnt >= 3 && (opt[2] == 'y' || opt[2] == 'Y'));
  617. X        }
  618. X#endif
  619. X        else
  620. X            warn("Unknown configuration line: `%s'\n", buf);
  621. X    }
  622. X    fclose(fp);
  623. X
  624. X    /* The only text file has been read.  Switch to binary mode */
  625. X}
  626. X
  627. X#include <dos.h>
  628. X#define DEVICE    0x80
  629. X#define RAW    0x20
  630. X#define IOCTL    0x44
  631. X#define STDIN    fileno(stdin)
  632. X#define STDOUT    fileno(stdout)
  633. X#define GETBITS    0
  634. X#define SETBITS    1
  635. X
  636. Xstatic unsigned    old_stdin, old_stdout, ioctl();
  637. X
  638. Xvoid
  639. Xmsdos_raw() {
  640. X    if (!rawio)
  641. X        return;
  642. X    old_stdin = ioctl(STDIN, GETBITS, 0);
  643. X    old_stdout = ioctl(STDOUT, GETBITS, 0);
  644. X    if (old_stdin & DEVICE)
  645. X        ioctl(STDIN, SETBITS, old_stdin | RAW);
  646. X    if (old_stdout & DEVICE)
  647. X        ioctl(STDOUT, SETBITS, old_stdout | RAW);
  648. X}
  649. X
  650. Xvoid
  651. Xmsdos_noraw() {
  652. X    if (!rawio)
  653. X        return;
  654. X    if (old_stdin)
  655. X        (void) ioctl(STDIN, SETBITS, old_stdin);
  656. X    if (old_stdout)
  657. X        (void) ioctl(STDOUT, SETBITS, old_stdout);
  658. X}
  659. X
  660. Xstatic unsigned int
  661. Xioctl(handle, mode, setvalue)
  662. Xunsigned int setvalue;
  663. X{
  664. X    union REGS regs;
  665. X
  666. X    regs.h.ah = IOCTL;
  667. X    regs.h.al = (unsigned char) mode;
  668. X    regs.x.bx = handle;
  669. X    regs.h.dl = (unsigned char) setvalue;
  670. X    regs.h.dh = 0;            /* Zero out dh */
  671. X    intdos(®s, ®s);
  672. X    return (regs.x.dx);
  673. X}
  674. X
  675. X/* Normal characters are output when the shift key is not pushed.
  676. X * Shift characters are output when either shift key is pushed.
  677. X */
  678. X#define KEYPADHI    83
  679. X#define KEYPADLOW    71
  680. X#define ISKEYPAD(x)    (KEYPADLOW <= (x) && (x) <= KEYPADHI)
  681. X#undef CTRL
  682. X#define CTRL(x)        (x - '@')
  683. Xtypedef struct {
  684. X    char normal, shift, numlock;
  685. X} KEY;
  686. Xstatic KEY roguekeypad[KEYPADHI - KEYPADLOW + 1] = {
  687. X    {'y', 'Y', CTRL('Y')},            /* 7 */
  688. X    {'k', 'K', CTRL('K')},            /* 8 */
  689. X    {'u', 'U', CTRL('U')},            /* 9 */
  690. X    {'.', '.', '.'},            /* - */
  691. X    {'h', 'H', CTRL('H')},            /* 4 */
  692. X    {'.', '.', '.'},            /* 5 */
  693. X    {'l', 'L', CTRL('L')},            /* 6 */
  694. X    {CTRL('P'), CTRL('P'), CTRL('P')},    /* + */
  695. X    {'b', 'B', CTRL('B')},            /* 1 */
  696. X    {'j', 'J', CTRL('J')},            /* 2 */
  697. X    {'n', 'N', CTRL('N')},            /* 3 */
  698. X    {'i', 'i', 'i'},            /* Ins */
  699. X    {'.', '.', '.'}                /* Del */
  700. X};
  701. Xstatic KEY originalkeypad[KEYPADHI - KEYPADLOW + 1] = {
  702. X    {'7', '7', '7'},            /* 7 */
  703. X    {'8', '8', '8'},            /* 8 */
  704. X    {'9', '9', '9'},            /* 9 */
  705. X    {'-', '-', '-'},            /* - */
  706. X    {'4', '4', '4'},            /* 4 */
  707. X    {'5', '5', '5'},            /* 5  - move */
  708. X    {'6', '6', '6'},            /* 6 */
  709. X    {CTRL('M'), CTRL('M'), CTRL('M')},    /* + */
  710. X    {'1', '1', '1'},            /* 1 */
  711. X    {'2', '2', '2'},            /* 2 */
  712. X    {'3', '3', '3'},            /* 3 */
  713. X    {'i', 'i', 'i'},        /* Ins */
  714. X    {'.', '.', '.'}            /* Del */
  715. X};
  716. X
  717. X/* bios_getch gets keys directly with a BIOS call.
  718. X */
  719. X#define SHIFT        (0x1 | 0x2)
  720. X#define NUMLOCK        0x20
  721. X#define KEYBRD_BIOS    0x16
  722. X
  723. Xint
  724. Xbios_getch()
  725. X{
  726. X    unsigned char scan, shift;
  727. X    int    ch;
  728. X    KEY    *kp;
  729. X    union REGS regs;
  730. X
  731. X    if (rogue_like_commands)
  732. X        kp = roguekeypad;
  733. X    else
  734. X        kp = originalkeypad;
  735. X
  736. X    /* Get scan code.
  737. X     */
  738. X    regs.h.ah = 0;
  739. X    int86(KEYBRD_BIOS, ®s, ®s);
  740. X    ch = regs.h.al;
  741. X    scan = regs.h.ah;
  742. X
  743. X    /* Get shift status.
  744. X     */
  745. X    regs.h.ah = 2;
  746. X    int86(KEYBRD_BIOS, ®s, ®s);
  747. X    shift = regs.h.al;
  748. X
  749. X    /* If scan code is for the keypad, translate it.
  750. X     */
  751. X    if (ISKEYPAD(scan)) {
  752. X        if (shift & NUMLOCK)
  753. X            ch = kp[scan - KEYPADLOW].numlock;
  754. X        else if (shift & SHIFT)
  755. X            ch = kp[scan - KEYPADLOW].shift;
  756. X        else
  757. X            ch = kp[scan - KEYPADLOW].normal;
  758. X    }
  759. X    return ch;
  760. X}
  761. X
  762. Xint
  763. Xmsdos_getch()
  764. X{
  765. X    int    ch;
  766. X
  767. X    if (ibmbios)
  768. X        ch = bios_getch();
  769. X    else {
  770. X        ch = getch();
  771. X        if (ch == 0)
  772. X            ch = getch();
  773. X    }
  774. X    return ch;
  775. X}
  776. X
  777. X/* Hardcode the introductory message in */
  778. Xvoid
  779. Xmsdos_intro()
  780. X{
  781. X        char buf[80];
  782. X
  783. X    clear_screen(0, 0);
  784. X        wmove(stdscr,0,0); 
  785. X    waddstr(stdscr,"                         *********************");
  786. X    wmove(stdscr,1,0);
  787. X        sprintf(buf,"                         **   Moria %d.%d    **",
  788. X      CUR_VERSION_MAJ, CUR_VERSION_MIN);
  789. X        waddstr(stdscr,buf);
  790. X        wmove(stdscr,2,0);
  791. X    waddstr(stdscr,"                         *********************");
  792. X        wmove(stdscr,3,0);
  793. X    waddstr(stdscr,"                   COPYRIGHT (c) Robert Alan Koeneke");
  794. X        wmove(stdscr,5,0);
  795. X    waddstr(stdscr,"Programmers : Robert Alan Koeneke / University of Oklahoma");
  796. X        wmove(stdscr,6,0);
  797. X    waddstr(stdscr,"              Jimmey Wayne Todd   / University of Oklahoma");
  798. X        wmove(stdscr,8,0);
  799. X    waddstr(stdscr,"UNIX Port   : James E. Wilson     / UC Berkeley");
  800. X        wmove(stdscr,10,0);
  801. X    waddstr(stdscr,"MSDOS Port  : Don Kneller         / 1349 - 10th ave");
  802. X        wmove(stdscr,11,0);
  803. X    waddstr(stdscr,"                                  / San Francisco, CA 94122");
  804. X        wmove(stdscr,12,0);
  805. X    waddstr(stdscr,"                                  / Dec 12, 1988");
  806. X    pause_line(23);
  807. X}
  808. X
  809. X#ifdef PC_CURSES
  810. X/* Seems to be a bug in PCcurses whereby it won't really clear the screen
  811. X * if there are characters there it doesn't know about.
  812. X */
  813. X#define VIDEOINT    0x10
  814. Xvoid
  815. Xbios_clear()
  816. X{
  817. X    union REGS regs;
  818. X    unsigned char    nocols, activepage;
  819. X
  820. X#ifdef ANSI
  821. X    if (ansi)
  822. X        return;
  823. X#endif
  824. X
  825. X    /* get video attributes */
  826. X    regs.h.ah = 15;
  827. X    int86(VIDEOINT, ®s, ®s);
  828. X    nocols = regs.h.ah;
  829. X    activepage = regs.h.bh;
  830. X
  831. X    /* Move to lower right corner */
  832. X    regs.h.ah = 2;
  833. X    regs.h.dh = (unsigned char) 24;
  834. X    regs.h.dl = nocols - 1;    /* lower right col */
  835. X    regs.h.bh = activepage;
  836. X    int86(VIDEOINT, ®s, ®s);
  837. X
  838. X    /* get current attribute into bh */
  839. X    regs.h.ah = 8;
  840. X    regs.h.bh = activepage;
  841. X    int86(VIDEOINT, ®s, ®s);
  842. X    regs.h.bh = regs.h.ah;
  843. X
  844. X    regs.h.cl = 0;    /* upper left row */
  845. X    regs.h.ch = 0;    /* upper left col */
  846. X    regs.h.dh = (unsigned char) 24;    /* lower right row */
  847. X    regs.h.dl = nocols - 1;    /* lower right col */
  848. X    regs.h.al = 0;    /* clear window */
  849. X    regs.h.ah = 7;    /* scroll down */
  850. X    int86(VIDEOINT, ®s, ®s);
  851. X}
  852. X#endif
  853. X
  854. X#endif
  855. END_OF_FILE
  856. if test 10270 -ne `wc -c <'ibmpc/ms_misc.c'`; then
  857.     echo shar: \"'ibmpc/ms_misc.c'\" unpacked with wrong size!
  858. fi
  859. # end of 'ibmpc/ms_misc.c'
  860. fi
  861. if test -f 'mac/dumpres/MakeFile.hqx' -a "${1}" != "-c" ; then 
  862.   echo shar: Will not clobber existing file \"'mac/dumpres/MakeFile.hqx'\"
  863. else
  864. echo shar: Extracting \"'mac/dumpres/MakeFile.hqx'\" \(1455 characters\)
  865. sed "s/^X//" >'mac/dumpres/MakeFile.hqx' <<'END_OF_FILE'
  866. X(This file must be converted with BinHex 4.0)
  867. X:$8eKDf9'D@aP,Q4eEA!!9%9B9%e38b!"!!!!!QS!!!&qfZp$6h"dD@pZFb!p)#e
  868. XYBQFJEfi06%p`G'P[ER-J23d04(9YF&*PFbj[)-3J4(9YF&*PFbjM$3P$)(Y$6h"
  869. XdD@pZFhdJ,@mJ4(9YF&*PFbj[)%4eEA"5CA-ZB`d04(9YF&*PFe4PFh3ZBbj[)-3
  870. XJ4(9YF&*PFe4PFh3ZB`d*3b"l3dp`G'P[ER0p)%4eEA"5CA08CA0d,Q-0#3e2BQT
  871. XPBh4c)$dJ4(9YF&*PFe4PFh3ZBbj[)%4eEA"5CA-ZE`d04(9YF&*PFe4PFh3Ja-3
  872. XJHdpLDQ9MG(0p$3P-D@jV)(Y-6h"dD@pZFhdJ,AFJ,@-J*de38b!R)#ed)%e38e3
  873. XJYJd*#AY2BQTPBh4cI5#f$3N*)RY-D@*bBA*TCA0p)R0dG@*c,QmJYJd*#5*l3da
  874. XTBR*KFQPPFhdL3e*eER4TE@8ZEb#f$3N*)RY-D@*bBA*TCA0p)NPZG'9bCQ&MC5j
  875. X[),B0#3NLHd0-D@*bBA*TCA0p)P0dC%0-D@)ZEb#f$3N*)RY$6'PLFQ&bD@9cI5*
  876. X$8d&148aTBLj[),B0#3NLHd0-D@*bBA*TCA0p)NeKG'JZEb#f$3N*)RY$6'PLFQ&
  877. XbD@9cI5*$5@jdCA*QB@0P,QmJYJd*#5*l6'PLFQ&bD@9cI5*8EfpX6'PLFbj[),B
  878. X0#3NYEb"%G@e`8Q9c9'9cG!d05@jcG'&XE#$%)%4eEA"5CA-ZD#"%G@e`8Q9c,Qm
  879. X0#84eF'aTBf&dC5!YH5"%G@e`8Q9c,QJJ)RY$5@jME(9NCA0p)Jd*4(9`E'PMBA4
  880. XP)#ej)%4eEA"5CA-ZEb!LHd0-D@*bBA*TCA0p)Je1TJ!!!3!!!!&-!!!!6!!!!$*
  881. X%G@e`8Q9c9'9cG#jYB@YP$5-J)#"8BA*RCA3k)#!J)!K0B@YP4QPXC@X#!!!!!!!
  882. X!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  883. X!!+)9Fa)!!!!!!!!"IQ&bBfJJ05`J-6Ni15!a-MSb-6Sd0!d04(9YF&*PFe4PFh3
  884. XZBbj[)-3J4(9YF&*PFe4PFh3ZE@&VC5"%G@e`8Q9c9'9cG#jM$3P$)%4eEA"5CA0
  885. X8CA0d,Q-04(9YF&*PFbjM,QmJa#"%G@e`8Q9c9'9cG#jYB@YP)%4eEA"5CA-ZB`d
  886. X!!!")!!P0EfjKBfm!JJ!$!!N!#Rrr!!i!#3!+Irm!K`#"!)*rr`!'!!3!2J!2!G-
  887. X#F`!q!!m"d`*cS$l[KJ!!!!!!!!!!!!!!!!%!!!!"!!!!!8`!!!"-!!!!-J!Y8%J
  888. X%DJ!!!"`!-J!!69"68J!!!!S$lIrr!!!!!!!ZIq3'X3:
  889. END_OF_FILE
  890. if test 1456 -ne `wc -c <'mac/dumpres/MakeFile.hqx'`; then
  891.     echo shar: \"'mac/dumpres/MakeFile.hqx'\" unpacked with wrong size!
  892. fi
  893. # end of 'mac/dumpres/MakeFile.hqx'
  894. fi
  895. if test -f 'source/main.c' -a "${1}" != "-c" ; then 
  896.   echo shar: Will not clobber existing file \"'source/main.c'\"
  897. else
  898. echo shar: Extracting \"'source/main.c'\" \(11025 characters\)
  899. sed "s/^X//" >'source/main.c' <<'END_OF_FILE'
  900. X/* UNIX Moria Version 5.0
  901. X   main.c: initialization, main() function and main loop
  902. X
  903. X   Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
  904. X
  905. X   This software may be copied and distributed for educational, research, and
  906. X   not for profit purposes provided that this copyright and statement are
  907. X   included in all such copies. */
  908. X
  909. X
  910. X/* Original copyright message follows. */
  911. X
  912. X/* Moria Version 4.8    COPYRIGHT (c) Robert Alan Koeneke        */
  913. X/*                                     */
  914. X/*     I lovingly dedicate this game to hackers and adventurers     */
  915. X/*     everywhere...                             */
  916. X/*                                     */
  917. X/*                                     */
  918. X/*     Designer and Programmer : Robert Alan Koeneke             */
  919. X/*                   University of Oklahoma         */
  920. X/*                                     */
  921. X/*     Assistant Programmers     : Jimmey Wayne Todd             */
  922. X/*                   University of Oklahoma         */
  923. X/*                                     */
  924. X/*                   Gary D. McAdoo             */
  925. X/*                   University of Oklahoma         */
  926. X/*                                     */
  927. X/*     UNIX Port         : James E. Wilson             */
  928. X/*                   UC Berkeley                 */
  929. X/*                   wilson@ernie.Berkeley.EDU         */
  930. X/*                   ucbvax!ucbernie!wilson         */
  931. X/*                                     */
  932. X/*     MSDOS Port         : Don Kneller                 */
  933. X/*                   1349 - 10th ave             */
  934. X/*                   San Francisco, CA 94122         */
  935. X/*                   kneller@cgl.ucsf.EDU             */
  936. X/*                   ...ucbvax!ucsfcgl!kneller         */
  937. X/*                   kneller@ucsf-cgl.BITNET         */
  938. X/*                                     */
  939. X/*     BRUCE Moria         : Christopher Stuart             */
  940. X/*                   Monash University             */
  941. X/*                   Melbourne, Victoria, AUSTRALIA     */
  942. X/*                   cjs@moncsbruce.oz             */
  943. X/*                                     */
  944. X/*     Moria may be copied and modified freely as long as the above     */
  945. X/*     credits are retained.    No one who-so-ever may sell or market     */
  946. X/*     this software in any form without the expressed written consent */
  947. X/*     of the author Robert Alan Koeneke.                 */
  948. X/*                                     */
  949. X
  950. X#include "config.h"
  951. X
  952. X/* include before constant, because param.h defines NULL incorrectly */
  953. X#ifndef USG
  954. X#include <sys/types.h>
  955. X#include <sys/param.h>
  956. X#endif
  957. X
  958. X#include "constant.h"
  959. X#include "types.h"
  960. X#include "externs.h"
  961. X
  962. X#ifdef USG
  963. X#ifndef ATARIST_MWC
  964. X#include <string.h>
  965. X#else
  966. X#include "string.h"
  967. X#endif
  968. X#else
  969. X#include <strings.h>
  970. X#endif
  971. X
  972. X#include <ctype.h>
  973. X
  974. X#ifdef Pyramid
  975. X#include <sys/time.h>
  976. X#else
  977. X#include <time.h>
  978. X#endif
  979. X
  980. X#ifndef MAC
  981. X#ifndef GEMDOS
  982. Xlong time();
  983. X#endif
  984. Xchar *getenv();
  985. X#endif
  986. X
  987. X#ifndef MAC
  988. X#ifdef USG
  989. X#ifndef MSDOS
  990. Xunsigned short getuid(), getgid();
  991. X#endif
  992. X#else
  993. X#ifndef SECURE
  994. X#ifdef BSD4_3
  995. Xuid_t getuid(), getgid();
  996. X#else  /* other BSD versions */
  997. Xint getuid(), getgid();
  998. X#endif
  999. X#endif
  1000. X#endif
  1001. X#endif
  1002. X
  1003. X#ifndef VMS
  1004. X#ifndef MAC
  1005. X#if defined(ultrix) || defined(USG)
  1006. Xvoid perror();
  1007. X#endif
  1008. X#endif
  1009. X#endif
  1010. X
  1011. X#ifndef VMS
  1012. X#ifndef MAC
  1013. X#ifdef USG
  1014. Xvoid exit();
  1015. X#endif
  1016. X#endif
  1017. X#endif
  1018. X
  1019. X#ifdef ATARIST_MWC
  1020. Xlong _stksize = 18000;        /*(SAJ) for MWC    */
  1021. X#endif
  1022. X
  1023. X#if defined(LINT_ARGS)
  1024. Xstatic void char_inven_init(void);
  1025. Xstatic void init_m_level(void);
  1026. Xstatic void init_t_level(void);
  1027. X#if (COST_ADJ != 100)
  1028. Xstatic void price_adjust(void);
  1029. X#endif
  1030. X#else
  1031. Xstatic void char_inven_init();
  1032. Xstatic void init_m_level();
  1033. Xstatic void init_t_level();
  1034. X#if (COST_ADJ != 100)
  1035. Xstatic void price_adjust();
  1036. X#endif
  1037. X#endif
  1038. X
  1039. X/* Initialize, restore, and get the ball rolling.    -RAK-    */
  1040. X#ifdef MAC
  1041. X/* This is just a subroutine for the Mac version */
  1042. X/* only options passed in are -orn */
  1043. X/* save file name is never passed */
  1044. Xint moria_main(argc, argv)
  1045. Xint argc;
  1046. Xchar *argv[];
  1047. X#else
  1048. Xint main(argc, argv)
  1049. Xint argc;
  1050. Xchar *argv[];
  1051. X#endif
  1052. X{
  1053. X  int32u seed;
  1054. X  int generate;
  1055. X  int result;
  1056. X#ifndef MAC
  1057. X  char *p;
  1058. X#endif
  1059. X  int new_game = FALSE;
  1060. X  int force_rogue_like = FALSE;
  1061. X  int force_keys_to;
  1062. X  char string[80];
  1063. X
  1064. X  /* default command set defined in config.h file */
  1065. X  rogue_like_commands = ROGUE_LIKE;
  1066. X
  1067. X#ifdef SECURE
  1068. X  Authenticate();
  1069. X#endif
  1070. X
  1071. X#ifdef MSDOS
  1072. X  msdos_init();        /* find out where everything is */
  1073. X#endif
  1074. X
  1075. X  /* call this routine to grab a file pointer to the highscore file */
  1076. X  /* and prepare things to relinquish setuid privileges */
  1077. X  init_scorefile();
  1078. X
  1079. X/* Call this routine to grab a file pointer to the log files and
  1080. X   start the backup process before relinquishing setuid privileges */
  1081. X  init_files();
  1082. X
  1083. X#ifndef SECURE
  1084. X#if !defined(MSDOS) && !defined(ATARIST_MWC) && !defined(MAC)
  1085. X  if (0 != setuid(getuid()))
  1086. X    {
  1087. X      perror("Can't set permissions correctly!  Setuid call failed.\n");
  1088. X      exit(0);
  1089. X    }
  1090. X  if (0 != setgid(getgid()))
  1091. X    {
  1092. X      perror("Can't set permissions correctly!  Setgid call failed.\n");
  1093. X      exit(0);
  1094. X    }
  1095. X#endif
  1096. X#endif
  1097. X
  1098. X  /* use curses */
  1099. X  init_curses();
  1100. X
  1101. X  /* catch those nasty signals */
  1102. X  /* must come after init_curses as some of the signal handlers use curses */
  1103. X  init_signals();
  1104. X
  1105. X  seed = 0; /* let wizard specify rng seed */
  1106. X  /* check for user interface option */
  1107. X  for (--argc, ++argv; argc > 0 && argv[0][0] == '-'; --argc, ++argv)
  1108. X    switch (argv[0][1])
  1109. X      {
  1110. X      case 'N':
  1111. X      case 'n': new_game = TRUE; break;
  1112. X      case 'O':
  1113. X      case 'o':
  1114. X    /* rogue_like_commands may be set in get_char(), so delay this
  1115. X       until after read savefile if any */
  1116. X    force_rogue_like = TRUE;
  1117. X    force_keys_to = FALSE;
  1118. X    break;
  1119. X      case 'R':
  1120. X      case 'r':
  1121. X    force_rogue_like = TRUE;
  1122. X    force_keys_to = TRUE;
  1123. X    break;
  1124. X#ifndef MAC
  1125. X      case 'S':
  1126. X      case 's': display_scores(0, TRUE); exit_game();
  1127. X      case 'W':
  1128. X      case 'w':
  1129. X    to_be_wizard = TRUE;
  1130. X
  1131. X    if (isdigit((int)argv[0][2]))
  1132. X      seed = atoi(&argv[0][2]);
  1133. X    break;
  1134. X      default: (void) printf("Usage: moria [-norsw] [savefile]\n");
  1135. X    exit_game();
  1136. X#endif
  1137. X      }
  1138. X
  1139. X#ifndef MAC
  1140. X  /* Check operating hours            */
  1141. X  /* If not wizard  No_Control_Y           */
  1142. X  read_times();
  1143. X#endif
  1144. X
  1145. X  /* Some necessary initializations        */
  1146. X  /* all made into constants or initialized in variables.c */
  1147. X
  1148. X#if (COST_ADJ != 100)
  1149. X  price_adjust();
  1150. X#endif
  1151. X
  1152. X  /* Grab a random seed from the clock        */
  1153. X  init_seeds(seed);
  1154. X
  1155. X  /* Init monster and treasure levels for allocate */
  1156. X  init_m_level();
  1157. X  init_t_level();
  1158. X
  1159. X  /* Init the store inventories            */
  1160. X  store_init();
  1161. X
  1162. X#ifndef MAC
  1163. X  /* On Mac, if -n is passed, no savefile is used */
  1164. X  /* If -n is not passed, the calling routine will know savefile name,
  1165. X     hence, this code is not necessary */
  1166. X
  1167. X  /* Auto-restart of saved file */
  1168. X  if (argv[0] != NULL)
  1169. X    (void) strcpy (savefile, argv[0]);
  1170. X  else if (p = getenv("MORIA_SAV"))
  1171. X    (void) strcpy(savefile, p);
  1172. X  else if (p = getenv("HOME"))
  1173. X#ifdef ATARIST_MWC
  1174. X    (void) sprintf(savefile, "%s\\%s", p, MORIA_SAV);
  1175. X#else
  1176. X    (void) sprintf(savefile, "%s/%s", p, MORIA_SAV);
  1177. X#endif
  1178. X  else
  1179. X    (void) strcpy(savefile, MORIA_SAV);
  1180. X#endif
  1181. X
  1182. X/* This restoration of a saved character may get ONLY the monster memory. In
  1183. X   this case, get_char returns false. It may also resurrect a dead character
  1184. X   (if you are the wizard). In this case, it returns true, but also sets the
  1185. X   parameter "generate" to true, as it does not recover any cave details. */
  1186. X
  1187. X  result = get_char(&generate);
  1188. X  /* enter wizard mode before showing the character display, but must wait
  1189. X     until after get_char in case it was just a resurrection */
  1190. X  if (to_be_wizard)
  1191. X    if (!enter_wiz_mode())
  1192. X      exit_game();
  1193. X
  1194. X#ifdef MAC
  1195. X  if ((new_game == FALSE) && result)
  1196. X#else
  1197. X  if ((new_game == FALSE) && !access(savefile, 0) && result)
  1198. X#endif
  1199. X    {
  1200. X      change_name();
  1201. X
  1202. X      /* could be restoring a dead character after a signal or HANGUP */
  1203. X      if (py.misc.chp < 0)
  1204. X    death = TRUE;
  1205. X    }
  1206. X  else
  1207. X    {      /* Create character       */
  1208. X      create_character();
  1209. X      char_inven_init();
  1210. X      py.flags.food = 7500;
  1211. X      py.flags.food_digested = 2;
  1212. X      if (class[py.misc.pclass].spell == MAGE)
  1213. X    {      /* Magic realm   */
  1214. X      clear_screen(); /* makes spell list easier to read */
  1215. X      calc_spells(A_INT);
  1216. X      calc_mana(A_INT);
  1217. X    }
  1218. X      else if (class[py.misc.pclass].spell == PRIEST)
  1219. X    {      /* Clerical realm*/
  1220. X      calc_spells(A_WIS);
  1221. X      clear_screen(); /* force out the 'learn prayer' message */
  1222. X      calc_mana(A_WIS);
  1223. X    }
  1224. X      if (!_new_log())
  1225. X    {
  1226. X      (void) sprintf(string, "Can't get at log file \"%s\".", MORIA_LOG);
  1227. X      msg_print(string);
  1228. X      exit_game();
  1229. X    }
  1230. X      /* prevent ^c quit from entering score into scoreboard,
  1231. X     and prevent signal from creating panic save until this point,
  1232. X     all info needed for save file is now valid */
  1233. X      character_generated = 1;
  1234. X      generate = TRUE;
  1235. X    }
  1236. X
  1237. X  if (force_rogue_like)
  1238. X    rogue_like_commands = force_keys_to;
  1239. X
  1240. X  magic_init();
  1241. X
  1242. X  /* Begin the game                */
  1243. X  clear_screen();
  1244. X  prt_stat_block();
  1245. X  if (generate)
  1246. X    generate_cave();
  1247. X
  1248. X  /* Loop till dead, or exit            */
  1249. X  while(!death)
  1250. X    {
  1251. X      dungeon();                  /* Dungeon logic */
  1252. X
  1253. X#ifndef MAC
  1254. X      /* check for eof here, see inkey() in io.c */
  1255. X      /* eof can occur if the process gets a HANGUP signal */
  1256. X      if (eof_flag)
  1257. X    {
  1258. X      (void) strcpy(died_from, "(end of input: saved)");
  1259. X      if (!save_char())
  1260. X        {
  1261. X          (void) strcpy(died_from, "unexpected eof");
  1262. X        }
  1263. X      /* should not reach here, by if we do, this guarantees exit */
  1264. X      death = TRUE;
  1265. X    }
  1266. X#endif
  1267. X
  1268. X      if (!death) generate_cave();           /* New level    */
  1269. X    }
  1270. X
  1271. X  exit_game();        /* Character gets buried. */
  1272. X  /* should never reach here, but just in case */
  1273. X  return (0);
  1274. X}
  1275. X
  1276. X/* Init players with some belongings            -RAK-    */
  1277. Xstatic void char_inven_init()
  1278. X{
  1279. X  register int i, j;
  1280. X  inven_type inven_init;
  1281. X
  1282. X  /* this is needed for bash to work right, it can't hurt anyway */
  1283. X  for (i = 0; i < INVEN_ARRAY_SIZE; i++)
  1284. X    invcopy(&inventory[i], OBJ_NOTHING);
  1285. X
  1286. X  for (i = 0; i < 5; i++)
  1287. X    {
  1288. X      j = player_init[py.misc.pclass][i];
  1289. X      invcopy(&inven_init, j);
  1290. X      /* this makes it known2 and known1 */
  1291. X      store_bought(&inven_init);
  1292. X      /* must set this bit to display tohit/todam for stiletto */
  1293. X      if (inven_init.tval == TV_SWORD)
  1294. X    inven_init.ident |= ID_SHOW_HITDAM;
  1295. X      (void) inven_carry(&inven_init);
  1296. X    }
  1297. X
  1298. X  /* wierd place for it, but why not? */
  1299. X  for (i = 0; i < 32; i++)
  1300. X    spell_order[i] = 99;
  1301. X}
  1302. X
  1303. X
  1304. X/* Initializes M_LEVEL array for use with PLACE_MONSTER    -RAK-    */
  1305. Xstatic void init_m_level()
  1306. X{
  1307. X  register int i, k;
  1308. X
  1309. X  for (i = 0; i <= MAX_MONS_LEVEL; i++)
  1310. X    m_level[i] = 0;
  1311. X
  1312. X  k = MAX_CREATURES - WIN_MON_TOT;
  1313. X  for (i = 0; i < k; i++)
  1314. X    m_level[c_list[i].level]++;
  1315. X
  1316. X  for (i = 1; i <= MAX_MONS_LEVEL; i++)
  1317. X    m_level[i] += m_level[i-1];
  1318. X}
  1319. X
  1320. X
  1321. X/* Initializes T_LEVEL array for use with PLACE_OBJECT    -RAK-    */
  1322. Xstatic void init_t_level()
  1323. X{
  1324. X  register int i, l;
  1325. X  int tmp[MAX_OBJ_LEVEL+1];
  1326. X
  1327. X  for (i = 0; i <= MAX_OBJ_LEVEL; i++)
  1328. X    t_level[i] = 0;
  1329. X  for (i = 0; i < MAX_DUNGEON_OBJ; i++)
  1330. X    t_level[object_list[i].level]++;
  1331. X  for (i = 1; i <= MAX_OBJ_LEVEL; i++)
  1332. X    t_level[i] += t_level[i-1];
  1333. X
  1334. X  /* now produce an array with object indexes sorted by level, by using
  1335. X     the info in t_level, this is an O(n) sort! */
  1336. X  /* this is not a stable sort, but that does not matter */
  1337. X  for (i = 0; i <= MAX_OBJ_LEVEL; i++)
  1338. X    tmp[i] = 1;
  1339. X  for (i = 0; i < MAX_DUNGEON_OBJ; i++)
  1340. X    {
  1341. X      l = object_list[i].level;
  1342. X      sorted_objects[t_level[l] - tmp[l]] = i;
  1343. X      tmp[l]++;
  1344. X    }
  1345. X}
  1346. X
  1347. X
  1348. X#if (COST_ADJ != 100)
  1349. X/* Adjust prices of objects                -RAK-    */
  1350. Xstatic void price_adjust()
  1351. X{
  1352. X  register int i;
  1353. X
  1354. X  /* round half-way cases up */
  1355. X  for (i = 0; i < MAX_OBJECTS; i++)
  1356. X    object_list[i].cost = ((object_list[i].cost * COST_ADJ) + 50) / 100;
  1357. X}
  1358. X#endif
  1359. END_OF_FILE
  1360. if test 11025 -ne `wc -c <'source/main.c'`; then
  1361.     echo shar: \"'source/main.c'\" unpacked with wrong size!
  1362. fi
  1363. # end of 'source/main.c'
  1364. fi
  1365. if test -f 'util/showmon.c' -a "${1}" != "-c" ; then 
  1366.   echo shar: Will not clobber existing file \"'util/showmon.c'\"
  1367. else
  1368. echo shar: Extracting \"'util/showmon.c'\" \(11631 characters\)
  1369. sed "s/^X//" >'util/showmon.c' <<'END_OF_FILE'
  1370. X/* this used to be in files.c, this is not a working program */
  1371. X
  1372. X/* move to cheat.c file */
  1373. X/* Prints a listing of monsters                -RAK-     */
  1374. Xprint_monsters()
  1375. X{
  1376. X  register int i;
  1377. X  int j, xpos, attype, adesc, adice, asides, count;
  1378. X  register FILE *file1;
  1379. X  vtype out_val, filename1;
  1380. X  char *attstr;
  1381. X  register creature_type *c_ptr;
  1382. X  register char *string;
  1383. X
  1384. X  prt("File name: ", 0, 0);
  1385. X  if (get_string(filename1, 0, 11, 64))
  1386. X    {
  1387. X      if (strlen(filename1) == 0)
  1388. X    (void) strcpy(filename1, "MORIAMON.DAT");
  1389. X      if ((file1 = fopen(filename1, "w")) != NULL)
  1390. X    {
  1391. X      prt("Writing Monster Dictionary...", 0, 0);
  1392. X      put_qio();
  1393. X      for (i = 0; i < MAX_CREATURES; i++)
  1394. X        {
  1395. X          c_ptr = &c_list[i];
  1396. X          /* Begin writing to file                       */
  1397. X          (void) fprintf(file1, "--------------------------------------------\n");
  1398. X          (void) fprintf(file1, "%3d  %-31s     (%c)\n", i, c_ptr->name, c_ptr->cchar);
  1399. X          (void) fprintf(file1, "     Speed =%3d  Level     =%3d  Exp =%6u\n",
  1400. X              c_ptr->speed-10, c_ptr->level, c_ptr->mexp);
  1401. X          (void) fprintf(file1, "     AC    =%3d  Eye-sight =%3d  HD  =%6s\n",
  1402. X              c_ptr->ac, c_ptr->aaf, c_ptr->hd);
  1403. X          if (CM_WIN & c_ptr->cmove)
  1404. X        (void) fprintf(file1, "     Creature is a ***Win Creature***\n");
  1405. X          if (CM_EATS_OTHER) & c_ptr->cmove)
  1406. X        (void) fprintf(file1, "     Creature Eats/kills other creatures.\n");
  1407. X          if (CD_DRAGON & c_ptr->cdefense)
  1408. X        (void) fprintf(file1, "     Creature is a dragon.\n");
  1409. X          if (CD_ANIMAL & c_ptr->cdefense)
  1410. X        (void) fprintf(file1, "     Creature is an animal.\n");
  1411. X          if (CD_EVIL & c_ptr->cdefense)
  1412. X        (void) fprintf(file1, "     Creature is evil.\n");
  1413. X          if (CD_UNDEAD & c_ptr->cdefense)
  1414. X        (void) fprintf(file1, "     Creature is undead.\n");
  1415. X          if (CD_FROST & c_ptr->cdefense)
  1416. X        (void) fprintf(file1, "     Creature harmed by cold.\n");
  1417. X          if (CD_FIRE & c_ptr->cdefense)
  1418. X        (void) fprintf(file1, "     Creature harmed by fire.\n");
  1419. X          if (CD_POISON & c_ptr->cdefense)
  1420. X        (void) fprintf(file1, "     Creature harmed by poison.\n");
  1421. X          if (CD_ACID & c_ptr->cdefense)
  1422. X        (void) fprintf(file1, "     Creature harmed by acid.\n");
  1423. X          if (CD_LIGHT & c_ptr->cdefense)
  1424. X        (void) fprintf(file1, "     Creature harmed by blue light.\n");
  1425. X          if (CD_STONE & c_ptr->cdefense)
  1426. X        (void) fprintf(file1, "     Creature harmed by Stone-to-Mud.\n");
  1427. X          if (CD_NO_SLEEP & c_ptr->cdefense)
  1428. X        (void) fprintf(file1, "     Creature cannot be charmed or slept.\n");
  1429. X          if (CD_INFRA & c_ptr->cdefense)
  1430. X        (void) fprintf(file1, "     Creature seen with Infra-Vision.\n");
  1431. X          if (CD_MAX_HP & c_ptr->cdefense)
  1432. X        (void) fprintf(file1, "     Creature has MAX hit points.\n");
  1433. X          if (CM_INVISIBLE & c_ptr->cmove)
  1434. X        (void) fprintf(file1, "     Creature is invisible.\n");
  1435. X          if (CM_PICKS_UP & c_ptr->cmove)
  1436. X        (void) fprintf(file1, "     Creature picks up objects.\n");
  1437. X          if (CM_MULTIPLY & c_ptr->cmove)
  1438. X        (void) fprintf(file1, "     Creature multiplies.\n");
  1439. X          if (CM_CARRY_OBJ & c_ptr->cmove)
  1440. X        (void) fprintf(file1, "     Carries object(s).\n");
  1441. X          if (CM_CARRY_GOLD & c_ptr->cmove)
  1442. X        (void) fprintf(file1, "     Carries gold, gems, etc.\n");
  1443. X          if (CM_60_RANDOM & c_ptr->cmove)
  1444. X        (void) fprintf(file1, "       Has object/gold 60%% of time.\n");
  1445. X          if (CM_90_RANDOM & c_ptr->cmove)
  1446. X        (void) fprintf(file1, "       Has object/gold 90%% of time.\n");
  1447. X          if (CM_1D2_OBJ & c_ptr->cmove)
  1448. X        (void) fprintf(file1, "       Has 1d2 object(s)/gold.\n");
  1449. X          if (CM_2D2_OBJ & c_ptr->cmove)
  1450. X        (void) fprintf(file1, "       Has 2d2 object(s)/gold.\n");
  1451. X          if (CM_4D2_OBJ & c_ptr->cmove)
  1452. X        (void) fprintf(file1, "       Has 4d2 object(s)/gold.\n");
  1453. X          /*
  1454. X           * Creature casts spells / Breathes Dragon
  1455. X           * breath.
  1456. X           */
  1457. X          if (c_ptr->spells != 0)
  1458. X        {
  1459. X          (void) fprintf(file1, "   --Spells/Dragon Breath =\n");
  1460. X          (void) fprintf(file1, "       Casts spells 1 out of %d turns.\n",
  1461. X              (int)(CS_FREQ & c_ptr->spells));
  1462. X          if (CS_TEL_SHORT & c_ptr->spells)
  1463. X            (void) fprintf(file1, "       Can teleport short.\n");
  1464. X          if (CS_TEL_LONG & c_ptr->spells)
  1465. X            (void) fprintf(file1, "       Can teleport long.\n");
  1466. X          if (CS_TEL_TO & c_ptr->spells)
  1467. X            (void) fprintf(file1, "       Teleport player to itself.\n");
  1468. X          if (CS_LGHT_WND & c_ptr->spells)
  1469. X            (void) fprintf(file1, "       Cause light wounds.\n");
  1470. X          if (CS_SER_WND & c_ptr->spells)
  1471. X            (void) fprintf(file1, "       Cause serious wounds.\n");
  1472. X          if (CS_HOLD_PER & c_ptr->spells)
  1473. X            (void) fprintf(file1, "       Hold person.\n");
  1474. X          if (CS_BLIND & c_ptr->spells)
  1475. X            (void) fprintf(file1, "       Cause blindness.\n");
  1476. X          if (CS_CONFUSE & c_ptr->spells)
  1477. X            (void) fprintf(file1, "       Cause confusion.\n");
  1478. X          if (CS_FEAR & c_ptr->spells)
  1479. X            (void) fprintf(file1, "       Cause fear.\n");
  1480. X          if (CS_SUMMON_MON & c_ptr->spells)
  1481. X            (void) fprintf(file1, "       Summon a monster.\n");
  1482. X          if (CS_SUMMON_UND & c_ptr->spells)
  1483. X            (void) fprintf(file1, "       Summon an undead.\n");
  1484. X          if (CS_SLOW_PER & c_ptr->spells)
  1485. X            (void) fprintf(file1, "       Slow person.\n");
  1486. X          if (CS_DRAIN_MANA & c_ptr->spells)
  1487. X            (void) fprintf(file1, "       Drains mana for healing.\n");
  1488. X          if (0x00020000L & c_ptr->spells)
  1489. X            (void) fprintf(file1, "       **Unknown spell value**\n");
  1490. X          if (0x00040000L & c_ptr->spells)
  1491. X            (void) fprintf(file1, "       **Unknown spell value**\n");
  1492. X          if (CS_BR_LIGHT & c_ptr->spells)
  1493. X            (void) fprintf(file1, "       Breathes Lightning Dragon Breath.\n");
  1494. X          if (CS_BR_GAS & c_ptr->spells)
  1495. X            (void) fprintf(file1, "       Breathes Gas Dragon Breath.\n");
  1496. X          if (CS_BR_ACID & c_ptr->spells)
  1497. X            (void) fprintf(file1, "       Breathes Acid Dragon Breath.\n");
  1498. X          if (CS_BR_FROST & c_ptr->spells)
  1499. X            (void) fprintf(file1, "       Breathes Frost Dragon Breath.\n");
  1500. X          if (CS_BR_FIRE & c_ptr->spells)
  1501. X            (void) fprintf(file1, "       Breathes Fire Dragon Breath.\n");
  1502. X        }
  1503. X          /* Movement for creature                       */
  1504. X          (void) fprintf(file1, "   --Movement =\n");
  1505. X          if ((CM_ALL_MV_FLAGS & c_ptr->cmove) == 0)
  1506. X        (void) fprintf(file1, "       Do not move.\n");
  1507. X          if (CM_ATTACK_ONLY & c_ptr->cmove)
  1508. X        (void) fprintf(file1, "       Move only to attack.\n");
  1509. X          if (CM_MOVE_NORMAL & c_ptr->cmove)
  1510. X        (void) fprintf(file1, "       Move and attack normally.\n");
  1511. X          if (CM_20_RANDOM & c_ptr->cmove)
  1512. X        (void) fprintf(file1, "       20%% random movement.\n");
  1513. X          if (CM_40_RANDOM & c_ptr->cmove)
  1514. X        (void) fprintf(file1, "       40%% random movement.\n");
  1515. X          if (CM_75_RANDOM & c_ptr->cmove)
  1516. X        (void) fprintf(file1, "       75%% random movement.\n");
  1517. X          if (CM_OPEN_DOOR & c_ptr->cmove)
  1518. X        (void) fprintf(file1, "       Can open doors.\n");
  1519. X          if (CM_PHASE & c_ptr->cmove)
  1520. X        (void) fprintf(file1, "       Can phase through walls.\n");
  1521. X
  1522. X          (void) fprintf(file1, "   --Creature attacks =\n");
  1523. X          attstr = c_ptr->damage;
  1524. X          count = 0;
  1525. X          while (*attstr != 0 && count < 4)
  1526. X        {
  1527. X          attype = monster_attacks[*attstr].attack_type;
  1528. X          adesc = monster_attacks[*attstr].attack_desc;
  1529. X          adice = monster_attacks[*attstr].attack_dice;
  1530. X          asides = monster_attacks[*attstr].attack_sides;
  1531. X          attstr++;
  1532. X          count++;
  1533. X          out_val[0] = '\0';
  1534. X          switch (adesc)
  1535. X            {
  1536. X            case 0:
  1537. X              (void) strcpy(out_val, "       No hits for ");
  1538. X              break;
  1539. X            case 1:
  1540. X              (void) strcpy(out_val, "       Hits for ");
  1541. X              break;
  1542. X            case 2:
  1543. X              (void) strcpy(out_val, "       Bites for ");
  1544. X              break;
  1545. X            case 3:
  1546. X              (void) strcpy(out_val, "       Claws for ");
  1547. X              break;
  1548. X            case 4:
  1549. X              (void) strcpy(out_val, "       Stings for ");
  1550. X              break;
  1551. X            case 5:
  1552. X              (void) strcpy(out_val, "       Touches for ");
  1553. X              break;
  1554. X            case 6:
  1555. X              (void) strcpy(out_val, "       Kicks for ");
  1556. X              break;
  1557. X            case 7:
  1558. X              (void) strcpy(out_val, "       Gazes for ");
  1559. X              break;
  1560. X            case 8:
  1561. X              (void) strcpy(out_val, "       Breathes for ");
  1562. X              break;
  1563. X            case 9:
  1564. X              (void) strcpy(out_val, "       Spits for ");
  1565. X              break;
  1566. X            case 10:
  1567. X              (void) strcpy(out_val, "       Wails for ");
  1568. X              break;
  1569. X            case 11:
  1570. X              (void) strcpy(out_val, "       Embraces for ");
  1571. X              break;
  1572. X            case 12:
  1573. X              (void) strcpy(out_val, "       Crawls on you for ");
  1574. X              break;
  1575. X            case 13:
  1576. X              (void) strcpy(out_val, "       Shoots spores for ");
  1577. X              break;
  1578. X            case 14:
  1579. X              (void) strcpy(out_val, "       Begs for money for ");
  1580. X              break;
  1581. X            case 15:
  1582. X              (void) strcpy(out_val, "       Slimes you for ");
  1583. X              break;
  1584. X            case 16:
  1585. X              (void) strcpy(out_val, "       Crushes you for ");
  1586. X              break;
  1587. X            case 17:
  1588. X              (void) strcpy(out_val, "       Tramples you for ");
  1589. X              break;
  1590. X            case 18:
  1591. X              (void) strcpy(out_val, "       Drools on you for ");
  1592. X              break;
  1593. X            case 19:
  1594. X              (void) strcpy(out_val, "       Insults you for ");
  1595. X              break;
  1596. X            case 99:
  1597. X              (void) strcpy(out_val, "       Is repelled.");
  1598. X              break;
  1599. X            default:
  1600. X              (void) strcpy(out_val, "     **Unknown value** ");
  1601. X              break;
  1602. X            }
  1603. X          switch (attype)
  1604. X            {
  1605. X            case 0:
  1606. X              (void) strcat(out_val, "no damage.");
  1607. X              break;
  1608. X            case 1:
  1609. X              (void) strcat(out_val, "normal damage.");
  1610. X              break;
  1611. X            case 2:
  1612. X              (void) strcat(out_val, "lowering strength.");
  1613. X              break;
  1614. X            case 3:
  1615. X              (void) strcat(out_val, "confusion.");
  1616. X              break;
  1617. X            case 4:
  1618. X              (void) strcat(out_val, "fear.");
  1619. X              break;
  1620. X            case 5:
  1621. X              (void) strcat(out_val, "fire damage.");
  1622. X              break;
  1623. X            case 6:
  1624. X              (void) strcat(out_val, "acid damage.");
  1625. X              break;
  1626. X            case 7:
  1627. X              (void) strcat(out_val, "cold damage.");
  1628. X              break;
  1629. X            case 8:
  1630. X              (void) strcat(out_val, "lightning damage.");
  1631. X              break;
  1632. X            case 9:
  1633. X              (void) strcat(out_val, "corrosion damage.");
  1634. X              break;
  1635. X            case 10:
  1636. X              (void) strcat(out_val, "blindness.");
  1637. X              break;
  1638. X            case 11:
  1639. X              (void) strcat(out_val, "paralyzation.");
  1640. X              break;
  1641. X            case 12:
  1642. X              (void) strcat(out_val, "stealing money.");
  1643. X              break;
  1644. X            case 13:
  1645. X              (void) strcat(out_val, "stealing object.");
  1646. X              break;
  1647. X            case 14:
  1648. X              (void) strcat(out_val, "poison damage.");
  1649. X              break;
  1650. X            case 15:
  1651. X              (void) strcat(out_val, "lose dexterity.");
  1652. X              break;
  1653. X            case 16:
  1654. X              (void) strcat(out_val, "lose constitution.");
  1655. X              break;
  1656. X            case 17:
  1657. X              (void) strcat(out_val, "lose intelligence.");
  1658. X              break;
  1659. X            case 18:
  1660. X              (void) strcat(out_val, "lose wisdom.");
  1661. X              break;
  1662. X            case 19:
  1663. X              (void) strcat(out_val, "lose experience.");
  1664. X              break;
  1665. X            case 20:
  1666. X              (void) strcat(out_val, "aggravates monsters.");
  1667. X              break;
  1668. X            case 21:
  1669. X              (void) strcat(out_val, "disenchants objects.");
  1670. X              break;
  1671. X            case 22:
  1672. X              (void) strcat(out_val, "eating food.");
  1673. X              break;
  1674. X            case 23:
  1675. X              (void) strcat(out_val, "eating light source.");
  1676. X              break;
  1677. X            case 24:
  1678. X              (void) strcat(out_val, "absorbing charges.");
  1679. X              break;
  1680. X            case 99:
  1681. X              (void) strcat(out_val, "blank message.");
  1682. X              break;
  1683. X            default:
  1684. X              (void) strcat(out_val, "**Unknown value**");
  1685. X              break;
  1686. X            }
  1687. X          (void) fprintf(file1, "%s (%dd%d)\n", out_val, adice,asides);
  1688. X        }
  1689. X          for (j = 0; j < 2; j++)
  1690. X        (void) fprintf(file1, "\n");
  1691. X        }
  1692. X      /* End writing to file                   */
  1693. X      (void) fclose(file1);
  1694. X      prt("Completed.", 0, 0);
  1695. X    }
  1696. X    }
  1697. X}
  1698. END_OF_FILE
  1699. if test 11631 -ne `wc -c <'util/showmon.c'`; then
  1700.     echo shar: \"'util/showmon.c'\" unpacked with wrong size!
  1701. fi
  1702. # end of 'util/showmon.c'
  1703. fi
  1704. if test -f 'util/weapons/README' -a "${1}" != "-c" ; then 
  1705.   echo shar: Will not clobber existing file \"'util/weapons/README'\"
  1706. else
  1707. echo shar: Extracting \"'util/weapons/README'\" \(10774 characters\)
  1708. sed "s/^X//" >'util/weapons/README' <<'END_OF_FILE'
  1709. X
  1710. X> 
  1711. X> Here's a question for all of you who have had experiences with HA's.  Is a
  1712. X> dagger a better weapon than say, a war hammer or an axe?  I've found a
  1713. X> bodkin [+8,+8] and a war hammer [+7,+8], and found that the dagger sold
  1714. X> for more in the stores.  Why?  Just because it is one up on To-Hit??  To me,
  1715. X> it would seem like the war hammer is a way better weapon...  Well, the
  1716. X> difference between the prices is about 1000 gp.
  1717. X> 
  1718. X
  1719. X
  1720. X
  1721. Xok, here are some spoilers.
  1722. X
  1723. X
  1724. X1) dont trust what the store will buy or sell things for as being a
  1725. X   good indicator of its true value.  they basis it only on the base
  1726. X   value of a weapon, the to-hit and to-damage, and the special
  1727. X   abilities it has.  these are _not_ always what makes a weapon
  1728. X   really good, and what might be good for one character may be bad
  1729. X   for another.
  1730. X
  1731. X2) when in doubt, keep the dagger.  daggers are probably best for all
  1732. X   types of characters (mages, warriors etc) until you get your
  1733. X   strength and dexterity up real high.
  1734. X
  1735. X
  1736. Xa detail explanation of how things work follows...
  1737. X
  1738. X
  1739. Xthe amount of damage that a weapon will do is based on the following things:
  1740. X
  1741. X   * the weight of the weapon.  the lighter it is the more likely you
  1742. X     will get two hits in for each attack.  on the other hand, the
  1743. X     heavier the weapon, the more likely you are to get a critical hit
  1744. X     (good, excellent, great hits).
  1745. X
  1746. X   * the basic amount of damage the weapon does.  most daggers do 1d4,
  1747. X     two handed swords (Zweihander) do 4d6.
  1748. X
  1749. X   * your total to-hit.  this includes the pluses that come with your
  1750. X     weapon, the minuses that your armor does, any rings of to-hit or
  1751. X     slaying, etc.  the higher your total to-hit is, the more likely
  1752. X     you are to get a critical blow.
  1753. X
  1754. X   * your total to-damage.  like your total to-hit, this includes
  1755. X     everything.  when you get a really good character, this will
  1756. X     usually dominate over the weapons basic damage.
  1757. X
  1758. X   * your current strength.  the stronger you are the easier it is for
  1759. X     you to get several hits per attack.
  1760. X
  1761. X   * your current dexterity.  the more dextrous you are the more hits
  1762. X     per attack you are capable of.
  1763. X
  1764. X   * the level of your character.  the more experience you have the
  1765. X     more likely you are to get a "good (x2)" or "excellent (x3)" hit.
  1766. X
  1767. X
  1768. Xall of these things are mixed together in a rather complicated way.  i
  1769. Xhad to write a program that takes all of these factors into account
  1770. Xand gives a true indication of which weapon is better.  (i had two
  1771. XHA's that i couldnt decide between.  it turned out that depending on
  1772. Xmy current strength and dex either one could be much better than the
  1773. Xother.  i ended up keeping both of them until both my str and dex were
  1774. X18/100.)
  1775. X
  1776. X
  1777. Xthe chance that you actually hit the monster is based on:
  1778. X
  1779. X   * your "base to hit".  this is based on what race your character is
  1780. X     and ranges from -10 for Halflings to 20 for Half-Trolls.  it also
  1781. X     depends on what "class" your character is and these bonuses range
  1782. X     from 20 for mages to 70 for paladin's.  (warriors arent much
  1783. X     behind with a bonus of 68).  a human mage will have a "base to
  1784. X     hit" of 20, a half troll warrior will have a "base to hit" of 88.
  1785. X
  1786. X   * your current level.  the more experience you have, the more likely
  1787. X     you are to hit the monster.  going up one level is equivalent to
  1788. X     enchanting your weapon's to-hit by one.
  1789. X
  1790. X   * your total to-hit.  the higher your total to-hit, the more likely
  1791. X     you are to hit the monster
  1792. X
  1793. X   * the monsters ac (armor class).  the higher the monster's ac, the
  1794. X     less likely you are to hit the monster.  this varies a lot from
  1795. X     monster to monster.  most worm masses, mushrooms, jellies and
  1796. X     stuff have ac's under 10.  most of the ancient dragons have ac's
  1797. X     in the 80-100 range.  the balrog has an ac of 125, the highest of
  1798. X     any monster.  iron golems have an ac of 99, which can give you
  1799. X     some idea of how hard it would be to hit a ancient dragon without
  1800. X     taking too many risks.  most of the other monsters seem to to be
  1801. X     in the 30-60 range.
  1802. X
  1803. X   the formula for this is:
  1804. X
  1805. X      val = bth + 3*level + 3*tohit
  1806. X   
  1807. X      if a random number between 1 and val is greater than the
  1808. X      monsters ac, then you hit, otherwise you miss.
  1809. X
  1810. X   you will always hit one out of 20 times, even if your weapon is too
  1811. X   heavy for you to wield.
  1812. X
  1813. Xi dont have anything to calculate calculate your chances to hit
  1814. Xmonsters because there are just too many different cases.  a level 40
  1815. Xhalf-troll warrior with a total to hit of 30 would have a two out of
  1816. Xthree chance of hitting a AMHD.  everyone else is going to going to be
  1817. Xwell under 50-50.
  1818. X
  1819. X
  1820. X
  1821. XThe program "calc_hits" can help you figure out which weapon is better
  1822. Xfor you now, and as your strength and dexterity goes up.  it is based
  1823. Xon the source code to moria so it should be basically correct.
  1824. Xcalc_hits isnt a fancy program and it handles errors by stopping the
  1825. Xprogram.  it is designed to be used by the person who wrote it. :->
  1826. X
  1827. X
  1828. Xprobably the best way to explain how to run the program is simply to
  1829. Xgive you an example run comparing a bastard sword, a dagger (stiletto)
  1830. Xand a two handed great flail.  all of them will be (+3,+4) giving you
  1831. Xa total to-hit of 2 and a total to-damage of 4.
  1832. X
  1833. Xthe results are given in a table form with the following field:
  1834. X
  1835. XMblow is the maximum number of blows you can get per attack.  it is
  1836. X      based only on your dex.
  1837. X
  1838. XBlows is the number of plows you can get with your current strength
  1839. X      based on the Mblows, and strength/weight ratio.
  1840. X
  1841. Xwt ratio is your strength to weight of weapon ratio.  a ratio above 10
  1842. X      doesnt do you any more good than a ratio of 10.  if the ratio is
  1843. X      under 2, you can only get one blow no matter what your dex is.
  1844. X
  1845. Xdam   is the amount of damage that you get, on the average if you hit
  1846. X      with every blow and dont get a critical hit.
  1847. X
  1848. Xw/ critical is the amount of damage you get on the average if you
  1849. X      include the possibilities of getting a critical hit.  for low
  1850. X      level characters, this rarely makes a difference.  for high
  1851. X      level characters, this can make a real difference.
  1852. X
  1853. X(wayne 6) % calc_hits
  1854. XEnter level of your character: 12
  1855. XEnter number of weapons: 3
  1856. XEnter weight, weapon_dam, to_hit, to_dam for weapon #0: 140 3d4 2 4
  1857. XEnter weight, weapon_dam, to_hit, to_dam for weapon #1: 12 1d4 2 4
  1858. XEnter weight, weapon_dam, to_hit, to_dam for weapon #2: 280 3d6 2 4
  1859. XEnter cstr, cdex: 11 14
  1860. X| Weapon | Max blows | Blows | weight ratio | hp of dam | w/ critical |
  1861. X|    0   |      2    |    1  |        0     |     11    |       12    |
  1862. X|    1   |      2    |    2  |        9     |     13    |       13    |
  1863. X|    2   |      0    |    0  |        0     |      0    |        0    |
  1864. X
  1865. XEnter cstr, cdex: 17 18
  1866. X| Weapon | Max blows | Blows | weight ratio | hp of dam | w/ critical |
  1867. X|    0   |      2    |    1  |        1     |     11    |       12    |
  1868. X|    1   |      2    |    2  |       14     |     13    |       13    |
  1869. X|    2   |      0    |    0  |        0     |      0    |        0    |
  1870. X
  1871. XEnter cstr, cdex: 18/20 18/10
  1872. X| Weapon | Max blows | Blows | weight ratio | hp of dam | w/ critical |
  1873. X|    0   |      3    |    2  |        2     |     23    |       25    |
  1874. X|    1   |      3    |    3  |       31     |     19    |       19    |
  1875. X|    2   |      3    |    1  |        1     |     14    |       17    |
  1876. X
  1877. XEnter cstr, cdex: 18/100 18/100
  1878. X| Weapon | Max blows | Blows | weight ratio | hp of dam | w/ critical |
  1879. X|    0   |      6    |    4  |        8     |     46    |       50    |
  1880. X|    1   |      6    |    5  |       98     |     32    |       32    |
  1881. X|    2   |      6    |    3  |        4     |     43    |       52    |
  1882. X
  1883. XEnter cstr, cdex: 
  1884. X(wayne 7) % exit
  1885. X
  1886. X
  1887. X
  1888. X
  1889. X
  1890. Xthere is a second program called "mk_all_weapon" that generates a list
  1891. Xof how much damage all weapons will do given a certain character.  it
  1892. Xis useful for getting a feel of which weapons are good and why.
  1893. X
  1894. X
  1895. Xfor low level characters, the following are the top 5 weapons:
  1896. X
  1897. Xcharacter level of 12
  1898. Xtotal to-hit and to-damage of +7
  1899. Xstrength of 11.  these numbers wont change much until you get above 18
  1900. Xdexterity of 17.  these numbers will be the same unless your dex is
  1901. X                  above 18/01 or below 10.
  1902. X
  1903. X          Name                | Mblow | Blows | wt ratio | dam | w/ critical |
  1904. XDagger (Stiletto)             |   2   |    2  |    9     |  19 |       19    |
  1905. XDagger (Misercorde)           |   2   |    2  |    7     |  19 |       19    |
  1906. XDagger (Bodkin)               |   2   |    2  |    5     |  19 |       19    |
  1907. XMorningstar                   |   2   |    1  |    0     |  14 |       15    |
  1908. XKatana                        |   2   |    1  |    0     |  14 |       15    |
  1909. X
  1910. Xthe bottom 5 for a low level character:
  1911. X
  1912. XFauchard                      |   0   |    0  |    0     |   0 |        0    |
  1913. XExecutioner's Sword           |   0   |    0  |    0     |   0 |        0    |
  1914. XBeaked Axe                    |   0   |    0  |    0     |   0 |        0    |
  1915. XBattle Axe (European)         |   0   |    0  |    0     |   0 |        0    |
  1916. XBattle Axe (Balestarius)      |   0   |    0  |    0     |   0 |        0    |
  1917. X
  1918. X
  1919. X
  1920. Xfor high level characters, the following are the top 5 weapons:
  1921. X
  1922. Xcharacter level of 36
  1923. Xtotal to-hit and to-damage of +20
  1924. Xstrength of 18/100.
  1925. Xdexterity of 18/100.
  1926. X
  1927. X          Name                | Mblow | Blows | wt ratio | dam | w/ critical |
  1928. XKatana                        |   6   |    5  |    9     | 137 |      161    |
  1929. XWar Hammer                    |   6   |    5  |    9     | 130 |      153    |
  1930. XLucerne Hammer                |   6   |    5  |    9     | 130 |      153    |
  1931. XTwo Handed Sword (Claymore)   |   6   |    4  |    5     | 122 |      151    |
  1932. XTwo Handed Sword (No-Dachi)   |   6   |    4  |    5     | 120 |      149    |
  1933. X
  1934. Xthe bottom 5
  1935. X
  1936. XTwo Handed Great Flail        |   6   |    3  |    4     |  91 |      120    |
  1937. XBall and Chain                |   6   |    4  |    7     | 100 |      120    |
  1938. XAwl-Pike                      |   6   |    4  |    7     |  98 |      118    |
  1939. XLance                         |   6   |    3  |    3     |  87 |      117    |
  1940. XFauchard                      |   6   |    4  |    6     |  84 |      102    |
  1941. X
  1942. X
  1943. X
  1944. Xthe katana tends to be at or near the top for all characters at all
  1945. Xtimes.  if you get even a poor katana (HA) or (DF), keep it and enchant
  1946. Xit.  
  1947. X
  1948. X
  1949. Xone of the biggest mistakes people do is get rid of the weapon that
  1950. Xthe start with and try to get a "bigger meaner" weapon.  dont.  just
  1951. Xenchant your original weapon until you get something really good.  i
  1952. Xdont consider the (FT), (FB), (SD), (SE) and (SU) as "really good".  i
  1953. Xconsider the "(SM)" good, only if i dont already have something of see
  1954. Xinvisible.  (HA) and (DF)'s i keep if they are better than the ones i
  1955. Xalready have.
  1956. X
  1957. X
  1958. X-wayne
  1959. END_OF_FILE
  1960. if test 10774 -ne `wc -c <'util/weapons/README'`; then
  1961.     echo shar: \"'util/weapons/README'\" unpacked with wrong size!
  1962. fi
  1963. # end of 'util/weapons/README'
  1964. fi
  1965. echo shar: End of archive 26 \(of 31\).
  1966. cp /dev/null ark26isdone
  1967. MISSING=""
  1968. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ; do
  1969.     if test ! -f ark${I}isdone ; then
  1970.     MISSING="${MISSING} ${I}"
  1971.     fi
  1972. done
  1973. if test "${MISSING}" = "" ; then
  1974.     echo You have unpacked all 31 archives.
  1975.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1976. else
  1977.     echo You still need to unpack the following archives:
  1978.     echo "        " ${MISSING}
  1979. fi
  1980. ##  End of shell archive.
  1981. exit 0
  1982.