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