home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume16 / nethck31 / part57 < prev    next >
Encoding:
Internet Message Format  |  1993-02-03  |  57.8 KB

  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: v16i065:  nethack31 - display oriented dungeons & dragons (Ver. 3.1), Part57/108
  5. Message-ID: <4368@master.CNA.TEK.COM>
  6. Date: 1 Feb 93 19:44:26 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 2177
  9. Approved: billr@saab.CNA.TEK.COM
  10. Xref: uunet comp.sources.games:1615
  11.  
  12. Submitted-by: izchak@linc.cis.upenn.edu (Izchak Miller)
  13. Posting-number: Volume 16, Issue 65
  14. Archive-name: nethack31/Part57
  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 57 (of 108)."
  27. # Contents:  src/mhitu.c2 sys/share/dgn_yacc.c
  28. # Wrapped by billr@saab on Wed Jan 27 16:09:09 1993
  29. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  30. if test -f 'src/mhitu.c2' -a "${1}" != "-c" ; then 
  31.   echo shar: Will not clobber existing file \"'src/mhitu.c2'\"
  32. else
  33. echo shar: Extracting \"'src/mhitu.c2'\" \(21658 characters\)
  34. sed "s/^X//" >'src/mhitu.c2' <<'END_OF_FILE'
  35. X#ifdef OVLB
  36. X
  37. XSTATIC_OVL int
  38. Xgulpmu(mtmp, mattk)    /* monster swallows you, or damage if u.uswallow */
  39. X    register struct monst *mtmp;
  40. X    register struct attack  *mattk;
  41. X{
  42. X    struct trap *t = t_at(u.ux, u.uy);
  43. X    int    tmp = d((int)mattk->damn, (int)mattk->damd);
  44. X    int    tim_tmp;
  45. X    register struct obj *otmp2;
  46. X#ifdef WALKIES
  47. X    int    i;
  48. X#endif
  49. X
  50. X    if(!u.uswallow) {    /* swallows you */
  51. X#ifdef POLYSELF
  52. X        if (uasmon->msize >= MZ_HUGE) return(0);
  53. X#endif
  54. X        if ((t && ((t->ttyp == PIT) || (t->ttyp == SPIKED_PIT))) &&
  55. X            sobj_at(BOULDER, u.ux, u.uy))
  56. X            return(0);    
  57. X        if (Punished) unplacebc();    /* ball&chain go away */
  58. X        remove_monster(mtmp->mx, mtmp->my);
  59. X        place_monster(mtmp, u.ux, u.uy);
  60. X        u.ustuck = mtmp;
  61. X        newsym(mtmp->mx,mtmp->my);
  62. X        pline("%s engulfs you!", Monnam(mtmp));
  63. X        stop_occupation();
  64. X        if (u.utrap) {
  65. X            You("are released from the %s!",
  66. X                u.utraptype==TT_WEB ? "web" : "trap");
  67. X            u.utrap = 0;
  68. X        }
  69. X#ifdef WALKIES
  70. X        if((i = number_leashed()) > 0) {
  71. X            pline("The leash%s snap%s loose...",
  72. X                    (i > 1) ? "es" : "",
  73. X                    (i > 1) ? "" : "s");
  74. X            unleash_all();
  75. X        }
  76. X#endif
  77. X#ifdef POLYSELF
  78. X        if (u.umonnum==PM_COCKATRICE && !resists_ston(mtmp->data)) {
  79. X            pline("%s turns to stone!", Monnam(mtmp));
  80. X            stoned = 1;
  81. X            xkilled(mtmp, 0);
  82. X            return 2;
  83. X        }
  84. X#endif
  85. X        display_nhwindow(WIN_MESSAGE, FALSE);
  86. X        vision_recalc(2);    /* hero can't see anything */
  87. X        u.uswallow = 1;
  88. X        /*assume that u.uswldtim always set >=0*/
  89. X        u.uswldtim = (tim_tmp =
  90. X            (-u.uac + 10 + rnd(25 - (int)mtmp->m_lev)) >> 1) > 0 ?
  91. X                tim_tmp : 0;
  92. X        swallowed(1);
  93. X        for(otmp2 = invent; otmp2; otmp2 = otmp2->nobj) {
  94. X            (void) snuff_lit(otmp2);
  95. X        }
  96. X    } else {
  97. X
  98. X        if(mtmp != u.ustuck) return(0);
  99. X        switch(mattk->adtyp) {
  100. X
  101. X        case AD_DGST:
  102. X            if(!u.uswldtim) {    /* a3 *//*no cf unsigned <=0*/
  103. X            pline("%s totally digests you!", Monnam(mtmp));
  104. X            tmp = u.uhp;
  105. X            } else {
  106. X            pline("%s digests you!", Monnam(mtmp));
  107. X                exercise(A_STR, FALSE);
  108. X            }
  109. X            break;
  110. X        case AD_PHYS:
  111. X            You("are pummeled with debris!");
  112. X            exercise(A_STR, FALSE);
  113. X            break;
  114. X        case AD_ACID:
  115. X#ifdef POLYSELF
  116. X            if (resists_acid(uasmon)) {
  117. X            You("are covered with a seemingly harmless goo.");
  118. X            tmp = 0;
  119. X            } else
  120. X#endif
  121. X            {
  122. X              if (Hallucination) pline("Ouch!  You've been slimed!");
  123. X              else You("are covered in slime!  It burns!");
  124. X              exercise(A_STR, FALSE);
  125. X            }
  126. X            break;
  127. X        case AD_BLND:
  128. X            if (!defends(AD_BLND, uwep)) {
  129. X            if(!Blind) {
  130. X                You("can't see in here!");
  131. X                make_blinded((long)tmp,FALSE);
  132. X            } else
  133. X                /* keep him blind until disgorged */
  134. X                make_blinded(Blinded+1,FALSE);
  135. X            }
  136. X            tmp = 0;
  137. X            break;
  138. X        case AD_ELEC:
  139. X            if(!mtmp->mcan && rn2(2)) {
  140. X            pline("The air around you crackles with electricity.");
  141. X            if (Shock_resistance) {
  142. X                shieldeff(u.ux, u.uy);
  143. X                You("seem unhurt.");
  144. X#if defined(POLYSELF)
  145. X                ugolemeffects(AD_ELEC,tmp);
  146. X#endif
  147. X                tmp = 0;
  148. X            }
  149. X            } else tmp = 0;
  150. X            break;
  151. X        case AD_COLD:
  152. X            if(!mtmp->mcan && rn2(2)) {
  153. X            if (Cold_resistance) {
  154. X                shieldeff(u.ux, u.uy);
  155. X                You("feel mildly chilly.");
  156. X#if defined(POLYSELF)
  157. X                ugolemeffects(AD_COLD,tmp);
  158. X#endif
  159. X                tmp = 0;
  160. X            } else You("are freezing to death!");
  161. X            } else tmp = 0;
  162. X            break;
  163. X        case AD_FIRE:
  164. X            if(!mtmp->mcan && rn2(2)) {
  165. X            if (Fire_resistance) {
  166. X                shieldeff(u.ux, u.uy);
  167. X                You("feel mildly hot.");
  168. X#if defined(POLYSELF)
  169. X                ugolemeffects(AD_FIRE,tmp);
  170. X#endif
  171. X                tmp = 0;
  172. X            } else You("are burning to a crisp!");
  173. X            } else tmp = 0;
  174. X            break;
  175. X        case AD_DISE:
  176. X            if (!diseasemu(mtmp->data)) tmp = 0;
  177. X            break;
  178. X        default:    tmp = 0;
  179. X                break;
  180. X        }
  181. X    }
  182. X
  183. X    if(Half_physical_damage) tmp = (tmp+1) / 2;
  184. X
  185. X    mdamageu(mtmp, tmp);
  186. X    if(tmp) stop_occupation();
  187. X    if(u.uswldtim) --u.uswldtim;
  188. X    if(!u.uswldtim
  189. X#ifdef POLYSELF
  190. X        || u.umonnum==PM_COCKATRICE
  191. X        || uasmon->msize >= MZ_HUGE
  192. X#endif
  193. X        ) {
  194. X#ifdef POLYSELF
  195. X        if (u.umonnum == PM_COCKATRICE) {
  196. X        pline("%s very hurriedly %s you!", Monnam(mtmp), 
  197. X               is_animal(mtmp->data)? "regurgitates" : "expels");
  198. X        u.uswldtim = 0;
  199. X        } else {
  200. X#endif
  201. X        You("get %s!", 
  202. X            is_animal(mtmp->data)? "regurgitated" : "expelled");
  203. X        if(flags.verbose && is_animal(mtmp->data))
  204. X            pline("Obviously %s doesn't like your taste.",
  205. X                   mon_nam(mtmp));
  206. X#ifdef POLYSELF
  207. X        }
  208. X#endif
  209. X        expels(mtmp, mtmp->data, FALSE);
  210. X    }
  211. X    return(1);
  212. X}
  213. X
  214. XSTATIC_OVL int
  215. Xexplmu(mtmp, mattk, ufound)    /* monster explodes in your face */
  216. Xregister struct monst *mtmp;
  217. Xregister struct attack  *mattk;
  218. Xboolean ufound;
  219. X{
  220. X    if (mtmp->mcan) return(0);
  221. X
  222. X    if (!ufound)
  223. X    pline("%s explodes at a spot in thin air!",
  224. X          canseemon(mtmp) ? Monnam(mtmp) : "It");
  225. X    else {
  226. X    register int tmp = d((int)mattk->damn, (int)mattk->damd);
  227. X    register boolean not_affected = defends((int)mattk->adtyp, uwep);
  228. X
  229. X    hitmsg(mtmp, mattk);
  230. X
  231. X    switch (mattk->adtyp) {
  232. X        case AD_COLD:
  233. X        not_affected |= Cold_resistance;
  234. X
  235. X        if (!not_affected) {
  236. X            if (flags.verbose) You("get blasted!");
  237. X            if (ACURR(A_DEX) > rnd(20)) {
  238. X            You("duck the blast...");
  239. X            tmp = (tmp+1) / 2;
  240. X            }
  241. X            if (Half_physical_damage) tmp = (tmp+1) / 2;
  242. X            mdamageu(mtmp, tmp);
  243. X        }
  244. X        break;
  245. X
  246. X        case AD_BLND:
  247. X        not_affected |=
  248. X#ifdef POLYSELF
  249. X            (u.umonnum == PM_YELLOW_LIGHT) ||
  250. X#endif
  251. X            Blind;
  252. X        if (!not_affected) {
  253. X            if (mon_visible(mtmp)) {
  254. X            You("are blinded by a blast of light!");
  255. X            make_blinded((long)tmp, FALSE);
  256. X            } else
  257. X            You("get the impression it was not terribly bright.");
  258. X        }
  259. X        break;
  260. X
  261. X        default:
  262. X        break;
  263. X    }
  264. X    if (not_affected) {
  265. X        You("seem unaffected by it.");
  266. X#if defined(POLYSELF)
  267. X        ugolemeffects((int)mattk->adtyp, tmp);
  268. X#endif
  269. X    }
  270. X    }
  271. X    mondead(mtmp);
  272. X    return(2);    /* it dies */
  273. X}
  274. X
  275. XSTATIC_OVL int
  276. Xgazemu(mtmp, mattk)    /* monster gazes at you */
  277. X    register struct monst *mtmp;
  278. X    register struct attack  *mattk;
  279. X{
  280. X    switch(mattk->adtyp) {
  281. X        case AD_STON:
  282. X        if (mtmp->mcan) {
  283. X            You("notice that %s isn't all that ugly.",mon_nam(mtmp));
  284. X           break;
  285. X        }
  286. X        if (canseemon(mtmp)) {
  287. X            You("look upon %s.", mon_nam(mtmp));
  288. X# ifdef POLYSELF
  289. X            if (resists_ston(uasmon)) {
  290. X                pline("So what?");
  291. X                break;
  292. X            }
  293. X            if(poly_when_stoned(uasmon) && polymon(PM_STONE_GOLEM))
  294. X                break;
  295. X# endif
  296. X            You("turn to stone...");
  297. X            killer_format = KILLED_BY_AN;
  298. X            killer = mons[PM_MEDUSA].mname;
  299. X            done(STONING);
  300. X            }
  301. X        break;
  302. X        case AD_CONF:
  303. X        if(!mtmp->mcan && canseemon(mtmp) && mtmp->mcansee && 
  304. X                    !mtmp->mspec_used && rn2(5)) {
  305. X            int conf = d(3,4);
  306. X
  307. X            mtmp->mspec_used = mtmp->mspec_used + (conf + rn2(6));
  308. X            if(!Confusion)
  309. X            pline("%s gaze confuses you!", 
  310. X                              s_suffix(Monnam(mtmp)));
  311. X            else
  312. X            You("are getting more and more confused.");
  313. X            make_confused(HConfusion + conf, FALSE);
  314. X        }
  315. X        break;
  316. X        case AD_STUN:
  317. X        if(!mtmp->mcan && canseemon(mtmp) && mtmp->mcansee &&
  318. X                    !mtmp->mspec_used && rn2(5)) {
  319. X            int stun = d(2,6);
  320. X
  321. X            pline("%s stares piercingly at you!", Monnam(mtmp));
  322. X            mtmp->mspec_used = mtmp->mspec_used + (stun + rn2(6));
  323. X            make_stunned(HStun + stun, TRUE);
  324. X        }
  325. X        break;
  326. X        case AD_BLND:
  327. X        if(!mtmp->mcan && canseemon(mtmp) && !defends(AD_BLND, uwep) &&
  328. X           distu(mtmp->mx,mtmp->my) <= BOLT_LIM*BOLT_LIM) {
  329. X            int blnd = d((int)mattk->damn, (int)mattk->damd);
  330. X            You("are blinded by %s radiance!", 
  331. X                          s_suffix(mon_nam(mtmp)));
  332. X            make_blinded((long)blnd,FALSE);
  333. X            make_stunned((long)d(1,3),TRUE);
  334. X        }
  335. X        break;
  336. X        default: impossible("Gaze attack %d?", mattk->adtyp);
  337. X        break;
  338. X    }
  339. X    return(1);
  340. X}
  341. X
  342. X#endif /* OVLB */
  343. X#ifdef OVL1
  344. X
  345. Xvoid
  346. Xmdamageu(mtmp, n)    /* mtmp hits you for n points damage */
  347. X    register struct monst *mtmp;
  348. X    register int n;
  349. X{
  350. X#ifdef POLYSELF
  351. X    if (u.mtimedone) {
  352. X        u.mh -= n;
  353. X        flags.botl = 1;
  354. X        if (u.mh < 1) rehumanize();
  355. X        return;
  356. X    }
  357. X#endif
  358. X    u.uhp -= n;
  359. X    flags.botl = 1;
  360. X    if(u.uhp < 1)
  361. X        done_in_by(mtmp);
  362. X}
  363. X
  364. X#endif /* OVL1 */
  365. X#ifdef OVLB
  366. X
  367. X#ifdef POLYSELF
  368. XSTATIC_OVL void
  369. Xurustm(mon, obj)
  370. Xregister struct monst *mon;
  371. Xregister struct obj *obj;
  372. X{
  373. X    boolean vis = cansee(mon->mx, mon->my);
  374. X
  375. X    if (!mon || !obj) return; /* just in case */
  376. X    if (u.umonnum == PM_RUST_MONSTER && 
  377. X        is_rustprone(obj) && obj->oeroded < MAX_ERODE) {
  378. X        if (obj->greased || obj->oerodeproof || (obj->blessed && rn2(3))) {
  379. X            if (vis)
  380. X            pline("Somehow, %s weapon is not affected.",
  381. X                        s_suffix(mon_nam(mon)));
  382. X            if (obj->greased && !rn2(2)) obj->greased = 0;
  383. X        } else {
  384. X            if (vis)
  385. X            pline("%s %s%s!",
  386. X                    s_suffix(Monnam(mon)), aobjnam(obj, "rust"),
  387. X                    obj->oeroded ? " further" : "");
  388. X            obj->oeroded++;
  389. X        }
  390. X    }
  391. X}
  392. X#endif
  393. X
  394. X#endif /* OVLB */
  395. X#ifdef OVL1
  396. X
  397. Xint
  398. Xcould_seduce(magr,mdef,mattk)
  399. Xstruct monst *magr, *mdef;
  400. Xstruct attack *mattk;
  401. X/* returns 0 if seduction impossible,
  402. X *       1 if fine,
  403. X *       2 if wrong gender for nymph */
  404. X{
  405. X    register struct permonst *pagr;
  406. X    boolean agrinvis, defperc;
  407. X    xchar genagr, gendef;
  408. X
  409. X    if(magr == &youmonst) {
  410. X        pagr = uasmon;
  411. X        agrinvis = (Invis != 0);
  412. X        genagr = poly_gender();
  413. X    } else {
  414. X        pagr = magr->data;
  415. X        agrinvis = magr->minvis;
  416. X        genagr = gender(magr);
  417. X    }
  418. X    if(mdef == &youmonst) {
  419. X        defperc = (See_invisible != 0);
  420. X        gendef = poly_gender();
  421. X    } else {
  422. X        defperc = perceives(mdef->data);
  423. X        gendef = gender(mdef);
  424. X    }
  425. X
  426. X    if(agrinvis && !defperc
  427. X#ifdef SEDUCE
  428. X        && mattk && mattk->adtyp != AD_SSEX
  429. X#endif
  430. X        )
  431. X        return 0;
  432. X
  433. X    if(pagr->mlet != S_NYMPH
  434. X        && ((pagr != &mons[PM_INCUBUS] && pagr != &mons[PM_SUCCUBUS])
  435. X#ifdef SEDUCE
  436. X            || (mattk && mattk->adtyp != AD_SSEX)
  437. X#endif
  438. X           ))
  439. X        return 0;
  440. X    
  441. X    if(genagr == 1 - gendef)
  442. X        return 1;
  443. X    else
  444. X        return (pagr->mlet == S_NYMPH) ? 2 : 0;
  445. X}
  446. X
  447. X#endif /* OVL1 */
  448. X#ifdef OVLB
  449. X
  450. X#ifdef SEDUCE
  451. X/* Returns 1 if monster teleported */
  452. Xint
  453. Xdoseduce(mon)
  454. Xregister struct monst *mon;
  455. X{
  456. X    register struct obj *ring;
  457. X    boolean fem = (mon->data == &mons[PM_SUCCUBUS]); /* otherwise incubus */
  458. X    char qbuf[QBUFSZ];
  459. X
  460. X    if (mon->mcan || mon->mspec_used) {
  461. X          pline("%s acts as though %s has got a %sheadache.",
  462. X              Monnam(mon), Blind ? "it" : fem ? "she" : "he",
  463. X            mon->mcan ? "severe " : "");
  464. X        return 0;
  465. X    }
  466. X
  467. X    if (unconscious()) {
  468. X        pline("%s seems dismayed at your lack of response.",
  469. X            Monnam(mon));
  470. X        return 0;
  471. X    }
  472. X
  473. X    if (Blind) pline("It caresses you...");
  474. X    else You("feel very attracted to %s.", mon_nam(mon));
  475. X
  476. X    for(ring = invent; ring; ring = ring->nobj) {
  477. X        if (ring->otyp != RIN_ADORNMENT) continue;
  478. X        if (fem) {
  479. X        if (rn2(20) < ACURR(A_CHA)) {
  480. X            Sprintf(qbuf, "\"That %s looks pretty.  May I have it?\"",
  481. X            xname(ring));
  482. X            makeknown(RIN_ADORNMENT);
  483. X            if (yn(qbuf) == 'n') continue;
  484. X        } else pline("%s decides she'd like your %s, and takes it.",
  485. X            Blind ? "She" : Monnam(mon), xname(ring));
  486. X        makeknown(RIN_ADORNMENT);
  487. X        if (ring==uleft || ring==uright) Ring_gone(ring);
  488. X        if (ring==uwep) setuwep((struct obj *)0);
  489. X        freeinv(ring);
  490. X        mpickobj(mon,ring);
  491. X        } else {
  492. X        char buf[BUFSZ];
  493. X
  494. X        if (uleft && uright && uleft->otyp == RIN_ADORNMENT
  495. X                && uright->otyp==RIN_ADORNMENT)
  496. X            break;
  497. X        if (ring==uleft || ring==uright) continue;
  498. X        if (rn2(20) < ACURR(A_CHA)) {
  499. X            Sprintf(qbuf,"\"That %s looks pretty.  Would you wear it for me?\"",
  500. X            xname(ring));
  501. X            makeknown(RIN_ADORNMENT);
  502. X            if (yn(qbuf) == 'n') continue;
  503. X        } else {
  504. X            pline("%s decides you'd look prettier wearing your %s,",
  505. X            Blind ? "He" : Monnam(mon), xname(ring));
  506. X            pline("and puts it on your finger.");
  507. X        }
  508. X        makeknown(RIN_ADORNMENT);
  509. X        if (!uright) {
  510. X            pline("%s puts %s on your right hand.",
  511. X            Blind ? "He" : Monnam(mon), the(xname(ring)));
  512. X            setworn(ring, RIGHT_RING);
  513. X        } else if (!uleft) {
  514. X            pline("%s puts %s on your left hand.",
  515. X            Blind ? "He" : Monnam(mon), the(xname(ring)));
  516. X            setworn(ring, LEFT_RING);
  517. X        } else if (uright && uright->otyp != RIN_ADORNMENT) {
  518. X            Strcpy(buf, xname(uright));
  519. X            pline("%s replaces your %s with your %s.",
  520. X            Blind ? "He" : Monnam(mon), buf, xname(ring));
  521. X            Ring_gone(uright);
  522. X            setworn(ring, RIGHT_RING);
  523. X        } else if (uleft && uleft->otyp != RIN_ADORNMENT) {
  524. X            Strcpy(buf, xname(uleft));
  525. X            pline("%s replaces your %s with your %s.",
  526. X            Blind ? "He" : Monnam(mon), buf, xname(ring));
  527. X            Ring_gone(uleft);
  528. X            setworn(ring, LEFT_RING);
  529. X        } else impossible("ring replacement");
  530. X        Ring_on(ring);
  531. X            prinv(NULL, ring, 0L);
  532. X        }
  533. X    }
  534. X
  535. X    if (!uarmc && !uarmf && !uarmg && !uarms && !uarmh
  536. X#ifdef TOURIST
  537. X                                && !uarmu
  538. X#endif
  539. X                                    )
  540. X        pline("%s murmurs sweet nothings into your ear.",
  541. X            Blind ? (fem ? "She" : "He") : Monnam(mon));
  542. X    else
  543. X        pline("%s murmurs in your ear, while helping you undress.",
  544. X            Blind ? (fem ? "She" : "He") : Monnam(mon));
  545. X    mayberem(uarmc, "cloak");
  546. X    if(!uarmc)
  547. X        mayberem(uarm, "suit");
  548. X    mayberem(uarmf, "boots");
  549. X    if(!uwep || !welded(uwep))
  550. X        mayberem(uarmg, "gloves");
  551. X    mayberem(uarms, "shield");
  552. X    mayberem(uarmh, "helmet");
  553. X#ifdef TOURIST
  554. X    if(!uarmc && !uarm)
  555. X        mayberem(uarmu, "shirt");
  556. X#endif
  557. X
  558. X    if (uarm || uarmc) {
  559. X        verbalize("You're such a %s; I wish...",
  560. X                flags.female ? "sweet lady" : "nice guy");
  561. X        rloc(mon);
  562. X        return 1;
  563. X    }
  564. X    if (u.ualign.type == A_CHAOTIC && u.ualign.record < ALIGNLIM)
  565. X        u.ualign.record++;
  566. X
  567. X    /* by this point you have discovered mon's identity, blind or not... */
  568. X    pline("Time stands still while you and %s lie in each other's arms...",
  569. X        mon_nam(mon));
  570. X    if (rn2(35) > ACURR(A_CHA) + ACURR(A_INT)) {
  571. X        /* Don't bother with mspec_used here... it didn't get tired! */
  572. X        pline("%s seems to have enjoyed it more than you...",
  573. X            Monnam(mon));
  574. X        switch (rn2(5)) {
  575. X            case 0: You("feel drained of energy.");
  576. X                u.uen = 0;
  577. X                u.uenmax -= rnd(Half_physical_damage ? 5 : 10);
  578. X                    exercise(A_CON, FALSE);
  579. X                if (u.uenmax < 0) u.uenmax = 0;
  580. X                break;
  581. X            case 1: You("are down in the dumps.");
  582. X                (void) adjattrib(A_CON, -1, TRUE);
  583. X                    exercise(A_CON, FALSE);
  584. X                flags.botl = 1;
  585. X                break;
  586. X            case 2: Your("senses are dulled.");
  587. X                (void) adjattrib(A_WIS, -1, TRUE);
  588. X                    exercise(A_WIS, FALSE);
  589. X                flags.botl = 1;
  590. X                break;
  591. X            case 3:
  592. X#ifdef POLYSELF
  593. X                if (resists_drli(uasmon))
  594. X                    You("have a curious feeling...");
  595. X                else {
  596. X#endif
  597. X                    You("feel out of shape.");
  598. X                    losexp();
  599. X                    if(u.uhp <= 0) {
  600. X                    killer_format = KILLED_BY;
  601. X                    killer = "overexertion";
  602. X                    done(DIED);
  603. X                    }
  604. X#ifdef POLYSELF
  605. X                }
  606. X#endif
  607. X                break;
  608. X            case 4: {
  609. X                int tmp;
  610. X                You("feel exhausted.");
  611. X                    exercise(A_STR, FALSE);
  612. X                tmp = rn1(10, 6);
  613. X                if(Half_physical_damage) tmp = (tmp+1) / 2;
  614. X                losehp(tmp, "exhaustion", KILLED_BY);
  615. X                break;
  616. X            }
  617. X        }
  618. X    } else {
  619. X        mon->mspec_used = rnd(100); /* monster is worn out */
  620. X        You("seem to have enjoyed it more than %s...", mon_nam(mon));
  621. X        switch (rn2(5)) {
  622. X            case 0: You("feel raised to your full potential.");
  623. X                    exercise(A_CON, TRUE);
  624. X                u.uen = (u.uenmax += rnd(5));
  625. X                break;
  626. X            case 1: You("feel good enough to do it again.");
  627. X                (void) adjattrib(A_CON, 1, TRUE);
  628. X                    exercise(A_CON, TRUE);
  629. X                flags.botl = 1;
  630. X                break;
  631. X            case 2: You("will always remember %s...", mon_nam(mon));
  632. X                (void) adjattrib(A_WIS, 1, TRUE);
  633. X                    exercise(A_WIS, TRUE);
  634. X                flags.botl = 1;
  635. X                break;
  636. X            case 3: pline("That was a very educational experience.");
  637. X                pluslvl();
  638. X                    exercise(A_WIS, TRUE);
  639. X                break;
  640. X            case 4: You("feel restored to health!");
  641. X                u.uhp = u.uhpmax;
  642. X#ifdef POLYSELF
  643. X                if (u.mtimedone) u.mh = u.mhmax;
  644. X#endif
  645. X                    exercise(A_STR, TRUE);
  646. X                flags.botl = 1;
  647. X                break;
  648. X        }
  649. X    }
  650. X
  651. X    if (mon->mtame) /* don't charge */ ;
  652. X    else if (rn2(20) < ACURR(A_CHA)) {
  653. X        pline("%s demands that you pay %s, but you refuse...",
  654. X            Monnam(mon), (fem ? "her" : "him"));
  655. X    }
  656. X#ifdef POLYSELF
  657. X    else if (u.umonnum == PM_LEPRECHAUN)
  658. X        pline("%s tries to take your money, but fails...",
  659. X                Monnam(mon));
  660. X#endif
  661. X    else {
  662. X        long cost;
  663. X
  664. X        if (u.ugold > (long)LARGEST_INT - 10L)
  665. X            cost = (long) rnd(LARGEST_INT) + 500L;
  666. X        else
  667. X            cost = (long) rnd((int)u.ugold + 10) + 500L;
  668. X        if (mon->mpeaceful) {
  669. X            cost /= 5L;
  670. X            if (!cost) cost = 1L;
  671. X        }
  672. X        if (cost > u.ugold) cost = u.ugold;
  673. X        if (!cost) verbalize("It's on the house!");
  674. X        else {
  675. X            pline("%s takes %ld zorkmid%s for services rendered!",
  676. X                Monnam(mon), cost, plur(cost));
  677. X            u.ugold -= cost;
  678. X            mon->mgold += cost;
  679. X            flags.botl = 1;
  680. X        }
  681. X    }
  682. X    if (!rn2(25)) mon->mcan = 1; /* monster is worn out */
  683. X    rloc(mon);
  684. X    return 1;
  685. X}
  686. X
  687. Xstatic void
  688. Xmayberem(obj, str)
  689. Xregister struct obj *obj;
  690. Xconst char *str;
  691. X{
  692. X    char qbuf[QBUFSZ];
  693. X
  694. X    if (!obj || !obj->owornmask) return;
  695. X
  696. X    if (rn2(20) < ACURR(A_CHA)) {
  697. X        Sprintf(qbuf,"\"Shall I remove your %s, %s?\"",
  698. X            str,
  699. X            (!rn2(2) ? "lover" : !rn2(2) ? "dear" : "sweetheart"));
  700. X        if (yn(qbuf) == 'n') return;
  701. X    } else verbalize("Take off your %s; %s.", str,
  702. X            (obj == uarm)  ? "let's get a little closer" :
  703. X            (obj == uarmc || obj == uarms) ? "it's in the way" :
  704. X            (obj == uarmf) ? "let me rub your feet" :
  705. X            (obj == uarmg) ? "they're too clumsy" :
  706. X#ifdef TOURIST
  707. X            (obj == uarmu) ? "let me massage you" :
  708. X#endif
  709. X            /* obj == uarmh */
  710. X            "let me run my fingers through your hair");
  711. X
  712. X    if (donning(obj)) cancel_don();
  713. X    if (obj == uarm)  (void) Armor_off();
  714. X    else if (obj == uarmc) (void) Cloak_off();
  715. X    else if (obj == uarmf) (void) Boots_off();
  716. X    else if (obj == uarmg) (void) Gloves_off();
  717. X    else if (obj == uarmh) (void) Helmet_off();
  718. X    else setworn((struct obj *)0, obj->owornmask & W_ARMOR);
  719. X}
  720. X#endif  /* SEDUCE */
  721. X
  722. X#endif /* OVLB */
  723. X
  724. X#ifdef POLYSELF
  725. X
  726. X#ifdef OVL1
  727. X
  728. Xstatic int
  729. Xpassiveum(olduasmon,mtmp,mattk)
  730. Xstruct permonst *olduasmon;
  731. Xregister struct monst *mtmp;
  732. Xregister struct attack *mattk;
  733. X{
  734. X    register struct permonst *mdat = mtmp->data;
  735. X    int i, tmp;
  736. X
  737. X    for(i = 0; ; i++) {
  738. X        if(i >= NATTK) return 1;
  739. X        if(olduasmon->mattk[i].aatyp == AT_NONE) break;
  740. X    }
  741. X    if (olduasmon->mattk[i].damn)
  742. X        tmp = d((int)olduasmon->mattk[i].damn, 
  743. X                                    (int)olduasmon->mattk[i].damd);
  744. X    else if(olduasmon->mattk[i].damd)
  745. X        tmp = d((int)olduasmon->mlevel+1, (int)olduasmon->mattk[i].damd);
  746. X    else
  747. X        tmp = 0;
  748. X
  749. X    /* These affect the enemy even if you were "killed" (rehumanized) */
  750. X    switch(olduasmon->mattk[i].adtyp) {
  751. X        case AD_ACID:
  752. X        if (!rn2(2)) {
  753. X            pline("%s is splashed by your acid!", Monnam(mtmp));
  754. X            if(resists_acid(mdat)) {
  755. X            pline("%s is not affected.", Monnam(mtmp));
  756. X            tmp = 0;
  757. X            }
  758. X        } else tmp = 0;
  759. X        goto assess_dmg;
  760. X        case AD_STON: /* cockatrice */
  761. X        if (!resists_ston(mdat) &&
  762. X#ifdef MUSE
  763. X            (mattk->aatyp != AT_WEAP || !MON_WEP(mtmp)) &&
  764. X#else
  765. X            (mattk->aatyp != AT_WEAP || !select_hwep(mtmp)) &&
  766. X#endif
  767. X            mattk->aatyp != AT_GAZE && mattk->aatyp != AT_EXPL &&
  768. X            mattk->aatyp != AT_MAGC &&
  769. X#ifdef MUSE
  770. X            (!which_armor(mtmp, W_ARMG))) {
  771. X#else
  772. X            (!is_mercenary(mdat) ||
  773. X                      !m_carrying(mtmp, LEATHER_GLOVES))) {
  774. X#endif
  775. X            if(poly_when_stoned(mdat)) {
  776. X            mon_to_stone(mtmp);
  777. X            return (1);
  778. X            }
  779. X            pline("%s turns to stone!", Monnam(mtmp));
  780. X            stoned = 1;
  781. X            xkilled(mtmp, 0);
  782. X            return 2;
  783. X        }
  784. X        return 1;
  785. X        default:
  786. X        break;
  787. X    }
  788. X    if (!u.mtimedone) return 1;
  789. X
  790. X    /* These affect the enemy only if you are still a monster */
  791. X    if (rn2(3)) switch(uasmon->mattk[i].adtyp) {
  792. X        case AD_PLYS: /* Floating eye */
  793. X        if (u.umonnum == PM_FLOATING_EYE) {
  794. X            if (!rn2(4)) tmp = 120;
  795. X            if (mtmp->mcansee && haseyes(mtmp->data) && rn2(3) &&
  796. X                (perceives(mdat) || !Invis)) {
  797. X            if (Blind)
  798. X                pline("As a blind %s, you cannot defend yourself.",
  799. X                            uasmon->mname);
  800. X                else {
  801. X                pline("%s is frozen by your gaze!", Monnam(mtmp));
  802. X                mtmp->mcanmove = 0;
  803. X                mtmp->mfrozen = tmp;
  804. X                return 3;
  805. X            }
  806. X            }
  807. X        } else { /* gelatinous cube */
  808. X            pline("%s is frozen by you.", Monnam(mtmp));
  809. X            mtmp->mcanmove = 0;
  810. X            mtmp->mfrozen = tmp;
  811. X            return 3;
  812. X        }
  813. X        return 1;
  814. X        case AD_COLD: /* Brown mold or blue jelly */
  815. X        if(resists_cold(mdat)) {
  816. X              shieldeff(mtmp->mx, mtmp->my);
  817. X            pline("%s is mildly chilly.", Monnam(mtmp));
  818. X            golemeffects(mtmp, AD_COLD, tmp);
  819. X            tmp = 0;
  820. X            break;
  821. X        }
  822. X        pline("%s is suddenly very cold!", Monnam(mtmp));
  823. X        u.mh += tmp / 2;
  824. X        if (u.mhmax < u.mh) u.mhmax = u.mh;
  825. X        if (u.mhmax > ((uasmon->mlevel+1) * 8)) {
  826. X            register struct monst *mon;
  827. X
  828. X            if ((mon = cloneu()) != 0) {
  829. X                mon->mhpmax = u.mhmax /= 2;
  830. X                You("multiply from %s heat!", 
  831. X                           s_suffix(mon_nam(mtmp)));
  832. X            }
  833. X        }
  834. X        break;
  835. X        case AD_STUN: /* Yellow mold */
  836. X        if (!mtmp->mstun) {
  837. X            mtmp->mstun = 1;
  838. X            pline("%s staggers.", Monnam(mtmp));
  839. X        }
  840. X        tmp = 0;
  841. X        break;
  842. X        case AD_FIRE: /* Red mold */
  843. X        if(resists_fire(mdat)) {
  844. X              shieldeff(mtmp->mx, mtmp->my);
  845. X            pline("%s is mildly warm.", Monnam(mtmp));
  846. X            golemeffects(mtmp, AD_FIRE, tmp);
  847. X            tmp = 0;
  848. X            break;
  849. X        }
  850. X        pline("%s is suddenly very hot!", Monnam(mtmp));
  851. X        break;
  852. X        case AD_ELEC:
  853. X        if(resists_elec(mdat)) {
  854. X              shieldeff(mtmp->mx, mtmp->my);
  855. X            pline("%s is slightly tingled.", Monnam(mtmp));
  856. X            golemeffects(mtmp, AD_ELEC, tmp);
  857. X            tmp = 0;
  858. X            break;
  859. X        }
  860. X        pline("%s is jolted with your electricity!", Monnam(mtmp));
  861. X        break;
  862. X        default: tmp = 0;
  863. X        break;
  864. X    }
  865. X    else tmp = 0;
  866. X
  867. X    assess_dmg:
  868. X    if((mtmp->mhp -= tmp) <= 0) {
  869. X        pline("%s dies!", Monnam(mtmp));
  870. X        xkilled(mtmp,0);
  871. X        return 2;
  872. X    }
  873. X    return 1;
  874. X}
  875. X
  876. X#endif /* OVL1 */
  877. X#ifdef OVLB
  878. X
  879. X#include "edog.h"
  880. Xstruct monst *
  881. Xcloneu()
  882. X{
  883. X    register struct monst *mon;
  884. X
  885. X    if (u.mh <= 1) return(struct monst *)0;
  886. X    if (uasmon->geno & G_EXTINCT) return(struct monst *)0;
  887. X    uasmon->pxlth += sizeof(struct edog);
  888. X    mon = makemon(uasmon, u.ux, u.uy);
  889. X    uasmon->pxlth -= sizeof(struct edog);
  890. X    mon = christen_monst(mon, plname);
  891. X    initedog(mon);
  892. X    mon->m_lev = uasmon->mlevel;
  893. X    mon->mhp = u.mh /= 2;
  894. X    mon->mhpmax = u.mhmax;
  895. X    return(mon);
  896. X}
  897. X
  898. X#endif /* OVLB */
  899. X
  900. X#endif /* POLYSELF */
  901. X
  902. X/*mhitu.c*/
  903. END_OF_FILE
  904. if test 21658 -ne `wc -c <'src/mhitu.c2'`; then
  905.     echo shar: \"'src/mhitu.c2'\" unpacked with wrong size!
  906. fi
  907. # end of 'src/mhitu.c2'
  908. fi
  909. if test -f 'sys/share/dgn_yacc.c' -a "${1}" != "-c" ; then 
  910.   echo shar: Will not clobber existing file \"'sys/share/dgn_yacc.c'\"
  911. else
  912. echo shar: Extracting \"'sys/share/dgn_yacc.c'\" \(32600 characters\)
  913. sed "s/^X//" >'sys/share/dgn_yacc.c' <<'END_OF_FILE'
  914. Xextern char *malloc(), *realloc();
  915. X
  916. X# line 2 "dgn_comp.y"
  917. X/*    SCCS Id: @(#)dgn_comp.c    3.1    93/01/17    */
  918. X/*    Copyright (c) 1989 by Jean-Christophe Collet */
  919. X/*    Copyright (c) 1990 by M. Stephenson                  */
  920. X/* NetHack may be freely redistributed.  See license for details. */
  921. X
  922. X/*
  923. X * This file contains the Dungeon Compiler code
  924. X */
  925. X
  926. X/* In case we're using bison in AIX.  This definition must be
  927. X * placed before any other C-language construct in the file
  928. X * excluding comments and preprocessor directives (thanks IBM
  929. X * for this wonderful feature...).
  930. X *
  931. X * Note: some cpps barf on this 'undefined control' (#pragma).
  932. X * Addition of the leading space seems to prevent barfage for now,
  933. X * and AIX will still see the directive in its non-standard locale.
  934. X */
  935. X
  936. X#ifdef _AIX
  937. X #pragma alloca        /* keep leading space! */
  938. X#endif
  939. X
  940. X#include "config.h"
  941. X#include "dgn_file.h"
  942. X
  943. Xvoid FDECL(yyerror, (char *));
  944. Xvoid FDECL(yywarning, (char *));
  945. Xint NDECL(yylex);
  946. Xint NDECL(yyparse);
  947. Xint FDECL(getchain, (char *));
  948. Xint NDECL(check_dungeon);
  949. Xint NDECL(check_branch);
  950. Xint NDECL(check_level);
  951. Xvoid NDECL(init_dungeon);
  952. Xvoid NDECL(init_branch);
  953. Xvoid NDECL(init_level);
  954. Xvoid NDECL(output_dgn);
  955. X
  956. X#ifdef AMIGA
  957. X# undef    printf
  958. X#ifndef    LATTICE
  959. X# define    memset(addr,val,len)    setmem(addr,len,val)
  960. X#endif
  961. X#endif
  962. X
  963. X#ifdef MICRO
  964. X# undef exit
  965. Xextern void FDECL(exit, (int));
  966. X#endif
  967. X
  968. X#undef NULL
  969. X
  970. X#define ERR        (-1)
  971. X
  972. Xstatic struct couple couple;
  973. Xstatic struct tmpdungeon tmpdungeon[MAXDUNGEON];
  974. Xstatic struct tmplevel tmplevel[LEV_LIMIT];
  975. Xstatic struct tmpbranch tmpbranch[BRANCH_LIMIT];
  976. X
  977. Xstatic int in_dungeon = 0, n_dgns = -1, n_levs = -1, n_brs = -1;
  978. X
  979. Xextern int fatal_error;
  980. Xextern char* fname;
  981. X
  982. X
  983. X# line 69 "dgn_comp.y"
  984. Xtypedef union 
  985. X{
  986. X    int    i;
  987. X    char*    str;
  988. X} YYSTYPE;
  989. X# define INTEGER 257
  990. X# define A_DUNGEON 258
  991. X# define BRANCH 259
  992. X# define CHBRANCH 260
  993. X# define LEVEL 261
  994. X# define RNDLEVEL 262
  995. X# define CHLEVEL 263
  996. X# define RNDCHLEVEL 264
  997. X# define UP_OR_DOWN 265
  998. X# define PROTOFILE 266
  999. X# define DESCRIPTION 267
  1000. X# define DESCRIPTOR 268
  1001. X# define LEVELDESC 269
  1002. X# define ALIGNMENT 270
  1003. X# define LEVALIGN 271
  1004. X# define ENTRY 272
  1005. X# define STAIR 273
  1006. X# define NO_UP 274
  1007. X# define NO_DOWN 275
  1008. X# define PORTAL 276
  1009. X# define STRING 277
  1010. X#define yyclearin yychar = -1
  1011. X#define yyerrok yyerrflag = 0
  1012. Xextern int yychar;
  1013. Xextern int yyerrflag;
  1014. X#ifndef YYMAXDEPTH
  1015. X#define YYMAXDEPTH 150
  1016. X#endif
  1017. XYYSTYPE yylval, yyval;
  1018. X# define YYERRCODE 256
  1019. X
  1020. X# line 450 "dgn_comp.y"
  1021. X
  1022. X
  1023. Xvoid
  1024. Xinit_dungeon()
  1025. X{
  1026. X    if(++n_dgns > MAXDUNGEON) {
  1027. X        fprintf(stderr, "FATAL - Too many dungeons (limit: %d).\n",
  1028. X            MAXDUNGEON);
  1029. X        fprintf(stderr, "To increase the limit edit MAXDUNGEON in global.h\n");
  1030. X        exit(1);
  1031. X    }
  1032. X
  1033. X    in_dungeon = 1;
  1034. X    tmpdungeon[n_dgns].lev.base = 0;
  1035. X    tmpdungeon[n_dgns].lev.rand = 0;
  1036. X    tmpdungeon[n_dgns].chance = 100;
  1037. X    strcpy(tmpdungeon[n_dgns].name, "");
  1038. X    strcpy(tmpdungeon[n_dgns].protoname, "");
  1039. X    tmpdungeon[n_dgns].flags = 0;
  1040. X    tmpdungeon[n_dgns].levels = 0;
  1041. X    tmpdungeon[n_dgns].branches = 0;
  1042. X    tmpdungeon[n_dgns].entry_lev = 0;
  1043. X}
  1044. X
  1045. Xvoid
  1046. Xinit_level()
  1047. X{
  1048. X    if(++n_levs > LEV_LIMIT) {
  1049. X
  1050. X        yyerror("FATAL - Too many special levels defined.");
  1051. X        exit(1);
  1052. X    }
  1053. X    tmplevel[n_levs].lev.base = 0;
  1054. X    tmplevel[n_levs].lev.rand = 0;
  1055. X    tmplevel[n_levs].chance = 100;
  1056. X    tmplevel[n_levs].rndlevs = 0;
  1057. X    tmplevel[n_levs].flags = 0;
  1058. X    strcpy(tmplevel[n_levs].name, "");
  1059. X    tmplevel[n_levs].chain = -1;
  1060. X}
  1061. X
  1062. Xvoid
  1063. Xinit_branch()
  1064. X{
  1065. X    if(++n_brs > BRANCH_LIMIT) {
  1066. X
  1067. X        yyerror("FATAL - Too many special levels defined.");
  1068. X        exit(1);
  1069. X    }
  1070. X    tmpbranch[n_brs].lev.base = 0;
  1071. X    tmpbranch[n_brs].lev.rand = 0;
  1072. X    strcpy(tmpbranch[n_brs].name, "");
  1073. X    tmpbranch[n_brs].chain = -1;
  1074. X}
  1075. X
  1076. Xint
  1077. Xgetchain(s)
  1078. X    char    *s;
  1079. X{
  1080. X    int i;
  1081. X
  1082. X    if(strlen(s)) {
  1083. X
  1084. X        for(i = n_levs - tmpdungeon[n_dgns].levels + 1; i <= n_levs; i++)
  1085. X        if(!strcmp(tmplevel[i].name, s)) return i;
  1086. X
  1087. X        yyerror("Can't locate the specified chain level.");
  1088. X        return(-2);
  1089. X    }
  1090. X    return(-1);
  1091. X}
  1092. X
  1093. X/*
  1094. X *    Consistancy checking routines:
  1095. X *
  1096. X *    - A dungeon must have a unique name.
  1097. X *    - A dungeon must have a originating "branch" command
  1098. X *      (except, of course, for the first dungeon).
  1099. X *    - A dungeon must have a proper depth (at least (1, 0)).
  1100. X */
  1101. X
  1102. Xint
  1103. Xcheck_dungeon()
  1104. X{
  1105. X    int i;
  1106. X
  1107. X    for(i = 0; i < n_dgns; i++)
  1108. X        if(!strcmp(tmpdungeon[i].name, tmpdungeon[n_dgns].name)) {
  1109. X        yyerror("Duplicate dungeon name.");
  1110. X        return(0);
  1111. X        }
  1112. X
  1113. X    if(n_dgns)
  1114. X      for(i = 0; i < n_brs - tmpdungeon[n_dgns].branches; i++) {
  1115. X        if(!strcmp(tmpbranch[i].name, tmpdungeon[n_dgns].name)) break;
  1116. X
  1117. X        if(i >= n_brs - tmpdungeon[n_dgns].branches) {
  1118. X        yyerror("Dungeon cannot be reached.");
  1119. X        return(0);
  1120. X        }
  1121. X      }
  1122. X
  1123. X    if(tmpdungeon[n_dgns].lev.base <= 0 ||
  1124. X       tmpdungeon[n_dgns].lev.rand < 0) {
  1125. X        yyerror("Invalid dungeon depth specified.");
  1126. X        return(0);
  1127. X    }
  1128. X    return(1);    /* OK */
  1129. X}
  1130. X
  1131. X/*
  1132. X *    - A level must have a unique level name.
  1133. X *    - If chained, the level used as reference for the chain
  1134. X *      must be in this dungeon, must be previously defined, and
  1135. X *      the level chained from must be "non-probabalistic" (ie.
  1136. X *      have a 100% chance of existing).
  1137. X */
  1138. X
  1139. Xint
  1140. Xcheck_level()
  1141. X{
  1142. X    int i;
  1143. X
  1144. X    if(!in_dungeon) {
  1145. X        yyerror("Level defined outside of dungeon.");
  1146. X        return(0);
  1147. X    }
  1148. X
  1149. X    for(i = 0; i < n_levs; i++)
  1150. X        if(!strcmp(tmplevel[i].name, tmplevel[n_levs].name)) {
  1151. X        yyerror("Duplicate level name.");
  1152. X        return(0);
  1153. X        }
  1154. X
  1155. X    if(tmplevel[i].chain == -2) {
  1156. X        yyerror("Invaild level chain reference.");
  1157. X        return(0);
  1158. X    } else if(tmplevel[i].chain != -1) {    /* there is a chain */
  1159. X        if(tmplevel[tmpbranch[i].chain].chance != 100) {
  1160. X        yyerror("Level cannot chain from a probabalistic level.");
  1161. X        return(0);
  1162. X        } else if(tmplevel[i].chain == n_levs) {
  1163. X        yyerror("A level cannot chain to itself!");
  1164. X        return(0);
  1165. X        }
  1166. X    }
  1167. X    return(1);    /* OK */
  1168. X}
  1169. X
  1170. X/*
  1171. X *    - A branch may not branch backwards - to avoid branch loops.
  1172. X *    - A branch name must be unique.
  1173. X *      (ie. You can only have one entry point to each dungeon).
  1174. X *    - If chained, the level used as reference for the chain
  1175. X *      must be in this dungeon, must be previously defined, and
  1176. X *      the level chained from must be "non-probabalistic" (ie.
  1177. X *      have a 100% chance of existing).
  1178. X */
  1179. X
  1180. Xint
  1181. Xcheck_branch()
  1182. X{
  1183. X    int i;
  1184. X
  1185. X    if(!in_dungeon) {
  1186. X        yyerror("Branch defined outside of dungeon.");
  1187. X        return(0);
  1188. X    }
  1189. X
  1190. X    for(i = 0; i < n_dgns; i++)
  1191. X        if(!strcmp(tmpdungeon[i].name, tmpbranch[n_brs].name)) {
  1192. X
  1193. X        yyerror("Reverse branching not allowed.");
  1194. X        return(0);
  1195. X        }
  1196. X
  1197. X    if(tmpbranch[i].chain == -2) {
  1198. X
  1199. X        yyerror("Invaild branch chain reference.");
  1200. X        return(0);
  1201. X    } else if(tmpbranch[i].chain != -1) {    /* it is chained */
  1202. X
  1203. X        if(tmplevel[tmpbranch[i].chain].chance != 100) {
  1204. X        yyerror("Branch cannot chain from a probabalistic level.");
  1205. X        return(0);
  1206. X        }
  1207. X    }
  1208. X    return(1);    /* OK */
  1209. X}
  1210. X
  1211. X/*
  1212. X *    Output the dungon definition into a file.
  1213. X *
  1214. X *    The file will have the following format:
  1215. X *
  1216. X *    [ number of dungeons ]
  1217. X *    [ first dungeon struct ]
  1218. X *    [ levels for the first dungeon ]
  1219. X *      ...
  1220. X *    [ branches for the first dungeon ]
  1221. X *      ...
  1222. X *    [ second dungeon struct ]
  1223. X *      ...
  1224. X */
  1225. X
  1226. Xvoid
  1227. Xoutput_dgn()
  1228. X{
  1229. X    int    nd, cl = 0, nl = 0,
  1230. X            cb = 0, nb = 0;
  1231. X
  1232. X    if(++n_dgns <= 0) {
  1233. X
  1234. X        yyerror("FATAL - no dungeons were defined.");
  1235. X        exit(1);
  1236. X    }
  1237. X
  1238. X    fwrite((char *)(&n_dgns), sizeof(int), 1, stdout);
  1239. X    for(nd = 0; nd < n_dgns; nd++) {
  1240. X
  1241. X        fwrite((char *)&tmpdungeon[nd], sizeof(struct tmpdungeon), 1,
  1242. X                                stdout);
  1243. X
  1244. X        nl += tmpdungeon[nd].levels;
  1245. X        for(; cl < nl; cl++)
  1246. X        fwrite((char *)&tmplevel[cl], sizeof(struct tmplevel), 1,
  1247. X                                stdout);
  1248. X
  1249. X        nb += tmpdungeon[nd].branches;
  1250. X        for(; cb < nb; cb++)
  1251. X        fwrite((char *)&tmpbranch[cb], sizeof(struct tmpbranch), 1,
  1252. X                                stdout);
  1253. X    }
  1254. X}
  1255. Xint yyexca[] ={
  1256. X-1, 1,
  1257. X    0, -1,
  1258. X    -2, 0,
  1259. X    };
  1260. X# define YYNPROD 48
  1261. X# define YYLAST 145
  1262. Xint yyact[]={
  1263. X
  1264. X     8,    22,    23,    24,    25,    28,    29,    74,    21,    30,
  1265. X    73,    26,    31,    27,    19,    65,    79,    80,    81,    82,
  1266. X   106,    64,    63,    62,    61,    59,    56,    55,    52,    51,
  1267. X    50,    49,    48,    46,    58,    57,    54,    53,    91,   103,
  1268. X   102,   101,    99,    98,    95,    94,    83,    77,    76,    47,
  1269. X    90,    66,    78,    68,    72,    71,    60,    45,    44,    43,
  1270. X    42,    41,    40,    39,    38,    37,    36,    35,    34,    33,
  1271. X    92,    89,    88,    87,    70,   105,   104,    67,    69,     3,
  1272. X    13,    12,    32,    18,    17,    16,    15,    14,    20,    11,
  1273. X    10,     9,     7,     6,     5,     4,     2,     1,    75,     0,
  1274. X     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  1275. X     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  1276. X     0,     0,    84,     0,     0,    85,    86,     0,     0,     0,
  1277. X     0,     0,     0,     0,     0,     0,     0,    93,     0,    96,
  1278. X    97,     0,     0,     0,   100 };
  1279. Xint yypact[]={
  1280. X
  1281. X  -258, -1000,  -258, -1000, -1000, -1000, -1000, -1000,    11, -1000,
  1282. X -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,    10,
  1283. X -1000,     9,     8,     7,     6,     5,     4,     3,     2,     1,
  1284. X     0,    -1, -1000,  -244,  -208,  -245,  -246,  -247,  -248,  -249,
  1285. X  -231,  -232,  -250,  -251,  -233,  -234,  -252, -1000, -1000,    -8,
  1286. X  -253,  -254,  -255, -1000, -1000,  -256,  -262, -1000, -1000,    37,
  1287. X    38,    31,    -9,   -10,  -267,  -270,  -209,  -210,  -257,  -211,
  1288. X    37,    38,    38,    30,    29, -1000, -1000,    27,  -227, -1000,
  1289. X -1000, -1000, -1000,    26,  -257,  -212,  -213,    37,    37,  -214,
  1290. X -1000, -1000,  -215,  -227, -1000,  -216,  -217,  -218,    35,    34,
  1291. X -1000, -1000, -1000,  -237, -1000, -1000, -1000 };
  1292. Xint yypgo[]={
  1293. X
  1294. X     0,    98,    50,    52,    97,    96,    79,    95,    94,    93,
  1295. X    92,    51,    91,    90,    89,    88,    87,    86,    85,    84,
  1296. X    83,    53,    81,    80 };
  1297. Xint yyr1[]={
  1298. X
  1299. X     0,     4,     4,     5,     5,     6,     6,     6,     6,     7,
  1300. X     1,     1,     8,     8,     8,    12,    13,    15,    15,    14,
  1301. X    10,    10,    10,    10,    10,    16,    16,    17,    17,    18,
  1302. X    18,    19,    19,    20,    20,     9,     9,    22,    23,     3,
  1303. X     3,     3,     3,     3,     2,     2,    21,    11 };
  1304. Xint yyr2[]={
  1305. X
  1306. X     0,     0,     3,     2,     4,     2,     2,     2,     2,    13,
  1307. X     1,     3,     2,     2,     2,     7,     2,     7,     7,     7,
  1308. X     2,     2,     2,     2,     2,    13,    15,    15,    17,     7,
  1309. X     7,    15,    17,    17,    19,     2,     2,    15,    17,     1,
  1310. X     3,     3,     3,     3,     1,     3,    11,    11 };
  1311. Xint yychk[]={
  1312. X
  1313. X -1000,    -4,    -5,    -6,    -7,    -8,    -9,   -10,   258,   -12,
  1314. X   -13,   -14,   -22,   -23,   -16,   -17,   -18,   -19,   -20,   272,
  1315. X   -15,   266,   259,   260,   261,   262,   269,   271,   263,   264,
  1316. X   267,   270,    -6,    58,    58,    58,    58,    58,    58,    58,
  1317. X    58,    58,    58,    58,    58,    58,   277,   257,   277,   277,
  1318. X   277,   277,   277,   268,   268,   277,   277,   268,   268,   277,
  1319. X    64,   277,   277,   277,   277,   277,   -11,    40,   -21,    40,
  1320. X    43,    64,    64,   277,   277,    -1,   257,   257,    -3,   273,
  1321. X   274,   275,   276,   257,   -11,   -21,   -21,    43,    43,    44,
  1322. X    -2,   265,    44,    -3,   257,   257,   -11,   -11,   257,   257,
  1323. X    -2,   257,   257,   257,    41,    41,   257 };
  1324. Xint yydef[]={
  1325. X
  1326. X     1,    -2,     2,     3,     5,     6,     7,     8,     0,    12,
  1327. X    13,    14,    35,    36,    20,    21,    22,    23,    24,     0,
  1328. X    16,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  1329. X     0,     0,     4,     0,     0,     0,     0,     0,     0,     0,
  1330. X     0,     0,     0,     0,     0,     0,     0,    15,    19,     0,
  1331. X     0,     0,     0,    29,    30,     0,     0,    17,    18,     0,
  1332. X     0,     0,     0,     0,     0,     0,    10,     0,    39,     0,
  1333. X     0,     0,     0,     0,     0,     9,    11,     0,    44,    40,
  1334. X    41,    42,    43,     0,    39,    25,     0,     0,     0,     0,
  1335. X    37,    45,     0,    44,    27,    26,    31,     0,     0,     0,
  1336. X    38,    28,    33,    32,    47,    46,    34 };
  1337. Xtypedef struct { char *t_name; int t_val; } yytoktype;
  1338. X#ifndef YYDEBUG
  1339. X#    define YYDEBUG    0    /* don't allow debugging */
  1340. X#endif
  1341. X
  1342. X#if YYDEBUG
  1343. X
  1344. Xyytoktype yytoks[] =
  1345. X{
  1346. X    "INTEGER",    257,
  1347. X    "A_DUNGEON",    258,
  1348. X    "BRANCH",    259,
  1349. X    "CHBRANCH",    260,
  1350. X    "LEVEL",    261,
  1351. X    "RNDLEVEL",    262,
  1352. X    "CHLEVEL",    263,
  1353. X    "RNDCHLEVEL",    264,
  1354. X    "UP_OR_DOWN",    265,
  1355. X    "PROTOFILE",    266,
  1356. X    "DESCRIPTION",    267,
  1357. X    "DESCRIPTOR",    268,
  1358. X    "LEVELDESC",    269,
  1359. X    "ALIGNMENT",    270,
  1360. X    "LEVALIGN",    271,
  1361. X    "ENTRY",    272,
  1362. X    "STAIR",    273,
  1363. X    "NO_UP",    274,
  1364. X    "NO_DOWN",    275,
  1365. X    "PORTAL",    276,
  1366. X    "STRING",    277,
  1367. X    "-unknown-",    -1    /* ends search */
  1368. X};
  1369. X
  1370. Xchar * yyreds[] =
  1371. X{
  1372. X    "-no such reduction-",
  1373. X    "file : /* empty */",
  1374. X    "file : dungeons",
  1375. X    "dungeons : dungeon",
  1376. X    "dungeons : dungeons dungeon",
  1377. X    "dungeon : dungeonline",
  1378. X    "dungeon : dungeondesc",
  1379. X    "dungeon : branches",
  1380. X    "dungeon : levels",
  1381. X    "dungeonline : A_DUNGEON ':' STRING STRING rcouple optional_int",
  1382. X    "optional_int : /* empty */",
  1383. X    "optional_int : INTEGER",
  1384. X    "dungeondesc : entry",
  1385. X    "dungeondesc : descriptions",
  1386. X    "dungeondesc : prototype",
  1387. X    "entry : ENTRY ':' INTEGER",
  1388. X    "descriptions : desc",
  1389. X    "desc : DESCRIPTION ':' DESCRIPTOR",
  1390. X    "desc : ALIGNMENT ':' DESCRIPTOR",
  1391. X    "prototype : PROTOFILE ':' STRING",
  1392. X    "levels : level1",
  1393. X    "levels : level2",
  1394. X    "levels : levdesc",
  1395. X    "levels : chlevel1",
  1396. X    "levels : chlevel2",
  1397. X    "level1 : LEVEL ':' STRING STRING '@' acouple",
  1398. X    "level1 : RNDLEVEL ':' STRING STRING '@' acouple INTEGER",
  1399. X    "level2 : LEVEL ':' STRING STRING '@' acouple INTEGER",
  1400. X    "level2 : RNDLEVEL ':' STRING STRING '@' acouple INTEGER INTEGER",
  1401. X    "levdesc : LEVELDESC ':' DESCRIPTOR",
  1402. X    "levdesc : LEVALIGN ':' DESCRIPTOR",
  1403. X    "chlevel1 : CHLEVEL ':' STRING STRING STRING '+' rcouple",
  1404. X    "chlevel1 : RNDCHLEVEL ':' STRING STRING STRING '+' rcouple INTEGER",
  1405. X    "chlevel2 : CHLEVEL ':' STRING STRING STRING '+' rcouple INTEGER",
  1406. X    "chlevel2 : RNDCHLEVEL ':' STRING STRING STRING '+' rcouple INTEGER INTEGER",
  1407. X    "branches : branch",
  1408. X    "branches : chbranch",
  1409. X    "branch : BRANCH ':' STRING '@' acouple branch_type direction",
  1410. X    "chbranch : CHBRANCH ':' STRING STRING '+' rcouple branch_type direction",
  1411. X    "branch_type : /* empty */",
  1412. X    "branch_type : STAIR",
  1413. X    "branch_type : NO_UP",
  1414. X    "branch_type : NO_DOWN",
  1415. X    "branch_type : PORTAL",
  1416. X    "direction : /* empty */",
  1417. X    "direction : UP_OR_DOWN",
  1418. X    "acouple : '(' INTEGER ',' INTEGER ')'",
  1419. X    "rcouple : '(' INTEGER ',' INTEGER ')'",
  1420. X};
  1421. X#endif /* YYDEBUG */
  1422. X#line 1 "/usr/lib/yaccpar"
  1423. X/*    @(#)yaccpar 1.10 89/04/04 SMI; from S5R3 1.10    */
  1424. X
  1425. X/*
  1426. X** Skeleton parser driver for yacc output
  1427. X*/
  1428. X
  1429. X/*
  1430. X** yacc user known macros and defines
  1431. X*/
  1432. X#define YYERROR        goto yyerrlab
  1433. X#define YYACCEPT    { free(yys); free(yyv); return(0); }
  1434. X#define YYABORT        { free(yys); free(yyv); return(1); }
  1435. X#define YYBACKUP( newtoken, newvalue )\
  1436. X{\
  1437. X    if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\
  1438. X    {\
  1439. X        yyerror( "syntax error - cannot backup" );\
  1440. X        goto yyerrlab;\
  1441. X    }\
  1442. X    yychar = newtoken;\
  1443. X    yystate = *yyps;\
  1444. X    yylval = newvalue;\
  1445. X    goto yynewstate;\
  1446. X}
  1447. X#define YYRECOVERING()    (!!yyerrflag)
  1448. X#ifndef YYDEBUG
  1449. X#    define YYDEBUG    1    /* make debugging available */
  1450. X#endif
  1451. X
  1452. X/*
  1453. X** user known globals
  1454. X*/
  1455. Xint yydebug;            /* set to 1 to get debugging */
  1456. X
  1457. X/*
  1458. X** driver internal defines
  1459. X*/
  1460. X#define YYFLAG        (-1000)
  1461. X
  1462. X/*
  1463. X** static variables used by the parser
  1464. X*/
  1465. Xstatic YYSTYPE *yyv;            /* value stack */
  1466. Xstatic int *yys;            /* state stack */
  1467. X
  1468. Xstatic YYSTYPE *yypv;            /* top of value stack */
  1469. Xstatic int *yyps;            /* top of state stack */
  1470. X
  1471. Xstatic int yystate;            /* current state */
  1472. Xstatic int yytmp;            /* extra var (lasts between blocks) */
  1473. X
  1474. Xint yynerrs;            /* number of errors */
  1475. X
  1476. Xint yyerrflag;            /* error recovery flag */
  1477. Xint yychar;            /* current input token number */
  1478. X
  1479. X
  1480. X/*
  1481. X** yyparse - return 0 if worked, 1 if syntax error not recovered from
  1482. X*/
  1483. Xint
  1484. Xyyparse()
  1485. X{
  1486. X    register YYSTYPE *yypvt;    /* top of value stack for $vars */
  1487. X    unsigned yymaxdepth = YYMAXDEPTH;
  1488. X
  1489. X    /*
  1490. X    ** Initialize externals - yyparse may be called more than once
  1491. X    */
  1492. X    yyv = (YYSTYPE*)malloc(yymaxdepth*sizeof(YYSTYPE));
  1493. X    yys = (int*)malloc(yymaxdepth*sizeof(int));
  1494. X    if (!yyv || !yys)
  1495. X    {
  1496. X        yyerror( "out of memory" );
  1497. X        return(1);
  1498. X    }
  1499. X    yypv = &yyv[-1];
  1500. X    yyps = &yys[-1];
  1501. X    yystate = 0;
  1502. X    yytmp = 0;
  1503. X    yynerrs = 0;
  1504. X    yyerrflag = 0;
  1505. X    yychar = -1;
  1506. X
  1507. X    goto yystack;
  1508. X    {
  1509. X        register YYSTYPE *yy_pv;    /* top of value stack */
  1510. X        register int *yy_ps;        /* top of state stack */
  1511. X        register int yy_state;        /* current state */
  1512. X        register int  yy_n;        /* internal state number info */
  1513. X
  1514. X        /*
  1515. X        ** get globals into registers.
  1516. X        ** branch to here only if YYBACKUP was called.
  1517. X        */
  1518. X    yynewstate:
  1519. X        yy_pv = yypv;
  1520. X        yy_ps = yyps;
  1521. X        yy_state = yystate;
  1522. X        goto yy_newstate;
  1523. X
  1524. X        /*
  1525. X        ** get globals into registers.
  1526. X        ** either we just started, or we just finished a reduction
  1527. X        */
  1528. X    yystack:
  1529. X        yy_pv = yypv;
  1530. X        yy_ps = yyps;
  1531. X        yy_state = yystate;
  1532. X
  1533. X        /*
  1534. X        ** top of for (;;) loop while no reductions done
  1535. X        */
  1536. X    yy_stack:
  1537. X        /*
  1538. X        ** put a state and value onto the stacks
  1539. X        */
  1540. X#if YYDEBUG
  1541. X        /*
  1542. X        ** if debugging, look up token value in list of value vs.
  1543. X        ** name pairs.  0 and negative (-1) are special values.
  1544. X        ** Note: linear search is used since time is not a real
  1545. X        ** consideration while debugging.
  1546. X        */
  1547. X        if ( yydebug )
  1548. X        {
  1549. X            register int yy_i;
  1550. X
  1551. X            (void)printf( "State %d, token ", yy_state );
  1552. X            if ( yychar == 0 )
  1553. X                (void)printf( "end-of-file\n" );
  1554. X            else if ( yychar < 0 )
  1555. X                (void)printf( "-none-\n" );
  1556. X            else
  1557. X            {
  1558. X                for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
  1559. X                    yy_i++ )
  1560. X                {
  1561. X                    if ( yytoks[yy_i].t_val == yychar )
  1562. X                        break;
  1563. X                }
  1564. X                (void)printf( "%s\n", yytoks[yy_i].t_name );
  1565. X            }
  1566. X        }
  1567. X#endif /* YYDEBUG */
  1568. X        if ( ++yy_ps >= &yys[ yymaxdepth ] )    /* room on stack? */
  1569. X        {
  1570. X            /*
  1571. X            ** reallocate and recover.  Note that pointers
  1572. X            ** have to be reset, or bad things will happen
  1573. X            */
  1574. X            int yyps_index = (yy_ps - yys);
  1575. X            int yypv_index = (yy_pv - yyv);
  1576. X            int yypvt_index = (yypvt - yyv);
  1577. X            yymaxdepth += YYMAXDEPTH;
  1578. X            yyv = (YYSTYPE*)realloc((char*)yyv,
  1579. X                yymaxdepth * sizeof(YYSTYPE));
  1580. X            yys = (int*)realloc((char*)yys,
  1581. X                yymaxdepth * sizeof(int));
  1582. X            if (!yyv || !yys)
  1583. X            {
  1584. X                yyerror( "yacc stack overflow" );
  1585. X                return(1);
  1586. X            }
  1587. X            yy_ps = yys + yyps_index;
  1588. X            yy_pv = yyv + yypv_index;
  1589. X            yypvt = yyv + yypvt_index;
  1590. X        }
  1591. X        *yy_ps = yy_state;
  1592. X        *++yy_pv = yyval;
  1593. X
  1594. X        /*
  1595. X        ** we have a new state - find out what to do
  1596. X        */
  1597. X    yy_newstate:
  1598. X        if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG )
  1599. X            goto yydefault;        /* simple state */
  1600. X#if YYDEBUG
  1601. X        /*
  1602. X        ** if debugging, need to mark whether new token grabbed
  1603. X        */
  1604. X        yytmp = yychar < 0;
  1605. X#endif
  1606. X        if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) )
  1607. X            yychar = 0;        /* reached EOF */
  1608. X#if YYDEBUG
  1609. X        if ( yydebug && yytmp )
  1610. X        {
  1611. X            register int yy_i;
  1612. X
  1613. X            (void)printf( "Received token " );
  1614. X            if ( yychar == 0 )
  1615. X                (void)printf( "end-of-file\n" );
  1616. X            else if ( yychar < 0 )
  1617. X                (void)printf( "-none-\n" );
  1618. X            else
  1619. X            {
  1620. X                for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
  1621. X                    yy_i++ )
  1622. X                {
  1623. X                    if ( yytoks[yy_i].t_val == yychar )
  1624. X                        break;
  1625. X                }
  1626. X                (void)printf( "%s\n", yytoks[yy_i].t_name );
  1627. X            }
  1628. X        }
  1629. X#endif /* YYDEBUG */
  1630. X        if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) )
  1631. X            goto yydefault;
  1632. X        if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar )    /*valid shift*/
  1633. X        {
  1634. X            yychar = -1;
  1635. X            yyval = yylval;
  1636. X            yy_state = yy_n;
  1637. X            if ( yyerrflag > 0 )
  1638. X                yyerrflag--;
  1639. X            goto yy_stack;
  1640. X        }
  1641. X
  1642. X    yydefault:
  1643. X        if ( ( yy_n = yydef[ yy_state ] ) == -2 )
  1644. X        {
  1645. X#if YYDEBUG
  1646. X            yytmp = yychar < 0;
  1647. X#endif
  1648. X            if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) )
  1649. X                yychar = 0;        /* reached EOF */
  1650. X#if YYDEBUG
  1651. X            if ( yydebug && yytmp )
  1652. X            {
  1653. X                register int yy_i;
  1654. X
  1655. X                (void)printf( "Received token " );
  1656. X                if ( yychar == 0 )
  1657. X                    (void)printf( "end-of-file\n" );
  1658. X                else if ( yychar < 0 )
  1659. X                    (void)printf( "-none-\n" );
  1660. X                else
  1661. X                {
  1662. X                    for ( yy_i = 0;
  1663. X                        yytoks[yy_i].t_val >= 0;
  1664. X                        yy_i++ )
  1665. X                    {
  1666. X                        if ( yytoks[yy_i].t_val
  1667. X                            == yychar )
  1668. X                        {
  1669. X                            break;
  1670. X                        }
  1671. X                    }
  1672. X                    (void)printf( "%s\n", yytoks[yy_i].t_name );
  1673. X                }
  1674. X            }
  1675. X#endif /* YYDEBUG */
  1676. X            /*
  1677. X            ** look through exception table
  1678. X            */
  1679. X            {
  1680. X                register int *yyxi = yyexca;
  1681. X
  1682. X                while ( ( *yyxi != -1 ) ||
  1683. X                    ( yyxi[1] != yy_state ) )
  1684. X                {
  1685. X                    yyxi += 2;
  1686. X                }
  1687. X                while ( ( *(yyxi += 2) >= 0 ) &&
  1688. X                    ( *yyxi != yychar ) )
  1689. X                    ;
  1690. X                if ( ( yy_n = yyxi[1] ) < 0 )
  1691. X                    YYACCEPT;
  1692. X            }
  1693. X        }
  1694. X
  1695. X        /*
  1696. X        ** check for syntax error
  1697. X        */
  1698. X        if ( yy_n == 0 )    /* have an error */
  1699. X        {
  1700. X            /* no worry about speed here! */
  1701. X            switch ( yyerrflag )
  1702. X            {
  1703. X            case 0:        /* new error */
  1704. X                yyerror( "syntax error" );
  1705. X                goto skip_init;
  1706. X            yyerrlab:
  1707. X                /*
  1708. X                ** get globals into registers.
  1709. X                ** we have a user generated syntax type error
  1710. X                */
  1711. X                yy_pv = yypv;
  1712. X                yy_ps = yyps;
  1713. X                yy_state = yystate;
  1714. X                yynerrs++;
  1715. X            skip_init:
  1716. X            case 1:
  1717. X            case 2:        /* incompletely recovered error */
  1718. X                    /* try again... */
  1719. X                yyerrflag = 3;
  1720. X                /*
  1721. X                ** find state where "error" is a legal
  1722. X                ** shift action
  1723. X                */
  1724. X                while ( yy_ps >= yys )
  1725. X                {
  1726. X                    yy_n = yypact[ *yy_ps ] + YYERRCODE;
  1727. X                    if ( yy_n >= 0 && yy_n < YYLAST &&
  1728. X                        yychk[yyact[yy_n]] == YYERRCODE)                    {
  1729. X                        /*
  1730. X                        ** simulate shift of "error"
  1731. X                        */
  1732. X                        yy_state = yyact[ yy_n ];
  1733. X                        goto yy_stack;
  1734. X                    }
  1735. X                    /*
  1736. X                    ** current state has no shift on
  1737. X                    ** "error", pop stack
  1738. X                    */
  1739. X#if YYDEBUG
  1740. X#    define _POP_ "Error recovery pops state %d, uncovers state %d\n"
  1741. X                    if ( yydebug )
  1742. X                        (void)printf( _POP_, *yy_ps,
  1743. X                            yy_ps[-1] );
  1744. X#    undef _POP_
  1745. X#endif
  1746. X                    yy_ps--;
  1747. X                    yy_pv--;
  1748. X                }
  1749. X                /*
  1750. X                ** there is no state on stack with "error" as
  1751. X                ** a valid shift.  give up.
  1752. X                */
  1753. X                YYABORT;
  1754. X            case 3:        /* no shift yet; eat a token */
  1755. X#if YYDEBUG
  1756. X                /*
  1757. X                ** if debugging, look up token in list of
  1758. X                ** pairs.  0 and negative shouldn't occur,
  1759. X                ** but since timing doesn't matter when
  1760. X                ** debugging, it doesn't hurt to leave the
  1761. X                ** tests here.
  1762. X                */
  1763. X                if ( yydebug )
  1764. X                {
  1765. X                    register int yy_i;
  1766. X
  1767. X                    (void)printf( "Error recovery discards " );
  1768. X                    if ( yychar == 0 )
  1769. X                        (void)printf( "token end-of-file\n" );
  1770. X                    else if ( yychar < 0 )
  1771. X                        (void)printf( "token -none-\n" );
  1772. X                    else
  1773. X                    {
  1774. X                        for ( yy_i = 0;
  1775. X                            yytoks[yy_i].t_val >= 0;
  1776. X                            yy_i++ )
  1777. X                        {
  1778. X                            if ( yytoks[yy_i].t_val
  1779. X                                == yychar )
  1780. X                            {
  1781. X                                break;
  1782. X                            }
  1783. X                        }
  1784. X                        (void)printf( "token %s\n",
  1785. X                            yytoks[yy_i].t_name );
  1786. X                    }
  1787. X                }
  1788. X#endif /* YYDEBUG */
  1789. X                if ( yychar == 0 )    /* reached EOF. quit */
  1790. X                    YYABORT;
  1791. X                yychar = -1;
  1792. X                goto yy_newstate;
  1793. X            }
  1794. X        }/* end if ( yy_n == 0 ) */
  1795. X        /*
  1796. X        ** reduction by production yy_n
  1797. X        ** put stack tops, etc. so things right after switch
  1798. X        */
  1799. X#if YYDEBUG
  1800. X        /*
  1801. X        ** if debugging, print the string that is the user's
  1802. X        ** specification of the reduction which is just about
  1803. X        ** to be done.
  1804. X        */
  1805. X        if ( yydebug )
  1806. X            (void)printf( "Reduce by (%d) \"%s\"\n",
  1807. X                yy_n, yyreds[ yy_n ] );
  1808. X#endif
  1809. X        yytmp = yy_n;            /* value to switch over */
  1810. X        yypvt = yy_pv;            /* $vars top of value stack */
  1811. X        /*
  1812. X        ** Look in goto table for next state
  1813. X        ** Sorry about using yy_state here as temporary
  1814. X        ** register variable, but why not, if it works...
  1815. X        ** If yyr2[ yy_n ] doesn't have the low order bit
  1816. X        ** set, then there is no action to be done for
  1817. X        ** this reduction.  So, no saving & unsaving of
  1818. X        ** registers done.  The only difference between the
  1819. X        ** code just after the if and the body of the if is
  1820. X        ** the goto yy_stack in the body.  This way the test
  1821. X        ** can be made before the choice of what to do is needed.
  1822. X        */
  1823. X        {
  1824. X            /* length of production doubled with extra bit */
  1825. X            register int yy_len = yyr2[ yy_n ];
  1826. X
  1827. X            if ( !( yy_len & 01 ) )
  1828. X            {
  1829. X                yy_len >>= 1;
  1830. X                yyval = ( yy_pv -= yy_len )[1];    /* $$ = $1 */
  1831. X                yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
  1832. X                    *( yy_ps -= yy_len ) + 1;
  1833. X                if ( yy_state >= YYLAST ||
  1834. X                    yychk[ yy_state =
  1835. X                    yyact[ yy_state ] ] != -yy_n )
  1836. X                {
  1837. X                    yy_state = yyact[ yypgo[ yy_n ] ];
  1838. X                }
  1839. X                goto yy_stack;
  1840. X            }
  1841. X            yy_len >>= 1;
  1842. X            yyval = ( yy_pv -= yy_len )[1];    /* $$ = $1 */
  1843. X            yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
  1844. X                *( yy_ps -= yy_len ) + 1;
  1845. X            if ( yy_state >= YYLAST ||
  1846. X                yychk[ yy_state = yyact[ yy_state ] ] != -yy_n )
  1847. X            {
  1848. X                yy_state = yyact[ yypgo[ yy_n ] ];
  1849. X            }
  1850. X        }
  1851. X                    /* save until reenter driver code */
  1852. X        yystate = yy_state;
  1853. X        yyps = yy_ps;
  1854. X        yypv = yy_pv;
  1855. X    }
  1856. X    /*
  1857. X    ** code supplied by user is placed in this switch
  1858. X    */
  1859. X    switch( yytmp )
  1860. X    {
  1861. X        
  1862. Xcase 2:
  1863. X# line 86 "dgn_comp.y"
  1864. X{
  1865. X            output_dgn();
  1866. X          } break;
  1867. Xcase 9:
  1868. X# line 102 "dgn_comp.y"
  1869. X{
  1870. X            init_dungeon();
  1871. X            strcpy(tmpdungeon[n_dgns].name, yypvt[-3].str);
  1872. X            if (!strcmp(yypvt[-2].str, "none"))
  1873. X                tmpdungeon[n_levs].boneschar = '\0';
  1874. X            else if (yypvt[-2].str[1])
  1875. X                yyerror("Bones marker must be a single char, or \"none\"!");
  1876. X            else
  1877. X                tmpdungeon[n_dgns].boneschar = yypvt[-2].str[0];
  1878. X            tmpdungeon[n_dgns].lev.base = couple.base;
  1879. X            tmpdungeon[n_dgns].lev.rand = couple.rand;
  1880. X            tmpdungeon[n_dgns].chance = yypvt[-0].i;
  1881. X          } break;
  1882. Xcase 10:
  1883. X# line 118 "dgn_comp.y"
  1884. X{
  1885. X            yyval.i = 0;
  1886. X          } break;
  1887. Xcase 11:
  1888. X# line 122 "dgn_comp.y"
  1889. X{
  1890. X            yyval.i = yypvt[-0].i;
  1891. X          } break;
  1892. Xcase 15:
  1893. X# line 133 "dgn_comp.y"
  1894. X{
  1895. X            tmpdungeon[n_dgns].entry_lev = yypvt[-0].i;
  1896. X          } break;
  1897. Xcase 17:
  1898. X# line 142 "dgn_comp.y"
  1899. X{
  1900. X            if(yypvt[-0].i <= TOWN || yypvt[-0].i >= D_ALIGN_CHAOTIC)
  1901. X                yyerror("Illegal description - ignoring!");
  1902. X            else
  1903. X                tmpdungeon[n_dgns].flags |= yypvt[-0].i ;
  1904. X          } break;
  1905. Xcase 18:
  1906. X# line 149 "dgn_comp.y"
  1907. X{
  1908. X            if(yypvt[-0].i && yypvt[-0].i < D_ALIGN_CHAOTIC)
  1909. X                yyerror("Illegal alignment - ignoring!");
  1910. X            else
  1911. X                tmpdungeon[n_dgns].flags |= yypvt[-0].i ;
  1912. X          } break;
  1913. Xcase 19:
  1914. X# line 158 "dgn_comp.y"
  1915. X{
  1916. X            strcpy(tmpdungeon[n_dgns].protoname, yypvt[-0].str);
  1917. X          } break;
  1918. Xcase 25:
  1919. X# line 171 "dgn_comp.y"
  1920. X{
  1921. X            init_level();
  1922. X            strcpy(tmplevel[n_levs].name, yypvt[-3].str);
  1923. X            if (!strcmp(yypvt[-2].str, "none"))
  1924. X                tmplevel[n_levs].boneschar = '\0';
  1925. X            else if (yypvt[-2].str[1])
  1926. X                yyerror("Bones marker must be a single char, or \"none\"!");
  1927. X            else
  1928. X                tmplevel[n_levs].boneschar = yypvt[-2].str[0];
  1929. X            tmplevel[n_levs].lev.base = couple.base;
  1930. X            tmplevel[n_levs].lev.rand = couple.rand;
  1931. X            tmpdungeon[n_dgns].levels++;
  1932. X          } break;
  1933. Xcase 26:
  1934. X# line 185 "dgn_comp.y"
  1935. X{
  1936. X            init_level();
  1937. X            strcpy(tmplevel[n_levs].name, yypvt[-4].str);
  1938. X            if (!strcmp(yypvt[-3].str, "none"))
  1939. X                tmplevel[n_levs].boneschar = '\0';
  1940. X            else if (yypvt[-3].str[1])
  1941. X                yyerror("Bones marker must be a single char, or \"none\"!");
  1942. X            else
  1943. X                tmplevel[n_levs].boneschar = yypvt[-3].str[0];
  1944. X            tmplevel[n_levs].lev.base = couple.base;
  1945. X            tmplevel[n_levs].lev.rand = couple.rand;
  1946. X            tmplevel[n_levs].rndlevs = yypvt[-0].i;
  1947. X            tmpdungeon[n_dgns].levels++;
  1948. X          } break;
  1949. Xcase 27:
  1950. X# line 202 "dgn_comp.y"
  1951. X{
  1952. X            init_level();
  1953. X            strcpy(tmplevel[n_levs].name, yypvt[-4].str);
  1954. X            if (!strcmp(yypvt[-3].str, "none"))
  1955. X                tmplevel[n_levs].boneschar = '\0';
  1956. X            else if (yypvt[-3].str[1])
  1957. X                yyerror("Bones marker must be a single char, or \"none\"!");
  1958. X            else
  1959. X                tmplevel[n_levs].boneschar = yypvt[-3].str[0];
  1960. X            tmplevel[n_levs].lev.base = couple.base;
  1961. X            tmplevel[n_levs].lev.rand = couple.rand;
  1962. X            tmplevel[n_levs].chance = yypvt[-0].i;
  1963. X            tmpdungeon[n_dgns].levels++;
  1964. X          } break;
  1965. Xcase 28:
  1966. X# line 217 "dgn_comp.y"
  1967. X{
  1968. X            init_level();
  1969. X            strcpy(tmplevel[n_levs].name, yypvt[-5].str);
  1970. X            if (!strcmp(yypvt[-4].str, "none"))
  1971. X                tmplevel[n_levs].boneschar = '\0';
  1972. X            else if (yypvt[-4].str[1])
  1973. X                yyerror("Bones marker must be a single char, or \"none\"!");
  1974. X            else
  1975. X                tmplevel[n_levs].boneschar = yypvt[-4].str[0];
  1976. X            tmplevel[n_levs].lev.base = couple.base;
  1977. X            tmplevel[n_levs].lev.rand = couple.rand;
  1978. X            tmplevel[n_levs].chance = yypvt[-1].i;
  1979. X            tmplevel[n_levs].rndlevs = yypvt[-0].i;
  1980. X            tmpdungeon[n_dgns].levels++;
  1981. X          } break;
  1982. Xcase 29:
  1983. X# line 235 "dgn_comp.y"
  1984. X{
  1985. X            if(yypvt[-0].i >= D_ALIGN_CHAOTIC)
  1986. X                yyerror("Illegal description - ignoring!");
  1987. X            else
  1988. X                tmplevel[n_levs].flags |= yypvt[-0].i ;
  1989. X          } break;
  1990. Xcase 30:
  1991. X# line 242 "dgn_comp.y"
  1992. X{
  1993. X            if(yypvt[-0].i && yypvt[-0].i < D_ALIGN_CHAOTIC)
  1994. X                yyerror("Illegal alignment - ignoring!");
  1995. X            else
  1996. X                tmplevel[n_levs].flags |= yypvt[-0].i ;
  1997. X          } break;
  1998. Xcase 31:
  1999. X# line 251 "dgn_comp.y"
  2000. X{
  2001. X            init_level();
  2002. X            strcpy(tmplevel[n_levs].name, yypvt[-4].str);
  2003. X            if (!strcmp(yypvt[-3].str, "none"))
  2004. X                tmplevel[n_levs].boneschar = '\0';
  2005. X            else if (yypvt[-3].str[1])
  2006. X                yyerror("Bones marker must be a single char, or \"none\"!");
  2007. X            else
  2008. X                tmplevel[n_levs].boneschar = yypvt[-3].str[0];
  2009. X            tmplevel[n_levs].chain = getchain(yypvt[-2].str);
  2010. X            tmplevel[n_levs].lev.base = couple.base;
  2011. X            tmplevel[n_levs].lev.rand = couple.rand;
  2012. X            if(!check_level()) n_levs--;
  2013. X            else tmpdungeon[n_dgns].levels++;
  2014. X          } break;
  2015. Xcase 32:
  2016. X# line 267 "dgn_comp.y"
  2017. X{
  2018. X            init_level();
  2019. X            strcpy(tmplevel[n_levs].name, yypvt[-5].str);
  2020. X            if (!strcmp(yypvt[-4].str, "none"))
  2021. X                tmplevel[n_levs].boneschar = '\0';
  2022. X            else if (yypvt[-4].str[1])
  2023. X                yyerror("Bones marker must be a single char, or \"none\"!");
  2024. X            else
  2025. X                tmplevel[n_levs].boneschar = yypvt[-4].str[0];
  2026. X            tmplevel[n_levs].chain = getchain(yypvt[-3].str);
  2027. X            tmplevel[n_levs].lev.base = couple.base;
  2028. X            tmplevel[n_levs].lev.rand = couple.rand;
  2029. X            tmplevel[n_levs].rndlevs = yypvt[-0].i;
  2030. X            if(!check_level()) n_levs--;
  2031. X            else tmpdungeon[n_dgns].levels++;
  2032. X          } break;
  2033. Xcase 33:
  2034. X# line 286 "dgn_comp.y"
  2035. X{
  2036. X            init_level();
  2037. X            strcpy(tmplevel[n_levs].name, yypvt[-5].str);
  2038. X            if (!strcmp(yypvt[-4].str, "none"))
  2039. X                tmplevel[n_levs].boneschar = '\0';
  2040. X            else if (yypvt[-4].str[1])
  2041. X                yyerror("Bones marker must be a single char, or \"none\"!");
  2042. X            else
  2043. X                tmplevel[n_levs].boneschar = yypvt[-4].str[0];
  2044. X            tmplevel[n_levs].chain = getchain(yypvt[-3].str);
  2045. X            tmplevel[n_levs].lev.base = couple.base;
  2046. X            tmplevel[n_levs].lev.rand = couple.rand;
  2047. X            tmplevel[n_levs].chance = yypvt[-0].i;
  2048. X            if(!check_level()) n_levs--;
  2049. X            else tmpdungeon[n_dgns].levels++;
  2050. X          } break;
  2051. Xcase 34:
  2052. X# line 303 "dgn_comp.y"
  2053. X{
  2054. X            init_level();
  2055. X            strcpy(tmplevel[n_levs].name, yypvt[-6].str);
  2056. X            if (!strcmp(yypvt[-5].str, "none"))
  2057. X                tmplevel[n_levs].boneschar = '\0';
  2058. X            else if (yypvt[-5].str[1])
  2059. X                yyerror("Bones marker must be a single char, or \"none\"!");
  2060. X            else
  2061. X                tmplevel[n_levs].boneschar = yypvt[-5].str[0];
  2062. X            tmplevel[n_levs].chain = getchain(yypvt[-4].str);
  2063. X            tmplevel[n_levs].lev.base = couple.base;
  2064. X            tmplevel[n_levs].lev.rand = couple.rand;
  2065. X            tmplevel[n_levs].chance = yypvt[-1].i;
  2066. X            tmplevel[n_levs].rndlevs = yypvt[-0].i;
  2067. X            if(!check_level()) n_levs--;
  2068. X            else tmpdungeon[n_dgns].levels++;
  2069. X          } break;
  2070. Xcase 37:
  2071. X# line 327 "dgn_comp.y"
  2072. X{
  2073. X            init_branch();
  2074. X            strcpy(tmpbranch[n_brs].name, yypvt[-4].str);
  2075. X            tmpbranch[n_brs].lev.base = couple.base;
  2076. X            tmpbranch[n_brs].lev.rand = couple.rand;
  2077. X            tmpbranch[n_brs].type = yypvt[-1].i;
  2078. X            tmpbranch[n_brs].up = yypvt[-0].i;
  2079. X            if(!check_branch()) n_brs--;
  2080. X            else tmpdungeon[n_dgns].branches++;
  2081. X          } break;
  2082. Xcase 38:
  2083. X# line 340 "dgn_comp.y"
  2084. X{
  2085. X            init_branch();
  2086. X            strcpy(tmpbranch[n_brs].name, yypvt[-5].str);
  2087. X            tmpbranch[n_brs].chain = getchain(yypvt[-4].str);
  2088. X            tmpbranch[n_brs].lev.base = couple.base;
  2089. X            tmpbranch[n_brs].lev.rand = couple.rand;
  2090. X            tmpbranch[n_brs].type = yypvt[-1].i;
  2091. X            tmpbranch[n_brs].up = yypvt[-0].i;
  2092. X            if(!check_branch()) n_brs--;
  2093. X            else tmpdungeon[n_dgns].branches++;
  2094. X          } break;
  2095. Xcase 39:
  2096. X# line 354 "dgn_comp.y"
  2097. X{
  2098. X            yyval.i = TBR_STAIR;    /* two way stair */
  2099. X          } break;
  2100. Xcase 40:
  2101. X# line 358 "dgn_comp.y"
  2102. X{
  2103. X            yyval.i = TBR_STAIR;    /* two way stair */
  2104. X          } break;
  2105. Xcase 41:
  2106. X# line 362 "dgn_comp.y"
  2107. X{
  2108. X            yyval.i = TBR_NO_UP;    /* no up staircase */
  2109. X          } break;
  2110. Xcase 42:
  2111. X# line 366 "dgn_comp.y"
  2112. X{
  2113. X            yyval.i = TBR_NO_DOWN;    /* no down staircase */
  2114. X          } break;
  2115. Xcase 43:
  2116. X# line 370 "dgn_comp.y"
  2117. X{
  2118. X            yyval.i = TBR_PORTAL;    /* portal connection */
  2119. X          } break;
  2120. Xcase 44:
  2121. X# line 376 "dgn_comp.y"
  2122. X{
  2123. X            yyval.i = 0;    /* defaults to down */
  2124. X          } break;
  2125. Xcase 45:
  2126. X# line 380 "dgn_comp.y"
  2127. X{
  2128. X            yyval.i = yypvt[-0].i;
  2129. X          } break;
  2130. Xcase 46:
  2131. X# line 403 "dgn_comp.y"
  2132. X{
  2133. X            if (yypvt[-3].i < -MAXLEVEL || yypvt[-3].i > MAXLEVEL) {
  2134. X                yyerror("Abs base out of dlevel range - zeroing!");
  2135. X                couple.base = couple.rand = 0;
  2136. X            } else if (yypvt[-1].i < -1 ||
  2137. X                ((yypvt[-3].i < 0) ? (MAXLEVEL + yypvt[-3].i + yypvt[-1].i + 1) > MAXLEVEL :
  2138. X                    (yypvt[-3].i + yypvt[-1].i) > MAXLEVEL)) {
  2139. X                yyerror("Abs range out of dlevel range - zeroing!");
  2140. X                couple.base = couple.rand = 0;
  2141. X            } else {
  2142. X                couple.base = yypvt[-3].i;
  2143. X                couple.rand = yypvt[-1].i;
  2144. X            }
  2145. X          } break;
  2146. Xcase 47:
  2147. X# line 440 "dgn_comp.y"
  2148. X{
  2149. X            if (yypvt[-3].i < -MAXLEVEL || yypvt[-3].i > MAXLEVEL) {
  2150. X                yyerror("Rel base out of dlevel range - zeroing!");
  2151. X                couple.base = couple.rand = 0;
  2152. X            } else {
  2153. X                couple.base = yypvt[-3].i;
  2154. X                couple.rand = yypvt[-1].i;
  2155. X            }
  2156. X          } break;
  2157. X    }
  2158. X    goto yystack;        /* reset registers in driver code */
  2159. X}
  2160. END_OF_FILE
  2161. if test 32600 -ne `wc -c <'sys/share/dgn_yacc.c'`; then
  2162.     echo shar: \"'sys/share/dgn_yacc.c'\" unpacked with wrong size!
  2163. fi
  2164. # end of 'sys/share/dgn_yacc.c'
  2165. fi
  2166. echo shar: End of archive 57 \(of 108\).
  2167. cp /dev/null ark57isdone
  2168. MISSING=""
  2169. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
  2170. 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 \
  2171. 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 \
  2172. 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 \
  2173. 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 \
  2174. 101 102 103 104 105 106 107 108 ; do
  2175.     if test ! -f ark${I}isdone ; then
  2176.     MISSING="${MISSING} ${I}"
  2177.     fi
  2178. done
  2179. if test "${MISSING}" = "" ; then
  2180.     echo You have unpacked all 108 archives.
  2181.     echo "Now execute 'rebuild.sh'"
  2182.     rm -f ark10[0-8]isdone ark[1-9]isdone ark[1-9][0-9]isdone
  2183. else
  2184.     echo You still need to unpack the following archives:
  2185.     echo "        " ${MISSING}
  2186. fi
  2187. ##  End of shell archive.
  2188. exit 0
  2189.