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

Contents

1 Top of file
2 take_gold
3 dosit
4 rndcurse
5 attrcurse

Top of file
&nbsp;/* NetHack 3.6	sit.c	$NHDT-Date: 1458341129 2016/03/18 22:45:29 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.53 $ */
&nbsp;/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
&nbsp;/*-Copyright (c) Robert Patrick Rankin, 2012. */
&nbsp;/* NetHack may be freely redistributed.  See license for details. */

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.

&nbsp;
&nbsp;#include "hack.h"
&nbsp;#include "artifact.h"
&nbsp;
&nbsp;
take_gold
&nbsp;/* take away the hero's money */
&nbsp;void
&nbsp;take_gold()
&nbsp;{
&nbsp;    struct obj *otmp, *nobj;
&nbsp;    int lost_money = 0;
&nbsp;
&nbsp;    for (otmp = invent; otmp; otmp = nobj) {
&nbsp;        nobj = otmp-&gt;nobj;
&nbsp;        if (otmp-&gt;oclass == COIN_CLASS) {
&nbsp;            lost_money = 1;
&nbsp;            remove_worn_item(otmp, FALSE);
&nbsp;            delobj(otmp);
&nbsp;        }
&nbsp;    }
&nbsp;    if (!lost_money) {
&nbsp;        You_feel("a strange sensation.");
&nbsp;    } else {
&nbsp;        You("notice you have no money!");
&nbsp;        context.botl = 1;
&nbsp;    }
&nbsp;}
&nbsp;
dosit
&nbsp;/* #sit command */
&nbsp;int
&nbsp;dosit()
&nbsp;{
&nbsp;    static const char sit_message[] = "sit on the %s.";
&nbsp;    register struct trap *trap = t_at(u.ux, u.uy);
&nbsp;    register int typ = levl[u.ux][u.uy].typ;
&nbsp;
&nbsp;    if (u.usteed) {
&nbsp;        You("are already sitting on %s.", mon_nam(u.usteed));
&nbsp;        return 0;
&nbsp;    }
&nbsp;    if (u.uundetected &amp;&amp; is_hider(youmonst.data) &amp;&amp; u.umonnum != PM_TRAPPER)
&nbsp;        u.uundetected = 0; /* no longer on the ceiling */
&nbsp;
&nbsp;    if (!can_reach_floor(FALSE)) {
&nbsp;        if (u.uswallow)
&nbsp;            There("are no seats in here!");
&nbsp;        else if (Levitation)
&nbsp;            You("tumble in place.");
&nbsp;        else
&nbsp;            You("are sitting on air.");
&nbsp;        return 0;
&nbsp;    } else if (u.ustuck &amp;&amp; !sticks(youmonst.data)) {
&nbsp;        /* holding monster is next to hero rather than beneath, but
&nbsp;           hero is in no condition to actually sit at has/her own spot */
&nbsp;        if (humanoid(u.ustuck-&gt;data))
&nbsp;            pline("%s won't offer %s lap.", Monnam(u.ustuck), mhis(u.ustuck));
&nbsp;        else
&nbsp;            pline("%s has no lap.", Monnam(u.ustuck));
&nbsp;        return 0;
&nbsp;    } else if (is_pool(u.ux, u.uy) &amp;&amp; !Underwater) { /* water walking */
&nbsp;        goto in_water;
&nbsp;    }
&nbsp;
&nbsp;    if (OBJ_AT(u.ux, u.uy)
&nbsp;        /* ensure we're not standing on the precipice */
&nbsp;        &amp;&amp; !uteetering_at_seen_pit(trap)) {
&nbsp;        register struct obj *obj;
&nbsp;
&nbsp;        obj = level.objects[u.ux][u.uy];
&nbsp;        if (youmonst.data-&gt;mlet == S_DRAGON &amp;&amp; obj-&gt;oclass == COIN_CLASS) {
&nbsp;            You("coil up around your %shoard.",
&nbsp;                (obj-&gt;quan + money_cnt(invent) &lt; u.ulevel * 1000) ? "meager "
&nbsp;                                                                  : "");
&nbsp;        } else {
&nbsp;            You("sit on %s.", the(xname(obj)));
&nbsp;            if (!(Is_box(obj) || objects[obj-&gt;otyp].oc_material == CLOTH))
&nbsp;                pline("It's not very comfortable...");
&nbsp;        }
&nbsp;    } else if (trap != 0 || (u.utrap &amp;&amp; (u.utraptype &gt;= TT_LAVA))) {
&nbsp;        if (u.utrap) {
&nbsp;            exercise(A_WIS, FALSE); /* you're getting stuck longer */
&nbsp;            if (u.utraptype == TT_BEARTRAP) {
&nbsp;                You_cant("sit down with your %s in the bear trap.",
&nbsp;                         body_part(FOOT));
&nbsp;                u.utrap++;
&nbsp;            } else if (u.utraptype == TT_PIT) {
&nbsp;                if (trap &amp;&amp; trap-&gt;ttyp == SPIKED_PIT) {
&nbsp;                    You("sit down on a spike.  Ouch!");
&nbsp;                    losehp(Half_physical_damage ? rn2(2) : 1,
&nbsp;                           "sitting on an iron spike", KILLED_BY);
&nbsp;                    exercise(A_STR, FALSE);
&nbsp;                } else
&nbsp;                    You("sit down in the pit.");
&nbsp;                u.utrap += rn2(5);
&nbsp;            } else if (u.utraptype == TT_WEB) {
&nbsp;                You("sit in the spider web and get entangled further!");
&nbsp;                u.utrap += rn1(10, 5);
&nbsp;            } else if (u.utraptype == TT_LAVA) {
&nbsp;                /* Must have fire resistance or they'd be dead already */
&nbsp;                You("sit in the %s!", hliquid("lava"));
&nbsp;                if (Slimed)
&nbsp;                    burn_away_slime();
&nbsp;                u.utrap += rnd(4);
&nbsp;                losehp(d(2, 10), "sitting in lava",
&nbsp;                       KILLED_BY); /* lava damage */
&nbsp;            } else if (u.utraptype == TT_INFLOOR
&nbsp;                       || u.utraptype == TT_BURIEDBALL) {
&nbsp;                You_cant("maneuver to sit!");
&nbsp;                u.utrap++;
&nbsp;            }
&nbsp;        } else {
&nbsp;            You("sit down.");
&nbsp;            dotrap(trap, VIASITTING);
&nbsp;        }
&nbsp;    } else if (Underwater || Is_waterlevel(&amp;u.uz)) {
&nbsp;        if (Is_waterlevel(&amp;u.uz))
&nbsp;            There("are no cushions floating nearby.");
&nbsp;        else
&nbsp;            You("sit down on the muddy bottom.");
&nbsp;    } else if (is_pool(u.ux, u.uy)) {
&nbsp;    in_water:
&nbsp;        You("sit in the %s.", hliquid("water"));
&nbsp;        if (!rn2(10) &amp;&amp; uarm)
&nbsp;            (void) water_damage(uarm, "armor", TRUE);
&nbsp;        if (!rn2(10) &amp;&amp; uarmf &amp;&amp; uarmf-&gt;otyp != WATER_WALKING_BOOTS)
&nbsp;            (void) water_damage(uarm, "armor", TRUE);
&nbsp;    } else if (IS_SINK(typ)) {
&nbsp;        You(sit_message, defsyms[S_sink].explanation);
&nbsp;        Your("%s gets wet.", humanoid(youmonst.data) ? "rump" : "underside");
&nbsp;    } else if (IS_ALTAR(typ)) {
&nbsp;        You(sit_message, defsyms[S_altar].explanation);
&nbsp;        altar_wrath(u.ux, u.uy);
&nbsp;    } else if (IS_GRAVE(typ)) {
&nbsp;        You(sit_message, defsyms[S_grave].explanation);
&nbsp;    } else if (typ == STAIRS) {
&nbsp;        You(sit_message, "stairs");
&nbsp;    } else if (typ == LADDER) {
&nbsp;        You(sit_message, "ladder");
&nbsp;    } else if (is_lava(u.ux, u.uy)) {
&nbsp;        /* must be WWalking */
&nbsp;        You(sit_message, hliquid("lava"));
&nbsp;        burn_away_slime();
&nbsp;        if (likes_lava(youmonst.data)) {
&nbsp;            pline_The("%s feels warm.", hliquid("lava"));
&nbsp;            return 1;
&nbsp;        }
&nbsp;        pline_The("%s burns you!", hliquid("lava"));
&nbsp;        losehp(d((Fire_resistance ? 2 : 10), 10), /* lava damage */
&nbsp;               "sitting on lava", KILLED_BY);
&nbsp;    } else if (is_ice(u.ux, u.uy)) {
&nbsp;        You(sit_message, defsyms[S_ice].explanation);
&nbsp;        if (!Cold_resistance)
&nbsp;            pline_The("ice feels cold.");
&nbsp;    } else if (typ == DRAWBRIDGE_DOWN) {
&nbsp;        You(sit_message, "drawbridge");
&nbsp;    } else if (IS_THRONE(typ)) {
&nbsp;        You(sit_message, defsyms[S_throne].explanation);
&nbsp;        if (rnd(6) &gt; 4) {
&nbsp;            switch (rnd(13)) {
&nbsp;            case 1:
&nbsp;                (void) adjattrib(rn2(A_MAX), -rn1(4, 3), FALSE);
&nbsp;                losehp(rnd(10), "cursed throne", KILLED_BY_AN);
&nbsp;                break;
&nbsp;            case 2:
&nbsp;                (void) adjattrib(rn2(A_MAX), 1, FALSE);
&nbsp;                break;
&nbsp;            case 3:
&nbsp;                pline("A%s electric shock shoots through your body!",
&nbsp;                      (Shock_resistance) ? "n" : " massive");
&nbsp;                losehp(Shock_resistance ? rnd(6) : rnd(30), "electric chair",
&nbsp;                       KILLED_BY_AN);
&nbsp;                exercise(A_CON, FALSE);
&nbsp;                break;
&nbsp;            case 4:
&nbsp;                You_feel("much, much better!");
&nbsp;                if (Upolyd) {
&nbsp;                    if (u.mh &gt;= (u.mhmax - 5))
&nbsp;                        u.mhmax += 4;
&nbsp;                    u.mh = u.mhmax;
&nbsp;                }
&nbsp;                if (u.uhp &gt;= (u.uhpmax - 5))
&nbsp;                    u.uhpmax += 4;
&nbsp;                u.uhp = u.uhpmax;
&nbsp;                u.ucreamed = 0;
&nbsp;                make_blinded(0L, TRUE);
&nbsp;                make_sick(0L, (char *) 0, FALSE, SICK_ALL);
&nbsp;                heal_legs();
&nbsp;                context.botl = 1;
&nbsp;                break;
&nbsp;            case 5:
&nbsp;                take_gold();
&nbsp;                break;
&nbsp;            case 6:
&nbsp;                if (u.uluck + rn2(5) &lt; 0) {
&nbsp;                    You_feel("your luck is changing.");
&nbsp;                    change_luck(1);
&nbsp;                } else
&nbsp;                    makewish();
&nbsp;                break;
&nbsp;            case 7:
&nbsp;              {
&nbsp;                int cnt = rnd(10);
&nbsp;
&nbsp;                /* Magical voice not affected by deafness */
&nbsp;                pline("A voice echoes:");
&nbsp;                verbalize("Thy audience hath been summoned, %s!",
&nbsp;                          flags.female ? "Dame" : "Sire");
&nbsp;                while (cnt--)
&nbsp;                    (void) makemon(courtmon(), u.ux, u.uy, NO_MM_FLAGS);
&nbsp;                break;
&nbsp;              }
&nbsp;            case 8:
&nbsp;                /* Magical voice not affected by deafness */
&nbsp;                pline("A voice echoes:");
&nbsp;                verbalize("By thine Imperious order, %s...",
&nbsp;                          flags.female ? "Dame" : "Sire");
&nbsp;                do_genocide(5); /* REALLY|ONTHRONE, see do_genocide() */
&nbsp;                break;
&nbsp;            case 9:
&nbsp;                /* Magical voice not affected by deafness */
&nbsp;                pline("A voice echoes:");
&nbsp;                verbalize(
&nbsp;                 "A curse upon thee for sitting upon this most holy throne!");
&nbsp;                if (Luck &gt; 0) {
&nbsp;                    make_blinded(Blinded + rn1(100, 250), TRUE);
&nbsp;                    change_luck((Luck &gt; 1) ? -rnd(2) : -1);
&nbsp;                } else
&nbsp;                    rndcurse();
&nbsp;                break;
&nbsp;            case 10:
&nbsp;                if (Luck &lt; 0 || (HSee_invisible &amp; INTRINSIC)) {
&nbsp;                    if (level.flags.nommap) {
&nbsp;                        pline("A terrible drone fills your head!");
&nbsp;                        make_confused((HConfusion &amp; TIMEOUT) + (long) rnd(30),
&nbsp;                                      FALSE);
&nbsp;                    } else {
&nbsp;                        pline("An image forms in your mind.");
&nbsp;                        do_mapping();
&nbsp;                    }
&nbsp;                } else {
&nbsp;                    Your("vision becomes clear.");
&nbsp;                    HSee_invisible |= FROMOUTSIDE;
&nbsp;                    newsym(u.ux, u.uy);
&nbsp;                }
&nbsp;                break;
&nbsp;            case 11:
&nbsp;                if (Luck &lt; 0) {
&nbsp;                    You_feel("threatened.");
&nbsp;                    aggravate();
&nbsp;                } else {
&nbsp;                    You_feel("a wrenching sensation.");
&nbsp;                    tele(); /* teleport him */
&nbsp;                }
&nbsp;                break;
&nbsp;            case 12:
&nbsp;                You("are granted an insight!");
&nbsp;                if (invent) {
&nbsp;                    /* rn2(5) agrees w/seffects() */
&nbsp;                    identify_pack(rn2(5), FALSE);
&nbsp;                }
&nbsp;                break;
&nbsp;            case 13:
&nbsp;                Your("mind turns into a pretzel!");
&nbsp;                make_confused((HConfusion &amp; TIMEOUT) + (long) rn1(7, 16),
&nbsp;                              FALSE);
&nbsp;                break;
&nbsp;            default:
&nbsp;                impossible("throne effect");
&nbsp;                break;
&nbsp;            }
&nbsp;        } else {
&nbsp;            if (is_prince(youmonst.data))
&nbsp;                You_feel("very comfortable here.");
&nbsp;            else
&nbsp;                You_feel("somehow out of place...");
&nbsp;        }
&nbsp;
&nbsp;        if (!rn2(3) &amp;&amp; IS_THRONE(levl[u.ux][u.uy].typ)) {
&nbsp;            /* may have teleported */
&nbsp;            levl[u.ux][u.uy].typ = ROOM;
&nbsp;            pline_The("throne vanishes in a puff of logic.");
&nbsp;            newsym(u.ux, u.uy);
&nbsp;        }
&nbsp;    } else if (lays_eggs(youmonst.data)) {
&nbsp;        struct obj *uegg;
&nbsp;
&nbsp;        if (!flags.female) {
&nbsp;            pline("%s can't lay eggs!",
&nbsp;                  Hallucination
&nbsp;                      ? "You may think you are a platypus, but a male still"
&nbsp;                      : "Males");
&nbsp;            return 0;
&nbsp;        } else if (u.uhunger &lt; (int) objects[EGG].oc_nutrition) {
&nbsp;            You("don't have enough energy to lay an egg.");
&nbsp;            return 0;
&nbsp;        }
&nbsp;
&nbsp;        uegg = mksobj(EGG, FALSE, FALSE);
&nbsp;        uegg-&gt;spe = 1;
&nbsp;        uegg-&gt;quan = 1L;
&nbsp;        uegg-&gt;owt = weight(uegg);
&nbsp;        /* this sets hatch timers if appropriate */
&nbsp;        set_corpsenm(uegg, egg_type_from_parent(u.umonnum, FALSE));
&nbsp;        uegg-&gt;known = uegg-&gt;dknown = 1;
&nbsp;        You("lay an egg.");
&nbsp;        dropy(uegg);
&nbsp;        stackobj(uegg);
&nbsp;        morehungry((int) objects[EGG].oc_nutrition);
&nbsp;    } else {
&nbsp;        pline("Having fun sitting on the %s?", surface(u.ux, u.uy));
&nbsp;    }
&nbsp;    return 1;
&nbsp;}
&nbsp;
rndcurse
&nbsp;/* curse a few inventory items at random! */
&nbsp;void
&nbsp;rndcurse()
&nbsp;{
&nbsp;    int nobj = 0;
&nbsp;    int cnt, onum;
&nbsp;    struct obj *otmp;
&nbsp;    static const char mal_aura[] = "feel a malignant aura surround %s.";
&nbsp;
&nbsp;    if (uwep &amp;&amp; (uwep-&gt;oartifact == ART_MAGICBANE) &amp;&amp; rn2(20)) {
&nbsp;        You(mal_aura, "the magic-absorbing blade");
&nbsp;        return;
&nbsp;    }
&nbsp;
&nbsp;    if (Antimagic) {
&nbsp;        shieldeff(u.ux, u.uy);
&nbsp;        You(mal_aura, "you");
&nbsp;    }
&nbsp;
&nbsp;    for (otmp = invent; otmp; otmp = otmp-&gt;nobj) {
&nbsp;        /* gold isn't subject to being cursed or blessed */
&nbsp;        if (otmp-&gt;oclass == COIN_CLASS)
&nbsp;            continue;
&nbsp;        nobj++;
&nbsp;    }
&nbsp;    if (nobj) {
&nbsp;        for (cnt = rnd(6 / ((!!Antimagic) + (!!Half_spell_damage) + 1));
&nbsp;             cnt &gt; 0; cnt--) {
&nbsp;            onum = rnd(nobj);
&nbsp;            for (otmp = invent; otmp; otmp = otmp-&gt;nobj) {
&nbsp;                /* as above */
&nbsp;                if (otmp-&gt;oclass == COIN_CLASS)
&nbsp;                    continue;
&nbsp;                if (--onum == 0)
&nbsp;                    break; /* found the target */
&nbsp;            }
&nbsp;            /* the !otmp case should never happen; picking an already
&nbsp;               cursed item happens--avoid "resists" message in that case */
&nbsp;            if (!otmp || otmp-&gt;cursed)
&nbsp;                continue; /* next target */
&nbsp;
&nbsp;            if (otmp-&gt;oartifact &amp;&amp; spec_ability(otmp, SPFX_INTEL)
&nbsp;                &amp;&amp; rn2(10) &lt; 8) {
&nbsp;                pline("%s!", Tobjnam(otmp, "resist"));
&nbsp;                continue;
&nbsp;            }
&nbsp;
&nbsp;            if (otmp-&gt;blessed)
&nbsp;                unbless(otmp);
&nbsp;            else
&nbsp;                curse(otmp);
&nbsp;        }
&nbsp;        update_inventory();
&nbsp;    }
&nbsp;
&nbsp;    /* treat steed's saddle as extended part of hero's inventory */
&nbsp;    if (u.usteed &amp;&amp; !rn2(4) &amp;&amp; (otmp = which_armor(u.usteed, W_SADDLE)) != 0
&nbsp;        &amp;&amp; !otmp-&gt;cursed) { /* skip if already cursed */
&nbsp;        if (otmp-&gt;blessed)
&nbsp;            unbless(otmp);
&nbsp;        else
&nbsp;            curse(otmp);
&nbsp;        if (!Blind) {
&nbsp;            pline("%s %s.", Yobjnam2(otmp, "glow"),
&nbsp;                  hcolor(otmp-&gt;cursed ? NH_BLACK : (const char *) "brown"));
&nbsp;            otmp-&gt;bknown = TRUE;
&nbsp;        }
&nbsp;    }
&nbsp;}
&nbsp;
attrcurse
&nbsp;/* remove a random INTRINSIC ability */
&nbsp;void
&nbsp;attrcurse()
&nbsp;{
&nbsp;    switch (rnd(11)) {
&nbsp;    case 1:
&nbsp;        if (HFire_resistance &amp; INTRINSIC) {
&nbsp;            HFire_resistance &amp;= ~INTRINSIC;
&nbsp;            You_feel("warmer.");
&nbsp;            break;
&nbsp;        }
&nbsp;        /*FALLTHRU*/
&nbsp;    case 2:
&nbsp;        if (HTeleportation &amp; INTRINSIC) {
&nbsp;            HTeleportation &amp;= ~INTRINSIC;
&nbsp;            You_feel("less jumpy.");
&nbsp;            break;
&nbsp;        }
&nbsp;        /*FALLTHRU*/
&nbsp;    case 3:
&nbsp;        if (HPoison_resistance &amp; INTRINSIC) {
&nbsp;            HPoison_resistance &amp;= ~INTRINSIC;
&nbsp;            You_feel("a little sick!");
&nbsp;            break;
&nbsp;        }
&nbsp;        /*FALLTHRU*/
&nbsp;    case 4:
&nbsp;        if (HTelepat &amp; INTRINSIC) {
&nbsp;            HTelepat &amp;= ~INTRINSIC;
&nbsp;            if (Blind &amp;&amp; !Blind_telepat)
&nbsp;                see_monsters(); /* Can't sense mons anymore! */
&nbsp;            Your("senses fail!");
&nbsp;            break;
&nbsp;        }
&nbsp;        /*FALLTHRU*/
&nbsp;    case 5:
&nbsp;        if (HCold_resistance &amp; INTRINSIC) {
&nbsp;            HCold_resistance &amp;= ~INTRINSIC;
&nbsp;            You_feel("cooler.");
&nbsp;            break;
&nbsp;        }
&nbsp;        /*FALLTHRU*/
&nbsp;    case 6:
&nbsp;        if (HInvis &amp; INTRINSIC) {
&nbsp;            HInvis &amp;= ~INTRINSIC;
&nbsp;            You_feel("paranoid.");
&nbsp;            break;
&nbsp;        }
&nbsp;        /*FALLTHRU*/
&nbsp;    case 7:
&nbsp;        if (HSee_invisible &amp; INTRINSIC) {
&nbsp;            HSee_invisible &amp;= ~INTRINSIC;
&nbsp;            You("%s!", Hallucination ? "tawt you taw a puttie tat"
&nbsp;                                     : "thought you saw something");
&nbsp;            break;
&nbsp;        }
&nbsp;        /*FALLTHRU*/
&nbsp;    case 8:
&nbsp;        if (HFast &amp; INTRINSIC) {
&nbsp;            HFast &amp;= ~INTRINSIC;
&nbsp;            You_feel("slower.");
&nbsp;            break;
&nbsp;        }
&nbsp;        /*FALLTHRU*/
&nbsp;    case 9:
&nbsp;        if (HStealth &amp; INTRINSIC) {
&nbsp;            HStealth &amp;= ~INTRINSIC;
&nbsp;            You_feel("clumsy.");
&nbsp;            break;
&nbsp;        }
&nbsp;        /*FALLTHRU*/
&nbsp;    case 10:
&nbsp;        /* intrinsic protection is just disabled, not set back to 0 */
&nbsp;        if (HProtection &amp; INTRINSIC) {
&nbsp;            HProtection &amp;= ~INTRINSIC;
&nbsp;            You_feel("vulnerable.");
&nbsp;            break;
&nbsp;        }
&nbsp;        /*FALLTHRU*/
&nbsp;    case 11:
&nbsp;        if (HAggravate_monster &amp; INTRINSIC) {
&nbsp;            HAggravate_monster &amp;= ~INTRINSIC;
&nbsp;            You_feel("less attractive.");
&nbsp;            break;
&nbsp;        }
&nbsp;        /*FALLTHRU*/
&nbsp;    default:
&nbsp;        break;
&nbsp;    }
&nbsp;}
&nbsp;
&nbsp;/*sit.c*/