home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sources / games / 163 next >
Encoding:
Internet Message Format  |  1992-08-20  |  55.3 KB

  1. Path: sparky!uunet!zephyr.ens.tek.com!master!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v14i033:  umoria4 - single player dungeon simulation (ver. 5.5), Part01/39
  5. Message-ID: <3391@master.CNA.TEK.COM>
  6. Date: 20 Aug 92 17:56:09 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 1964
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: grabiner@math.harvard.edu (David Grabiner)
  12. Posting-number: Volume 14, Issue 33
  13. Archive-name: umoria4/Part01
  14. Environment: Curses, Unix, Mac, MS-DOS, Atari-ST, Amiga, VMS
  15.  
  16.     [Here's the latest and greatest version of umoria. I compiled and
  17.      ran this with no problems on a Sun SS-2. Be sure the run the
  18.      "bldfiles.sh" script when after parts are unpacked to rebuild
  19.      some large files that were split for posting. Also read the
  20.      INSTALL file for building and installation instructions.  -br]
  21.  
  22. #! /bin/sh
  23. # This is a shell archive.  Remove anything before this line, then unpack
  24. # it by saving it into a file and typing "sh file".  To overwrite existing
  25. # files, type "sh file -c".  You can also feed this as standard input via
  26. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  27. # will see the following message at the end:
  28. #        "End of archive 1 (of 39)."
  29. # Contents:  README MANIFEST INSTALL amiga atari_st atari_st/atarist.c
  30. #   atari_st/curscomp doc files ibmpc ibmpc/make mac mac/dumpres
  31. #   mac/scrnmgr misc source source/moria3.c unix util util/mc
  32. #   util/printit util/scores util/weapons vms
  33. #   amiga/README amiga/timer.c
  34. # Wrapped by billr@saab on Thu Aug 20 09:11:25 1992
  35. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  36. if test -f 'README' -a "${1}" != "-c" ; then 
  37.   echo shar: Will not clobber existing file \"'README'\"
  38. else
  39. echo shar: Extracting \"'README'\" \(2160 characters\)
  40. sed "s/^X//" >'README' <<'END_OF_FILE'
  41. X
  42. XThis is the source for Umoria 5.5, a dungeon exploration game.  This is my
  43. Xsecond major release of the game.  These sources have been compiled
  44. Xsuccessfully at least once in the following environments: UNIX (4.2 BSD,
  45. X4.3 BSD, SYS V, Xenix, and many similar systems), IBM-PC (MSC 5.0,
  46. XTurbo C 2.0), Mac (MPW 3.0, Think C 4.0), Atari ST (MWC, GCC, TC 2.0),
  47. XAmiga (Aztec C 5.0), and VMS.
  48. X
  49. XI consider these to be production sources.  They should work without trouble
  50. Xon all of the systems mentioned above.  Some minor bugs must surely remain,
  51. Xbut there should be no major program bugs encountered.
  52. X
  53. XPeople who are accustomed to Umoria 4.87 MUST read the file doc/FEATURES.NEW
  54. Xwhich documents many of the user visible features.  Don't send me bug reports
  55. Xunless you have read the file.
  56. X
  57. XUmoria 5.x does not understand Umoria 4.87 savefiles.  The changes to the
  58. Xgame are so great, that supporting the old savefile format is not worth
  59. Xthe effort.  Implementing a savefile conversion program will be an almost
  60. Ximpossible task, and at least two people have tried and not succeeded.
  61. X
  62. XYou may distribute modified copies of this game.  However, you must clearly
  63. Xindicate the extent and purpose of the changes.  Also, if the changes are
  64. Xextensive, I request that you call your sources something other than
  65. X`umoria' so that they won't be confused with my version of the game.
  66. XI would also appreciate receiving a copy of your changes, so that good ideas
  67. Xcan be added back into my version.
  68. X
  69. XDavid Grabiner
  70. XDepartment of Mathematics
  71. XHarvard University
  72. XCambridge, MA 02138
  73. X
  74. XInternet electronic mail addess: grabiner@math.harvard.edu
  75. X
  76. XJim Wilson
  77. X856 University Ave.
  78. XPalo Alto, CA  94301
  79. XUSA
  80. X
  81. Xinternet electronic mail address: wilson@kithrup.com
  82. X
  83. XIf the above addresses fail, then try contacting the alumni
  84. Xorganizations of Princeton University for David Grabiner, or Case
  85. XWestern Reserve Univ (Cleveland, OH) or Univ California at Berkeley for
  86. XJim Wilson, for current addresses.  These addresses are expected to
  87. Xremain valid for an unknown length of time.
  88. X
  89. XFirst revision (alpha): February 28, 1990
  90. XSecond revision (beta): May 4, 1990
  91. XThird revision (production): March 25, 1991
  92. END_OF_FILE
  93. if test 2160 -ne `wc -c <'README'`; then
  94.     echo shar: \"'README'\" unpacked with wrong size!
  95. fi
  96. # end of 'README'
  97. fi
  98. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  99.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  100. else
  101. echo shar: Extracting \"'MANIFEST'\" \(7127 characters\)
  102. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  103. X   File Name        Archive #    Description
  104. X-----------------------------------------------------------
  105. X CHANGES                   13    
  106. X ERRORS                    12    
  107. X INSTALL                    1    
  108. X MANIFEST                   1    This shipping list
  109. X OChanges                   3    
  110. X OOChanges.1               29    
  111. X OOChanges.2               26    
  112. X README                     1    
  113. X amiga                      1    
  114. X amiga/ERRORS               9    
  115. X amiga/README               1    
  116. X amiga/amiga.c             39    
  117. X amiga/makefile            37    
  118. X amiga/timer.c              1    
  119. X atari_st                   1    
  120. X atari_st/Makefile         37    
  121. X atari_st/Makefile.bam     38    
  122. X atari_st/Makefile.roe     38    
  123. X atari_st/Makefile.tc      20    
  124. X atari_st/README           39    
  125. X atari_st/atarist.c         1    
  126. X atari_st/curscomp          1    
  127. X atari_st/curscomp/curses.c  9    
  128. X atari_st/curscomp/curses.h 35    
  129. X atari_st/curscomp/curses.txt  4    
  130. X atari_st/curscomp/cursinc.h 37    
  131. X atari_st/moria.lnk        39    
  132. X atari_st/moria.prj        38    
  133. X atari_st/porting.txt      37    
  134. X atari_st/st-stuff.c       38    
  135. X atari_st/string.h         39    
  136. X bldfiles.sh               38    
  137. X doc                        1    
  138. X doc/ERRORS                33    
  139. X doc/FEATURES.NEW          28    
  140. X doc/README                39    
  141. X doc/dragon.inf            38    
  142. X doc/exp.doc               35    
  143. X doc/faq                   19    
  144. X doc/history               34    
  145. X doc/moria.6               37    
  146. X doc/moria.man             37    
  147. X doc/moria1.ms.1           24    
  148. X doc/moria1.ms.2           23    
  149. X doc/moria1.txt             5    
  150. X doc/moria2.ms             27    
  151. X doc/moria2.txt.1          19    
  152. X doc/moria2.txt.2          25    
  153. X doc/pronounc              38    
  154. X doc/spells.doc            31    
  155. X doc/where.inf             38    
  156. X files                      1    
  157. X files/hours               39    
  158. X files/news                39    
  159. X files/origcmds.hlp        38    
  160. X files/owizcmds.hlp        39    
  161. X files/roglcmds.hlp        38    
  162. X files/rwizcmds.hlp        34    
  163. X files/scores               2    
  164. X files/version.hlp         38    
  165. X files/welcome.hlp         39    
  166. X ibmpc                      1    
  167. X ibmpc/CONFIG.DOC          31    
  168. X ibmpc/ERRORS              39    
  169. X ibmpc/MAKE.BAT            39    
  170. X ibmpc/MLINK.LNK           39    
  171. X ibmpc/MORIA.CNF           38    
  172. X ibmpc/Makefile.tc         39    
  173. X ibmpc/README              39    
  174. X ibmpc/TCCONFIG.TCU        32    
  175. X ibmpc/TCPICK.TCU          39    
  176. X ibmpc/TERMCAP             16    
  177. X ibmpc/make                 1    
  178. X ibmpc/make/ccthru.bat     39    
  179. X ibmpc/make/makefile.ibm   39    
  180. X ibmpc/make/makefile.src   39    
  181. X ibmpc/make/makefile.top   13    
  182. X ibmpc/ms_ansi.c           34    
  183. X ibmpc/ms_ansi.h           38    
  184. X ibmpc/ms_misc.c           31    
  185. X ibmpc/tcio.c              33    
  186. X ibmpc/turbo_c.inf         39    
  187. X ibmpc/umoria.prj          39    
  188. X mac                        1    
  189. X mac/ERRORS                39    
  190. X mac/Install.doc           38    
  191. X mac/Install.hqx           35    
  192. X mac/MakeFile.hqx          33    
  193. X mac/README                39    
  194. X mac/dumpres                1    
  195. X mac/dumpres/DumpRes.c     35    
  196. X mac/dumpres/DumpRes.h     39    
  197. X mac/dumpres/MakeFile.hqx  39    
  198. X mac/dumpres/TestDR.c      30    
  199. X mac/mac.c                 16    
  200. X mac/macconf.c             36    
  201. X mac/macdata.c             38    
  202. X mac/machelp.c             35    
  203. X mac/macio.c               30    
  204. X mac/macrsrc.c             34    
  205. X mac/macrsrc.h             38    
  206. X mac/macscore.c            32    
  207. X mac/miscrsrc.hqx          33    
  208. X mac/moria.r               20    
  209. X mac/moria.ro              34    
  210. X mac/scrnmgr                1    
  211. X mac/scrnmgr/ERRORS        39    
  212. X mac/scrnmgr/MakeFile.hqx  38    
  213. X mac/scrnmgr/README        39    
  214. X mac/scrnmgr/ScrnMgr.c.1   11    
  215. X mac/scrnmgr/ScrnMgr.c.2   17    
  216. X mac/scrnmgr/ScrnMgr.doc   17    
  217. X mac/scrnmgr/ScrnMgr.h     34    
  218. X mac/scrnmgr/ScrnMgr.r     33    
  219. X mac/scrnmgr/ScrnMgr.ro    36    
  220. X mac/scrnmgr/ScrnTest.c    34    
  221. X mac/scrnmgr/ScrnTest.r    36    
  222. X mac/scrnmgr/ScrnTest.ro   39    
  223. X misc                       1    
  224. X misc/README               15    
  225. X misc/damage.chg           32    
  226. X misc/funckeys.c           37    
  227. X misc/funckeys.h           39    
  228. X misc/haggle.sug           37    
  229. X misc/mabbrev              39    
  230. X misc/mail.msg             15    
  231. X misc/moria.msg            35    
  232. X misc/rick.msg             28    
  233. X misc/shading              31    
  234. X misc/wex.msg              32    
  235. X shortnam.sed               9    
  236. X source                     1    
  237. X source/config.h           32    
  238. X source/constant.h         16    
  239. X source/create.c           30    
  240. X source/creature.c          6    
  241. X source/death.c            22    
  242. X source/desc.c             23    
  243. X source/dungeon.c           4    
  244. X source/eat.c              36    
  245. X source/externs.h          22    
  246. X source/files.c            12    
  247. X source/generate.c         14    
  248. X source/help.c             35    
  249. X source/io.c               13    
  250. X source/magic.c            36    
  251. X source/main.c             30    
  252. X source/misc1.c            26    
  253. X source/misc2.c            27    
  254. X source/misc3.c.1          24    
  255. X source/misc3.c.2          21    
  256. X source/misc4.c             3    
  257. X source/monsters.c         10    
  258. X source/moria1.c            7    
  259. X source/moria2.c           21    
  260. X source/moria3.c            1    
  261. X source/moria4.c           15    
  262. X source/player.c           18    
  263. X source/potions.c          33    
  264. X source/prayer.c            5    
  265. X source/recall.c           14    
  266. X source/rnd.c              37    
  267. X source/save.c              8    
  268. X source/scrolls.c          29    
  269. X source/sets.c             36    
  270. X source/signals.c          34    
  271. X source/spells.c.1         18    
  272. X source/spells.c.2         25    
  273. X source/staffs.c           37    
  274. X source/store1.c           10    
  275. X source/store2.c           20    
  276. X source/tables.c            8    
  277. X source/treasure.c          2    
  278. X source/types.h            30    
  279. X source/variable.c         37    
  280. X source/wands.c            36    
  281. X source/wizard.c           32    
  282. X unix                       1    
  283. X unix/Makefile             21    
  284. X unix/unix.c               33    
  285. X util                       1    
  286. X util/README               39    
  287. X util/map.c                37    
  288. X util/mc                    1    
  289. X util/mc/ERRORS            39    
  290. X util/mc/Makefile          39    
  291. X util/mc/attribut.txt      39    
  292. X util/mc/creature.y        28    
  293. X util/mc/generic.h         39    
  294. X util/mc/mon.inf            7    
  295. X util/mc/st.h              18    
  296. X util/mc/symtab.c          11    
  297. X util/mcheck.inf           36    
  298. X util/monster.cng          37    
  299. X util/printit               1    
  300. X util/printit/Makefile     39    
  301. X util/printit/pr_items.c   35    
  302. X util/printit/pr_monst.c    6    
  303. X util/scores                1    
  304. X util/scores/Makefile      39    
  305. X util/scores/README        17    
  306. X util/scores/delete.c      23    
  307. X util/scores/print.c       36    
  308. X util/showmon.c            29    
  309. X util/weapons               1    
  310. X util/weapons/ERRORS       39    
  311. X util/weapons/Makefile     39    
  312. X util/weapons/README       31    
  313. X util/weapons/calchits.c   35    
  314. X util/weapons/highchar.in  39    
  315. X util/weapons/lowchar.in   39    
  316. X util/weapons/medchar.in   39    
  317. X util/weapons/mkallwpn     39    
  318. X util/weapons/mkallwpn.lst 37    
  319. X util/weapons/weapon.lst   37    
  320. X vms                        1    
  321. X vms/ERRORS                39    
  322. X vms/Makefile              36    
  323. X vms/README                39    
  324. X vms/debug.mms             38    
  325. X vms/descrip.mms           38    
  326. X vms/getch.c               36    
  327. X vms/make.com              39    
  328. X vms/moria.opt             26    
  329. X vms/scores.fdl            39    
  330. X vms/uexit.c               39    
  331. END_OF_FILE
  332. if test 7127 -ne `wc -c <'MANIFEST'`; then
  333.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  334. fi
  335. # end of 'MANIFEST'
  336. fi
  337. if test -f 'INSTALL' -a "${1}" != "-c" ; then 
  338.   echo shar: Will not clobber existing file \"'INSTALL'\"
  339. else
  340. echo shar: Extracting \"'INSTALL'\" \(1835 characters\)
  341. sed "s/^X//" >'INSTALL' <<'END_OF_FILE'
  342. X
  343. XFirst, you have to put every file in the 'source' directory, and every file
  344. Xin your machine/OS specific directory into a common directory.  If you are on
  345. Xa UNIX machine and running csh, the following works nicely if typed from this
  346. Xdirectory.
  347. X******
  348. Xforeach i (source/* unix/*)
  349. Xln -s $i $i:t
  350. Xend
  351. X******
  352. X(If you wish to build the program in a temporary directory, the same command
  353. Xwill work, but you will have to give full pathnames for the source and
  354. Xunix directories.  If you build the program in a different filesystem than
  355. Xthe one containing the sources, then 'ln -s' will only work if you have
  356. XBSD or SYSVR4.    If the 'ln -s' fails, you can use 'ln' or 'cp' instead.)
  357. X
  358. XTo compile the program, edit the config.h file to change the
  359. Xnames of the files the game uses.  Also, uncomment the appropriate
  360. Xline for the system you are compiling on. Type make (or build
  361. Xor whatever) to compile the game.  You may want to edit the 'files/hours' file
  362. Xto indicate during what hours people are allowed to play the game.  (The
  363. Xmicro versions don't use this file.)
  364. X
  365. XThe game needs to be installed setuid on UNIX systems for the scoreboard
  366. Xto work.  Use the command 'chmod 4511 moria' to do this.
  367. XThe file scores should be mode 644 with the same owner as moria.
  368. XThe files hours and news must be publicly readable with mode 444.
  369. X(Or just type 'make install' after setting BINDIR and LIBDIR in the
  370. XMakefile to appropriate values.)
  371. X
  372. XThere are two choices for the key bindings, the original style and
  373. Xa rogue-like style.  You can choose which one is to be the default
  374. Xby changing the value of ROGUE_LIKE in config.h.
  375. X
  376. XMoria only has partial support for SYS III.  It probably won't
  377. Xcompile and run under this system without a bit of work.
  378. X
  379. XIf your compiler has a seven character identifier limit, the shortnam.sed
  380. Xfile should solve the problem nicely.
  381. END_OF_FILE
  382. if test 1835 -ne `wc -c <'INSTALL'`; then
  383.     echo shar: \"'INSTALL'\" unpacked with wrong size!
  384. fi
  385. # end of 'INSTALL'
  386. fi
  387. if test ! -d 'amiga' ; then
  388.     echo shar: Creating directory \"'amiga'\"
  389.     mkdir 'amiga'
  390. fi
  391. if test ! -d 'atari_st' ; then
  392.     echo shar: Creating directory \"'atari_st'\"
  393.     mkdir 'atari_st'
  394. fi
  395. if test -f 'atari_st/atarist.c' -a "${1}" != "-c" ; then 
  396.   echo shar: Will not clobber existing file \"'atari_st/atarist.c'\"
  397. else
  398. echo shar: Extracting \"'atari_st/atarist.c'\" \(1611 characters\)
  399. sed "s/^X//" >'atari_st/atarist.c' <<'END_OF_FILE'
  400. X/* atari_st/atarist.c: Atari ST support code for MWC or TC
  401. X
  402. X   Copyright (c) 1990-92 Stephen A. Jacobs, James E. Wilson
  403. X
  404. X   This software may be copied and distributed for educational, research, and
  405. X   not for profit purposes provided that this copyright and statement are
  406. X   included in all such copies. */
  407. X
  408. X#include <stdio.h>
  409. X#include "config.h"
  410. X#include "constant.h"
  411. X#include "types.h"
  412. X#include "externs.h"
  413. X
  414. X#if defined(GEMDOS) && (__STDC__ == 0) || defined(ATARIST_TC)
  415. X#include <time.h>
  416. X#ifdef ATARIST_TC
  417. X#include <tos.h>
  418. X#else    /* ATARIST_MWC */
  419. X#include <osbind.h>
  420. X#include <bios.h>
  421. X#endif
  422. X
  423. X#include "curses.h"
  424. X
  425. X#ifdef ATARIST_TC
  426. X/* Include this to get prototypes for standard library functions.  */
  427. X#include <stdlib.h>
  428. X#endif
  429. X
  430. X/* check_input does a non blocking read (consuming the input if any) and
  431. X   returns 1 if there was input pending */
  432. Xint check_input(microsec)
  433. Xint microsec;
  434. X{
  435. X    time_t start;
  436. X
  437. X    if(microsec != 0 && (turn & (unsigned long)0x3f) == 0){
  438. X        start = clock();
  439. X        while ((clock() <= (start + 100)));/*    half second pause */
  440. X    }
  441. X    if (Bconstat(2) != 0L)
  442. X      {
  443. X        (void) getch();
  444. X        return 1;
  445. X      }
  446. X    else
  447. X      return 0;
  448. X}
  449. X
  450. Xvoid user_name(buf)
  451. Xchar *buf;
  452. X{
  453. X    extern char *getenv();
  454. X    register char *p;
  455. X
  456. X    if(p=getenv("NAME")) strcpy(buf, p);
  457. X    else if(p=getenv("USER")) strcpy(buf, p);
  458. X    else strcpy(buf, "X");
  459. X}
  460. X
  461. X#ifdef ATARIST_TC
  462. Xint access(name, dum)
  463. Xchar *name;
  464. Xint dum;
  465. X{
  466. X  int fd;
  467. X
  468. X  fd = open(name, O_RDWR);
  469. X  if (fd < 0)
  470. X    return(-1);
  471. X  else
  472. X    {
  473. X      close(fd);
  474. X      return(0);
  475. X    }
  476. X}
  477. X
  478. Xvoid chmod(name, mode)
  479. Xchar *name;
  480. Xint mode;
  481. X{
  482. X/* does not exist, dummy function */
  483. X}
  484. X#endif
  485. X#endif
  486. END_OF_FILE
  487. if test 1611 -ne `wc -c <'atari_st/atarist.c'`; then
  488.     echo shar: \"'atari_st/atarist.c'\" unpacked with wrong size!
  489. fi
  490. # end of 'atari_st/atarist.c'
  491. fi
  492. if test ! -d 'atari_st/curscomp' ; then
  493.     echo shar: Creating directory \"'atari_st/curscomp'\"
  494.     mkdir 'atari_st/curscomp'
  495. fi
  496. if test ! -d 'doc' ; then
  497.     echo shar: Creating directory \"'doc'\"
  498.     mkdir 'doc'
  499. fi
  500. if test ! -d 'files' ; then
  501.     echo shar: Creating directory \"'files'\"
  502.     mkdir 'files'
  503. fi
  504. if test ! -d 'ibmpc' ; then
  505.     echo shar: Creating directory \"'ibmpc'\"
  506.     mkdir 'ibmpc'
  507. fi
  508. if test ! -d 'ibmpc/make' ; then
  509.     echo shar: Creating directory \"'ibmpc/make'\"
  510.     mkdir 'ibmpc/make'
  511. fi
  512. if test ! -d 'mac' ; then
  513.     echo shar: Creating directory \"'mac'\"
  514.     mkdir 'mac'
  515. fi
  516. if test ! -d 'mac/dumpres' ; then
  517.     echo shar: Creating directory \"'mac/dumpres'\"
  518.     mkdir 'mac/dumpres'
  519. fi
  520. if test ! -d 'mac/scrnmgr' ; then
  521.     echo shar: Creating directory \"'mac/scrnmgr'\"
  522.     mkdir 'mac/scrnmgr'
  523. fi
  524. if test ! -d 'misc' ; then
  525.     echo shar: Creating directory \"'misc'\"
  526.     mkdir 'misc'
  527. fi
  528. if test ! -d 'source' ; then
  529.     echo shar: Creating directory \"'source'\"
  530.     mkdir 'source'
  531. fi
  532. if test -f 'source/moria3.c' -a "${1}" != "-c" ; then 
  533.   echo shar: Will not clobber existing file \"'source/moria3.c'\"
  534. else
  535. echo shar: Extracting \"'source/moria3.c'\" \(31365 characters\)
  536. sed "s/^X//" >'source/moria3.c' <<'END_OF_FILE'
  537. X/* source/moria3.c: misc code, mainly to handle player commands
  538. X
  539. X   Copyright (c) 1989-92 James E. Wilson, Robert A. Koeneke
  540. X
  541. X   This software may be copied and distributed for educational, research, and
  542. X   not for profit purposes provided that this copyright and statement are
  543. X   included in all such copies. */
  544. X
  545. X#ifdef __TURBOC__
  546. X#include    <stdio.h>
  547. X#endif
  548. X
  549. X#include "config.h"
  550. X#include "constant.h"
  551. X#include "types.h"
  552. X#include "externs.h"
  553. X
  554. X#ifdef USG
  555. X#ifndef ATARIST_MWC
  556. X#include <string.h>
  557. X#endif
  558. X#else
  559. X#include <strings.h>
  560. X#endif
  561. X
  562. X#if defined(LINT_ARGS)
  563. Xstatic void hit_trap(int, int);
  564. Xstatic void carry(int, int, int);
  565. Xstatic int summon_object(int, int, int, int);
  566. X#endif
  567. X
  568. X
  569. X/* Player hit a trap.    (Chuckle)            -RAK-    */
  570. Xstatic void hit_trap(y, x)
  571. Xint y, x;
  572. X{
  573. X  int i, ty, tx, num, dam;
  574. X  register cave_type *c_ptr;
  575. X  register struct misc *p_ptr;
  576. X  register inven_type *t_ptr;
  577. X  bigvtype tmp;
  578. X
  579. X  end_find();
  580. X  change_trap(y, x);
  581. X  c_ptr = &cave[y][x];
  582. X  p_ptr = &py.misc;
  583. X  t_ptr = &t_list[c_ptr->tptr];
  584. X  dam = pdamroll(t_ptr->damage);
  585. X  switch(t_ptr->subval)
  586. X    {
  587. X    case 1:  /* Open pit*/
  588. X      msg_print("You fell into a pit!");
  589. X      if (py.flags.ffall)
  590. X    msg_print("You gently float down.");
  591. X      else
  592. X      {
  593. X    objdes(tmp, t_ptr, TRUE);
  594. X    take_hit(dam, tmp);
  595. X      }
  596. X      break;
  597. X    case 2: /* Arrow trap*/
  598. X      if (test_hit(125, 0, 0, p_ptr->pac+p_ptr->ptoac, CLA_MISC_HIT))
  599. X    {
  600. X      objdes(tmp, t_ptr, TRUE);
  601. X      take_hit(dam, tmp);
  602. X      msg_print("An arrow hits you.");
  603. X    }
  604. X      else
  605. X    msg_print("An arrow barely misses you.");
  606. X      break;
  607. X    case 3: /* Covered pit*/
  608. X      msg_print("You fell into a covered pit.");
  609. X      if (py.flags.ffall)
  610. X    msg_print("You gently float down.");
  611. X      else
  612. X      {
  613. X    objdes(tmp, t_ptr, TRUE);
  614. X    take_hit(dam, tmp);
  615. X      }
  616. X      place_trap(y, x, 0);
  617. X      break;
  618. X    case 4: /* Trap door*/
  619. X      msg_print("You fell through a trap door!");
  620. X      new_level_flag = TRUE;
  621. X      dun_level++;
  622. X      if (py.flags.ffall)
  623. X    msg_print("You gently float down.");
  624. X      else
  625. X    {
  626. X      objdes(tmp, t_ptr, TRUE);
  627. X      take_hit(dam, tmp);
  628. X    }
  629. X      /* Force the messages to display before starting to generate the
  630. X     next level.  */
  631. X      msg_print (CNIL);
  632. X      break;
  633. X    case 5: /* Sleep gas*/
  634. X      if (py.flags.paralysis == 0)
  635. X    {
  636. X      msg_print("A strange white mist surrounds you!");
  637. X      if (py.flags.free_act)
  638. X        msg_print("You are unaffected.");
  639. X      else
  640. X        {
  641. X          msg_print("You fall asleep.");
  642. X          py.flags.paralysis += randint(10) + 4;
  643. X        }
  644. X    }
  645. X      break;
  646. X    case 6: /* Hid Obj*/
  647. X      (void) delete_object(y, x);
  648. X      place_object(y, x);
  649. X      msg_print("Hmmm, there was something under this rock.");
  650. X      break;
  651. X    case 7:  /* STR Dart*/
  652. X      if (test_hit(125, 0, 0, p_ptr->pac+p_ptr->ptoac, CLA_MISC_HIT))
  653. X    {
  654. X      if (!py.flags.sustain_str)
  655. X        {
  656. X          (void) dec_stat(A_STR);
  657. X          objdes(tmp, t_ptr, TRUE);
  658. X          take_hit(dam, tmp);
  659. X          msg_print("A small dart weakens you!");
  660. X        }
  661. X      else
  662. X        msg_print("A small dart hits you.");
  663. X    }
  664. X      else
  665. X    msg_print("A small dart barely misses you.");
  666. X      break;
  667. X    case 8: /* Teleport*/
  668. X      teleport_flag = TRUE;
  669. X      msg_print("You hit a teleport trap!");
  670. X      /* Light up the teleport trap, before we teleport away.  */
  671. X      move_light (y, x, y, x);
  672. X      break;
  673. X    case 9: /* Rockfall*/
  674. X      take_hit(dam, "a falling rock");
  675. X      (void) delete_object(y, x);
  676. X      place_rubble(y, x);
  677. X      msg_print("You are hit by falling rock.");
  678. X      break;
  679. X    case 10: /* Corrode gas*/
  680. X      /* Makes more sense to print the message first, then damage an
  681. X     object.  */
  682. X      msg_print("A strange red gas surrounds you.");
  683. X      corrode_gas("corrosion gas");
  684. X      break;
  685. X    case 11: /* Summon mon*/
  686. X      (void) delete_object(y, x);    /* Rune disappears.    */
  687. X      num = 2 + randint (3);
  688. X      for (i = 0; i < num; i++)
  689. X    {
  690. X      ty = y;
  691. X      tx = x;
  692. X      (void) summon_monster(&ty, &tx, FALSE);
  693. X    }
  694. X      break;
  695. X    case 12: /* Fire trap*/
  696. X      msg_print("You are enveloped in flames!");
  697. X      fire_dam(dam, "a fire trap");
  698. X      break;
  699. X    case 13: /* Acid trap*/
  700. X      msg_print("You are splashed with acid!");
  701. X      acid_dam(dam, "an acid trap");
  702. X      break;
  703. X    case 14: /* Poison gas*/
  704. X      msg_print("A pungent green gas surrounds you!");
  705. X      poison_gas(dam, "a poison gas trap");
  706. X      break;
  707. X    case 15: /* Blind Gas */
  708. X      msg_print("A black gas surrounds you!");
  709. X      py.flags.blind += randint(50) + 50;
  710. X      break;
  711. X    case 16: /* Confuse Gas*/
  712. X      msg_print("A gas of scintillating colors surrounds you!");
  713. X      py.flags.confused += randint(15) + 15;
  714. X      break;
  715. X    case 17: /* Slow Dart*/
  716. X      if (test_hit(125, 0, 0, p_ptr->pac+p_ptr->ptoac, CLA_MISC_HIT))
  717. X    {
  718. X      objdes(tmp, t_ptr, TRUE);
  719. X      take_hit(dam, tmp);
  720. X      msg_print("A small dart hits you!");
  721. X      if (py.flags.free_act)
  722. X        msg_print("You are unaffected.");
  723. X      else
  724. X        py.flags.slow += randint(20) + 10;
  725. X    }
  726. X      else
  727. X    msg_print("A small dart barely misses you.");
  728. X      break;
  729. X    case 18: /* CON Dart*/
  730. X      if (test_hit(125, 0, 0, p_ptr->pac+p_ptr->ptoac, CLA_MISC_HIT))
  731. X    {
  732. X      if (!py.flags.sustain_con)
  733. X        {
  734. X          (void) dec_stat(A_CON);
  735. X          objdes(tmp, t_ptr, TRUE);
  736. X          take_hit(dam, tmp);
  737. X          msg_print("A small dart saps your health!");
  738. X        }
  739. X      else
  740. X        msg_print("A small dart hits you.");
  741. X    }
  742. X      else
  743. X    msg_print("A small dart barely misses you.");
  744. X      break;
  745. X    case 19: /*Secret Door*/
  746. X      break;
  747. X    case 99: /* Scare Mon*/
  748. X      break;
  749. X
  750. X      /* Town level traps are special,    the stores.    */
  751. X    case 101: /* General    */
  752. X      enter_store(0);
  753. X      break;
  754. X    case 102: /* Armory        */
  755. X      enter_store(1);
  756. X      break;
  757. X    case 103: /* Weaponsmith*/
  758. X      enter_store(2);
  759. X      break;
  760. X    case 104: /* Temple        */
  761. X      enter_store(3);
  762. X      break;
  763. X    case 105: /* Alchemy    */
  764. X      enter_store(4);
  765. X      break;
  766. X    case 106: /* Magic-User */
  767. X      enter_store(5);
  768. X      break;
  769. X
  770. X    default:
  771. X      msg_print("Unknown trap value.");
  772. X      break;
  773. X    }
  774. X}
  775. X
  776. X
  777. X/* Return spell number and failure chance        -RAK-    */
  778. X/* returns -1 if no spells in book
  779. X   returns 1 if choose a spell in book to cast
  780. X   returns 0 if don't choose a spell, i.e. exit with an escape */
  781. Xint cast_spell(prompt, item_val, sn, sc)
  782. Xchar *prompt;
  783. Xint item_val;
  784. Xint *sn, *sc;
  785. X{
  786. X  int32u j;
  787. X  register int i, k;
  788. X  int spell[31], result, first_spell;
  789. X  register spell_type *s_ptr;
  790. X
  791. X  result = -1;
  792. X  i = 0;
  793. X  j = inventory[item_val].flags;
  794. X  first_spell = bit_pos(&j);
  795. X  /* set j again, since bit_pos modified it */
  796. X  j = inventory[item_val].flags & spell_learned;
  797. X  s_ptr = magic_spell[py.misc.pclass-1];
  798. X  while (j)
  799. X    {
  800. X      k = bit_pos(&j);
  801. X      if (s_ptr[k].slevel <= py.misc.lev)
  802. X    {
  803. X      spell[i] = k;
  804. X      i++;
  805. X    }
  806. X    }
  807. X  if (i > 0)
  808. X    {
  809. X      result = get_spell(spell, i, sn, sc, prompt, first_spell);
  810. X      if (result && magic_spell[py.misc.pclass-1][*sn].smana > py.misc.cmana)
  811. X    {
  812. X      if (class[py.misc.pclass].spell == MAGE)
  813. X        result = get_check("You summon your limited strength to cast \
  814. Xthis one! Confirm?");
  815. X      else
  816. X        result = get_check("The gods may think you presumptuous for \
  817. Xthis! Confirm?");
  818. X    }
  819. X    }
  820. X  return(result);
  821. X}
  822. X
  823. X
  824. X/* Player is on an object.  Many things can happen based -RAK-    */
  825. X/* on the TVAL of the object.  Traps are set off, money and most */
  826. X/* objects are picked up.  Some objects, such as open doors, just*/
  827. X/* sit there.                               */
  828. Xstatic void carry(y, x, pickup)
  829. Xint y, x;
  830. Xint pickup;
  831. X{
  832. X  register int locn, i;
  833. X  bigvtype out_val, tmp_str;
  834. X  register cave_type *c_ptr;
  835. X  register inven_type *i_ptr;
  836. X
  837. X  c_ptr = &cave[y][x];
  838. X  i_ptr = &t_list[c_ptr->tptr];
  839. X  i = t_list[c_ptr->tptr].tval;
  840. X  if (i <= TV_MAX_PICK_UP)
  841. X    {
  842. X      end_find();
  843. X      /* There's GOLD in them thar hills!      */
  844. X      if (i == TV_GOLD)
  845. X    {
  846. X      py.misc.au += i_ptr->cost;
  847. X      objdes(tmp_str, i_ptr, TRUE);
  848. X      (void) sprintf(out_val,
  849. X             "You have found %ld gold pieces worth of %s",
  850. X             i_ptr->cost, tmp_str);
  851. X      prt_gold();
  852. X      (void) delete_object(y, x);
  853. X      msg_print(out_val);
  854. X    }
  855. X      else
  856. X    {
  857. X      if (inven_check_num(i_ptr))       /* Too many objects?        */
  858. X        {                /* Okay,  pick it up      */
  859. X          if (pickup && prompt_carry_flag)
  860. X        {
  861. X          objdes(tmp_str, i_ptr, TRUE);
  862. X          /* change the period to a question mark */
  863. X          tmp_str[strlen(tmp_str)-1] = '?';
  864. X          (void) sprintf(out_val, "Pick up %s", tmp_str);
  865. X          pickup = get_check(out_val);
  866. X        }
  867. X          /* Check to see if it will change the players speed. */
  868. X          if (pickup && !inven_check_weight(i_ptr))
  869. X        {
  870. X          objdes(tmp_str, i_ptr, TRUE);
  871. X          /* change the period to a question mark */
  872. X          tmp_str[strlen(tmp_str)-1] = '?';
  873. X          (void) sprintf(out_val,
  874. X                 "Exceed your weight limit to pick up %s",
  875. X                 tmp_str);
  876. X          pickup = get_check(out_val);
  877. X        }
  878. X          /* Attempt to pick up an object.           */
  879. X          if (pickup)
  880. X        {
  881. X          locn = inven_carry(i_ptr);
  882. X          objdes(tmp_str, &inventory[locn], TRUE);
  883. X          (void) sprintf(out_val, "You have %s (%c)",tmp_str,locn+'a');
  884. X          msg_print(out_val);
  885. X          (void) delete_object(y, x);
  886. X        }
  887. X        }
  888. X      else
  889. X        {
  890. X          objdes(tmp_str, i_ptr, TRUE);
  891. X          (void) sprintf(out_val, "You can't carry %s", tmp_str);
  892. X          msg_print(out_val);
  893. X        }
  894. X    }
  895. X    }
  896. X  /* OPPS!                   */
  897. X  else if (i == TV_INVIS_TRAP || i == TV_VIS_TRAP || i == TV_STORE_DOOR)
  898. X    hit_trap(y, x);
  899. X}
  900. X
  901. X
  902. X/* Deletes a monster entry from the level        -RAK-    */
  903. Xvoid delete_monster(j)
  904. Xint j;
  905. X{
  906. X  register monster_type *m_ptr;
  907. X
  908. X  m_ptr = &m_list[j];
  909. X  cave[m_ptr->fy][m_ptr->fx].cptr = 0;
  910. X  if (m_ptr->ml)
  911. X    lite_spot((int)m_ptr->fy, (int)m_ptr->fx);
  912. X  if (j != mfptr - 1)
  913. X    {
  914. X      m_ptr = &m_list[mfptr - 1];
  915. X      cave[m_ptr->fy][m_ptr->fx].cptr = j;
  916. X      m_list[j] = m_list[mfptr - 1];
  917. X    }
  918. X  mfptr--;
  919. X  m_list[mfptr] = blank_monster;
  920. X  if (mon_tot_mult > 0)
  921. X    mon_tot_mult--;
  922. X}
  923. X
  924. X/* The following two procedures implement the same function as delete monster.
  925. X   However, they are used within creatures(), because deleting a monster
  926. X   while scanning the m_list causes two problems, monsters might get two
  927. X   turns, and m_ptr/monptr might be invalid after the delete_monster.
  928. X   Hence the delete is done in two steps. */
  929. X/* fix1_delete_monster does everything delete_monster does except delete
  930. X   the monster record and reduce mfptr, this is called in breathe, and
  931. X   a couple of places in creatures.c */
  932. Xvoid fix1_delete_monster(j)
  933. Xint j;
  934. X{
  935. X  register monster_type *m_ptr;
  936. X
  937. X  m_ptr = &m_list[j];
  938. X  /* force the hp negative to ensure that the monster is dead, for example,
  939. X     if the monster was just eaten by another, it will still have positive
  940. X     hit points */
  941. X  m_ptr->hp = -1;
  942. X  cave[m_ptr->fy][m_ptr->fx].cptr = 0;
  943. X  if (m_ptr->ml)
  944. X    lite_spot((int)m_ptr->fy, (int)m_ptr->fx);
  945. X  if (mon_tot_mult > 0)
  946. X    mon_tot_mult--;
  947. X}
  948. X
  949. X/* fix2_delete_monster does everything in delete_monster that wasn't done
  950. X   by fix1_monster_delete above, this is only called in creatures() */
  951. Xvoid fix2_delete_monster(j)
  952. Xint j;
  953. X{
  954. X  register monster_type *m_ptr;
  955. X
  956. X  if (j != mfptr - 1)
  957. X    {
  958. X      m_ptr = &m_list[mfptr - 1];
  959. X      cave[m_ptr->fy][m_ptr->fx].cptr = j;
  960. X      m_list[j] = m_list[mfptr - 1];
  961. X    }
  962. X  m_list[mfptr - 1] = blank_monster;
  963. X  mfptr--;
  964. X}
  965. X
  966. X
  967. X/* Creates objects nearby the coordinates given        -RAK-      */
  968. Xstatic int summon_object(y, x, num, typ)
  969. Xint y, x, num, typ;
  970. X{
  971. X  register int i, j, k;
  972. X  register cave_type *c_ptr;
  973. X  int real_typ, res;
  974. X
  975. X  if (typ == 1)
  976. X    real_typ = 1; /* typ == 1 -> objects */
  977. X  else
  978. X    real_typ = 256; /* typ == 2 -> gold */
  979. X  res = 0;
  980. X  do
  981. X    {
  982. X      i = 0;
  983. X      do
  984. X    {
  985. X      j = y - 3 + randint(5);
  986. X      k = x - 3 + randint(5);
  987. X      if (in_bounds(j, k) && los(y, x, j, k))
  988. X        {
  989. X          c_ptr = &cave[j][k];
  990. X          if (c_ptr->fval <= MAX_OPEN_SPACE && (c_ptr->tptr == 0))
  991. X        {
  992. X          if (typ == 3) /* typ == 3 -> 50% objects, 50% gold */
  993. X            {
  994. X              if (randint(100) < 50)
  995. X            real_typ = 1;
  996. X              else
  997. X            real_typ = 256;
  998. X            }
  999. X          if (real_typ == 1)
  1000. X            place_object(j, k);
  1001. X          else
  1002. X            place_gold(j, k);
  1003. X          lite_spot(j, k);
  1004. X          if (test_light(j, k))
  1005. X            res += real_typ;
  1006. X          i = 20;
  1007. X        }
  1008. X        }
  1009. X      i++;
  1010. X    }
  1011. X      while (i <= 20);
  1012. X      num--;
  1013. X    }
  1014. X  while (num != 0);
  1015. X  return res;
  1016. X}
  1017. X
  1018. X
  1019. X/* Deletes object from given location            -RAK-    */
  1020. Xint delete_object(y, x)
  1021. Xint y, x;
  1022. X{
  1023. X  register int delete;
  1024. X  register cave_type *c_ptr;
  1025. X
  1026. X  c_ptr = &cave[y][x];
  1027. X  if (c_ptr->fval == BLOCKED_FLOOR)
  1028. X    c_ptr->fval = CORR_FLOOR;
  1029. X  pusht(c_ptr->tptr);
  1030. X  c_ptr->tptr = 0;
  1031. X  c_ptr->fm = FALSE;
  1032. X  lite_spot(y, x);
  1033. X  if (test_light(y, x))
  1034. X    delete = TRUE;
  1035. X  else
  1036. X    delete = FALSE;
  1037. X  return(delete);
  1038. X}
  1039. X
  1040. X
  1041. X/* Allocates objects upon a creatures death        -RAK-    */
  1042. X/* Oh well,  another creature bites the dust.  Reward the victor*/
  1043. X/* based on flags set in the main creature record         */
  1044. X/* Returns a mask of bits from the given flags which indicates what the
  1045. X   monster is seen to have dropped.  This may be added to monster memory. */
  1046. Xint32u monster_death(y, x, flags)
  1047. Xint y, x;
  1048. Xregister int32u flags;
  1049. X{
  1050. X  register int i, number;
  1051. X  int32u dump, res;
  1052. X#if defined(ATARIST_MWC)
  1053. X  int32u holder;    /* avoid a compiler bug */
  1054. X#endif
  1055. X
  1056. X#if !defined(ATARIST_MWC)
  1057. X  if (flags & CM_CARRY_OBJ)
  1058. X    i = 1;
  1059. X  else
  1060. X    i = 0;
  1061. X  if (flags & CM_CARRY_GOLD)
  1062. X    i += 2;
  1063. X
  1064. X  number = 0;
  1065. X  if ((flags & CM_60_RANDOM) && (randint(100) < 60))
  1066. X    number++;
  1067. X  if ((flags & CM_90_RANDOM) && (randint(100) < 90))
  1068. X    number++;
  1069. X  if (flags & CM_1D2_OBJ)
  1070. X    number += randint(2);
  1071. X  if (flags & CM_2D2_OBJ)
  1072. X    number += damroll(2, 2);
  1073. X  if (flags & CM_4D2_OBJ)
  1074. X    number += damroll(4, 2);
  1075. X  if (number > 0)
  1076. X    dump = summon_object(y, x, number, i);
  1077. X  else
  1078. X    dump = 0;
  1079. X#else
  1080. X  holder = CM_CARRY_OBJ;
  1081. X  if (flags & holder)
  1082. X    i = 1;
  1083. X  else
  1084. X    i = 0;
  1085. X  holder = CM_CARRY_GOLD;
  1086. X  if (flags & holder)
  1087. X    i += 2;
  1088. X
  1089. X  number = 0;
  1090. X  holder = CM_60_RANDOM;
  1091. X  if ((flags & holder) && (randint(100) < 60))
  1092. X    number++;
  1093. X  holder = CM_90_RANDOM;
  1094. X  if ((flags & holder) && (randint(100) < 90))
  1095. X    number++;
  1096. X  holder = CM_1D2_OBJ;
  1097. X  if (flags & holder)
  1098. X    number += randint(2);
  1099. X  holder = CM_2D2_OBJ;
  1100. X  if (flags & holder)
  1101. X    number += damroll(2, 2);
  1102. X  holder = CM_4D2_OBJ;
  1103. X  if (flags & holder)
  1104. X    number += damroll(4, 2);
  1105. X  if (number > 0)
  1106. X    dump = summon_object(y, x, number, i);
  1107. X  else
  1108. X    dump = 0;
  1109. X
  1110. X
  1111. X#endif
  1112. X
  1113. X#if defined(ATARIST_MWC)
  1114. X  holder = CM_WIN;
  1115. X  if (flags & holder)
  1116. X#else
  1117. X  if (flags & CM_WIN)
  1118. X#endif
  1119. X    {
  1120. X      total_winner = TRUE;
  1121. X      prt_winner();
  1122. X      msg_print("*** CONGRATULATIONS *** You have won the game.");
  1123. X      msg_print("You cannot save this game, but you may retire when ready.");
  1124. X    }
  1125. X
  1126. X  if (dump)
  1127. X    {
  1128. X      res = 0;
  1129. X      if (dump & 255)
  1130. X#ifdef ATARIST_MWC
  1131. X    {
  1132. X      holder = CM_CARRY_OBJ;
  1133. X      res |= holder;
  1134. X    }
  1135. X#else
  1136. X        res |= CM_CARRY_OBJ;
  1137. X#endif
  1138. X      if (dump >= 256)
  1139. X#ifdef ATARIST_MWC
  1140. X    {
  1141. X      holder = CM_CARRY_GOLD;
  1142. X      res |= holder;
  1143. X    }
  1144. X#else
  1145. X    res |= CM_CARRY_GOLD;
  1146. X#endif
  1147. X      dump = (dump % 256) + (dump / 256);  /* number of items */
  1148. X      res |= dump << CM_TR_SHIFT;
  1149. X    }
  1150. X  else
  1151. X    res = 0;
  1152. X
  1153. X  return res;
  1154. X}
  1155. X
  1156. X
  1157. X/* Decreases monsters hit points and deletes monster if needed.    */
  1158. X/* (Picking on my babies.)                   -RAK-   */
  1159. Xint mon_take_hit(monptr, dam)
  1160. Xint monptr, dam;
  1161. X{
  1162. X  register int32u i;
  1163. X  int32 new_exp, new_exp_frac;
  1164. X  register monster_type *m_ptr;
  1165. X  register struct misc *p_ptr;
  1166. X  register creature_type *c_ptr;
  1167. X  int m_take_hit;
  1168. X  int32u tmp;
  1169. X#ifdef ATARIST_MWC
  1170. X  int32u holder;
  1171. X#endif
  1172. X
  1173. X  m_ptr = &m_list[monptr];
  1174. X  m_ptr->hp -= dam;
  1175. X  m_ptr->csleep = 0;
  1176. X  if (m_ptr->hp < 0)
  1177. X    {
  1178. X      i = monster_death((int)m_ptr->fy, (int)m_ptr->fx,
  1179. X            c_list[m_ptr->mptr].cmove);
  1180. X      if ((py.flags.blind < 1 && m_ptr->ml)
  1181. X#ifdef ATARIST_MWC
  1182. X      || (c_list[m_ptr->mptr].cmove & (holder = CM_WIN)))
  1183. X#else
  1184. X      || (c_list[m_ptr->mptr].cmove & CM_WIN))
  1185. X#endif
  1186. X    {
  1187. X#ifdef ATARIST_MWC
  1188. X      holder = CM_TREASURE;
  1189. X      tmp = (c_recall[m_ptr->mptr].r_cmove & holder) >> CM_TR_SHIFT;
  1190. X      if (tmp > ((i & holder) >> CM_TR_SHIFT))
  1191. X        i = (i & ~holder) | (tmp << CM_TR_SHIFT);
  1192. X      c_recall[m_ptr->mptr].r_cmove =
  1193. X        (c_recall[m_ptr->mptr].r_cmove & ~holder) | i;
  1194. X#else
  1195. X      tmp = (c_recall[m_ptr->mptr].r_cmove & CM_TREASURE) >> CM_TR_SHIFT;
  1196. X      if (tmp > ((i & CM_TREASURE) >> CM_TR_SHIFT))
  1197. X        i = (i & ~CM_TREASURE) | (tmp << CM_TR_SHIFT);
  1198. X      c_recall[m_ptr->mptr].r_cmove =
  1199. X        (c_recall[m_ptr->mptr].r_cmove & ~CM_TREASURE) | i;
  1200. X#endif
  1201. X      if (c_recall[m_ptr->mptr].r_kills < MAX_SHORT)
  1202. X        c_recall[m_ptr->mptr].r_kills++;
  1203. X    }
  1204. X      c_ptr = &c_list[m_ptr->mptr];
  1205. X      p_ptr = &py.misc;
  1206. X
  1207. X      new_exp = ((long)c_ptr->mexp * c_ptr->level) / p_ptr->lev;
  1208. X      new_exp_frac = ((((long)c_ptr->mexp * c_ptr->level) % p_ptr->lev)
  1209. X    * 0x10000L / p_ptr->lev) + p_ptr->exp_frac;
  1210. X      if (new_exp_frac >= 0x10000L)
  1211. X    {
  1212. X      new_exp++;
  1213. X      p_ptr->exp_frac = new_exp_frac - 0x10000L;
  1214. X    }
  1215. X      else
  1216. X    p_ptr->exp_frac = new_exp_frac;
  1217. X
  1218. X      p_ptr->exp += new_exp;
  1219. X      /* can't call prt_experience() here, as that would result in "new level"
  1220. X     message appearing before "monster dies" message */
  1221. X      m_take_hit = m_ptr->mptr;
  1222. X      /* in case this is called from within creatures(), this is a
  1223. X     horrible hack, the m_list/creatures() code needs to be
  1224. X     rewritten */
  1225. X      if (hack_monptr < monptr)
  1226. X    delete_monster(monptr);
  1227. X      else
  1228. X    fix1_delete_monster(monptr);
  1229. X    }
  1230. X  else
  1231. X    m_take_hit = -1;
  1232. X  return(m_take_hit);
  1233. X}
  1234. X
  1235. X
  1236. X/* Player attacks a (poor, defenseless) creature    -RAK-    */
  1237. Xvoid py_attack(y, x)
  1238. Xint y, x;
  1239. X{
  1240. X  register int k, blows;
  1241. X  int crptr, monptr, tot_tohit, base_tohit;
  1242. X  vtype m_name, out_val;
  1243. X  register inven_type *i_ptr;
  1244. X  register struct misc *p_ptr;
  1245. X#ifdef ATARIST_MWC
  1246. X  int32u holder;
  1247. X#endif
  1248. X
  1249. X  crptr = cave[y][x].cptr;
  1250. X  monptr = m_list[crptr].mptr;
  1251. X  m_list[crptr].csleep = 0;
  1252. X  i_ptr = &inventory[INVEN_WIELD];
  1253. X  /* Does the player know what he's fighting?       */
  1254. X  if (!m_list[crptr].ml)
  1255. X    (void) strcpy(m_name, "it");
  1256. X  else
  1257. X    (void) sprintf(m_name, "the %s", c_list[monptr].name);
  1258. X  if (i_ptr->tval != TV_NOTHING)        /* Proper weapon */
  1259. X    blows = attack_blows((int)i_ptr->weight, &tot_tohit);
  1260. X  else                      /* Bare hands?   */
  1261. X    {
  1262. X      blows = 2;
  1263. X      tot_tohit = -3;
  1264. X    }
  1265. X  if ((i_ptr->tval >= TV_SLING_AMMO) && (i_ptr->tval <= TV_SPIKE))
  1266. X    /* Fix for arrows */
  1267. X    blows = 1;
  1268. X  p_ptr = &py.misc;
  1269. X  tot_tohit += p_ptr->ptohit;
  1270. X  /* if creature not lit, make it more difficult to hit */
  1271. X  if (m_list[crptr].ml)
  1272. X    base_tohit = p_ptr->bth;
  1273. X  else
  1274. X    base_tohit = (p_ptr->bth / 2) - (tot_tohit * (BTH_PLUS_ADJ-1))
  1275. X      - (p_ptr->lev * class_level_adj[p_ptr->pclass][CLA_BTH] / 2);
  1276. X
  1277. X  /* Loop for number of blows,    trying to hit the critter.      */
  1278. X  do
  1279. X    {
  1280. X      if (test_hit(base_tohit, (int)p_ptr->lev, tot_tohit,
  1281. X           (int)c_list[monptr].ac, CLA_BTH))
  1282. X    {
  1283. X      (void) sprintf(out_val, "You hit %s.", m_name);
  1284. X      msg_print(out_val);
  1285. X      if (i_ptr->tval != TV_NOTHING)
  1286. X        {
  1287. X          k = pdamroll(i_ptr->damage);
  1288. X          k = tot_dam(i_ptr, k, monptr);
  1289. X          k = critical_blow((int)i_ptr->weight, tot_tohit, k, CLA_BTH);
  1290. X        }
  1291. X      else                  /* Bare hands!?  */
  1292. X        {
  1293. X          k = damroll(1, 1);
  1294. X          k = critical_blow(1, 0, k, CLA_BTH);
  1295. X        }
  1296. X      k += p_ptr->ptodam;
  1297. X      if (k < 0)  k = 0;
  1298. X
  1299. X      if (py.flags.confuse_monster)
  1300. X        {
  1301. X          py.flags.confuse_monster = FALSE;
  1302. X          msg_print("Your hands stop glowing.");
  1303. X          if ((c_list[monptr].cdefense & CD_NO_SLEEP)
  1304. X          || (randint(MAX_MONS_LEVEL) < c_list[monptr].level))
  1305. X        (void) sprintf(out_val, "%s is unaffected.", m_name);
  1306. X          else
  1307. X        {
  1308. X          (void) sprintf(out_val, "%s appears confused.", m_name);
  1309. X          m_list[crptr].confused = TRUE;
  1310. X        }
  1311. X          msg_print(out_val);
  1312. X          if (m_list[crptr].ml && randint(4) == 1)
  1313. X        c_recall[monptr].r_cdefense |=
  1314. X          c_list[monptr].cdefense & CD_NO_SLEEP;
  1315. X        }
  1316. X
  1317. X      /* See if we done it in.                 */
  1318. X      if (mon_take_hit(crptr, k) >= 0)
  1319. X        {
  1320. X          (void) sprintf(out_val, "You have slain %s.", m_name);
  1321. X          msg_print(out_val);
  1322. X          prt_experience();
  1323. X          blows = 0;
  1324. X        }
  1325. X
  1326. X      if ((i_ptr->tval >= TV_SLING_AMMO)
  1327. X          && (i_ptr->tval <= TV_SPIKE)) /* Use missiles up*/
  1328. X        {
  1329. X          i_ptr->number--;
  1330. X          inven_weight -= i_ptr->weight;
  1331. X#ifdef ATARIST_MWC
  1332. X          py.flags.status |= (holder = PY_STR_WGT);
  1333. X#else
  1334. X          py.flags.status |= PY_STR_WGT;
  1335. X#endif
  1336. X          if (i_ptr->number == 0)
  1337. X        {
  1338. X          equip_ctr--;
  1339. X          py_bonuses(i_ptr, -1);
  1340. X          invcopy(i_ptr, OBJ_NOTHING);
  1341. X          calc_bonuses();
  1342. X        }
  1343. X        }
  1344. X    }
  1345. X      else
  1346. X    {
  1347. X      (void) sprintf(out_val, "You miss %s.", m_name);
  1348. X      msg_print(out_val);
  1349. X    }
  1350. X      blows--;
  1351. X    }
  1352. X  while (blows >= 1);
  1353. X}
  1354. X
  1355. X
  1356. X/* Moves player from one space to another.        -RAK-    */
  1357. X/* Note: This routine has been pre-declared; see that for argument*/
  1358. Xvoid move_char(dir, do_pickup)
  1359. Xint dir, do_pickup;
  1360. X{
  1361. X  int old_row, old_col, old_find_flag;
  1362. X  int y, x;
  1363. X  register int i, j;
  1364. X  register cave_type *c_ptr, *d_ptr;
  1365. X
  1366. X  if ((py.flags.confused > 0) &&    /* Confused?         */
  1367. X      (randint(4) > 1) &&        /* 75% random movement   */
  1368. X      (dir != 5))            /* Never random if sitting*/
  1369. X    {
  1370. X      dir = randint(9);
  1371. X      end_find();
  1372. X    }
  1373. X  y = char_row;
  1374. X  x = char_col;
  1375. X  if (mmove(dir, &y, &x))    /* Legal move?          */
  1376. X    {
  1377. X      c_ptr = &cave[y][x];
  1378. X      /* if there is no creature, or an unlit creature in the walls then... */
  1379. X      /* disallow attacks against unlit creatures in walls because moving into
  1380. X     a wall is a free turn normally, hence don't give player free turns
  1381. X     attacking each wall in an attempt to locate the invisible creature,
  1382. X     instead force player to tunnel into walls which always takes a turn */
  1383. X      if ((c_ptr->cptr < 2)
  1384. X      || (!m_list[c_ptr->cptr].ml && c_ptr->fval >= MIN_CLOSED_SPACE))
  1385. X    {
  1386. X      if (c_ptr->fval <= MAX_OPEN_SPACE) /* Open floor spot    */
  1387. X        {
  1388. X          /* Make final assignments of char co-ords */
  1389. X          old_row = char_row;
  1390. X          old_col = char_col;
  1391. X          char_row = y;
  1392. X          char_col = x;
  1393. X          /* Move character record (-1)           */
  1394. X          move_rec(old_row, old_col, char_row, char_col);
  1395. X          /* Check for new panel               */
  1396. X          if (get_panel(char_row, char_col, FALSE))
  1397. X        prt_map();
  1398. X          /* Check to see if he should stop           */
  1399. X          if (find_flag)
  1400. X        area_affect(dir, char_row, char_col);
  1401. X          /* Check to see if he notices something  */
  1402. X          /* fos may be negative if have good rings of searching */
  1403. X          if ((py.misc.fos <= 1) || (randint(py.misc.fos) == 1) ||
  1404. X          (py.flags.status & PY_SEARCH))
  1405. X        search(char_row, char_col, py.misc.srh);
  1406. X          /* A room of light should be lit.         */
  1407. X          if (c_ptr->fval == LIGHT_FLOOR)
  1408. X        {
  1409. X          if (!c_ptr->pl && !py.flags.blind)
  1410. X            light_room(char_row, char_col);
  1411. X        }
  1412. X          /* In doorway of light-room?           */
  1413. X          else if (c_ptr->lr && (py.flags.blind < 1))
  1414. X        for (i = (char_row - 1); i <= (char_row + 1); i++)
  1415. X          for (j = (char_col - 1); j <= (char_col + 1); j++)
  1416. X            {
  1417. X              d_ptr = &cave[i][j];
  1418. X              if ((d_ptr->fval == LIGHT_FLOOR) && (!d_ptr->pl))
  1419. X            light_room(i, j);
  1420. X            }
  1421. X          /* Move the light source               */
  1422. X          move_light(old_row, old_col, char_row, char_col);
  1423. X          /* An object is beneath him.         */
  1424. X          if (c_ptr->tptr != 0)
  1425. X        {
  1426. X          carry(char_row, char_col, do_pickup);
  1427. X          /* if stepped on falling rock trap, and space contains
  1428. X             rubble, then step back into a clear area */
  1429. X          if (t_list[c_ptr->tptr].tval == TV_RUBBLE)
  1430. X            {
  1431. X              move_rec(char_row, char_col, old_row, old_col);
  1432. X              move_light(char_row, char_col, old_row, old_col);
  1433. X              char_row = old_row;
  1434. X              char_col = old_col;
  1435. X              /* check to see if we have stepped back onto another
  1436. X             trap, if so, set it off */
  1437. X              c_ptr = &cave[char_row][char_col];
  1438. X              if (c_ptr->tptr != 0)
  1439. X            {
  1440. X              i = t_list[c_ptr->tptr].tval;
  1441. X              if (i == TV_INVIS_TRAP || i == TV_VIS_TRAP
  1442. X                  || i == TV_STORE_DOOR)
  1443. X                hit_trap(char_row, char_col);
  1444. X            }
  1445. X            }
  1446. X        }
  1447. X        }
  1448. X      else      /*Can't move onto floor space*/
  1449. X        {
  1450. X          if (!find_flag && (c_ptr->tptr != 0))
  1451. X        {
  1452. X          if (t_list[c_ptr->tptr].tval == TV_RUBBLE)
  1453. X            msg_print("There is rubble blocking your way.");
  1454. X          else if (t_list[c_ptr->tptr].tval == TV_CLOSED_DOOR)
  1455. X            msg_print("There is a closed door blocking your way.");
  1456. X        }
  1457. X          else
  1458. X        end_find();
  1459. X          free_turn_flag = TRUE;
  1460. X        }
  1461. X    }
  1462. X      else      /* Attacking a creature! */
  1463. X    {
  1464. X      old_find_flag = find_flag;
  1465. X      end_find();
  1466. X      /* if player can see monster, and was in find mode, then nothing */
  1467. X      if (m_list[c_ptr->cptr].ml && old_find_flag)
  1468. X        {
  1469. X          /* did not do anything this turn */
  1470. X          free_turn_flag = TRUE;
  1471. X        }
  1472. X      else
  1473. X        {
  1474. X          if (py.flags.afraid < 1)        /* Coward?    */
  1475. X        py_attack(y, x);
  1476. X          else                /* Coward!    */
  1477. X        msg_print("You are too afraid!");
  1478. X        }
  1479. X    }
  1480. X    }
  1481. X}
  1482. X
  1483. X
  1484. X/* Chests have traps too.                -RAK-    */
  1485. X/* Note: Chest traps are based on the FLAGS value         */
  1486. Xvoid chest_trap(y, x)
  1487. Xint y, x;
  1488. X{
  1489. X  register int i;
  1490. X  int j, k;
  1491. X  register inven_type *t_ptr;
  1492. X
  1493. X  t_ptr = &t_list[cave[y][x].tptr];
  1494. X  if (CH_LOSE_STR & t_ptr->flags)
  1495. X    {
  1496. X      msg_print("A small needle has pricked you!");
  1497. X      if (!py.flags.sustain_str)
  1498. X    {
  1499. X      (void) dec_stat(A_STR);
  1500. X      take_hit(damroll(1, 4), "a poison needle");
  1501. X      msg_print("You feel weakened!");
  1502. X    }
  1503. X      else
  1504. X    msg_print("You are unaffected.");
  1505. X    }
  1506. X  if (CH_POISON & t_ptr->flags)
  1507. X    {
  1508. X      msg_print("A small needle has pricked you!");
  1509. X      take_hit(damroll(1, 6), "a poison needle");
  1510. X      py.flags.poisoned += 10 + randint(20);
  1511. X    }
  1512. X  if (CH_PARALYSED & t_ptr->flags)
  1513. X    {
  1514. X      msg_print("A puff of yellow gas surrounds you!");
  1515. X      if (py.flags.free_act)
  1516. X    msg_print("You are unaffected.");
  1517. X      else
  1518. X    {
  1519. X      msg_print("You choke and pass out.");
  1520. X      py.flags.paralysis = 10 + randint(20);
  1521. X    }
  1522. X    }
  1523. X  if (CH_SUMMON & t_ptr->flags)
  1524. X    {
  1525. X      for (i = 0; i < 3; i++)
  1526. X    {
  1527. X      j = y;
  1528. X      k = x;
  1529. X      (void) summon_monster(&j, &k, FALSE);
  1530. X    }
  1531. X    }
  1532. X  if (CH_EXPLODE & t_ptr->flags)
  1533. X    {
  1534. X      msg_print("There is a sudden explosion!");
  1535. X      (void) delete_object(y, x);
  1536. X      take_hit(damroll(5, 8), "an exploding chest");
  1537. X    }
  1538. X}
  1539. X
  1540. X
  1541. X/* Opens a closed door or closed chest.        -RAK-    */
  1542. Xvoid openobject()
  1543. X{
  1544. X  int y, x, i, dir;
  1545. X  int flag, no_object;
  1546. X  register cave_type *c_ptr;
  1547. X  register inven_type *t_ptr;
  1548. X  register struct misc *p_ptr;
  1549. X  register monster_type *m_ptr;
  1550. X  vtype m_name, out_val;
  1551. X#ifdef ATARIST_MWC
  1552. X  int32u holder;
  1553. X#endif
  1554. X
  1555. X  y = char_row;
  1556. X  x = char_col;
  1557. X  if (get_dir(CNIL, &dir))
  1558. X    {
  1559. X      (void) mmove(dir, &y, &x);
  1560. X      c_ptr = &cave[y][x];
  1561. X      no_object = FALSE;
  1562. X      if (c_ptr->cptr > 1 && c_ptr->tptr != 0 &&
  1563. X      (t_list[c_ptr->tptr].tval == TV_CLOSED_DOOR
  1564. X       || t_list[c_ptr->tptr].tval == TV_CHEST))
  1565. X    {
  1566. X      m_ptr = &m_list[c_ptr->cptr];
  1567. X      if (m_ptr->ml)
  1568. X        (void) sprintf (m_name, "The %s", c_list[m_ptr->mptr].name);
  1569. X      else
  1570. X        (void) strcpy (m_name, "Something");
  1571. X      (void) sprintf(out_val, "%s is in your way!", m_name);
  1572. X      msg_print(out_val);
  1573. X    }
  1574. X      else if (c_ptr->tptr != 0)
  1575. X    /* Closed door         */
  1576. X    if (t_list[c_ptr->tptr].tval == TV_CLOSED_DOOR)
  1577. X      {
  1578. X        t_ptr = &t_list[c_ptr->tptr];
  1579. X        if (t_ptr->p1 > 0)     /* It's locked.    */
  1580. X          {
  1581. X        p_ptr = &py.misc;
  1582. X        i = p_ptr->disarm + 2*todis_adj() + stat_adj(A_INT)
  1583. X          + (class_level_adj[p_ptr->pclass][CLA_DISARM]
  1584. X             * p_ptr->lev / 3);
  1585. X        if (py.flags.confused > 0)
  1586. X          msg_print("You are too confused to pick the lock.");
  1587. X        else if ((i-t_ptr->p1) > randint(100))
  1588. X          {
  1589. X            msg_print("You have picked the lock.");
  1590. X            py.misc.exp++;
  1591. X            prt_experience();
  1592. X            t_ptr->p1 = 0;
  1593. X          }
  1594. X        else
  1595. X          count_msg_print("You failed to pick the lock.");
  1596. X          }
  1597. X        else if (t_ptr->p1 < 0)     /* It's stuck      */
  1598. X          msg_print("It appears to be stuck.");
  1599. X        if (t_ptr->p1 == 0)
  1600. X          {
  1601. X        invcopy(&t_list[c_ptr->tptr], OBJ_OPEN_DOOR);
  1602. X        c_ptr->fval = CORR_FLOOR;
  1603. X        lite_spot(y, x);
  1604. X        command_count = 0;
  1605. X          }
  1606. X      }
  1607. X      /* Open a closed chest.             */
  1608. X    else if (t_list[c_ptr->tptr].tval == TV_CHEST)
  1609. X      {
  1610. X        p_ptr = &py.misc;
  1611. X        i = p_ptr->disarm + 2*todis_adj() + stat_adj(A_INT)
  1612. X          + (class_level_adj[p_ptr->pclass][CLA_DISARM] * p_ptr->lev / 3);
  1613. X        t_ptr = &t_list[c_ptr->tptr];
  1614. X        flag = FALSE;
  1615. X        if (CH_LOCKED & t_ptr->flags)
  1616. X          if (py.flags.confused > 0)
  1617. X        msg_print("You are too confused to pick the lock.");
  1618. X          else if ((i-(int)t_ptr->level) > randint(100))
  1619. X        {
  1620. X          msg_print("You have picked the lock.");
  1621. X          flag = TRUE;
  1622. X          py.misc.exp += t_ptr->level;
  1623. X          prt_experience();
  1624. X        }
  1625. X          else
  1626. X        count_msg_print("You failed to pick the lock.");
  1627. X        else
  1628. X          flag = TRUE;
  1629. X        if (flag)
  1630. X          {
  1631. X        t_ptr->flags &= ~CH_LOCKED;
  1632. X        t_ptr->name2 = SN_EMPTY;
  1633. X        known2(t_ptr);
  1634. X        t_ptr->cost = 0;
  1635. X          }
  1636. X        flag = FALSE;
  1637. X        /* Was chest still trapped?     (Snicker)   */
  1638. X        if ((CH_LOCKED & t_ptr->flags) == 0)
  1639. X          {
  1640. X        chest_trap(y, x);
  1641. X        if (c_ptr->tptr != 0)
  1642. X          flag = TRUE;
  1643. X          }
  1644. X        /* Chest treasure is allocated as if a creature   */
  1645. X        /* had been killed.                   */
  1646. X        if (flag)
  1647. X          {
  1648. X        /* clear the cursed chest/monster win flag, so that people
  1649. X           can not win by opening a cursed chest */
  1650. X#ifdef ATARIST_MWC
  1651. X        t_list[c_ptr->tptr].flags &= ~(holder = TR_CURSED);
  1652. X#else
  1653. X        t_list[c_ptr->tptr].flags &= ~TR_CURSED;
  1654. X#endif
  1655. X        (void) monster_death(y, x, t_list[c_ptr->tptr].flags);
  1656. X        t_list[c_ptr->tptr].flags = 0;
  1657. X          }
  1658. X      }
  1659. X    else
  1660. X      no_object = TRUE;
  1661. X      else
  1662. X    no_object = TRUE;
  1663. X
  1664. X      if (no_object)
  1665. X    {
  1666. X      msg_print("I do not see anything you can open there.");
  1667. X      free_turn_flag = TRUE;
  1668. X    }
  1669. X    }
  1670. X}
  1671. X
  1672. X
  1673. X/* Closes an open door.                -RAK-    */
  1674. Xvoid closeobject()
  1675. X{
  1676. X  int y, x, dir, no_object;
  1677. X  vtype out_val, m_name;
  1678. X  register cave_type *c_ptr;
  1679. X  register monster_type *m_ptr;
  1680. X
  1681. X  y = char_row;
  1682. X  x = char_col;
  1683. X  if (get_dir(CNIL, &dir))
  1684. X    {
  1685. X      (void) mmove(dir, &y, &x);
  1686. X      c_ptr = &cave[y][x];
  1687. X      no_object = FALSE;
  1688. X      if (c_ptr->tptr != 0)
  1689. X    if (t_list[c_ptr->tptr].tval == TV_OPEN_DOOR)
  1690. X      if (c_ptr->cptr == 0)
  1691. X        if (t_list[c_ptr->tptr].p1 == 0)
  1692. X          {
  1693. X        invcopy(&t_list[c_ptr->tptr], OBJ_CLOSED_DOOR);
  1694. X        c_ptr->fval = BLOCKED_FLOOR;
  1695. X        lite_spot(y, x);
  1696. X          }
  1697. X        else
  1698. X          msg_print("The door appears to be broken.");
  1699. X      else
  1700. X        {
  1701. X          m_ptr = &m_list[c_ptr->cptr];
  1702. X          if (m_ptr->ml)
  1703. X        (void) sprintf (m_name, "The %s", c_list[m_ptr->mptr].name);
  1704. X          else
  1705. X        (void) strcpy (m_name, "Something");
  1706. X          (void) sprintf(out_val, "%s is in your way!", m_name);
  1707. X          msg_print(out_val);
  1708. X        }
  1709. X    else
  1710. X      no_object = TRUE;
  1711. X      else
  1712. X    no_object = TRUE;
  1713. X
  1714. X      if (no_object)
  1715. X    {
  1716. X      msg_print("I do not see anything you can close there.");
  1717. X      free_turn_flag = TRUE;
  1718. X    }
  1719. X    }
  1720. X}
  1721. X
  1722. X
  1723. X/* Tunneling through real wall: 10, 11, 12        -RAK-    */
  1724. X/* Used by TUNNEL and WALL_TO_MUD                 */
  1725. Xint twall(y, x, t1, t2)
  1726. Xint y, x, t1, t2;
  1727. X{
  1728. X  register int i, j;
  1729. X  register cave_type *c_ptr;
  1730. X  int res, found;
  1731. X
  1732. X  res = FALSE;
  1733. X  if (t1 > t2)
  1734. X    {
  1735. X      c_ptr = &cave[y][x];
  1736. X      if (c_ptr->lr)
  1737. X    {
  1738. X      /* should become a room space, check to see whether it should be
  1739. X         LIGHT_FLOOR or DARK_FLOOR */
  1740. X      found = FALSE;
  1741. X      for (i = y-1; i <= y+1; i++)
  1742. X        for (j = x-1; j <= x+1; j++)
  1743. X          if (cave[i][j].fval <= MAX_CAVE_ROOM)
  1744. X        {
  1745. X          c_ptr->fval = cave[i][j].fval;
  1746. X          c_ptr->pl = cave[i][j].pl;
  1747. X          found = TRUE;
  1748. X          break;
  1749. X        }
  1750. X      if (!found)
  1751. X        {
  1752. X          c_ptr->fval = CORR_FLOOR;
  1753. X          c_ptr->pl = FALSE;
  1754. X        }
  1755. X    }
  1756. X      else
  1757. X    {
  1758. X      /* should become a corridor space */
  1759. X      c_ptr->fval  = CORR_FLOOR;
  1760. X      c_ptr->pl = FALSE;
  1761. X    }
  1762. X      c_ptr->fm = FALSE;
  1763. X      if (panel_contains(y, x))
  1764. X    if ((c_ptr->tl || c_ptr->pl) && c_ptr->tptr != 0)
  1765. X      msg_print("You have found something!");
  1766. X      lite_spot(y, x);
  1767. X      res = TRUE;
  1768. X    }
  1769. X  return(res);
  1770. X}
  1771. END_OF_FILE
  1772. if test 31365 -ne `wc -c <'source/moria3.c'`; then
  1773.     echo shar: \"'source/moria3.c'\" unpacked with wrong size!
  1774. fi
  1775. # end of 'source/moria3.c'
  1776. fi
  1777. if test ! -d 'unix' ; then
  1778.     echo shar: Creating directory \"'unix'\"
  1779.     mkdir 'unix'
  1780. fi
  1781. if test ! -d 'util' ; then
  1782.     echo shar: Creating directory \"'util'\"
  1783.     mkdir 'util'
  1784. fi
  1785. if test ! -d 'util/mc' ; then
  1786.     echo shar: Creating directory \"'util/mc'\"
  1787.     mkdir 'util/mc'
  1788. fi
  1789. if test ! -d 'util/printit' ; then
  1790.     echo shar: Creating directory \"'util/printit'\"
  1791.     mkdir 'util/printit'
  1792. fi
  1793. if test ! -d 'util/scores' ; then
  1794.     echo shar: Creating directory \"'util/scores'\"
  1795.     mkdir 'util/scores'
  1796. fi
  1797. if test ! -d 'util/weapons' ; then
  1798.     echo shar: Creating directory \"'util/weapons'\"
  1799.     mkdir 'util/weapons'
  1800. fi
  1801. if test ! -d 'vms' ; then
  1802.     echo shar: Creating directory \"'vms'\"
  1803.     mkdir 'vms'
  1804. fi
  1805. if test -f 'amiga/README' -a "${1}" != "-c" ; then 
  1806.   echo shar: Will not clobber existing file \"'amiga/README'\"
  1807. else
  1808. echo shar: Extracting \"'amiga/README'\" \(1784 characters\)
  1809. sed "s/^X//" >'amiga/README' <<'END_OF_FILE'
  1810. XThis is the readme file for the Amiga port of Umoria.  Please keep this file
  1811. Xwith any distribution of Umoria for the Amiga.
  1812. X
  1813. XVersion 5.3.1:   changed display to use Simon John Raybould's curses.  The
  1814. X    version of the curses that was used in the binary distribution was 1.22
  1815. X    with some modifications.  Because of this some of the bugs may be fixed
  1816. X    and new bugs may have been created.  Please send any bug reports to me
  1817. X    at (cgehman@hubcap.clemson.edu) or post on usenet in rec.games.moria.
  1818. X
  1819. XThe game detachs from the cli.  This was done so that the program can set
  1820. Xits own stack size.  You no longer have to set the stack higher.  I have
  1821. Xcompiled the binary distribution with stack depth checking, if anyone
  1822. XEVER gets the error "stack overflow!" tell me and I'll increase the stack
  1823. Xsize.  As far as I can tell the program only uses about 20000 bytes and
  1824. XI have set the stack to 30000, so it should be fine.
  1825. X
  1826. XThis game will work on 1 MB amigas with one disk drive.
  1827. X
  1828. XFor the game to work properly you must:
  1829. X
  1830. X1)  The game looks for the amiga environment variables.  If you don't have
  1831. X    env: set, you'll get a requester asking for it.
  1832. X
  1833. X2)  If umoria is install on a hard disk, assign moria: to the directory where
  1834. X    the binary and all of the support files are.  If the files are in
  1835. X    "dh1:games/moria" type "assign moria: dh1:games/moria".
  1836. X
  1837. X
  1838. XTo compile the game:
  1839. X
  1840. X1)  You must have Aztec C 5.0d.
  1841. X
  1842. X2)  Copy all of the files in the subdirectories "amiga" & "source" together
  1843. X    and type "make".  You must have the environment setup so that Aztec will
  1844. X    find the include files and the large code libraries (cl.lib & ml.lib).
  1845. X
  1846. X3)  If you do not want to use the assignment "moria:" to find the game, then
  1847. X    you will have to change variables in "config.h" and "makefile".
  1848. END_OF_FILE
  1849. if test 1784 -ne `wc -c <'amiga/README'`; then
  1850.     echo shar: \"'amiga/README'\" unpacked with wrong size!
  1851. fi
  1852. # end of 'amiga/README'
  1853. fi
  1854. if test -f 'amiga/timer.c' -a "${1}" != "-c" ; then 
  1855.   echo shar: Will not clobber existing file \"'amiga/timer.c'\"
  1856. else
  1857. echo shar: Extracting \"'amiga/timer.c'\" \(2271 characters\)
  1858. sed "s/^X//" >'amiga/timer.c' <<'END_OF_FILE'
  1859. X/* amiga/timer.c: high level io commands for the timer.device
  1860. X
  1861. X   Copyright (c) 1990-92 Corey Gehman, James E. Wilson
  1862. X
  1863. X   This software may be copied and distributed for educational, research, and
  1864. X   not for profit purposes provided that this copyright and statement are
  1865. X   included in all such copies. */
  1866. X
  1867. X#include <exec/memory.h>
  1868. X#include <devices/timer.h>
  1869. X#include <functions.h>
  1870. X
  1871. Xextern UBYTE *malloc();
  1872. X
  1873. Xstruct mydevice {
  1874. X   struct IORequest *readreq;
  1875. X   struct MsgPort *readport;
  1876. X   unsigned short size;
  1877. X} *currentdevice;
  1878. X
  1879. Xvoid clean(i)
  1880. Xint i;
  1881. X{
  1882. X   switch (i){
  1883. X      case 6:  if (currentdevice->readreq)
  1884. X         CloseDevice(currentdevice->readreq);
  1885. X      case 5:  if (currentdevice->readreq)
  1886. X         DeleteExtIO(currentdevice->readreq);
  1887. X      case 4:  if (currentdevice->readport)
  1888. X         DeletePort(currentdevice->readport);
  1889. X      case 1:  free(currentdevice);
  1890. X   }
  1891. X}
  1892. X
  1893. Xint openreadports(size)   /* 0=error,-1=ok */
  1894. Xint size;
  1895. X{
  1896. X   currentdevice->size=size;
  1897. X   currentdevice->readport=CreatePort("Read Port",0);
  1898. X   if (currentdevice->readport==0L) {
  1899. X      printf("The Read message port did not open\n");
  1900. X      clean(1);
  1901. X      return(0);
  1902. X   }
  1903. X   currentdevice->readreq=CreateExtIO(currentdevice->readport,size);
  1904. X   if (currentdevice->readreq==0L) {
  1905. X      printf("Read Standard IO Did Not Open\n");
  1906. X      clean(4);
  1907. X      return(0);
  1908. X   }
  1909. X   return(-1);
  1910. X}
  1911. X
  1912. Xint opentimer()         /* 0=error,-1=ok */
  1913. X{
  1914. X   currentdevice=(struct mydevice *)malloc(sizeof(struct mydevice));
  1915. X   if (currentdevice==0) {
  1916. X      printf("Not enough memory\n");
  1917. X      return(0);
  1918. X   }
  1919. X   setmem(currentdevice,sizeof(struct mydevice),0);
  1920. X   openreadports(sizeof(struct timerequest));
  1921. X   if (OpenDevice("timer.device",UNIT_VBLANK,currentdevice->readreq,0)) {
  1922. X      printf("New Timer OpenDevice Failed\n");
  1923. X      clean(5);
  1924. X      return(0);
  1925. X   }
  1926. X   currentdevice->readreq->io_Command=TR_ADDREQUEST;
  1927. X   return(-1);
  1928. X}
  1929. X
  1930. Xvoid closetimer()
  1931. X{
  1932. X   clean(6);
  1933. X}
  1934. X
  1935. Xvoid sendtimer(microsec)
  1936. Xint microsec;
  1937. X{
  1938. Xstruct timerequest *tr;
  1939. X   tr=(struct timerequest *)currentdevice->readreq;
  1940. X   tr->tr_time.tv_secs=microsec/1000000;
  1941. X   tr->tr_time.tv_micro=microsec%1000000;
  1942. X   SendIO((struct IORequest *)tr);
  1943. X}
  1944. X
  1945. Xvoid waittimer()
  1946. X{
  1947. X   Wait(1<<(currentdevice->readport->mp_SigBit));
  1948. X   GetMsg(currentdevice->readport);
  1949. X}
  1950. X
  1951. END_OF_FILE
  1952. if test 2271 -ne `wc -c <'amiga/timer.c'`; then
  1953.     echo shar: \"'amiga/timer.c'\" unpacked with wrong size!
  1954. fi
  1955. # end of 'amiga/timer.c'
  1956. fi
  1957. echo shar: End of archive 1 \(of 39\).
  1958. cp /dev/null ark1isdone
  1959. MISSING=""
  1960. 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 32 33 34 35 36 37 38 39 ; do
  1961.     if test ! -f ark${I}isdone ; then
  1962.     MISSING="${MISSING} ${I}"
  1963.     fi
  1964. done
  1965. if test "${MISSING}" = "" ; then
  1966.     echo You have unpacked all 39 archives.
  1967.     echo "Now run "bldfiles.sh" to build split files"
  1968.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1969. else
  1970.     echo You still need to unpack the following archives:
  1971.     echo "        " ${MISSING}
  1972. fi
  1973. ##  End of shell archive.
  1974. exit 0
  1975.