NetHack->aNetHack
[aNetHack.git] / src / sit.c
bloba6c6a0906855a159edba3c17a573fe4a8017cc9e
1 /* NetHack 3.6 sit.c $NHDT-Date: 1458341129 2016/03/18 22:45:29 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.53 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed. See license for details. */
5 #include "hack.h"
6 #include "artifact.h"
9 /* take away the hero's money */
10 void
11 take_gold()
13 struct obj *otmp, *nobj;
14 int lost_money = 0;
16 for (otmp = invent; otmp; otmp = nobj) {
17 nobj = otmp->nobj;
18 if (otmp->oclass == COIN_CLASS) {
19 lost_money = 1;
20 remove_worn_item(otmp, FALSE);
21 delobj(otmp);
24 if (!lost_money) {
25 You_feel("a strange sensation.");
26 } else {
27 You("notice you have no money!");
28 context.botl = 1;
32 /* #sit command */
33 int
34 dosit()
36 static const char sit_message[] = "sit on the %s.";
37 register struct trap *trap = t_at(u.ux, u.uy);
38 register int typ = levl[u.ux][u.uy].typ;
40 if (u.usteed) {
41 You("are already sitting on %s.", mon_nam(u.usteed));
42 return 0;
44 if (u.uundetected && is_hider(youmonst.data) && u.umonnum != PM_TRAPPER)
45 u.uundetected = 0; /* no longer on the ceiling */
47 if (!can_reach_floor(FALSE)) {
48 if (u.uswallow)
49 There("are no seats in here!");
50 else if (Levitation)
51 You("tumble in place.");
52 else
53 You("are sitting on air.");
54 return 0;
55 } else if (u.ustuck && !sticks(youmonst.data)) {
56 /* holding monster is next to hero rather than beneath, but
57 hero is in no condition to actually sit at has/her own spot */
58 if (humanoid(u.ustuck->data))
59 pline("%s won't offer %s lap.", Monnam(u.ustuck), mhis(u.ustuck));
60 else
61 pline("%s has no lap.", Monnam(u.ustuck));
62 return 0;
63 } else if (is_pool(u.ux, u.uy) && !Underwater) { /* water walking */
64 goto in_water;
67 if (OBJ_AT(u.ux, u.uy)
68 /* ensure we're not standing on the precipice */
69 && !uteetering_at_seen_pit(trap)) {
70 register struct obj *obj;
72 obj = level.objects[u.ux][u.uy];
73 if (youmonst.data->mlet == S_DRAGON && obj->oclass == COIN_CLASS) {
74 You("coil up around your %shoard.",
75 (obj->quan + money_cnt(invent) < u.ulevel * 1000) ? "meager "
76 : "");
77 } else {
78 You("sit on %s.", the(xname(obj)));
79 if (!(Is_box(obj) || objects[obj->otyp].oc_material == CLOTH))
80 pline("It's not very comfortable...");
82 } else if (trap != 0 || (u.utrap && (u.utraptype >= TT_LAVA))) {
83 if (u.utrap) {
84 exercise(A_WIS, FALSE); /* you're getting stuck longer */
85 if (u.utraptype == TT_BEARTRAP) {
86 You_cant("sit down with your %s in the bear trap.",
87 body_part(FOOT));
88 u.utrap++;
89 } else if (u.utraptype == TT_PIT) {
90 if (trap && trap->ttyp == SPIKED_PIT) {
91 You("sit down on a spike. Ouch!");
92 losehp(Half_physical_damage ? rn2(2) : 1,
93 "sitting on an iron spike", KILLED_BY);
94 exercise(A_STR, FALSE);
95 } else
96 You("sit down in the pit.");
97 u.utrap += rn2(5);
98 } else if (u.utraptype == TT_WEB) {
99 You("sit in the spider web and get entangled further!");
100 u.utrap += rn1(10, 5);
101 } else if (u.utraptype == TT_LAVA) {
102 /* Must have fire resistance or they'd be dead already */
103 You("sit in the %s!", hliquid("lava"));
104 if (Slimed)
105 burn_away_slime();
106 u.utrap += rnd(4);
107 losehp(d(2, 10), "sitting in lava",
108 KILLED_BY); /* lava damage */
109 } else if (u.utraptype == TT_INFLOOR
110 || u.utraptype == TT_BURIEDBALL) {
111 You_cant("maneuver to sit!");
112 u.utrap++;
114 } else {
115 You("sit down.");
116 dotrap(trap, VIASITTING);
118 } else if (Underwater || Is_waterlevel(&u.uz)) {
119 if (Is_waterlevel(&u.uz))
120 There("are no cushions floating nearby.");
121 else
122 You("sit down on the muddy bottom.");
123 } else if (is_pool(u.ux, u.uy)) {
124 in_water:
125 You("sit in the %s.", hliquid("water"));
126 if (!rn2(10) && uarm)
127 (void) water_damage(uarm, "armor", TRUE);
128 if (!rn2(10) && uarmf && uarmf->otyp != WATER_WALKING_BOOTS)
129 (void) water_damage(uarm, "armor", TRUE);
130 } else if (IS_SINK(typ)) {
131 You(sit_message, defsyms[S_sink].explanation);
132 Your("%s gets wet.", humanoid(youmonst.data) ? "rump" : "underside");
133 } else if (IS_ALTAR(typ)) {
134 You(sit_message, defsyms[S_altar].explanation);
135 altar_wrath(u.ux, u.uy);
136 } else if (IS_GRAVE(typ)) {
137 You(sit_message, defsyms[S_grave].explanation);
138 } else if (typ == STAIRS) {
139 You(sit_message, "stairs");
140 } else if (typ == LADDER) {
141 You(sit_message, "ladder");
142 } else if (is_lava(u.ux, u.uy)) {
143 /* must be WWalking */
144 You(sit_message, hliquid("lava"));
145 burn_away_slime();
146 if (likes_lava(youmonst.data)) {
147 pline_The("%s feels warm.", hliquid("lava"));
148 return 1;
150 pline_The("%s burns you!", hliquid("lava"));
151 losehp(d((Fire_resistance ? 2 : 10), 10), /* lava damage */
152 "sitting on lava", KILLED_BY);
153 } else if (is_ice(u.ux, u.uy)) {
154 You(sit_message, defsyms[S_ice].explanation);
155 if (!Cold_resistance)
156 pline_The("ice feels cold.");
157 } else if (typ == DRAWBRIDGE_DOWN) {
158 You(sit_message, "drawbridge");
159 } else if (IS_THRONE(typ)) {
160 You(sit_message, defsyms[S_throne].explanation);
161 if (rnd(6) > 4) {
162 switch (rnd(13)) {
163 case 1:
164 (void) adjattrib(rn2(A_MAX), -rn1(4, 3), FALSE);
165 losehp(rnd(10), "cursed throne", KILLED_BY_AN);
166 break;
167 case 2:
168 (void) adjattrib(rn2(A_MAX), 1, FALSE);
169 break;
170 case 3:
171 pline("A%s electric shock shoots through your body!",
172 (Shock_resistance) ? "n" : " massive");
173 losehp(Shock_resistance ? rnd(6) : rnd(30), "electric chair",
174 KILLED_BY_AN);
175 exercise(A_CON, FALSE);
176 break;
177 case 4:
178 You_feel("much, much better!");
179 if (Upolyd) {
180 if (u.mh >= (u.mhmax - 5))
181 u.mhmax += 4;
182 u.mh = u.mhmax;
184 if (u.uhp >= (u.uhpmax - 5))
185 u.uhpmax += 4;
186 u.uhp = u.uhpmax;
187 u.ucreamed = 0;
188 make_blinded(0L, TRUE);
189 make_sick(0L, (char *) 0, FALSE, SICK_ALL);
190 heal_legs();
191 context.botl = 1;
192 break;
193 case 5:
194 take_gold();
195 break;
196 case 6:
197 if (u.uluck + rn2(5) < 0) {
198 You_feel("your luck is changing.");
199 change_luck(1);
200 } else
201 makewish();
202 break;
203 case 7:
205 int cnt = rnd(10);
207 /* Magical voice not affected by deafness */
208 pline("A voice echoes:");
209 verbalize("Thy audience hath been summoned, %s!",
210 flags.female ? "Dame" : "Sire");
211 while (cnt--)
212 (void) makemon(courtmon(), u.ux, u.uy, NO_MM_FLAGS);
213 break;
215 case 8:
216 /* Magical voice not affected by deafness */
217 pline("A voice echoes:");
218 verbalize("By thine Imperious order, %s...",
219 flags.female ? "Dame" : "Sire");
220 do_genocide(5); /* REALLY|ONTHRONE, see do_genocide() */
221 break;
222 case 9:
223 /* Magical voice not affected by deafness */
224 pline("A voice echoes:");
225 verbalize(
226 "A curse upon thee for sitting upon this most holy throne!");
227 if (Luck > 0) {
228 make_blinded(Blinded + rn1(100, 250), TRUE);
229 change_luck((Luck > 1) ? -rnd(2) : -1);
230 } else
231 rndcurse();
232 break;
233 case 10:
234 if (Luck < 0 || (HSee_invisible & INTRINSIC)) {
235 if (level.flags.nommap) {
236 pline("A terrible drone fills your head!");
237 make_confused((HConfusion & TIMEOUT) + (long) rnd(30),
238 FALSE);
239 } else {
240 pline("An image forms in your mind.");
241 do_mapping();
243 } else {
244 Your("vision becomes clear.");
245 HSee_invisible |= FROMOUTSIDE;
246 newsym(u.ux, u.uy);
248 break;
249 case 11:
250 if (Luck < 0) {
251 You_feel("threatened.");
252 aggravate();
253 } else {
254 You_feel("a wrenching sensation.");
255 tele(); /* teleport him */
257 break;
258 case 12:
259 You("are granted an insight!");
260 if (invent) {
261 /* rn2(5) agrees w/seffects() */
262 identify_pack(rn2(5), FALSE);
264 break;
265 case 13:
266 Your("mind turns into a pretzel!");
267 make_confused((HConfusion & TIMEOUT) + (long) rn1(7, 16),
268 FALSE);
269 break;
270 default:
271 impossible("throne effect");
272 break;
274 } else {
275 if (is_prince(youmonst.data))
276 You_feel("very comfortable here.");
277 else
278 You_feel("somehow out of place...");
281 if (!rn2(3) && IS_THRONE(levl[u.ux][u.uy].typ)) {
282 /* may have teleported */
283 levl[u.ux][u.uy].typ = ROOM;
284 pline_The("throne vanishes in a puff of logic.");
285 newsym(u.ux, u.uy);
287 } else if (lays_eggs(youmonst.data)) {
288 struct obj *uegg;
290 if (!flags.female) {
291 pline("%s can't lay eggs!",
292 Hallucination
293 ? "You may think you are a platypus, but a male still"
294 : "Males");
295 return 0;
296 } else if (u.uhunger < (int) objects[EGG].oc_nutrition) {
297 You("don't have enough energy to lay an egg.");
298 return 0;
301 uegg = mksobj(EGG, FALSE, FALSE);
302 uegg->spe = 1;
303 uegg->quan = 1L;
304 uegg->owt = weight(uegg);
305 /* this sets hatch timers if appropriate */
306 set_corpsenm(uegg, egg_type_from_parent(u.umonnum, FALSE));
307 uegg->known = uegg->dknown = 1;
308 You("lay an egg.");
309 dropy(uegg);
310 stackobj(uegg);
311 morehungry((int) objects[EGG].oc_nutrition);
312 } else {
313 pline("Having fun sitting on the %s?", surface(u.ux, u.uy));
315 return 1;
318 /* curse a few inventory items at random! */
319 void
320 rndcurse()
322 int nobj = 0;
323 int cnt, onum;
324 struct obj *otmp;
325 static const char mal_aura[] = "feel a malignant aura surround %s.";
327 if (uwep && (uwep->oartifact == ART_MAGICBANE) && rn2(20)) {
328 You(mal_aura, "the magic-absorbing blade");
329 return;
332 if (Antimagic) {
333 shieldeff(u.ux, u.uy);
334 You(mal_aura, "you");
337 for (otmp = invent; otmp; otmp = otmp->nobj) {
338 /* gold isn't subject to being cursed or blessed */
339 if (otmp->oclass == COIN_CLASS)
340 continue;
341 nobj++;
343 if (nobj) {
344 for (cnt = rnd(6 / ((!!Antimagic) + (!!Half_spell_damage) + 1));
345 cnt > 0; cnt--) {
346 onum = rnd(nobj);
347 for (otmp = invent; otmp; otmp = otmp->nobj) {
348 /* as above */
349 if (otmp->oclass == COIN_CLASS)
350 continue;
351 if (--onum == 0)
352 break; /* found the target */
354 /* the !otmp case should never happen; picking an already
355 cursed item happens--avoid "resists" message in that case */
356 if (!otmp || otmp->cursed)
357 continue; /* next target */
359 if (otmp->oartifact && spec_ability(otmp, SPFX_INTEL)
360 && rn2(10) < 8) {
361 pline("%s!", Tobjnam(otmp, "resist"));
362 continue;
365 if (otmp->blessed)
366 unbless(otmp);
367 else
368 curse(otmp);
370 update_inventory();
373 /* treat steed's saddle as extended part of hero's inventory */
374 if (u.usteed && !rn2(4) && (otmp = which_armor(u.usteed, W_SADDLE)) != 0
375 && !otmp->cursed) { /* skip if already cursed */
376 if (otmp->blessed)
377 unbless(otmp);
378 else
379 curse(otmp);
380 if (!Blind) {
381 pline("%s %s.", Yobjnam2(otmp, "glow"),
382 hcolor(otmp->cursed ? NH_BLACK : (const char *) "brown"));
383 otmp->bknown = TRUE;
388 /* remove a random INTRINSIC ability */
389 void
390 attrcurse()
392 switch (rnd(11)) {
393 case 1:
394 if (HFire_resistance & INTRINSIC) {
395 HFire_resistance &= ~INTRINSIC;
396 You_feel("warmer.");
397 break;
399 case 2:
400 if (HTeleportation & INTRINSIC) {
401 HTeleportation &= ~INTRINSIC;
402 You_feel("less jumpy.");
403 break;
405 case 3:
406 if (HPoison_resistance & INTRINSIC) {
407 HPoison_resistance &= ~INTRINSIC;
408 You_feel("a little sick!");
409 break;
411 case 4:
412 if (HTelepat & INTRINSIC) {
413 HTelepat &= ~INTRINSIC;
414 if (Blind && !Blind_telepat)
415 see_monsters(); /* Can't sense mons anymore! */
416 Your("senses fail!");
417 break;
419 case 5:
420 if (HCold_resistance & INTRINSIC) {
421 HCold_resistance &= ~INTRINSIC;
422 You_feel("cooler.");
423 break;
425 case 6:
426 if (HInvis & INTRINSIC) {
427 HInvis &= ~INTRINSIC;
428 You_feel("paranoid.");
429 break;
431 case 7:
432 if (HSee_invisible & INTRINSIC) {
433 HSee_invisible &= ~INTRINSIC;
434 You("%s!", Hallucination ? "tawt you taw a puttie tat"
435 : "thought you saw something");
436 break;
438 case 8:
439 if (HFast & INTRINSIC) {
440 HFast &= ~INTRINSIC;
441 You_feel("slower.");
442 break;
444 case 9:
445 if (HStealth & INTRINSIC) {
446 HStealth &= ~INTRINSIC;
447 You_feel("clumsy.");
448 break;
450 case 10:
451 /* intrinsic protection is just disabled, not set back to 0 */
452 if (HProtection & INTRINSIC) {
453 HProtection &= ~INTRINSIC;
454 You_feel("vulnerable.");
455 break;
457 case 11:
458 if (HAggravate_monster & INTRINSIC) {
459 HAggravate_monster &= ~INTRINSIC;
460 You_feel("less attractive.");
461 break;
463 default:
464 break;
468 /*sit.c*/