object.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152
  1. /* =============================================================================
  2. * PROGRAM: ularn
  3. * FILENAME: object.c
  4. *
  5. * DESCRIPTION:
  6. * This module contains function for handling what a player finds when moving
  7. * onto a new square in the dungeon.
  8. *
  9. * =============================================================================
  10. * EXPORTED VARIABLES
  11. *
  12. * None.
  13. *
  14. * =============================================================================
  15. * EXPORTED FUNCTIONS
  16. *
  17. * lookforobject : Performs processing for the item found at the player's
  18. * current location.
  19. *
  20. * =============================================================================
  21. */
  22. #include "object.h"
  23. #include "dungeon.h"
  24. #include "dungeon_obj.h"
  25. #include "fortune.h"
  26. #include "header.h"
  27. #include "itm.h"
  28. #include "monster.h"
  29. #include "player.h"
  30. #include "potion.h"
  31. #include "scores.h"
  32. #include "scroll.h"
  33. #include "spell.h"
  34. #include "store.h"
  35. #include "ularn_game.h"
  36. #include "ularn_win.h"
  37. /* =============================================================================
  38. * Local functions
  39. */
  40. /* =============================================================================
  41. * FUNCTION: iopts
  42. *
  43. * DESCRIPTION:
  44. * Function to print the ignore option.
  45. * Originally used to save program space, now probably not required.
  46. *
  47. * PARAMETERS:
  48. *
  49. * None.
  50. *
  51. * RETURN VALUE:
  52. *
  53. * None.
  54. */
  55. static void iopts(void) { Print(", or (i) ignore it? "); }
  56. /* =============================================================================
  57. * FUNCTION: ignore
  58. *
  59. * DESCRIPTION:
  60. * Function to print 'ignore.'.
  61. * Originally used to save program space, now probably not required.
  62. *
  63. * PARAMETERS:
  64. *
  65. * None.
  66. *
  67. * RETURN VALUE:
  68. *
  69. * None.
  70. */
  71. static void ignore(void) { Print("ignore.\n"); }
  72. /* =============================================================================
  73. * FUNCTION: opotion
  74. *
  75. * DESCRIPTION:
  76. * Function to handle finding a potion.
  77. *
  78. * PARAMETERS:
  79. *
  80. * pot : The potion type found.
  81. *
  82. * RETURN VALUE:
  83. *
  84. * None.
  85. */
  86. static void opotion(int pot) {
  87. int ans;
  88. ans = get_prompt_input(
  89. "\nDo you (d) drink it, (t) take it, or (i) ignore it? ", "dit\033", 1);
  90. switch (ans) {
  91. case ESC:
  92. case 'i':
  93. ignore();
  94. break;
  95. case 'd':
  96. Print("drink.\n");
  97. forget(); /* destroy potion */
  98. quaffpotion(pot);
  99. break;
  100. case 't':
  101. Print("take.\n");
  102. if (take(OPOTION, pot) == 0)
  103. forget();
  104. break;
  105. default:
  106. break;
  107. }
  108. }
  109. /* =============================================================================
  110. * FUNCTION: oscroll
  111. *
  112. * DESCRIPTION:
  113. * Function to process finding a mogic scroll.
  114. *
  115. * PARAMETERS:
  116. *
  117. * typ : The type of scroll found.
  118. *
  119. * RETURN VALUE:
  120. *
  121. * None.
  122. */
  123. void oscroll(int typ) {
  124. int ans;
  125. Print("\nDo you ");
  126. if (c[BLINDCOUNT] == 0)
  127. Print("(r) read it, ");
  128. Print("(t) take it");
  129. iopts();
  130. ans = get_prompt_input("", "irt\033", 1);
  131. switch (ans) {
  132. case ESC:
  133. case 'i':
  134. ignore();
  135. break;
  136. case 'r':
  137. if (c[BLINDCOUNT])
  138. break;
  139. Print("read.");
  140. /* remove the scroll */
  141. forget();
  142. /* read the scroll */
  143. read_scroll(typ);
  144. break;
  145. case 't':
  146. Print("take.");
  147. if (take(OSCROLL, typ) == 0)
  148. forget(); /* destroy it */
  149. break;
  150. default:
  151. break;
  152. }
  153. }
  154. /* =============================================================================
  155. * FUNCTION: obook
  156. *
  157. * DESCRIPTION:
  158. * Function to process finding a book.
  159. *
  160. * PARAMETERS:
  161. *
  162. * None.
  163. *
  164. * RETURN VALUE:
  165. *
  166. * None.
  167. */
  168. void obook(void) {
  169. int ans;
  170. Print("\nDo you ");
  171. if (c[BLINDCOUNT] == 0)
  172. Print("(r) read it, ");
  173. Print("(t) take it");
  174. iopts();
  175. ans = get_prompt_input("", "irt\033", 1);
  176. switch (ans) {
  177. case ESC:
  178. case 'i':
  179. ignore();
  180. return;
  181. case 'r':
  182. if (c[BLINDCOUNT])
  183. break;
  184. Print("read.");
  185. readbook(iarg[playerx][playery]);
  186. /* no more book */
  187. forget();
  188. return;
  189. case 't':
  190. Print("take.");
  191. if (take(OBOOK, iarg[playerx][playery]) == 0)
  192. forget(); /* no more book */
  193. return;
  194. default:
  195. break;
  196. }
  197. }
  198. /* =============================================================================
  199. * FUNCTION: ocookie
  200. *
  201. * DESCRIPTION:
  202. * Function to process finding a cookie.
  203. *
  204. * PARAMETERS:
  205. *
  206. * None
  207. *
  208. * RETURN VALUE:
  209. *
  210. * None
  211. */
  212. void ocookie(void) {
  213. int ans;
  214. char *p;
  215. Print("\nDo you (e) eat it, (t) take it");
  216. iopts();
  217. ans = get_prompt_input("", "eit\033", 1);
  218. switch (ans) {
  219. case ESC:
  220. case 'i':
  221. ignore();
  222. return;
  223. case 'e':
  224. Print("eat.\nThe cookie tasted good.");
  225. forget(); /* no more cookie */
  226. if (c[BLINDCOUNT])
  227. return;
  228. p = fortune(fortfile);
  229. if (p == (char *)NULL)
  230. return;
  231. Print(" A message inside the cookie reads:\n");
  232. Print(p);
  233. return;
  234. case 't':
  235. Print("take.");
  236. if (take(OCOOKIE, 0) == 0)
  237. forget();
  238. return;
  239. default:
  240. break;
  241. }
  242. }
  243. /* =============================================================================
  244. * FUNCTION: ogold
  245. *
  246. * DESCRIPTION:
  247. * Function to pick up some gold.
  248. *
  249. * PARAMETERS:
  250. *
  251. * arg : The size of the gold pile
  252. * if arg ==
  253. * ODGOLD then the pile is worth 10x the argument
  254. * OMAXGOLD then the pile is worth 100x the argument
  255. * OKGOLD then the pile is worth 1000x the argument
  256. *
  257. * RETURN VALUE:
  258. *
  259. * None.
  260. */
  261. void ogold(int arg) {
  262. long i;
  263. i = iarg[playerx][playery];
  264. if (arg == ODGOLD)
  265. i *= 10;
  266. else if (arg == OMAXGOLD)
  267. i *= 100;
  268. else if (arg == OKGOLD)
  269. i *= 1000;
  270. Printf("\nYou find %d gold piece%s.", i, plural(i));
  271. c[GOLD] += i;
  272. UpdateStatus();
  273. /* destroy gold */
  274. item[playerx][playery] = ONOTHING;
  275. }
  276. /* =============================================================================
  277. * FUNCTION: ochest
  278. *
  279. * DESCRIPTION:
  280. * Function to handle finding a chest.
  281. *
  282. * PARAMETERS:
  283. *
  284. * None.
  285. *
  286. * RETURN VALUE:
  287. *
  288. * None.
  289. */
  290. void ochest(void) {
  291. int ans;
  292. ans = get_prompt_input(
  293. "\nDo you (t) take it, (o) try to open it, or (i) ignore it? ", "oti\033",
  294. 1);
  295. switch (ans) {
  296. case 'o':
  297. Print(" open it.");
  298. oopenchest();
  299. break;
  300. case 't':
  301. Print(" take");
  302. if (take(OCHEST, iarg[playerx][playery]) == 0)
  303. item[playerx][playery] = ONOTHING;
  304. break;
  305. case 'i':
  306. case ESC:
  307. ignore();
  308. break;
  309. default:
  310. break;
  311. }
  312. }
  313. /* =============================================================================
  314. * FUNCTION: finditem
  315. *
  316. * DESCRIPTION:
  317. * Function to say what object we found and ask if player wants to take it
  318. *
  319. * PARAMETERS:
  320. *
  321. * itm : The item found
  322. *
  323. * RETURN VALUE:
  324. *
  325. * None.
  326. */
  327. static void finditem(int itm) {
  328. int tmp, i;
  329. Printf("\n\nYou find %s", objectname[itm]);
  330. tmp = iarg[playerx][playery];
  331. switch (itm) {
  332. case ODIAMOND:
  333. case ORUBY:
  334. case OEMERALD:
  335. case OSAPPHIRE:
  336. case OSPIRITSCARAB:
  337. case OORBOFDRAGON:
  338. case OORB:
  339. case OHANDofFEAR:
  340. case OWWAND:
  341. case OCUBEofUNDEAD:
  342. case ONOTHEFT:
  343. Print(".");
  344. break;
  345. default:
  346. if (tmp > 0)
  347. Printf(" + %d", (long)tmp);
  348. else if (tmp < 0)
  349. Printf(" %d", (long)tmp);
  350. }
  351. Print("\nDo you want to (t) take it");
  352. iopts();
  353. i = get_prompt_input("", "it\033", 1);
  354. if (i == 't') {
  355. Print("take.");
  356. if (take(itm, tmp) == 0)
  357. forget();
  358. } else
  359. ignore();
  360. }
  361. /* =============================================================================
  362. * Exported functions
  363. */
  364. /* =============================================================================
  365. * FUNCTION: oopenchest
  366. */
  367. void oopenchest(void) {
  368. int i;
  369. int k;
  370. if (item[playerx][playery] != OCHEST)
  371. return;
  372. k = rnd(101);
  373. if (k < 40) {
  374. Print("\nThe chest explodes as you open it.");
  375. UlarnBeep();
  376. i = rnd(10);
  377. if (i > c[HP])
  378. i = c[HP];
  379. Printf("\nYou suffer %d hit point%s damage!", (long)i, plural(i));
  380. losehp(DIED_EXPLODING_CHEST, i);
  381. UpdateStatus();
  382. switch (rnd(10)) {
  383. case 1:
  384. c[ITCHING] += rnd(1000) + 100;
  385. Print("\nYou feel an irritation spread over your skin!");
  386. UlarnBeep();
  387. break;
  388. case 2:
  389. c[CLUMSINESS] += rnd(1600) + 200;
  390. Print("\nYou begin to lose hand-eye co-ordination!");
  391. UlarnBeep();
  392. break;
  393. case 3:
  394. c[HALFDAM] += rnd(1600) + 200;
  395. Print("\nYou suddenly feel sick and BARF all over your shoes!");
  396. UlarnBeep();
  397. break;
  398. }
  399. /* Remove the chest */
  400. item[playerx][playery] = ONOTHING;
  401. /* create the items in the chest */
  402. if (rnd(100) < 69)
  403. /* gems from the chest */
  404. creategem();
  405. dropgold(rnd(110 * iarg[playerx][playery] + 200));
  406. for (i = 0; i < rnd(4); i++)
  407. something(playerx, playery, iarg[playerx][playery] + 2);
  408. } else
  409. Print("\nNothing happens.");
  410. }
  411. /* =============================================================================
  412. * FUNCTION: lookforobject
  413. */
  414. void lookforobject(void) {
  415. int i, j;
  416. int dx, dy;
  417. char code[3];
  418. /* can't find objects is time is stopped */
  419. if (c[TIMESTOP])
  420. return;
  421. i = item[playerx][playery];
  422. if (i == ONOTHING)
  423. return;
  424. showcell(playerx, playery);
  425. yrepcount = 0;
  426. switch (i) {
  427. case OGOLDPILE:
  428. case OMAXGOLD:
  429. case OKGOLD:
  430. case ODGOLD:
  431. ogold(i);
  432. break;
  433. case OPOTION:
  434. Print("\n\nYou find a magic potion");
  435. i = iarg[playerx][playery];
  436. if (potionknown[i])
  437. Printf(" of %s", &potionname[i][1]);
  438. Print(".");
  439. opotion(i);
  440. break;
  441. case OSCROLL:
  442. Print("\n\nYou find a magic scroll");
  443. i = iarg[playerx][playery];
  444. if (scrollknown[i])
  445. Printf(" of %s", &scrollname[i][1]);
  446. Print(".");
  447. oscroll(i);
  448. break;
  449. case OALTAR:
  450. if (nearbymonst())
  451. return;
  452. Print("\n\nThere is a holy altar here.");
  453. oaltar();
  454. break;
  455. case OBOOK:
  456. Print("\n\nYou find a book.");
  457. obook();
  458. break;
  459. case OCOOKIE:
  460. Print("\n\nYou find a fortune cookie.");
  461. ocookie();
  462. break;
  463. case OTHRONE:
  464. if (nearbymonst())
  465. return;
  466. Printf("\n\nThere is %s here.", objectname[i]);
  467. othrone(0);
  468. break;
  469. case OTHRONE2:
  470. if (nearbymonst())
  471. return;
  472. Printf("\n\nThere is %s here.", objectname[i]);
  473. othrone(1);
  474. break;
  475. case ODEADTHRONE:
  476. Printf("\n\nThere is %s here.", objectname[i]);
  477. odeadthrone();
  478. break;
  479. case OORB:
  480. if (nearbymonst())
  481. return;
  482. finditem(i);
  483. break;
  484. case OBRASSLAMP:
  485. Print("\nYou find a brass lamp.");
  486. i = get_prompt_input(
  487. "\nDo you want to (r) rub it, (t) take it, or (i) ignore it? ",
  488. "rit\033", 1);
  489. if (i == 'r') {
  490. i = rnd(100);
  491. if (i > 90) {
  492. Print("\nThe magic genie was very upset at being disturbed!");
  493. losehp(DIED_ANNOYED_GENIE, (int)c[HP] / 2 + 1);
  494. UlarnBeep();
  495. }
  496. /* higher level, better chance of spell */
  497. else if ((rnd(100) + c[LEVEL] / 2) > 80) {
  498. Print("\nA magic genie appears!");
  499. get_spell_code("\n What spell would you like? : ", code);
  500. Printc('\n');
  501. for (i = 0; i < SPELL_COUNT; i++) {
  502. if ((spelcode[i][0] == code[0]) && (spelcode[i][1] == code[1]) &&
  503. (spelcode[i][2] == code[2])) {
  504. spelknow[i]++;
  505. Printf("\nSpell \"%s\": %s\n%s", spelcode[i], spelname[i],
  506. speldescript[i]);
  507. Print("\nThe genie prefers not to be disturbed again.");
  508. forget();
  509. recalc();
  510. UpdateStatus();
  511. return;
  512. }
  513. }
  514. Print("\nThe genie has never heard of such a spell!");
  515. Print("\nThe genie prefers not to be disturbed again.");
  516. forget();
  517. recalc();
  518. UpdateStatus();
  519. return;
  520. } else
  521. Print("\nnothing happened.");
  522. if (rnd(100) < 15) {
  523. Print("\nThe genie prefers not to be disturbed again!");
  524. forget();
  525. c[LAMP] = 0; /* chance of finding lamp again */
  526. }
  527. UpdateStatus();
  528. } else if (i == 't') {
  529. Print("take.");
  530. if (take(OBRASSLAMP, 0) == 0)
  531. forget();
  532. } else
  533. Print("ignore.");
  534. return;
  535. case OWWAND:
  536. if (nearbymonst())
  537. return;
  538. finditem(i);
  539. break;
  540. case OHANDofFEAR:
  541. if (nearbymonst())
  542. return;
  543. finditem(i);
  544. break;
  545. case OPIT:
  546. Print("\n\nYou're standing at the top of a pit.");
  547. opit();
  548. break;
  549. case OSTAIRSUP:
  550. Print("\n\nThere is a circular staircase here.");
  551. ostairs(1); /* up */
  552. break;
  553. case OELEVATORUP:
  554. Print("\n\nYou have found an express elevator going up.");
  555. oelevator(1); /* up */
  556. break;
  557. case OELEVATORDOWN:
  558. Print("\n\nYou have found an express elevator going down.");
  559. oelevator(-1); /* down */
  560. break;
  561. case OFOUNTAIN:
  562. if (nearbymonst())
  563. return;
  564. Print("\n\nThere is a fountain here.");
  565. ofountain();
  566. break;
  567. case OSTATUE:
  568. if (nearbymonst())
  569. return;
  570. Print("\n\nYou stand before a statue.");
  571. ostatue();
  572. break;
  573. case OCHEST:
  574. Print("\n\nThere is a chest here.");
  575. ochest();
  576. break;
  577. case OIVTELETRAP:
  578. if (rnd(11) < 6)
  579. return;
  580. item[playerx][playery] = OTELEPORTER;
  581. case OTELEPORTER:
  582. /*
  583. * The player is being teleported, so obviously the player gets
  584. * to know that a teleport trap is here.
  585. * oteleport forces a screen redraw, so don't bother display anything
  586. * here.
  587. */
  588. know[playerx][playery] = item[playerx][playery];
  589. Print("\nZaaaappp! You've been teleported!\n");
  590. UlarnBeep();
  591. nap(3000);
  592. oteleport(0);
  593. break;
  594. case OSCHOOL:
  595. if (nearbymonst())
  596. return;
  597. Print("\n\nYou have found the College of VLarn.");
  598. i = get_prompt_input("\nDo you (g) go inside, or (i) stay here? ", "gi\033",
  599. 1);
  600. if (i == 'g') {
  601. oschool(); /* the college of larn */
  602. } else
  603. Print(" stay here.");
  604. break;
  605. case OMIRROR:
  606. if (nearbymonst())
  607. return;
  608. Print("\n\nThere is a mirror here.");
  609. omirror();
  610. break;
  611. case OBANK2:
  612. case OBANK:
  613. if (nearbymonst())
  614. return;
  615. if (i == OBANK)
  616. Print("\n\nYou have found the bank of VLarn.");
  617. else
  618. Print("\n\nYou have found a branch office of the bank of VLarn.");
  619. j = get_prompt_input("\nDo you (g) go inside, or (i) stay here? ", "gi\033",
  620. 1);
  621. if (j == 'g') {
  622. if (i == OBANK)
  623. obank();
  624. else
  625. obank2(); /* the bank of larn */
  626. } else
  627. Print(" stay here.");
  628. break;
  629. case ODEADFOUNTAIN:
  630. if (nearbymonst())
  631. return;
  632. Print("\n\nThere is a dead fountain here.");
  633. break;
  634. case ODNDSTORE:
  635. if (nearbymonst())
  636. return;
  637. Print("\n\nThere is a DND store here.");
  638. i = get_prompt_input("\nDo you (g) go inside, or (i) stay here? ", "gi\033",
  639. 1);
  640. if (i == 'g')
  641. dndstore(); /* the dnd adventurers store */
  642. else
  643. Print(" stay here.");
  644. break;
  645. case OSTAIRSDOWN:
  646. Print("\n\nThere is a circular staircase here.");
  647. ostairs(-1); /* down */
  648. break;
  649. case OOPENDOOR:
  650. Print("\nThere is an open door here.");
  651. break;
  652. case OCLOSEDDOOR:
  653. /* can't move objects if time is stopped */
  654. if (c[TIMESTOP])
  655. return;
  656. dx = playerx;
  657. dy = playery;
  658. if (dropflag)
  659. return;
  660. Printf("\n\nYou find %s", objectname[i]);
  661. Print("\nDo you (o) try to open it");
  662. iopts();
  663. i = get_prompt_input("", "oi\033", 1);
  664. if ((i == ESC) || (i == 'i')) {
  665. ignore();
  666. playerx = lastpx;
  667. playery = lastpy;
  668. lastpx = (char)dx;
  669. lastpy = (char)dy;
  670. break;
  671. } else {
  672. Print("open.");
  673. /* Try and open the door that is here */
  674. oopendoor(playerx, playery);
  675. if (item[playerx][playery] == OCLOSEDDOOR) {
  676. /*
  677. * Door didn't open.
  678. * Move the player back where they came from.
  679. */
  680. playerx = lastpx;
  681. playery = lastpy;
  682. lastpx = (char)dx;
  683. lastpy = (char)dy;
  684. }
  685. }
  686. break;
  687. case OENTRANCE:
  688. Print("\nYou have found ");
  689. Print(objectname[OENTRANCE]);
  690. Print("\nDo you (g) go inside");
  691. iopts();
  692. i = get_prompt_input("", "gi\033", 1);
  693. if (i == 'g') {
  694. newcavelevel(1);
  695. playerx = 33;
  696. playery = MAXY - 2;
  697. /* Make sure the entrance to the dungeon is clear */
  698. item[33][MAXY - 1] = ONOTHING;
  699. mitem[33][MAXY - 1].mon = MONST_NONE;
  700. draws(0, MAXX, 0, MAXY);
  701. UpdateStatusAndEffects();
  702. return;
  703. } else
  704. ignore();
  705. break;
  706. case OVOLDOWN:
  707. Print("\nYou have found ");
  708. Print(objectname[OVOLDOWN]);
  709. Print("\nDo you (c) climb down");
  710. iopts();
  711. i = get_prompt_input("", "ci\033", 1);
  712. if ((i == ESC) || (i == 'i')) {
  713. ignore();
  714. break;
  715. }
  716. if (level != 0) {
  717. Print("\nThe shaft only extends 5 feet downward!");
  718. return;
  719. }
  720. if (packweight() > 45 + 3 * (c[STRENGTH] + c[STREXTRA])) {
  721. Print("\nYou slip and fall down the shaft.");
  722. UlarnBeep();
  723. losehp(DIED_SLIPPED_VOLCANO_SHAFT, 30 + rnd(20));
  724. UpdateStatus();
  725. } else
  726. Print("climb down.");
  727. nap(3000);
  728. newcavelevel(DBOTTOM + 1); /* down to V1 */
  729. playerx = (char)rnd(MAXX - 2);
  730. playery = (char)rnd(MAXY - 2);
  731. positionplayer();
  732. draws(0, MAXX, 0, MAXY);
  733. UpdateStatusAndEffects();
  734. return;
  735. case OVOLUP:
  736. Print("\nYou have found ");
  737. Print(objectname[OVOLUP]);
  738. Print("\nDo you (c) climb up");
  739. iopts();
  740. i = get_prompt_input("", "ci\033", 1);
  741. if ((i == ESC) || (i == 'i')) {
  742. ignore();
  743. break;
  744. }
  745. if (packweight() > 40 + 5 * (c[DEXTERITY] + c[STRENGTH] + c[STREXTRA])) {
  746. Print("\nYou slip and fall down the shaft.");
  747. UlarnBeep();
  748. losehp(DIED_SLIPPED_VOLCANO_SHAFT, 15 + rnd(20));
  749. UpdateStatus();
  750. return;
  751. }
  752. Print("climb up.");
  753. nap(3000);
  754. newcavelevel(0);
  755. for (i = 0; i < MAXY; i++)
  756. for (j = 0; j < MAXX; j++) {
  757. /* put player near volcano shaft */
  758. if (item[j][i] == OVOLDOWN) {
  759. playerx = (char)j;
  760. playery = (char)i;
  761. j = MAXX;
  762. i = MAXY;
  763. positionplayer();
  764. }
  765. }
  766. draws(0, MAXX, 0, MAXY);
  767. UpdateStatusAndEffects();
  768. return;
  769. case OTRAPARROWIV:
  770. if (rnd(17) < 13)
  771. return; /* for an arrow trap */
  772. item[playerx][playery] = OTRAPARROW;
  773. case OTRAPARROW:
  774. Print("\nYou are hit by an arrow!");
  775. UlarnBeep(); /* for an arrow trap */
  776. losehp(DIED_SHOT_BY_ARROW, rnd(10) + level);
  777. UpdateStatus();
  778. return;
  779. case OIVDARTRAP:
  780. if (rnd(17) < 13)
  781. return; /* for a dart trap */
  782. item[playerx][playery] = ODARTRAP;
  783. case ODARTRAP:
  784. Print("\nYou are hit by a dart!");
  785. UlarnBeep(); /* for a dart trap */
  786. losehp(DIED_HIT_BY_DART, rnd(5));
  787. if ((--c[STRENGTH]) < 3)
  788. c[STRENGTH] = 3;
  789. UpdateStatus();
  790. return;
  791. case OIVTRAPDOOR:
  792. if (rnd(17) < 13)
  793. return; /* for a trap door */
  794. item[playerx][playery] = OTRAPDOOR;
  795. case OTRAPDOOR:
  796. for (i = 0; i < IVENSIZE; i++) {
  797. if (iven[i] == OWWAND) {
  798. Print("\nYou escape a trap door.");
  799. return;
  800. }
  801. }
  802. if ((level == DBOTTOM) || (level == VBOTTOM)) {
  803. Print("\nYou fall through a trap door leading straight to HELL!");
  804. UlarnBeep();
  805. nap(3000);
  806. died(DIED_FELL_THROUGH_BOTTOMLESS_TRAPDOOR, 0);
  807. }
  808. Print("\nYou fall through a trap door!");
  809. UlarnBeep();
  810. losehp(DIED_FELL_THROUGH_TRAPDOOR, rnd(5 + level));
  811. nap(2000);
  812. newcavelevel(level + 1);
  813. draws(0, MAXX, 0, MAXY);
  814. UpdateStatusAndEffects();
  815. return;
  816. case OTRADEPOST:
  817. if (nearbymonst())
  818. return;
  819. Print("\nYou have found the VLarn trading Post.");
  820. i = get_prompt_input("\nDo you (g) go inside, or (i) stay here? ", "gi\033",
  821. 1);
  822. if (i == 'g')
  823. otradepost();
  824. else
  825. Print("stay here.");
  826. return;
  827. case OHOME:
  828. if (nearbymonst())
  829. return;
  830. Print("\nYou have found your way home.");
  831. i = get_prompt_input("\nDo you (g) go inside, or (i) stay here? ", "gi\033",
  832. 1);
  833. if (i == 'g')
  834. ohome();
  835. else
  836. Print("stay here.");
  837. return;
  838. case OPAD:
  839. if (nearbymonst())
  840. return;
  841. Print("\nYou have found Dealer McDope's Hideout!");
  842. i = get_prompt_input("\nDo you (c) check it out, or (i) ignore it? ",
  843. "ci\033", 1);
  844. if (i == 'c')
  845. opad();
  846. else
  847. Print("forget it.");
  848. return;
  849. case OSPEED:
  850. Print("\nYou find some speed.");
  851. i = get_prompt_input(
  852. "\nDo you (s) snort it, (t) take it, or (i) ignore it? ", "sti\033", 1);
  853. if (i == 's') {
  854. Print("snort!");
  855. Print("\nOhwowmanlikethingstotallyseemtoslowdown!");
  856. c[HASTESELF] += 200 + c[LEVEL];
  857. c[HALFDAM] += 300 + rnd(200);
  858. adjust_ability(INTELLIGENCE, -2);
  859. adjust_ability(WISDOM, -2);
  860. adjust_ability(CONSTITUTION, -2);
  861. adjust_ability(DEXTERITY, -2);
  862. adjust_ability(STRENGTH, -2);
  863. forget();
  864. UpdateStatus();
  865. } else if (i == 't') {
  866. Print("take.");
  867. if (take(OSPEED, 0) == 0)
  868. forget();
  869. } else
  870. Print("ignore.");
  871. break;
  872. case OSHROOMS:
  873. Print("\nYou find some magic mushrooms.");
  874. i = get_prompt_input(
  875. "\nDo you (e) eat them, (t) take them, or (i) ignore them? ", "eti\033",
  876. 1);
  877. if (i == 'e') {
  878. Print("eat!");
  879. Print("\nThings start to get real spacey...");
  880. c[HASTEMONST] += rnd(75) + 25;
  881. c[CONFUSE] += 30 + rnd(10);
  882. adjust_ability(WISDOM, 2);
  883. adjust_ability(CHARISMA, 2);
  884. forget();
  885. UpdateStatus();
  886. } else if (i == 't') {
  887. Print("take.");
  888. if (take(OSHROOMS, 0) == 0)
  889. forget();
  890. } else
  891. Print("ignore.");
  892. break;
  893. case OACID:
  894. Print("\nYou find some LSD.");
  895. i = get_prompt_input("\nDo you (e) eat it, (t) take it, or (i) ignore it? ",
  896. "eit\033", 1);
  897. if (i == 'e') {
  898. Print("eat!");
  899. Print("\nYou are now frying your ass off!");
  900. c[CONFUSE] += 30 + rnd(10);
  901. adjust_ability(WISDOM, 2);
  902. adjust_ability(INTELLIGENCE, 2);
  903. c[AWARENESS] += 1500;
  904. c[AGGRAVATE] += 1500;
  905. {
  906. int j, k; /* heal monsters */
  907. for (j = 0; j < MAXY; j++) {
  908. for (k = 0; k < MAXX; k++)
  909. if (mitem[k][j].mon)
  910. hitp[k][j] = monster[(int)mitem[k][j].mon].hitpoints;
  911. }
  912. }
  913. forget();
  914. UpdateStatus();
  915. } else if (i == 't') {
  916. Print("take.");
  917. if (take(OACID, 0) == 0)
  918. forget();
  919. } else
  920. Print("ignore.");
  921. break;
  922. case OHASH:
  923. Print("\nYou find some hashish.");
  924. i = get_prompt_input(
  925. "\nDo you (s) smoke it, (t) take it, or (i) ignore it? ", "sti\033", 1);
  926. if (i == 's') {
  927. Print("smoke!");
  928. Print("\nWOW! You feel stooooooned...");
  929. c[HASTEMONST] += rnd(75) + 25;
  930. adjust_ability(INTELLIGENCE, 2);
  931. adjust_ability(WISDOM, 2);
  932. adjust_ability(CONSTITUTION, -2);
  933. adjust_ability(DEXTERITY, -2);
  934. c[HALFDAM] += 300 + rnd(200);
  935. c[CLUMSINESS] += rnd(1800) + 200;
  936. forget();
  937. UpdateStatus();
  938. } else if (i == 't') {
  939. Print("take.");
  940. if (take(OHASH, 0) == 0)
  941. forget();
  942. } else
  943. Print("ignore.");
  944. break;
  945. case OCOKE:
  946. Print("\nYou find some cocaine.");
  947. i = get_prompt_input(
  948. "\nDo you want to (s) snort it, (t) take it, or (i) ignore it? ",
  949. "sit\033", 1);
  950. if (i == 's') {
  951. Print("snort!");
  952. Print("\nYour nose begins to bleed!");
  953. adjust_ability(DEXTERITY, -2);
  954. adjust_ability(CONSTITUTION, -2);
  955. adjust_ability(CHARISMA, 3);
  956. for (i = ABILITY_FIRST; i <= ABILITY_LAST; i++)
  957. adjust_ability(i, 33);
  958. c[COKED] += 10;
  959. forget();
  960. UpdateStatus();
  961. } else if (i == 't') {
  962. Print("take.");
  963. if (take(OCOKE, 0) == 0)
  964. forget();
  965. } else
  966. Print("ignore.");
  967. break;
  968. case OWALL:
  969. break;
  970. case OANNIHILATION:
  971. if (player_has_item(OSPHTALISMAN)) {
  972. Print("\nThe Talisman of the Sphere protects you from annihilation!");
  973. return;
  974. }
  975. /* annihilated by sphere of annihilation */
  976. died(DIED_SPHERE_ANNIHILATION, 0);
  977. return;
  978. case OLRS:
  979. if (nearbymonst())
  980. return;
  981. Print("\n\nThere is an LRS office here.");
  982. i = get_prompt_input("\nDo you (g) go inside, or (i) stay here? ", "gi\033",
  983. 1);
  984. if (i == 'g') {
  985. olrs(); /* the larn revenue service */
  986. } else
  987. Print(" stay here.");
  988. break;
  989. default:
  990. finditem(i);
  991. break;
  992. }
  993. }