home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Games / NetHack 3.1.3 / source / src / sit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-01  |  8.9 KB  |  371 lines  |  [TEXT/R*ch]

  1. /*    SCCS Id: @(#)sit.c    3.1    93/05/19    */
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3. /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5. #include "hack.h"
  6. #include "artifact.h"
  7.  
  8. void
  9. take_gold()
  10. {
  11.     if (u.ugold <= 0)  {
  12.         You("feel a strange sensation.");
  13.     } else {
  14.         You("notice you have no gold!");
  15.         u.ugold = 0;
  16.         flags.botl = 1;
  17.     }
  18. }
  19.  
  20. int
  21. dosit()
  22. {
  23.     static const char *sit_message = "sit on the %s.";
  24.     register struct trap *trap;
  25.     register int typ = levl[u.ux][u.uy].typ;
  26.  
  27.     if(Levitation)  {
  28.         pline("You're sitting on air.");
  29.         return 0;
  30.     } 
  31.  
  32.     if(OBJ_AT(u.ux, u.uy)) { 
  33.         register struct obj *obj;
  34.  
  35.         obj = level.objects[u.ux][u.uy];
  36.         You("sit on %s.", the(xname(obj)));
  37.         if(!Is_box(obj)) pline("It's not very comfortable...");
  38.  
  39.     } else if ((trap = t_at(u.ux, u.uy)) != 0) {
  40.  
  41.         if (u.utrap) {
  42.         exercise(A_WIS, FALSE);    /* you're getting stuck longer */
  43.         if(u.utraptype == TT_BEARTRAP) {
  44.             You("can't sit down with your %s in the bear trap.", body_part(FOOT));
  45.             u.utrap++;
  46.             } else if(u.utraptype == TT_PIT) {
  47.             if(trap->ttyp == SPIKED_PIT) {
  48.             You("sit down on a spike.  Ouch!");
  49.             losehp(1, "sitting on an iron spike", KILLED_BY);
  50.             exercise(A_STR, FALSE);
  51.             } else
  52.             You("sit down in the pit.");
  53.             u.utrap += rn2(5);
  54.         } else if(u.utraptype == TT_WEB) {
  55.             You("sit in the spider web and get entangled further!");
  56.             u.utrap += rn1(10, 5);
  57.         } else if(u.utraptype == TT_LAVA) {
  58.             /* Must have fire resistance or they'd be dead already */
  59.             You("sit in the lava!");
  60.             u.utrap += rnd(4);
  61.             losehp(d(2,10), "sitting in lava", KILLED_BY);
  62.         } else if(u.utraptype == TT_INFLOOR) {
  63.             You("can't maneuver to sit!");
  64.             u.utrap++;
  65.         }
  66.         } else {
  67.             You("sit down.");
  68.         dotrap(trap);
  69.         }
  70.     } else if(Underwater || Is_waterlevel(&u.uz)) {
  71.         if (Is_waterlevel(&u.uz))
  72.         pline("There are no cushions floating nearby.");
  73.         else
  74.         You("sit down in the muddy bottom.");
  75.     } else if(is_pool(u.ux, u.uy)) {
  76.  
  77.         You("sit in the water.");
  78.         if (!rn2(10) && uarm)
  79.         (void) rust_dmg(uarm, "armor", 1, TRUE);
  80. #ifdef POLYSELF
  81.         /* Note: without POLYSELF, this can't _happen_ without */
  82.         /* water walking boots.... */
  83.         if (!rn2(10) && uarmf && uarmf->otyp != WATER_WALKING_BOOTS)
  84.         (void) rust_dmg(uarm, "armor", 1, TRUE);
  85. #endif
  86. #ifdef SINKS
  87.     } else if(IS_SINK(typ)) {
  88.  
  89.         You(sit_message, defsyms[S_sink].explanation);
  90.         Your("%s gets wet.", humanoid(uasmon) ? "rump" : "underside");
  91. #endif
  92.     } else if(IS_ALTAR(typ)) {
  93.  
  94.         You(sit_message, defsyms[S_altar].explanation);
  95.         altar_wrath(u.ux, u.uy);
  96.  
  97.     } else if(typ == STAIRS) {
  98.  
  99.         You(sit_message, "stairs");
  100.  
  101.     } else if(typ == LADDER) {
  102.  
  103.         You(sit_message, "ladder");
  104.  
  105.     } else if (is_lava(u.ux, u.uy)) {
  106.  
  107.         /* must be WWalking */
  108.         You(sit_message, "lava");
  109.         pline("The lava burns you!");
  110.         losehp(d((Fire_resistance ? 2 : 10), 10),
  111.            "sitting on lava", KILLED_BY);
  112.  
  113.     } else if (is_ice(u.ux, u.uy)) {
  114.  
  115.         You(sit_message, defsyms[S_ice].explanation);
  116.         if (!Cold_resistance) pline("The ice feels cold.");
  117.  
  118.     } else if (typ == DRAWBRIDGE_DOWN) {
  119.  
  120.         You(sit_message, "drawbridge");
  121.  
  122.     } else if(IS_THRONE(typ)) {
  123.  
  124.         You(sit_message, defsyms[S_throne].explanation);
  125.         if (rnd(6) > 4)  {
  126.         switch (rnd(13))  {
  127.             case 1:
  128.             (void) adjattrib(rn2(A_MAX), -rn1(4,3), FALSE);
  129.             losehp(rnd(10), "cursed throne", KILLED_BY_AN);
  130.             break;
  131.             case 2:
  132.             (void) adjattrib(rn2(A_MAX), 1, FALSE);
  133.             break;
  134.             case 3:
  135.             pline("A%s electric shock shoots through your body!",
  136.                   (Shock_resistance) ? "" : " massive");
  137.             losehp(Shock_resistance ? rnd(6) : rnd(30),
  138.                    "electric chair", KILLED_BY_AN);
  139.             exercise(A_CON, FALSE);
  140.             break;
  141.             case 4:
  142.             You("feel much, much better!");
  143.             if(u.uhp >= (u.uhpmax - 5))  u.uhpmax += 4;
  144.             u.uhp = u.uhpmax;
  145.             make_blinded(0L,TRUE);
  146.             make_sick(0L,FALSE);
  147.             heal_legs();
  148.             flags.botl = 1;
  149.             break;
  150.             case 5:
  151.             take_gold();
  152.             break;
  153.             case 6:
  154.             if(u.uluck + rn2(5) < 0) {
  155.                 You("feel your luck is changing.");
  156.                 change_luck(1);
  157.             } else        makewish();
  158.             break;
  159.             case 7:
  160.             {
  161.             register int cnt = rnd(10);
  162.  
  163.             pline("A voice echoes:");
  164.             verbalize("Thy audience hath been summoned, %s!",
  165.                   flags.female ? "Dame" : "Sire");
  166.             while(cnt--)
  167.                 (void) makemon(courtmon(), u.ux, u.uy);
  168.             break;
  169.             }
  170.             case 8:
  171.             pline("A voice echoes:");
  172.             verbalize("By thy Imperious order, %s...",
  173.                   flags.female ? "Dame" : "Sire");
  174.             do_genocide(1);
  175.             break;
  176.             case 9:
  177.             pline("A voice echoes:");
  178.     verbalize("A curse upon thee for sitting upon this most holy throne!");
  179.             if (Luck > 0)  {
  180.                 make_blinded(Blinded + rn1(100,250),TRUE);
  181.             } else        rndcurse();
  182.             break;
  183.             case 10:
  184.             if (Luck < 0 || (HSee_invisible & INTRINSIC))  {
  185.                 if (level.flags.nommap) {
  186.                     pline(
  187.                     "A terrible drone fills your head!");
  188.                     make_confused(HConfusion + rnd(30),
  189.                                     FALSE);
  190.                 } else {
  191.                     pline("An image forms in your mind.");
  192.                     do_mapping();
  193.                 }
  194.             } else  {
  195.                 Your("vision becomes clear.");
  196.                 HSee_invisible |= FROMOUTSIDE;
  197.                 newsym(u.ux, u.uy);
  198.             }
  199.             break;
  200.             case 11:
  201.             if (Luck < 0)  {
  202.                 You("feel threatened.");
  203.                 aggravate();
  204.             } else  {
  205.  
  206.                 You("feel a wrenching sensation.");
  207.                 tele();        /* teleport him */
  208.             }
  209.             break;
  210.             case 12:
  211.             You("are granted an insight!");
  212.             if (invent) {
  213.                 int ret, cval = rn2(5); /* agrees w/seffects() */
  214.                 /* use up `cval' "charges"; 0 is special case */
  215.                 do {
  216.                 ret = ggetobj("identify", identify, cval);
  217.                 if (ret < 0) break;    /* quit */
  218.                 } while (ret == 0 || (cval -= ret) > 0);
  219.             }
  220.             break;
  221.             case 13:
  222.             Your("mind turns into a pretzel!");
  223.             make_confused(HConfusion + rn1(7,16),FALSE);
  224.             break;
  225.             default:    impossible("throne effect");
  226.                 break;
  227.         }
  228.         } else    You("feel somehow out of place...");
  229.  
  230.         if (!rn2(3) && IS_THRONE(levl[u.ux][u.uy].typ)) {
  231.         /* may have teleported */
  232.         pline("The throne vanishes in a puff of logic.");
  233.         levl[u.ux][u.uy].typ = ROOM;
  234.         if(Invisible) newsym(u.ux,u.uy);
  235.         }
  236.  
  237. #ifdef POLYSELF
  238.     } else if (lays_eggs(uasmon) || u.umonnum == PM_QUEEN_BEE) {
  239.         struct obj *uegg;
  240.  
  241.         if (!flags.female) {
  242.             pline("Males can't lay eggs!");
  243.             return 0;
  244.         }
  245.  
  246.         if (u.uhunger < (int)objects[EGG].oc_nutrition) {
  247.             You("don't have enough energy to lay an egg.");
  248.             return 0;
  249.         }
  250.  
  251.         uegg = mksobj(EGG, FALSE, FALSE);
  252.         uegg->spe = 1;
  253.         uegg->quan = 1;
  254.         uegg->owt = weight(uegg);
  255.         uegg->corpsenm =
  256.             (u.umonnum==PM_QUEEN_BEE ? PM_KILLER_BEE : monsndx(uasmon));
  257.         uegg->known = uegg->dknown = 1;
  258.         You("lay an egg.");
  259.         dropy(uegg);
  260.         stackobj(uegg);
  261.         morehungry((int)objects[EGG].oc_nutrition);
  262. #endif
  263.     } else if (u.uswallow)
  264.         pline("There are no seats in here!");
  265.     else
  266.         pline("Having fun sitting on the %s?", surface(u.ux,u.uy));
  267.     return(1);
  268. }
  269.  
  270. void
  271. rndcurse()            /* curse a few inventory items at random! */
  272. {
  273.     int    nobj = 0;
  274.     int    cnt, onum;
  275.     struct    obj    *otmp;
  276.     static const char *mal_aura = "feel a malignant aura surround %s.";
  277.  
  278.     if (uwep && (uwep->oartifact == ART_MAGICBANE) && rn2(20)) {
  279.         You(mal_aura, "the magic-absorbing blade");
  280.         return;
  281.     }
  282.  
  283.     if(Antimagic) {
  284.         shieldeff(u.ux, u.uy);
  285.         You(mal_aura, "you");
  286.     }
  287.  
  288.     for (otmp = invent; otmp; otmp = otmp->nobj)  nobj++;
  289.  
  290.     if (nobj)
  291.         for (cnt = rnd(6/((!!Antimagic) + (!!Half_spell_damage) + 1));
  292.          cnt > 0; cnt--)  {
  293.         onum = rn2(nobj);
  294.         for(otmp = invent; onum != 0; onum--)
  295.             otmp = otmp->nobj;
  296.  
  297.         if(otmp->oartifact && spec_ability(otmp, SPFX_INTEL) &&
  298.            rn2(10) < 8) {
  299.             pline("%s resists!", The(xname(otmp)));
  300.             continue;
  301.         }
  302.  
  303.         if(otmp->blessed)
  304.             unbless(otmp);
  305.         else
  306.             curse(otmp);
  307.         }
  308. }
  309.  
  310. void
  311. attrcurse()            /* remove a random INTRINSIC ability */
  312. {
  313.     switch(rnd(10)) {
  314.     case 1 : if (HFire_resistance & INTRINSIC) {
  315.             HFire_resistance &= ~INTRINSIC;
  316.             You("feel warmer.");
  317.             break;
  318.         }
  319.     case 2 : if (HTeleportation & INTRINSIC) {
  320.             HTeleportation &= ~INTRINSIC;
  321.             You("feel less jumpy.");
  322.             break;
  323.         }
  324.     case 3 : if (HPoison_resistance & INTRINSIC) {
  325.             HPoison_resistance &= ~INTRINSIC;
  326.             You("feel a little sick!");
  327.             break;
  328.         }
  329.     case 4 : if (HTelepat & INTRINSIC) {
  330.             HTelepat &= ~INTRINSIC;
  331.             if (Blind && !Telepat)
  332.                 see_monsters();    /* Can't sense mons anymore! */
  333.             Your("senses fail!");
  334.             break;
  335.         }
  336.     case 5 : if (HCold_resistance & INTRINSIC) {
  337.             HCold_resistance &= ~INTRINSIC;
  338.             You("feel cooler.");
  339.             break;
  340.         }
  341.     case 6 : if (HInvis & INTRINSIC) {
  342.             HInvis &= ~INTRINSIC;
  343.             You("feel paranoid.");
  344.             break;
  345.         }
  346.     case 7 : if (HSee_invisible & INTRINSIC) {
  347.             HSee_invisible &= ~INTRINSIC;
  348.             You("thought you saw something!");
  349.             break;
  350.         }
  351.     case 8 : if (Fast & INTRINSIC) {
  352.             Fast &= ~INTRINSIC;
  353.             You("feel slower.");
  354.             break;
  355.         }
  356.     case 9 : if (Stealth & INTRINSIC) {
  357.             Stealth &= ~INTRINSIC;
  358.             You("feel clumsy.");
  359.             break;
  360.         }
  361.     case 10: if (Protection & INTRINSIC) {
  362.             Protection &= ~INTRINSIC;
  363.             You("feel vulnerable.");
  364.             break;
  365.         }
  366.     default: break;
  367.     }
  368. }
  369.  
  370. /*sit.c*/
  371.