home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume3 / nethack2.2 / part16 / fountain.c < prev    next >
C/C++ Source or Header  |  1987-12-04  |  8KB  |  329 lines

  1. /*    SCCS Id: @(#)fountain.c    2.1    87/10/19
  2. /* fountain.c  v 1.4.3 */
  3.  
  4. /*
  5.  * Revision 1.4.3  87/11/25  19:16:00  M. Stephenson
  6.  * Implemented levitation bug fixes.
  7.  *
  8.  * Revision 1.4.2  87/10/19  11:48:00  M. Stephenson
  9.  * Implementation of KJS bug fixes.
  10.  *
  11.  * Revision 1.4.1  87/05/20  11:53:00  M. Stephenson
  12.  * Implementation of KAA bug fixes.
  13.  *
  14.  * Revision 1.4    87/05/04  17:39:00  M. Stephenson
  15.  * Integration of independent modifications
  16.  *
  17.  * Revision 1.3    87/03/02            Eric Backus
  18.  * Rearranged, and dipfountain added
  19.  * 
  20.  * Revision 1.2    87/03/01  13:59:59  gil
  21.  * patches
  22.  * 
  23.  * Revision 1.1    87/02/11  15:14:10  gil
  24.  * Initial revision
  25.  *
  26.  */
  27.  
  28. /* Code for drinking from fountains.   */
  29. /* Scott R. Turner, srt@ucla, 10/27/86 */
  30.  
  31. #include "hack.h"
  32.  
  33. extern struct monst *mkmon_at();
  34. extern struct obj *mkobj_at();
  35. extern char genocided[];
  36.  
  37. #ifdef FOUNTAINS
  38. #define somex() ((rand()%(croom->hx-croom->lx+1))+croom->lx)
  39. #define somey() ((rand()%(croom->hy-croom->ly+1))+croom->ly)
  40.  
  41. dowatersnakes() /* Fountain of snakes! */ {
  42.     register int num = rnd(6);
  43.     if (!index(genocided, 'S')) {
  44.  
  45.         pline("Good Lord!  An endless stream of snakes pours forth!");
  46.         while(num-- > 0) (void) mkmon_at('S',u.ux,u.uy);
  47.     } else
  48.         pline("The fountain bubbles furiously for a moment, then calms.");
  49. }
  50.  
  51. dowaterdemon() /* Water demon */ {
  52. register struct monst *mtmp;
  53.  
  54.     if((mtmp = mkmon_at('&',u.ux,u.uy))) {
  55.         pline("You have unleashed a water demon!");
  56.  
  57.     /* Give those on low levels a (slightly) better chance of survival */
  58.         if ( rnd(100) > (80 + dlevel)) {
  59.         pline("Grateful for his release, he grants you a wish!");
  60.         makewish();
  61.         mondied(mtmp);
  62.         }
  63.     }
  64. }
  65.  
  66. dowaternymph() /* Water Nymph */ {
  67.     register struct monst *mtmp;
  68.     if((mtmp = mkmon_at('N',u.ux,u.uy))) {
  69.  
  70.         pline("You have attracted a water nymph!");
  71.         mtmp->msleep = 0;
  72.     } else
  73.         pline("A large bubble rises to the surface and pops.");
  74. }
  75.  
  76. #include    "mkroom.h"
  77.  
  78. dogushforth() /* Gushing forth in this room */ {
  79. register int num = rnd(10);
  80. register xchar mx,my;
  81. register int tryct = 0;
  82. register int uroom = inroom(u.ux, u.uy);
  83. register struct mkroom *croom = &rooms[uroom];
  84. register int madepool = 0;
  85.  
  86.     if(croom->hx < 0 || has_upstairs(croom) ||
  87.        has_dnstairs(croom))  {
  88.         pline("Your thirst is quenched.");
  89.         return;
  90.     }
  91.     while(num--) {
  92.         do {
  93.         if(++tryct > 200)  {
  94.             if(madepool)
  95.             pline("Water gushes forth from the overflowing fountain!");
  96.             else
  97.             pline("Your thirst is quenched.");
  98.             return;
  99.         }
  100.         mx = somex();
  101.         my = somey();
  102.         } while(nexttodoor(mx,my) || !((mx+my)%2) ||
  103.             (mx == u.ux && my == u.uy) ||
  104.             (IS_POOL(levl[mx][my].typ)));
  105.                
  106.         /* Put a pool at mx, my */
  107.              
  108.         levl[mx][my].typ = POOL;
  109.         atl(mx,my,POOL_SYM);
  110.         madepool = 1;
  111.     }
  112.  
  113.     pline("Water gushes forth from the overflowing fountain!");
  114. }
  115.  
  116. dofindgem() /* Find a gem in the sparkling waters. */ {
  117.  
  118.     if (!Blind) pline("You spot a gem in the sparkling waters!");
  119.     mkobj_at('*',u.ux,u.uy);
  120. }
  121.  
  122. dryup(){
  123.     if (!rn2(3) && (levl[u.ux][u.uy].typ == FOUNTAIN)) {
  124.         pline("The fountain dries up!");
  125.         levl[u.ux][u.uy].typ = ROOM;
  126.         if(Invis) newsym(u.ux, u.uy);
  127.     }
  128. }
  129.  
  130. drinkfountain() {
  131.  
  132.     /* What happens when you drink from a fountain? */
  133.     register int fate = rnd(30);
  134.  
  135.     if(Levitation)     pline("You are floating high above the fountain.");
  136.     else if (fate < 10) {
  137.         pline("The cool draught refreshes you.");
  138.         lesshungry(rnd(10));
  139.     } else {
  140.         switch (fate) {
  141.  
  142.         case 20: /* Foul water */
  143.  
  144.             pline("The water is foul!  You gag and vomit.");
  145.             morehungry(rnd(20)+10);
  146.             if(Sick)  {
  147.                 Sick = 0;
  148.                 pline("What a relief!");
  149.             }
  150.             break;
  151.  
  152.         case 21: /* Poisonous */
  153.  
  154.             pline("The water is contaminated!");
  155.             if (Poison_resistance) {
  156.                pline("Perhaps it is run off from the nearby orange farm.");
  157.                losehp(rnd(4),"unrefrigerated orange juice");
  158.                break;
  159.             }
  160.             losestr(rn1(4,3));
  161.             losehp(rnd(10),"contaminated water");
  162.             break;
  163.     
  164.         case 22: /* Fountain of snakes! */
  165.             dowatersnakes();
  166.             break;
  167.  
  168.         case 23: /* Water demon */
  169.             dowaterdemon();
  170.             break;
  171.  
  172.         case 24: /* Curse an item... */ {
  173.             register struct obj *obj;
  174.  
  175.             pline("This water's no good!");
  176.             morehungry(rnd(20)+10);
  177.             for(obj = invent; obj ; obj = obj->nobj)
  178.                 if (!rn2(5))    obj->cursed++;
  179.             break;
  180.             }
  181.              
  182.         case 25: /* See invisible */
  183.  
  184.             pline("You see an image of someone stalking you.");
  185.             pline("But it disappears.");
  186.             HSee_invisible |= INTRINSIC;
  187.             break;
  188.  
  189.         case 26: /* See Monsters */ {
  190.             register struct monst *mtmp;
  191.  
  192.               if(!fmon) pline("You feel oddly disturbed.");
  193.               else {
  194.                 cls();
  195.                 for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
  196.                 if(mtmp->mx > 0)
  197.                     at(mtmp->mx,mtmp->my,mtmp->data->mlet);
  198.                 prme();
  199.                 pline("You sense the presence of monsters.");
  200.                 more();
  201.                 docrt();
  202.               }
  203.             }
  204.             break;
  205.  
  206.         case 27: /* Find a gem in the sparkling waters. */
  207.             dofindgem();
  208.             break;
  209.  
  210.         case 28: /* Water Nymph */
  211.             dowaternymph();
  212.             break;
  213.  
  214.         case 29: /* Scare */ {
  215.             register struct monst *mtmp;
  216.  
  217.             pline("This water gives you bad breath!");
  218.             for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) 
  219.                 mtmp->mflee = 1;
  220.             }
  221.             break;
  222.  
  223.         case 30: /* Gushing forth in this room */
  224.             dogushforth();
  225.             break;
  226.         default:
  227.             break;
  228.         }
  229.     }
  230.     dryup();
  231. }
  232.  
  233. dipfountain(obj)
  234. register struct obj *obj;
  235. {
  236.     register int fate = rnd(30);
  237.  
  238.     if(Levitation)     pline("You are floating high above the fountain.");
  239.     else if(fate<10)
  240.         if(!obj->rustfree &&
  241.             /* Only swords affected here */
  242.             (obj->otyp == LONG_SWORD ||
  243.             obj->otyp == KATANA ||
  244.             obj->otyp == BROAD_SWORD ||
  245.             obj->otyp == SHORT_SWORD ||
  246.             obj->otyp == TWO_HANDED_SWORD)) {
  247.             if(obj->spe > -6) {
  248.                 pline("Your weapon rusts somewhat.");
  249.                 obj->spe--;
  250.             } else pline("Your weapon looks quite rusted.");
  251.         } else pline("Well, it looks wet now.");
  252.     else if(fate<14)
  253.         if(obj->otyp == LONG_SWORD
  254. #ifndef RPH
  255.            && !strcmp(ONAME(obj), "Excalibur")
  256. #endif
  257.         ) {
  258.             /* The lady of the lake acts! - Eric Backus */
  259.             /* Be *REAL* nice to him */
  260.     pline("A murky hand from the depths reaches up to bless the sword.");
  261.     pline("As the hand retreats, the fountain disappears!");
  262. #ifndef RPH
  263.             if(obj->spe < 5) obj->spe = 5;
  264. #else
  265.             /* otherwise +rnd(10) / +5 "Super"sword */
  266.             oname(obj, "Excalibur");
  267. #endif
  268. #ifdef KAA
  269.             obj->dknown = 1;    /* blessed */
  270. #endif
  271.             obj->cursed = 0;
  272.             obj->rustfree = 1;
  273.             levl[u.ux][u.uy].typ = ROOM;
  274.             if(Invis) newsym(u.ux, u.uy);
  275.             return(0);
  276.         } else pline ("Well, it looks wet now.");
  277.     else {
  278.         switch (fate) {
  279.         case 16: /* Curse the item */
  280.             pline("Well, it looks wet now.");
  281.             obj->cursed = 1;
  282.             break;
  283.         case 17:
  284.         case 18:
  285.         case 19:
  286.         case 20: /* Uncurse the item */
  287.             if(obj->cursed) {
  288.                 pline("The water glows for a moment.");
  289.                 obj->cursed = 0;
  290.             } else {
  291.                 pline("A feeling of loss comes over you.");
  292.             }
  293.             break;
  294.         case 21: /* Water Demon */
  295.             dowaterdemon();
  296.             break;
  297.         case 22: /* Water Nymph */
  298.             dowaternymph();
  299.             break;
  300.         case 23: /* An Endless Stream Of Snakes */
  301.             dowatersnakes();
  302.             break;
  303.         case 24: /* Find a gem */
  304.             dofindgem();
  305.             break;
  306.         case 25: /* Water gushes forth */
  307.             dogushforth();
  308.             break;
  309.         case 26: /* Strange feeling */
  310.             pline("A strange tingling runs up your arm.");
  311.             break;
  312.         case 27: /* Strange feeling */
  313.             pline("You feel a sudden chill.");
  314.             break;
  315.         case 28: /* Strange feeling */
  316.         pline("An urge to take a bath nearly overwhelms you.");
  317.             break;
  318.         case 29: /* You see coins */
  319.         pline("Far below you, you see coins glistening in the water.");
  320.             break;
  321.         default:
  322.             break;
  323.         }
  324.     }
  325.     dryup();
  326.     return(0);
  327. }
  328. #endif
  329.