Source:NetHack 2.3e/sit.c

From NetHackWiki
Revision as of 03:58, 4 March 2008 by Kernigh bot (talk | contribs) (NetHack 2.3e/sit.c moved to Source:NetHack 2.3e/sit.c: Robot: moved page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Below is the full text to sit.c from the source code of NetHack 2.3e. To link to a particular line, write [[NetHack 2.3e/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	2.3	88/02/02
2.    /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3.    
4.    #include "hack.h"
5.    
6.    #ifdef NEWCLASS
7.    int	identify();
8.    extern struct monst *makemon();
9.    extern struct permonst *courtmon();
10.   
11.   dosit() {
12.   	extern struct obj *readobjnam(), *addinv();
13.   	struct	 obj	*sobj_at();
14.   	register int	cnt;
15.   
16.   	if(Levitation)  {
17.   
18.   		pline("You are floating in the air, you can't sit!");
19.   	} else	if(IS_THRONE(levl[u.ux][u.uy].typ)) {
20.   
21.   		pline("As you sit in the opulent throne");
22.   		if (rnd(6) > 4)  {
23.   
24.   			switch (rnd(13))  {
25.   
26.   			    case 1:
27.   				pline("you feel suddenly weaker.");
28.   				if(Poison_resistance) {
29.   
30.   				    losestr(rn1(1,2));
31.   				    losehp(rnd(6), "cursed throne");
32.   				} else {
33.   
34.   				    losestr(rn1(4,3));
35.   				    losehp(rnd(10), "cursed throne");
36.   				}
37.   				break;
38.   			    case 2:
39.   				pline("you feel suddenly stronger.");
40.   				gainstr(0);
41.   				break;
42.   			    case 3:
43.   				pline("A%s charge of electricity shoots through your body!",
44.   				      (Shock_resistance) ? "" : " massive");
45.   				if(Shock_resistance)
46.   					losehp(rnd(6), "electric chair");
47.   				else	losehp(rnd(30), "electric chair");
48.   				break;
49.   			    case 4:
50.   				pline("you feel much, much better!");
51.   				if(u.uhp >= (u.uhpmax - 5))  u.uhpmax += 4;
52.   				u.uhp = u.uhpmax;
53.   				if (Blinded) Blinded = 1;
54.   				if (Sick)  Sick = 0;
55.   				heal_legs();
56.   				flags.botl = 1;
57.   				break;
58.   			    case 5:
59.   				if (u.ugold <= 0)  {
60.   
61.   					pline("you feel a strange sensation.");
62.   				} else {
63.   					pline("you notice you have no gold!");
64.   					u.ugold = 0;
65.   					flags.botl = 1;
66.   				}
67.   				break;
68.   			    case 6:
69.   				if(u.uluck + rn2(5) < 0) {
70.   
71.   				    pline("you feel your luck is changing.");
72.   				    change_luck(1);
73.   				} else	    makewish();
74.   				break;
75.   			    case 7:
76.   				cnt = rnd(10);
77.   				pline("you hear a voice echo:");
78.   				pline("Your audience has been summoned, Sire!");
79.   				while(cnt--)
80.   				    (void) makemon(courtmon(), u.ux, u.uy);
81.   				break;
82.   			    case 8:
83.   				if (Confusion != 0)  {
84.   
85.   				    pline("you hear a voice echo:");
86.   				    pline("By your Imperious order Sire...");
87.   				}
88.   				do_genocide();
89.   				break;
90.   			    case 9:
91.   				pline("you hear a voice echo:");
92.   				pline("A curse upon you for sitting upon this most holy throne!");
93.   				if (u.uluck > 0)  {
94.   
95.   				    if(!Blind)	pline("a cloud of darkness falls upon you.");
96.   				    Blinded += rn1(100,250);
97.   				    seeoff(0);
98.   				} else	    rndcurse();
99.   				break;
100.  			    case 10:
101.  				if (u.uluck < 0)  {
102.  
103.  					pline("an image forms in your mind.");
104.  					do_mapping();
105.  				} else  {
106.  
107.  					pline("your vision clarifies.");
108.  					HSee_invisible |= INTRINSIC;
109.  				}
110.  				break;
111.  			    case 11:
112.  				if (u.uluck < 0)  {
113.  
114.  				    pline("you feel threatened.");
115.  				    aggravate();
116.  				} else  {
117.  
118.  				    pline("you feel a wrenching sensation.");
119.  				    tele();		/* teleport him */
120.  				}
121.  				break;
122.  			    case 12:
123.  				pline("you are granted a gift of insight!");
124.  				while (!ggetobj("identify", identify, rn2(5))
125.  					&& invent);
126.  				break;
127.  			    case 13:
128.  				pline("your mind turns into a pretzel!");
129.  				HConfusion += rn1(7,16);
130.  				break;
131.  			    default:	impossible("throne effect");
132.  					break;
133.  			}
134.  		} else	pline("you feel somehow out of place...");
135.  
136.  		if (!rn2(3) && IS_THRONE(levl[u.ux][u.uy].typ))	{
137.  
138.  			pline("The throne vanishes in a puff of logic.");
139.  /*			levl[u.ux][u.uy].scrsym = ROOM_SYM; */
140.  			levl[u.ux][u.uy].typ = ROOM;
141.  		}
142.  
143.  	} else	pline("Having fun sitting on the floor???");
144.  	return(1);
145.  }
146.  #endif /* NEWCLASS /**/
147.  
148.  #if defined(NEWCLASS) || defined(PRAYERS) || defined(HARD)
149.  rndcurse() {			/* curse a few inventory items at random! */
150.  
151.  	int	nobj = 0;
152.  	int	cnt, onum;
153.  	struct	obj	*otmp;
154.  
155.  	for (otmp = invent; otmp; otmp = otmp->nobj)  nobj++;
156.  	    for (cnt = rnd(6); cnt > 0; cnt--)  {
157.  
158.  		onum = rn2(nobj);
159.  		for(otmp = invent; onum != 0; onum--)
160.  		    otmp = otmp->nobj;
161.  
162.  			otmp->cursed++;
163.  	    }
164.  }
165.  #endif
166.  
167.  attrcurse() {			/* remove a random INTRINSIC ability */
168.  	switch(rnd(10)) {
169.  	case 1 : if (HFire_resistance & INTRINSIC) {
170.  			HFire_resistance &= ~INTRINSIC;
171.  			if (Inhell && !Fire_resistance) {
172.  			    pline("You burn to a crisp.");
173.  			    killer = "gremlin curse";
174.  			    done("died");
175.  			} else pline("You feel warmer!");
176.  			break;
177.  		}
178.  	case 2 : if (HTeleportation & INTRINSIC) {
179.  			HTeleportation &= ~INTRINSIC;
180.  			pline("You don't feel jumpy!");
181.  			break;
182.  		}
183.  	case 3 : if (HPoison_resistance & INTRINSIC) {
184.  			HPoison_resistance &= ~INTRINSIC;
185.  			pline("You feel a little sick!");
186.  			break;
187.  		}
188.  	case 4 : if (HTelepat & INTRINSIC) {
189.  			HTelepat &= ~INTRINSIC;
190.  			pline("Your senses fail!");
191.  			break;
192.  		}
193.  	case 5 : if (HCold_resistance & INTRINSIC) {
194.  			HCold_resistance &= ~INTRINSIC;
195.  			pline("You feel colder!");
196.  			break;
197.  		}
198.  	case 6 : if (HInvis & INTRINSIC) {
199.  			HInvis &= ~INTRINSIC;
200.  			pline("You feel paranoid!");
201.  			break;
202.  		}
203.  	case 7 : if (HSee_invisible & INTRINSIC) {
204.  			HSee_invisible &= ~INTRINSIC;
205.  			pline("You think you see something!");
206.  			break;
207.  		}
208.  	case 8 : if (Fast & INTRINSIC) {
209.  			Fast &= ~INTRINSIC;
210.  			pline("You feel slower!");
211.  			break;
212.  		}
213.  	case 9 : if (Stealth & INTRINSIC) {
214.  			Stealth &= ~INTRINSIC;
215.  			pline("You feel clumsy!");
216.  			break;
217.  		}
218.  	case 10: if (Protection & INTRINSIC) {
219.  			Protection &= ~INTRINSIC;
220.  			pline("You feel vulnerable!");
221.  			break;
222.  		}
223.  	default: break;
224.  	}
225.  }