home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / games / volume16 / nethack31 / part82 < prev    next >
Internet Message Format  |  1993-02-06  |  59KB

  1. Path: uunet!news.tek.com!master!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v16i090:  nethack31 - display oriented dungeons & dragons (Ver. 3.1), Part82/108
  5. Message-ID: <4453@master.CNA.TEK.COM>
  6. Date: 5 Feb 93 19:21:33 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 1937
  9. Approved: billr@saab.CNA.TEK.COM
  10. Xref: uunet comp.sources.games:1641
  11.  
  12. Submitted-by: izchak@linc.cis.upenn.edu (Izchak Miller)
  13. Posting-number: Volume 16, Issue 90
  14. Archive-name: nethack31/Part82
  15. Supersedes: nethack3p9: Volume 10, Issue 46-102
  16. Environment: Amiga, Atari, Mac, MS-DOS, OS2, Unix, VMS, X11
  17.  
  18.  
  19.  
  20. #! /bin/sh
  21. # This is a shell archive.  Remove anything before this line, then unpack
  22. # it by saving it into a file and typing "sh file".  To overwrite existing
  23. # files, type "sh file -c".  You can also feed this as standard input via
  24. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  25. # will see the following message at the end:
  26. #        "End of archive 82 (of 108)."
  27. # Contents:  dat/Rogue.des src/u_init.c src/worm.c
  28. # Wrapped by billr@saab on Wed Jan 27 16:09:19 1993
  29. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  30. if test -f 'dat/Rogue.des' -a "${1}" != "-c" ; then 
  31.   echo shar: Will not clobber existing file \"'dat/Rogue.des'\"
  32. else
  33. echo shar: Extracting \"'dat/Rogue.des'\" \(16887 characters\)
  34. sed "s/^X//" >'dat/Rogue.des' <<'END_OF_FILE'
  35. X#    SCCS Id: @(#)Rogue.des    3.1    92/04/27
  36. X#    Copyright (c) 1992 by Dean Luick
  37. X# NetHack may be freely redistributed.  See license for details.
  38. X#
  39. X#    The "start" level for the quest.
  40. X#
  41. X#    Here you meet your (besieged) class leader, Master of Thieves
  42. X#    and receive your quest assignment.
  43. X#
  44. XMAZE: "R-start",' '
  45. XFLAGS: noteleport, hardfloor, nommap
  46. XGEOMETRY:center,center
  47. XMAP
  48. X#         1         2         3         4         5         6         7 
  49. X#123456789012345678901234567890123456789012345678901234567890123456789012345
  50. X---------------------------------.------------------------------------------
  51. X|.....|.||..........|....|......|.|.........|.......+............---.......|
  52. X|.....|..+..........+....---....S.|...-------.-----.|............+.+.......|
  53. X|.....+.||........---......|....|.|...|.....|.|...|.---.....------.--------|
  54. X|-----|.-------|..|........------.-----.....|.--..|...-------..............|
  55. X|.....|........------+------..........+.....|..------.........------.-----..
  56. X|.....|.------...............-----.}}.--------.|....-------.---....|.+...--|
  57. X|..-+--.|....|-----.--------.|...|.....+.....|.|....|.....+.+......|.--....|
  58. X|..|....|....|....+.|......|.|...-----.|.....|.--...|.....|.|......|..|....|
  59. X|..|.----------...|.+....-----...|...|.----..|..|.---....--.---S-----.|----|
  60. X|..|.|........|...------.|.S.....|...|....-----.+.|......|..|.......|.|....|
  61. X|---.-------..|...|....|.|.|.....|...----.|...|.|---.....|.|-.......|.---..|
  62. X...........|..|...|....---.----S----..|...|...+.|..-------.---+-....|...--+|
  63. X|---------.---------...|......|....S..|.---...|.|..|...........----.---....|
  64. X|........|.........|...+.------....|---.---...|.--+-.----.----....|.+...--+|
  65. X|........|.---+---.|----.--........|......-----......|..|..|.--+-.|.-S-.|..|
  66. X|........|.|.....|........----------.----.......---.--..|-.|....|.-----.|..|
  67. X|----....+.|.....----+---............|..|--------.+.|...SS.|....|.......|..|
  68. X|...--+-----.....|......|.------------............---...||.------+--+----..|
  69. X|..........S.....|......|.|..........S............|.....||...|.....|....|..|
  70. X-------------------------.--------------------------------------------------
  71. XENDMAP
  72. X# Random Monsters
  73. XRANDOM_MONSTERS: 'l', 'N'
  74. X# Dungeon Description
  75. X#REGION:(00,00,75,20),lit,"ordinary"
  76. X# The down stairs is at one of the 4 "exits".  The others are mimics,
  77. X# mimicing stairwells.
  78. XRANDOM_PLACES: (33,0), (0,12), (25,20), (75,05)
  79. XSTAIR:place[0],down
  80. XMONSTER:'m',"giant mimic", place[1], m_feature "staircase down"
  81. XMONSTER:'m',"large mimic", place[2], m_feature "staircase down"
  82. XMONSTER:'m',"small mimic", place[3], m_feature "staircase down"
  83. X# Portal arrival point
  84. XBRANCH:(19,09,19,09),(0,0,0,0)
  85. X# Doors (secret)
  86. X#DOOR:locked|closed|open,(xx,yy)
  87. XDOOR: locked, (32, 2)
  88. XDOOR: locked, (63, 9)
  89. XDOOR: locked, (27,10)
  90. XDOOR: locked, (31,12)
  91. XDOOR: locked, (35,13)
  92. XDOOR: locked, (69,15)
  93. XDOOR: locked, (56,17)
  94. XDOOR: locked, (57,17)
  95. XDOOR: locked, (11,19)
  96. XDOOR: locked, (37,19)
  97. X# Doors (regular)
  98. XDOOR: closed, (52, 1)
  99. XDOOR: closed, ( 9, 2)
  100. XDOOR: closed, (20, 2)
  101. XDOOR: closed, (65, 2)
  102. XDOOR: closed, (67, 2)
  103. XDOOR: closed, ( 6, 3)
  104. XDOOR: closed, (21, 5)
  105. XDOOR: closed, (38, 5)
  106. XDOOR: closed, (69, 6)
  107. XDOOR: closed, ( 4, 7)
  108. XDOOR: closed, (39, 7)
  109. XDOOR: closed, (58, 7)
  110. XDOOR: closed, (60, 7)
  111. XDOOR: closed, (18, 8)
  112. XDOOR: closed, (20, 9)
  113. XDOOR: closed, (48,10)
  114. XDOOR: closed, (46,12)
  115. XDOOR: closed, (62,12)
  116. XDOOR: closed, (74,12)
  117. XDOOR: closed, (23,14)
  118. XDOOR: closed, (23,14)
  119. XDOOR: closed, (50,14)
  120. XDOOR: closed, (68,14)
  121. XDOOR: closed, (74,14)
  122. XDOOR: closed, (14,15)
  123. XDOOR: closed, (63,15)
  124. XDOOR: closed, ( 9,17)
  125. XDOOR: closed, (21,17)
  126. XDOOR: closed, (50,17)
  127. XDOOR: closed, ( 6,18)
  128. XDOOR: closed, (65,18)
  129. XDOOR: closed, (68,18)
  130. X# Master of Thieves
  131. XMONSTER:'@',"Master of Thieves",(36,11)
  132. X# The treasure of Master of Thieves
  133. XOBJECT:'(',"chest",(36,11)
  134. X# thug guards, room #1
  135. XMONSTER:'@',"thug",(28,10)
  136. XMONSTER:'@',"thug",(29,11)
  137. XMONSTER:'@',"thug",(30,09)
  138. XMONSTER:'@',"thug",(31,07)
  139. X# thug guards, room #2
  140. XMONSTER:'@',"thug",(31,13)
  141. XMONSTER:'@',"thug",(33,14)
  142. XMONSTER:'@',"thug",(30,15)
  143. X#thug guards, room #3
  144. XMONSTER:'@',"thug",(35,09)
  145. XMONSTER:'@',"thug",(36,13)
  146. X# Non diggable walls
  147. XNON_DIGGABLE:(00,00,75,20)
  148. X# Random traps
  149. XTRAP:random,random
  150. XTRAP:random,random
  151. XTRAP:random,random
  152. XTRAP:random,random
  153. XTRAP:random,random
  154. XTRAP:random,random
  155. XTRAP:random,random
  156. XTRAP:random,random
  157. XTRAP:random,random
  158. XTRAP:random,random
  159. XTRAP:random,random
  160. XTRAP:random,random
  161. XTRAP:random,random
  162. XTRAP:random,random
  163. XTRAP:random,random
  164. XTRAP:random,random
  165. X#
  166. X# Monsters to get in the way.
  167. X#
  168. X# West exit
  169. XMONSTER: 'l',"leprechaun",(01,12),hostile
  170. XMONSTER: 'n',"water nymph",(02,12),hostile
  171. X# North exit
  172. XMONSTER: 'n',"water nymph",(33,01),hostile
  173. XMONSTER: 'l',"leprechaun",(33,02),hostile
  174. X# East exit
  175. XMONSTER: 'n',"water nymph",(74,05),hostile
  176. XMONSTER: 'l',"leprechaun",(74,04),hostile
  177. X# South exit
  178. XMONSTER: 'l',"leprechaun",(25,19),hostile
  179. XMONSTER: 'n',"water nymph",(25,18),hostile
  180. X# Wandering the streets.  What I'd really like for this is a random
  181. X# location, but make sure we're on a given type, e.g. street (if they
  182. X# existed, of course).
  183. XMONSTER: 'n',"water nymph",(07,05),hostile
  184. XMONSTER: 'l',"leprechaun",(28,06),hostile
  185. XMONSTER: 'n',"water nymph",(38,07),hostile
  186. XMONSTER: 'l',"leprechaun",(45,01),hostile
  187. XMONSTER: 'n',"water nymph",(59,07),hostile
  188. XMONSTER: 'l',"leprechaun",(62,14),hostile
  189. XMONSTER: 'n',"water nymph",(71,14),hostile
  190. XMONSTER: 'l',"leprechaun",(39,13),hostile
  191. XMONSTER: 'n',"water nymph",(18,14),hostile
  192. XMONSTER: ':',"chameleon",(19,08),hostile
  193. XMONSTER: ':',"chameleon",(22,08),hostile
  194. XMONSTER: ':',"chameleon",(16,08),hostile
  195. XMONSTER: ':',"chameleon",random,hostile
  196. XMONSTER: ':',"chameleon",random,hostile
  197. XMONSTER: ':',"chameleon",random,hostile
  198. XMONSTER: ':',"chameleon",random,hostile
  199. XMONSTER: ':',"chameleon",random,hostile
  200. X
  201. X#
  202. X#    The "locate" level for the quest.
  203. X#
  204. X#    Here you have to find the entrance to the Assassins' Guild to go
  205. X#    further towards your assigned quest.
  206. X#
  207. X
  208. XMAZE: "R-locate",' '
  209. XGEOMETRY:center,center
  210. XMAP
  211. X#         1         2         3         4         5         6         7 
  212. X#123456789012345678901234567890123456789012345678901234567890123456789012345
  213. X             ----------------------------------------------------   --------
  214. X           ---.................................................-    --......
  215. X         ---...--------........------........................---     ---....
  216. X       ---.....-      --.......-     ---..................----         --.--
  217. X     ---.....----       -------        --..................--         --..|
  218. X   ---...-----                       ----.----.....----.....---      --..||
  219. X----..----                       -----..---  |...---  |.......---   --...|
  220. X|...---                       ----....---    |.---    |.........-- --...||
  221. X|...-                      ----.....---     ----      |..........---....|
  222. X|...----                ----......---       |         |...|.......-....||
  223. X|......-----          ---.........-         |     -----...|............|
  224. X|..........-----   ----...........---       -------......||...........||
  225. X|..............-----................---     |............|||..........|
  226. X|------...............................---   |...........|| |.........||
  227. X|.....|..............------.............-----..........||  ||........|
  228. X|.....|.............--    ---.........................||    |.......||
  229. X|.....|.............-       ---.....................--|     ||......|
  230. X|------------.......----      --.................----        |.....||
  231. X|...........|..........--------..............-----           ||....|
  232. X|...........|............................-----                |....|
  233. X------------------------------------------                    ------
  234. XENDMAP
  235. X# Random Monsters
  236. XRANDOM_MONSTERS: 'l', 'N'
  237. X# Dungeon Description
  238. XREGION:(00,00,75,20),lit,"ordinary"
  239. X# Doors
  240. X#DOOR:locked|closed|open,(xx,yy)
  241. X# Stairs
  242. XSTAIR:random,up
  243. XSTAIR:random,down
  244. X# Non diggable walls
  245. XNON_DIGGABLE:(00,00,75,20)
  246. X# Objects
  247. XOBJECT:random,random,random
  248. XOBJECT:random,random,random
  249. XOBJECT:random,random,random
  250. XOBJECT:random,random,random
  251. XOBJECT:random,random,random
  252. XOBJECT:random,random,random
  253. XOBJECT:random,random,random
  254. XOBJECT:random,random,random
  255. XOBJECT:random,random,random
  256. XOBJECT:random,random,random
  257. XOBJECT:random,random,random
  258. XOBJECT:random,random,random
  259. XOBJECT:random,random,random
  260. XOBJECT:random,random,random
  261. XOBJECT:random,random,random
  262. X# Random traps
  263. XTRAP:random,random
  264. XTRAP:random,random
  265. XTRAP:random,random
  266. XTRAP:random,random
  267. XTRAP:random,random
  268. XTRAP:random,random
  269. X# Random monsters.
  270. XMONSTER:'l',"leprechaun",random,hostile
  271. XMONSTER:'l',"leprechaun",random,hostile
  272. XMONSTER:'l',"leprechaun",random,hostile
  273. XMONSTER:'l',"leprechaun",random,hostile
  274. XMONSTER:'l',"leprechaun",random,hostile
  275. XMONSTER:'l',"leprechaun",random,hostile
  276. XMONSTER:'l',"leprechaun",random,hostile
  277. XMONSTER:'l',"leprechaun",random,hostile
  278. XMONSTER:'l',"leprechaun",random,hostile
  279. XMONSTER:'l',"leprechaun",random,hostile
  280. XMONSTER:'l',"leprechaun",random,hostile
  281. XMONSTER:'l',"leprechaun",random,hostile
  282. XMONSTER:'l',"leprechaun",random,hostile
  283. XMONSTER:'l',"leprechaun",random,hostile
  284. XMONSTER:'l',"leprechaun",random,hostile
  285. XMONSTER:'l',"leprechaun",random,hostile
  286. XMONSTER:'l',"leprechaun",random,hostile
  287. XMONSTER:'l',random,random,hostile
  288. XMONSTER:'N',"guardian naga",random,hostile
  289. XMONSTER:'N',"guardian naga",random,hostile
  290. XMONSTER:'N',"guardian naga",random,hostile
  291. XMONSTER:'N',"guardian naga",random,hostile
  292. XMONSTER:'N',"guardian naga",random,hostile
  293. XMONSTER:'N',"guardian naga",random,hostile
  294. XMONSTER:'N',"guardian naga",random,hostile
  295. XMONSTER:'N',random,random,hostile
  296. XMONSTER:'N',random,random,hostile
  297. XMONSTER:'N',random,random,hostile
  298. XMONSTER: ':',"chameleon",random,hostile
  299. XMONSTER: ':',"chameleon",random,hostile
  300. XMONSTER: ':',"chameleon",random,hostile
  301. XMONSTER: ':',"chameleon",random,hostile
  302. XMONSTER: ':',"chameleon",random,hostile
  303. X
  304. X#
  305. X#    The "goal" level for the quest.
  306. X#
  307. X#    Here you meet The Master Assassin your nemesis monster.  You have to
  308. X#    defeat The Master Assassin in combat to gain the artifact you have
  309. X#    been assigned to retrieve.
  310. X#
  311. XMAZE: "R-goal", ' '
  312. XFLAGS: noteleport
  313. XGEOMETRY:center,center
  314. XMAP
  315. X#         1         2         3         4         5         6         7
  316. X#123456789012345678901234567890123456789012345678901234567890123456789012345
  317. X-----      -------.......................................|-----------------|
  318. X|...|  -----.....|.......................................|.................|
  319. X|...----...|.....|.......................................|....---------....|
  320. X|.---......---..--.................................------------.......|....|
  321. X|...............|..................................|..|...|...----........-|
  322. X|.....-----....--.................................|-..--..-|.....---------|
  323. X|------...|....|.................................|-........-|....|........|
  324. X|.........---------.............................|-....}}....-|...|...|....|
  325. X|....|.....|......|............................|-.....}}.....-|..--.------|
  326. X|-----.....--.....|...........................|-...}}}}}}}}...-|....|.....--
  327. X|...........--....------------...............|-....}}}}}}}}....-|..........|
  328. X|............--........|...|.|..............--.....}}.}}........------------
  329. X|.............|........|...|.|..............|......}}}}}}}}......|...|.....|
  330. X|--.---.---.---.---.---|...|.------------...--........}}.}}.....--..---....|
  331. X|.---.---.---.---.---..-----.|....|.....|....|-....}}}}}}}}....---..|.|--..|
  332. X|...|.......|..........|...---....---...S.....|-...}}}}}}}}...-|.|..|...|..|
  333. X|...|..|....|..........|............|..--..----|-.....}}.....-|..----...----
  334. X|...|---....----.......|----- ......|...---|    |-....}}....-|...|..-----..|
  335. X-----.....---.....--.---....--...--------..|     |-........-|....|.........|
  336. X    |.............|..........|.............S...   |S-------|.....|..-----..|
  337. X    ----------------------------------------  ......       ----------   ----
  338. XENDMAP
  339. X# Random Monsters
  340. XRANDOM_MONSTERS: '@', 'g', 'n'
  341. X# Dungeon Description
  342. XREGION:(00,00,75,20),lit,"ordinary"
  343. X# Stairs
  344. XSTAIR:random,up
  345. X# Doors
  346. X# Non diggable walls
  347. XNON_DIGGABLE:(00,00,75,20)
  348. X# One trap to keep the gnomes at bay.
  349. XTRAP:"spiked pit",(37,07)
  350. X# Objects
  351. XOBJECT:'(',"skeleton key",(38,10),blessed,0,"The Master Key of Thievery"
  352. XOBJECT:random,random,random
  353. XOBJECT:random,random,random
  354. XOBJECT:random,random,random
  355. XOBJECT:random,random,random
  356. XOBJECT:random,random,random
  357. XOBJECT:random,random,random
  358. XOBJECT:random,random,random
  359. XOBJECT:random,random,random
  360. XOBJECT:random,random,random
  361. XOBJECT:random,random,random
  362. XOBJECT:random,random,random
  363. XOBJECT:random,random,random
  364. XOBJECT:random,random,random
  365. XOBJECT:random,random,random
  366. X# Random traps
  367. XTRAP:random,random
  368. XTRAP:random,random
  369. XTRAP:random,random
  370. XTRAP:random,random
  371. XTRAP:random,random
  372. XTRAP:random,random
  373. XTRAP:random,random
  374. XTRAP:random,random
  375. XTRAP:random,random
  376. XTRAP:random,random
  377. XTRAP:random,random
  378. X# Random monsters.
  379. XMONSTER:'@',"Master Assassin",(38,10),hostile
  380. XMONSTER:'l',"leprechaun",random,hostile
  381. XMONSTER:'l',"leprechaun",random,hostile
  382. XMONSTER:'l',"leprechaun",random,hostile
  383. XMONSTER:'l',"leprechaun",random,hostile
  384. XMONSTER:'l',"leprechaun",random,hostile
  385. XMONSTER:'l',"leprechaun",random,hostile
  386. XMONSTER:'l',"leprechaun",random,hostile
  387. XMONSTER:'l',"leprechaun",random,hostile
  388. XMONSTER:'l',"leprechaun",random,hostile
  389. XMONSTER:'l',"leprechaun",random,hostile
  390. XMONSTER:'l',"leprechaun",random,hostile
  391. XMONSTER:'l',"leprechaun",random,hostile
  392. XMONSTER:'l',"leprechaun",random,hostile
  393. XMONSTER:'l',"leprechaun",random,hostile
  394. XMONSTER:'l',"leprechaun",random,hostile
  395. XMONSTER:'l',"leprechaun",random,hostile
  396. XMONSTER:'l',random,random,hostile
  397. XMONSTER:'l',random,random,hostile
  398. XMONSTER:'N',"guardian naga",random,hostile
  399. XMONSTER:'N',"guardian naga",random,hostile
  400. XMONSTER:'N',"guardian naga",random,hostile
  401. XMONSTER:'N',"guardian naga",random,hostile
  402. XMONSTER:'N',"guardian naga",random,hostile
  403. XMONSTER:'N',"guardian naga",random,hostile
  404. XMONSTER:'N',"guardian naga",random,hostile
  405. XMONSTER:'N',"guardian naga",random,hostile
  406. XMONSTER:'N',random,random,hostile
  407. XMONSTER:'N',random,random,hostile
  408. XMONSTER:'N',random,random,hostile
  409. XMONSTER: ':',"chameleon",random,hostile
  410. XMONSTER: ':',"chameleon",random,hostile
  411. XMONSTER: ':',"chameleon",random,hostile
  412. XMONSTER: ':',"chameleon",random,hostile
  413. XMONSTER: ':',"chameleon",random,hostile
  414. X
  415. X#
  416. X#    The "fill" level for the quest.
  417. X#
  418. X#    This level is used to fill out any levels not occupied by specific
  419. X#    levels as defined above.
  420. X#
  421. XLEVEL: "R-filla"
  422. X# Random Monsters
  423. XRANDOM_MONSTERS: 'l', 'N', 'n', ':'
  424. X#
  425. XROOM: "ordinary" , random, random, random, random
  426. XSTAIR: random, up
  427. XOBJECT: random,random,random
  428. XMONSTER: 'l', "leprechaun", random, hostile
  429. X
  430. XROOM: "ordinary" , random, random, random, random
  431. XOBJECT: random, random, random
  432. XOBJECT: random,random,random
  433. XMONSTER: 'l', "leprechaun", random, hostile
  434. XMONSTER: 'N', "guardian naga", random, hostile
  435. X
  436. XROOM: "ordinary" , random, random, random, random
  437. XOBJECT: random, random, random
  438. XTRAP: random, random
  439. XTRAP: random, random
  440. XOBJECT: random,random,random
  441. XMONSTER: 'n', "water nymph", random, hostile
  442. X
  443. XROOM: "ordinary" , random, random, random, random
  444. XSTAIR: random, down
  445. XOBJECT: random, random, random
  446. XTRAP: random, random
  447. XTRAP: random, random
  448. XMONSTER: 'l', random, random, hostile
  449. XMONSTER: 'N', "guardian naga", random, hostile
  450. X
  451. XROOM: "ordinary" , random, random, random, random
  452. XOBJECT: random, random, random
  453. XOBJECT: random, random, random
  454. XTRAP: random, random
  455. XTRAP: random, random
  456. XMONSTER: 'l', "leprechaun", random, hostile
  457. X
  458. XROOM: "ordinary" , random, random, random, random
  459. XOBJECT: random, random, random
  460. XTRAP: random, random
  461. XTRAP: random, random
  462. XMONSTER: 'l', "leprechaun", random, hostile
  463. XMONSTER: 'n', "water nymph", random, hostile
  464. X
  465. XRANDOM_CORRIDORS
  466. X
  467. X#
  468. X# currently a & b are the same.
  469. X#
  470. XLEVEL: "R-fillb"
  471. X# Random Monsters
  472. XRANDOM_MONSTERS: 'l', 'N', 'n', ':'
  473. X#
  474. XROOM: "ordinary" , random, random, random, random
  475. XSTAIR: random, up
  476. XOBJECT: random,random,random
  477. XMONSTER: 'l', "leprechaun", random, hostile
  478. X
  479. XROOM: "ordinary" , random, random, random, random
  480. XOBJECT: random, random, random
  481. XOBJECT: random,random,random
  482. XMONSTER: 'l', "leprechaun", random, hostile
  483. XMONSTER: 'N', "guardian naga", random, hostile
  484. X
  485. XROOM: "ordinary" , random, random, random, random
  486. XOBJECT: random, random, random
  487. XTRAP: random, random
  488. XTRAP: random, random
  489. XOBJECT: random,random,random
  490. XMONSTER: 'n', "water nymph", random, hostile
  491. X
  492. XROOM: "ordinary" , random, random, random, random
  493. XSTAIR: random, down
  494. XOBJECT: random, random, random
  495. XTRAP: random, random
  496. XTRAP: random, random
  497. XMONSTER: 'l', random, random, hostile
  498. XMONSTER: 'N', "guardian naga", random, hostile
  499. X
  500. XROOM: "ordinary" , random, random, random, random
  501. XOBJECT: random, random, random
  502. XOBJECT: random, random, random
  503. XTRAP: random, random
  504. XTRAP: random, random
  505. XMONSTER: 'l', "leprechaun", random, hostile
  506. X
  507. XROOM: "ordinary" , random, random, random, random
  508. XOBJECT: random, random, random
  509. XTRAP: random, random
  510. XTRAP: random, random
  511. XMONSTER: 'l', "leprechaun", random, hostile
  512. XMONSTER: 'n', "water nymph", random, hostile
  513. X
  514. XRANDOM_CORRIDORS
  515. END_OF_FILE
  516. if test 16887 -ne `wc -c <'dat/Rogue.des'`; then
  517.     echo shar: \"'dat/Rogue.des'\" unpacked with wrong size!
  518. fi
  519. # end of 'dat/Rogue.des'
  520. fi
  521. if test -f 'src/u_init.c' -a "${1}" != "-c" ; then 
  522.   echo shar: Will not clobber existing file \"'src/u_init.c'\"
  523. else
  524. echo shar: Extracting \"'src/u_init.c'\" \(18225 characters\)
  525. sed "s/^X//" >'src/u_init.c' <<'END_OF_FILE'
  526. X/*    SCCS Id: @(#)u_init.c    3.1    92/11/13    */
  527. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  528. X/* NetHack may be freely redistributed.  See license for details. */
  529. X
  530. X#include "hack.h"
  531. X
  532. Xstruct trobj {
  533. X    unsigned short int trotyp;
  534. X    schar trspe;
  535. X    char trclass;
  536. X    Bitfield(trquan,6);
  537. X    Bitfield(trknown,1);
  538. X    Bitfield(trbless,2);
  539. X};
  540. X
  541. Xstatic void FDECL(ini_inv, (struct trobj *));
  542. Xstatic void FDECL(knows_object,(int));
  543. Xstatic void FDECL(knows_class,(CHAR_P));
  544. Xstatic int FDECL(role_index,(CHAR_P));
  545. X
  546. X#define    UNDEF_TYP    0
  547. X#define    UNDEF_SPE    '\177'
  548. X#define    UNDEF_BLESS    2
  549. X
  550. X/* all roles must all have distinct first letter */
  551. Xconst char *roles[] = {    /* also used in options.c and winxxx.c */
  552. X            /* roles[2] and [6] are changed for females */
  553. X            /* in all cases, the corresponding male and female */
  554. X            /* roles must start with the same letter */
  555. X    "Archeologist", "Barbarian", "Caveman", "Elf", "Healer", "Knight",
  556. X    "Priest", "Rogue", "Samurai",
  557. X#ifdef TOURIST
  558. X    "Tourist",
  559. X#endif
  560. X    "Valkyrie", "Wizard", 0
  561. X};
  562. X
  563. Xstatic struct trobj Cave_man[] = {
  564. X#define C_ARROWS    2
  565. X    { CLUB, 1, WEAPON_CLASS, 1, 1, UNDEF_BLESS },
  566. X    { BOW, 1, WEAPON_CLASS, 1, 1, UNDEF_BLESS },
  567. X    { ARROW, 0, WEAPON_CLASS, 25, 1, UNDEF_BLESS },    /* quan is variable */
  568. X    { LEATHER_ARMOR, 0, ARMOR_CLASS, 1, 1, UNDEF_BLESS },
  569. X    { 0, 0, 0, 0, 0, 0 }
  570. X};
  571. X
  572. Xstatic struct trobj Barbarian[] = {
  573. X#define B_MAJOR 0    /* two-handed sword or battle-axe  */
  574. X#define B_MINOR 1    /* matched with axe or short sword */
  575. X    { TWO_HANDED_SWORD, 0, WEAPON_CLASS, 1, 1, UNDEF_BLESS },
  576. X    { AXE, 0, WEAPON_CLASS, 1, 1, UNDEF_BLESS },
  577. X    { RING_MAIL, 0, ARMOR_CLASS, 1, 1, UNDEF_BLESS },
  578. X    { FOOD_RATION, 0, FOOD_CLASS, 1, 1, 0 },
  579. X    { 0, 0, 0, 0, 0, 0 }
  580. X};
  581. X
  582. Xstatic struct trobj Knight[] = {
  583. X    { LONG_SWORD, 0, WEAPON_CLASS, 1, 1, UNDEF_BLESS },
  584. X    { SPEAR, 2, WEAPON_CLASS, 1, 1, UNDEF_BLESS },
  585. X    { RING_MAIL, 1, ARMOR_CLASS, 1, 1, UNDEF_BLESS },
  586. X    { HELMET, 0, ARMOR_CLASS, 1, 1, UNDEF_BLESS },
  587. X    { SMALL_SHIELD, 0, ARMOR_CLASS, 1, 1, UNDEF_BLESS },
  588. X    { LEATHER_GLOVES, 0, ARMOR_CLASS, 1, 1, UNDEF_BLESS },
  589. X    { 0, 0, 0, 0, 0, 0 }
  590. X};
  591. X
  592. Xstatic struct trobj Elf[] = {
  593. X#define E_ARROWS    2
  594. X#define E_ARMOR        3
  595. X    { ELVEN_SHORT_SWORD, 0, WEAPON_CLASS, 1, 1, UNDEF_BLESS },
  596. X    { ELVEN_BOW, 0, WEAPON_CLASS, 1, 1, UNDEF_BLESS },
  597. X    { ELVEN_ARROW, 0, WEAPON_CLASS, 25, 1, UNDEF_BLESS },
  598. X    { UNDEF_TYP, 0, ARMOR_CLASS, 1, 1, UNDEF_BLESS },
  599. X    { LEMBAS_WAFER, 0, FOOD_CLASS, 2, 1, 0 },
  600. X    { 0, 0, 0, 0, 0, 0 }
  601. X};
  602. X
  603. Xstatic struct trobj Valkyrie[] = {
  604. X    { LONG_SWORD, 1, WEAPON_CLASS, 1, 1, UNDEF_BLESS },
  605. X    { DAGGER, 0, WEAPON_CLASS, 1, 1, UNDEF_BLESS },
  606. X    { SMALL_SHIELD, 3, ARMOR_CLASS, 1, 1, UNDEF_BLESS },
  607. X    { FOOD_RATION, 0, FOOD_CLASS, 1, 1, 0 },
  608. X    { 0, 0, 0, 0, 0, 0 }
  609. X};
  610. X
  611. Xstatic struct trobj Healer[] = {
  612. X    { SCALPEL, 0, WEAPON_CLASS, 1, 1, UNDEF_BLESS },
  613. X    { LEATHER_GLOVES, 1, ARMOR_CLASS, 1, 1, UNDEF_BLESS },
  614. X    { STETHOSCOPE, 0, TOOL_CLASS, 1, 1, 0 },
  615. X    { POT_HEALING, 0, POTION_CLASS, 4, 1, UNDEF_BLESS },
  616. X    { POT_EXTRA_HEALING, 0, POTION_CLASS, 4, 1, UNDEF_BLESS },
  617. X    { WAN_SLEEP, UNDEF_SPE, WAND_CLASS, 1, 1, UNDEF_BLESS },
  618. X    /* always blessed, so it's guaranteed readable */
  619. X    { SPE_HEALING, 0, SPBOOK_CLASS, 1, 1, 1 },
  620. X    { SPE_EXTRA_HEALING, 0, SPBOOK_CLASS, 1, 1, 1 },
  621. X    { APPLE, 0, FOOD_CLASS, 5, 1, 0 },
  622. X    { 0, 0, 0, 0, 0, 0 }
  623. X};
  624. X
  625. Xstatic struct trobj Archeologist[] = {
  626. X    /* if adventure has a name...  idea from tan@uvm-gen */
  627. X    { BULLWHIP, 2, WEAPON_CLASS, 1, 1, UNDEF_BLESS },
  628. X    { LEATHER_JACKET, 0, ARMOR_CLASS, 1, 1, UNDEF_BLESS },
  629. X    { FEDORA, 0, ARMOR_CLASS, 1, 1, UNDEF_BLESS },
  630. X    { FOOD_RATION, 0, FOOD_CLASS, 3, 1, 0 },
  631. X    { PICK_AXE, UNDEF_SPE, TOOL_CLASS, 1, 1, UNDEF_BLESS },
  632. X    { TINNING_KIT, 0, TOOL_CLASS, 1, 1, UNDEF_BLESS },
  633. X    { SACK, 0, TOOL_CLASS, 1, 0, 0 },
  634. X    { 0, 0, 0, 0, 0, 0 }
  635. X};
  636. X
  637. Xstatic struct trobj Tinopener[] = {
  638. X    { TIN_OPENER, 0, TOOL_CLASS, 1, 1, 0 },
  639. X    { 0, 0, 0, 0, 0, 0 }
  640. X};
  641. X
  642. Xstatic struct trobj Magicmarker[] = {
  643. X    { MAGIC_MARKER, UNDEF_SPE, TOOL_CLASS, 1, 1, 0 },
  644. X    { 0, 0, 0, 0, 0, 0 }
  645. X};
  646. X
  647. Xstatic struct trobj Lamp[] = {
  648. X    { OIL_LAMP, 1, TOOL_CLASS, 1, 1, 0 },
  649. X    { 0, 0, 0, 0, 0, 0 }
  650. X};
  651. X
  652. X#ifdef TOURIST
  653. X# ifdef WALKIES
  654. Xstatic struct trobj Leash[] = {
  655. X    { LEASH, 0, TOOL_CLASS, 1, 1, 0 },
  656. X    { 0, 0, 0, 0, 0, 0 }
  657. X};
  658. X# endif
  659. X
  660. Xstatic struct trobj Towel[] = {
  661. X    { TOWEL, 0, TOOL_CLASS, 1, 1, 0 },
  662. X    { 0, 0, 0, 0, 0, 0 }
  663. X};
  664. X#endif
  665. X
  666. X#ifdef EXPLORE_MODE
  667. Xstatic struct trobj Wishing[] = {
  668. X    { WAN_WISHING, 3, WAND_CLASS, 1, 1, 0 },
  669. X    { 0, 0, 0, 0, 0, 0 }
  670. X};
  671. X#endif
  672. X
  673. Xstatic struct trobj Instrument[] = {
  674. X    { WOODEN_FLUTE, 0, TOOL_CLASS, 1, 1, 0 },
  675. X    { 0, 0, 0, 0, 0, 0 }
  676. X};
  677. X
  678. Xstatic struct trobj Blindfold[] = {
  679. X    { BLINDFOLD, 0, TOOL_CLASS, 1, 1, 0 },
  680. X    { 0, 0, 0, 0, 0, 0 }
  681. X};
  682. X
  683. X#ifdef TOURIST
  684. Xstatic struct trobj Tourist[] = {
  685. X#define    T_DARTS        0
  686. X    { DART, 2, WEAPON_CLASS, 25, 1, UNDEF_BLESS },    /* quan is variable */
  687. X    { UNDEF_TYP, UNDEF_SPE, FOOD_CLASS, 10, 1, 0 },
  688. X    { POT_EXTRA_HEALING, 0, POTION_CLASS, 2, 1, UNDEF_BLESS },
  689. X    { SCR_MAGIC_MAPPING, 0, SCROLL_CLASS, 4, 1, UNDEF_BLESS },
  690. X    { HAWAIIAN_SHIRT, 0, ARMOR_CLASS, 1, 1, UNDEF_BLESS },
  691. X    { EXPENSIVE_CAMERA, 0, TOOL_CLASS, 1, 1, 0 },
  692. X    { CREDIT_CARD, 0, TOOL_CLASS, 1, 1, 0 },
  693. X    { 0, 0, 0, 0, 0, 0 }
  694. X};
  695. X#endif
  696. X
  697. Xstatic struct trobj Rogue[] = {
  698. X#define R_DAGGERS    1
  699. X    { SHORT_SWORD, 0, WEAPON_CLASS, 1, 1, UNDEF_BLESS },
  700. X    { DAGGER, 0, WEAPON_CLASS, 10, 1, 0 },    /* quan is variable */
  701. X    { LEATHER_ARMOR, 1, ARMOR_CLASS, 1, 1, UNDEF_BLESS },
  702. X    { POT_SICKNESS, 0, POTION_CLASS, 1, 1, 0 },
  703. X    { LOCK_PICK, 9, TOOL_CLASS, 1, 1, 0 },
  704. X    { SACK, 0, TOOL_CLASS, 1, 0, 0 },
  705. X    { 0, 0, 0, 0, 0, 0 }
  706. X};
  707. X
  708. Xstatic struct trobj Wizard[] = {
  709. X#define W_MULTSTART    2
  710. X#define W_MULTEND    6
  711. X    { ATHAME, 1, WEAPON_CLASS, 1, 1, 1 },    /* for dealing with ghosts */
  712. X    { CLOAK_OF_MAGIC_RESISTANCE, 0, ARMOR_CLASS, 1, 1, UNDEF_BLESS },
  713. X    { UNDEF_TYP, UNDEF_SPE, WAND_CLASS, 1, 1, UNDEF_BLESS },
  714. X    { UNDEF_TYP, UNDEF_SPE, RING_CLASS, 2, 1, UNDEF_BLESS },
  715. X    { UNDEF_TYP, UNDEF_SPE, POTION_CLASS, 3, 1, UNDEF_BLESS },
  716. X    { UNDEF_TYP, UNDEF_SPE, SCROLL_CLASS, 3, 1, UNDEF_BLESS },
  717. X    { UNDEF_TYP, UNDEF_SPE, SPBOOK_CLASS, 1, 1, UNDEF_BLESS },
  718. X    { 0, 0, 0, 0, 0, 0 }
  719. X};
  720. X
  721. Xstatic struct trobj Samurai[] = {
  722. X#define S_ARROWS    3
  723. X    { KATANA, 0, WEAPON_CLASS, 1, 1, UNDEF_BLESS },
  724. X    { SHORT_SWORD, 0, WEAPON_CLASS, 1, 1, UNDEF_BLESS }, /* wakizashi */
  725. X    { YUMI, 0, WEAPON_CLASS, 1, 1, UNDEF_BLESS },
  726. X    { YA, 0, WEAPON_CLASS, 25, 1, UNDEF_BLESS }, /* variable quan */
  727. X    { SPLINT_MAIL, 0, ARMOR_CLASS, 1, 1, UNDEF_BLESS },
  728. X    { FORTUNE_COOKIE, 0, FOOD_CLASS, 3, 1, 0 },
  729. X    { 0, 0, 0, 0, 0, 0 }
  730. X};
  731. X
  732. Xstatic struct trobj Priest[] = {
  733. X    { MACE, 1, WEAPON_CLASS, 1, 1, 1 },
  734. X    { CHAIN_MAIL, 0, ARMOR_CLASS, 1, 1, UNDEF_BLESS },
  735. X    { SMALL_SHIELD, 0, ARMOR_CLASS, 1, 1, UNDEF_BLESS },
  736. X    { POT_WATER, 0, POTION_CLASS, 4, 1, 1 },    /* holy water */
  737. X    { CLOVE_OF_GARLIC, 0, FOOD_CLASS, 1, 1, 0 },
  738. X    { SPRIG_OF_WOLFSBANE, 0, FOOD_CLASS, 1, 1, 0 },
  739. X    { UNDEF_TYP, UNDEF_SPE, SPBOOK_CLASS, 2, 1, UNDEF_BLESS },
  740. X    { 0, 0, 0, 0, 0, 0 }
  741. X};
  742. X
  743. Xstatic void
  744. Xknows_object(obj)
  745. Xregister int obj;
  746. X{
  747. X    makeknown(obj);
  748. X    objects[obj].oc_descr_idx = 0;        /* not a "discovery" */
  749. X}
  750. X
  751. X/* Know ordinary (non-magical) objects of a certain class,
  752. X * like all gems except the loadstone and luckstone.
  753. X */
  754. Xstatic void
  755. Xknows_class(sym)
  756. Xregister char sym;
  757. X{
  758. X    register int ct;
  759. X    for (ct = 1; ct <= NROFOBJECTS; ct++)
  760. X        if (objects[ct].oc_class == sym && !objects[ct].oc_magic)
  761. X            knows_object(ct);
  762. X}
  763. X
  764. Xstatic int
  765. Xrole_index(pc)
  766. Xchar pc;
  767. X{
  768. X    register const char *cp;
  769. X
  770. X    if ((cp = index(pl_classes, pc)) != 0)
  771. X        return(cp - pl_classes);
  772. X    return(-1);
  773. X}
  774. X
  775. Xvoid
  776. Xu_init()
  777. X{
  778. X    register int i;
  779. X    char pc;
  780. X
  781. X    pc = pl_character[0];
  782. X    if(pc == '\0') {
  783. X        /* should be unnecessary now */
  784. X        exit_nhwindows(NULL);
  785. X        terminate(0);
  786. X    }
  787. X    i = role_index(pc);
  788. X
  789. X    (void) strncpy(pl_character, roles[i], PL_CSIZ-1);
  790. X    pl_character[PL_CSIZ-1] = 0;
  791. X    flags.beginner = 1;
  792. X
  793. X    /* zero u, including pointer values --
  794. X     * necessary when aborting from a failed restore */
  795. X    (void) memset((genericptr_t)&u, 0, sizeof(u));
  796. X    for (i = 0; i < LAST_PROP+1; i++) u.uprops[i].p_tofn = 0;
  797. X    u.ustuck = (struct monst *)0;
  798. X
  799. X#if 0    /* documentation of more zero values as desirable */
  800. X    u.uluck  = u.moreluck = 0;
  801. X# ifdef TOURIST
  802. X    uarmu = 0;
  803. X# endif
  804. X    uarm = uarmc = uarmh = uarms = uarmg = uarmf = 0;
  805. X    uwep = uball = uchain = uleft = uright = 0;
  806. X    u.ublessed = 0;                /* not worthy yet */
  807. X    u.ugangr   = 0;                /* gods not angry */
  808. X# ifdef ELBERETH
  809. X    u.uevent.uhand_of_elbereth = 0;
  810. X# endif
  811. X    u.uevent.uheard_tune = 0;
  812. X    u.uevent.uopened_dbridge = 0;
  813. X    u.uevent.udemigod = 0;        /* not a demi-god yet... */
  814. X    u.udg_cnt = 0;
  815. X# ifdef POLYSELF
  816. X    u.mh = u.mhmax = u.mtimedone = 0;
  817. X# endif
  818. X    u.uz.dnum = u.uz0.dnum = 0;
  819. X    u.utotype = 0;
  820. X#endif    /* 0 */
  821. X    u.uz.dlevel = u.uz0.dlevel = 1;
  822. X    u.utolev = u.uz;
  823. X
  824. X    u.usym = S_HUMAN;
  825. X    u.umoved = FALSE;
  826. X    u.ugrave_arise = -1;
  827. X
  828. X    u.ulevel = 0;    /* set up some of the initial attributes */
  829. X    u.uhp = u.uhpmax = newhp();
  830. X    adjabil(0,1);
  831. X    u.ulevel = 1;
  832. X
  833. X    init_uhunger();
  834. X    u.uen = u.uenmax = 1;
  835. X    for (i = 0; i <= MAXSPELL; i++) spl_book[i].sp_id = NO_SPELL;
  836. X    u.ublesscnt = 300;            /* no prayers just yet */
  837. X#ifdef POLYSELF
  838. X    u.umonnum = -1;
  839. X    u.ulycn = -1;
  840. X    set_uasmon();
  841. X#endif
  842. X
  843. X    /*
  844. X     *  For now, everyone starts out with a night vision range of 1 and
  845. X     *  their xray range disabled.
  846. X     */
  847. X    u.nv_range   =  1;
  848. X    u.xray_range = -1;
  849. X
  850. X
  851. X    switch(pc) {
  852. X    /* pc will always be in uppercase by this point */
  853. X    case 'A':
  854. X        u.umonster = PM_ARCHEOLOGIST;
  855. X        ini_inv(Archeologist);
  856. X        if(!rn2(10)) ini_inv(Tinopener);
  857. X        else if(!rn2(4)) ini_inv(Lamp);
  858. X        else if(!rn2(10)) ini_inv(Magicmarker);
  859. X        knows_class(GEM_CLASS);
  860. X        knows_object(SACK);
  861. X        /* We can't set trknown for it, then it'd be "uncursed"
  862. X         * sack...
  863. X         */
  864. X        break;
  865. X    case 'B':
  866. X        u.umonster = PM_BARBARIAN;
  867. X        if (rn2(100) >= 50) {    /* see Elf comment */
  868. X            Barbarian[B_MAJOR].trotyp = BATTLE_AXE;
  869. X            Barbarian[B_MINOR].trotyp = SHORT_SWORD;
  870. X        }
  871. X        ini_inv(Barbarian);
  872. X        if(!rn2(6)) ini_inv(Lamp);
  873. X        knows_class(WEAPON_CLASS);
  874. X        knows_class(ARMOR_CLASS);
  875. X        break;
  876. X    case 'C':
  877. X        u.umonster = PM_CAVEMAN;
  878. X        Cave_man[C_ARROWS].trquan = rn1(30, 13);
  879. X        ini_inv(Cave_man);
  880. X        break;
  881. X    case 'E':
  882. X        u.umonster = PM_ELF;
  883. X        Elf[E_ARROWS].trquan = rn1(20, 16);
  884. X        Elf[E_ARMOR].trotyp = ((rn2(100) >= 50)
  885. X                 ? ELVEN_MITHRIL_COAT : ELVEN_CLOAK);
  886. X            /* rn2(100) > 50 necessary because some random number
  887. X             * generators are bad enough to seriously skew the
  888. X             * results if we use rn2(2)...  --KAA
  889. X             */
  890. X
  891. X        /*
  892. X         * Elves are people of music and song, or they are warriors.
  893. X         * Warriors get mithril coats; non-warriors MAY get an
  894. X         * instrument.  We use a kludge to get only non-magic
  895. X         * instruments.
  896. X         */
  897. X        if (Elf[E_ARMOR].trotyp == ELVEN_CLOAK) {
  898. X            if (!rn2(5)) {
  899. X                static int trotyp[] = {
  900. X                    WOODEN_FLUTE, TOOLED_HORN, WOODEN_HARP,
  901. X                    BELL, BUGLE, LEATHER_DRUM
  902. X                };
  903. X
  904. X                Instrument[0].trotyp = trotyp[rn2(SIZE(trotyp))];
  905. X#ifdef DEBUG
  906. X                debugpline("Elf got instrument %d",
  907. X                    Instrument[0].trotyp);
  908. X#endif
  909. X                ini_inv(Instrument);
  910. X            }
  911. X        }
  912. X        ini_inv(Elf);
  913. X        if(!rn2(5)) ini_inv(Blindfold);
  914. X        else if(!rn2(6)) ini_inv(Lamp);
  915. X        knows_object(ELVEN_SHORT_SWORD);
  916. X        knows_object(ELVEN_ARROW);
  917. X        knows_object(ELVEN_BOW);
  918. X        knows_object(ELVEN_SPEAR);
  919. X        knows_object(ELVEN_DAGGER);
  920. X        knows_object(ELVEN_BROADSWORD);
  921. X        knows_object(ELVEN_MITHRIL_COAT);
  922. X        knows_object(ELVEN_LEATHER_HELM);
  923. X        knows_object(ELVEN_SHIELD);
  924. X        knows_object(ELVEN_BOOTS);
  925. X        knows_object(ELVEN_CLOAK);
  926. X        break;
  927. X    case 'H':
  928. X        u.umonster = PM_HEALER;
  929. X        u.ugold = u.ugold0 = rn1(1000, 1001);
  930. X        ini_inv(Healer);
  931. X        if(!rn2(25)) ini_inv(Lamp);
  932. X        break;
  933. X    case 'K':
  934. X        u.umonster = PM_KNIGHT;
  935. X        ini_inv(Knight);
  936. X        knows_class(WEAPON_CLASS);
  937. X        knows_class(ARMOR_CLASS);
  938. X        /* give knights chess-like mobility
  939. X         * -- idea from wooledge@skybridge.scl.cwru.edu */
  940. X        Jumping |= FROMOUTSIDE;
  941. X        break;
  942. X    case 'P':
  943. X        u.umonster = PM_PRIEST;
  944. X        u.uen = u.uenmax += rn2(4);
  945. X        ini_inv(Priest);
  946. X        if(!rn2(10)) ini_inv(Magicmarker);
  947. X        else if(!rn2(10)) ini_inv(Lamp);
  948. X        knows_object(POT_WATER);
  949. X        break;
  950. X    case 'R':
  951. X        u.umonster = PM_ROGUE;
  952. X        Rogue[R_DAGGERS].trquan = rn1(10, 6);
  953. X        u.ugold = u.ugold0 = 0;
  954. X        ini_inv(Rogue);
  955. X        if(!rn2(5)) ini_inv(Blindfold);
  956. X        knows_object(SACK);
  957. X        break;
  958. X    case 'S':
  959. X        u.umonster = PM_SAMURAI;
  960. X        Samurai[S_ARROWS].trquan = rn1(20, 26);
  961. X        ini_inv(Samurai);
  962. X        if(!rn2(5)) ini_inv(Blindfold);
  963. X        knows_class(WEAPON_CLASS);
  964. X        knows_class(ARMOR_CLASS);
  965. X        break;
  966. X#ifdef TOURIST
  967. X    case 'T':
  968. X        u.umonster = PM_TOURIST;
  969. X        Tourist[T_DARTS].trquan = rn1(20, 21);
  970. X        u.ugold = u.ugold0 = rnd(1000);
  971. X        ini_inv(Tourist);
  972. X        if(!rn2(25)) ini_inv(Tinopener);
  973. X#ifdef WALKIES
  974. X        else if(!rn2(25)) ini_inv(Leash);
  975. X#endif
  976. X        else if(!rn2(25)) ini_inv(Towel);
  977. X        else if(!rn2(25)) ini_inv(Magicmarker);
  978. X        break;
  979. X#endif
  980. X    case 'V':
  981. X        u.umonster = PM_VALKYRIE;
  982. X        flags.female = TRUE;
  983. X        ini_inv(Valkyrie);
  984. X        if(!rn2(6)) ini_inv(Lamp);
  985. X        knows_class(WEAPON_CLASS);
  986. X        knows_class(ARMOR_CLASS);
  987. X        break;
  988. X    case 'W':
  989. X        u.umonster = PM_WIZARD;
  990. X        u.uen = u.uenmax += rn2(4);
  991. X        ini_inv(Wizard);
  992. X        if(!rn2(5)) ini_inv(Magicmarker);
  993. X        if(!rn2(5)) ini_inv(Blindfold);
  994. X        break;
  995. X
  996. X    default:    /* impossible */
  997. X        break;
  998. X    }
  999. X#ifdef EXPLORE_MODE
  1000. X    if (discover)
  1001. X        ini_inv(Wishing);
  1002. X#endif
  1003. X    find_ac();            /* get initial ac value */
  1004. X    init_attr(75);            /* init attribute values */
  1005. X    max_rank_sz();            /* set max str size for class ranks */
  1006. X/*
  1007. X *    Do we really need this?
  1008. X */
  1009. X    for(i = 0; i < A_MAX; i++)
  1010. X        if(!rn2(20)) {
  1011. X        register int xd = rn2(7) - 2;    /* biased variation */
  1012. X        (void) adjattrib(i, xd, TRUE);
  1013. X        if (ABASE(i) < AMAX(i)) AMAX(i) = ABASE(i);
  1014. X        }
  1015. X
  1016. X    /* make sure you can carry all you have - especially for Tourists */
  1017. X    while(inv_weight() > 0 && ACURR(A_STR) < 118)
  1018. X        (void) adjattrib(A_STR, 1, TRUE);
  1019. X
  1020. X    u.ualignbase[0] = u.ualignbase[1] = u.ualign.type;
  1021. X}
  1022. X
  1023. Xstatic void
  1024. Xini_inv(trop)
  1025. Xregister struct trobj *trop;
  1026. X{
  1027. X    struct obj *obj;
  1028. X    while(trop->trclass) {
  1029. X        boolean undefined = (trop->trotyp == UNDEF_TYP);
  1030. X
  1031. X        if (!undefined)
  1032. X            obj = mksobj((int)trop->trotyp, TRUE, FALSE);
  1033. X        else obj = mkobj(trop->trclass,FALSE);
  1034. X
  1035. X        /* For random objects, do not create certain overly powerful
  1036. X         * items: wand of wishing, ring of levitation, or the
  1037. X         * polymorph/polymorph control combination.  Specific objects,
  1038. X         * i.e. the discovery wishing, are still OK.
  1039. X         * Also, don't get a couple of really useless items.  (Note:
  1040. X         * punishment isn't "useless".  Some players who start out with
  1041. X         * one will immediately read it and use the iron ball as a
  1042. X         * weapon.)
  1043. X         */
  1044. X        if (undefined) {
  1045. X#ifdef POLYSELF
  1046. X            static unsigned NEARDATA nocreate = STRANGE_OBJECT;
  1047. X            static unsigned NEARDATA nocreate2 = STRANGE_OBJECT;
  1048. X#endif
  1049. X            static unsigned NEARDATA nocreate3 = STRANGE_OBJECT;
  1050. X
  1051. X            while(obj->otyp == WAN_WISHING
  1052. X#ifdef POLYSELF
  1053. X                || obj->otyp == nocreate
  1054. X                || obj->otyp == nocreate2
  1055. X#endif
  1056. X                || obj->otyp == nocreate3
  1057. X#ifdef ELBERETH
  1058. X                || obj->otyp == RIN_LEVITATION
  1059. X#endif
  1060. X                /* 'useless' items */
  1061. X                || obj->otyp == POT_HALLUCINATION
  1062. X                || obj->otyp == SCR_AMNESIA
  1063. X                || obj->otyp == SCR_FIRE
  1064. X                || obj->otyp == RIN_AGGRAVATE_MONSTER
  1065. X                || obj->otyp == RIN_HUNGER
  1066. X                || obj->otyp == WAN_NOTHING
  1067. X                /* powerful spells are either useless to
  1068. X                   low level players or unbalancing */
  1069. X                || (obj->oclass == SPBOOK_CLASS &&
  1070. X                    objects[obj->otyp].oc_level > 3)
  1071. X                            ) {
  1072. X                dealloc_obj(obj);
  1073. X                obj = mkobj(trop->trclass, FALSE);
  1074. X            }
  1075. X
  1076. X            /* Don't start with +0 or negative rings */
  1077. X            if(objects[obj->otyp].oc_charged && obj->spe <= 0)
  1078. X                obj->spe = rne(3);
  1079. X
  1080. X            /* Heavily relies on the fact that 1) we create wands
  1081. X             * before rings, 2) that we create rings before
  1082. X             * spellbooks, and that 3) not more than 1 object of a
  1083. X             * particular symbol is to be prohibited.  (For more
  1084. X             * objects, we need more nocreate variables...)
  1085. X             */
  1086. X#ifdef POLYSELF
  1087. X            switch (obj->otyp) {
  1088. X                case WAN_POLYMORPH:
  1089. X                case RIN_POLYMORPH:
  1090. X                nocreate = RIN_POLYMORPH_CONTROL;
  1091. X                break;
  1092. X                case RIN_POLYMORPH_CONTROL:
  1093. X                nocreate = RIN_POLYMORPH;
  1094. X                nocreate2 = SPE_POLYMORPH;
  1095. X            }
  1096. X#endif /* POLYSELF */
  1097. X            /* Don't have 2 of the same ring */
  1098. X            if (obj->oclass == RING_CLASS)
  1099. X                nocreate3 = obj->otyp;
  1100. X        }
  1101. X
  1102. X        obj->bknown = trop->trknown;
  1103. X        if(objects[obj->otyp].oc_uses_known) obj->known = trop->trknown;
  1104. X        /* not obj->dknown = 1; - let him look at it at least once */
  1105. X        obj->cursed = 0;
  1106. X        if(obj->oclass == WEAPON_CLASS || obj->oclass == TOOL_CLASS) {
  1107. X            obj->quan = (long) trop->trquan;
  1108. X            trop->trquan = 1;
  1109. X        }
  1110. X        if(obj->oclass == FOOD_CLASS && undefined) {
  1111. X            obj->known = 1;
  1112. X            /* needed for tins and eggs; harmless otherwise */
  1113. X            obj->bknown = 1;
  1114. X        }
  1115. X        /*
  1116. X         * The below lines not needed because they don't correspond
  1117. X         * to any actual inventory; nobody gets random tools.
  1118. X        else if(obj->oclass == TOOL_CLASS && undefined) {
  1119. X            obj->bknown = (obj->otyp != BAG_OF_TRICKS
  1120. X                && obj->otyp != SACK
  1121. X                && obj->otyp != CHEST
  1122. X                && obj->otyp != LARGE_BOX
  1123. X                && obj->otyp != ICE_BOX);
  1124. X        }
  1125. X        */
  1126. X        if(trop->trspe != UNDEF_SPE)
  1127. X            obj->spe = trop->trspe;
  1128. X        if(trop->trbless != UNDEF_BLESS)
  1129. X            obj->blessed = trop->trbless;
  1130. X
  1131. X        /* defined after setting otyp+quan + blessedness */
  1132. X        obj->owt = weight(obj);
  1133. X        obj = addinv(obj);
  1134. X
  1135. X        /* Make the type known if necessary */
  1136. X        if (OBJ_DESCR(objects[obj->otyp]) && obj->known)
  1137. X            makeknown(obj->otyp);
  1138. X
  1139. X        if(obj->oclass == ARMOR_CLASS){
  1140. X            if (is_shield(obj) && !uarms)
  1141. X                setworn(obj, W_ARMS);
  1142. X            else if (is_helmet(obj) && !uarmh)
  1143. X                setworn(obj, W_ARMH);
  1144. X            else if (is_gloves(obj) && !uarmg)
  1145. X                setworn(obj, W_ARMG);
  1146. X#ifdef TOURIST
  1147. X            else if (obj->otyp == HAWAIIAN_SHIRT && !uarmu)
  1148. X                setworn(obj, W_ARMU);
  1149. X#endif
  1150. X            else if (is_cloak(obj) && !uarmc)
  1151. X                setworn(obj, W_ARMC);
  1152. X            else if (is_boots(obj) && !uarmf)
  1153. X                setworn(obj, W_ARMF);
  1154. X            else if (!uarm)
  1155. X                setworn(obj, W_ARM);
  1156. X        }
  1157. X        /* below changed by GAN 01/09/87 to allow wielding of
  1158. X         * pick-axe or can-opener if there is no weapon
  1159. X         */
  1160. X        if(obj->oclass == WEAPON_CLASS || obj->otyp == PICK_AXE ||
  1161. X           obj->otyp == TIN_OPENER)
  1162. X            if(!uwep) setuwep(obj);
  1163. X#if !defined(PYRAMID_BUG) && !defined(MAC)
  1164. X        if(--trop->trquan) continue;    /* make a similar object */
  1165. X#else
  1166. X        if(trop->trquan) {        /* check if zero first */
  1167. X            --trop->trquan;
  1168. X            if(trop->trquan)
  1169. X                continue;    /* make a similar object */
  1170. X        }
  1171. X#endif
  1172. X        trop++;
  1173. X    }
  1174. X}
  1175. X
  1176. Xvoid
  1177. Xplnamesuffix() {
  1178. X    register char *p;
  1179. X    if ((p = rindex(plname, '-')) != 0) {
  1180. X        *p = 0;
  1181. X        pl_character[0] = p[1];
  1182. X        pl_character[1] = 0;
  1183. X        if(!plname[0]) {
  1184. X            askname();
  1185. X            plnamesuffix();
  1186. X        }
  1187. X    }
  1188. X}
  1189. X
  1190. X/*u_init.c*/
  1191. END_OF_FILE
  1192. if test 18225 -ne `wc -c <'src/u_init.c'`; then
  1193.     echo shar: \"'src/u_init.c'\" unpacked with wrong size!
  1194. fi
  1195. # end of 'src/u_init.c'
  1196. fi
  1197. if test -f 'src/worm.c' -a "${1}" != "-c" ; then 
  1198.   echo shar: Will not clobber existing file \"'src/worm.c'\"
  1199. else
  1200. echo shar: Extracting \"'src/worm.c'\" \(18662 characters\)
  1201. sed "s/^X//" >'src/worm.c' <<'END_OF_FILE'
  1202. X/*    SCCS Id: @(#)worm.c    3.1    91/12/30    */
  1203. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  1204. X/* NetHack may be freely redistributed.  See license for details. */
  1205. X
  1206. X#include "hack.h"
  1207. X#include "lev.h"
  1208. X
  1209. X#define newseg()      (struct wseg *) alloc(sizeof(struct wseg))
  1210. X#define dealloc_seg(wseg) free((genericptr_t) (wseg))
  1211. X
  1212. X/* worm segment structure */
  1213. Xstruct wseg {
  1214. X    struct wseg *nseg;
  1215. X    xchar  wx, wy;    /* the segment's position */
  1216. X};
  1217. X
  1218. Xstatic void FDECL(toss_wsegs, (struct wseg *,BOOLEAN_P));
  1219. Xstatic void FDECL(shrink_worm, (int));
  1220. Xstatic void FDECL(random_dir, (XCHAR_P,XCHAR_P,xchar *,xchar *));
  1221. Xstatic struct wseg *FDECL(create_worm_tail, (int));
  1222. X
  1223. X/*  Description of long worm implementation.
  1224. X *
  1225. X *  Each monst struct of the head of a tailed worm has a wormno set to
  1226. X *            1 <= wormno < MAX_NUM_WORMS
  1227. X *  If wormno == 0 this does not mean that the monster is not a worm,
  1228. X *  it just means that the monster does not have a long worm tail.
  1229. X *
  1230. X *  The actual segments of a worm are not full blown monst structs.
  1231. X *  They are small wseg structs, and their position in the levels.monsters[][]
  1232. X *  array is held by the monst struct of the head of the worm.  This makes
  1233. X *  things like probing and hit point bookkeeping much easier.
  1234. X *
  1235. X *  The segments of the long worms on a level are kept as an array of
  1236. X *  singly threaded linked lists.  The wormno variable is used as an index
  1237. X *  for these segment arrays.
  1238. X *
  1239. X *  wtails:    The first (starting struct) of a linked list.  This points
  1240. X *        to the tail (last) segment of the worm.
  1241. X *
  1242. X *  wheads:    The last (end) of a linked list of segments.  This points to
  1243. X *        the segment that is at the same position as the real monster
  1244. X *        (the head).  Note that the segment that wheads[wormno] points
  1245. X *        to, is not displayed.  It is simply there to keep track of
  1246. X *        where the head came from, so that worm movement and display are
  1247. X *        simplified later.
  1248. X *        Keeping the head segment of the worm at the end of the list
  1249. X *        of tail segments is an endless source of confusion, but it is
  1250. X *        necessary.
  1251. X *        From now on, we will use "start" and "end" to refer to the
  1252. X *        linked list and "head" and "tail" to refer to the worm.
  1253. X *
  1254. X *  One final worm array is:
  1255. X *
  1256. X *  wgrowtime:    This tells us when to add another segment to the worm.
  1257. X *
  1258. X *  When a worm is moved, we add a new segment at the head, and delete the
  1259. X *  segment at the tail (unless we want it to grow).  This new head segment is
  1260. X *  located in the same square as the actual head of the worm.  If we want
  1261. X *  to grow the worm, we don't delete the tail segment, and we give the worm
  1262. X *  extra hit points, which possibly go into its maximum.
  1263. X *
  1264. X *  Non-moving worms (worm_nomove) are assumed to be surrounded by their own
  1265. X *  tail, and, thus, shrink instead of grow (as their tails keep going while
  1266. X *  their heads are stopped short).  In this case, we delete the last tail
  1267. X *  segment, and remove hit points from the worm.
  1268. X */
  1269. X
  1270. Xstruct wseg *wheads[MAX_NUM_WORMS]   = DUMMY, *wtails[MAX_NUM_WORMS] = DUMMY;
  1271. Xlong         wgrowtime[MAX_NUM_WORMS] = DUMMY;
  1272. X
  1273. X/*
  1274. X *  get_wormno()
  1275. X *  
  1276. X *  Find an unused worm tail slot and return the index.  A zero means that
  1277. X *  there are no slots available.  This means that the worm head can exist,
  1278. X *  it just cannot ever grow a tail.
  1279. X *
  1280. X *  It, also, means that there is an optimisation to made.  The [0] positions
  1281. X *  of the arrays are never used.  Meaning, we really *could* have one more
  1282. X *  tailed worm on the level, or use a smaller array (using wormno - 1).
  1283. X *
  1284. X *  Implementation is left to the interested hacker.
  1285. X */
  1286. Xint
  1287. Xget_wormno()
  1288. X{
  1289. X    register int new_wormno = 1;
  1290. X
  1291. X    while (new_wormno < MAX_NUM_WORMS) {
  1292. X    if (!wheads[new_wormno])
  1293. X        return new_wormno; /* found an empty wtails[] slot at new_wormno */
  1294. X    new_wormno++;
  1295. X    }
  1296. X
  1297. X    return(0);    /* level infested with worms */
  1298. X}
  1299. X
  1300. X/*
  1301. X *  initworm()
  1302. X *  
  1303. X *  Use if (mon->wormno = get_wormno()) before calling this function!
  1304. X *
  1305. X *  Initialize the worm entry.  This will set up the worm grow time, and
  1306. X *  create and initialize the dummy segment for wheads[] and wtails[].
  1307. X *
  1308. X *  If the worm has no tail (ie get_wormno() fails) then this function need
  1309. X *  not be called.
  1310. X */
  1311. Xvoid
  1312. Xinitworm(worm, wseg_count)
  1313. X    struct monst *worm;
  1314. X    int wseg_count;
  1315. X{
  1316. X    register struct wseg *seg, *new_tail = create_worm_tail(wseg_count);
  1317. X    register int wnum = worm->wormno;
  1318. X
  1319. X/*  if (!wnum) return; /* bullet proofing */
  1320. X
  1321. X    if (new_tail) {
  1322. X    wtails[wnum] = new_tail;
  1323. X    for (seg = new_tail; seg->nseg; seg = seg->nseg);
  1324. X    wheads[wnum] = seg;
  1325. X    } else {
  1326. X        wtails[wnum] = wheads[wnum] = seg = newseg();
  1327. X    seg->nseg    = (struct wseg *) 0;
  1328. X    seg->wx      = worm->mx;
  1329. X    seg->wy      = worm->my;
  1330. X    }
  1331. X    wgrowtime[wnum] = 0L;
  1332. X}
  1333. X
  1334. X
  1335. X/*
  1336. X *  toss_wsegs()
  1337. X *  
  1338. X *  Get rid of all worm segments on and following the given pointer curr.
  1339. X *  The display may or may not need to be updated as we free the segments.
  1340. X */
  1341. Xstatic
  1342. Xvoid
  1343. Xtoss_wsegs(curr, display_update)
  1344. X    register struct wseg *curr;
  1345. X    register boolean display_update;
  1346. X{
  1347. X    register struct wseg *seg;
  1348. X
  1349. X    while (curr) {
  1350. X    seg = curr->nseg;
  1351. X
  1352. X    /* remove from level.monsters[][] */
  1353. X
  1354. X    /* need to check curr->wx for genocided while migrating_mon */
  1355. X    if (curr->wx) {
  1356. X        remove_monster(curr->wx, curr->wy);
  1357. X
  1358. X        /* update screen before deallocation */
  1359. X        if (display_update) newsym(curr->wx,curr->wy);
  1360. X    }
  1361. X
  1362. X    /* free memory used by the segment */
  1363. X    dealloc_seg(curr);
  1364. X    curr = seg;
  1365. X    }
  1366. X}
  1367. X
  1368. X
  1369. X/*
  1370. X *  shrink_worm()
  1371. X *
  1372. X *  Remove the tail segment of the worm (the starting segment of the list).
  1373. X */
  1374. Xstatic
  1375. Xvoid
  1376. Xshrink_worm(wnum)
  1377. X    int wnum;    /* worm number */
  1378. X{
  1379. X    struct wseg *seg;
  1380. X
  1381. X    if (wtails[wnum] == wheads[wnum]) return;    /* no tail */
  1382. X
  1383. X    seg = wtails[wnum];
  1384. X    wtails[wnum] = seg->nseg;
  1385. X    seg->nseg = (struct wseg *) 0;
  1386. X    toss_wsegs(seg, TRUE);
  1387. X}
  1388. X
  1389. X/*
  1390. X *  worm_move()
  1391. X * 
  1392. X *  Check for mon->wormno before calling this function!
  1393. X *
  1394. X *  Move the worm.  Maybe grow.
  1395. X */
  1396. Xvoid
  1397. Xworm_move(worm)
  1398. X    struct monst *worm;
  1399. X{
  1400. X    register struct wseg *seg, *new_seg;    /* new segment */
  1401. X    register int     wnum = worm->wormno;    /* worm number */
  1402. X
  1403. X
  1404. X/*  if (!wnum) return; /* bullet proofing */
  1405. X
  1406. X    /*
  1407. X     *  Place a segment at the old worm head.  The head has already moved.
  1408. X     */
  1409. X    seg = wheads[wnum];
  1410. X    place_worm_seg(worm, seg->wx, seg->wy);
  1411. X    newsym(seg->wx,seg->wy);        /* display the new segment */
  1412. X
  1413. X    /*
  1414. X     *  Create a new dummy segment head and place it at the end of the list.
  1415. X     */
  1416. X    new_seg       = newseg();
  1417. X    new_seg->wx   = worm->mx;
  1418. X    new_seg->wy   = worm->my;
  1419. X    new_seg->nseg = (struct wseg *) 0;
  1420. X    seg->nseg     = new_seg;        /* attach it to the end of the list */
  1421. X    wheads[wnum]  = new_seg;        /* move the end pointer */
  1422. X
  1423. X
  1424. X    if (wgrowtime[wnum] <= moves) {
  1425. X    if (!wgrowtime[wnum])
  1426. X        wgrowtime[wnum] = moves + rnd(5);
  1427. X    else
  1428. X        wgrowtime[wnum] += rn1(15, 3);
  1429. X    worm->mhp += 3;
  1430. X    if (worm->mhp > MHPMAX) worm->mhp = MHPMAX;
  1431. X    if (worm->mhp > worm->mhpmax) worm->mhpmax = worm->mhp;
  1432. X    } else
  1433. X    /* The worm doesn't grow, so the last segment goes away. */
  1434. X    shrink_worm(wnum);
  1435. X}
  1436. X
  1437. X/*
  1438. X *  worm_nomove()
  1439. X * 
  1440. X *  Check for mon->wormno before calling this function!
  1441. X *
  1442. X *  The worm don't move so it should shrink.
  1443. X */
  1444. Xvoid
  1445. Xworm_nomove(worm)
  1446. X    register struct monst *worm;
  1447. X{
  1448. X    shrink_worm((int) worm->wormno);    /* shrink */
  1449. X
  1450. X    if (worm->mhp > 3)
  1451. X    worm->mhp -= 3;        /* mhpmax not changed ! */
  1452. X    else
  1453. X    worm->mhp = 1;
  1454. X}
  1455. X
  1456. X/*
  1457. X *  wormgone()
  1458. X *
  1459. X *  Check for mon->wormno before calling this function!
  1460. X *
  1461. X *  Kill a worm tail.
  1462. X */
  1463. Xvoid
  1464. Xwormgone(worm)
  1465. X    register struct monst *worm;
  1466. X{
  1467. X    register int wnum = worm->wormno;
  1468. X
  1469. X/*  if (!wnum) return; /* bullet proofing */
  1470. X
  1471. X    worm->wormno = 0;
  1472. X
  1473. X    /*  This will also remove the real monster (ie 'w') from the its
  1474. X     *  position in level.monsters[][].
  1475. X     */
  1476. X    toss_wsegs(wtails[wnum], TRUE);
  1477. X
  1478. X    wheads[wnum] = wtails[wnum] = (struct wseg *) 0;
  1479. X}
  1480. X
  1481. X/*
  1482. X *  wormhitu()
  1483. X *
  1484. X *  Check for mon->wormno before calling this function!
  1485. X *
  1486. X *  If the hero is near any part of the worm, the worm will try to attack.
  1487. X */
  1488. Xvoid
  1489. Xwormhitu(worm)
  1490. X    register struct monst *worm;
  1491. X{
  1492. X    register int wnum = worm->wormno;
  1493. X    register struct wseg *seg;
  1494. X
  1495. X/*  if (!wnum) return; /* bullet proofing */
  1496. X
  1497. X/*  This does not work right now because mattacku() thinks that the head is
  1498. X *  out of range of the player.  We might try to kludge, and bring the head
  1499. X *  within range for a tiny moment, but this needs a bit more looking at
  1500. X *  before we decide to do this.
  1501. X */
  1502. X    for (seg = wtails[wnum]; seg; seg = seg->nseg)
  1503. X    if (distu(seg->wx, seg->wy) < 3)
  1504. X        (void) mattacku(worm);
  1505. X}
  1506. X
  1507. X/*  cutworm()
  1508. X *
  1509. X *  Check for mon->wormno before calling this function!
  1510. X *
  1511. X *  When hitting a worm (worm) at position x, y, with a weapon (weap),
  1512. X *  there is a chance that the worm will be cut in half, and a chance
  1513. X *  that both halves will survive.
  1514. X */
  1515. Xvoid
  1516. Xcutworm(worm, x, y, weap)
  1517. X    struct monst *worm;
  1518. X    xchar x,y;
  1519. X    struct obj *weap;
  1520. X{
  1521. X    register struct wseg  *curr, *new_tail;
  1522. X    register struct monst *new_worm;
  1523. X    int wnum = worm->wormno;
  1524. X    int cut_chance, new_wnum;
  1525. X
  1526. X/*  if (!wnum) return; /* bullet proofing */
  1527. X
  1528. X    if (x == worm->mx && y == worm->my) return;        /* hit on head */
  1529. X
  1530. X    /* cutting goes best with a bladed weapon */
  1531. X    cut_chance = rnd(20);    /* Normally  1-16 does not cut */
  1532. X                /* Normally 17-20 does */
  1533. X
  1534. X    if (weap && is_blade(weap))    /* With a blade 1- 6 does not cut */
  1535. X    cut_chance += 10;    /*         7-20 does */
  1536. X
  1537. X    if (cut_chance < 17) return;    /* not good enough */
  1538. X
  1539. X    /* Find the segment that was attacked. */
  1540. X    curr = wtails[wnum];
  1541. X
  1542. X    while ( (curr->wx != x) || (curr->wy != y) ) {
  1543. X    curr = curr->nseg;
  1544. X    if (!curr) {
  1545. X        impossible("cut_worm:  no segment at (%d,%d)", (int) x, (int) y);
  1546. X        return;
  1547. X    }
  1548. X    }
  1549. X
  1550. X    /* If this is the tail segment, then the worm just loses it. */
  1551. X    if (curr == wtails[wnum]) {
  1552. X    shrink_worm(wnum);
  1553. X    return;
  1554. X    }
  1555. X
  1556. X    /*
  1557. X     *  Split the worm.  The tail for the new worm is the old worm's tail.
  1558. X     *  The tail for the old worm is the segment that follows "curr", 
  1559. X     *  and "curr" becomes the dummy segment under the new head.
  1560. X     */
  1561. X    new_tail = wtails[wnum];
  1562. X    wtails[wnum] = curr->nseg;
  1563. X    curr->nseg = (struct wseg *) 0;    /* split the worm */
  1564. X
  1565. X    /*
  1566. X     *  At this point, the old worm is correct.  Any new worm will have
  1567. X     *  it's head at "curr" and its tail at "new_tail".
  1568. X     */
  1569. X
  1570. X    /* Sometimes the tail end dies. */
  1571. X    if (rn2(3) || !(new_wnum = get_wormno())) {
  1572. X    You("cut part of the tail off of %s.", mon_nam(worm));
  1573. X    toss_wsegs(new_tail, TRUE);
  1574. X    worm->mhp /= 2;
  1575. X    return;
  1576. X    }
  1577. X
  1578. X    /* Create the second worm. */
  1579. X    new_worm  = newmonst(0);
  1580. X    *new_worm = *worm;            /* make a copy of the old worm */
  1581. X    new_worm->m_id = flags.ident++;    /* make sure it has a unique id */
  1582. X    new_worm->wormno = new_wnum;    /* affix new worm number */
  1583. X
  1584. X    if (worm->mtame)
  1585. X    new_worm->mtame = (rn2(max(2 + u.uluck, 2)) ? worm->mtame : 0);
  1586. X    else
  1587. X    if (worm->mpeaceful)
  1588. X        new_worm->mpeaceful = (rn2(max(2 + u.uluck, 2)) ? 1 : 0);
  1589. X    set_malign(new_worm);
  1590. X
  1591. X    new_worm->mxlth = new_worm->mnamelth = 0;
  1592. X    
  1593. X    /* Devalue the monster level of both halves of the worm. */
  1594. X    worm->m_lev = ((unsigned)worm->m_lev <= 3) ? 
  1595. X           (unsigned)worm->m_lev : max((unsigned)worm->m_lev - 2, 3);
  1596. X    new_worm->m_lev = worm->m_lev;
  1597. X
  1598. X    /* Calculate the mhp on the new_worm for the (lower) monster level. */
  1599. X    new_worm->mhpmax = new_worm->mhp = d((int)new_worm->m_lev, 8);
  1600. X
  1601. X    /* Calculate the mhp on the old worm for the (lower) monster level. */
  1602. X    if (worm->m_lev > 3) {
  1603. X    worm->mhpmax = d((int)worm->m_lev, 8);
  1604. X    if (worm->mhpmax < worm->mhp) worm->mhp = worm->mhpmax;
  1605. X    }
  1606. X
  1607. X    /* Add new monster to mon chain. */
  1608. X    new_worm->nmon = fmon;
  1609. X    fmon = new_worm;
  1610. X
  1611. X    /* Initialize the new worm. */
  1612. X    place_monster(new_worm, x, y);    /* put worm in level.monsters[][] */
  1613. X    newsym(x, y);            /* make sure new worm shows up */
  1614. X
  1615. X    wtails[new_wnum] = new_tail;    /* We've got all the info right now */
  1616. X    wheads[new_wnum] = curr;        /* so we can do this faster than    */
  1617. X    wgrowtime[new_wnum] = 0L;        /* trying to call initworm().       */
  1618. X
  1619. X    /* Place the new monster at all the segment locations. */
  1620. X    place_wsegs(new_worm);
  1621. X
  1622. X    You("cut %s in half.", mon_nam(worm));
  1623. X}
  1624. X
  1625. X
  1626. X/*
  1627. X *  see_wsegs()
  1628. X *
  1629. X *  Refresh all of the segments of the given worm.  This is only called
  1630. X *  from see_monster() in display.c or when a monster goes minvis.  It
  1631. X *  is located here for modularity.
  1632. X */
  1633. Xvoid
  1634. Xsee_wsegs(worm) 
  1635. X    struct monst *worm;
  1636. X{
  1637. X    struct wseg *curr = wtails[worm->wormno];
  1638. X
  1639. X/*  if (!mtmp->wormno) return; /* bullet proofing */
  1640. X
  1641. X    while (curr != wheads[worm->wormno]) {
  1642. X    newsym(curr->wx,curr->wy);
  1643. X    curr = curr->nseg;
  1644. X    }
  1645. X}
  1646. X
  1647. X
  1648. X/*
  1649. X *  save_worm()
  1650. X *  
  1651. X *  Save the worm information for later use.  The count is the number
  1652. X *  of segments, including the dummy.  Called from save.c.
  1653. X */
  1654. Xvoid
  1655. Xsave_worm(fd, mode)
  1656. X    int fd, mode;
  1657. X{
  1658. X    int i;
  1659. X    int count;
  1660. X    struct wseg *curr, *temp;
  1661. X
  1662. X    for (i = 1; i < MAX_NUM_WORMS; i++) {
  1663. X    for (count = 0, curr = wtails[i]; curr; curr = curr->nseg) count++;
  1664. X
  1665. X    /* Save number of segments */
  1666. X    bwrite(fd, (genericptr_t) &count, sizeof(int));
  1667. X
  1668. X    /* Save segment locations of the monster. */
  1669. X    if (count) {
  1670. X        for (curr = wtails[i]; curr; curr = curr->nseg) {
  1671. X        bwrite(fd, (genericptr_t) &(curr->wx), sizeof(xchar));
  1672. X        bwrite(fd, (genericptr_t) &(curr->wy), sizeof(xchar));
  1673. X        }
  1674. X    }
  1675. X    }
  1676. X    bwrite(fd, (genericptr_t) wgrowtime, sizeof(wgrowtime));
  1677. X
  1678. X    if (mode & FREE_SAVE) {
  1679. X    /* Free the segments only.  savemonchn() will take care of the
  1680. X     * monsters. */
  1681. X    for (i = 1; i < MAX_NUM_WORMS; i++) {
  1682. X        if (!(curr = wtails[i])) continue;
  1683. X
  1684. X        while (curr) {
  1685. X        temp = curr->nseg;
  1686. X        dealloc_seg(curr);        /* free the segment */
  1687. X        curr = temp;
  1688. X        }
  1689. X        wheads[i] = wtails[i] = (struct wseg *) 0;
  1690. X    }
  1691. X    }
  1692. X
  1693. X}
  1694. X
  1695. X/*
  1696. X *  rest_worm()
  1697. X *
  1698. X *  Restore the worm information from the save file.  Called from restore.c
  1699. X */
  1700. Xvoid
  1701. Xrest_worm(fd)
  1702. X    int fd;
  1703. X{
  1704. X    int i, j, count;
  1705. X    struct wseg *curr, *temp;
  1706. X
  1707. X    for (i = 1; i < MAX_NUM_WORMS; i++) {
  1708. X    mread(fd, (genericptr_t) &count, sizeof(int));
  1709. X    if (!count) continue;    /* none */
  1710. X
  1711. X    /* Get the segments. */
  1712. X    for (curr = (struct wseg *) 0, j = 0; j < count; j++) {
  1713. X        temp = newseg();
  1714. X        temp->nseg = (struct wseg *) 0;
  1715. X        mread(fd, (genericptr_t) &(temp->wx), sizeof(xchar));
  1716. X        mread(fd, (genericptr_t) &(temp->wy), sizeof(xchar));
  1717. X        if (curr)
  1718. X        curr->nseg = temp;
  1719. X        else
  1720. X        wtails[i] = temp;
  1721. X        curr = temp;
  1722. X    }
  1723. X    wheads[i] = curr;
  1724. X    }
  1725. X    mread(fd, (genericptr_t) wgrowtime, sizeof(wgrowtime));
  1726. X}
  1727. X
  1728. X/*
  1729. X *  place_wsegs()
  1730. X *
  1731. X *  Place the segments of the given worm.  Called from restore.c
  1732. X */
  1733. Xvoid
  1734. Xplace_wsegs(worm) 
  1735. X    struct monst *worm;
  1736. X{
  1737. X    struct wseg *curr = wtails[worm->wormno];
  1738. X
  1739. X/*  if (!mtmp->wormno) return; /* bullet proofing */
  1740. X
  1741. X    while (curr != wheads[worm->wormno]) {
  1742. X    place_worm_seg(worm,curr->wx,curr->wy);
  1743. X    curr = curr->nseg;
  1744. X    }
  1745. X}
  1746. X
  1747. X/*
  1748. X *  remove_worm()
  1749. X *
  1750. X *  This function is equivalent to the remove_monster #define in
  1751. X *  rm.h, only it will take the worm *and* tail out of the levels array.
  1752. X *  It does not get rid of (dealloc) the worm tail structures, and it does
  1753. X *  not remove the mon from the fmon chain.
  1754. X */
  1755. Xvoid
  1756. Xremove_worm(worm)
  1757. X    register struct monst *worm;
  1758. X{
  1759. X    register struct wseg *curr = wtails[worm->wormno];
  1760. X
  1761. X/*  if (!mtmp->wormno) return; /* bullet proofing */
  1762. X
  1763. X    while (curr) {
  1764. X    remove_monster(curr->wx, curr->wy);
  1765. X    newsym(curr->wx, curr->wy);
  1766. X    curr = curr->nseg;
  1767. X    }
  1768. X}
  1769. X
  1770. X/*
  1771. X *  place_worm_tail_randomly()
  1772. X *
  1773. X *  Place a worm tail somewhere on a level behind the head.
  1774. X *  This routine essentially reverses the order of the wsegs from head
  1775. X *  to tail while placing them.
  1776. X *  x, and y are most likely the worm->mx, and worm->my, but don't *need* to
  1777. X *  be, if somehow the head is disjoint from the tail.
  1778. X */
  1779. Xvoid
  1780. Xplace_worm_tail_randomly(worm, x, y)
  1781. X    struct monst *worm;
  1782. X    xchar x, y;
  1783. X{
  1784. X    int wnum = worm->wormno;
  1785. X    struct wseg *curr = wtails[wnum];
  1786. X    struct wseg *new_tail;
  1787. X    register xchar ox = x, oy = y;
  1788. X
  1789. X/*  if (!wnum) return; /* bullet proofing */
  1790. X
  1791. X    if (wnum && (!wtails[wnum] || !wheads[wnum]) ) {
  1792. X    impossible("place_worm_tail_randomly: wormno is set without a tail!");
  1793. X    return;
  1794. X    }
  1795. X
  1796. X    wheads[wnum] = new_tail = curr;
  1797. X    curr = curr->nseg;
  1798. X    new_tail->nseg = (struct wseg *) 0;
  1799. X    new_tail->wx = x;
  1800. X    new_tail->wy = y;
  1801. X
  1802. X    while(curr)  {
  1803. X    xchar nx, ny;
  1804. X    char tryct = 0;
  1805. X
  1806. X    /* pick a random direction from x, y and search for goodpos() */
  1807. X
  1808. X    do {
  1809. X        random_dir(ox, oy, &nx, &ny);
  1810. X    } while (!goodpos(nx, ny, worm, worm->data) && (tryct++ < 50));
  1811. X
  1812. X    if (tryct < 50)  {
  1813. X        place_worm_seg(worm, nx, ny);
  1814. X        curr->wx = ox = nx;
  1815. X        curr->wy = oy = ny;
  1816. X        wtails[wnum] = curr;
  1817. X        curr = curr->nseg;
  1818. X        wtails[wnum]->nseg = new_tail;
  1819. X        new_tail = wtails[wnum];
  1820. X        newsym(nx, ny);
  1821. X    } else {            /* Oops.  Truncate because there was */
  1822. X        toss_wsegs(curr, FALSE);    /* no place for the rest of it */
  1823. X        curr = (struct wseg *) 0;
  1824. X    }
  1825. X    }
  1826. X}
  1827. X
  1828. X/*
  1829. X * Given a coordinate x, y.
  1830. X * return in *nx, *ny, the coordinates of one of the <= 8 squares adjoining.
  1831. X *
  1832. X * This function, and the loop it serves, could be eliminated by coding
  1833. X * enexto() with a search radius.
  1834. X */
  1835. Xstatic
  1836. Xvoid
  1837. Xrandom_dir(x, y, nx, ny)
  1838. X    register xchar   x,   y;
  1839. X    register xchar *nx, *ny;
  1840. X{
  1841. X    *nx = x;
  1842. X    *ny = y;
  1843. X
  1844. X    *nx += (x > 1 ?            /* extreme left ? */
  1845. X        (x < COLNO ?         /* extreme right ? */
  1846. X            (rn2(3) - 1)      /* neither so +1, 0, or -1 */
  1847. X        :    -rn2(2))     /* 0, or -1 */
  1848. X       :    rn2(2));        /* 0, or 1 */
  1849. X
  1850. X    *ny += (*nx == x ?            /* same kind of thing with y */
  1851. X        (y > 1 ?
  1852. X            (y < ROWNO ?
  1853. X            (rn2(2) ?
  1854. X                1
  1855. X            :   -1)
  1856. X            :    -1)
  1857. X        :   1) 
  1858. X        :    (y > 1 ?
  1859. X            (y < ROWNO ?
  1860. X            (rn2(3) - 1)
  1861. X            :    -rn2(2))
  1862. X        :   rn2(2)));
  1863. X}
  1864. X
  1865. X/*  count_wsegs()
  1866. X *
  1867. X *  returns
  1868. X *  the number of visible segments that a worm has.
  1869. X */
  1870. X
  1871. Xint
  1872. Xcount_wsegs(mtmp)
  1873. X    struct monst *mtmp;
  1874. X{
  1875. X    register int i=0;
  1876. X    register struct wseg *curr = (wtails[mtmp->wormno])->nseg;
  1877. X
  1878. X/*  if (!mtmp->wormno) return 0; /* bullet proofing */
  1879. X
  1880. X    while (curr) {
  1881. X    i++;
  1882. X    curr = curr->nseg;
  1883. X    }
  1884. X
  1885. X    return i;
  1886. X}
  1887. X
  1888. X/*  create_worm_tail()
  1889. X *
  1890. X *  will create a worm tail chain of (num_segs + 1) and return a pointer to it.
  1891. X */
  1892. Xstatic
  1893. Xstruct wseg *
  1894. Xcreate_worm_tail(num_segs)
  1895. X    int num_segs;
  1896. X{
  1897. X    register int i=0;
  1898. X    register struct wseg *new_tail, *curr;
  1899. X
  1900. X    if (!num_segs) return (struct wseg *)0;
  1901. X
  1902. X    new_tail = curr = newseg();
  1903. X    curr->nseg = (struct wseg *)0;
  1904. X    curr->wx = 0;
  1905. X    curr->wy = 0;
  1906. X
  1907. X    while (i < num_segs) {
  1908. X    curr->nseg = newseg();
  1909. X    curr = curr->nseg;
  1910. X    curr->nseg = (struct wseg *)0;
  1911. X    curr->wx = 0;
  1912. X    curr->wy = 0;
  1913. X    i++;
  1914. X    }
  1915. X
  1916. X    return (new_tail);
  1917. X}
  1918. X
  1919. X/*worm.c*/
  1920. END_OF_FILE
  1921. if test 18662 -ne `wc -c <'src/worm.c'`; then
  1922.     echo shar: \"'src/worm.c'\" unpacked with wrong size!
  1923. fi
  1924. # end of 'src/worm.c'
  1925. fi
  1926. echo shar: End of archive 82 \(of 108\).
  1927. cp /dev/null ark82isdone
  1928. MISSING=""
  1929. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
  1930. 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 \
  1931. 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 \
  1932. 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 \
  1933. 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 \
  1934. 101 102 103 104 105 106 107 108 ; do
  1935.     if test ! -f ark${I}isdone ; then
  1936.     MISSING="${MISSING} ${I}"
  1937.     fi
  1938. done
  1939. if test "${MISSING}" = "" ; then
  1940.     echo You have unpacked all 108 archives.
  1941.     echo "Now execute 'rebuild.sh'"
  1942.     rm -f ark10[0-8]isdone ark[1-9]isdone ark[1-9][0-9]isdone
  1943. else
  1944.     echo You still need to unpack the following archives:
  1945.     echo "        " ${MISSING}
  1946. fi
  1947. ##  End of shell archive.
  1948. exit 0
  1949.