home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / games / volume16 / nethack31 / part96 < 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: v16i104:  nethack31 - display oriented dungeons & dragons (Ver. 3.1), Part96/108
  5. Message-ID: <4469@master.CNA.TEK.COM>
  6. Date: 5 Feb 93 22:03:06 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 1986
  9. Approved: billr@saab.CNA.TEK.COM
  10. Xref: uunet comp.sources.games:1655
  11.  
  12. Submitted-by: izchak@linc.cis.upenn.edu (Izchak Miller)
  13. Posting-number: Volume 16, Issue 104
  14. Archive-name: nethack31/Part96
  15. Supersedes: nethack3p9: Volume 10, Issue 46-108
  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 96 (of 108)."
  27. # Contents:  dat/help include/decl.h src/extralev.c src/mplayer.c
  28. #   src/wield.c sys/share/pcunix.c win/tty/topl.c
  29. # Wrapped by billr@saab on Wed Jan 27 16:09:27 1993
  30. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  31. if test -f 'dat/help' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'dat/help'\"
  33. else
  34. echo shar: Extracting \"'dat/help'\" \(8454 characters\)
  35. sed "s/^X//" >'dat/help' <<'END_OF_FILE'
  36. X        Welcome to NetHack!                ( description of version 3.1 )
  37. X
  38. X        NetHack is a Dungeons and Dragons like game where you (the adventurer)
  39. Xdescend into the depths of the dungeon in search of the Amulet of Yendor
  40. X(reputed to be hidden somewhere below the twentieth level).  You are
  41. Xaccompanied by a dog or cat that can help you in many ways and can be trained
  42. Xto do all sorts of things.  On the way you will find useful (or useless)
  43. Xitems (quite possibly with magic properties), and assorted monsters.  You
  44. Xattack a monster by trying to move into the space a monster is in (but often
  45. Xit is much wiser to leave it alone).
  46. X
  47. X        Unlike most adventure games, which give you a verbal description of
  48. Xyour location, NetHack gives you a visual image of the dungeon level you are
  49. Xon.
  50. X
  51. X        NetHack uses the following symbols:
  52. X
  53. X        - and |  The walls of a room, also open doors.
  54. X        .        The floor of a room or a doorway.
  55. X        #        A corridor, a kitchen sink (if your dungeon has sinks), or
  56. X                 a drawbridge.
  57. X        >        A way to the next level.
  58. X        <        A way to the previous level.
  59. X        @        You (usually) or another human.
  60. X        )        A weapon of some sort.
  61. X        [        A suit or piece of armor.
  62. X        %        A piece of food (not necessarily healthy).
  63. X        /        A wand.
  64. X        =        A ring.
  65. X        ?        A scroll.
  66. X        !        A potion.
  67. X        (        Some other useful object (pick-axe, key, lamp...)
  68. X        $        A pile of gold.
  69. X        *        A gem or rock (possibly valuable, possibly worthless).
  70. X        +        A closed door, or a spell book containing a spell
  71. X                 you can learn.
  72. X        ^        A trap (once you detect it).
  73. X        "        An amulet, or a spider web.
  74. X        0        An iron ball.
  75. X        _        An altar, or an iron chain.
  76. X        }        A pool of water or moat or a pool of lava.
  77. X        {        A fountain.
  78. X        \        An opulent throne.
  79. X        `        A boulder or statue.
  80. X        A to Z, a to z, and several others:  Monsters.
  81. X
  82. X                 You can find out what a character represents by typing
  83. X                 '/' followed by the character, as in "/A", which will
  84. X                 tell you that 'A' is an Ape.
  85. X
  86. X
  87. Xy k u   7 8 9   Move commands:
  88. X \|/     \|/            yuhjklbn: go one step in specified direction
  89. Xh-.-l   4-.-6           YUHJKLBN: go in specified direction until you
  90. X /|\     /|\                        hit a wall or run into something
  91. Xb j n   1 2 3           g<dir>:   run in direction <dir> until something
  92. X      numberpad                     interesting is seen
  93. X                        G<dir>,   same, except a branching corridor isn't
  94. X                        ^<dir>:     considered interesting
  95. X                        m<dir>:   move without picking up objects
  96. X                If the numberpad option is set, the number keys move instead.
  97. X
  98. XCommands:
  99. X        NetHack knows the following commands:
  100. X        ?       Help menu.
  101. X        /       (followed by any symbol):  tell what this symbol represents.
  102. X                You may choose to specify a location or give a symbol argument.
  103. X        &       Tell what a command does.
  104. X        <       Go up a staircase (if you are standing on it).
  105. X        >       Go down a staircase (if you are standing on it).
  106. X        .       Rest, do nothing for one turn.
  107. X        a       Apply (use) an tool (pick-axe, key, lamp...)
  108. X        A       Remove all armor.
  109. X        ^A      Redo the previous command
  110. X        c       Close a door.
  111. X        C       Call (name) an individual monster.
  112. X        d       Drop something.  d7a:  drop seven items of object a.
  113. X        D       Drop several things.  In answer to the question
  114. X                "What kinds of things do you want to drop? [!%= au]"
  115. X                you should type zero or more object symbols possibly
  116. X                followed by 'a' and/or 'u'.
  117. X                Da - drop all objects, without asking for confirmation.
  118. X                Du - drop only unpaid objects (when in a shop).
  119. X                D%u - drop only unpaid food.
  120. X        ^D      Kick (for doors, usually).
  121. X        e       Eat food.
  122. X        E       Engrave a message on the floor.
  123. X                E- - write in the dust with your fingers.
  124. X
  125. X
  126. X
  127. X        i       Print your inventory.
  128. X        I       Print selected parts of your inventory, as in
  129. X                I* - list all gems in inventory.
  130. X                Iu - list all unpaid items.
  131. X                Ix - list all used up items that are on your shopping bill.
  132. X                I$ - count your money.
  133. X        o       Open a door.
  134. X        O       Set options.  You will be asked to enter an option line.
  135. X                If the line is empty, the current options are reported.
  136. X                Descriptions of possible options and their formats can be
  137. X                obtained by entering "?".  Options are usually set before
  138. X                the game with a NETHACKOPTIONS environment variable, not
  139. X                with the 'O' command.
  140. X        p       Pay your shopping bill.
  141. X        P       Put on an accessory (ring, amulet, etc).
  142. X        ^P      Repeat last message (subsequent ^P's repeat earlier messages).
  143. X        q       Drink (quaff) a potion.
  144. X        Q       Quit the game.
  145. X        r       Read a scroll or spell book.
  146. X        R       Remove an accessory (ring, amulet, etc).
  147. X        ^R      Redraw the screen.
  148. X        s       Search for secret doors and traps around you.
  149. X        S       Save the game.
  150. X        t       Throw an object or shoot a projectile.
  151. X        T       Take off armor.
  152. X        ^T      Teleport, if you are able.
  153. X        v       Prints the version number.
  154. X        V       Prints a longer identification of the version, including the
  155. X                history of the game.
  156. X        w       Wield weapon.  w- means wield nothing, use bare hands.
  157. X        W       Wear armor.
  158. X        x       List the spells you know (same as '+').
  159. X        X       Switch the game to explore (discovery) mode.
  160. X        z       Zap a wand.
  161. X        Z       Cast a spell.
  162. X        ^Z      Suspend the game.
  163. X        :       Look at what is here.
  164. X        ;       Look at what is somewhere else.
  165. X        ,       Pick up some things.
  166. X        @       Toggle the pickup option.
  167. X        ^       Ask for the type of a trap you found earlier.
  168. X        )       Tell what weapon you are wielding.
  169. X        [       Tell what armor you are wearing.
  170. X        =       Tell what rings you are wearing.
  171. X        "       Tell what amulet you are wearing.
  172. X        (       Tell what tools you are using.
  173. X        $       Count your gold pieces.
  174. X        +       List the spells you know (same as 'x').
  175. X        \       Show what types of objects have been discovered.
  176. X        !       Escape to a shell.
  177. X        #       Introduces one of the "extended" commands.  To get a list of
  178. X                the commands you can use with "#" type "#?".  The extended
  179. X                commands you can use depends upon what options the game was
  180. X                compiled with, along with your class and what type of monster
  181. X                you most closely resemble at a given moment.  If your keyboard
  182. X                has a meta key (which, when pressed in combination with another
  183. X                key, modifies it by setting the 'meta' (8th, or 'high') bit),
  184. X                these extended commands can be invoked by meta-ing the first
  185. X                letter of the command.
  186. X
  187. X        If the "number_pad" option is on, some additional letter commands
  188. X        are available:
  189. X
  190. X        j       Jump to another location.
  191. X        k       Kick (for doors, usually).
  192. X        l       Loot a box on the floor.
  193. X        n       Name an object or type of object.
  194. X        u       Untrap a trapped object or door.
  195. X
  196. X        You can put a number before a command to repeat it that many times,
  197. X        as in "40." or "20s.".  If you have the number_pad option set, you
  198. X        must type 'n' to prefix the count, as in "n40." or "n20s".
  199. X
  200. X        Some information is displayed on the bottom line.  You see your
  201. X        attributes, your alignment, what dungeon level you are on, how many
  202. X        hit points you have now (and will have when fully recovered), what
  203. X        your armor class is (the lower the better), your experience level,
  204. X        and the state of your stomach.  Optionally, you may or may not see
  205. X        other information such as spell points, how much gold you have, etc.
  206. X
  207. X        Have Fun, and Happy Hacking!
  208. END_OF_FILE
  209. if test 8454 -ne `wc -c <'dat/help'`; then
  210.     echo shar: \"'dat/help'\" unpacked with wrong size!
  211. fi
  212. # end of 'dat/help'
  213. fi
  214. if test -f 'include/decl.h' -a "${1}" != "-c" ; then 
  215.   echo shar: Will not clobber existing file \"'include/decl.h'\"
  216. else
  217. echo shar: Extracting \"'include/decl.h'\" \(8850 characters\)
  218. sed "s/^X//" >'include/decl.h' <<'END_OF_FILE'
  219. X/*    SCCS Id: @(#)decl.h    3.1    92/12/11    */
  220. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  221. X/* NetHack may be freely redistributed.  See license for details. */
  222. X
  223. X#ifndef DECL_H
  224. X#define DECL_H
  225. X
  226. X#define E extern
  227. X
  228. XE int NDECL((*occupation));
  229. XE int NDECL((*afternmv));
  230. X
  231. XE const char *hname;
  232. XE int hackpid;
  233. X#if defined(UNIX) || defined(VMS)
  234. XE int locknum;
  235. X#endif
  236. X#ifdef DEF_PAGER
  237. XE char *catmore;
  238. X#endif    /* DEF_PAGER */
  239. X
  240. XE char SAVEF[];
  241. X#ifdef MICRO
  242. XE char SAVEP[];
  243. X#endif
  244. X
  245. XE int NEARDATA bases[];
  246. X
  247. XE int NEARDATA multi;
  248. XE int NEARDATA warnlevel;
  249. XE int NEARDATA nroom;
  250. XE int NEARDATA nsubroom;
  251. XE int NEARDATA occtime;
  252. X
  253. XE int x_maze_max, y_maze_max;
  254. XE int otg_temp;
  255. X
  256. X#ifdef REDO
  257. XE int NEARDATA in_doagain;
  258. X#endif
  259. X
  260. XE struct dgn_topology {    /* special dungeon levels for speed */
  261. X    d_level    d_oracle_level;
  262. X    d_level    d_bigroom_level;    /* unused */
  263. X#ifdef REINCARNATION
  264. X    d_level    d_rogue_level;
  265. X#endif
  266. X    d_level    d_medusa_level;
  267. X    d_level    d_stronghold_level;
  268. X    d_level    d_valley_level;
  269. X    d_level    d_wiz1_level;
  270. X    d_level    d_wiz2_level;
  271. X    d_level    d_wiz3_level;
  272. X    d_level     d_juiblex_level;
  273. X    d_level     d_orcus_level;
  274. X    d_level    d_baalzebub_level;    /* unused */
  275. X    d_level    d_asmodeus_level;    /* unused */
  276. X    d_level    d_portal_level;        /* only in goto_level() [do.c] */
  277. X    d_level    d_sanctum_level;
  278. X    d_level    d_earth_level;
  279. X    d_level    d_water_level;
  280. X    d_level    d_fire_level;
  281. X    d_level    d_air_level;
  282. X    d_level    d_astral_level;
  283. X    xchar    d_tower_dnum;
  284. X#ifdef MULDGN
  285. X    xchar    d_mines_dnum, d_quest_dnum;
  286. X    d_level    d_qstart_level, d_qlocate_level, d_nemesis_level;
  287. X    d_level    d_knox_level;
  288. X#endif
  289. X} dungeon_topology;
  290. X/* macros for accesing the dungeon levels by their old names */
  291. X#define oracle_level        (dungeon_topology.d_oracle_level)
  292. X#define bigroom_level        (dungeon_topology.d_bigroom_level)
  293. X#ifdef REINCARNATION
  294. X#define rogue_level        (dungeon_topology.d_rogue_level)
  295. X#endif
  296. X#define medusa_level        (dungeon_topology.d_medusa_level)
  297. X#define stronghold_level    (dungeon_topology.d_stronghold_level)
  298. X#define valley_level        (dungeon_topology.d_valley_level)
  299. X#define wiz1_level        (dungeon_topology.d_wiz1_level)
  300. X#define wiz2_level        (dungeon_topology.d_wiz2_level)
  301. X#define wiz3_level        (dungeon_topology.d_wiz3_level)
  302. X#define juiblex_level        (dungeon_topology.d_juiblex_level)
  303. X#define orcus_level        (dungeon_topology.d_orcus_level)
  304. X#define baalzebub_level        (dungeon_topology.d_baalzebub_level)
  305. X#define asmodeus_level        (dungeon_topology.d_asmodeus_level)
  306. X#define portal_level        (dungeon_topology.d_portal_level)
  307. X#define sanctum_level        (dungeon_topology.d_sanctum_level)
  308. X#define earth_level        (dungeon_topology.d_earth_level)
  309. X#define water_level        (dungeon_topology.d_water_level)
  310. X#define fire_level        (dungeon_topology.d_fire_level)
  311. X#define air_level        (dungeon_topology.d_air_level)
  312. X#define astral_level        (dungeon_topology.d_astral_level)
  313. X#define tower_dnum        (dungeon_topology.d_tower_dnum)
  314. X#ifdef MULDGN
  315. X#define mines_dnum        (dungeon_topology.d_mines_dnum)
  316. X#define quest_dnum        (dungeon_topology.d_quest_dnum)
  317. X#define qstart_level        (dungeon_topology.d_qstart_level)
  318. X#define qlocate_level        (dungeon_topology.d_qlocate_level)
  319. X#define nemesis_level        (dungeon_topology.d_nemesis_level)
  320. X#define knox_level        (dungeon_topology.d_knox_level)
  321. X#endif
  322. X
  323. XE stairway NEARDATA dnstair, NEARDATA upstair; /* stairs up and down. */
  324. X#define xdnstair    (dnstair.sx)
  325. X#define ydnstair    (dnstair.sy)
  326. X#define xupstair    (upstair.sx)
  327. X#define yupstair    (upstair.sy)
  328. X
  329. XE stairway NEARDATA dnladder, NEARDATA upladder; /* ladders up and down. */
  330. X#define xdnladder    (dnladder.sx)
  331. X#define ydnladder    (dnladder.sy)
  332. X#define xupladder    (upladder.sx)
  333. X#define yupladder    (upladder.sy)
  334. X
  335. XE stairway NEARDATA sstairs;
  336. X
  337. XE dest_area NEARDATA updest, NEARDATA dndest; /* level-change dest. areas */
  338. X
  339. XE coord NEARDATA inv_pos;
  340. XE dungeon NEARDATA dungeons[];
  341. XE s_level NEARDATA *sp_levchn;
  342. X#define dunlev_reached(x)    (dungeons[(x)->dnum].dunlev_ureached)
  343. X
  344. X#ifdef MULDGN
  345. X#include "quest.h"
  346. XE struct q_score     quest_status;
  347. X#endif
  348. X
  349. XE int NEARDATA done_stopprint;
  350. XE int NEARDATA done_hup;
  351. X
  352. XE char NEARDATA pl_character[PL_CSIZ];
  353. X#ifdef TUTTI_FRUTTI
  354. XE char NEARDATA pl_fruit[PL_FSIZ];
  355. XE int NEARDATA current_fruit;
  356. XE struct fruit NEARDATA *ffruit;
  357. X#endif
  358. X
  359. XE char NEARDATA tune[6];
  360. X
  361. XE const char NEARDATA quitchars[];
  362. XE const char NEARDATA vowels[];
  363. XE const char NEARDATA ynchars[];
  364. XE const char NEARDATA ynqchars[];
  365. XE const char NEARDATA ynaqchars[];
  366. XE const char NEARDATA ynNaqchars[];
  367. XE long NEARDATA yn_number;
  368. XE int NEARDATA smeq[];
  369. XE int NEARDATA doorindex;
  370. XE char NEARDATA *save_cm;
  371. X#define KILLED_BY_AN     0
  372. X#define KILLED_BY     1
  373. X#define NO_KILLER_PREFIX 2
  374. XE int NEARDATA killer_format;
  375. XE const char NEARDATA *killer;
  376. XE const char *configfile;
  377. XE char NEARDATA plname[PL_NSIZ];
  378. XE char NEARDATA dogname[];
  379. XE char NEARDATA catname[];
  380. XE char preferred_pet;
  381. XE const char NEARDATA *occtxt;        /* defined when occupation != NULL */
  382. XE const char NEARDATA *nomovemsg;
  383. XE const char NEARDATA nul[];
  384. XE const char *traps[];
  385. XE char lock[];
  386. X
  387. XE const char NEARDATA sdir[], NEARDATA ndir[];
  388. XE const schar NEARDATA xdir[], NEARDATA ydir[], zdir[];
  389. X
  390. XE schar NEARDATA tbx, NEARDATA tby;        /* set in mthrowu.c */
  391. XE int NEARDATA dig_effort;    /* apply.c, hack.c */
  392. XE d_level NEARDATA dig_level;
  393. XE coord NEARDATA dig_pos;
  394. XE boolean NEARDATA dig_down;
  395. X
  396. XE long NEARDATA moves, NEARDATA monstermoves;
  397. XE long NEARDATA wailmsg;
  398. X
  399. XE boolean NEARDATA in_mklev;
  400. XE boolean NEARDATA stoned;
  401. XE boolean NEARDATA unweapon;
  402. XE boolean NEARDATA mrg_to_wielded;
  403. X
  404. X#ifdef KOPS
  405. XE boolean NEARDATA allow_kops;
  406. X#endif
  407. X
  408. XE const int shield_static[];
  409. X
  410. X#ifndef SPELLS_H
  411. X#include "spell.h"
  412. X#endif
  413. XE struct spell NEARDATA spl_book[];    /* sized in decl.c */
  414. X
  415. X#ifdef TEXTCOLOR
  416. X# ifndef COLOR_H
  417. X#include "color.h"
  418. X# endif
  419. XE const int zapcolors[];
  420. X#endif
  421. X
  422. XE const char def_oc_syms[MAXOCLASSES];    /* default class symbols */
  423. XE uchar oc_syms[MAXOCLASSES];        /* current class symbols */
  424. XE const char def_monsyms[MAXMCLASSES];    /* default class symbols */
  425. XE uchar monsyms[MAXMCLASSES];        /* current class symbols */
  426. X
  427. X#ifndef OBJ_H
  428. X#include "obj.h"
  429. X#endif
  430. X
  431. XE struct obj NEARDATA *invent, NEARDATA *uarm, NEARDATA *uarmc,
  432. X    NEARDATA *uarmh, NEARDATA *uarms, NEARDATA *uarmg, NEARDATA *uarmf,
  433. X#ifdef TOURIST
  434. X    NEARDATA *uarmu, /* under-wear, so to speak */
  435. X#endif
  436. X#ifdef POLYSELF
  437. X    NEARDATA *uskin,
  438. X#endif
  439. X    NEARDATA *uamul, NEARDATA *uleft, NEARDATA *uright, NEARDATA *ublindf,
  440. X    NEARDATA *uwep;
  441. X
  442. XE struct obj NEARDATA *uchain;    /* defined only when punished */
  443. XE struct obj NEARDATA *uball;
  444. XE struct obj NEARDATA *migrating_objs;
  445. XE struct obj NEARDATA *billobjs;
  446. XE struct obj NEARDATA zeroobj;        /* init'd and defined in decl.c */
  447. X
  448. X#ifndef YOU_H
  449. X#include "you.h"
  450. X#endif
  451. X
  452. XE struct you NEARDATA u;
  453. X
  454. X#ifndef ONAMES_H
  455. X#include "onames.h"
  456. X#endif
  457. X#ifndef PM_H
  458. X#include "pm.h"
  459. X#endif
  460. X
  461. XE struct permonst NEARDATA playermon, NEARDATA *uasmon;
  462. X                    /* also decl'd extern in permonst.h */
  463. X                    /* init'd in monst.c */
  464. X
  465. XE struct monst NEARDATA youmonst;    /* init'd and defined in decl.c */
  466. XE struct monst NEARDATA *mydogs, NEARDATA *migrating_mons;
  467. X
  468. XE struct c_color_names {
  469. X    char const    *const c_black, *const c_amber, *const c_golden,
  470. X        *const c_light_blue,*const c_red, *const c_green,
  471. X        *const c_silver, *const c_blue, *const c_purple,
  472. X        *const c_white;
  473. X} NEARDATA c_color_names;
  474. X#define Black        c_color_names.c_black
  475. X#define amber        c_color_names.c_amber
  476. X#define golden        c_color_names.c_golden
  477. X#define light_blue    c_color_names.c_light_blue
  478. X#define red        c_color_names.c_red
  479. X#define green        c_color_names.c_green
  480. X#define silver        c_color_names.c_silver
  481. X#define blue        c_color_names.c_blue
  482. X#define purple        c_color_names.c_purple
  483. X#define White        c_color_names.c_white
  484. X
  485. XE struct c_common_strings {
  486. X    char const    *const c_nothing_happens, *const c_thats_enough_tries,
  487. X        *const c_silly_thing_to, *const c_shudder_for_moment;
  488. X} c_common_strings;
  489. X#define nothing_happens    c_common_strings.c_nothing_happens
  490. X#define thats_enough_tries c_common_strings.c_thats_enough_tries
  491. X#define silly_thing_to       c_common_strings.c_silly_thing_to
  492. X#define shudder_for_moment c_common_strings.c_shudder_for_moment
  493. X
  494. X/* Vision */
  495. XE boolean NEARDATA vision_full_recalc;    /* TRUE if need vision recalc */
  496. XE char NEARDATA **viz_array;    /* could see/in sight row pointers */
  497. X
  498. X/* Window system stuff */
  499. XE winid NEARDATA WIN_MESSAGE, NEARDATA WIN_STATUS;
  500. XE winid NEARDATA WIN_MAP, NEARDATA WIN_INVEN;
  501. XE char toplines[];
  502. X#ifndef TERMCAP_H
  503. XE struct tc_gbl_data {    /* also declared in termcap.h */
  504. X    char *tc_AS, *tc_AE;    /* graphics start and end (tty font swapping) */
  505. X    int   tc_LI,  tc_CO;    /* lines and columns */
  506. X} tc_gbl_data;
  507. X#define AS tc_gbl_data.tc_AS
  508. X#define AE tc_gbl_data.tc_AE
  509. X#define LI tc_gbl_data.tc_LI
  510. X#define CO tc_gbl_data.tc_CO
  511. X#endif
  512. X
  513. X/* xxxexplain[] is in drawing.c */
  514. XE const char *monexplain[], *objexplain[], *oclass_names[];
  515. X
  516. XE const char NEARDATA *pl_classes;
  517. X
  518. X#undef E
  519. X
  520. X#endif /* DECL_H */
  521. END_OF_FILE
  522. if test 8850 -ne `wc -c <'include/decl.h'`; then
  523.     echo shar: \"'include/decl.h'\" unpacked with wrong size!
  524. fi
  525. # end of 'include/decl.h'
  526. fi
  527. if test -f 'src/extralev.c' -a "${1}" != "-c" ; then 
  528.   echo shar: Will not clobber existing file \"'src/extralev.c'\"
  529. else
  530. echo shar: Extracting \"'src/extralev.c'\" \(8664 characters\)
  531. sed "s/^X//" >'src/extralev.c' <<'END_OF_FILE'
  532. X/*    SCCS Id: @(#)extralev.c    3.1    92/05/27            */
  533. X/*    Copyright 1988, 1989 by Ken Arromdee                */
  534. X/* NetHack may be freely redistributed.  See license for details. */
  535. X
  536. X#include "hack.h"
  537. X
  538. X#ifdef REINCARNATION
  539. X
  540. Xstruct rogueroom {
  541. X    xchar rlx, rly;
  542. X    xchar dx, dy;
  543. X    boolean real;
  544. X    uchar doortable;
  545. X    int nroom; /* Only meaningful for "real" rooms */
  546. X};
  547. X#define UP 1
  548. X#define DOWN 2
  549. X#define LEFT 4
  550. X#define RIGHT 8
  551. X
  552. Xstatic struct rogueroom NEARDATA r[3][3];
  553. Xstatic void FDECL(roguejoin,(int,int,int,int,int));
  554. Xstatic void FDECL(roguecorr,(int,int,int));
  555. Xstatic void FDECL(miniwalk,(int,int));
  556. X
  557. Xstatic
  558. Xvoid
  559. Xroguejoin(x1,y1,x2,y2, horiz)
  560. Xint x1,y1,x2,y2;
  561. Xint horiz;
  562. X{
  563. X    register int x,y,middle;
  564. X#ifndef MAX
  565. X#define MAX(a,b) (((a) > (b)) ? (a) : (b))
  566. X#endif
  567. X#ifndef MIN
  568. X#define MIN(a,b) (((a) < (b)) ? (a) : (b))
  569. X#endif
  570. X    if (horiz) {
  571. X        middle = x1 + rn2(x2-x1+1);
  572. X        for(x=MIN(x1,middle); x<=MAX(x1,middle); x++)
  573. X            corr(x, y1);
  574. X        for(y=MIN(y1,y2); y<=MAX(y1,y2); y++)
  575. X            corr(middle,y);
  576. X        for(x=MIN(middle,x2); x<=MAX(middle,x2); x++)
  577. X            corr(x, y2);
  578. X    } else {
  579. X        middle = y1 + rn2(y2-y1+1);
  580. X        for(y=MIN(y1,middle); y<=MAX(y1,middle); y++)
  581. X            corr(x1, y);
  582. X        for(x=MIN(x1,x2); x<=MAX(x1,x2); x++)
  583. X            corr(x, middle);
  584. X        for(y=MIN(middle,y2); y<=MAX(middle,y2); y++)
  585. X            corr(x2,y);
  586. X    }
  587. X}
  588. X
  589. Xstatic
  590. Xvoid
  591. Xroguecorr(x, y, dir)
  592. Xint x,y,dir;
  593. X{
  594. X    register int fromx, fromy, tox, toy;
  595. X
  596. X    if (dir==DOWN) {
  597. X        r[x][y].doortable &= ~DOWN;
  598. X        if (!r[x][y].real) {
  599. X            fromx = r[x][y].rlx; fromy = r[x][y].rly;
  600. X            fromx += 1 + 26*x; fromy += 7*y;
  601. X        } else {
  602. X            fromx = r[x][y].rlx + rn2(r[x][y].dx);
  603. X            fromy = r[x][y].rly + r[x][y].dy;
  604. X            fromx += 1 + 26*x; fromy += 7*y;
  605. X            if (!IS_WALL(levl[fromx][fromy].typ))
  606. X                impossible("down: no wall at %d,%d?",fromx,
  607. X                                    fromy);
  608. X            dodoor(fromx, fromy, &rooms[r[x][y].nroom]);
  609. X            levl[fromx][fromy].doormask = D_NODOOR;
  610. X            fromy++;
  611. X        }
  612. X        if(y >= 2) {
  613. X            impossible("down door from %d,%d going nowhere?",x,y);
  614. X            return;
  615. X        }
  616. X        y++;
  617. X        r[x][y].doortable &= ~UP;
  618. X        if (!r[x][y].real) {
  619. X            tox = r[x][y].rlx; toy = r[x][y].rly;
  620. X            tox += 1 + 26*x; toy += 7*y;
  621. X        } else {
  622. X            tox = r[x][y].rlx + rn2(r[x][y].dx);
  623. X            toy = r[x][y].rly - 1;
  624. X            tox += 1 + 26*x; toy += 7*y;
  625. X            if (!IS_WALL(levl[tox][toy].typ))
  626. X                impossible("up: no wall at %d,%d?",tox,toy);
  627. X            dodoor(tox, toy, &rooms[r[x][y].nroom]);
  628. X            levl[tox][toy].doormask = D_NODOOR;
  629. X            toy--;
  630. X        }
  631. X        roguejoin(fromx, fromy, tox, toy, FALSE);
  632. X        return;
  633. X    } else if (dir == RIGHT) {
  634. X        r[x][y].doortable &= ~RIGHT;
  635. X        if (!r[x][y].real) {
  636. X            fromx = r[x][y].rlx; fromy = r[x][y].rly;
  637. X            fromx += 1 + 26*x; fromy += 7*y;
  638. X        } else {
  639. X            fromx = r[x][y].rlx + r[x][y].dx;
  640. X            fromy = r[x][y].rly + rn2(r[x][y].dy);
  641. X            fromx += 1 + 26*x; fromy += 7*y;
  642. X            if (!IS_WALL(levl[fromx][fromy].typ))
  643. X                impossible("down: no wall at %d,%d?",fromx,
  644. X                                    fromy);
  645. X            dodoor(fromx, fromy, &rooms[r[x][y].nroom]);
  646. X            levl[fromx][fromy].doormask = D_NODOOR;
  647. X            fromx++;
  648. X        }
  649. X        if(x >= 2) {
  650. X            impossible("right door from %d,%d going nowhere?",x,y);
  651. X            return;
  652. X        }
  653. X        x++;
  654. X        r[x][y].doortable &= ~LEFT;
  655. X        if (!r[x][y].real) {
  656. X            tox = r[x][y].rlx; toy = r[x][y].rly;
  657. X            tox += 1 + 26*x; toy += 7*y;
  658. X        } else {
  659. X            tox = r[x][y].rlx - 1;
  660. X            toy = r[x][y].rly + rn2(r[x][y].dy);
  661. X            tox += 1 + 26*x; toy += 7*y;
  662. X            if (!IS_WALL(levl[tox][toy].typ))
  663. X                impossible("left: no wall at %d,%d?",tox,toy);
  664. X            dodoor(tox, toy, &rooms[r[x][y].nroom]);
  665. X            levl[tox][toy].doormask = D_NODOOR;
  666. X            tox--;
  667. X        }
  668. X        roguejoin(fromx, fromy, tox, toy, TRUE);
  669. X        return;
  670. X    } else impossible("corridor in direction %d?",dir);
  671. X}
  672. X            
  673. X/* Modified walkfrom() from mkmaze.c */
  674. Xstatic
  675. Xvoid
  676. Xminiwalk(x, y)
  677. Xint x,y;
  678. X{
  679. X    register int q, dir;
  680. X    int dirs[4];
  681. X
  682. X    while(1) {
  683. X        q = 0;
  684. X#define doorhere (r[x][y].doortable)
  685. X        if (x>0 && (!(doorhere & LEFT)) &&
  686. X                    (!r[x-1][y].doortable || !rn2(10)))
  687. X            dirs[q++] = 0;
  688. X        if (x<2 && (!(doorhere & RIGHT)) &&
  689. X                    (!r[x+1][y].doortable || !rn2(10)))
  690. X            dirs[q++] = 1;
  691. X        if (y>0 && (!(doorhere & UP)) &&
  692. X                    (!r[x][y-1].doortable || !rn2(10)))
  693. X            dirs[q++] = 2;
  694. X        if (y<2 && (!(doorhere & DOWN)) &&
  695. X                    (!r[x][y+1].doortable || !rn2(10)))
  696. X            dirs[q++] = 3;
  697. X    /* Rogue levels aren't just 3 by 3 mazes; they have some extra
  698. X     * connections, thus that 1/10 chance
  699. X     */
  700. X        if (!q) return;
  701. X        dir = dirs[rn2(q)];
  702. X        switch(dir) { /* Move in direction */
  703. X            case 0: doorhere |= LEFT;
  704. X                x--;
  705. X                doorhere |= RIGHT;
  706. X                break;
  707. X            case 1: doorhere |= RIGHT;
  708. X                x++;
  709. X                doorhere |= LEFT;
  710. X                break;
  711. X            case 2: doorhere |= UP;
  712. X                y--;
  713. X                doorhere |= DOWN;
  714. X                break;
  715. X            case 3: doorhere |= DOWN;
  716. X                y++;
  717. X                doorhere |= UP;
  718. X                break;
  719. X        }
  720. X        miniwalk(x,y);
  721. X    }
  722. X}
  723. X
  724. Xvoid
  725. Xmakeroguerooms() {
  726. X    register int x,y;
  727. X    /* Rogue levels are structured 3 by 3, with each section containing
  728. X     * a room or an intersection.  The minimum width is 2 each way.
  729. X     * One difference between these and "real" Rogue levels: real Rogue
  730. X     * uses 24 rows and NetHack only 23.  So we cheat a bit by making the
  731. X     * second row of rooms not as deep.
  732. X     *
  733. X     * Each normal space has 6/7 rows and 25 columns in which a room may
  734. X     * actually be placed.  Walls go from rows 0-5/6 and columns 0-24.
  735. X     * Not counting walls, the room may go in
  736. X     * rows 1-5 and columns 1-23 (numbering starting at 0).  A room
  737. X     * coordinate of this type may be converted to a level coordinate
  738. X     * by adding 1+28*x to the column, and 7*y to the row.  (The 1
  739. X     * is because column 0 isn't used [we only use 1-78]).
  740. X     * Room height may be 2-4 (2-5 on last row), length 2-23 (not
  741. X     * counting walls)
  742. X     */
  743. X#define here r[x][y]
  744. X
  745. X    nroom = 0;
  746. X    for(y=0; y<3; y++) for(x=0; x<3; x++) {
  747. X        /* Note: we want to insure at least 1 room.  So, if the
  748. X         * first 8 are all dummies, force the last to be a room.
  749. X         */
  750. X        if (!rn2(5) && (nroom || (x<2 && y<2))) {
  751. X            /* Arbitrary: dummy rooms may only go where real
  752. X             * ones do.
  753. X             */
  754. X            here.real = FALSE;
  755. X            here.rlx = rn1(22, 2);
  756. X            here.rly = rn1((y==2)?4:3, 2);
  757. X        } else {
  758. X            here.real = TRUE;
  759. X            here.dx = rn1(22, 2); /* 2-23 long, plus walls */
  760. X            here.dy = rn1((y==2)?4:3, 2); /* 2-5 high, plus walls */
  761. X
  762. X            /* boundaries of room floor */
  763. X            here.rlx = rnd(23 - here.dx + 1);
  764. X            here.rly = rnd(((y==2) ? 5 : 4)- here.dy + 1);
  765. X            nroom++;
  766. X        }
  767. X        here.doortable = 0;
  768. X    }
  769. X    miniwalk(rn2(3), rn2(3));
  770. X    nroom = 0;
  771. X    for(y=0; y<3; y++) for(x=0; x<3; x++) {
  772. X        if (here.real) { /* Make a room */
  773. X            int lowx, lowy, hix, hiy;
  774. X
  775. X            r[x][y].nroom = nroom;
  776. X            smeq[nroom] = nroom;
  777. X
  778. X            lowx = 1 + 26*x + here.rlx;
  779. X            lowy = 7*y + here.rly;
  780. X            hix = 1 + 26*x + here.rlx + here.dx - 1;
  781. X            hiy = 7*y + here.rly + here.dy - 1;
  782. X            /* Strictly speaking, it should be lit only if above
  783. X             * level 10, but since Rogue rooms are only
  784. X             * encountered below level 10, use !rn2(7).
  785. X             */
  786. X
  787. X            add_room(lowx, lowy, hix, hiy, !rn2(7), OROOM, FALSE);
  788. X        }
  789. X    }
  790. X
  791. X    /* Now, add connecting corridors. */
  792. X    for(y=0; y<3; y++) for(x=0; x<3; x++) {
  793. X        if (here.doortable & DOWN)
  794. X            roguecorr(x, y, DOWN);
  795. X        if (here.doortable & RIGHT)
  796. X            roguecorr(x, y, RIGHT);
  797. X        if (here.doortable & LEFT)
  798. X            impossible ("left end of %d, %d never connected?",x,y);
  799. X        if (here.doortable & UP)
  800. X            impossible ("up end of %d, %d never connected?",x,y);
  801. X    }
  802. X}
  803. X
  804. Xvoid
  805. Xcorr(x,y)
  806. Xint x, y;
  807. X{
  808. X    if (rn2(50)) {
  809. X        levl[x][y].typ = CORR;
  810. X    } else {
  811. X        levl[x][y].typ = SCORR;
  812. X    }
  813. X}
  814. X
  815. Xvoid
  816. Xmakerogueghost()
  817. X{
  818. X    register struct monst *ghost;
  819. X    struct obj *ghostobj;
  820. X    struct mkroom *croom;
  821. X    int x,y;
  822. X
  823. X    if (!nroom) return; /* Should never happen */
  824. X    croom = &rooms[rn2(nroom)];
  825. X    x = somex(croom); y = somey(croom);
  826. X    if (!(ghost = makemon(&mons[PM_GHOST], x, y)))
  827. X        return;
  828. X    ghost->msleep = 1;
  829. X    Strcpy((char *)ghost->mextra, roguename());
  830. X
  831. X    if (rn2(4)) {
  832. X        ghostobj = mksobj_at(FOOD_RATION,x,y,FALSE);
  833. X        ghostobj->quan = (long) rnd(7);
  834. X        ghostobj->owt = weight(ghostobj);
  835. X    }
  836. X    if (rn2(2)) {
  837. X        ghostobj = mksobj_at(MACE,x,y,FALSE);
  838. X        ghostobj->spe = rnd(3);
  839. X        if (rn2(4)) curse(ghostobj);
  840. X    } else {
  841. X        ghostobj = mksobj_at(TWO_HANDED_SWORD,x,y,FALSE);
  842. X        ghostobj->spe = rnd(5) - 2;
  843. X        if (rn2(4)) curse(ghostobj);
  844. X    }
  845. X    ghostobj = mksobj_at(BOW,x,y,FALSE);
  846. X    ghostobj->spe = 1;
  847. X    if (rn2(4)) curse(ghostobj);
  848. X
  849. X    ghostobj = mksobj_at(ARROW,x,y,FALSE);
  850. X    ghostobj->spe = 0;
  851. X    ghostobj->quan = (long) rn1(10,25);
  852. X    ghostobj->owt = weight(ghostobj);
  853. X    if (rn2(4)) curse(ghostobj);
  854. X
  855. X    if (rn2(2)) {
  856. X        ghostobj = mksobj_at(RING_MAIL,x,y,FALSE);
  857. X        ghostobj->spe = rn2(3);
  858. X        if (!rn2(3)) ghostobj->oerodeproof = TRUE;
  859. X        if (rn2(4)) curse(ghostobj);
  860. X    } else {
  861. X        ghostobj = mksobj_at(PLATE_MAIL,x,y,FALSE);
  862. X        ghostobj->spe = rnd(5) - 2;
  863. X        if (!rn2(3)) ghostobj->oerodeproof = TRUE;
  864. X        if (rn2(4)) curse(ghostobj);
  865. X    }
  866. X    if (rn2(2)) {
  867. X        ghostobj = mksobj_at(FAKE_AMULET_OF_YENDOR,x,y,TRUE);
  868. X        ghostobj->known = TRUE;
  869. X    }
  870. X}
  871. X#endif /* REINCARNATION /**/
  872. X
  873. X/*extralev.c*/
  874. END_OF_FILE
  875. if test 8664 -ne `wc -c <'src/extralev.c'`; then
  876.     echo shar: \"'src/extralev.c'\" unpacked with wrong size!
  877. fi
  878. # end of 'src/extralev.c'
  879. fi
  880. if test -f 'src/mplayer.c' -a "${1}" != "-c" ; then 
  881.   echo shar: Will not clobber existing file \"'src/mplayer.c'\"
  882. else
  883. echo shar: Extracting \"'src/mplayer.c'\" \(8151 characters\)
  884. sed "s/^X//" >'src/mplayer.c' <<'END_OF_FILE'
  885. X/*    SCCS Id: @(#)mplayer.c    3.1    92/10/28    */
  886. X/*    Copyright (c) Izchak Miller, 1992.              */
  887. X/* NetHack may be freely redistributed.  See license for details. */
  888. X
  889. X#include "hack.h"
  890. X
  891. Xstatic const char *NDECL(dev_name);
  892. Xstatic void FDECL(get_mplname, (struct monst *, char *));
  893. Xstatic void FDECL(mk_mplayer_armor, (struct monst *, int, int));
  894. X
  895. X/* These are the names of those who
  896. X * contributed to the development of NetHack 3.1.
  897. X *
  898. X * Keep in alphabetical order within teams.
  899. X * Same first name is entered once within each team.
  900. X */
  901. Xstatic const char *developers[] = {
  902. X    /* devteam */
  903. X    "Dave", "Dean", "Eric", "Izchak", "Janet", "Jessie",
  904. X    "Ken", "Kevin", "Matt", "Mike", "Pat", "Steve", "Timo",
  905. X    /* PC team */
  906. X    "Bill", "Carl", "John", "Kevin", "Mike", "Norm", "Paul",
  907. X    "Stephen", "Steve",
  908. X    /* Amiga team */
  909. X    "Greg", "Gregg", "Keni", "Mike", "Olaf", "Richard",
  910. X    /* Mac team */
  911. X    "David", "Johnny", "Jon", "Jonathan", "Michael", "Rob",
  912. X    "Tim", "Wang",
  913. X    /* OS/2 team */
  914. X    "Timo",
  915. X    /* Atari team */
  916. X    "Eric",
  917. X    /* VMS team */
  918. X    "Joshua", "Pat",
  919. X    ""};
  920. X
  921. X
  922. X/* return a randomly chosen developer name */
  923. Xstatic const char *
  924. Xdev_name() 
  925. X{
  926. X    register int i, m = 0, n = SIZE(developers);
  927. X    register struct monst *mtmp;
  928. X    register boolean match;
  929. X
  930. X    do {
  931. X        match = FALSE;
  932. X        i = rn2(n);
  933. X        for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { 
  934. X        if(!is_mplayer(mtmp->data)) continue;
  935. X        if(!strncmp(developers[i], NAME(mtmp),
  936. X                           strlen(developers[i]))) {
  937. X            match = TRUE;
  938. X            break;
  939. X            }
  940. X        }
  941. X        m++;
  942. X    } while (match && m < 100); /* m for insurance */
  943. X
  944. X    if (match) return NULL;
  945. X    return(developers[i]);
  946. X}
  947. X
  948. Xstatic void
  949. Xget_mplname(mtmp, nam)
  950. Xregister struct monst *mtmp;
  951. Xchar *nam;
  952. X{
  953. X    boolean fmlkind = is_female(mtmp->data);
  954. X    const char *devnam;
  955. X
  956. X    devnam = dev_name();
  957. X    if (!devnam)
  958. X        Strcpy(nam, fmlkind ? "Eve" : "Adam");
  959. X    else if (fmlkind && !!strcmp(devnam, "Janet"))
  960. X        Strcpy(nam, rn2(2) ? "Maud" : "Eve");
  961. X    else Strcpy(nam, devnam);
  962. X
  963. X    if (fmlkind || !strcmp(nam, "Janet"))
  964. X        mtmp->female = 1;
  965. X    else
  966. X        mtmp->female = 0;
  967. X    Strcat(nam, " the ");
  968. X    Strcat(nam, rank_of((unsigned)rn1(12, 20), 
  969. X               highc(mtmp->data->mname[0]), (boolean)mtmp->female));
  970. X}
  971. X
  972. Xstatic void
  973. Xmk_mplayer_armor(mon, range1, range2)
  974. Xstruct monst *mon;
  975. Xint range1, range2;
  976. X{
  977. X    struct obj *obj;
  978. X
  979. X    obj = mksobj(rnd_class(range1, range2), FALSE, FALSE);
  980. X    if (!rn2(3)) obj->oerodeproof = 1;
  981. X    if (!rn2(3)) curse(obj);
  982. X    if (!rn2(3)) bless(obj);
  983. X    /* Most players who get to the endgame who have cursed equipment
  984. X     * have it because the wizard or other monsters cursed it, so its
  985. X     * chances of having plusses is the same as usual....
  986. X     */
  987. X    obj->spe = rn2(10) ? (rn2(3) ? rn2(5) : rn1(4,4)) : -rnd(3);
  988. X    mpickobj(mon, obj);
  989. X}
  990. X
  991. Xstruct monst *
  992. Xmk_mplayer(ptr, x, y, special)
  993. Xregister struct permonst *ptr;
  994. Xxchar x, y;
  995. Xregister boolean special;
  996. X{
  997. X    register struct monst *mtmp;
  998. X    char nam[PL_NSIZ];
  999. X
  1000. X    if(!is_mplayer(ptr)) 
  1001. X        return((struct monst *)0);
  1002. X
  1003. X    if(MON_AT(x, y))
  1004. X        rloc(m_at(x, y)); /* insurance */
  1005. X
  1006. X    if(!In_endgame(&u.uz)) special = FALSE;
  1007. X
  1008. X    if ((mtmp = makemon(ptr, x, y)) != 0) {
  1009. X        int weapon, quan;
  1010. X        struct obj *otmp;
  1011. X
  1012. X        mtmp->m_lev = (special ? rn1(8,12) : rnd(16));
  1013. X        mtmp->mhp = mtmp->mhpmax = (special ?
  1014. X                          (d((int)mtmp->m_lev,10) + 30 + rnd(30)) :
  1015. X                          (d((int)mtmp->m_lev,10) + 30));
  1016. X        if(special) {
  1017. X            get_mplname(mtmp, nam);
  1018. X            mtmp = christen_monst(mtmp, nam);
  1019. X        }
  1020. X        mtmp->mpeaceful = 0;
  1021. X        set_malign(mtmp); /* peaceful may have changed again */
  1022. X        if(special && In_endgame(&u.uz))
  1023. X        /* that's why they are "stuck" in the endgame :-) */
  1024. X        (void)mongets(mtmp, FAKE_AMULET_OF_YENDOR);
  1025. X        switch(monsndx(ptr)) {
  1026. X        case PM_ARCHEOLOGIST:
  1027. X            weapon = BULLWHIP;
  1028. X            break;
  1029. X        case PM_BARBARIAN:
  1030. X            weapon = rn2(2) ? TWO_HANDED_SWORD : BATTLE_AXE;
  1031. X            break;
  1032. X        case PM_CAVEMAN:
  1033. X        case PM_CAVEWOMAN:
  1034. X            weapon = CLUB;
  1035. X            break;
  1036. X        case PM_ELF:
  1037. X            weapon = ELVEN_SHORT_SWORD;
  1038. X            break;
  1039. X        case PM_HEALER:
  1040. X            weapon = SCALPEL;
  1041. X            break;
  1042. X        case PM_KNIGHT:
  1043. X            weapon = LONG_SWORD;
  1044. X            break;
  1045. X        case PM_PRIEST:
  1046. X        case PM_PRIESTESS:
  1047. X            weapon = MACE;
  1048. X            break;
  1049. X        case PM_ROGUE:
  1050. X            weapon = SHORT_SWORD;
  1051. X            break;
  1052. X        case PM_SAMURAI:
  1053. X            weapon = KATANA;
  1054. X            break;
  1055. X#ifdef TOURIST
  1056. X        case PM_TOURIST:
  1057. X            weapon = 0;
  1058. X            break;
  1059. X#endif
  1060. X        case PM_VALKYRIE:
  1061. X            weapon = LONG_SWORD;
  1062. X            break;
  1063. X        case PM_WIZARD:
  1064. X            weapon = ATHAME;
  1065. X            break;
  1066. X        default: impossible("bad mplayer monster");
  1067. X            weapon = 0;
  1068. X            break;
  1069. X        }
  1070. X        if (rn2(2) && weapon)
  1071. X        otmp = mksobj(weapon, TRUE, FALSE);
  1072. X        else
  1073. X        otmp = mksobj(rn2(2) ? LONG_SWORD : 
  1074. X                  rnd_class(SPEAR, BULLWHIP), TRUE, FALSE);
  1075. X        otmp->spe = (special ? rn1(5,4) : rn2(4));
  1076. X        if (!rn2(3)) otmp->oerodeproof = 0;
  1077. X        if(special) {
  1078. X            /* probably the player got most artifacts anyway. */
  1079. X            if(In_endgame(&u.uz) && rn2(2)) 
  1080. X                  otmp = mk_artifact(otmp, A_NONE);
  1081. X            mpickobj(mtmp, otmp);
  1082. X            if (!rn2(10))
  1083. X            (void) mongets(mtmp, rn2(3) ? LUCKSTONE : LOADSTONE);
  1084. X            if (rn2(8))
  1085. X            mk_mplayer_armor(mtmp, ELVEN_LEATHER_HELM, HELM_OF_TELEPATHY);
  1086. X            if (!rn2(3))
  1087. X            mk_mplayer_armor(mtmp, GRAY_DRAGON_SCALE_MAIL,
  1088. X            YELLOW_DRAGON_SCALE_MAIL);
  1089. X            else if (rn2(15))
  1090. X            mk_mplayer_armor(mtmp, PLATE_MAIL, CHAIN_MAIL);
  1091. X            if (rn2(8))
  1092. X            mk_mplayer_armor(mtmp, ELVEN_SHIELD, 
  1093. X                               SHIELD_OF_REFLECTION);
  1094. X            if (rn2(8))
  1095. X            mk_mplayer_armor(mtmp, LEATHER_GLOVES, 
  1096. X                               GAUNTLETS_OF_DEXTERITY);
  1097. X            if (rn2(8))
  1098. X            mk_mplayer_armor(mtmp, LOW_BOOTS, LEVITATION_BOOTS);
  1099. X#ifdef MUSE
  1100. X            /* Not clear what to do without MUSE. */
  1101. X            m_dowear(mtmp, TRUE);
  1102. X#endif
  1103. X            quan = rn2(3) ? rn2(3) : rn2(16);
  1104. X            while(quan--)
  1105. X            (void)mongets(mtmp, rnd_class(DILITHIUM_CRYSTAL, JADE));
  1106. X            /* To get the gold "right" would mean a player can double his */
  1107. X            /* gold supply by killing one mplayer.  Not good. */
  1108. X            mtmp->mgold = rn2(1000);
  1109. X            quan = rn2(10);
  1110. X            while(quan--)
  1111. X            mpickobj(mtmp, mkobj(RANDOM_CLASS, FALSE));
  1112. X        }
  1113. X#ifdef MUSE
  1114. X        quan = rnd(3);
  1115. X        while(quan--)
  1116. X        (void)mongets(mtmp, rnd_offensive_item(mtmp));
  1117. X        quan = rnd(3);
  1118. X        while(quan--)
  1119. X        (void)mongets(mtmp, rnd_defensive_item(mtmp));
  1120. X        quan = rnd(3);
  1121. X        while(quan--)
  1122. X        (void)mongets(mtmp, rnd_misc_item(mtmp));
  1123. X#endif
  1124. X    }
  1125. X
  1126. X    return(mtmp);
  1127. X}
  1128. X
  1129. X/* create the indicated number (num) of monster-players,
  1130. X * randomly chosen, and in randomly chosen (free) locations
  1131. X * on the level.  If "special", the size of num should not
  1132. X * be bigger than the number of _non-repeated_ names in the
  1133. X * developers array, otherwise a bunch of Adams and Eves will
  1134. X * fill up the overflow.
  1135. X */
  1136. Xvoid
  1137. Xcreate_mplayers(num, special)
  1138. Xregister int num;
  1139. Xboolean special;
  1140. X{
  1141. X    register int pm, x, y;
  1142. X
  1143. X    while(num) {
  1144. X        int tryct = 0;
  1145. X
  1146. X        /* roll for character class */
  1147. X        pm = PM_ARCHEOLOGIST + rn2(PM_WIZARD - PM_ARCHEOLOGIST + 1);
  1148. X
  1149. X        /* roll for an available location */
  1150. X        do {
  1151. X            x = rn1(COLNO-4, 2);
  1152. X            y = rnd(ROWNO-2);
  1153. X        } while(!goodpos(x, y, (struct monst *)0, &mons[pm]) ||
  1154. X             tryct++ >= 50);
  1155. X
  1156. X        /* if pos not found in 50 tries, don't bother to continue */
  1157. X        if(tryct > 50) return;
  1158. X
  1159. X        (void) mk_mplayer(&mons[pm], (xchar)x, (xchar)y, special);
  1160. X        num--;
  1161. X    }
  1162. X}
  1163. X
  1164. Xvoid
  1165. Xmplayer_talk(mtmp)
  1166. Xregister struct monst *mtmp;
  1167. X{
  1168. X    char pbuf[BUFSZ];
  1169. X
  1170. X    if(mtmp->mpeaceful) return; /* will drop to humanoid talk */
  1171. X
  1172. X    Strcpy(pbuf, "Talk? -- ");
  1173. X    if(pl_character[0] == highc(*mtmp->data->mname)) { /* same kind */
  1174. X         switch(rn2(4)) {
  1175. X           case 0: Strcat(pbuf, "I can't win, and neither will you!");
  1176. X               break;
  1177. X           case 1: Strcat(pbuf, "You don't deserve to win!");
  1178. X               break;
  1179. X           case 3: Strcat(pbuf, "Mine should be the honor, not yours!");
  1180. X               break;
  1181. X         }
  1182. X    } else {
  1183. X         switch(rn2(4)) {
  1184. X           case 0: Strcat(pbuf, "The low-life wants to talk, eh?");
  1185. X               break;
  1186. X           case 1: Strcat(pbuf, "Fight, scum!");
  1187. X               break;
  1188. X           case 3: Strcat(pbuf, "Here is what I have to say!");
  1189. X               break;
  1190. X         }
  1191. X    }
  1192. X    pline(pbuf);
  1193. X}
  1194. X
  1195. X/*mplayer.c*/
  1196. END_OF_FILE
  1197. if test 8151 -ne `wc -c <'src/mplayer.c'`; then
  1198.     echo shar: \"'src/mplayer.c'\" unpacked with wrong size!
  1199. fi
  1200. # end of 'src/mplayer.c'
  1201. fi
  1202. if test -f 'src/wield.c' -a "${1}" != "-c" ; then 
  1203.   echo shar: Will not clobber existing file \"'src/wield.c'\"
  1204. else
  1205. echo shar: Extracting \"'src/wield.c'\" \(7935 characters\)
  1206. sed "s/^X//" >'src/wield.c' <<'END_OF_FILE'
  1207. X/*    SCCS Id: @(#)wield.c    3.1    92/12/10    */
  1208. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  1209. X/* NetHack may be freely redistributed.  See license for details. */
  1210. X
  1211. X#include    "hack.h"
  1212. X
  1213. X/* elven weapons vibrate warningly when enchanted beyond a limit */
  1214. X#define is_elven_weapon(optr)    ((optr)->otyp == ELVEN_ARROW\
  1215. X                || (optr)->otyp == ELVEN_SPEAR\
  1216. X                || (optr)->otyp == ELVEN_DAGGER\
  1217. X                || (optr)->otyp == ELVEN_SHORT_SWORD\
  1218. X                || (optr)->otyp == ELVEN_BROADSWORD\
  1219. X                || (optr)->otyp == ELVEN_BOW)
  1220. X
  1221. X/* Note: setuwep() with a null obj, and uwepgone(), are NOT the same!  Sometimes
  1222. X * unwielding a weapon can kill you, and lifesaving will then put it back into
  1223. X * your hand.  If lifesaving is permitted to do this, use
  1224. X * setwuep((struct obj *)0); otherwise use uwepgone().
  1225. X */
  1226. Xvoid
  1227. Xsetuwep(obj)
  1228. Xregister struct obj *obj;
  1229. X{
  1230. X    setworn(obj, W_WEP);
  1231. X    /* Note: Explicitly wielding a pick-axe will not give a "bashing"
  1232. X     * message.  Wielding one via 'a'pplying it will.
  1233. X     */
  1234. X    if (obj)
  1235. X        unweapon = ((obj->otyp >= BOW || obj->otyp <= BOOMERANG) &&
  1236. X            obj->otyp != PICK_AXE && obj->otyp != UNICORN_HORN);
  1237. X    else
  1238. X        unweapon = TRUE;    /* for "bare hands" message */
  1239. X}
  1240. X
  1241. Xvoid
  1242. Xuwepgone()
  1243. X{
  1244. X    if (uwep) {
  1245. X        setnotworn(uwep);
  1246. X        unweapon = TRUE;
  1247. X    }
  1248. X}
  1249. X
  1250. Xstatic const char NEARDATA wield_objs[] =
  1251. X    { ALL_CLASSES, ALLOW_NONE, WEAPON_CLASS, TOOL_CLASS, 0 };
  1252. X
  1253. Xint
  1254. Xdowield()
  1255. X{
  1256. X    register struct obj *wep;
  1257. X    register int res = 0;
  1258. X
  1259. X    multi = 0;
  1260. X#ifdef POLYSELF
  1261. X    if (cantwield(uasmon)) {
  1262. X        pline("Don't be ridiculous!");
  1263. X        return(0);
  1264. X    }
  1265. X#endif
  1266. X    if (!(wep = getobj(wield_objs, "wield"))) /* nothing */;
  1267. X    else if (uwep == wep)
  1268. X        You("are already wielding that!");
  1269. X    else if (welded(uwep))
  1270. X        weldmsg(uwep, TRUE);
  1271. X    else if (wep == &zeroobj) {
  1272. X        if (uwep == 0)
  1273. X        You("are already empty %s.", body_part(HANDED));
  1274. X        else  {
  1275. X          You("are empty %s.", body_part(HANDED));
  1276. X          setuwep((struct obj *) 0);
  1277. X          res++;
  1278. X        }
  1279. X    } else if (!uarmg &&
  1280. X#ifdef POLYSELF
  1281. X           !resists_ston(uasmon) &&
  1282. X#endif
  1283. X           (wep->otyp == CORPSE && wep->corpsenm == PM_COCKATRICE)) {
  1284. X        /* Prevent wielding cockatrice when not wearing gloves --KAA */
  1285. X        You("wield the cockatrice corpse in your bare %s.",
  1286. X            makeplural(body_part(HAND)));
  1287. X# ifdef POLYSELF
  1288. X        if (!(poly_when_stoned(uasmon) && polymon(PM_STONE_GOLEM)))
  1289. X# endif
  1290. X        {
  1291. X        You("turn to stone...");
  1292. X        killer_format = KILLED_BY;
  1293. X        killer="touching a cockatrice corpse";
  1294. X        done(STONING);
  1295. X        }
  1296. X    } else if (uarms && bimanual(wep))
  1297. X        You("cannot wield a two-handed %s while wearing a shield.",
  1298. X        is_sword(wep) ? "sword" :
  1299. X            wep->otyp == BATTLE_AXE ? "axe" : "weapon");
  1300. X    else if (wep->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL))
  1301. X        You("cannot wield that!");
  1302. X    else if (!wep->oartifact || touch_artifact(wep,&youmonst)) {
  1303. X        res++;
  1304. X        if (wep->cursed &&
  1305. X            (wep->oclass == WEAPON_CLASS ||
  1306. X             wep->otyp == HEAVY_IRON_BALL || wep->otyp == PICK_AXE ||
  1307. X             wep->otyp == UNICORN_HORN || wep->otyp == TIN_OPENER)) {
  1308. X            const char *tmp = xname(wep), *thestr = "The ";
  1309. X            if (strncmp(tmp, thestr, 4) && !strncmp(The(tmp),thestr,4))
  1310. X            tmp = thestr;
  1311. X            else tmp = "";
  1312. X            pline("%s%s %s to your %s!",
  1313. X            tmp, aobjnam(wep, "weld"),
  1314. X            (wep->quan == 1L) ? "itself" : "themselves", /* a3 */
  1315. X            body_part(HAND));
  1316. X            wep->bknown = TRUE;
  1317. X        } else {
  1318. X            /* The message must be printed before setuwep (since
  1319. X             * you might die and be revived from changing weapons),
  1320. X             * and the message must be before the death message and
  1321. X             * Lifesaved rewielding.  Yet we want the message to
  1322. X             * say "weapon in hand", thus this kludge.
  1323. X             */
  1324. X            long dummy = wep->owornmask;
  1325. X            wep->owornmask |= W_WEP;
  1326. X            prinv(NULL, wep, 0L);
  1327. X            wep->owornmask = dummy;
  1328. X        }
  1329. X        setuwep(wep);
  1330. X    }
  1331. X    return(res);
  1332. X}
  1333. X
  1334. Xvoid
  1335. Xerode_weapon(acid_dmg)
  1336. Xboolean acid_dmg;
  1337. X/* Rust weapon, or corrode it if acid damage is called for */
  1338. X{
  1339. X    if(!uwep || uwep->oclass != WEAPON_CLASS) return;    /* %% */
  1340. X    if (uwep->greased) {
  1341. X        grease_protect(uwep,NULL,FALSE);
  1342. X    } else if(uwep->oerodeproof ||
  1343. X       (acid_dmg ? !is_corrodeable(uwep) : !is_rustprone(uwep))) {
  1344. X        if (flags.verbose || !(uwep->oerodeproof && uwep->rknown))
  1345. X            Your("%s not affected.", aobjnam(uwep, "are"));
  1346. X        if (uwep->oerodeproof) uwep->rknown = TRUE;
  1347. X    } else if (uwep->oeroded < MAX_ERODE) {
  1348. X        Your("%s%s!", aobjnam(uwep, acid_dmg ? "corrode" : "rust"),
  1349. X             uwep->oeroded+1 == MAX_ERODE ? " completely" :
  1350. X             uwep->oeroded ? " further" : "");
  1351. X        uwep->oeroded++;
  1352. X    } else
  1353. X        if (flags.verbose)
  1354. X            Your("%s completely %s.",
  1355. X             aobjnam(uwep, Blind ? "feel" : "look"),
  1356. X             acid_dmg ? "corroded" : "rusty");
  1357. X}
  1358. X
  1359. Xint
  1360. Xchwepon(otmp, amount)
  1361. Xregister struct obj *otmp;
  1362. Xregister int amount;
  1363. X{
  1364. X    register const char *color = Hallucination ? hcolor() :
  1365. X                     (amount < 0) ? Black : blue;
  1366. X    register const char *xtime;
  1367. X
  1368. X    if(!uwep || (uwep->oclass != WEAPON_CLASS && uwep->otyp != PICK_AXE
  1369. X            && uwep->otyp != UNICORN_HORN)) {
  1370. X        char buf[36];
  1371. X
  1372. X        Sprintf(buf, "Your %s %s.", makeplural(body_part(HAND)),
  1373. X            (amount >= 0) ? "twitch" : "itch");
  1374. X        strange_feeling(otmp, buf);
  1375. X        exercise(A_DEX, amount >= 0);
  1376. X        return(0);
  1377. X    }
  1378. X
  1379. X    if(uwep->otyp == WORM_TOOTH && amount >= 0) {
  1380. X        uwep->otyp = CRYSKNIFE;
  1381. X        Your("weapon seems sharper now.");
  1382. X        uwep->cursed = 0;
  1383. X        return(1);
  1384. X    }
  1385. X
  1386. X    if(uwep->otyp == CRYSKNIFE && amount < 0) {
  1387. X        uwep->otyp = WORM_TOOTH;
  1388. X        Your("weapon seems duller now.");
  1389. X        return(1);
  1390. X    }
  1391. X
  1392. X    if (amount < 0 && uwep->oartifact && restrict_name(uwep, ONAME(uwep))) {
  1393. X        if (!Blind)
  1394. X        Your("%s %s.", aobjnam(uwep, "faintly glow"), color);
  1395. X        return(1);
  1396. X    }
  1397. X    /* there is a (soft) upper and lower limit to uwep->spe */
  1398. X    if(((uwep->spe > 5 && amount >= 0) || (uwep->spe < -5 && amount < 0))
  1399. X                                && rn2(3)) {
  1400. X        if (!Blind)
  1401. X        Your("%s %s for a while and then evaporate%s.",
  1402. X         aobjnam(uwep, "violently glow"), color,
  1403. X         uwep->quan == 1L ? "s" : "");
  1404. X        else
  1405. X        Your("%s.", aobjnam(uwep, "evaporate"));
  1406. X
  1407. X        while(uwep)        /* let all of them disappear */
  1408. X                /* note: uwep->quan = 1 is nogood if unpaid */
  1409. X        useup(uwep);
  1410. X        return(1);
  1411. X    }
  1412. X    if (!Blind) {
  1413. X        xtime = (amount*amount == 1) ? "moment" : "while";
  1414. X        Your("%s %s for a %s.",
  1415. X         aobjnam(uwep, amount == 0 ? "violently glow" : "glow"),
  1416. X         color, xtime);
  1417. X    }
  1418. X    uwep->spe += amount;
  1419. X    if(amount > 0) uwep->cursed = 0;
  1420. X
  1421. X    /*
  1422. X     * Enchantment, which normally improves a weapon, has an
  1423. X     * addition adverse reaction on Magicbane whose effects are
  1424. X     * spe dependent.  Give an obscure clue here.
  1425. X     */
  1426. X    if (uwep->oartifact == ART_MAGICBANE && uwep->spe >= 0) {
  1427. X        Your("right %s %sches!",
  1428. X            body_part(HAND),
  1429. X            (((amount > 1) && (uwep->spe > 1)) ? "flin" : "it"));
  1430. X    }
  1431. X
  1432. X    /* an elven magic clue, cookie@keebler */
  1433. X    if ((uwep->spe > 5)
  1434. X        && (is_elven_weapon(uwep) || uwep->oartifact || !rn2(7)))
  1435. X        Your("%s unexpectedly.",
  1436. X        aobjnam(uwep, "suddenly vibrate"));
  1437. X
  1438. X    return(1);
  1439. X}
  1440. X
  1441. Xint
  1442. Xwelded(obj)
  1443. Xregister struct obj *obj;
  1444. X{
  1445. X    if (obj && obj == uwep && obj->cursed &&
  1446. X          (obj->oclass == WEAPON_CLASS ||
  1447. X           obj->otyp == HEAVY_IRON_BALL ||
  1448. X           obj->otyp == TIN_OPENER || obj->otyp == PICK_AXE ||
  1449. X           obj->otyp == UNICORN_HORN))
  1450. X    {
  1451. X        obj->bknown = TRUE;
  1452. X        return 1;
  1453. X    }
  1454. X    return 0;
  1455. X}
  1456. X
  1457. X/* The reason for "specific" is historical; some parts of the code used
  1458. X * the object name and others just used "weapon"/"sword".  This function
  1459. X * replaced all of those.  Which one we use is really arbitrary.
  1460. X */
  1461. Xvoid
  1462. Xweldmsg(obj, specific)
  1463. Xregister struct obj *obj;
  1464. Xboolean specific;
  1465. X{
  1466. X    char buf[BUFSZ];
  1467. X
  1468. X    if (specific) {
  1469. X        long savewornmask = obj->owornmask;
  1470. X        obj->owornmask &= ~W_WEP;
  1471. X        Strcpy(buf, Doname2(obj));
  1472. X        obj->owornmask = savewornmask;
  1473. X    } else
  1474. X        Sprintf(buf, "Your %s%s",
  1475. X            is_sword(obj) ? "sword" : "weapon",
  1476. X            plur(obj->quan));
  1477. X    Strcat(buf, (obj->quan == 1L) ? " is" : " are");
  1478. X#ifdef POLYSELF
  1479. X    Sprintf(eos(buf), " welded to your %s!",
  1480. X        bimanual(obj) ? (const char *)makeplural(body_part(HAND)) : body_part(HAND));
  1481. X#else
  1482. X    Sprintf(eos(buf), " welded to your hand%s!",
  1483. X        bimanual(obj) ? "s" : "");
  1484. X#endif
  1485. X    pline(buf);
  1486. X}
  1487. X
  1488. X/*wield.c*/
  1489. END_OF_FILE
  1490. if test 7935 -ne `wc -c <'src/wield.c'`; then
  1491.     echo shar: \"'src/wield.c'\" unpacked with wrong size!
  1492. fi
  1493. # end of 'src/wield.c'
  1494. fi
  1495. if test -f 'sys/share/pcunix.c' -a "${1}" != "-c" ; then 
  1496.   echo shar: Will not clobber existing file \"'sys/share/pcunix.c'\"
  1497. else
  1498. echo shar: Extracting \"'sys/share/pcunix.c'\" \(2804 characters\)
  1499. sed "s/^X//" >'sys/share/pcunix.c' <<'END_OF_FILE'
  1500. X/*    SCCS Id: @(#)pcunix.c    3.1    90/22/02
  1501. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  1502. X/* NetHack may be freely redistributed.  See license for details. */
  1503. X
  1504. X/* This file collects some Unix dependencies; pager.c contains some more */
  1505. X
  1506. X#include "hack.h"
  1507. X
  1508. X#include    <sys/stat.h>
  1509. X
  1510. X#ifdef OVLB
  1511. X
  1512. Xstatic struct stat buf;
  1513. X# ifdef WANT_GETHDATE
  1514. Xstatic struct stat hbuf;
  1515. X# endif
  1516. X
  1517. Xvoid
  1518. Xgethdate(name)
  1519. Xchar *name;
  1520. X{
  1521. X# ifdef WANT_GETHDATE
  1522. X/* old version - for people short of space */
  1523. X/*
  1524. X/* register char *np;
  1525. X/*      if(stat(name, &hbuf))
  1526. X/*          error("Cannot get status of %s.",
  1527. X/*              (np = rindex(name, '/')) ? np+1 : name);
  1528. X/*
  1529. X/* version using PATH from: seismo!gregc@ucsf-cgl.ARPA (Greg Couch) */
  1530. X
  1531. X/*
  1532. X * The problem with   #include  <sys/param.h> is that this include file
  1533. X * does not exist on all systems, and moreover, that it sometimes includes
  1534. X * <sys/types.h> again, so that the compiler sees these typedefs twice.
  1535. X */
  1536. X#define     MAXPATHLEN      1024
  1537. X
  1538. X    register char *np, *path;
  1539. X    char filename[MAXPATHLEN+1], *getenv();
  1540. X
  1541. X    if (index(name, '/') != NULL || (path = getenv("PATH")) == NULL)
  1542. X    path = "";
  1543. X
  1544. X    for (;;) {
  1545. X    if ((np = index(path, ':')) == NULL)
  1546. X        np = path + strlen(path);       /* point to end str */
  1547. X    if (np - path <= 1)             /* %% */
  1548. X        Strcpy(filename, name);
  1549. X    else {
  1550. X        (void) strncpy(filename, path, np - path);
  1551. X        filename[np - path] = '/';
  1552. X        Strcpy(filename + (np - path) + 1, name);
  1553. X    }
  1554. X    if (stat(filename, &hbuf) == 0)
  1555. X        return;
  1556. X    if (*np == '\0')
  1557. X    path = "";
  1558. X    path = np + 1;
  1559. X    }
  1560. X    error("Cannot get status of %s.", (np = rindex(name, '/')) ? np+1 : name);
  1561. X# endif /* WANT_GETHDATE */
  1562. X}
  1563. X
  1564. Xint
  1565. Xuptodate(fd)
  1566. Xint fd;
  1567. X{
  1568. X# ifdef WANT_GETHDATE
  1569. X    if(fstat(fd, &buf)) {
  1570. X    pline("Cannot get status of saved level? ");
  1571. X    return(0);
  1572. X    }
  1573. X    if(buf.st_mtime < hbuf.st_mtime) {
  1574. X    pline("Saved level is out of date. ");
  1575. X    return(0);
  1576. X    }
  1577. X# else
  1578. X#  if defined(MICRO) && !defined(NO_FSTAT)
  1579. X    if(fstat(fd, &buf)) {
  1580. X    if(moves > 1) pline("Cannot get status of saved level? ");
  1581. X    else pline("Cannot get status of saved game");
  1582. X    return(0);
  1583. X    } 
  1584. X    if(comp_times(buf.st_mtime)) { 
  1585. X    if(moves > 1) pline("Saved level is out of date");
  1586. X    else pline("Saved game is out of date. ");
  1587. X    return(0);
  1588. X    }
  1589. X#  endif  /* MICRO /* */
  1590. X# endif /* WANT_GETHDATE */
  1591. X    return(1);
  1592. X}
  1593. X
  1594. Xvoid
  1595. Xregularize(s)
  1596. X/*
  1597. X * normalize file name - we don't like .'s, /'s, spaces, and
  1598. X * lots of other things
  1599. X */
  1600. Xregister char *s;
  1601. X{
  1602. X    register char *lp;
  1603. X
  1604. X    for (lp = s; *lp; lp++)
  1605. X        if (*lp <= ' ' || *lp == '"' || (*lp >= '*' && *lp <= ',') ||
  1606. X            *lp == '.' || *lp == '/' || (*lp >= ':' && *lp <= '?') ||
  1607. X# ifdef OS2
  1608. X            *lp == '&' || *lp == '(' || *lp == ')' ||
  1609. X# endif
  1610. X            *lp == '|' || *lp >= 127 || (*lp >= '[' && *lp <= ']'))
  1611. X                        *lp = '_';
  1612. X}
  1613. X
  1614. X#endif /* OVLB */
  1615. END_OF_FILE
  1616. if test 2804 -ne `wc -c <'sys/share/pcunix.c'`; then
  1617.     echo shar: \"'sys/share/pcunix.c'\" unpacked with wrong size!
  1618. fi
  1619. # end of 'sys/share/pcunix.c'
  1620. fi
  1621. if test -f 'win/tty/topl.c' -a "${1}" != "-c" ; then 
  1622.   echo shar: Will not clobber existing file \"'win/tty/topl.c'\"
  1623. else
  1624. echo shar: Extracting \"'win/tty/topl.c'\" \(7994 characters\)
  1625. sed "s/^X//" >'win/tty/topl.c' <<'END_OF_FILE'
  1626. X/*    SCCS Id: @(#)topl.c    3.1    90/09/21
  1627. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  1628. X/* NetHack may be freely redistributed.  See license for details. */
  1629. X
  1630. X#include "hack.h"
  1631. X#include "termcap.h"
  1632. X#include "wintty.h"
  1633. X#include <ctype.h>
  1634. X
  1635. XSTATIC_DCL void FDECL(redotoplin, (const char*));
  1636. XSTATIC_DCL void FDECL(topl_putsym, (CHAR_P));
  1637. XSTATIC_DCL void NDECL(remember_topl);
  1638. Xstatic void FDECL(removetopl, (int));
  1639. X
  1640. X#ifdef OVLB
  1641. X
  1642. Xint
  1643. Xtty_doprev_message()
  1644. X{
  1645. X    register struct WinDesc *cw = wins[WIN_MESSAGE];
  1646. X
  1647. X    if(cw->data[cw->maxcol])
  1648. X    redotoplin(cw->data[cw->maxcol]);
  1649. X    else if(cw->maxcol == cw->maxrow)
  1650. X    redotoplin(toplines);
  1651. X    cw->maxcol--;
  1652. X    if(cw->maxcol < 0) cw->maxcol = cw->rows-1;
  1653. X    if(!cw->data[cw->maxcol])
  1654. X    cw->maxcol = cw->maxrow;
  1655. X    return 0;
  1656. X}
  1657. X
  1658. X#endif /* OVLB */
  1659. X#ifdef OVL1
  1660. X
  1661. XSTATIC_OVL void
  1662. Xredotoplin(str)
  1663. X    const char *str;
  1664. X{
  1665. X    int otoplin = ttyDisplay->toplin;
  1666. X    home();
  1667. X    if(*str & 0x80) {
  1668. X        /* kludge for the / command, the only time we ever want a */
  1669. X        /* graphics character on the top line */
  1670. X        g_putch(*str++);
  1671. X        ttyDisplay->curx++;
  1672. X    }
  1673. X    end_glyphout();    /* in case message printed during graphics output */
  1674. X    putsyms(str);
  1675. X    cl_end();
  1676. X    ttyDisplay->toplin = 1;
  1677. X    if(ttyDisplay->cury && otoplin != 3)
  1678. X        more();
  1679. X}
  1680. X
  1681. XSTATIC_OVL void
  1682. Xremember_topl()
  1683. X{
  1684. X    register struct WinDesc *cw = wins[WIN_MESSAGE];
  1685. X
  1686. X    cw->data[cw->maxrow] = (char*) alloc(strlen(toplines)+1);
  1687. X    Strcpy(cw->data[cw->maxrow], toplines);
  1688. X    cw->maxcol = cw->maxrow = (cw->maxrow+1) % cw->rows;
  1689. X    if(cw->data[cw->maxrow]) {
  1690. X    free((genericptr_t)cw->data[cw->maxrow]);
  1691. X    cw->data[cw->maxrow] = 0;
  1692. X    }
  1693. X}
  1694. X
  1695. Xvoid
  1696. Xaddtopl(s)
  1697. Xconst char *s;
  1698. X{
  1699. X    register struct WinDesc *cw = wins[WIN_MESSAGE];
  1700. X
  1701. X    tty_curs(BASE_WINDOW,cw->curx+1,cw->cury);
  1702. X    if(cw->curx + (int)strlen(s) >= CO) topl_putsym('\n');
  1703. X    putsyms(s);
  1704. X    cl_end();
  1705. X    ttyDisplay->toplin = 1;
  1706. X}
  1707. X
  1708. X#endif /* OVL1 */
  1709. X#ifdef OVL2
  1710. X
  1711. Xvoid
  1712. Xmore()
  1713. X{
  1714. X    struct WinDesc *cw = wins[WIN_MESSAGE];
  1715. X
  1716. X    /* avoid recursion -- only happens from interrupts */
  1717. X    if(ttyDisplay->inmore++)
  1718. X    return;
  1719. X
  1720. X    if(ttyDisplay->toplin) {
  1721. X    tty_curs(BASE_WINDOW, cw->curx+1, cw->cury);
  1722. X    if(cw->curx >= CO - 8) topl_putsym('\n');
  1723. X    }
  1724. X
  1725. X    if(flags.standout)
  1726. X    standoutbeg();
  1727. X    putsyms(defmorestr);
  1728. X    if(flags.standout)
  1729. X    standoutend();
  1730. X
  1731. X    xwaitforspace("\033");
  1732. X
  1733. X    if(morc == '\033')
  1734. X    cw->flags |= WIN_STOP;
  1735. X
  1736. X    if(ttyDisplay->toplin && cw->cury) {
  1737. X    docorner(1, cw->cury+1);
  1738. X    cw->curx = cw->cury = 0;
  1739. X    home();
  1740. X    } else if(morc == '\033') {
  1741. X    cw->curx = cw->cury = 0;
  1742. X    home();
  1743. X    cl_end();
  1744. X    }
  1745. X    ttyDisplay->toplin = 0;
  1746. X    ttyDisplay->inmore = 0;
  1747. X}
  1748. X
  1749. Xvoid
  1750. Xupdate_topl(bp)
  1751. X    register const char *bp;
  1752. X{
  1753. X    register char *tl, *otl;
  1754. X    register int n0;
  1755. X    int notdied = 1;
  1756. X    struct WinDesc *cw = wins[WIN_MESSAGE];
  1757. X
  1758. X    /* If there is room on the line, print message on same line */
  1759. X    /* But messages like "You die..." deserve their own line */
  1760. X    n0 = strlen(bp);
  1761. X    if(ttyDisplay->toplin == 1 && cw->cury == 0 &&
  1762. X        n0 + (int)strlen(toplines) + 3 < CO-8 &&  /* room for --More-- */
  1763. X        (notdied = strncmp(bp, "You die", 7))) {
  1764. X        Strcat(toplines, "  ");
  1765. X        Strcat(toplines, bp);
  1766. X        cw->curx += 2;
  1767. X        if(!(cw->flags & WIN_STOP))
  1768. X            addtopl(bp);
  1769. X        return;
  1770. X    } else if(!(cw->flags & WIN_STOP)) {
  1771. X        if(ttyDisplay->toplin == 1) more();
  1772. X        else if(cw->cury) {    /* for when flags.toplin == 2 && cury > 1 */
  1773. X        docorner(1, cw->cury+1); /* reset cury = 0 if redraw screen */
  1774. X        cw->curx = cw->cury = 0;/* from home--cls() & docorner(1,n) */
  1775. X        }
  1776. X    }
  1777. X    remember_topl();
  1778. X    Strcpy(toplines, bp);
  1779. X    for(tl = toplines; n0 >= CO; ){
  1780. X        otl = tl;
  1781. X        for(tl+=CO-1; tl != otl && !isspace(*tl); --tl) ;
  1782. X        if(tl == otl) {
  1783. X        /* Eek!  A huge token.  Try splitting after it. */
  1784. X        tl = index(otl, ' ');
  1785. X        if (!tl) break;    /* No choice but to spit it out whole. */
  1786. X        }
  1787. X        *tl++ = '\n';
  1788. X        n0 = strlen(tl);
  1789. X    }
  1790. X    if(!notdied) cw->flags &= ~WIN_STOP;
  1791. X    if(!(cw->flags & WIN_STOP)) redotoplin(toplines);
  1792. X}
  1793. X
  1794. XSTATIC_OVL
  1795. Xvoid
  1796. Xtopl_putsym(c)
  1797. X    char c;
  1798. X{
  1799. X    register struct WinDesc *cw = wins[WIN_MESSAGE];
  1800. X
  1801. X    if(cw == (struct WinDesc *) 0) panic("Putsym window MESSAGE nonexistant");
  1802. X    
  1803. X    switch(c) {
  1804. X    case '\b':
  1805. X    if(ttyDisplay->curx == 0 && ttyDisplay->cury > 0)
  1806. X        tty_curs(BASE_WINDOW, CO, (int)ttyDisplay->cury-1);
  1807. X    backsp();
  1808. X    ttyDisplay->curx--;
  1809. X    cw->curx = ttyDisplay->curx;
  1810. X    return;
  1811. X    case '\n':
  1812. X    cl_end();
  1813. X    ttyDisplay->curx = 0;
  1814. X    ttyDisplay->cury++;
  1815. X    cw->cury = ttyDisplay->cury;
  1816. X    break;
  1817. X    default:
  1818. X    if(ttyDisplay->curx == CO-1)
  1819. X        topl_putsym('\n'); /* 1 <= curx <= CO; avoid CO */
  1820. X    ttyDisplay->curx++;
  1821. X    }
  1822. X    cw->curx = ttyDisplay->curx;
  1823. X    if(cw->curx == 0) cl_end();
  1824. X    (void) putchar(c);
  1825. X}
  1826. X
  1827. Xvoid
  1828. Xputsyms(str)
  1829. X    const char *str;
  1830. X{
  1831. X    while(*str)
  1832. X    topl_putsym(*str++);
  1833. X}
  1834. X
  1835. Xstatic void
  1836. Xremovetopl(n)
  1837. Xregister int n;
  1838. X{
  1839. X    /* assume addtopl() has been done, so ttyDisplay->toplin is already set */
  1840. X    while (n-- > 0) putsyms("\b \b");
  1841. X}
  1842. X
  1843. Xextern char erase_char;        /* from xxxtty.c; don't need kill_char */
  1844. X
  1845. Xchar
  1846. Xtty_yn_function(query,resp, def)
  1847. Xconst char *query,*resp;
  1848. Xchar def;
  1849. X/*
  1850. X *   Generic yes/no function. 'def' is the default (returned by space or
  1851. X *   return; 'esc' returns 'q', or 'n', or the default, depending on
  1852. X *   what's in the string. The 'query' string is printed before the user
  1853. X *   is asked about the string.
  1854. X *   If resp is NULL, any single character is accepted and returned.
  1855. X */
  1856. X{
  1857. X    register char q;
  1858. X    char rtmp[40];
  1859. X    boolean digit_ok, allow_num;
  1860. X    struct WinDesc *cw = wins[WIN_MESSAGE];
  1861. X    boolean doprev = 0;
  1862. X    char prompt[QBUFSZ];
  1863. X
  1864. X    if(ttyDisplay->toplin == 1 && !(cw->flags & WIN_STOP)) more();
  1865. X    cw->flags &= ~WIN_STOP;
  1866. X    ttyDisplay->toplin = 3; /* special prompt state */
  1867. X    ttyDisplay->inread++;
  1868. X    if(resp) {
  1869. X        allow_num = (index(resp, '#') != 0);
  1870. X        if(def)
  1871. X        Sprintf(prompt, "%s [%s] (%c) ", query, resp, def);
  1872. X        else
  1873. X        Sprintf(prompt, "%s [%s] ", query, resp);
  1874. X        pline("%s", prompt);
  1875. X    } else {
  1876. X        pline("%s ", query);
  1877. X        q = readchar();
  1878. X        goto clean_up;
  1879. X    }
  1880. X
  1881. X    do {    /* loop until we get valid input */
  1882. X        q = lowc(readchar());
  1883. X        if (q == '\020') { /* ctrl-P */
  1884. X        if(!doprev) (void) tty_doprev_message(); /* need two initially */
  1885. X        (void) tty_doprev_message();
  1886. X        q = (char)0;
  1887. X        doprev = 1;
  1888. X        continue;
  1889. X        } else if(doprev) {
  1890. X        tty_clear_nhwindow(WIN_MESSAGE);
  1891. X        cw->maxcol = cw->maxrow;
  1892. X        doprev = 0;
  1893. X        addtopl(prompt);
  1894. X        continue;
  1895. X        }
  1896. X        digit_ok = allow_num && digit(q);
  1897. X        if (q == '\033') {
  1898. X        if (index(resp, 'q'))
  1899. X            q = 'q';
  1900. X        else if (index(resp, 'n'))
  1901. X            q = 'n';
  1902. X        else
  1903. X            q = def;
  1904. X        break;
  1905. X        } else if (index(quitchars, q)) {
  1906. X        q = def;
  1907. X        break;
  1908. X        }
  1909. X        if (!index(resp, q) && !digit_ok) {
  1910. X        tty_nhbell();
  1911. X        q = (char)0;
  1912. X        } else if (q == '#' || digit_ok) {
  1913. X        char z, digit_string[2];
  1914. X        int n_len = 0;
  1915. X        long value = 0;
  1916. X        addtopl("#"),  n_len++;
  1917. X        digit_string[1] = '\0';
  1918. X        if (q != '#') {
  1919. X            digit_string[0] = q;
  1920. X            addtopl(digit_string),  n_len++;
  1921. X            value = q - '0';
  1922. X            q = '#';
  1923. X        }
  1924. X        do {    /* loop until we get a non-digit */
  1925. X            z = lowc(readchar());
  1926. X            if (digit(z)) {
  1927. X            value = (10 * value) + (z - '0');
  1928. X            if (value < 0) break;    /* overflow: try again */
  1929. X            digit_string[0] = z;
  1930. X            addtopl(digit_string),  n_len++;
  1931. X            } else if (z == 'y' || index(quitchars, z)) {
  1932. X            if (z == '\033')  value = -1;    /* abort */
  1933. X            z = '\n';    /* break */
  1934. X            } else if (z == erase_char || z == '\b') {
  1935. X            if (n_len <= 1) { value = -1;  break; }
  1936. X            else { value /= 10;  removetopl(1),  n_len--; }
  1937. X            } else {
  1938. X            value = -1;    /* abort */
  1939. X            tty_nhbell();
  1940. X            break;
  1941. X            }
  1942. X        } while (z != '\n');
  1943. X        if (value > 0) yn_number = value;
  1944. X        else if (value == 0) q = 'n';        /* 0 => "no" */
  1945. X        else {    /* remove number from top line, then try again */
  1946. X            removetopl(n_len),  n_len = 0;
  1947. X            q = '\0';
  1948. X        }
  1949. X        }
  1950. X    } while(!q);
  1951. X
  1952. X    if (q != '#') {
  1953. X        Sprintf(rtmp, "%c", q);
  1954. X        addtopl(rtmp);
  1955. X    }
  1956. X    clean_up:
  1957. X    ttyDisplay->inread--;
  1958. X    ttyDisplay->toplin = 2;
  1959. X    if(wins[WIN_MESSAGE]->cury)
  1960. X        tty_clear_nhwindow(WIN_MESSAGE);
  1961. X
  1962. X    return q;
  1963. X}
  1964. X
  1965. X#endif /* OVL2 */
  1966. X
  1967. X/*topl.c*/
  1968. END_OF_FILE
  1969. if test 7994 -ne `wc -c <'win/tty/topl.c'`; then
  1970.     echo shar: \"'win/tty/topl.c'\" unpacked with wrong size!
  1971. fi
  1972. # end of 'win/tty/topl.c'
  1973. fi
  1974. echo shar: End of archive 96 \(of 108\).
  1975. cp /dev/null ark96isdone
  1976. MISSING=""
  1977. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
  1978. 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 \
  1979. 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 \
  1980. 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 \
  1981. 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 \
  1982. 101 102 103 104 105 106 107 108 ; do
  1983.     if test ! -f ark${I}isdone ; then
  1984.     MISSING="${MISSING} ${I}"
  1985.     fi
  1986. done
  1987. if test "${MISSING}" = "" ; then
  1988.     echo You have unpacked all 108 archives.
  1989.     echo "Now execute 'rebuild.sh'"
  1990.     rm -f ark10[0-8]isdone ark[1-9]isdone ark[1-9][0-9]isdone
  1991. else
  1992.     echo You still need to unpack the following archives:
  1993.     echo "        " ${MISSING}
  1994. fi
  1995. ##  End of shell archive.
  1996. exit 0
  1997.