home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume10 / nethack3p9 / part35 < prev    next >
Internet Message Format  |  1990-07-27  |  61KB

  1. Path: uunet!wuarchive!mailrus!cornell!uw-beaver!zephyr.ens.tek.com!tekred!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v10i080:  nethack3p9 -  display oriented dungeons & dragons (Ver. 3.0i), Part35/56
  5. Message-ID: <5938@tekred.CNA.TEK.COM>
  6. Date: 12 Jul 90 16:08:14 GMT
  7. Sender: news@tekred.CNA.TEK.COM
  8. Lines: 2222
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: Izchak Miller <izchak@linc.cis.upenn.edu>
  12. Posting-number: Volume 10, Issue 80
  13. Archive-name: nethack3p9/Part35
  14. Supersedes: NetHack3: Volume 7, Issue 56-93
  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 35 (of 56)."
  25. # Contents:  amiga/Makefile.ami src/hack.c src/wield.c
  26. # Wrapped by billr@saab on Wed Jul 11 17:11:44 1990
  27. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  28. if test -f 'amiga/Makefile.ami' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'amiga/Makefile.ami'\"
  30. else
  31. echo shar: Extracting \"'amiga/Makefile.ami'\" \(21416 characters\)
  32. sed "s/^X//" >'amiga/Makefile.ami' <<'END_OF_FILE'
  33. X#    Hack Makefile.
  34. X#    SCCS Id: @(#)Makefile.ami    3.0    90/02/13
  35. X
  36. X# This makefile is arranged for compiling for the Amiga with Lattice C but
  37. X# can be configured for compiling with Manx C 3.6 with simple changes.
  38. X# The appropriate changes are identified by #[LATTICE] and #[MANX3.6] in
  39. X# this makefile as should be set according to the compiler being used.
  40. X
  41. X# The following assignments should be made before using this makefile:
  42. X#
  43. X#   HackExe:    directory where final executable should go
  44. X#   NetHack:    directory where other runtime support files should go
  45. X#   Amiga:    "amiga" directory
  46. X#   Auxil:    "auxil" directory
  47. X#   Incl:    "include" directory
  48. X#   Others:    "others" directory
  49. X#   Src1:    "src" directory (a* through l*)
  50. X#   Src2:    "src" directory (m* through po*)
  51. X#   Src3:    "src" directory (pr* through z*)
  52. X#   O_Amiga:    destination for object files from Amiga:
  53. X#   O_Others:    destination for object files from Others:
  54. X#   O_Src1:    destination for object files from Src1:
  55. X#   O_Src2:    destination for object files from Src2:
  56. X#   O_Src3:    destination for object files from Src3:
  57. X#
  58. X# Startup makefile with:
  59. X#
  60. X#[LATTICE]
  61. X#    cd NetHack:
  62. X#    lmk -f Amiga:Makefile.ami
  63. X#
  64. X#[MANX3.6]
  65. X#    cd NetHack:
  66. X#    make -f Amiga:Makefile.ami
  67. X#
  68. X# May use following targets on lmk/make command line:
  69. X#   all        do it all (default)
  70. X#   link    just create $(GAME) from object files
  71. X#   obj1    just create O_Src1 object files
  72. X#   obj2    just create O_Src2 object files
  73. X#   obj3    just create O_Src3 object files
  74. X#   obja    just create O_Amiga object files
  75. X#   objo    just create O_Others object files
  76. X#   clean    deletes the object files
  77. X#   spotless    deletes the object files, $(GAME), and more
  78. X#
  79. X
  80. X# Precompiled header file:
  81. X#   $(HDEP) should appear in any dependency list for an object file where
  82. X#   we would want to make use of the precompiled version of Incl:hack.h,
  83. X#   while $(CSYM) should appear in the C compiler command line that creates
  84. X#   any such object file.  (Changes made here should agree with the $(HDEP):
  85. X#   target that appears later in this makefile.)
  86. X#
  87. X#   Notice that since this file would be created on Ram: that we would
  88. X#   end up recompiling everything if we followed the normal make sequence.
  89. X#   Thus, we could use:
  90. X#
  91. X#[LATTICE]
  92. X#    cd NetHack:
  93. X#    lmk -f Amiga:Makefile.ami Ram:hack.sym
  94. X#    setdate Ram:hack.sym {date & time of Incl:hack.h}
  95. X#    lmk -f Amiga:Makefile.ami
  96. X#
  97. X#[MANX3.6]
  98. X#    cd NetHack:
  99. X#    make -f Amiga:Makefile.ami Ram:hack.sym
  100. X#    setdate Ram:hack.sym {date & time of Incl:hack.h}
  101. X#    make -f Amiga:Makefile.ami
  102. X
  103. X#[LATTICE]
  104. X#   If we were to use the precompiled header file feature, we would uncomment
  105. X#   these following two lines.  However, there are still problems in the
  106. X#   behavior of this feature in version 5.04, so these lines are commented
  107. X#   out for now.
  108. X
  109. X#HDEP    = Ram:hack.sym
  110. X#CSYM    = -HRam:hack.sym
  111. X
  112. X#[LATTICE]
  113. X#   If we were to use the precompiled header file feature in a newer version
  114. X#   of Lattice, we would comment out these following two lines.
  115. X
  116. XHDEP    = Incl:hack.h
  117. XCSYM    =
  118. X
  119. X#[MANX3.6]
  120. X#   If we were compiling with Aztec 3.6 and wanted to use the symbol table
  121. X#   pre-loading feature, we would uncomment these following two lines.
  122. X
  123. X#HDEP    = Ram:hack.sym
  124. X#CSYM    = +IRam:hack.sym
  125. X
  126. X
  127. X# Pathname for (optional) uudecode program:
  128. X#   If uudecode is available for use by this makefile, give its name below.
  129. X#   Use a harmless command (like echo) otherwise.
  130. X
  131. XUUDEC    = echo
  132. X#UUDEC    = uudecode
  133. X
  134. X
  135. X# Pathname for the C compiler being used.
  136. X
  137. X#[LATTICE]
  138. X
  139. XCC    = lc
  140. X
  141. X#[MANX3.6]
  142. X
  143. X#CC    = cc
  144. X
  145. X
  146. X# Compilation flags for selected C Compiler:
  147. X#   $(CFLAGS) should appear before filename arguments of $(CC) command line.
  148. X
  149. X#[LATTICE]
  150. X#   Note: do not use -ms with Lattice 5.04 (Others:lev_lex.c fails)
  151. X#   Note: make sure your CLI stack size is large or lev_comp and makedefs
  152. X#    may fail terribly - stack checking is disabled.
  153. XCFLAGS    = -b0 -cfi -d1 -iIncl: -ma -v
  154. X
  155. X#[MANX3.6]
  156. X
  157. X#CFLAGS    = +c +d -e300 -z8000 +q -iIncl:
  158. X
  159. X
  160. X# Components of varous link command lines:
  161. X#   $(LINK) should be the pathname of the linker being used (with any options
  162. X#   that should appear at the beginning of the command line).  The name of the
  163. X#   output file should appear immediately after $(LINK).  $(LIN) should appear
  164. X#   before the list of object files in each link command.  $(LLINK) should
  165. X#   appear as the list of object files in the link command line that creates
  166. X#   the NetHack executable.  $(LLIB) should appear at the end of each link
  167. X#   command line.
  168. X
  169. X#[LATTICE]
  170. X
  171. XLINK    = Blink to
  172. XLIN    = from Lib:catch.o
  173. XLLINK    = with Amiga:ami.lnk
  174. XLLIB    = lib Lib:lc.lib BATCH
  175. X
  176. X#[MANX3.6]
  177. X
  178. X#LINK    = ln +q +ss -o
  179. X#LIN    =
  180. X#LLINK    = -f Amiga:ami.lnk
  181. X#LLIB    = -lcl
  182. X
  183. X
  184. X# Name of the game:
  185. X
  186. XGAME    = HackExe:NetHack
  187. X
  188. X
  189. X# A more reasonable random number generator (recommended for the Amiga):
  190. X
  191. XRANDOBJ    = O_Others:random.o
  192. X
  193. X
  194. X.PRECIOUS:  Incl:config.h Incl:decl.h Incl:hack.h Incl:permonst.h Incl:you.h
  195. X
  196. X
  197. X# Almost nothing below this line should have to be changed.
  198. X# (Exceptions are marked by [LATTICE] and [MANX3.6].)
  199. X#
  200. X# Other things that have to be reconfigured are in config.h,
  201. X# (amiconf.h, pcconf.h), and possibly system.h, tradstdc.h.
  202. X
  203. X
  204. X# HSRC1 = \
  205. X#    Src1:allmain.c        Src1:alloc.c        Src1:apply.c \
  206. X#    Src1:artifact.c        Src1:attrib.c        Src1:bones.c \
  207. X#    Src1:cmd.c        Src1:dbridge.c        Src1:decl.c \
  208. X#    Src1:demon.c        Src1:do.c        Src1:do_name.c \
  209. X#    Src1:do_wear.c        Src1:dog.c        Src1:dogmove.c \
  210. X#    Src1:dokick.c        Src1:dothrow.c        Src1:eat.c \
  211. X#    Src1:end.c        Src1:engrave.c        Src1:exper.c \
  212. X#    Src1:extralev.c        Src1:fountain.c        Src1:getline.c \
  213. X#    Src1:hack.c        Src1:invent.c        Src1:lock.c
  214. X#
  215. X# HSRC2 = \
  216. X#    Src2:mail.c        Src2:makemon.c        Src2:mcastu.c \
  217. X#    Src2:mhitm.c        Src2:mhitu.c        Src2:mklev.c \
  218. X#    Src2:mkmaze.c        Src2:mkobj.c        Src2:mkroom.c \
  219. X#    Src2:mon.c        Src2:mondata.c        Src2:monmove.c \
  220. X#    Src2:monst.c        Src2:mthrowu.c        Src2:music.c \
  221. X#    Src2:o_init.c        Src2:objects.c        Src2:objnam.c \
  222. X#    Src2:options.c        Src2:pager.c        Src2:pickup.c \
  223. X#    Src2:polyself.c        Src2:potion.c
  224. X#
  225. X# HSRC3 = \
  226. X#    Src3:pray.c        Src3:pri.c        Src3:priest.c \
  227. X#    Src3:prisym.c        Src3:read.c        Src3:restore.c \
  228. X#    Src3:rip.c        Src3:rnd.c        Src3:rumors.c \
  229. X#    Src3:save.c        Src3:search.c        Src3:shk.c \
  230. X#    Src3:shknam.c        Src3:sit.c        Src3:sounds.c \
  231. X#    Src3:sp_lev.c        Src3:spell.c        Src3:steal.c \
  232. X#    Src3:timeout.c        Src3:topl.c        Src3:topten.c \
  233. X#    Src3:track.c        Src3:trap.c        Src3:u_init.c \
  234. X#    Src3:uhitm.c        Src3:vault.c        Src3:version.c \
  235. X#    Src3:weapon.c        Src3:were.c        Src3:wield.c \
  236. X#    Src3:wizard.c        Src3:worm.c        Src3:worn.c \
  237. X#    Src3:write.c        Src3:zap.c
  238. X
  239. X
  240. X# All .c that are part of the main NetHack program and not system specific:
  241. X
  242. X# HACKCSRC = $(HSRC1) $(HSRC2) $(HSRC3)
  243. X
  244. X
  245. X# Other .c files (duplicates commented out):
  246. X
  247. X# MAKESRC = \
  248. X#    Src2:makedefs.c #    Src2:monst.c        Src2:objects.c
  249. X#
  250. X# SPLEVSRC = \
  251. X#    Src1:lev_comp.c        Others:lev_lex.c    Src1:lev_main.c
  252. X#
  253. X# AMIGASRC = \
  254. X#    Amiga:amidos.c        Amiga:amitcap.c        Amiga:amitty.c \
  255. X#    Amiga:amiunix.c        Amiga:amiwbench.c    Amiga:amiwind.c
  256. X#
  257. X# OTHERSRC = \
  258. X#    Others:pcmain.c        Others:random.c
  259. X
  260. X
  261. X# All .c that are used:
  262. X
  263. X# CSOURCES = $(HACKCSRC) $(MAKESRC) $(SPLEVSRC) $(AMIGASRC) $(OTHERSRC)
  264. X
  265. X
  266. X# All .h files (except date.h, onames.h, pm.h, and trap.h, which would
  267. X# cause dependency loops in run through "make depend"):
  268. X
  269. X# HACKINCL = \
  270. X#    Incl:amiconf.h        Incl:anime.h        Incl:artifact.h \
  271. X#    Incl:attrib.h        Incl:color.h        Incl:config.h \
  272. X#    Incl:coord.h        Incl:decl.h        Incl:edog.h \
  273. X#    Incl:epri.h        Incl:eshk.h        Incl:extern.h \
  274. X#    Incl:flag.h        Incl:func_tab.h        Incl:global.h \
  275. X#    Incl:gold.h        Incl:hack.h        Incl:lev.h \
  276. X#    Incl:mfndpos.h        Incl:mkroom.h        Incl:monattk.h \
  277. X#    Incl:mondata.h        Incl:monflag.h        Incl:monst.h \
  278. X#    Incl:monsym.h        Incl:msdos.h        Incl:obj.h \
  279. X#    Incl:objclass.h        Incl:patchlevel.h    Incl:pcconf.h \
  280. X#    Incl:permonst.h        Incl:prop.h        Incl:rm.h \
  281. X#    Incl:sp_lev.h        Incl:spell.h        Incl:system.h \
  282. X#    Incl:tradstdc.h        Incl:vault.h        Incl:wseg.h \
  283. X#    Incl:you.h        Incl:youprop.h
  284. X
  285. X
  286. X# All .h files:
  287. X
  288. X# HSOURCES = \
  289. X#    $(HACKINCL)        Incl:date.h        Incl:onames.h \
  290. X#    Incl:pm.h        Incl:trap.h
  291. X
  292. X
  293. X# All source files:
  294. X
  295. X# SOURCES = $(CSOURCES) $(HSOURCES)
  296. X
  297. X
  298. X# Object files for makedefs:
  299. X
  300. XMAKEOBJS = \
  301. X    O_Src2:makedefs.o    O_Src2:monst.o        O_Src2:objects.o
  302. X
  303. X
  304. X# Object files for special levels compiler:
  305. X
  306. XSPLEVOBJS = \
  307. X    O_Src1:lev_comp.o    O_Others:lev_lex.o    O_Src1:lev_main.o \
  308. X    O_Src2:monst.o        O_Src2:objects.o
  309. X
  310. X
  311. X# Object files for NetHack:
  312. X
  313. XHOBJ1 = \
  314. X    O_Src1:allmain.o    O_Src1:alloc.o        O_Src1:apply.o \
  315. X    O_Src1:artifact.o    O_Src1:attrib.o        O_Src1:bones.o \
  316. X    O_Src1:cmd.o        O_Src1:dbridge.o    O_Src1:decl.o \
  317. X    O_Src1:demon.o        O_Src1:do.o        O_Src1:do_name.o \
  318. X    O_Src1:do_wear.o    O_Src1:dog.o        O_Src1:dogmove.o \
  319. X    O_Src1:dokick.o        O_Src1:dothrow.o    O_Src1:eat.o \
  320. X    O_Src1:end.o        O_Src1:engrave.o    O_Src1:exper.o \
  321. X    O_Src1:extralev.o    O_Src1:fountain.o    O_Src1:getline.o \
  322. X    O_Src1:hack.o        O_Src1:invent.o        O_Src1:lock.o
  323. X
  324. XHOBJ2 = \
  325. X    O_Src2:mail.o        O_Src2:makemon.o    O_Src2:mcastu.o \
  326. X    O_Src2:mhitm.o        O_Src2:mhitu.o        O_Src2:mklev.o \
  327. X    O_Src2:mkmaze.o        O_Src2:mkobj.o        O_Src2:mkroom.o \
  328. X    O_Src2:mon.o        O_Src2:mondata.o    O_Src2:monmove.o \
  329. X    O_Src2:monst.o        O_Src2:mthrowu.o    O_Src2:music.o \
  330. X    O_Src2:o_init.o        O_Src2:objects.o    O_Src2:objnam.o \
  331. X    O_Src2:options.o    O_Src2:pager.o        O_Src2:pickup.o \
  332. X    O_Src2:polyself.o    O_Src2:potion.o
  333. X
  334. XHOBJ3 = \
  335. X    O_Src3:pray.o        O_Src3:pri.o        O_Src3:priest.o \
  336. X    O_Src3:prisym.o        O_Src3:read.o        O_Src3:restore.o \
  337. X    O_Src3:rip.o        O_Src3:rnd.o        O_Src3:rumors.o \
  338. X    O_Src3:save.o        O_Src3:search.o        O_Src3:shk.o \
  339. X    O_Src3:shknam.o        O_Src3:sit.o        O_Src3:sounds.o \
  340. X    O_Src3:sp_lev.o        O_Src3:spell.o        O_Src3:steal.o \
  341. X    O_Src3:timeout.o    O_Src3:topl.o        O_Src3:topten.o \
  342. X    O_Src3:track.o        O_Src3:trap.o        O_Src3:u_init.o \
  343. X    O_Src3:uhitm.o        O_Src3:vault.o        O_Src3:version.o \
  344. X    O_Src3:weapon.o        O_Src3:were.o        O_Src3:wield.o \
  345. X    O_Src3:wizard.o        O_Src3:worm.o        O_Src3:worn.o \
  346. X    O_Src3:write.o        O_Src3:zap.o
  347. X
  348. XAMIGAOBJ = \
  349. X    O_Amiga:amidos.o    O_Amiga:amitcap.o    O_Amiga:amitty.o \
  350. X    O_Amiga:amiunix.o    O_Amiga:amiwbench.o    O_Amiga:amiwind.o
  351. X
  352. XOTHEROBJ = \
  353. X    O_Others:pcmain.o    $(RANDOBJ)
  354. X
  355. X
  356. X# All the object files for NetHack:
  357. X
  358. XHOBJ = $(HOBJ1) $(HOBJ2) $(HOBJ3) $(AMIGAOBJ) $(OTHEROBJ)
  359. X
  360. X
  361. X# The auxiliary runtime files:
  362. X
  363. XAUXFILES = \
  364. X    NetHack:data        NetHack:rumors        NetHack:castle \
  365. X    NetHack:endgame        NetHack:tower1        NetHack:cmdhelp \
  366. X    NetHack:help        NetHack:hh        NetHack:history \
  367. X    NetHack:license        NetHack:opthelp        NetHack:oracles \
  368. X    NetHack:perm        NetHack:record        NetHack:NetHack.cnf \
  369. X    NetHack:hack.font    NetHack:hack        NetHack:hack/8 \
  370. X    NetHack:default.icon    HackExe:NetHack.info    NetHack:NewGame.info \
  371. X    NetHack:Guidebook.info    NetHack:Guidebook NetHack:NetHackScore.info
  372. X
  373. X
  374. X# Getting down to business:
  375. X
  376. Xall:  NetHack:lev_comp $(GAME) auxilstuff
  377. X
  378. X$(GAME):  $(HOBJ)
  379. X    $(LINK) $(GAME) $(LIN) $(LLINK) $(LLIB)
  380. X
  381. Xlink:
  382. X    $(LINK) $(GAME) $(LIN) $(LLINK) $(LLIB)
  383. X
  384. Xobj1:  $(HOBJ1)
  385. Xobj2:  $(HOBJ2)
  386. Xobj3:  $(HOBJ3)
  387. Xobja:  $(AMIGAOBJ)
  388. Xobjo:  $(OTHEROBJ)
  389. X
  390. X
  391. X# The default method for creating object files:
  392. X
  393. X#[LATTICE]
  394. X
  395. X.c.o:
  396. X    $(CC) $(CFLAGS) $(CSYM) -o$@ $<
  397. X
  398. X#[MANX3.6]
  399. X
  400. X#$(HOBJ1):
  401. X#    $(CC) $(CFLAGS) $(CSYM) -o$@ Src1:$*.c
  402. X
  403. X#$(HOBJ2):
  404. X#    $(CC) $(CFLAGS) $(CSYM) -o$@ Src2:$*.c
  405. X
  406. X#$(HOBJ3):
  407. X#    $(CC) $(CFLAGS) $(CSYM) -o$@ Src3:$*.c
  408. X
  409. X#$(AMIGAOBJ):
  410. X#    $(CC) $(CFLAGS) $(CSYM) -o$@ Amiga:$*.c
  411. X
  412. X#$(OTHEROBJ):
  413. X#    $(CC) $(CFLAGS) $(CSYM) -o$@ Others:$*.c
  414. X
  415. X
  416. Xclean:
  417. X    -delete O_Amiga:\#?.o O_Others:\#?.o
  418. X    -delete O_Src1:\#?.o O_Src2:\#?.o O_Src3:\#?.o
  419. X
  420. Xspotless:  clean
  421. X    -delete $(GAME) NetHack:lev_comp NetHack:makedefs
  422. X    -delete Auxil:data Auxil:rumors
  423. X    -delete NetHack:data NetHack:rumors
  424. X    -delete NetHack:castle NetHack:endgame
  425. X    -delete NetHack:tower1 NetHack:tower2 NetHack:tower3
  426. X    -delete Incl:onames.h Incl:pm.h
  427. X    -echo > Incl:onames.h "" noline
  428. X    -wait 2
  429. X    -echo > Incl:pm.h "" noline
  430. X    -wait 2
  431. X    -setdate Src2:makedefs.c
  432. X    -wait 2
  433. X# (Make sure files exist and have timestamps in the right order for
  434. X# next compile)
  435. X
  436. X
  437. X# Creating precompiled version of Incl:hack.h to save disk I/O.
  438. X
  439. X#[LATTICE]
  440. X#   If we were to use the precompiled header file feature of Lattice C, we
  441. X#   would uncomment the following lines.  However, there are still problems
  442. X#   in the behavior of this feature in version 5.04, so these lines are
  443. X#   commented out for now.  (Also see defines for HDEP and CSYM near the
  444. X#   beginning of this file, as these should be appropriately defined.)
  445. X
  446. X#$(HDEP):  Incl:hack.h NetHack:makedefs
  447. X#    echo > Ram:hackincl.c "#include <Incl:hack.h>"
  448. X#    $(CC) $(CFLAGS) -ph -o$@ Ram:hackincl.c
  449. X#    -delete Ram:hackincl.c
  450. X
  451. X#[MANX3.6]
  452. X#   If we were compiling with Aztec 3.6 and wanted to use the symbol table
  453. X#   pre-loading feature, we would uncomment these following two lines.
  454. X
  455. X#$(HDEP):  Incl:hack.h NetHack:makedefs
  456. X#    $(CC) $(CFLAGS) -a -oRam:hack.asm +h$@ Incl:hack.h
  457. X#    -delete Ram:hack.asm
  458. X
  459. X
  460. X#
  461. X#    Please note:    The dependency lines for the modules here are
  462. X#            deliberately incorrect.  Including "hack.h" in
  463. X#            the dependency list would cause a dependency
  464. X#            loop.
  465. X#
  466. X
  467. XNetHack:makedefs:  $(MAKEOBJS)
  468. X    $(LINK) NetHack:makedefs $(LIN) $(MAKEOBJS) $(LLIB)
  469. X
  470. XO_Src2:makedefs.o:  Src2:makedefs.c Incl:config.h Incl:permonst.h Incl:objclass.h
  471. X    $(CC) -dMAKEDEFS_C $(CFLAGS) -o$@ Src2:makedefs.c
  472. X
  473. XNetHack:lev_comp:  $(SPLEVOBJS)
  474. X    $(LINK) NetHack:lev_comp $(LIN) $(SPLEVOBJS) $(LLIB)
  475. X
  476. XO_Src1:lev_comp.o:  Src1:lev_comp.c $(HDEP) Incl:sp_lev.h
  477. X    $(CC) -dLEV_LEX_C $(CFLAGS) -o$@ Src1:lev_comp.c
  478. X
  479. XO_Others:lev_lex.o:  Others:lev_lex.c $(HDEP) Incl:lev_comp.h Incl:sp_lev.h
  480. X    $(CC) -dLEV_LEX_C $(CFLAGS) -o$@ Others:lev_lex.c
  481. X
  482. XO_Src1:lev_main.o:  Src1:lev_main.c $(HDEP)
  483. X    $(CC) -dLEV_LEX_C -dAMIGA $(CFLAGS) -o$@ Src1:lev_main.c
  484. X
  485. X#
  486. X#    The following include files depend on makedefs to be created.
  487. X#    As a result, they are not defined in HACKINCL, instead, their
  488. X#    dependencies are explicitly outlined here.
  489. X#
  490. X
  491. X#
  492. X#    date.h should be remade any time any of the source or include code
  493. X#    is modified.  Unfortunately, this would make the contents of this
  494. X#    file far more complex.    Since "hack.h" depends on most of the include
  495. X#    files, we kludge around this by making date.h dependent on hack.h,
  496. X#    even though it doesn't include this file.
  497. X#
  498. X
  499. XIncl:date.h:  $(HDEP) NetHack:makedefs $(AMIGAOBJ)
  500. X    NetHack:makedefs -v
  501. X
  502. XIncl:trap.h:  NetHack:makedefs
  503. X    NetHack:makedefs -t
  504. X    -copy makedefs.1 $@
  505. X
  506. XIncl:onames.h:  NetHack:makedefs
  507. X    NetHack:makedefs -o
  508. X
  509. XIncl:pm.h:  NetHack:makedefs
  510. X    NetHack:makedefs -p
  511. X
  512. X#
  513. X#    The following programs vary depending on what OS you are using.
  514. X#    As a result, they are not defined in HACKSRC and their dependancies
  515. X#    are explicitly outlined here.
  516. X#
  517. X
  518. XO_Amiga:amidos.o:  Amiga:amidos.c $(HDEP)
  519. X
  520. XO_Amiga:amitcap.o:  Amiga:amitcap.c $(HDEP)
  521. X
  522. XO_Amiga:amitty.o:  Amiga:amitty.c $(HDEP)
  523. X
  524. XO_Amiga:amiunix.o:  Amiga:amiunix.c $(HDEP)
  525. X
  526. XO_Amiga:amiwind.o:  Amiga:amiwind.c Amiga:amimenu.c $(HDEP)
  527. X
  528. XO_Amiga:amiwbench.o:  Amiga:amiwbench.c $(HDEP)
  529. X
  530. XO_Others:random.o:  Others:random.c
  531. X    $(CC) $(CFLAGS) -o$@ Others:random.c
  532. X
  533. XO_Others:pcmain.o:  Others:pcmain.c $(HDEP)
  534. X
  535. X
  536. X# Create/copy other stuff into NetHack: directory:
  537. X
  538. Xauxilstuff:  $(AUXFILES)
  539. X
  540. XNetHack:data:  Auxil:data
  541. X    copy Auxil:data $@
  542. X
  543. XAuxil:data:  Auxil:data.base Incl:config.h NetHack:makedefs
  544. X    NetHack:makedefs -d
  545. X
  546. XNetHack:rumors:  Auxil:rumors
  547. X    copy Auxil:rumors $@
  548. X
  549. XAuxil:rumors:  Auxil:rumors.tru Auxil:rumors.fal NetHack:makedefs
  550. X    NetHack:makedefs -r
  551. X
  552. XNetHack:castle:  Auxil:castle.des NetHack:lev_comp
  553. X    NetHack:lev_comp Auxil:castle.des
  554. X
  555. XNetHack:endgame:  Auxil:endgame.des NetHack:lev_comp
  556. X    NetHack:lev_comp Auxil:endgame.des
  557. X
  558. XNetHack:tower1:  Auxil:tower.des NetHack:lev_comp
  559. X    NetHack:lev_comp Auxil:tower.des
  560. X
  561. XNetHack:cmdhelp:  Auxil:cmdhelp
  562. X    copy Auxil:cmdhelp $@
  563. X
  564. XNetHack:help:  Auxil:help
  565. X    copy Auxil:help $@
  566. X
  567. XNetHack:hh:  Auxil:hh
  568. X    copy Auxil:hh $@
  569. X
  570. XNetHack:history:  Auxil:history
  571. X    copy Auxil:history $@
  572. X
  573. XNetHack:license:  Auxil:license
  574. X    copy Auxil:license $@
  575. X
  576. XNetHack:opthelp:  Auxil:opthelp
  577. X    copy Auxil:opthelp $@
  578. X
  579. XNetHack:oracles:  Auxil:oracles
  580. X    copy Auxil:oracles $@
  581. X
  582. XNetHack:perm:
  583. X    echo > $@ "" NOLINE
  584. X
  585. XNetHack:record:
  586. X    echo > $@ "" NOLINE
  587. X
  588. XNetHack:NetHack.cnf:  Amiga:NetHack.cnf
  589. X    copy Amiga:NetHack.cnf $@
  590. X
  591. XNetHack:hack.font:  Amiga:amifont.uu
  592. X    $(UUDEC) Amiga:amifont.uu
  593. X
  594. XNetHack:hack:
  595. X    makedir $@
  596. X
  597. XNetHack:hack/8:  Amiga:amifont8.uu NetHack:hack
  598. X    $(UUDEC) Amiga:amifont8.uu
  599. X    -rename 8 hack/8
  600. X
  601. XNetHack:default.icon:  Amiga:dflticon.uu
  602. X    $(UUDEC) Amiga:dflticon.uu
  603. X
  604. XHackExe:NetHack.info:  Amiga:NHinfo.uu
  605. X    $(UUDEC) Amiga:NHinfo.uu
  606. X
  607. XNetHack:NewGame.info:  Amiga:NewGame.uu
  608. X    $(UUDEC) Amiga:NewGame.uu
  609. X
  610. XNetHack:NetHackScore.info:  Amiga:NHScore.uu
  611. X    $(UUDEC) Amiga:NHScore.uu
  612. X
  613. XNetHack:Guidebook.info:  Amiga:GBinfo.uu
  614. X    $(UUDEC) Amiga:GBinfo.uu
  615. X
  616. XNetHack:Guidebook:  Auxil:Guidebook.mss
  617. X    copy Auxil:Guidebook.mss $@
  618. X
  619. X# DO NOT DELETE THIS LINE
  620. X
  621. XO_Src1:allmain.o:  Src1:allmain.c $(HDEP)
  622. XO_Src1:alloc.o:  Src1:alloc.c Incl:config.h
  623. X    $(CC) $(CFLAGS) -o$@ Src1:alloc.c
  624. XO_Src1:apply.o:  Src1:apply.c $(HDEP) Incl:edog.h
  625. XO_Src1:artifact.o:  Src1:artifact.c $(HDEP) Incl:artifact.h
  626. XO_Src1:attrib.o:  Src1:attrib.c $(HDEP)
  627. XO_Src1:bones.o:  Src1:bones.c $(HDEP)
  628. XO_Src1:cmd.o:  Src1:cmd.c $(HDEP) Incl:func_tab.h
  629. XO_Src1:dbridge.o:  Src1:dbridge.c $(HDEP)
  630. XO_Src1:decl.o:  Src1:decl.c $(HDEP)
  631. XO_Src1:demon.o:  Src1:demon.c $(HDEP)
  632. XO_Src1:do.o:  Src1:do.c $(HDEP)
  633. XO_Src1:do_name.o:  Src1:do_name.c $(HDEP)
  634. XO_Src1:do_wear.o:  Src1:do_wear.c $(HDEP)
  635. XO_Src1:dog.o:  Src1:dog.c $(HDEP) Incl:edog.h
  636. XO_Src1:dogmove.o:  Src1:dogmove.c $(HDEP) Incl:mfndpos.h Incl:edog.h
  637. XO_Src1:dokick.o:  Src1:dokick.c $(HDEP) Incl:eshk.h
  638. XO_Src1:dothrow.o:  Src1:dothrow.c $(HDEP)
  639. XO_Src1:eat.o:  Src1:eat.c $(HDEP)
  640. XO_Src1:end.o:  Src1:end.c $(HDEP) Incl:eshk.h
  641. XO_Src1:engrave.o:  Src1:engrave.c $(HDEP)
  642. XO_Src1:exper.o:  Src1:exper.c $(HDEP)
  643. XO_Src1:extralev.o:  Src1:extralev.c $(HDEP)
  644. XO_Src1:fountain.o:  Src1:fountain.c $(HDEP)
  645. XO_Src1:getline.o:  Src1:getline.c $(HDEP) Incl:func_tab.h
  646. XO_Src1:hack.o:  Src1:hack.c $(HDEP)
  647. XO_Src1:invent.o:  Src1:invent.c $(HDEP) Incl:lev.h Incl:wseg.h
  648. XO_Src1:lock.o:  Src1:lock.c $(HDEP)
  649. XO_Src2:mail.o:  Src2:mail.c $(HDEP)
  650. XO_Src2:makemon.o:  Src2:makemon.c $(HDEP)
  651. XO_Src2:mcastu.o:  Src2:mcastu.c $(HDEP)
  652. XO_Src2:mhitm.o:  Src2:mhitm.c $(HDEP) Incl:artifact.h
  653. XO_Src2:mhitu.o:  Src2:mhitu.c $(HDEP) Incl:artifact.h Incl:edog.h
  654. XO_Src2:mklev.o:  Src2:mklev.c $(HDEP)
  655. XO_Src2:mkmaze.o:  Src2:mkmaze.c $(HDEP)
  656. XO_Src2:mkobj.o:  Src2:mkobj.c $(HDEP)
  657. XO_Src2:mkroom.o:  Src2:mkroom.c $(HDEP)
  658. XO_Src2:mon.o:  Src2:mon.c $(HDEP) Incl:mfndpos.h Incl:wseg.h
  659. XO_Src2:mondata.o:  Src2:mondata.c $(HDEP) Incl:eshk.h Incl:epri.h
  660. XO_Src2:monmove.o:  Src2:monmove.c $(HDEP) Incl:mfndpos.h Incl:artifact.h
  661. XO_Src2:monst.o:  Src2:monst.c Incl:config.h Incl:permonst.h Incl:monsym.h Incl:eshk.h Incl:vault.h Incl:epri.h Incl:color.h
  662. X    $(CC) $(CFLAGS) -o$@ Src2:monst.c
  663. XO_Src2:mthrowu.o:  Src2:mthrowu.c $(HDEP)
  664. XO_Src2:music.o:  Src2:music.c $(HDEP)
  665. XO_Src2:o_init.o:  Src2:o_init.c $(HDEP)
  666. XO_Src2:objects.o:  Src2:objects.c Incl:config.h Incl:obj.h Incl:objclass.h Incl:prop.h Incl:color.h
  667. X    $(CC) $(CFLAGS) -o$@ Src2:objects.c
  668. XO_Src2:objnam.o:  Src2:objnam.c $(HDEP)
  669. XO_Src2:options.o:  Src2:options.c $(HDEP)
  670. XO_Src2:pager.o:  Src2:pager.c $(HDEP)
  671. XO_Src2:pickup.o:  Src2:pickup.c $(HDEP)
  672. XO_Src2:polyself.o:  Src2:polyself.c $(HDEP)
  673. XO_Src2:potion.o:  Src2:potion.c $(HDEP)
  674. XO_Src3:pray.o:  Src3:pray.c $(HDEP)
  675. XO_Src3:pri.o:  Src3:pri.c $(HDEP) Incl:epri.h Incl:termcap.h
  676. XO_Src3:priest.o:  Src3:priest.c $(HDEP) Incl:mfndpos.h Incl:eshk.h Incl:epri.h
  677. XO_Src3:prisym.o:  Src3:prisym.c $(HDEP) Incl:wseg.h Incl:lev.h
  678. XO_Src3:read.o:  Src3:read.c $(HDEP)
  679. XO_Src3:restore.o:  Src3:restore.c $(HDEP) Incl:lev.h Incl:wseg.h
  680. XO_Src3:rip.o:  Src3:rip.c $(HDEP)
  681. XO_Src3:rnd.o:  Src3:rnd.c $(HDEP)
  682. XO_Src3:rumors.o:  Src3:rumors.c $(HDEP)
  683. XO_Src3:save.o:  Src3:save.c $(HDEP) Incl:lev.h Incl:wseg.h
  684. XO_Src3:search.o:  Src3:search.c $(HDEP) Incl:artifact.h
  685. XO_Src3:shk.o:  Src3:shk.c $(HDEP) Incl:eshk.h
  686. XO_Src3:shknam.o:  Src3:shknam.c $(HDEP) Incl:eshk.h
  687. XO_Src3:sit.o:  Src3:sit.c $(HDEP)
  688. XO_Src3:sounds.o:  Src3:sounds.c $(HDEP) Incl:edog.h Incl:eshk.h
  689. XO_Src3:sp_lev.o:  Src3:sp_lev.c $(HDEP) Incl:sp_lev.h
  690. XO_Src3:spell.o:  Src3:spell.c $(HDEP)
  691. XO_Src3:steal.o:  Src3:steal.c $(HDEP)
  692. XO_Src3:timeout.o:  Src3:timeout.c $(HDEP)
  693. XO_Src3:topl.o:  Src3:topl.c $(HDEP)
  694. XO_Src3:topten.o:  Src3:topten.c $(HDEP)
  695. XO_Src3:track.o:  Src3:track.c $(HDEP)
  696. XO_Src3:trap.o:  Src3:trap.c $(HDEP) Incl:edog.h
  697. XO_Src3:u_init.o:  Src3:u_init.c $(HDEP)
  698. XO_Src3:uhitm.o:  Src3:uhitm.c $(HDEP) Incl:artifact.h
  699. XO_Src3:vault.o:  Src3:vault.c $(HDEP) Incl:vault.h
  700. XO_Src3:version.o:  Src3:version.c $(HDEP) Incl:date.h Incl:patchlevel.h
  701. XO_Src3:weapon.o:  Src3:weapon.c $(HDEP)
  702. XO_Src3:were.o:  Src3:were.c $(HDEP)
  703. XO_Src3:wield.o:  Src3:wield.c $(HDEP)
  704. XO_Src3:wizard.o:  Src3:wizard.c $(HDEP)
  705. XO_Src3:worm.o:  Src3:worm.c $(HDEP) Incl:wseg.h
  706. XO_Src3:worn.o:  Src3:worn.c $(HDEP)
  707. XO_Src3:write.o:  Src3:write.c $(HDEP)
  708. XO_Src3:zap.o:  Src3:zap.c $(HDEP)
  709. XIncl:config.h:  Incl:tradstdc.h Incl:global.h
  710. X    -setdate Incl:config.h
  711. X    -wait 2
  712. XIncl:decl.h:  Incl:spell.h Incl:color.h Incl:obj.h Incl:you.h Incl:onames.h Incl:pm.h
  713. X    -setdate Incl:decl.h
  714. X    -wait 2
  715. XIncl:global.h:  Incl:coord.h Incl:vmsconf.h Incl:unixconf.h Incl:pcconf.h Incl:tosconf.h Incl:amiconf.h Incl:macconf.h
  716. X    -setdate Incl:global.h
  717. X    -wait 2
  718. XIncl:hack.h:  Incl:config.h Incl:decl.h Incl:monsym.h Incl:mkroom.h Incl:objclass.h Incl:gold.h Incl:trap.h Incl:flag.h Incl:rm.h Incl:trampoli.h
  719. X    -setdate Incl:hack.h
  720. X    -wait 2
  721. XIncl:permonst.h:  Incl:monattk.h Incl:monflag.h
  722. X    -setdate Incl:permonst.h
  723. X    -wait 2
  724. XIncl:you.h:  Incl:attrib.h Incl:monst.h Incl:youprop.h
  725. X    -setdate Incl:you.h
  726. X    -wait 2
  727. XIncl:youprop.h:  Incl:prop.h Incl:permonst.h Incl:mondata.h Incl:pm.h
  728. X    -setdate Incl:youprop.h
  729. X    -wait 2
  730. X# DEPENDENCIES MUST END AT END OF FILE
  731. X# IF YOU PUT STUFF HERE IT WILL GO AWAY
  732. X# see make depend above
  733. END_OF_FILE
  734. if test 21416 -ne `wc -c <'amiga/Makefile.ami'`; then
  735.     echo shar: \"'amiga/Makefile.ami'\" unpacked with wrong size!
  736. fi
  737. # end of 'amiga/Makefile.ami'
  738. fi
  739. if test -f 'src/hack.c' -a "${1}" != "-c" ; then 
  740.   echo shar: Will not clobber existing file \"'src/hack.c'\"
  741. else
  742. echo shar: Extracting \"'src/hack.c'\" \(28166 characters\)
  743. sed "s/^X//" >'src/hack.c' <<'END_OF_FILE'
  744. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  745. X/* NetHack may be freely redistributed.  See license for details. */
  746. X
  747. X#include "hack.h"
  748. X
  749. X#if defined(UNIX) && !defined(LINT)
  750. Xstatic    const char    SCCS_Id[] = "@(#)hack.c    3.0\t89/11/20";
  751. X#endif
  752. X
  753. XSTATIC_DCL int NDECL(moverock);
  754. X#ifdef SINKS
  755. XSTATIC_DCL void NDECL(dosinkfall);
  756. X#endif
  757. X
  758. X#ifdef OVL1
  759. Xstatic boolean FDECL(is_edge,(XCHAR_P,XCHAR_P));
  760. Xstatic boolean FDECL(bad_rock,(XCHAR_P,XCHAR_P));
  761. X#endif /* OVL1 */
  762. X
  763. X#ifdef OVLB
  764. X
  765. X/* called on movement:
  766. X    1. when throwing ball+chain far away
  767. X    2. when teleporting
  768. X    3. when walking out of a lit room
  769. X */
  770. Xvoid
  771. Xunsee() {
  772. X    register xchar x,y;
  773. X    register struct rm *lev;
  774. X
  775. X    if(seehx){
  776. X        seehx = 0;
  777. X    } 
  778. X    /*
  779. X     *  Erase surrounding positions if needed.  We don't need to do this
  780. X     *  if we are blind, since we can't see them anyway.  This removes the
  781. X     *  pl6 bug that makes monsters disappear if they are next to you if
  782. X     *  you teleport while blind and telepathic.
  783. X     */
  784. X    else if(!Blind)
  785. X        for(x = u.ux-1; x < u.ux+2; x++)
  786. X            for(y = u.uy-1; y < u.uy+2; y++) {
  787. X            if(!isok(x, y)) continue;
  788. X            lev = &levl[x][y];
  789. X            if(!lev->lit && lev->scrsym == ROOM_SYM) {
  790. X            lev->scrsym = STONE_SYM;
  791. X            lev->new = 1;
  792. X            on_scr(x,y);
  793. X            }
  794. X            }
  795. X}
  796. X
  797. X/* called:
  798. X    in apply.c:  seeoff(0)    - when taking a picture of yourself
  799. X                - when donning a blindfold
  800. X    in do.c:     seeoff(0)    - blind after drinking potion
  801. X    in do.c:     seeoff(1)    - go up or down the stairs
  802. X    in eat.c:    seeoff(0)    - blind after eating rotten food
  803. X    in mhitu.c:  seeoff(0)    - blinded by a glowing eye
  804. X    in mhitu.c:  seeoff(1)    - swallowed
  805. X    in mthrow.c: seeoff(0)    - hit by a cream pie.
  806. X    in potion.c: seeoff(0)    - quaffing or sniffing a potion of blindness
  807. X    in spell.c:  seeoff(0)    - due to a cursed spell book
  808. X    in trap.c:   seeoff(1)    - fall through trap door
  809. X */
  810. Xvoid
  811. Xseeoff(mode)
  812. Xint mode;
  813. X{        /* 1 to redo @, 0 to leave them */
  814. X        /* 1 means misc movement, 0 means blindness */
  815. X    register xchar x,y;
  816. X    register struct rm *lev;
  817. X
  818. X    if(u.udispl && mode){
  819. X        u.udispl = 0;
  820. X        levl[u.udisx][u.udisy].scrsym = news0(u.udisx,u.udisy);
  821. X    }
  822. X    if(seehx) {
  823. X        seehx = 0;
  824. X    } else
  825. X        if(!mode) {
  826. X        for(x = u.ux-1; x < u.ux+2; x++)
  827. X            for(y = u.uy-1; y < u.uy+2; y++) {
  828. X            if(!isok(x, y)) continue;
  829. X            lev = &levl[x][y];
  830. X            if(MON_AT(x, y))
  831. X                unpmon(m_at(x,y));
  832. X            if(!lev->lit && lev->scrsym == ROOM_SYM) {
  833. X                lev->seen = 0;
  834. X                atl(x, y, (char)STONE_SYM);
  835. X            }
  836. X            }
  837. X        }
  838. X}
  839. X
  840. X#endif /* OVLB */
  841. X#ifdef OVL2
  842. X
  843. XSTATIC_OVL int
  844. Xmoverock() {
  845. X    register xchar rx, ry;
  846. X    register struct obj *otmp, *otmp2;
  847. X    register struct trap *ttmp;
  848. X    register struct    monst *mtmp;
  849. X
  850. X#ifdef POLYSELF
  851. X    if (passes_walls(uasmon)) return 0;
  852. X#endif
  853. X    while(otmp = sobj_at(BOULDER, u.ux+u.dx, u.uy+u.dy)) {
  854. X        rx = u.ux+2*u.dx;
  855. X        ry = u.uy+2*u.dy;
  856. X        nomul(0);
  857. X#ifdef POLYSELF
  858. X        if (verysmall(uasmon)) {
  859. X            pline("You're too small to push that boulder.");
  860. X            goto cannot_push;
  861. X        }
  862. X#endif
  863. X        if(isok(rx,ry) && !IS_ROCK(levl[rx][ry].typ) &&
  864. X            (!IS_DOOR(levl[rx][ry].typ) || !(u.dx && u.dy) || (
  865. X#ifdef REINCARNATION
  866. X            dlevel != rogue_level &&
  867. X#endif
  868. X             (levl[rx][ry].doormask & ~D_BROKEN) == D_NODOOR)) &&
  869. X            !sobj_at(BOULDER, rx, ry)) {
  870. X            if(MON_AT(rx, ry)) {
  871. X                mtmp = m_at(rx,ry);
  872. X                if(canseemon(mtmp))
  873. X                pline("There's %s on the other side.",
  874. X                      mon_nam(mtmp));
  875. X                else
  876. X                You("hear a monster behind the boulder.");
  877. X                if(flags.verbose)
  878. X                pline("Perhaps that's why you cannot move it.");
  879. X                goto cannot_push;
  880. X            }
  881. X            if(ttmp = t_at(rx,ry))
  882. X                switch(ttmp->ttyp) {
  883. X                case SPIKED_PIT:
  884. X                case PIT:
  885. X                You("push the boulder into a pit!");
  886. X                deltrap(ttmp);
  887. X                delobj(otmp);
  888. X                if(cansee(rx,ry)) newsym(rx,ry);
  889. X                else levl[rx][ry].seen = 0;
  890. X                if(flags.verbose)
  891. X                    pline("It completely fills the pit!");
  892. X                continue;
  893. X                case TRAPDOOR:
  894. X                if(is_maze_lev
  895. X#ifdef STRONGHOLD
  896. X                    && (dlevel > stronghold_level)
  897. X#endif
  898. X                    ) break;
  899. X                pline("The boulder falls into and plugs a hole in the ground!");
  900. X                deltrap(ttmp);
  901. X                delobj(otmp);
  902. X                if(cansee(rx,ry)) newsym(rx,ry);
  903. X                else levl[rx][ry].seen = 0;
  904. X                continue;
  905. X                case LEVEL_TELEP:
  906. X                case TELEP_TRAP:
  907. X                You("push the boulder and suddenly it disappears!");
  908. X                rloco(otmp);
  909. X                continue;
  910. X                }
  911. X            if(closed_door(rx, ry))
  912. X                goto nopushmsg;
  913. X            if(is_pool(rx,ry)) {
  914. X#ifdef STRONGHOLD
  915. X                if(levl[rx][ry].typ == DRAWBRIDGE_UP)
  916. X                    levl[rx][ry].drawbridgemask |= DB_FLOOR;
  917. X                else
  918. X#endif
  919. X                    levl[rx][ry].typ = ROOM;
  920. X                mnewsym(rx,ry);
  921. X                if(!Blind) prl(rx,ry);
  922. X                You("push the boulder into the water.");
  923. X                if(flags.verbose && !Blind)
  924. X                    pline("Now you can cross the water!");
  925. X                delobj(otmp);
  926. X                continue;
  927. X            }
  928. X                /*
  929. X                 * Re-link at top of fobj chain so that 
  930. X                 * pile order is preserved when level is 
  931. X                 * restored.
  932. X                 */
  933. X            if (otmp != fobj) {
  934. X                otmp2 = fobj;
  935. X                while (otmp2->nobj && otmp2->nobj != otmp) 
  936. X                    otmp2 = otmp2->nobj;
  937. X                if (!otmp2->nobj)
  938. X                    impossible("moverock: error in fobj chain");
  939. X                else {
  940. X                    otmp2->nobj = otmp->nobj;    
  941. X                    otmp->nobj = fobj;
  942. X                    fobj = otmp;
  943. X                }
  944. X            }
  945. X            move_object(otmp, rx, ry);
  946. X            /* pobj(otmp); */
  947. X            if(cansee(rx,ry)) atl(rx,ry,otmp->olet);
  948. X            newsym(u.ux+u.dx, u.uy+u.dy);
  949. X
  950. X            {
  951. X#ifdef LINT    /* static long lastmovetime; */
  952. X            long lastmovetime;
  953. X            lastmovetime = 0;
  954. X#else
  955. X            static long NEARDATA lastmovetime;
  956. X#endif
  957. X            /* note: this var contains garbage initially and
  958. X               after a restore */
  959. X            if(moves > lastmovetime+2 || moves < lastmovetime)
  960. X            pline("With great effort you move the boulder.");
  961. X            lastmovetime = moves;
  962. X            }
  963. X        } else {
  964. Xnopushmsg:
  965. X            You("try to move the boulder, but in vain.");
  966. X        cannot_push:
  967. X#ifdef POLYSELF
  968. X            if (throws_rocks(uasmon)) {
  969. X            if(!flags.pickup)
  970. X                pline("However, you easily can push it aside.");
  971. X            else
  972. X                pline("However, you easily can pick it up.");
  973. X            break;
  974. X            }
  975. X#endif
  976. X            if((!invent || inv_weight()+90 <= 0) &&
  977. X            (!u.dx || !u.dy || (IS_ROCK(levl[u.ux][u.uy+u.dy].typ)
  978. X                    && IS_ROCK(levl[u.ux+u.dx][u.uy].typ)))
  979. X#ifdef POLYSELF
  980. X            || verysmall(uasmon)
  981. X#endif
  982. X                                    )
  983. X            {
  984. X            pline("However, you can squeeze yourself into a small opening.");
  985. X            break;
  986. X            } else
  987. X            return (-1);
  988. X        }
  989. X    }
  990. X    return (0);
  991. X}
  992. X
  993. X#endif /* OVL2 */
  994. X#ifdef OVLB
  995. X
  996. Xvoid
  997. Xmovobj(obj, ox, oy)
  998. Xregister struct obj *obj;
  999. Xregister xchar ox, oy;
  1000. X{
  1001. X    remove_object(obj);
  1002. X    if (cansee(obj->ox, obj->oy)) {
  1003. X        levl[obj->ox][obj->oy].seen = 0;
  1004. X        prl(obj->ox, obj->oy);
  1005. X    } else
  1006. X        newsym(obj->ox, obj->oy);
  1007. X    place_object(obj, ox, oy);
  1008. X    if (cansee(ox, oy)) {
  1009. X        levl[ox][oy].seen = 0;
  1010. X        prl(ox, oy);
  1011. X    } else
  1012. X        newsym(ox, oy);
  1013. X}
  1014. X
  1015. X#ifdef SINKS
  1016. XSTATIC_OVL
  1017. Xvoid
  1018. Xdosinkfall() {
  1019. X    register struct obj *obj;
  1020. X
  1021. X# ifdef POLYSELF
  1022. X    if (is_floater(uasmon)) {
  1023. X        You("wobble unsteadily for a moment.");
  1024. X    } else {
  1025. X# endif
  1026. X        You("crash to the floor!");
  1027. X        losehp((rn1(10, 20 - (int)ACURR(A_CON))),
  1028. X            "fell onto a sink", NO_KILLER_PREFIX);
  1029. X        for(obj = level.objects[u.ux][u.uy]; obj; obj = obj->nexthere)
  1030. X            if(obj->olet == WEAPON_SYM) {
  1031. X            You("fell on %s.",doname(obj));
  1032. X            losehp(rn2(3),"fell onto a sink", NO_KILLER_PREFIX);
  1033. X            }
  1034. X# ifdef POLYSELF
  1035. X    }
  1036. X# endif
  1037. X
  1038. X    HLevitation = (HLevitation & ~TIMEOUT) + 1;
  1039. X    if(uleft && uleft->otyp == RIN_LEVITATION) {
  1040. X        obj = uleft;
  1041. X        Ring_off(obj);
  1042. X        off_msg(obj);
  1043. X    }
  1044. X    if(uright && uright->otyp == RIN_LEVITATION) {
  1045. X        obj = uright;
  1046. X        Ring_off(obj);
  1047. X        off_msg(obj);
  1048. X    }
  1049. X    if(uarmf && uarmf->otyp == LEVITATION_BOOTS) {
  1050. X        obj = uarmf;
  1051. X        (void)Boots_off();
  1052. X        off_msg(obj);
  1053. X    }
  1054. X    HLevitation--;
  1055. X}
  1056. X#endif
  1057. X
  1058. X#endif /* OVLB */
  1059. X#ifdef OVL1
  1060. X
  1061. Xstatic boolean
  1062. Xis_edge(x,y)
  1063. Xregister xchar x,y;
  1064. X/* return true if (x,y) is on the edge of a room
  1065. X * we cannot rely on IS_DOOR(levl[x][y].typ) because some of the stronghold
  1066. X * "rooms" are actually outside areas without doors
  1067. X */
  1068. X{
  1069. X    register int roomno = inroom(x,y);
  1070. X
  1071. X    if(roomno < 0) return FALSE;
  1072. X    return((x == rooms[roomno].lx - 1) || (x == rooms[roomno].hx + 1) ||
  1073. X           (y == rooms[roomno].ly - 1) || (y == rooms[roomno].hy + 1));
  1074. X}
  1075. X
  1076. X#endif /* OVL1 */
  1077. X#ifdef OVLB
  1078. X
  1079. Xboolean
  1080. Xmay_dig(x,y)
  1081. Xregister xchar x,y;
  1082. X/* intended to be called only on ROCKs */
  1083. X{
  1084. Xreturn (!(IS_STWALL(levl[x][y].typ) && (levl[x][y].diggable & W_NONDIGGABLE)));
  1085. X}
  1086. X
  1087. X#endif /* OVLB */
  1088. X#ifdef OVL1
  1089. X
  1090. Xstatic boolean
  1091. Xbad_rock(x,y)
  1092. Xregister xchar x,y;
  1093. X{
  1094. X    return(IS_ROCK(levl[x][y].typ)
  1095. X#ifdef POLYSELF
  1096. X            && !passes_walls(uasmon)
  1097. X            && (!tunnels(uasmon) || needspick(uasmon) || !may_dig(x,y))
  1098. X#endif
  1099. X    );
  1100. X}
  1101. X
  1102. Xvoid
  1103. Xdomove() {
  1104. X    register struct monst *mtmp;
  1105. X    register struct rm *tmpr,*ust;
  1106. X    register xchar x,y;
  1107. X    struct trap *trap;
  1108. X
  1109. X    u_wipe_engr(rnd(5));
  1110. X
  1111. X    if(inv_weight() > 0){
  1112. X        You("collapse under your load.");
  1113. X        nomul(0);
  1114. X        return;
  1115. X    }
  1116. X    if(u.uswallow) {
  1117. X        register xchar xx,yy;
  1118. X
  1119. X        u.dx = u.dy = 0;
  1120. X        xx = u.ux;
  1121. X        yy = u.uy;
  1122. X        x = u.ux = u.ustuck->mx;
  1123. X        y = u.uy = u.ustuck->my;
  1124. X        if(xx != x || yy != y) newsym(xx,yy);
  1125. X        mtmp = u.ustuck;
  1126. X    } else {
  1127. X        x = u.ux + u.dx;
  1128. X        y = u.uy + u.dy;
  1129. X        if(Stunned || (Confusion && !rn2(5))) {
  1130. X            register int tries = 0;
  1131. X
  1132. X            do {
  1133. X                if(tries++ > 50) {
  1134. X                    nomul(0);
  1135. X                    return;
  1136. X                }
  1137. X                confdir();
  1138. X                x = u.ux + u.dx;
  1139. X                y = u.uy + u.dy;
  1140. X            } while(!isok(x, y) || bad_rock(x, y));
  1141. X        }
  1142. X        if(!isok(x, y)) {
  1143. X            nomul(0);
  1144. X            return;
  1145. X        }
  1146. X        if((trap = t_at(x, y)) && trap->tseen)
  1147. X            nomul(0);
  1148. X        if(u.ustuck && (x != u.ustuck->mx ||
  1149. X                y != u.ustuck->my)) {
  1150. X            if(dist(u.ustuck->mx, u.ustuck->my) > 2) {
  1151. X            /* perhaps it fled (or was teleported or ... ) */
  1152. X                u.ustuck = 0;
  1153. X            } else {
  1154. X#ifdef POLYSELF
  1155. X                /* If polymorphed into a sticking monster,
  1156. X                 * u.ustuck means it's stuck to you, not you
  1157. X                 * to it.
  1158. X                 */
  1159. X                if (sticks(uasmon)) {
  1160. X                    kludge("You release %s.",
  1161. X                        mon_nam(u.ustuck));
  1162. X                    u.ustuck = 0;
  1163. X                } else {
  1164. X#endif
  1165. X                    kludge("You cannot escape from %s!",
  1166. X                        mon_nam(u.ustuck));
  1167. X                    nomul(0);
  1168. X                    return;
  1169. X#ifdef POLYSELF
  1170. X                }
  1171. X#endif
  1172. X            }
  1173. X        }
  1174. X        mtmp = m_at(x,y);
  1175. X        if (mtmp) {
  1176. X            /* Don't attack if you're running */
  1177. X            if (flags.run && !mtmp->mimic &&
  1178. X                    (Blind ? Telepat :
  1179. X                     (!mtmp->minvis || See_invisible))) {
  1180. X                nomul(0);
  1181. X                flags.move = 0;
  1182. X                return;
  1183. X            }
  1184. X        }
  1185. X    }
  1186. X
  1187. X    u.ux0 = u.ux;
  1188. X    u.uy0 = u.uy;
  1189. X    tmpr = &levl[x][y];
  1190. X
  1191. X    /* attack monster */
  1192. X    if(mtmp) {
  1193. X        nomul(0);
  1194. X        gethungry();
  1195. X        if(multi < 0) return;    /* we just fainted */
  1196. X
  1197. X        /* try to attack; note that it might evade */
  1198. X        if(attack(mtmp)) return;
  1199. X    }
  1200. X
  1201. X    /* not attacking an animal, so we try to move */
  1202. X#ifdef POLYSELF
  1203. X    if(!uasmon->mmove) {
  1204. X        You("are rooted %s.", Levitation ? "in place"
  1205. X            : "to the ground");
  1206. X        nomul(0);
  1207. X        return;
  1208. X    }
  1209. X#endif
  1210. X    if(u.utrap) {
  1211. X        if(u.utraptype == TT_PIT) {
  1212. X            if(flags.verbose)
  1213. X            Norep("You are still in a pit.");
  1214. X            u.utrap--;
  1215. X        } else if (u.utraptype == TT_WEB) {
  1216. X            if(flags.verbose)
  1217. X                Norep("You are stuck to the web.");
  1218. X            u.utrap--;
  1219. X        } else {
  1220. X            if(flags.verbose)
  1221. X            Norep("You are caught in a bear trap.");
  1222. X            if((u.dx && u.dy) || !rn2(5)) u.utrap--;
  1223. X        }
  1224. X        return;
  1225. X    }
  1226. X    /* check for physical obstacles */
  1227. X#ifdef POLYSELF
  1228. X    if (!passes_walls(uasmon)) {
  1229. X#endif
  1230. X#ifdef STRONGHOLD
  1231. X        if(dlevel == stronghold_level && is_db_wall(x,y)) {
  1232. X            pline("The drawbridge is up!");
  1233. X            nomul(0);
  1234. X            return;
  1235. X        }
  1236. X#endif
  1237. X        if(closed_door(x, y)) {
  1238. X#ifdef POLYSELF
  1239. X        if(amorphous(uasmon))
  1240. X            You("ooze under the door.");
  1241. X        else {
  1242. X#endif
  1243. X            flags.move = 0;
  1244. X            if(x == u.ux || y == u.uy) {
  1245. X                if (Blind || Stunned || ACURR(A_DEX) < 10 || Fumbling)
  1246. X                pline("Ouch!  You bump into a door.");
  1247. X                 else pline("That door is closed.");
  1248. X            }
  1249. X            nomul(0);
  1250. X            return;
  1251. X#ifdef POLYSELF
  1252. X        }
  1253. X#endif
  1254. X        }
  1255. X#ifdef POLYSELF
  1256. X    }
  1257. X#endif
  1258. X    ust = &levl[u.ux][u.uy];
  1259. X
  1260. X    if(bad_rock(x,y) ||
  1261. X       (u.dx && u.dy
  1262. X#ifdef POLYSELF
  1263. X         && !passes_walls(uasmon)
  1264. X#endif
  1265. X         && ( (IS_DOOR(ust->typ) && block_entry(x, y)) ||
  1266. X#ifdef REINCARNATION
  1267. X            (IS_DOOR(tmpr->typ) &&
  1268. X             ((tmpr->doormask & ~D_BROKEN) 
  1269. X               || dlevel == rogue_level || block_door(x, y))
  1270. X                        )  
  1271. X             || (IS_DOOR(ust->typ) &&
  1272. X             ((ust->doormask & ~D_BROKEN) || dlevel == rogue_level)
  1273. X                        )
  1274. X#else
  1275. X            (IS_DOOR(tmpr->typ) &&
  1276. X             ((tmpr->doormask & ~D_BROKEN) || block_door(x, y))) ||
  1277. X            (IS_DOOR(ust->typ) && (ust->doormask & ~D_BROKEN))
  1278. X#endif
  1279. X            )
  1280. X       )) {
  1281. X        flags.move = 0;
  1282. X        nomul(0);
  1283. X        return;
  1284. X    }
  1285. X    if(moverock() < 0) return;
  1286. X    if(u.dx && u.dy && bad_rock(u.ux,y) &&
  1287. X               bad_rock(x,u.uy)) {
  1288. X#ifdef POLYSELF
  1289. X        if (bigmonst(uasmon)) {
  1290. X        Your("body is too large to fit through.");
  1291. X        nomul(0);
  1292. X        return;
  1293. X        }
  1294. X#endif
  1295. X        if (invent && inv_weight()+40 > 0) {
  1296. X        You("are carrying too much to get through.");
  1297. X        nomul(0);
  1298. X        return;
  1299. X        }
  1300. X    }
  1301. X    if(Punished &&
  1302. X       dist2(x, y, uchain->ox, uchain->oy) > 2) {
  1303. X        if(carried(uball)) {
  1304. X            movobj(uchain, u.ux, u.uy);
  1305. X            goto nodrag;
  1306. X        }
  1307. X
  1308. X        if(dist2(x, y, uball->ox, uball->oy) < 3) {
  1309. X            /* leave ball, move chain under/over ball */
  1310. X            movobj(uchain, uball->ox, uball->oy);
  1311. X            goto nodrag;
  1312. X        }
  1313. X
  1314. X        if(inv_weight() + (int)(uball->owt >> 1) > 0) {
  1315. X            You("cannot %sdrag the heavy iron ball.",
  1316. X            invent ? "carry all that and also " : "");
  1317. X            nomul(0);
  1318. X            return;
  1319. X        }
  1320. X
  1321. X        movobj(uball, uchain->ox, uchain->oy);
  1322. X        movobj(uchain, u.ux, u.uy);
  1323. X        nomul(-2);
  1324. X        nomovemsg = "";
  1325. X    nodrag:    ;
  1326. X    }
  1327. X#ifdef POLYSELF
  1328. X    if (tunnels(uasmon) && !needspick(uasmon) && IS_ROCK(tmpr->typ)) {
  1329. X        static const char NEARDATA *digtxt;
  1330. X
  1331. X        if(dig_pos.x != x || dig_pos.y != y
  1332. X            || dig_level != dlevel || dig_down) {
  1333. X            dig_down = FALSE;
  1334. X            dig_pos.x = x;
  1335. X            dig_pos.y = y;
  1336. X            dig_level = dlevel;
  1337. X            dig_effort = 30;
  1338. X            You("start chewing a hole in the rock.");
  1339. X            return;
  1340. X        } else if ((dig_effort += 30) < 100)  {
  1341. X            if(flags.verbose)
  1342. X            You("continue chewing the rock up.");
  1343. X            return;
  1344. X        } else {
  1345. X            if (IS_WALL(tmpr->typ)) {
  1346. X                digtxt = "You chew a hole in the wall.";
  1347. X                if(!is_maze_lev)
  1348. X                  tmpr->typ = DOOR;
  1349. X                else
  1350. X                  tmpr->typ = ROOM;
  1351. X            } else if (tmpr->typ==SDOOR) {
  1352. X                digtxt = "You chew through a secret door.";
  1353. X                tmpr->typ = DOOR;
  1354. X                if(!(tmpr->doormask & D_TRAPPED))
  1355. X                    tmpr->doormask = D_BROKEN;
  1356. X            } else {
  1357. X                digtxt = "You chew a passage through the rock.";
  1358. X                tmpr->typ = CORR;
  1359. X            }
  1360. X            mnewsym(x, y);
  1361. X            prl(x, y);
  1362. X            pline(digtxt);
  1363. X            if(IS_DOOR(tmpr->typ) && (tmpr->doormask & D_TRAPPED)) {
  1364. X                b_trapped("door");
  1365. X                tmpr->doormask = D_NODOOR;
  1366. X                mnewsym(x, y);
  1367. X                prl(x, y);
  1368. X            }
  1369. X            dig_level = -1;
  1370. X        }
  1371. X    }
  1372. X#endif
  1373. X    u.ux += u.dx;
  1374. X    u.uy += u.dy;
  1375. X    reset_occupations();
  1376. X    if(flags.run) {
  1377. X        if(IS_DOOR(tmpr->typ) ||
  1378. X#ifdef POLYSELF
  1379. X        (IS_ROCK(tmpr->typ)) ||
  1380. X#endif
  1381. X        (xupstair == u.ux && yupstair == u.uy) ||
  1382. X        (xdnstair == u.ux && ydnstair == u.uy)
  1383. X#ifdef STRONGHOLD
  1384. X        || (xupladder == u.ux && yupladder == u.uy)
  1385. X        || (xdnladder == u.ux && ydnladder == u.uy)
  1386. X#endif
  1387. X#ifdef FOUNTAINS
  1388. X        || IS_FOUNTAIN(tmpr->typ)
  1389. X#endif
  1390. X#ifdef THRONES
  1391. X        || IS_THRONE(tmpr->typ)
  1392. X#endif
  1393. X#ifdef SINKS
  1394. X        || IS_SINK(tmpr->typ)
  1395. X#endif
  1396. X#ifdef ALTARS
  1397. X        || IS_ALTAR(tmpr->typ)
  1398. X#endif
  1399. X        )
  1400. X            nomul(0);
  1401. X    }
  1402. X#ifdef POLYSELF
  1403. X    if (hides_under(uasmon))
  1404. X        u.uundetected = (OBJ_AT(u.ux, u.uy) || levl[u.ux][u.uy].gmask);
  1405. X    else if (u.dx || u.dy) { /* piercer */
  1406. X        if (u.usym == S_MIMIC_DEF)
  1407. X        u.usym = S_MIMIC;
  1408. X        u.uundetected = 0;
  1409. X    }
  1410. X#endif
  1411. X
  1412. X/*
  1413. X    if(u.udispl) {
  1414. X        u.udispl = 0;
  1415. X        newsym(u.ux0,u.uy0);
  1416. X    }
  1417. X*/
  1418. X    if(!Blind) {
  1419. X        register xchar backx = u.ux0 - u.dx;   /* one step beyond old pos */
  1420. X        register xchar backy = u.uy0 - u.dy;
  1421. X        register xchar frontx = u.ux + u.dx;   /* one step beyond new pos */
  1422. X        register xchar fronty = u.uy + u.dy;
  1423. X        register boolean newedge = is_edge(u.ux,u.uy);
  1424. X        register boolean oldedge = is_edge(u.ux0,u.uy0);
  1425. X
  1426. X        /* ust is old position, tmpr is new position */
  1427. X        if(oldedge && newedge && inroom(u.ux0,u.uy0) == inroom(u.ux,u.uy)) {
  1428. X        /* moving along wall */
  1429. X        nose1(backx,backy);
  1430. X        prl1(frontx,fronty);
  1431. X
  1432. X        } else if(oldedge || newedge) {
  1433. X        if(isok(backx,backy) && levl[backx][backy].lit)
  1434. X            setsee();
  1435. X        else
  1436. X            nose1(backx,backy);
  1437. X
  1438. X        if(isok(frontx,fronty) && levl[frontx][fronty].lit)
  1439. X            setsee();
  1440. X        else {
  1441. X            prl1(frontx,fronty);
  1442. X            prl1(u.ux,u.uy);    /* make sure side walls are seen */
  1443. X        }
  1444. X
  1445. X        } else if(!tmpr->lit) {
  1446. X        /* we haven't crossed an edge, so old & new are both light or
  1447. X         * both dark.  if both light, we need do nothing.
  1448. X         */
  1449. X        nose1(backx,backy);
  1450. X        prl1(frontx,fronty);
  1451. X        }
  1452. X
  1453. X    } else {
  1454. X        pru();
  1455. X    }
  1456. X#ifdef WALKIES
  1457. X    check_leash(u.ux0,u.uy0);
  1458. X#endif
  1459. X    if(u.ux0 != u.ux || u.uy0 != u.uy) u.umoved = TRUE;
  1460. X    spoteffects();
  1461. X}
  1462. X
  1463. X#endif /* OVL1 */
  1464. X#ifdef OVL2
  1465. X
  1466. Xvoid
  1467. Xspoteffects()
  1468. X{
  1469. X    register struct trap *trap;
  1470. X
  1471. X    if(is_pool(u.ux,u.uy) && !(Levitation || Wwalking
  1472. X#ifdef POLYSELF
  1473. X        || is_flyer(uasmon)
  1474. X#endif
  1475. X        ))
  1476. X        drown();    /* not necessarily fatal */
  1477. X    else {
  1478. X        (void) inshop();
  1479. X#ifdef SINKS
  1480. X        if(IS_SINK(levl[u.ux][u.uy].typ) && Levitation)
  1481. X            dosinkfall();
  1482. X#endif
  1483. X        if(!flags.nopick &&
  1484. X           (OBJ_AT(u.ux, u.uy) || levl[u.ux][u.uy].gmask))
  1485. X            pickup(1);
  1486. X        else read_engr_at(u.ux,u.uy);
  1487. X        if(trap = t_at(u.ux,u.uy))
  1488. X            dotrap(trap);    /* fall into pit, arrow trap, etc. */
  1489. X    }
  1490. X
  1491. X}
  1492. X
  1493. X#endif /* OVL2 */
  1494. X#ifdef OVLB
  1495. X
  1496. Xint
  1497. Xdopickup() {
  1498. X    /* uswallow case added by GAN 01/29/87 */
  1499. X    if(u.uswallow)  {
  1500. X        if (is_animal(u.ustuck->data)) {
  1501. X            You("pick up %s's tongue.", mon_nam(u.ustuck));
  1502. X            pline("But it's kind of slimy, so you drop it.");
  1503. X        } else
  1504. X            You("don't %s anything in here to pick up.",
  1505. X              Blind ? "feel" : "see");
  1506. X        return(1);
  1507. X    }
  1508. X    if(!OBJ_AT(u.ux, u.uy) && levl[u.ux][u.uy].gmask == 0) {
  1509. X        pline("There is nothing here to pick up.");
  1510. X        return(0);
  1511. X    }
  1512. X    if(Levitation) {
  1513. X        You("cannot reach the floor.");
  1514. X        return(1);
  1515. X    }
  1516. X    pickup(0);
  1517. X    return(1);
  1518. X}
  1519. X
  1520. X#endif /* OVLB */
  1521. X#ifdef OVL2
  1522. X
  1523. X/* stop running if we see something interesting */
  1524. X/* turn around a corner if that is the only way we can proceed */
  1525. X/* do not turn left or right twice */
  1526. Xvoid
  1527. Xlookaround() {
  1528. X    register int x, y, i, x0, y0, m0, i0 = 9, corrct = 0, noturn = 0;
  1529. X    register struct monst *mtmp;
  1530. X#if defined(LINT) || defined(__GNULINT__)
  1531. X    /* suppress "used before set" message */
  1532. X    x0 = y0 = m0 = 0;
  1533. X#endif
  1534. X    if(Blind || flags.run == 0) return;
  1535. X    for(x = u.ux-1; x <= u.ux+1; x++) for(y = u.uy-1; y <= u.uy+1; y++) {
  1536. X        if(!isok(x,y)) continue;
  1537. X#ifdef POLYSELF
  1538. X        if(u.umonnum == PM_GRID_BUG && x != u.ux && y != u.uy) continue;
  1539. X#endif
  1540. X        if(x == u.ux && y == u.uy) continue;
  1541. X        if((mtmp = m_at(x,y)) && !mtmp->mimic &&
  1542. X            (!mtmp->minvis || See_invisible) && !mtmp->mundetected) {
  1543. X            if((flags.run != 1 && !mtmp->mtame)
  1544. X                    || (x == u.ux+u.dx && y == u.uy+u.dy))
  1545. X                goto stop;
  1546. X        }
  1547. X        if(levl[x][y].typ == STONE) continue;
  1548. X        if(x == u.ux-u.dx && y == u.uy-u.dy) continue;
  1549. X        {
  1550. X        register uchar sym = levl[x][y].scrsym;
  1551. X
  1552. X        if (IS_ROCK(levl[x][y].typ) ||
  1553. X           (sym == ROOM_SYM && !IS_DOOR(levl[x][y].typ)))
  1554. X             continue;
  1555. X        else if (sym == CLOSED_DOOR_SYM) {
  1556. X            if(x != u.ux && y != u.uy) continue;
  1557. X            if(flags.run != 1) goto stop;
  1558. X            goto bcorr;
  1559. X        } else if (sym == CORR_SYM) {
  1560. X        bcorr:
  1561. X            if(levl[u.ux][u.uy].typ != ROOM) {
  1562. X                if(flags.run == 1 || flags.run == 3) {
  1563. X                i = dist2(x,y,u.ux+u.dx,u.uy+u.dy);
  1564. X                if(i > 2) continue;
  1565. X                if(corrct == 1 && dist2(x,y,x0,y0) != 1)
  1566. X                    noturn = 1;
  1567. X                if(i < i0) {
  1568. X                    i0 = i;
  1569. X                    x0 = x;
  1570. X                    y0 = y;
  1571. X                    m0 = mtmp ? 1 : 0;
  1572. X                }
  1573. X                }
  1574. X                corrct++;
  1575. X            }
  1576. X            continue;
  1577. X        } else if (sym == TRAP_SYM) {
  1578. X            if(flags.run == 1) goto bcorr;    /* if you must */
  1579. X            if(x == u.ux+u.dx && y == u.uy+u.dy) goto stop;
  1580. X            continue;
  1581. X        } else if (sym == POOL_SYM) {
  1582. X            /* pools only stop you if directly in front, and stop
  1583. X             * you even if you are running
  1584. X             */
  1585. X            if(!Levitation &&
  1586. X#ifdef POLYSELF
  1587. X                !is_flyer(uasmon) &&
  1588. X#endif
  1589. X                /* No Wwalking check; otherwise they'd be able
  1590. X                 * to test boots by trying to SHIFT-direction
  1591. X                 * into a pool and seeing if the game allowed it
  1592. X                 */
  1593. X                x == u.ux+u.dx && y == u.uy+u.dy) goto stop;
  1594. X            continue;
  1595. X        } else {        /* e.g. objects or trap or stairs */
  1596. X            if(flags.run == 1) goto bcorr;
  1597. X            if(mtmp) continue;        /* d */
  1598. X        }
  1599. X        stop:
  1600. X            nomul(0);
  1601. X            return;
  1602. X        }
  1603. X    }
  1604. X    if(corrct > 1 && flags.run == 2) goto stop;
  1605. X    if((flags.run == 1 || flags.run == 3) && !noturn && !m0 && i0 &&
  1606. X        (corrct == 1 || (corrct == 2 && i0 == 1))) {
  1607. X        /* make sure that we do not turn too far */
  1608. X        if(i0 == 2) {
  1609. X            if(u.dx == y0-u.uy && u.dy == u.ux-x0)
  1610. X            i = 2;        /* straight turn right */
  1611. X            else
  1612. X            i = -2;        /* straight turn left */
  1613. X        } else if(u.dx && u.dy) {
  1614. X            if((u.dx == u.dy && y0 == u.uy) ||
  1615. X            (u.dx != u.dy && y0 != u.uy))
  1616. X            i = -1;        /* half turn left */
  1617. X            else
  1618. X            i = 1;        /* half turn right */
  1619. X        } else {
  1620. X            if((x0-u.ux == y0-u.uy && !u.dy) ||
  1621. X            (x0-u.ux != y0-u.uy && u.dy))
  1622. X            i = 1;        /* half turn right */
  1623. X            else
  1624. X            i = -1;        /* half turn left */
  1625. X        }
  1626. X        i += u.last_str_turn;
  1627. X        if(i <= 2 && i >= -2) {
  1628. X            u.last_str_turn = i;
  1629. X            u.dx = x0-u.ux, u.dy = y0-u.uy;
  1630. X        }
  1631. X    }
  1632. X}
  1633. X
  1634. X/* something like lookaround, but we are not running */
  1635. X/* react only to monsters that might hit us */
  1636. Xint
  1637. Xmonster_nearby() {
  1638. X    register int x,y;
  1639. X    register struct monst *mtmp;
  1640. X
  1641. X    if(!Blind)
  1642. X    for(x = u.ux-1; x <= u.ux+1; x++)
  1643. X        for(y = u.uy-1; y <= u.uy+1; y++) {
  1644. X        if(!isok(x,y)) continue;
  1645. X        if(x == u.ux && y == u.uy) continue;
  1646. X        if((mtmp = m_at(x,y)) && !mtmp->mimic &&
  1647. X           !mtmp->mtame && !mtmp->mpeaceful &&
  1648. X           !noattacks(mtmp->data) &&
  1649. X           mtmp->mcanmove && !mtmp->msleep &&  /* aplvax!jcn */
  1650. X           (!mtmp->minvis || See_invisible) &&
  1651. X           !onscary(u.ux, u.uy, mtmp))
  1652. X            return(1);
  1653. X    }
  1654. X    return(0);
  1655. X}
  1656. X
  1657. X#endif /* OVL2 */
  1658. X#ifdef OVL0
  1659. X
  1660. Xint
  1661. Xcansee(x,y)
  1662. Xxchar x,y;
  1663. X{
  1664. X    if(Blind || (u.uswallow && (x != u.ux || y != u.uy))) return(0);
  1665. X    if(IS_ROCK(levl[x][y].typ) && levl[u.ux][u.uy].typ == CORR &&
  1666. X                !MON_AT(x, y) && !levl[u.ux][u.uy].lit)
  1667. X        return(0);
  1668. X    if(dist(x,y) < 3) return(1);
  1669. X    if(levl[x][y].lit &&
  1670. X        ((seelx <= x && x <= seehx && seely <= y && y <= seehy) ||
  1671. X        (seelx2 <= x && x <= seehx2 && seely2 <= y && y <= seehy2)))
  1672. X        return(1);
  1673. X    return(0);
  1674. X}
  1675. X
  1676. X#endif /* OVL0 */
  1677. X#ifdef OVL1
  1678. X
  1679. Xint
  1680. Xsgn(a)
  1681. X    register int a;
  1682. X{
  1683. X    return((a > 0) ? 1 : (a == 0) ? 0 : -1);
  1684. X}
  1685. X
  1686. X#endif /* OVL1 */
  1687. X#ifdef OVL2
  1688. X
  1689. Xvoid
  1690. Xgetcorners(lx1,hx1,ly1,hy1,lx2,hx2,ly2,hy2)
  1691. Xxchar *lx1,*hx1,*ly1,*hy1,*lx2,*hx2,*ly2,*hy2;
  1692. X/* return corners of one or two rooms player is in, so we can tell what areas
  1693. X * can be seen, or otherwise affected by room-specific things.  (two rooms are
  1694. X * possible when in a doorway of the stronghold)
  1695. X * the player is already known to be in at least one room
  1696. X */
  1697. X{
  1698. X    register int uroom1,uroom2;
  1699. X    register xchar ux,uy;
  1700. X
  1701. X    uroom1 = inroom(u.ux,u.uy);
  1702. X    *lx1 = rooms[uroom1].lx - 1;
  1703. X    *hx1 = rooms[uroom1].hx + 1;
  1704. X    *ly1 = rooms[uroom1].ly - 1;
  1705. X    *hy1 = rooms[uroom1].hy + 1;
  1706. X
  1707. X    if(!IS_DOOR(levl[u.ux][u.uy].typ)) {
  1708. X        *lx2 = 1;
  1709. X        *hx2 = 0;
  1710. X        *ly2 = 1;
  1711. X        *hy2 = 0;
  1712. X    } else {
  1713. X        for(ux = u.ux-1; ux <= u.ux+1; ux++)
  1714. X            for(uy = u.uy-1; uy <= u.uy+1; uy++) {
  1715. X                if(!isok(ux,uy)) continue;
  1716. X                if(IS_ROCK(levl[ux][uy].typ) ||
  1717. X                    IS_DOOR(levl[ux][uy].typ)) continue;
  1718. X                /* might have side-by-side walls, in which case
  1719. X                 * should only be able to see one room */
  1720. X                uroom2 = inroom(ux,uy);
  1721. X                if(uroom2 >= 0 && uroom2 != uroom1 && 
  1722. X                   rooms[uroom2].rlit) {
  1723. X                    *lx2 = rooms[uroom2].lx - 1;
  1724. X                    *ly2 = rooms[uroom2].ly - 1;
  1725. X                    *hx2 = rooms[uroom2].hx + 1;
  1726. X                    *hy2 = rooms[uroom2].hy + 1;
  1727. X                    return;
  1728. X                }
  1729. X            }
  1730. X        *lx2 = 1;
  1731. X        *hx2 = 0;
  1732. X        *ly2 = 1;
  1733. X        *hy2 = 0;
  1734. X    }
  1735. X}
  1736. X
  1737. X#endif /* OVL2 */
  1738. X#ifdef OVL1
  1739. X
  1740. Xvoid
  1741. Xsetsee() {
  1742. X    register int x, y;
  1743. X
  1744. X    if(Blind) {
  1745. X        pru();
  1746. X        return;
  1747. X    }
  1748. X    if(!levl[u.ux][u.uy].lit) {
  1749. X        seelx = u.ux-1;
  1750. X        seehx = u.ux+1;
  1751. X        seely = u.uy-1;
  1752. X        seehy = u.uy+1;
  1753. X        seelx2 = seely2 = 1;
  1754. X        seehx2 = seehy2 = 0;
  1755. X    } else {
  1756. X        getcorners(&seelx,&seehx,&seely,&seehy,
  1757. X               &seelx2,&seehx2,&seely2,&seehy2);
  1758. X    }
  1759. X    for(y = seely; y <= seehy; y++)
  1760. X        for(x = seelx; x <= seehx; x++) {
  1761. X            prl(x,y);
  1762. X    }
  1763. X    for(y = seely2; y <= seehy2; y++)
  1764. X        for(x = seelx2; x <= seehx2; x++) {
  1765. X            prl(x,y);
  1766. X    }
  1767. X    if(!levl[u.ux][u.uy].lit) seehx = 0; /* seems necessary elsewhere */
  1768. X    else {
  1769. X        if(seely == u.uy) for(x = u.ux-1; x <= u.ux+1; x++) prl(x,seely-1);
  1770. X        if(seehy == u.uy) for(x = u.ux-1; x <= u.ux+1; x++) prl(x,seehy+1);
  1771. X        if(seelx == u.ux) for(y = u.uy-1; y <= u.uy+1; y++) prl(seelx-1,y);
  1772. X        if(seehx == u.ux) for(y = u.uy-1; y <= u.uy+1; y++) prl(seehx+1,y);
  1773. X    }
  1774. X}
  1775. X
  1776. X#endif /* OVL1 */
  1777. X#ifdef OVL2
  1778. X
  1779. Xvoid
  1780. Xnomul(nval)
  1781. X    register int nval;
  1782. X{
  1783. X    if(multi < nval) return;    /* This is a bug fix by ab@unido */
  1784. X    multi = nval;
  1785. X    flags.mv = flags.run = 0;
  1786. X}
  1787. X
  1788. X#endif /* OVL2 */
  1789. X#ifdef OVL1
  1790. X
  1791. Xvoid
  1792. Xlosehp(n, knam, k_format)
  1793. Xregister int n;
  1794. Xregister const char *knam;
  1795. Xboolean k_format;
  1796. X{
  1797. X#ifdef POLYSELF
  1798. X    if (u.mtimedone) {
  1799. X        u.mh -= n;
  1800. X        if (u.mhmax < u.mh) u.mhmax = u.mh;
  1801. X        flags.botl = 1;
  1802. X        if (u.mh < 1) rehumanize();
  1803. X        return;
  1804. X    }
  1805. X#endif
  1806. X    u.uhp -= n;
  1807. X    if(u.uhp > u.uhpmax)
  1808. X        u.uhpmax = u.uhp;    /* perhaps n was negative */
  1809. X    flags.botl = 1;
  1810. X    if(u.uhp < 1) {
  1811. X        killer_format = k_format;
  1812. X        killer = knam;        /* the thing that killed you */
  1813. X        You("die...");
  1814. X        done(DIED);
  1815. X    } else if(u.uhp*10 < u.uhpmax && moves-wailmsg > 50 && n > 0){
  1816. X        wailmsg = moves;
  1817. X        if(index("WEV", pl_character[0])) {
  1818. X            if (u.uhp == 1)
  1819. X                pline("%s is about to die.", pl_character);
  1820. X            else if (4 <= (!!(HTeleportation & INTRINSIC)) +
  1821. X                    (!!(HSee_invisible & INTRINSIC)) +
  1822. X                    (!!(HPoison_resistance & INTRINSIC)) +
  1823. X                    (!!(HCold_resistance & INTRINSIC)) +
  1824. X                    (!!(HShock_resistance & INTRINSIC)) +
  1825. X                    (!!(HFire_resistance & INTRINSIC)) +
  1826. X                    (!!(HSleep_resistance & INTRINSIC)) +
  1827. X                    (!!(HDisint_resistance & INTRINSIC)) +
  1828. X                    (!!(HTeleport_control & INTRINSIC)) +
  1829. X                    (!!(Stealth & INTRINSIC)) +
  1830. X                    (!!(Fast & INTRINSIC)) +
  1831. X                    (!!(HInvis & INTRINSIC)))
  1832. X                pline("%s, all your powers will be lost...",
  1833. X                    pl_character);
  1834. X            else
  1835. X                pline("%s, your life force is running out.",
  1836. X                    pl_character);
  1837. X        } else {
  1838. X            if(u.uhp == 1)
  1839. X                You("hear the wailing of the Banshee...");
  1840. X            else
  1841. X                You("hear the howling of the CwnAnnwn...");
  1842. X        }
  1843. X    }
  1844. X}
  1845. X
  1846. Xint
  1847. Xweight_cap() {
  1848. X    register int carrcap;
  1849. X
  1850. X#ifdef HARD
  1851. X    carrcap = 5 * (((ACURR(A_STR) > 18) ? 20 : ACURR(A_STR)) + u.ulevel);
  1852. X#else
  1853. X    carrcap = 5 * u.ulevel;      /* New strength stewr 870807 */
  1854. X    if (ACURR(A_STR) < 19) carrcap += 5 * ACURR(A_STR);
  1855. X    if (ACURR(A_STR) > 18) carrcap += ACURR(A_STR) - 18 + 90;
  1856. X    if (ACURR(A_STR) > 68) carrcap += ACURR(A_STR) - 68;
  1857. X    if (ACURR(A_STR) > 93) carrcap += ACURR(A_STR) - 93;
  1858. X    if (ACURR(A_STR) > 108) carrcap += 2 * (ACURR(A_STR) - 108);
  1859. X    if (ACURR(A_STR) > 113) carrcap += 5 * (ACURR(A_STR) - 113);
  1860. X    if (ACURR(A_STR) == 118) carrcap += 100;
  1861. X#endif
  1862. X#ifdef POLYSELF
  1863. X    if (u.mtimedone) {
  1864. X        /* consistent with can_carry() in mon.c */
  1865. X        if (u.usym==S_NYMPH) carrcap = MAX_CARR_CAP;
  1866. X        else if (!uasmon->cwt)
  1867. X            carrcap = (carrcap * uasmon->mlevel * 6)/45;
  1868. X        else if (!strongmonst(uasmon)
  1869. X            || (strongmonst(uasmon) && (uasmon->cwt > 45)))
  1870. X            carrcap = (carrcap * uasmon->cwt / 45);
  1871. X    }
  1872. X#endif
  1873. X    if(Levitation)             /* pugh@cornell */
  1874. X        carrcap = MAX_CARR_CAP;
  1875. X    else {
  1876. X        if(carrcap > MAX_CARR_CAP) carrcap = MAX_CARR_CAP;
  1877. X        if(Wounded_legs & LEFT_SIDE) carrcap -= 10;
  1878. X        if(Wounded_legs & RIGHT_SIDE) carrcap -= 10;
  1879. X    }
  1880. X    return(carrcap);
  1881. X}
  1882. X
  1883. Xint
  1884. Xinv_weight() {
  1885. X    register struct obj *otmp = invent;
  1886. X#ifdef LINT    /* long to int conversion */
  1887. X    register int wt = 0;
  1888. X#else
  1889. X    register int wt = (int)((u.ugold + 500L)/1000L);
  1890. X#endif /* LINT */
  1891. X    while(otmp){
  1892. X#ifdef POLYSELF
  1893. X        if (otmp->otyp != BOULDER || !throws_rocks(uasmon))
  1894. X#endif
  1895. X            wt += otmp->owt;
  1896. X        otmp = otmp->nobj;
  1897. X    }
  1898. X    return(wt - weight_cap());
  1899. X}
  1900. X
  1901. X#endif /* OVL1 */
  1902. X#ifdef OVLB
  1903. X
  1904. Xint
  1905. Xinv_cnt() {
  1906. X    register struct obj *otmp = invent;
  1907. X    register int ct = 0;
  1908. X
  1909. X    while(otmp){
  1910. X        ct++;
  1911. X        otmp = otmp->nobj;
  1912. X    }
  1913. X    return(ct);
  1914. X}
  1915. X
  1916. Xint
  1917. Xidentify(otmp)        /* also called by newmail() */
  1918. X    register struct obj *otmp;
  1919. X{
  1920. X    makeknown(otmp->otyp);
  1921. X    otmp->known = otmp->dknown = otmp->bknown = 1;
  1922. X    prinv(otmp);
  1923. X    return(1);
  1924. X}
  1925. X
  1926. X#ifdef STUPID_CPP    /* otherwise these functions are macros in hack.h */
  1927. Xchar
  1928. Xyn() {
  1929. X    return(yn_function(ynchars, 'n'));
  1930. X}
  1931. X
  1932. Xchar
  1933. Xynq() {
  1934. X    return(yn_function(ynqchars, 'q'));
  1935. X}
  1936. X
  1937. Xchar
  1938. Xynaq() {
  1939. X    return(yn_function(ynaqchars, 'y'));
  1940. X}
  1941. X
  1942. Xchar
  1943. Xnyaq() {
  1944. X    return(yn_function(nyaqchars, 'n'));
  1945. X}
  1946. X
  1947. Xint
  1948. Xmax(a,b) int a,b; {
  1949. X    return((a > b) ? a : b);
  1950. X}
  1951. X
  1952. Xint
  1953. Xmin(a,b) int a,b; {
  1954. X    return((a < b) ? a : b);
  1955. X}
  1956. X
  1957. Xchar *
  1958. Xplur(x) long x; {
  1959. X    return((x == 1L) ? "" : "s");
  1960. X}
  1961. X
  1962. Xvoid
  1963. Xmakeknown(x) unsigned x; {
  1964. X    objects[x].oc_name_known = 1;
  1965. X}
  1966. X#endif /* STUPID_CPP */
  1967. X
  1968. X#endif /* OVLB */
  1969. END_OF_FILE
  1970. if test 28166 -ne `wc -c <'src/hack.c'`; then
  1971.     echo shar: \"'src/hack.c'\" unpacked with wrong size!
  1972. fi
  1973. # end of 'src/hack.c'
  1974. fi
  1975. if test -f 'src/wield.c' -a "${1}" != "-c" ; then 
  1976.   echo shar: Will not clobber existing file \"'src/wield.c'\"
  1977. else
  1978. echo shar: Extracting \"'src/wield.c'\" \(6236 characters\)
  1979. sed "s/^X//" >'src/wield.c' <<'END_OF_FILE'
  1980. X/*    SCCS Id: @(#)wield.c    3.0    87/05/10
  1981. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  1982. X/* NetHack may be freely redistributed.  See license for details. */
  1983. X
  1984. X#include    "hack.h"
  1985. X
  1986. X/* Note: setuwep() with a null obj, and uwepgone(), are NOT the same!  Sometimes
  1987. X * unwielding a weapon can kill you, and lifesaving will then put it back into
  1988. X * your hand.  If lifesaving is permitted to do this, use
  1989. X * setwuep((struct obj *)0); otherwise use uwepgone().
  1990. X * (The second function should probably be #ifdef NAMED_ITEMS since only then
  1991. X * may unwielding a weapon kill you, but...)
  1992. X */
  1993. Xvoid
  1994. Xsetuwep(obj)
  1995. Xregister struct obj *obj;
  1996. X{
  1997. X    setworn(obj, W_WEP);
  1998. X    if (!obj) unweapon = TRUE;    /* for "bare hands" message */
  1999. X}
  2000. X
  2001. Xvoid
  2002. Xuwepgone()
  2003. X{
  2004. X    if (uwep) {
  2005. X        setnotworn(uwep);
  2006. X        unweapon = TRUE;
  2007. X    }
  2008. X}
  2009. X
  2010. Xstatic const char NEARDATA wield_objs[] = { '#', '-', WEAPON_SYM, TOOL_SYM, 0 };
  2011. X
  2012. Xint
  2013. Xdowield()
  2014. X{
  2015. X    register struct obj *wep;
  2016. X    register int res = 0;
  2017. X
  2018. X    multi = 0;
  2019. X#ifdef POLYSELF
  2020. X    if (cantwield(uasmon)) {
  2021. X        pline("Don't be ridiculous!");
  2022. X        return(0);
  2023. X    }
  2024. X#endif
  2025. X    if(!(wep = getobj(wield_objs, "wield"))) /* nothing */;
  2026. X    else if(uwep == wep)
  2027. X        You("are already wielding that!");
  2028. X    else if(welded(uwep))
  2029. X        weldmsg(uwep, TRUE);
  2030. X    else if(wep == &zeroobj) {
  2031. X        if(uwep == 0)
  2032. X        You("are already empty %s.", body_part(HANDED));
  2033. X        else  {
  2034. X          You("are empty %s.", body_part(HANDED));
  2035. X          setuwep((struct obj *) 0);
  2036. X          res++;
  2037. X        }
  2038. X    } else if(!uarmg &&
  2039. X#ifdef POLYSELF
  2040. X        !resists_ston(uasmon) &&
  2041. X#endif
  2042. X        (wep->otyp == CORPSE && wep->corpsenm == PM_COCKATRICE)) {
  2043. X        /* Prevent wielding cockatrice when not wearing gloves --KAA */
  2044. X        You("wield the cockatrice corpse in your bare %s.",
  2045. X            makeplural(body_part(HAND)));
  2046. X        You("turn to stone...");
  2047. X        killer_format = KILLED_BY;
  2048. X        killer="touching a cockatrice corpse";
  2049. X        done(STONING);
  2050. X    } else if(uarms && bimanual(wep))
  2051. X        You("cannot wield a two-handed %s and hold a shield.",
  2052. X         is_sword(wep) ? "sword" : "weapon");
  2053. X    else if(wep->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL))
  2054. X        You("cannot wield that!");
  2055. X    else {
  2056. X        res++;
  2057. X        if(wep->cursed && (wep->olet == WEAPON_SYM ||
  2058. X            wep->otyp == HEAVY_IRON_BALL || wep->otyp == PICK_AXE ||
  2059. X            wep->otyp == UNICORN_HORN ||
  2060. X            wep->otyp == TIN_OPENER)) {
  2061. X            pline("The %s %s to your %s!",
  2062. X            aobjnam(wep, "weld"),
  2063. X            (wep->quan == 1) ? "itself" : "themselves", /* a3 */
  2064. X            body_part(HAND));
  2065. X            wep->bknown = 1;
  2066. X        } else {
  2067. X            /* The message must be printed before setuwep (since
  2068. X             * you might die and be revived from changing weapons),
  2069. X             * and the message must be before the death message and
  2070. X             * Lifesaved rewielding.  Yet we want the message to say
  2071. X             * "weapon in hand", thus this kludge.
  2072. X             */
  2073. X            long dummy = wep->owornmask;
  2074. X            wep->owornmask |= W_WEP;
  2075. X            prinv(wep);
  2076. X            wep->owornmask = dummy;
  2077. X        }
  2078. X        setuwep(wep);
  2079. X    }
  2080. X    /* Note: Explicitly wielding a pick-axe will not give a "bashing"
  2081. X     * message.  Wielding one via 'a'pplying it will.
  2082. X     */
  2083. X    if(res && uwep)
  2084. X        unweapon = ((uwep->otyp >= BOW || uwep->otyp <= BOOMERANG) &&
  2085. X            uwep->otyp != PICK_AXE && uwep->otyp != UNICORN_HORN);
  2086. X    return(res);
  2087. X}
  2088. X
  2089. Xvoid
  2090. Xcorrode_weapon(){
  2091. X    if(!uwep || uwep->olet != WEAPON_SYM) return;    /* %% */
  2092. X    if(uwep->rustfree || objects[uwep->otyp].oc_material != METAL)
  2093. X        Your("%s not affected.", aobjnam(uwep, "are"));
  2094. X    else if (uwep->spe > -6) {
  2095. X        Your("%s!", aobjnam(uwep, "corrode"));
  2096. X        uwep->spe--;
  2097. X    } else    Your("%s quite rusted now.", aobjnam(uwep, Blind ? "feel" : "look"));
  2098. X}
  2099. X
  2100. Xint
  2101. Xchwepon(otmp, amount)
  2102. Xregister struct obj *otmp;
  2103. Xregister int amount;
  2104. X{
  2105. X    register const char *color = Hallucination ? hcolor() :
  2106. X                     (amount < 0) ? black : blue;
  2107. X    register const char *xtime;
  2108. X
  2109. X    if(!uwep || (uwep->olet != WEAPON_SYM && uwep->otyp != PICK_AXE
  2110. X            && uwep->otyp != UNICORN_HORN)) {
  2111. X        char buf[36];
  2112. X
  2113. X        Sprintf(buf, "Your %s %s.", makeplural(body_part(HAND)),
  2114. X            (amount > 0) ? "twitch" : "itch");
  2115. X        strange_feeling(otmp, buf);
  2116. X        return(0);
  2117. X    }
  2118. X
  2119. X#ifdef WORM
  2120. X    if(uwep->otyp == WORM_TOOTH && amount > 0) {
  2121. X        uwep->otyp = CRYSKNIFE;
  2122. X        Your("weapon seems sharper now.");
  2123. X        uwep->cursed = 0;
  2124. X        return(1);
  2125. X    }
  2126. X
  2127. X    if(uwep->otyp == CRYSKNIFE && amount < 0) {
  2128. X        uwep->otyp = WORM_TOOTH;
  2129. X        Your("weapon seems duller now.");
  2130. X        return(1);
  2131. X    }
  2132. X#endif
  2133. X#ifdef NAMED_ITEMS
  2134. X    if(is_artifact(uwep) && restr_name(uwep, ONAME(uwep)) &&
  2135. X        amount<0) {
  2136. X        if (!Blind)
  2137. X        Your("%s faintly %s.", aobjnam(uwep, "glow"), color);
  2138. X        return(1);
  2139. X    }
  2140. X#endif
  2141. X    /* there is a (soft) upper and lower limit to uwep->spe */
  2142. X    if(((uwep->spe > 5 && amount > 0) || (uwep->spe < -5 && amount < 0))
  2143. X                                && rn2(3)) {
  2144. X        if (!Blind)
  2145. X        Your("%s violently %s for a while and then evaporate%s.",
  2146. X        aobjnam(uwep,"glow"), color, uwep->quan == 1 ? "s" : "");
  2147. X        else
  2148. X        Your("%s.", aobjnam(uwep, "evaporate"));
  2149. X
  2150. X        while(uwep)        /* let all of them disappear */
  2151. X                /* note: uwep->quan = 1 is nogood if unpaid */
  2152. X        useup(uwep);
  2153. X        return(1);
  2154. X    }
  2155. X    if (!Blind) {
  2156. X        xtime = (amount*amount == 1) ? "moment" : "while";
  2157. X        Your("%s %s for a %s.",
  2158. X          aobjnam(uwep, "glow"), color, xtime);
  2159. X    }
  2160. X    uwep->spe += amount;
  2161. X    if(amount > 0) uwep->cursed = 0;
  2162. X    return(1);
  2163. X}
  2164. X
  2165. Xint
  2166. Xwelded(obj)
  2167. Xregister struct obj *obj;
  2168. X{
  2169. X    if (obj && obj == uwep && obj->cursed &&
  2170. X          (obj->olet == WEAPON_SYM || obj->otyp == HEAVY_IRON_BALL ||
  2171. X           obj->otyp == TIN_OPENER || obj->otyp == PICK_AXE ||
  2172. X           obj->otyp == UNICORN_HORN))
  2173. X    {
  2174. X        obj->bknown = 1;
  2175. X        return 1;
  2176. X    }
  2177. X    return 0;
  2178. X}
  2179. X
  2180. X/* The reason for "specific" is historical; some parts of the code used
  2181. X * the object name and others just used "weapon"/"sword".  This function
  2182. X * replaced all of those.  Which one we use is really arbitrary.
  2183. X */
  2184. Xvoid
  2185. Xweldmsg(obj, specific)
  2186. Xregister struct obj *obj;
  2187. Xboolean specific;
  2188. X{
  2189. X    char buf[BUFSZ];
  2190. X
  2191. X    if (specific) {
  2192. X        long savewornmask = obj->owornmask;
  2193. X        obj->owornmask &= ~W_WEP;
  2194. X        Strcpy(buf, Doname2(obj));
  2195. X        obj->owornmask = savewornmask;
  2196. X    } else
  2197. X        Sprintf(buf, "Your %s%s",
  2198. X            is_sword(obj) ? "sword" : "weapon",
  2199. X            plur((long)obj->quan));
  2200. X    Strcat(buf, (obj->quan==1) ? " is" : " are");
  2201. X#ifdef POLYSELF
  2202. X    Sprintf(eos(buf), " welded to your %s!",
  2203. X        bimanual(obj) ? makeplural(body_part(HAND)) : body_part(HAND));
  2204. X#else
  2205. X    Sprintf(eos(buf), " welded to your hand%s!",
  2206. X        bimanual(obj) ? "s" : "");
  2207. X#endif
  2208. X    pline(buf);
  2209. X}
  2210. END_OF_FILE
  2211. if test 6236 -ne `wc -c <'src/wield.c'`; then
  2212.     echo shar: \"'src/wield.c'\" unpacked with wrong size!
  2213. fi
  2214. # end of 'src/wield.c'
  2215. fi
  2216. echo shar: End of archive 35 \(of 56\).
  2217. cp /dev/null ark35isdone
  2218. MISSING=""
  2219. 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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 ; do
  2220.     if test ! -f ark${I}isdone ; then
  2221.     MISSING="${MISSING} ${I}"
  2222.     fi
  2223. done
  2224. if test "${MISSING}" = "" ; then
  2225.     echo You have unpacked all 56 archives.
  2226.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2227. else
  2228.     echo You still need to unpack the following archives:
  2229.     echo "        " ${MISSING}
  2230. fi
  2231. ##  End of shell archive.
  2232. exit 0
  2233.