Source:NetHack 1.3d/sit.c

From NetHackWiki
Jump to navigation Jump to search

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

Warning! This is the source code from an old release. For the latest release, see Source code

Screenshots and source code from Hack are used under the CWI license.

1.    /*	SCCS Id: @(#)sit.c	1.3	87/07/14
2.    /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3.    /* sit.c - version 1.0 */
4.    
5.    #include "hack.h"
6.    
7.    #ifdef NEWCLASS
8.    int	identify();
9.    
10.   dosit() {
11.   	extern struct obj *readobjnam(), *addinv();
12.   	register struct	obj	*otmp;
13.   	struct	 obj	*sobj_at();
14.   	register int	cnt;
15.   
16.   	char	buf[BUFSZ];
17.   
18.   	if(Levitation)  {
19.   
20.   		pline("You are floating in the air, you can't sit!");
21.   	} else	if(IS_THRONE(levl[u.ux][u.uy].typ)) {
22.   
23.   		pline("As you sit in the opulant throne");
24.   		if (rnd(6) > 4)  {
25.   
26.   			switch (rnd(13))  {
27.   
28.   			    case 1:
29.   				pline("you feel suddenly weaker.");
30.   				if(Poison_resistance) {
31.   
32.   				    losestr(rn1(1,2));
33.   				    losehp(rnd(6), "cursed throne");
34.   				} else {
35.   
36.   				    losestr(rn1(4,3));
37.   				    losehp(rnd(10), "cursed throne");
38.   				}
39.   				break;
40.   			    case 2:
41.   				pline("you feel suddenly stronger.");
42.   				gainstr(0);
43.   				break;
44.   			    case 3:
45.   				pline("A massive charge of electricity shoots through your body!");
46.   				losehp(rnd(30), "electric chair");
47.   				break;
48.   			    case 4:
49.   				pline("you feel much, much better!");
50.   				if(u.uhp >= (u.uhpmax - 5))  u.uhpmax += 4;
51.   				u.uhp = u.uhpmax;
52.   				if (Blind) Blind = 1;
53.   				if (Sick)  Sick = 0;
54.   				flags.botl = 1;
55.   				break;
56.   			    case 5:
57.   				if (u.ugold <= 0)  {
58.   
59.   					pline("you feel a strange sensation.");
60.   				} else {
61.   					pline("you notice you have no gold!");
62.   					u.ugold = 0;
63.   					flags.botl = 1;
64.   				}
65.   				break;
66.   			    case 6:
67.   				if(u.uluck + rn2(5) < 0) {
68.   
69.   				    pline("you feel your luck is changing.");
70.   				    u.uluck++;
71.   				} else	    makewish();
72.   				break;
73.   			    case 7:
74.   				cnt = rnd(10);
75.   				pline("you hear a voice echo:");
76.   				pline("Your audience has been summoned, Sire!");
77.   				while(cnt--)
78.   				    (void) makemon(courtmon(), u.ux, u.uy);
79.   				break;
80.   			    case 8:
81.   				if (Confusion != 0)  {
82.   
83.   				    pline("you hear a voice echo:");
84.   				    pline("By your Imperious order Sire...");
85.   				}
86.   				do_genocide();
87.   				break;
88.   			    case 9:
89.   				pline("you hear a voice echo:");
90.   				pline("A curse upon you for sitting upon this most holy throne!");
91.   				if (u.uluck > 0)  {
92.   
93.   				    if(!Blind)	pline("a cloud of darkness falls upon you.");
94.   				    Blind += rn1(100,250);
95.   				    seeoff(0);
96.   				} else	    rndcurse();
97.   				break;
98.   			    case 10:
99.   				if (u.uluck < 0)  {
100.  
101.  					pline("an image forms in your mind.");
102.  					do_mapping();
103.  				} else  {
104.  
105.  					pline("your vision clarifies.");
106.  					HSee_invisible |= INTRINSIC;
107.  				}
108.  				break;
109.  			    case 11:
110.  				if (u.uluck < 0)  {
111.  
112.  				    pline("you feel threatened.");
113.  				    aggravate();
114.  				} else  {
115.  
116.  				    pline("you feel a wrenching sensation.");
117.  				    tele();		/* teleport him */
118.  				}
119.  				break;
120.  			    case 12:
121.  				pline("you are granted a gift of insight!");
122.  				while (!ggetobj("identify", identify, rn2(5))
123.  					&& invent);
124.  				break;
125.  			    case 13:
126.  				pline("your mind turns into a pretzel!");
127.  				HConfusion += rn1(7,16);
128.  				break;
129.  			    default:	impossible("throne effect");
130.  					break;
131.  			}
132.  		} else	pline("you feel somehow out of place...");
133.  
134.  		if (!rn2(3) && IS_THRONE(levl[u.ux][u.uy].typ))	{
135.  
136.  			pline("The throne vanishes in a puff of logic.");
137.  /*			levl[u.ux][u.uy].scrsym = '.'; */
138.  			levl[u.ux][u.uy].typ = ROOM;
139.  		}
140.  
141.  	} else	pline("Having fun sitting on the floor???");
142.  	return(1);
143.  }
144.  #endif /* NEWCLASS /**/
145.  
146.  #if defined(NEWCLASS) || defined(PRAYERS) || defined(HARD)
147.  rndcurse() {			/* curse a few inventory items at random! */
148.  
149.  	int	nobj = 0;
150.  	int	cnt, onum;
151.  	struct	obj	*otmp;
152.  
153.  	for (otmp = invent; otmp; otmp = otmp->nobj)  nobj++;
154.  	    for (cnt = rnd(6); cnt > 0; cnt--)  {
155.  
156.  		onum = rn2(nobj);
157.  		for(otmp = invent; onum != 0; onum--)
158.  		    otmp = otmp->nobj;
159.  
160.  			otmp->cursed++;
161.  	    }
162.  }
163.  #endif