dungeon_obj.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989
  1. /* =============================================================================
  2. * PROGRAM: ularn
  3. * FILENAME: dungeon_obj.c
  4. *
  5. * DESCRIPTION:
  6. * This module contains functions for handling the effects of static objects
  7. * in the dungeon.
  8. * (ie. Objects that cannot be picked up such as stairs, fountains etc.)
  9. *
  10. * =============================================================================
  11. * EXPORTED VARIABLES
  12. *
  13. * None
  14. *
  15. * =============================================================================
  16. * EXPORTED FUNCTIONS
  17. *
  18. * oopendoor - processes the player opening a closed door
  19. * oaltar - processes player stepping onto an alter
  20. * othrone - processes player stepping onto a throne
  21. * odeadthrone - processes player stepping onto a dead throne
  22. * ofountain - processes player stepping onto a fountain
  23. * ostairs - processes player stepping onto the stairs (up or down)
  24. * oteleport - processes player stepping onto a teleport trap, and all other
  25. * reasons for teleporting the player
  26. * opit - processes player stepping onto a pit
  27. * oelevator - processes player stepping onto an elevator
  28. * ostatue - processes player stepping onto a statue
  29. * omirror - processes player stepping onto a mirror
  30. *
  31. * =============================================================================
  32. */
  33. #include "ularn_win.h"
  34. #include "dungeon_obj.h"
  35. #include "header.h"
  36. #include "player.h"
  37. #include "monster.h"
  38. #include "potion.h"
  39. #include "scores.h"
  40. #include "itm.h"
  41. #include "ularn_game.h"
  42. /* =============================================================================
  43. * Local functions
  44. */
  45. /* =============================================================================
  46. * FUNCTION: ohear
  47. *
  48. * DESCRIPTION:
  49. * Function to cast a +3 protection on the player from an altar.
  50. *
  51. * PARAMETERS:
  52. *
  53. * None.
  54. *
  55. * RETURN VALUE:
  56. *
  57. * None.
  58. */
  59. static void ohear(void)
  60. {
  61. Print("\nYou have been heard!");
  62. if (c[ALTPRO]==0)
  63. c[MOREDEFENSES] += ALTAR_PRO_BOOST;
  64. c[ALTPRO] += 800; /* protection field */
  65. recalc();
  66. UpdateEffects();
  67. }
  68. /* =============================================================================
  69. * FUNCTION: fch
  70. *
  71. * DESCRIPTION:
  72. * Changes a players ability by 1 for ofountain effects.
  73. *
  74. * PARAMETERS:
  75. *
  76. * how : The direction the attribute is to be changed.
  77. * x < 0 => down
  78. * x > 0 => up
  79. *
  80. * x : A pointer to the attribute value to change.
  81. *
  82. * RETURN VALUE:
  83. *
  84. * None.
  85. */
  86. static void fch(int how, long *x)
  87. {
  88. if (how < 0 )
  89. {
  90. if (*x > 3)
  91. {
  92. Print(" went down by one!");
  93. --(*x);
  94. }
  95. else
  96. {
  97. Print(" remained unchanged!");
  98. }
  99. }
  100. else
  101. {
  102. Print(" went up by one!");
  103. (*x)++;
  104. }
  105. UpdateStatus();
  106. }
  107. /* =============================================================================
  108. * FUNCTION: fntchange
  109. *
  110. * DESCRIPTION:
  111. * Function to change player attributes for fountain based effects.
  112. *
  113. * PARAMETERS:
  114. *
  115. * how : The size and direction of the change.
  116. * how > 0 => raised
  117. * how < 0 => lowered
  118. *
  119. * RETURN VALUE:
  120. *
  121. * None.
  122. */
  123. static void fntchange(int how)
  124. {
  125. long j;
  126. Printc('\n');
  127. switch (rnd(9))
  128. {
  129. case 1:
  130. Print("Your strength");
  131. fch(how, &c[STRENGTH]);
  132. break;
  133. case 2:
  134. Print("Your intelligence");
  135. fch(how, &c[INTELLIGENCE]);
  136. break;
  137. case 3:
  138. Print("Your wisdom");
  139. fch(how, &c[WISDOM]);
  140. break;
  141. case 4:
  142. Print("Your constitution");
  143. fch(how, &c[CONSTITUTION]);
  144. break;
  145. case 5:
  146. Print("Your dexterity");
  147. fch(how, &c[DEXTERITY]);
  148. break;
  149. case 6:
  150. Print("Your charm");
  151. fch(how, &c[CHARISMA]);
  152. break;
  153. case 7:
  154. j = rnd(level+1);
  155. if (how < 0)
  156. {
  157. Printf("You lose %d hit point%s!", (long)j, plural(j));
  158. losemhp((int)j);
  159. }
  160. else
  161. {
  162. Printf("You gain %d hit point%s!",(long)j, plural(j));
  163. raisemhp((int)j);
  164. }
  165. UpdateStatus();
  166. break;
  167. case 8:
  168. j = rnd(level+1);
  169. if (how > 0)
  170. {
  171. Printf("You just gained %d spell%s!",(long)j, plural(j));
  172. raisemspells((int)j);
  173. }
  174. else
  175. {
  176. Printf("You just lost %d spell%s!",(long)j, plural(j));
  177. losemspells((int)j);
  178. }
  179. UpdateStatus();
  180. break;
  181. case 9:
  182. j = 5*rnd((level+1)*(level+1));
  183. if (how < 0)
  184. {
  185. Printf("You just lost %d experience point%s!",(long)j, plural(j));
  186. loseexperience((long)j);
  187. }
  188. else
  189. {
  190. Printf("You just gained %d experience point%s!",(long)j, plural(j));
  191. raiseexperience((long)j);
  192. }
  193. break;
  194. }
  195. }
  196. /* =============================================================================
  197. * FUNCTION: obottomless
  198. *
  199. * DESCRIPTION:
  200. * Processes the player falling into a bottomless pit.
  201. *
  202. * PARAMETERS:
  203. *
  204. * None.
  205. *
  206. * RETURN VALUE:
  207. *
  208. * None.
  209. */
  210. static void obottomless(void)
  211. {
  212. Print("\nYou fell into a pit leading straight to HELL!");
  213. UlarnBeep();
  214. nap(3000);
  215. died(DIED_FELL_INTO_BOTTOMLESS_PIT, 0);
  216. }
  217. /* =============================================================================
  218. * Exported functions
  219. */
  220. /* =============================================================================
  221. * FUNCTION: oopendoor
  222. */
  223. void oopendoor(int x, int y)
  224. {
  225. if (item[x][y] != OCLOSEDDOOR)
  226. {
  227. return;
  228. }
  229. if (rnd(11)<7)
  230. {
  231. /*
  232. * Failed to open the door
  233. * See if something nasty happened instead
  234. */
  235. switch (iarg[x][y])
  236. {
  237. case 6:
  238. c[AGGRAVATE] += rnd(400);
  239. break;
  240. case 7:
  241. case 8:
  242. Print("\nYou are jolted by an electric shock!");
  243. losehp(DIED_ELECTRIC_SHOCK, rnd(20));
  244. UpdateStatus();
  245. break;
  246. case 9:
  247. Print("\nYou suddenly feel weaker!");
  248. if (c[STRENGTH]>3) c[STRENGTH]--;
  249. UpdateStatus();
  250. break;
  251. default:
  252. break;
  253. }
  254. /* Now the trap has been triggered, clear the trap */
  255. iarg[x][y] = 0;
  256. }
  257. else
  258. {
  259. item[x][y] = OOPENDOOR;
  260. show1cell(x, y);
  261. }
  262. }
  263. /* =============================================================================
  264. * FUNCTION: oaltar
  265. */
  266. void oaltar(void)
  267. {
  268. long k;
  269. int p;
  270. int ans;
  271. int redo;
  272. do
  273. {
  274. redo = 0;
  275. ans = get_prompt_input(
  276. "\nDo you (p) pray (d) desecrate, or (i) ignore it? ",
  277. "pdi\033", 1);
  278. switch (ans)
  279. {
  280. case 'p':
  281. Print(" pray");
  282. ans = get_prompt_input(
  283. "\nDo you (m) give money or (j) just pray? ",
  284. "mj", 1);
  285. switch (ans)
  286. {
  287. case 'j':
  288. p = rund(100);
  289. if (p < 12) createmonster(makemonst(level+2));
  290. else if (p < 17) enchweapon(ENCH_ALTAR);
  291. else if (p < 22) enchantarmor(ENCH_ALTAR);
  292. else if (p < 27) ohear();
  293. else Print("\nNothing happens.");
  294. break;
  295. case 'm':
  296. Print("\nHow much do you donate? ");
  297. k = get_num_input(c[GOLD]);
  298. if (k < 0)
  299. {
  300. redo = 1;
  301. }
  302. else if (c[GOLD] < k)
  303. {
  304. Print(" You don't have that much!");
  305. nap(1001);
  306. redo = 1;
  307. }
  308. else
  309. {
  310. /*
  311. * Remove gold from player
  312. */
  313. c[GOLD] -= k;
  314. if ((k < (c[GOLD]/10)) && (rnd(60)<30) && !wizard)
  315. {
  316. /*
  317. * Player offers < 1/11% of gold insults the gods 50% of the time.
  318. * Insulted gods send a demon prince to punish the player.
  319. */
  320. Print(" Cheapskate! The Gods are insulted by such a tiny offering!");
  321. forget();
  322. createmonster(DEMONPRINCE);
  323. c[AGGRAVATE] += 1500;
  324. /* God takes more gold anyway */
  325. c[GOLD] -= k;
  326. }
  327. else if (((k < (c[GOLD]+k)/10) || (k < rnd(50))) && !wizard)
  328. {
  329. /*
  330. * Player offers more than 1/11, but less than 1/10 of gold.
  331. * God has a chance of sending a monster to encourage the player
  332. * to be more generous based on how far below 50 gold the
  333. * amount doneted is.
  334. */
  335. createmonster(makemonst(level+2));
  336. c[AGGRAVATE] += 500;
  337. /* God takes more gold anyway */
  338. c[GOLD] -= k;
  339. }
  340. else
  341. {
  342. /*
  343. * Player was reasonably generous, so give a blessing
  344. */
  345. p = rund(16);
  346. if (p < 4)
  347. {
  348. Print(" Thank you.");
  349. }
  350. else if (p < 6)
  351. {
  352. enchantarmor(ENCH_ALTAR);
  353. enchantarmor(ENCH_ALTAR);
  354. }
  355. else if (p < 8)
  356. {
  357. enchweapon(ENCH_ALTAR);
  358. enchweapon(ENCH_ALTAR);
  359. }
  360. else
  361. {
  362. ohear();
  363. }
  364. }
  365. UpdateStatus();
  366. }
  367. break;
  368. default:
  369. break;
  370. } /* end while switch : case j or m */
  371. break;
  372. case 'd':
  373. Print(" desecrate");
  374. if (rnd(100)<60)
  375. {
  376. createmonster(makemonst(level+3)+8);
  377. c[AGGRAVATE] += 2500;
  378. }
  379. else if(rnd(100)<5)
  380. {
  381. raiselevel();
  382. }
  383. else if (rnd(101)<30)
  384. {
  385. Print("\nThe altar crumbles into a pile of dust before your eyes.");
  386. forget();
  387. }
  388. else
  389. {
  390. Print("\nNothing happens.");
  391. }
  392. UpdateStatus();
  393. break;
  394. case 'i':
  395. case ESC:
  396. Print(" ignore");
  397. if (rnd(100)<30)
  398. {
  399. createmonster(makemonst(level+2));
  400. c[AGGRAVATE] += rnd(450);
  401. }
  402. else
  403. {
  404. Print("\nNothing happens.");
  405. nomove = 1; /* XXX trn */
  406. }
  407. break;
  408. } /* end while switch: pray, des, ignore */
  409. } while (redo);
  410. }
  411. /* =============================================================================
  412. * FUNCTION: othrone
  413. */
  414. void othrone(int arg)
  415. {
  416. int i,k;
  417. int ans;
  418. ans = get_prompt_input(
  419. "\nDo you (p) pry off jewels, (s) sit down, or (i) ignore it? ",
  420. "psi\033", 1);
  421. switch (ans)
  422. {
  423. case 'p':
  424. Print(" pry off");
  425. k = rnd(101);
  426. if (k<25)
  427. {
  428. for (i=0; i<rnd(4); i++)
  429. {
  430. creategem(); /*gems pop off the throne*/
  431. }
  432. item[playerx][playery] = ODEADTHRONE;
  433. }
  434. else if ((k<40) && (arg==0))
  435. {
  436. createmonster(GNOMEKING);
  437. item[playerx][playery] = OTHRONE2;
  438. }
  439. else
  440. {
  441. Print("\nNothing happens.");
  442. }
  443. break;
  444. case 's':
  445. Print(" sit down");
  446. k = rnd(101);
  447. if ((k<30) && (arg==0))
  448. {
  449. createmonster(GNOMEKING);
  450. item[playerx][playery] = OTHRONE2;
  451. }
  452. else if (k<35)
  453. {
  454. Print("\nZaaaappp! You've been teleported!\n");
  455. UlarnBeep();
  456. oteleport(0);
  457. }
  458. else
  459. {
  460. Print("\nNothing happens.");
  461. }
  462. break;
  463. case 'i':
  464. case ESC:
  465. Print(" ignore");
  466. break;;
  467. }
  468. }
  469. /* =============================================================================
  470. * FUNCTION: odeadthrone
  471. */
  472. void odeadthrone(void)
  473. {
  474. int k;
  475. int ans;
  476. ans = get_prompt_input(
  477. "\nDo you (s) sit down, or (i) ignore it? ",
  478. "si\033", 1);
  479. switch (ans)
  480. {
  481. case 's':
  482. Print(" sit down");
  483. k = rnd(101);
  484. if (k<5)
  485. {
  486. raiselevel();
  487. }
  488. else if (k<25)
  489. {
  490. Print("\nZaaaappp! You've been teleported!\n");
  491. UlarnBeep();
  492. oteleport(0);
  493. }
  494. else
  495. {
  496. Print("\nNothing happens.");
  497. }
  498. break;
  499. case 'i':
  500. case ESC:
  501. Print(" ignore");;
  502. break;
  503. }
  504. }
  505. /* =============================================================================
  506. * FUNCTION: ofountain
  507. */
  508. void ofountain(void)
  509. {
  510. int x;
  511. int ans;
  512. ans = get_prompt_input(
  513. "\nDo you (d) drink, (w) wash yourself, or (i) ignore it? ",
  514. "dwi\033", 1);
  515. switch (ans)
  516. {
  517. case 'd':
  518. Print("drink");
  519. if (rnd(1501) < 4)
  520. {
  521. Print("\nOH MY GOD!! You have caught the *dreadful sleep*!");
  522. UlarnBeep();
  523. nap(3000);
  524. died(DIED_DREADFUL_SLEEP, 0);
  525. return;
  526. }
  527. else
  528. {
  529. x = rnd(100);
  530. if (x==1)
  531. {
  532. raiselevel();
  533. }
  534. else if (x < 11)
  535. {
  536. x = rnd((level<<2)+2);
  537. Printf("\nBleah! The water tasted like stale gatorade! You lose %d hit point%s!",
  538. (long)x, plural(x));
  539. losehp(DIED_DRANK_POISONOUS_WATER, x);
  540. UpdateStatus();
  541. }
  542. else if (x<14)
  543. {
  544. c[HALFDAM] += 200+rnd(200);
  545. Print("\nThe water makes you vomit.");
  546. }
  547. else if (x<17)
  548. {
  549. /* Same effect as giant strength */
  550. Print("\n You now have incredible bulging muscles!");
  551. if (c[GIANTSTR]==0) c[STREXTRA] += PGIANTSTR_BOOST;
  552. c[GIANTSTR] += 700;
  553. UpdateEffects();
  554. }
  555. else if (x < 45)
  556. {
  557. Print("\nNothing seems to have happened.");
  558. }
  559. else if (rnd(3) != 2)
  560. {
  561. fntchange(1); /*change char levels upward*/
  562. }
  563. else
  564. {
  565. fntchange(-1); /*change char levels downward*/
  566. }
  567. if (rnd(12) < 3)
  568. {
  569. Print("\nThe fountains bubbling slowly quietens.");
  570. /* dead fountain */
  571. item[playerx][playery] = ODEADFOUNTAIN;
  572. }
  573. }
  574. break;
  575. case 'i':
  576. case ESC:
  577. Print(" ignore");
  578. break;
  579. case 'w':
  580. Print("wash yourself.");
  581. if (rnd(100) < 11)
  582. {
  583. x = rnd((level<<2)+2);
  584. Printf("\nThe water burns like acid! You lose %d hit point%s!",
  585. (long)x, plural(x));
  586. losehp(DIED_DRANK_POISONOUS_WATER, x);
  587. UpdateStatus();
  588. }
  589. else if (rnd(100) < 29)
  590. {
  591. Print("\nYou are now clean.");
  592. if (c[ITCHING])
  593. {
  594. /*
  595. * Managed to get rid of the itching powder, so set it so the
  596. * next call to regen will cancel the effect.
  597. */
  598. c[ITCHING] = 1;
  599. }
  600. }
  601. else if (rnd(100) < 31)
  602. {
  603. Print("\nThis water needs soap -- the dirt didn't come off.");
  604. }
  605. else if (rnd(100) < 34)
  606. {
  607. createmonster(WATERLORD);
  608. }
  609. else
  610. {
  611. Print("\nNothing seems to have happened.");
  612. }
  613. break;
  614. }
  615. }
  616. /* =============================================================================
  617. * FUNCTION: ostairs
  618. */
  619. void ostairs(int dir)
  620. {
  621. int x, y;
  622. int ans;
  623. Print("\nDo you (s) stay here or ");
  624. if (dir > 0)
  625. {
  626. Print("(u) go up? ");
  627. }
  628. else
  629. {
  630. Print("(d) go down? ");
  631. }
  632. ans = get_prompt_input("", "sudi\033", 1);
  633. switch (ans)
  634. {
  635. case ESC:
  636. case 's':
  637. case 'i':
  638. Print("stay here.");
  639. return;
  640. case 'u':
  641. Print("go up.");
  642. if (dir < 0)
  643. {
  644. Print("\nThe stairs don't go up!");
  645. }
  646. else
  647. {
  648. /* not on V1 */
  649. if ((level >= 2) && (level != (DBOTTOM+1)))
  650. {
  651. newcavelevel(level-1);
  652. for (x = 0 ; x < MAXX ; x++)
  653. {
  654. for (y = 0 ; y < MAXY ; y++)
  655. {
  656. if (item[x][y] == OSTAIRSDOWN)
  657. {
  658. playerx = (char) x;
  659. playery = (char) y;
  660. x = MAXX;
  661. y = MAXY;
  662. }
  663. }
  664. }
  665. if (mitem[playerx][playery].mon != MONST_NONE)
  666. {
  667. /*
  668. * A monster is on the stairs, so find an empty position for the
  669. * player.
  670. */
  671. positionplayer();
  672. }
  673. draws(0, MAXX, 0, MAXY);
  674. UpdateStatusAndEffects();
  675. }
  676. else
  677. {
  678. Print("\nThe stairs lead to a dead end!");
  679. }
  680. }
  681. break;
  682. case 'd':
  683. Print("go down.");
  684. if (dir > 0)
  685. {
  686. Print("\nThe stairs don't go down!");
  687. }
  688. else
  689. {
  690. /* not on dungeon bottom or V5 */
  691. if ((level!=0) && (level!=DBOTTOM) && (level!=VBOTTOM))
  692. {
  693. newcavelevel(level+1);
  694. for (x = 0 ; x < MAXX ; x++)
  695. {
  696. for (y = 0 ; y < MAXY ; y++)
  697. {
  698. if (item[x][y] == OSTAIRSUP)
  699. {
  700. playerx = (char) x;
  701. playery = (char) y;
  702. x = MAXX;
  703. y = MAXY;
  704. }
  705. }
  706. }
  707. if (mitem[playerx][playery].mon != MONST_NONE)
  708. {
  709. /*
  710. * A monster is on the stairs, so find an empty position for the
  711. * player.
  712. */
  713. positionplayer();
  714. }
  715. draws(0,MAXX,0,MAXY);
  716. UpdateStatusAndEffects();
  717. }
  718. else
  719. {
  720. Print("\nThe stairs lead to a dead end!");
  721. }
  722. }
  723. break;
  724. default:
  725. break;
  726. }
  727. }
  728. /* =============================================================================
  729. * FUNCTION: oteleport
  730. */
  731. void oteleport(int err)
  732. {
  733. int tmp;
  734. if (err)
  735. {
  736. if (rnd(151) < 3)
  737. {
  738. /* stuck in a rock if the player can't walk through walls */
  739. if (c[WTW] == 0)
  740. {
  741. died(DIED_TRAPPED_IN_SOLID_ROCK, 0);
  742. return;
  743. }
  744. }
  745. }
  746. /* show ?? on bottomline if been teleported */
  747. if (!wizard) c[TELEFLAG]=1;
  748. if (level==0)
  749. {
  750. tmp = 0;
  751. }
  752. else if (level <= DBOTTOM)
  753. {
  754. /* in dungeon */
  755. tmp = rnd(5) + level - 3;
  756. if (tmp > DBOTTOM)
  757. {
  758. tmp = DBOTTOM;
  759. }
  760. if (tmp < 0)
  761. {
  762. tmp = 0;
  763. }
  764. }
  765. else
  766. {
  767. /* in volcano */
  768. tmp = rnd(4) + level - 2;
  769. if (tmp >= VBOTTOM)
  770. {
  771. tmp = VBOTTOM;
  772. }
  773. if (tmp < DBOTTOM+1)
  774. {
  775. /* back to surface */
  776. tmp = 0;
  777. }
  778. }
  779. playerx = (char) rnd(MAXX-2);
  780. playery = (char) rnd(MAXY-2);
  781. if (level != tmp)
  782. {
  783. newcavelevel(tmp);
  784. }
  785. else
  786. {
  787. positionplayer();
  788. }
  789. draws(0, MAXX, 0, MAXY);
  790. UpdateStatusAndEffects();
  791. }
  792. /* =============================================================================
  793. * FUNCTION: opit
  794. */
  795. void opit(void)
  796. {
  797. int i;
  798. if (rnd(101) > 81) return;
  799. if ((rnd(70) > (9*c[DEXTERITY] - packweight())) || (rnd(101) < 5))
  800. {
  801. /* Never fall into a pit if the player has a wand of wonder */
  802. if (player_has_item(OWWAND))
  803. {
  804. Print("\nYou float right over the pit.");
  805. return;
  806. }
  807. if (level==DBOTTOM || level == VBOTTOM)
  808. {
  809. /* Pits on the bottom of the dungeon or volcano are bottomless */
  810. obottomless();
  811. }
  812. else
  813. {
  814. if (rnd(101)<20)
  815. {
  816. i = 0;
  817. Print("\nYou fell ino a pit! A poor monster cushions your fall!\n");
  818. }
  819. else
  820. {
  821. i = rnd(level*3+3);
  822. if (i > c[HP]) i = c[HP];
  823. Printf("\nYou fell into a pit! You suffer %d hit point%s damage.",
  824. (long)i, plural(i));
  825. }
  826. losehp(DIED_FELL_INTO_PIT, i);
  827. nap(2000);
  828. newcavelevel(level + 1);
  829. draws(0, MAXX, 0, MAXY);
  830. }
  831. }
  832. }
  833. /* =============================================================================
  834. * FUNCTION: oelevator
  835. */
  836. void oelevator(int dir)
  837. {
  838. int new_level;
  839. if (dir==1)
  840. {
  841. /* going up */
  842. if (level == 0)
  843. {
  844. Print(",\nunfortunately, it is out of order.");
  845. return;
  846. }
  847. playerx = (char) rnd(MAXX-2);
  848. playery = (char) rnd(MAXY-2);
  849. nap(2000);
  850. if (level <= DBOTTOM)
  851. {
  852. /* In dungeon */
  853. newcavelevel(rund(level));
  854. }
  855. else
  856. {
  857. /* In volcano */
  858. new_level = DBOTTOM + rund(level - DBOTTOM);
  859. if (new_level == DBOTTOM)
  860. {
  861. new_level = 0;
  862. }
  863. newcavelevel(new_level);
  864. }
  865. }
  866. else
  867. {
  868. /* going down */
  869. if ((level==DBOTTOM) || (level==VBOTTOM))
  870. {
  871. nap(2000);
  872. Print("\nand it leads straight to HELL!");
  873. UlarnBeep();
  874. nap(3000);
  875. died(DIED_ELEVATOR_TO_HELL, 0);
  876. return;
  877. }
  878. playerx = (char) rnd(MAXX-2);
  879. playery = (char) rnd(MAXY-2);
  880. nap(2000);
  881. if (level < DBOTTOM)
  882. {
  883. /* In dungeon */
  884. newcavelevel(level + rnd(DBOTTOM - level));
  885. }
  886. else
  887. {
  888. /* in volcano */
  889. newcavelevel(level + rnd(VBOTTOM - level));
  890. }
  891. }
  892. draws(0, MAXX, 0, MAXY);
  893. UpdateStatusAndEffects();
  894. }
  895. /* =============================================================================
  896. * FUNCTION: ostatue
  897. */
  898. void ostatue(void)
  899. { } /* nothing happens when you move on a statue */
  900. /* =============================================================================
  901. * FUNCTION: omirror
  902. */
  903. void omirror(void)
  904. { } /* nothing happens when you move on a mirror */