Source:NetHack 5.0.0/src/fountain.c

From NetHackWiki
Jump to navigation Jump to search

Below is the full text to fountain.c from the source code of NetHack 5.0.0. To link to a particular line, write [[Source:NetHack 5.0.0/src/fountain.c#line12]], for example.

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

1. /* NetHack 5.0	fountain.c	$NHDT-Date: 1699582923 2023/11/10 02:22:03 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.100 $ */
2. /*      Copyright Scott R. Turner, srt@ucla, 10/27/86 */
3. /* NetHack may be freely redistributed.  See license for details. */
4. 
5. /* Code for drinking from fountains. */
6. 
7. #include "hack.h"
8. 
9. staticfn void dowatersnakes(void);
10. staticfn void dowaterdemon(void);
11. staticfn void dowaternymph(void);
12. staticfn void gush(coordxy, coordxy, genericptr_t) NONNULLARG3;
13. staticfn void dofindgem(void);
14. staticfn boolean watchman_warn_fountain(struct monst *) NONNULLARG1;
15. 
16. DISABLE_WARNING_FORMAT_NONLITERAL
17. 
18. /* used when trying to dip in or drink from fountain or sink or pool while
19.    levitating above it, or when trying to move downwards in that state */
20. void
21. floating_above(const char *what)
22. {
23.     const char *umsg = "are floating high above the %s.";
24. 
25.     if (u.utrap && (u.utraptype == TT_INFLOOR || u.utraptype == TT_LAVA)) {
26.         /* when stuck in floor (not possible at fountain or sink location,
27.            so must be attempting to move down), override the usual message */
28.         umsg = "are trapped in the %s.";
29.         what = surface(u.ux, u.uy); /* probably redundant */
30.     }
31.     You(umsg, what);
32. }
33. 
34. RESTORE_WARNING_FORMAT_NONLITERAL
35. 
36. /* Fountain of snakes! */
37. staticfn void
38. dowatersnakes(void)
39. {
40.     int num = rn1(5, 2);
41.     struct monst *mtmp;
42. 
43.     if (!(svm.mvitals[PM_WATER_MOCCASIN].mvflags & G_GONE)) {
44.         if (!Blind) {
45.             pline("An endless stream of %s pours forth!",
46.                   Hallucination ? makeplural(rndmonnam(NULL)) : "snakes");
47.         } else {
48.             Soundeffect(se_snakes_hissing, 75);
49.             You_hear("%s hissing!", something);
50.         }
51.         while (num-- > 0)
52.             if ((mtmp = makemon(&mons[PM_WATER_MOCCASIN], u.ux, u.uy,
53.                                 MM_NOMSG)) != 0
54.                 && t_at(mtmp->mx, mtmp->my))
55.                 (void) mintrap(mtmp, NO_TRAP_FLAGS);
56.     } else {
57.         Soundeffect(se_furious_bubbling, 20);
58.         pline_The("fountain bubbles furiously for a moment, then calms.");
59.     }
60. }
61. 
62. /* Water demon */
63. staticfn void
64. dowaterdemon(void)
65. {
66.     struct monst *mtmp;
67. 
68.     if (!(svm.mvitals[PM_WATER_DEMON].mvflags & G_GONE)) {
69.         if ((mtmp = makemon(&mons[PM_WATER_DEMON], u.ux, u.uy,
70.                             MM_NOMSG)) != 0) {
71.             if (!Blind)
72.                 You("unleash %s!", a_monnam(mtmp));
73.             else
74.                 You_feel("the presence of evil.");
75. 
76.             /* Give those on low levels a (slightly) better chance of survival
77.              */
78.             if (rnd(100) > (80 + level_difficulty())) {
79.                 pline("Grateful for %s release, %s grants you a wish!",
80.                       mhis(mtmp), mhe(mtmp));
81.                 /* give a wish and discard the monster (mtmp set to null) */
82.                 mongrantswish(&mtmp);
83.             } else if (t_at(mtmp->mx, mtmp->my))
84.                 (void) mintrap(mtmp, NO_TRAP_FLAGS);
85.         }
86.     } else {
87.         Soundeffect(se_furious_bubbling, 20);
88.         pline_The("fountain bubbles furiously for a moment, then calms.");
89.     }
90. }
91. 
92. /* Water Nymph */
93. staticfn void
94. dowaternymph(void)
95. {
96.     struct monst *mtmp;
97. 
98.     if (!(svm.mvitals[PM_WATER_NYMPH].mvflags & G_GONE)
99.         && (mtmp = makemon(&mons[PM_WATER_NYMPH], u.ux, u.uy,
100.                            MM_NOMSG)) != 0) {
101.         if (!Blind)
102.             You("attract %s!", a_monnam(mtmp));
103.         else
104.             You_hear("a seductive voice.");
105.         mtmp->msleeping = 0;
106.         if (t_at(mtmp->mx, mtmp->my))
107.             (void) mintrap(mtmp, NO_TRAP_FLAGS);
108.     } else if (!Blind) {
109.         Soundeffect(se_bubble_rising, 50);
110.         Soundeffect(se_loud_pop, 50);
111.         pline("A large bubble rises to the surface and pops.");
112.     } else {
113.         Soundeffect(se_loud_pop, 50);
114.         You_hear("a loud pop.");
115.     }
116. }
117. 
118. /* Gushing forth along LOS from (u.ux, u.uy) */
119. void
120. dogushforth(int drinking)
121. {
122.     int madepool = 0;
123. 
124.     do_clear_area(u.ux, u.uy, 7, gush, (genericptr_t) &madepool);
125.     if (!madepool) {
126.         if (drinking)
127.             Your("thirst is quenched.");
128.         else
129.             pline("Water sprays all over you.");
130.     }
131. }
132. 
133. staticfn void
134. gush(coordxy x, coordxy y, genericptr_t poolcnt)
135. {
136.     struct monst *mtmp;
137.     struct trap *ttmp;
138. 
139.     if (((x + y) % 2) || u_at(x, y)
140.         || (rn2(1 + distmin(u.ux, u.uy, x, y))) || (levl[x][y].typ != ROOM)
141.         || (sobj_at(BOULDER, x, y)) || nexttodoor(x, y))
142.         return;
143. 
144.     if ((ttmp = t_at(x, y)) != 0 && !delfloortrap(ttmp))
145.         return;
146. 
147.     if (!((*(int *) poolcnt)++))
148.         pline("Water gushes forth from the overflowing fountain!");
149. 
150.     /* Put a pool at x, y */
151.     set_levltyp(x, y, POOL);
152.     levl[x][y].flags = 0;
153.     /* No kelp! */
154.     del_engr_at(x, y);
155.     water_damage_chain(svl.level.objects[x][y], TRUE);
156. 
157.     if ((mtmp = m_at(x, y)) != 0)
158.         (void) minliquid(mtmp);
159.     else
160.         newsym(x, y);
161. }
162. 
163. /* Find a gem in the sparkling waters. */
164. staticfn void
165. dofindgem(void)
166. {
167.     if (!Blind)
168.         You("spot a gem in the sparkling waters!");
169.     else
170.         You_feel("a gem here!");
171.     (void) mksobj_at(rnd_class(DILITHIUM_CRYSTAL, LUCKSTONE - 1), u.ux, u.uy,
172.                      FALSE, FALSE);
173.     SET_FOUNTAIN_LOOTED(u.ux, u.uy);
174.     newsym(u.ux, u.uy);
175.     exercise(A_WIS, TRUE); /* a discovery! */
176. }
177. 
178. staticfn boolean
179. watchman_warn_fountain(struct monst *mtmp)
180. {
181.     if (is_watch(mtmp->data) && couldsee(mtmp->mx, mtmp->my)
182.         && mtmp->mpeaceful) {
183.         if (!Deaf) {
184.             pline("%s yells:", Amonnam(mtmp));
185.             verbalize("Hey, stop using that fountain!");
186.         } else {
187.             pline("%s earnestly %s %s %s!",
188.                   Amonnam(mtmp),
189.                   nolimbs(mtmp->data) ? "shakes" : "waves",
190.                   mhis(mtmp),
191.                   nolimbs(mtmp->data)
192.                   ? mbodypart(mtmp, HEAD)
193.                   : makeplural(mbodypart(mtmp, ARM)));
194.         }
195.         return TRUE;
196.     }
197.     return FALSE;
198. }
199. 
200. void
201. dryup(coordxy x, coordxy y, boolean isyou)
202. {
203.     if (IS_FOUNTAIN(levl[x][y].typ)
204.         && (!rn2(3) || FOUNTAIN_IS_WARNED(x, y))) {
205.         if (isyou && in_town(x, y) && !FOUNTAIN_IS_WARNED(x, y)) {
206.             struct monst *mtmp;
207. 
208.             SET_FOUNTAIN_WARNED(x, y);
209.             /* Warn about future fountain use. */
210.             mtmp = get_iter_mons(watchman_warn_fountain);
211.             /* You can see or hear this effect */
212.             if (!mtmp)
213.                 pline_The("flow reduces to a trickle.");
214.             return;
215.         }
216.         if (isyou && wizard) {
217.             if (y_n("Dry up fountain?") == 'n')
218.                 return;
219.         }
220.         /* FIXME: sight-blocking clouds should use block_point() when
221.            being created and unblock_point() when going away, then this
222.            glyph hackery wouldn't be necessary */
223.         if (cansee(x, y)) {
224.             int glyph = glyph_at(x, y);
225. 
226.             if (!glyph_is_cmap(glyph) || glyph_to_cmap(glyph) != S_cloud)
227.                 pline_The("fountain dries up!");
228.         }
229.         /* replace the fountain with ordinary floor */
230.         set_levltyp(x, y, ROOM); /* updates level.flags.nfountains */
231.         levl[x][y].flags = 0;
232.         levl[x][y].blessedftn = 0;
233.         /* The location is seen if the hero/monster is invisible
234.            or felt if the hero is blind. */
235.         newsym(x, y);
236.         if (isyou && in_town(x, y))
237.             (void) angry_guards(FALSE);
238.     }
239. }
240. 
241. /* quaff from a fountain when standing on its location */
242. void
243. drinkfountain(void)
244. {
245.     /* What happens when you drink from a fountain? */
246.     boolean mgkftn = (levl[u.ux][u.uy].blessedftn == 1);
247.     int fate = rnd(30);
248. 
249.     if (Levitation) {
250.         floating_above("fountain");
251.         return;
252.     }
253. 
254.     if (mgkftn && u.uluck >= 0 && fate >= 10) {
255.         int i, ii, littleluck = (u.uluck < 4);
256. 
257.         pline("Wow!  This makes you feel great!");
258.         /* blessed restore ability */
259.         for (ii = 0; ii < A_MAX; ii++)
260.             if (ABASE(ii) < AMAX(ii)) {
261.                 ABASE(ii) = AMAX(ii);
262.                 disp.botl = TRUE;
263.             }
264.         /* gain ability, blessed if "natural" luck is high */
265.         i = rn2(A_MAX); /* start at a random attribute */
266.         for (ii = 0; ii < A_MAX; ii++) {
267.             if (adjattrib(i, 1, littleluck ? -1 : 0) && littleluck)
268.                 break;
269.             if (++i >= A_MAX)
270.                 i = 0;
271.         }
272.         display_nhwindow(WIN_MESSAGE, FALSE);
273.         pline("A wisp of vapor escapes the fountain...");
274.         exercise(A_WIS, TRUE);
275.         levl[u.ux][u.uy].blessedftn = 0;
276.         return;
277.     }
278. 
279.     if (fate < 10) {
280.         pline_The("cool draught refreshes you.");
281.         u.uhunger += rnd(10); /* don't choke on water */
282.         newuhs(FALSE);
283.         if (mgkftn)
284.             return;
285.     } else {
286.         switch (fate) {
287.         case 19: /* Self-knowledge */
288.             You_feel("self-knowledgeable...");
289.             display_nhwindow(WIN_MESSAGE, FALSE);
290.             enlightenment(MAGICENLIGHTENMENT, ENL_GAMEINPROGRESS);
291.             exercise(A_WIS, TRUE);
292.             pline_The("feeling subsides.");
293.             break;
294.         case 20: /* Foul water */
295.             pline_The("water is foul!  You gag and vomit.");
296.             morehungry(rn1(20, 11));
297.             vomit();
298.             break;
299.         case 21: /* Poisonous */
300.             pline_The("water is contaminated!");
301.             if (Poison_resistance) {
302.                 pline("Perhaps it is runoff from the nearby %s farm.",
303.                       fruitname(FALSE));
304.                 losehp(rnd(4), "unrefrigerated sip of juice", KILLED_BY_AN);
305.                 break;
306.             }
307.             poison_strdmg(rn1(4, 3), rnd(10), "contaminated water",
308.                           KILLED_BY);
309.             exercise(A_CON, FALSE);
310.             break;
311.         case 22: /* Fountain of snakes! */
312.             dowatersnakes();
313.             break;
314.         case 23: /* Water demon */
315.             dowaterdemon();
316.             break;
317.         case 24: { /* Maybe curse some items */
318.             struct obj *obj, *nextobj;
319.             int buc_changed = 0;
320. 
321.             pline("This water's no good!");
322.             morehungry(rn1(20, 11));
323.             exercise(A_CON, FALSE);
324.             /* this is more severe than rndcurse() */
325.             for (obj = gi.invent; obj; obj = nextobj) {
326.                 nextobj = obj->nobj;
327.                 if (obj->oclass != COIN_CLASS && !obj->cursed && !rn2(5)) {
328.                     curse(obj);
329.                     ++buc_changed;
330.                 }
331.             }
332.             if (buc_changed)
333.                 update_inventory();
334.             break;
335.         }
336.         case 25: /* See invisible */
337.             if (Blind) {
338.                 if (Invisible) {
339.                     You("feel transparent.");
340.                 } else {
341.                     You("feel very self-conscious.");
342.                     pline("Then it passes.");
343.                 }
344.             } else {
345.                 You_see("an image of someone stalking you.");
346.                 pline("But it disappears.");
347.             }
348.             HSee_invisible |= FROMOUTSIDE;
349.             newsym(u.ux, u.uy);
350.             exercise(A_WIS, TRUE);
351.             break;
352.         case 26: /* See Monsters */
353.             if (monster_detect((struct obj *) 0, 0))
354.                 pline_The("%s tastes like nothing.", hliquid("water"));
355.             exercise(A_WIS, TRUE);
356.             break;
357.         case 27: /* Find a gem in the sparkling waters. */
358.             if (!FOUNTAIN_IS_LOOTED(u.ux, u.uy)) {
359.                 dofindgem();
360.                 break;
361.             }
362.             FALLTHROUGH;
363.             /*FALLTHRU*/
364.         case 28: /* Water Nymph */
365.             dowaternymph();
366.             break;
367.         case 29: /* Scare */
368.         {
369.             struct monst *mtmp;
370. 
371.             pline("This %s gives you bad breath!",
372.                   hliquid("water"));
373.             for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
374.                 if (DEADMONSTER(mtmp))
375.                     continue;
376.                 monflee(mtmp, 0, FALSE, FALSE);
377.             }
378.             break;
379.         }
380.         case 30: /* Gushing forth in this room */
381.             dogushforth(TRUE);
382.             break;
383.         default:
384.             pline("This tepid %s is tasteless.",
385.                   hliquid("water"));
386.             break;
387.         }
388.     }
389.     dryup(u.ux, u.uy, TRUE);
390. }
391. 
392. /* dip an object into a fountain when standing on its location */
393. void
394. dipfountain(struct obj *obj)
395. {
396.     int er = ER_NOTHING;
397.     boolean is_hands = (obj == &hands_obj);
398. 
399.     if (Levitation) {
400.         floating_above("fountain");
401.         return;
402.     }
403. 
404.     if (obj->otyp == LONG_SWORD && u.ulevel >= 5
405.         && !rn2(Role_if(PM_KNIGHT) ? 6 : 30)
406.         /* once upon a time it was possible to poly N daggers into N swords */
407.         && obj->quan == 1L && !obj->oartifact
408.         && !exist_artifact(LONG_SWORD, artiname(ART_EXCALIBUR))) {
409.         static const char lady[] = "Lady of the Lake";
410. 
411.         if (u.ualign.type != A_LAWFUL) {
412.             /* Ha!  Trying to cheat her. */
413.             pline("A freezing mist rises from the %s"
414.                   " and envelopes the sword.",
415.                   hliquid("water"));
416.             pline_The("fountain disappears!");
417.             curse(obj);
418.             if (obj->spe > -6 && !rn2(3))
419.                 obj->spe--;
420.             obj->oerodeproof = FALSE;
421.             exercise(A_WIS, FALSE);
422.             livelog_printf(LL_ARTIFACT,
423.                            "was denied %s!  The %s has deemed %s unworthy",
424.                            artiname(ART_EXCALIBUR), lady, uhim());
425.         } else {
426.             /* The lady of the lake acts! - Eric Backus */
427.             /* Be *REAL* nice */
428.             pline(
429.               "From the murky depths, a hand reaches up to bless the sword.");
430.             pline("As the hand retreats, the fountain disappears!");
431.             obj = oname(obj, artiname(ART_EXCALIBUR),
432.                         ONAME_VIA_DIP | ONAME_KNOW_ARTI);
433.             discover_artifact(ART_EXCALIBUR);
434.             bless(obj);
435.             obj->oeroded = obj->oeroded2 = 0;
436.             obj->oerodeproof = TRUE;
437.             exercise(A_WIS, TRUE);
438.             livelog_printf(LL_ARTIFACT, "was given %s by the %s",
439.                            artiname(ART_EXCALIBUR), lady);
440.         }
441.         update_inventory();
442.         set_levltyp(u.ux, u.uy, ROOM); /* updates level.flags.nfountains */
443.         levl[u.ux][u.uy].flags = 0;
444.         newsym(u.ux, u.uy);
445.         if (in_town(u.ux, u.uy))
446.             (void) angry_guards(FALSE);
447.         return;
448.     } else if (is_hands || obj == uarmg) {
449.         er = wash_hands();
450.     } else {
451.         er = water_damage(obj, NULL, TRUE);
452.     }
453. 
454.     if (er == ER_DESTROYED || (er != ER_NOTHING && !rn2(2))) {
455.         return; /* no further effect */
456.     }
457. 
458.     switch (rnd(30)) {
459.     case 16: /* Curse the item */
460.         if (!is_hands && obj->oclass != COIN_CLASS && !obj->cursed) {
461.             curse(obj);
462.         }
463.         break;
464.     case 17:
465.     case 18:
466.     case 19:
467.     case 20: /* Uncurse the item */
468.         if (!is_hands && obj->cursed) {
469.             if (!Blind)
470.                 pline_The("%s glows for a moment.", hliquid("water"));
471.             uncurse(obj);
472.         } else {
473.             pline("A feeling of loss comes over you.");
474.         }
475.         break;
476.     case 21: /* Water Demon */
477.         dowaterdemon();
478.         break;
479.     case 22: /* Water Nymph */
480.         dowaternymph();
481.         break;
482.     case 23: /* an Endless Stream of Snakes */
483.         dowatersnakes();
484.         break;
485.     case 24: /* Find a gem */
486.         if (!FOUNTAIN_IS_LOOTED(u.ux, u.uy)) {
487.             dofindgem();
488.             break;
489.         }
490.         FALLTHROUGH;
491.         /*FALLTHRU*/
492.     case 25: /* Water gushes forth */
493.         dogushforth(FALSE);
494.         break;
495.     case 26: /* Strange feeling */
496.         pline("A strange tingling runs up your %s.", body_part(ARM));
497.         break;
498.     case 27: /* Strange feeling */
499.         You_feel("a sudden chill.");
500.         break;
501.     case 28: /* Strange feeling */
502.         pline("An urge to take a bath overwhelms you.");
503.         {
504.             long money = money_cnt(gi.invent);
505.             struct obj *otmp, *nextobj;
506. 
507.             if (money > 10) {
508.                 /* Amount to lose.  Might get rounded up as fountains don't
509.                  * pay change... */
510.                 money = somegold(money) / 10;
511.                 for (otmp = gi.invent; otmp && money > 0; otmp = nextobj) {
512.                     nextobj = otmp->nobj;
513.                     if (otmp->oclass == COIN_CLASS) {
514.                         int denomination = objects[otmp->otyp].oc_cost;
515.                         long coin_loss =
516.                             (money + denomination - 1) / denomination;
517.                         coin_loss = min(coin_loss, otmp->quan);
518.                         otmp->quan -= coin_loss;
519.                         money -= coin_loss * denomination;
520.                         if (!otmp->quan)
521.                             delobj(otmp);
522.                     }
523.                 }
524.                 You("lost some of your gold in the fountain!");
525.                 CLEAR_FOUNTAIN_LOOTED(u.ux, u.uy);
526.                 exercise(A_WIS, FALSE);
527.             }
528.         }
529.         break;
530.     case 29: /* You see coins */
531.         /* We make fountains have more coins the closer you are to the
532.          * surface.  After all, there will have been more people going
533.          * by.  Just like a shopping mall!  Chris Woodbury  */
534. 
535.         if (FOUNTAIN_IS_LOOTED(u.ux, u.uy))
536.             break;
537.         SET_FOUNTAIN_LOOTED(u.ux, u.uy);
538.         (void) mkgold((long) (rnd((dunlevs_in_dungeon(&u.uz) - dunlev(&u.uz)
539.                                    + 1) * 2) + 5),
540.                       u.ux, u.uy);
541.         if (!Blind)
542.             pline("Far below you, you see coins glistening in the %s.",
543.                   hliquid("water"));
544.         exercise(A_WIS, TRUE);
545.         newsym(u.ux, u.uy);
546.         break;
547.     default:
548.         if (er == ER_NOTHING)
549.             pline1(nothing_seems_to_happen);
550.         break;
551.     }
552.     update_inventory();
553.     dryup(u.ux, u.uy, TRUE);
554. }
555. 
556. /* dipping '-' in fountain, pool, or sink */
557. int
558. wash_hands(void)
559. {
560.     const char *hands = makeplural(body_part(HAND));
561.     int res = ER_NOTHING;
562.     boolean was_glib = !!Glib;
563. 
564.     You("wash your %s%s in the %s.", uarmg ? "gloved " : "", hands,
565.         hliquid("water"));
566.     if (Glib) {
567.         make_glib(0);
568.         Your("%s are no longer slippery.", fingers_or_gloves(TRUE));
569.     }
570.     if (uarmg)
571.         res = water_damage(uarmg, (const char *) 0, TRUE);
572.     /* not what ER_GREASED is for, but the checks in dipfountain just
573.        compare the result to ER_DESTROYED and ER_NOTHING, so it works */
574.     if (was_glib && res == ER_NOTHING)
575.         res = ER_GREASED;
576.     return res;
577. }
578. 
579. /* convert a sink into a fountain */
580. void
581. breaksink(coordxy x, coordxy y)
582. {
583.     if (cansee(x, y) || u_at(x, y))
584.         pline_The("pipes break!  Water spurts out!");
585.     /* updates level.flags.nsinks and level.flags.nfountains */
586.     set_levltyp(x, y, FOUNTAIN);
587.     levl[x][y].looted = 0;
588.     levl[x][y].blessedftn = 0;
589.     SET_FOUNTAIN_LOOTED(x, y);
590.     newsym(x, y);
591. }
592. 
593. /* quaff from a sink while standing on its location */
594. void
595. drinksink(void)
596. {
597.     struct obj *otmp;
598.     struct monst *mtmp;
599. 
600.     if (Levitation) {
601.         floating_above("sink");
602.         return;
603.     }
604.     switch (rn2(20)) {
605.     case 0:
606.         You("take a sip of very cold %s.", hliquid("water"));
607.         break;
608.     case 1:
609.         You("take a sip of very warm %s.", hliquid("water"));
610.         break;
611.     case 2:
612.         You("take a sip of scalding hot %s.", hliquid("water"));
613.         if (Fire_resistance) {
614.             pline("It seems quite tasty.");
615.             monstseesu(M_SEEN_FIRE);
616.         } else {
617.             losehp(rnd(6), "sipping boiling water", KILLED_BY);
618.             monstunseesu(M_SEEN_FIRE);
619.         }
620.         /* boiling water burns considered fire damage */
621.         break;
622.     case 3:
623.         if (svm.mvitals[PM_SEWER_RAT].mvflags & G_GONE)
624.             pline_The("sink seems quite dirty.");
625.         else {
626.             mtmp = makemon(&mons[PM_SEWER_RAT], u.ux, u.uy, MM_NOMSG);
627.             if (mtmp)
628.                 pline("Eek!  There's %s in the sink!",
629.                       (Blind || !canspotmon(mtmp)) ? "something squirmy"
630.                                                    : a_monnam(mtmp));
631.         }
632.         break;
633.     case 4:
634.         for (;;) {
635.             otmp = mkobj(POTION_CLASS, FALSE);
636.             if (otmp->otyp != POT_WATER)
637.                 break;
638.             /* reject water and try again */
639.             obfree(otmp, (struct obj *) 0);
640.         }
641.         otmp->cursed = otmp->blessed = 0;
642.         pline("Some %s liquid flows from the faucet.",
643.               Blind ? "odd" : hcolor(OBJ_DESCR(objects[otmp->otyp])));
644.         if(!(Blind || Hallucination))
645.             observe_object(otmp);
646.         otmp->quan++;       /* Avoid panic upon useup() */
647.         otmp->fromsink = 1; /* kludge for docall() */
648.         (void) dopotion(otmp);
649.         obfree(otmp, (struct obj *) 0);
650.         break;
651.     case 5:
652.         if (!(levl[u.ux][u.uy].looted & S_LRING)) {
653.             You("find a ring in the sink!");
654.             (void) mkobj_at(RING_CLASS, u.ux, u.uy, TRUE);
655.             levl[u.ux][u.uy].looted |= S_LRING;
656.             exercise(A_WIS, TRUE);
657.             newsym(u.ux, u.uy);
658.         } else
659.             pline("Some dirty %s backs up in the drain.", hliquid("water"));
660.         break;
661.     case 6:
662.         breaksink(u.ux, u.uy);
663.         break;
664.     case 7:
665.         pline_The("%s moves as though of its own will!", hliquid("water"));
666.         if ((svm.mvitals[PM_WATER_ELEMENTAL].mvflags & G_GONE)
667.             || !makemon(&mons[PM_WATER_ELEMENTAL], u.ux, u.uy, MM_NOMSG))
668.             pline("But it quiets down.");
669.         break;
670.     case 8:
671.         pline("Yuk, this %s tastes awful.", hliquid("water"));
672.         more_experienced(1, 0);
673.         newexplevel();
674.         break;
675.     case 9:
676.         pline("Gaggg... this tastes like sewage!  You vomit.");
677.         morehungry(rn1(30 - ACURR(A_CON), 11));
678.         vomit();
679.         break;
680.     case 10:
681.         pline("This %s contains toxic wastes!", hliquid("water"));
682.         if (!Unchanging) {
683.             You("undergo a freakish metamorphosis!");
684.             polyself(POLY_NOFLAGS);
685.         }
686.         break;
687.     /* more odd messages --JJB */
688.     case 11:
689.         Soundeffect(se_clanking_pipe, 50);
690.         You_hear("clanking from the pipes...");
691.         break;
692.     case 12:
693.         Soundeffect(se_sewer_song, 100);
694.         You_hear("snatches of song from among the sewers...");
695.         break;
696.     case 13:
697.         pline("Ew, what a stench!");
698.         create_gas_cloud(u.ux, u.uy, 1, 4);
699.         break;
700.     case 19:
701.         if (Hallucination) {
702.             pline("From the murky drain, a hand reaches up... --oops--");
703.             break;
704.         }
705.         FALLTHROUGH;
706.         /*FALLTHRU*/
707.     default:
708.         You("take a sip of %s %s.",
709.             rn2(3) ? (rn2(2) ? "cold" : "warm") : "hot",
710.             hliquid("water"));
711.     }
712. }
713. 
714. /* for #dip(potion.c) when standing on a sink */
715. void
716. dipsink(struct obj *obj)
717. {
718.     boolean try_call = FALSE,
719.             not_looted_yet = (levl[u.ux][u.uy].looted & S_LRING) == 0,
720.             is_hands = (obj == &hands_obj || (uarmg && obj == uarmg));
721. 
722.     if (!rn2(not_looted_yet ? 25 : 15)) {
723.         /* can't rely on using sink for unlimited scroll blanking; however,
724.            since sink will be converted into a fountain, hero can dip again */
725.         breaksink(u.ux, u.uy); /* "The pipes break!  Water spurts out!" */
726.         if (Glib && is_hands)
727.             Your("%s are still slippery.", fingers_or_gloves(TRUE));
728.         return;
729.     } else if (is_hands) {
730.         (void) wash_hands();
731.         return;
732.     } else if (obj->oclass != POTION_CLASS) {
733.         You("hold %s under the tap.", the(xname(obj)));
734.         if (water_damage(obj, (const char *) 0, TRUE) == ER_NOTHING)
735.             pline1(nothing_seems_to_happen);
736.         return;
737.     }
738. 
739.     /* at this point the object must be a potion */
740.     You("pour %s%s down the drain.", (obj->quan > 1L ? "one of " : ""),
741.         the(xname(obj)));
742.     switch (obj->otyp) {
743.     case POT_POLYMORPH:
744.         polymorph_sink();
745.         try_call = TRUE;
746.         break;
747.     case POT_OIL:
748.         if (!Blind) {
749.             pline("It leaves an oily film on the basin.");
750.             try_call = TRUE;
751.         } else {
752.             pline1(nothing_seems_to_happen);
753.         }
754.         break;
755.     case POT_ACID:
756.         /* acts like a drain cleaner product */
757.         try_call = TRUE;
758.         if (!Blind) {
759.             pline_The("drain seems less clogged.");
760.         } else if (!Deaf) {
761.             You_hear("a sucking sound.");
762.         } else {
763.             pline1(nothing_seems_to_happen);
764.             try_call = FALSE;
765.         }
766.         break;
767.     case POT_LEVITATION:
768.         sink_backs_up(u.ux, u.uy);
769.         try_call = TRUE;
770.         break;
771.     case POT_OBJECT_DETECTION:
772.         if (!(levl[u.ux][u.uy].looted & S_LRING)) {
773.             You("sense a ring lost down the drain.");
774.             try_call = TRUE;
775.             break;
776.         }
777.         FALLTHROUGH;
778.         /* FALLTHRU */
779.     case POT_GAIN_LEVEL:
780.     case POT_GAIN_ENERGY:
781.     case POT_MONSTER_DETECTION:
782.     case POT_FRUIT_JUICE:
783.     case POT_WATER:
784.         /* potions with no potionbreathe() effects, plus water.  if effects
785.            are added to potionbreathe these should go to that instead (except
786.            for water). */
787.         pline1(nothing_seems_to_happen);
788.         break;
789.     default:
790.         /* hero can feel the vapor on her skin, so no need to check Blind or
791.            breathless for this message */
792.         pline("A wisp of vapor rises up...");
793.         /* NB: potionbreathe calls trycall or makeknown as appropriate */
794.         if (!breathless(gy.youmonst.data) || haseyes(gy.youmonst.data))
795.             potionbreathe(obj);
796.         break;
797.     }
798.     if (try_call && obj->dknown)
799.         trycall(obj);
800.     useup(obj);
801. }
802. 
803. /* find a ring in a sink */
804. void
805. sink_backs_up(coordxy x, coordxy y)
806. {
807.     char buf[BUFSZ];
808. 
809.     if (!Blind)
810.         Strcpy(buf, "Muddy waste pops up from the drain");
811.     else if (!Deaf)
812.         Strcpy(buf, "You hear a sloshing sound"); /* Deaf-aware */
813.     else
814.         Sprintf(buf, "Something splashes you in the %s", body_part(FACE));
815.     pline("%s%s.", !Deaf ? "Flupp!  " : "", buf);
816. 
817.     if (!(levl[x][y].looted & S_LRING)) { /* once per sink */
818.         if (!Blind)
819.             You_see("a ring shining in its midst.");
820.         (void) mkobj_at(RING_CLASS, x, y, TRUE);
821.         newsym(x, y);
822.         exercise(A_DEX, TRUE);
823.         exercise(A_WIS, TRUE); /* a discovery! */
824.         levl[x][y].looted |= S_LRING;
825.     }
826. }
827. 
828. /*fountain.c*/