NHDT->ANH, nethack->anethack, nhdat->anhdat
[aNetHack.git] / src / pray.c
blobc1978083f35d41899fcef54bf2c272ac5297d83e
1 /* aNetHack 0.0.1 pray.c $ANH-Date: 1450577672 2015/12/20 02:14:32 $ $ANH-Branch: master $:$ANH-Revision: 1.89 $ */
2 /* Copyright (c) Benson I. Margulies, Mike Stephenson, Steve Linhart, 1989. */
3 /* aNetHack may be freely redistributed. See license for details. */
5 #include "hack.h"
7 STATIC_PTR int NDECL(prayer_done);
8 STATIC_DCL struct obj *NDECL(worst_cursed_item);
9 STATIC_DCL int NDECL(in_trouble);
10 STATIC_DCL void FDECL(fix_worst_trouble, (int));
11 STATIC_DCL void FDECL(angrygods, (ALIGNTYP_P));
12 STATIC_DCL void FDECL(at_your_feet, (const char *));
13 STATIC_DCL void NDECL(gcrownu);
14 STATIC_DCL void FDECL(pleased, (ALIGNTYP_P));
15 STATIC_DCL void FDECL(godvoice, (ALIGNTYP_P, const char *));
16 STATIC_DCL void FDECL(god_zaps_you, (ALIGNTYP_P));
17 STATIC_DCL void FDECL(fry_by_god, (ALIGNTYP_P, BOOLEAN_P));
18 STATIC_DCL void FDECL(gods_angry, (ALIGNTYP_P));
19 STATIC_DCL void FDECL(gods_upset, (ALIGNTYP_P));
20 STATIC_DCL void FDECL(consume_offering, (struct obj *));
21 STATIC_DCL boolean FDECL(water_prayer, (BOOLEAN_P));
22 STATIC_DCL boolean FDECL(blocked_boulder, (int, int));
24 /* simplify a few tests */
25 #define Cursed_obj(obj, typ) ((obj) && (obj)->otyp == (typ) && (obj)->cursed)
28 * Logic behind deities and altars and such:
29 * + prayers are made to your god if not on an altar, and to the altar's god
30 * if you are on an altar
31 * + If possible, your god answers all prayers, which is why bad things happen
32 * if you try to pray on another god's altar
33 * + sacrifices work basically the same way, but the other god may decide to
34 * accept your allegiance, after which they are your god. If rejected,
35 * your god takes over with your punishment.
36 * + if you're in Gehennom, all messages come from Moloch
40 * Moloch, who dwells in Gehennom, is the "renegade" cruel god
41 * responsible for the theft of the Amulet from Marduk, the Creator.
42 * Moloch is unaligned.
44 static const char *Moloch = "Moloch";
46 static const char *godvoices[] = {
47 "booms out", "thunders", "rings out", "booms",
50 /* values calculated when prayer starts, and used when completed */
51 static aligntyp p_aligntyp;
52 static int p_trouble;
53 static int p_type; /* (-1)-3: (-1)=really naughty, 3=really good */
55 #define PIOUS 20
56 #define DEVOUT 14
57 #define FERVENT 9
58 #define STRIDENT 4
61 * The actual trouble priority is determined by the order of the
62 * checks performed in in_trouble() rather than by these numeric
63 * values, so keep that code and these values synchronized in
64 * order to have the values be meaningful.
67 #define TROUBLE_STONED 14
68 #define TROUBLE_SLIMED 13
69 #define TROUBLE_STRANGLED 12
70 #define TROUBLE_LAVA 11
71 #define TROUBLE_SICK 10
72 #define TROUBLE_STARVING 9
73 #define TROUBLE_REGION 8 /* stinking cloud */
74 #define TROUBLE_HIT 7
75 #define TROUBLE_LYCANTHROPE 6
76 #define TROUBLE_COLLAPSING 5
77 #define TROUBLE_STUCK_IN_WALL 4
78 #define TROUBLE_CURSED_LEVITATION 3
79 #define TROUBLE_UNUSEABLE_HANDS 2
80 #define TROUBLE_CURSED_BLINDFOLD 1
82 #define TROUBLE_PUNISHED (-1)
83 #define TROUBLE_FUMBLING (-2)
84 #define TROUBLE_CURSED_ITEMS (-3)
85 #define TROUBLE_SADDLE (-4)
86 #define TROUBLE_BLIND (-5)
87 #define TROUBLE_POISONED (-6)
88 #define TROUBLE_WOUNDED_LEGS (-7)
89 #define TROUBLE_HUNGRY (-8)
90 #define TROUBLE_STUNNED (-9)
91 #define TROUBLE_CONFUSED (-10)
92 #define TROUBLE_HALLUCINATION (-11)
95 #define ugod_is_angry() (u.ualign.record < 0)
96 #define on_altar() IS_ALTAR(levl[u.ux][u.uy].typ)
97 #define on_shrine() ((levl[u.ux][u.uy].altarmask & AM_SHRINE) != 0)
98 #define a_align(x, y) ((aligntyp) Amask2align(levl[x][y].altarmask & AM_MASK))
100 /* critically low hit points if hp <= 5 or hp <= maxhp/N for some N */
101 boolean
102 critically_low_hp(only_if_injured)
103 boolean only_if_injured; /* determines whether maxhp <= 5 matters */
105 int divisor, hplim, curhp = Upolyd ? u.mh : u.uhp,
106 maxhp = Upolyd ? u.mhmax : u.uhpmax;
108 if (only_if_injured && !(curhp < maxhp))
109 return FALSE;
110 /* if maxhp is extremely high, use lower threshold for the division test
111 (golden glow cuts off at 11+5*lvl, nurse interaction at 25*lvl; this
112 ought to use monster hit dice--and a smaller multiplier--rather than
113 ulevel when polymorphed, but polyself doesn't maintain that) */
114 hplim = 15 * u.ulevel;
115 if (maxhp > hplim)
116 maxhp = hplim;
117 /* 7 used to be the unconditional divisor */
118 switch (xlev_to_rank(u.ulevel)) { /* maps 1..30 into 0..8 */
119 case 0:
120 case 1:
121 divisor = 5;
122 break; /* explvl 1 to 5 */
123 case 2:
124 case 3:
125 divisor = 6;
126 break; /* explvl 6 to 13 */
127 case 4:
128 case 5:
129 divisor = 7;
130 break; /* explvl 14 to 21 */
131 case 6:
132 case 7:
133 divisor = 8;
134 break; /* explvl 22 to 29 */
135 default:
136 divisor = 9;
137 break; /* explvl 30+ */
139 /* 5 is a magic number in TROUBLE_HIT handling below */
140 return (boolean) (curhp <= 5 || curhp * divisor <= maxhp);
144 * Return 0 if nothing particular seems wrong, positive numbers for
145 * serious trouble, and negative numbers for comparative annoyances.
146 * This returns the worst problem. There may be others, and the gods
147 * may fix more than one.
149 * This could get as bizarre as noting surrounding opponents, (or
150 * hostile dogs), but that's really hard.
152 * We could force rehumanize of polyselfed people, but we can't tell
153 * unintentional shape changes from the other kind. Oh well.
154 * 3.4.2: make an exception if polymorphed into a form which lacks
155 * hands; that's a case where the ramifications override this doubt.
157 STATIC_OVL int
158 in_trouble()
160 struct obj *otmp;
161 int i, j, count = 0;
164 * major troubles
166 if (Stoned)
167 return TROUBLE_STONED;
168 if (Slimed)
169 return TROUBLE_SLIMED;
170 if (Strangled)
171 return TROUBLE_STRANGLED;
172 if (u.utrap && u.utraptype == TT_LAVA)
173 return TROUBLE_LAVA;
174 if (Sick)
175 return TROUBLE_SICK;
176 if (u.uhs >= WEAK)
177 return TROUBLE_STARVING;
178 if (region_danger())
179 return TROUBLE_REGION;
180 if (critically_low_hp(FALSE))
181 return TROUBLE_HIT;
182 if (u.ulycn >= LOW_PM)
183 return TROUBLE_LYCANTHROPE;
184 if (near_capacity() >= EXT_ENCUMBER && AMAX(A_STR) - ABASE(A_STR) > 3)
185 return TROUBLE_COLLAPSING;
187 for (i = -1; i <= 1; i++)
188 for (j = -1; j <= 1; j++) {
189 if (!i && !j)
190 continue;
191 if (!isok(u.ux + i, u.uy + j)
192 || IS_ROCK(levl[u.ux + i][u.uy + j].typ)
193 || (blocked_boulder(i, j) && !throws_rocks(youmonst.data)))
194 count++;
196 if (count == 8 && !Passes_walls)
197 return TROUBLE_STUCK_IN_WALL;
199 if (Cursed_obj(uarmf, LEVITATION_BOOTS)
200 || stuck_ring(uleft, RIN_LEVITATION)
201 || stuck_ring(uright, RIN_LEVITATION))
202 return TROUBLE_CURSED_LEVITATION;
203 if (nohands(youmonst.data) || !freehand()) {
204 /* for bag/box access [cf use_container()]...
205 make sure it's a case that we know how to handle;
206 otherwise "fix all troubles" would get stuck in a loop */
207 if (welded(uwep))
208 return TROUBLE_UNUSEABLE_HANDS;
209 if (Upolyd && nohands(youmonst.data)
210 && (!Unchanging || ((otmp = unchanger()) != 0 && otmp->cursed)))
211 return TROUBLE_UNUSEABLE_HANDS;
213 if (Blindfolded && ublindf->cursed)
214 return TROUBLE_CURSED_BLINDFOLD;
217 * minor troubles
219 if (Punished || (u.utrap && u.utraptype == TT_BURIEDBALL))
220 return TROUBLE_PUNISHED;
221 if (Cursed_obj(uarmg, GAUNTLETS_OF_FUMBLING)
222 || Cursed_obj(uarmf, FUMBLE_BOOTS))
223 return TROUBLE_FUMBLING;
224 if (worst_cursed_item())
225 return TROUBLE_CURSED_ITEMS;
226 if (u.usteed) { /* can't voluntarily dismount from a cursed saddle */
227 otmp = which_armor(u.usteed, W_SADDLE);
228 if (Cursed_obj(otmp, SADDLE))
229 return TROUBLE_SADDLE;
232 if (Blinded > 1 && haseyes(youmonst.data)
233 && (!u.uswallow
234 || !attacktype_fordmg(u.ustuck->data, AT_ENGL, AD_BLND)))
235 return TROUBLE_BLIND;
236 for (i = 0; i < A_MAX; i++)
237 if (ABASE(i) < AMAX(i))
238 return TROUBLE_POISONED;
239 if (Wounded_legs && !u.usteed)
240 return TROUBLE_WOUNDED_LEGS;
241 if (u.uhs >= HUNGRY)
242 return TROUBLE_HUNGRY;
243 if (HStun & TIMEOUT)
244 return TROUBLE_STUNNED;
245 if (HConfusion & TIMEOUT)
246 return TROUBLE_CONFUSED;
247 if (HHallucination & TIMEOUT)
248 return TROUBLE_HALLUCINATION;
249 return 0;
252 /* select an item for TROUBLE_CURSED_ITEMS */
253 STATIC_OVL struct obj *
254 worst_cursed_item()
256 register struct obj *otmp;
258 /* if strained or worse, check for loadstone first */
259 if (near_capacity() >= HVY_ENCUMBER) {
260 for (otmp = invent; otmp; otmp = otmp->nobj)
261 if (Cursed_obj(otmp, LOADSTONE))
262 return otmp;
264 /* weapon takes precedence if it is interfering
265 with taking off a ring or putting on a shield */
266 if (welded(uwep) && (uright || bimanual(uwep))) { /* weapon */
267 otmp = uwep;
268 /* gloves come next, due to rings */
269 } else if (uarmg && uarmg->cursed) { /* gloves */
270 otmp = uarmg;
271 /* then shield due to two handed weapons and spells */
272 } else if (uarms && uarms->cursed) { /* shield */
273 otmp = uarms;
274 /* then cloak due to body armor */
275 } else if (uarmc && uarmc->cursed) { /* cloak */
276 otmp = uarmc;
277 } else if (uarm && uarm->cursed) { /* suit */
278 otmp = uarm;
279 } else if (uarmh && uarmh->cursed) { /* helmet */
280 otmp = uarmh;
281 } else if (uarmf && uarmf->cursed) { /* boots */
282 otmp = uarmf;
283 } else if (uarmu && uarmu->cursed) { /* shirt */
284 otmp = uarmu;
285 } else if (uamul && uamul->cursed) { /* amulet */
286 otmp = uamul;
287 } else if (uleft && uleft->cursed) { /* left ring */
288 otmp = uleft;
289 } else if (uright && uright->cursed) { /* right ring */
290 otmp = uright;
291 } else if (ublindf && ublindf->cursed) { /* eyewear */
292 otmp = ublindf; /* must be non-blinding lenses */
293 /* if weapon wasn't handled above, do it now */
294 } else if (welded(uwep)) { /* weapon */
295 otmp = uwep;
296 /* active secondary weapon even though it isn't welded */
297 } else if (uswapwep && uswapwep->cursed && u.twoweap) {
298 otmp = uswapwep;
299 /* all worn items ought to be handled by now */
300 } else {
301 for (otmp = invent; otmp; otmp = otmp->nobj) {
302 if (!otmp->cursed)
303 continue;
304 if (otmp->otyp == LOADSTONE || confers_luck(otmp))
305 break;
308 return otmp;
311 STATIC_OVL void
312 fix_worst_trouble(trouble)
313 int trouble;
315 int i;
316 struct obj *otmp = 0;
317 const char *what = (const char *) 0;
318 static NEARDATA const char leftglow[] = "Your left ring softly glows",
319 rightglow[] = "Your right ring softly glows";
321 switch (trouble) {
322 case TROUBLE_STONED:
323 make_stoned(0L, "You feel more limber.", 0, (char *) 0);
324 break;
325 case TROUBLE_SLIMED:
326 make_slimed(0L, "The slime disappears.");
327 break;
328 case TROUBLE_STRANGLED:
329 if (uamul && uamul->otyp == AMULET_OF_STRANGULATION) {
330 Your("amulet vanishes!");
331 useup(uamul);
333 You("can breathe again.");
334 Strangled = 0;
335 context.botl = 1;
336 break;
337 case TROUBLE_LAVA:
338 You("are back on solid ground.");
339 /* teleport should always succeed, but if not,
340 * just untrap them.
342 if (!safe_teleds(FALSE))
343 u.utrap = 0;
344 break;
345 case TROUBLE_STARVING:
346 losestr(-1);
347 /*FALLTHRU*/
348 case TROUBLE_HUNGRY:
349 Your("%s feels content.", body_part(STOMACH));
350 init_uhunger();
351 context.botl = 1;
352 break;
353 case TROUBLE_SICK:
354 You_feel("better.");
355 make_sick(0L, (char *) 0, FALSE, SICK_ALL);
356 break;
357 case TROUBLE_REGION:
358 /* stinking cloud, with hero vulnerable to HP loss */
359 region_safety();
360 break;
361 case TROUBLE_HIT:
362 /* "fix all troubles" will keep trying if hero has
363 5 or less hit points, so make sure they're always
364 boosted to be more than that */
365 You_feel("much better.");
366 if (Upolyd) {
367 u.mhmax += rnd(5);
368 if (u.mhmax <= 5)
369 u.mhmax = 5 + 1;
370 u.mh = u.mhmax;
372 if (u.uhpmax < u.ulevel * 5 + 11)
373 u.uhpmax += rnd(5);
374 if (u.uhpmax <= 5)
375 u.uhpmax = 5 + 1;
376 u.uhp = u.uhpmax;
377 context.botl = 1;
378 break;
379 case TROUBLE_COLLAPSING:
380 /* override Fixed_abil; uncurse that if feasible */
381 You_feel("%sstronger.",
382 (AMAX(A_STR) - ABASE(A_STR) > 6) ? "much " : "");
383 ABASE(A_STR) = AMAX(A_STR);
384 context.botl = 1;
385 if (Fixed_abil) {
386 if ((otmp = stuck_ring(uleft, RIN_SUSTAIN_ABILITY)) != 0) {
387 if (otmp == uleft)
388 what = leftglow;
389 } else if ((otmp = stuck_ring(uright, RIN_SUSTAIN_ABILITY))
390 != 0) {
391 if (otmp == uright)
392 what = rightglow;
394 if (otmp)
395 goto decurse;
397 break;
398 case TROUBLE_STUCK_IN_WALL:
399 Your("surroundings change.");
400 /* no control, but works on no-teleport levels */
401 (void) safe_teleds(FALSE);
402 break;
403 case TROUBLE_CURSED_LEVITATION:
404 if (Cursed_obj(uarmf, LEVITATION_BOOTS)) {
405 otmp = uarmf;
406 } else if ((otmp = stuck_ring(uleft, RIN_LEVITATION)) != 0) {
407 if (otmp == uleft)
408 what = leftglow;
409 } else if ((otmp = stuck_ring(uright, RIN_LEVITATION)) != 0) {
410 if (otmp == uright)
411 what = rightglow;
413 goto decurse;
414 case TROUBLE_UNUSEABLE_HANDS:
415 if (welded(uwep)) {
416 otmp = uwep;
417 goto decurse;
419 if (Upolyd && nohands(youmonst.data)) {
420 if (!Unchanging) {
421 Your("shape becomes uncertain.");
422 rehumanize(); /* "You return to {normal} form." */
423 } else if ((otmp = unchanger()) != 0 && otmp->cursed) {
424 /* otmp is an amulet of unchanging */
425 goto decurse;
428 if (nohands(youmonst.data) || !freehand())
429 impossible("fix_worst_trouble: couldn't cure hands.");
430 break;
431 case TROUBLE_CURSED_BLINDFOLD:
432 otmp = ublindf;
433 goto decurse;
434 case TROUBLE_LYCANTHROPE:
435 you_unwere(TRUE);
436 break;
439 case TROUBLE_PUNISHED:
440 Your("chain disappears.");
441 if (u.utrap && u.utraptype == TT_BURIEDBALL)
442 buried_ball_to_freedom();
443 else
444 unpunish();
445 break;
446 case TROUBLE_FUMBLING:
447 if (Cursed_obj(uarmg, GAUNTLETS_OF_FUMBLING))
448 otmp = uarmg;
449 else if (Cursed_obj(uarmf, FUMBLE_BOOTS))
450 otmp = uarmf;
451 goto decurse;
452 /*NOTREACHED*/
453 break;
454 case TROUBLE_CURSED_ITEMS:
455 otmp = worst_cursed_item();
456 if (otmp == uright)
457 what = rightglow;
458 else if (otmp == uleft)
459 what = leftglow;
460 decurse:
461 if (!otmp) {
462 impossible("fix_worst_trouble: nothing to uncurse.");
463 return;
465 if (!Blind || (otmp == ublindf && Blindfolded_only)) {
466 pline("%s %s.",
467 what ? what : (const char *) Yobjnam2(otmp, "softly glow"),
468 hcolor(NH_AMBER));
469 iflags.last_msg = PLNMSG_OBJ_GLOWS;
470 otmp->bknown = !Hallucination;
472 uncurse(otmp);
473 update_inventory();
474 break;
475 case TROUBLE_POISONED:
476 /* override Fixed_abil; ignore items which confer that */
477 if (Hallucination)
478 pline("There's a tiger in your tank.");
479 else
480 You_feel("in good health again.");
481 for (i = 0; i < A_MAX; i++) {
482 if (ABASE(i) < AMAX(i)) {
483 ABASE(i) = AMAX(i);
484 context.botl = 1;
487 (void) encumber_msg();
488 break;
489 case TROUBLE_BLIND: {
490 const char *eyes = body_part(EYE);
492 if (eyecount(youmonst.data) != 1)
493 eyes = makeplural(eyes);
494 Your("%s %s better.", eyes, vtense(eyes, "feel"));
495 u.ucreamed = 0;
496 make_blinded(0L, FALSE);
497 break;
499 case TROUBLE_WOUNDED_LEGS:
500 heal_legs();
501 break;
502 case TROUBLE_STUNNED:
503 make_stunned(0L, TRUE);
504 break;
505 case TROUBLE_CONFUSED:
506 make_confused(0L, TRUE);
507 break;
508 case TROUBLE_HALLUCINATION:
509 pline("Looks like you are back in Kansas.");
510 (void) make_hallucinated(0L, FALSE, 0L);
511 break;
512 case TROUBLE_SADDLE:
513 otmp = which_armor(u.usteed, W_SADDLE);
514 if (!Blind) {
515 pline("%s %s.", Yobjnam2(otmp, "softly glow"), hcolor(NH_AMBER));
516 otmp->bknown = TRUE;
518 uncurse(otmp);
519 break;
523 /* "I am sometimes shocked by... the nuns who never take a bath without
524 * wearing a bathrobe all the time. When asked why, since no man can see them,
525 * they reply 'Oh, but you forget the good God'. Apparently they conceive of
526 * the Deity as a Peeping Tom, whose omnipotence enables Him to see through
527 * bathroom walls, but who is foiled by bathrobes." --Bertrand Russell, 1943
528 * Divine wrath, dungeon walls, and armor follow the same principle.
530 STATIC_OVL void
531 god_zaps_you(resp_god)
532 aligntyp resp_god;
534 if (u.uswallow) {
535 pline(
536 "Suddenly a bolt of lightning comes down at you from the heavens!");
537 pline("It strikes %s!", mon_nam(u.ustuck));
538 if (!resists_elec(u.ustuck)) {
539 pline("%s fries to a crisp!", Monnam(u.ustuck));
540 /* Yup, you get experience. It takes guts to successfully
541 * pull off this trick on your god, anyway.
542 * Other credit/blame applies (luck or alignment adjustments),
543 * but not direct kill count (pacifist conduct).
545 xkilled(u.ustuck, XKILL_NOMSG | XKILL_NOCONDUCT);
546 } else
547 pline("%s seems unaffected.", Monnam(u.ustuck));
548 } else {
549 pline("Suddenly, a bolt of lightning strikes you!");
550 if (Reflecting) {
551 shieldeff(u.ux, u.uy);
552 if (Blind)
553 pline("For some reason you're unaffected.");
554 else
555 (void) ureflects("%s reflects from your %s.", "It");
556 } else if (Shock_resistance) {
557 shieldeff(u.ux, u.uy);
558 pline("It seems not to affect you.");
559 } else
560 fry_by_god(resp_god, FALSE);
563 pline("%s is not deterred...", align_gname(resp_god));
564 if (u.uswallow) {
565 pline("A wide-angle disintegration beam aimed at you hits %s!",
566 mon_nam(u.ustuck));
567 if (!resists_disint(u.ustuck)) {
568 pline("%s disintegrates into a pile of dust!", Monnam(u.ustuck));
569 xkilled(u.ustuck, XKILL_NOMSG | XKILL_NOCORPSE | XKILL_NOCONDUCT);
570 } else
571 pline("%s seems unaffected.", Monnam(u.ustuck));
572 } else {
573 pline("A wide-angle disintegration beam hits you!");
575 /* disintegrate shield and body armor before disintegrating
576 * the impudent mortal, like black dragon breath -3.
578 if (uarms && !(EReflecting & W_ARMS)
579 && !(EDisint_resistance & W_ARMS))
580 (void) destroy_arm(uarms);
581 if (uarmc && !(EReflecting & W_ARMC)
582 && !(EDisint_resistance & W_ARMC))
583 (void) destroy_arm(uarmc);
584 if (uarm && !(EReflecting & W_ARM) && !(EDisint_resistance & W_ARM)
585 && !uarmc)
586 (void) destroy_arm(uarm);
587 if (uarmu && !uarm && !uarmc)
588 (void) destroy_arm(uarmu);
589 if (!Disint_resistance) {
590 fry_by_god(resp_god, TRUE);
591 } else {
592 You("bask in its %s glow for a minute...", NH_BLACK);
593 godvoice(resp_god, "I believe it not!");
595 if (Is_astralevel(&u.uz) || Is_sanctum(&u.uz)) {
596 /* one more try for high altars */
597 verbalize("Thou cannot escape my wrath, mortal!");
598 summon_minion(resp_god, FALSE);
599 summon_minion(resp_god, FALSE);
600 summon_minion(resp_god, FALSE);
601 verbalize("Destroy %s, my servants!", uhim());
606 STATIC_OVL void
607 fry_by_god(resp_god, via_disintegration)
608 aligntyp resp_god;
609 boolean via_disintegration;
611 You("%s!", !via_disintegration ? "fry to a crisp"
612 : "disintegrate into a pile of dust");
613 killer.format = KILLED_BY;
614 Sprintf(killer.name, "the wrath of %s", align_gname(resp_god));
615 done(DIED);
618 STATIC_OVL void
619 angrygods(resp_god)
620 aligntyp resp_god;
622 int maxanger;
624 if (Inhell)
625 resp_god = A_NONE;
626 u.ublessed = 0;
628 /* changed from tmp = u.ugangr + abs (u.uluck) -- rph */
629 /* added test for alignment diff -dlc */
630 if (resp_god != u.ualign.type)
631 maxanger = u.ualign.record / 2 + (Luck > 0 ? -Luck / 3 : -Luck);
632 else
633 maxanger = 3 * u.ugangr + ((Luck > 0 || u.ualign.record >= STRIDENT)
634 ? -Luck / 3
635 : -Luck);
636 if (maxanger < 1)
637 maxanger = 1; /* possible if bad align & good luck */
638 else if (maxanger > 15)
639 maxanger = 15; /* be reasonable */
641 switch (rn2(maxanger)) {
642 case 0:
643 case 1:
644 You_feel("that %s is %s.", align_gname(resp_god),
645 Hallucination ? "bummed" : "displeased");
646 break;
647 case 2:
648 case 3:
649 godvoice(resp_god, (char *) 0);
650 pline("\"Thou %s, %s.\"",
651 (ugod_is_angry() && resp_god == u.ualign.type)
652 ? "hast strayed from the path"
653 : "art arrogant",
654 youmonst.data->mlet == S_HUMAN ? "mortal" : "creature");
655 verbalize("Thou must relearn thy lessons!");
656 (void) adjattrib(A_WIS, -1, FALSE);
657 losexp((char *) 0);
658 break;
659 case 6:
660 if (!Punished) {
661 gods_angry(resp_god);
662 punish((struct obj *) 0);
663 break;
664 } /* else fall thru */
665 case 4:
666 case 5:
667 gods_angry(resp_god);
668 if (!Blind && !Antimagic)
669 pline("%s glow surrounds you.", An(hcolor(NH_BLACK)));
670 rndcurse();
671 break;
672 case 7:
673 case 8:
674 godvoice(resp_god, (char *) 0);
675 verbalize("Thou durst %s me?",
676 (on_altar() && (a_align(u.ux, u.uy) != resp_god))
677 ? "scorn"
678 : "call upon");
679 pline("\"Then die, %s!\"",
680 youmonst.data->mlet == S_HUMAN ? "mortal" : "creature");
681 summon_minion(resp_god, FALSE);
682 break;
684 default:
685 gods_angry(resp_god);
686 god_zaps_you(resp_god);
687 break;
689 u.ublesscnt = rnz(300);
690 return;
693 /* helper to print "str appears at your feet", or appropriate */
694 static void
695 at_your_feet(str)
696 const char *str;
698 if (Blind)
699 str = Something;
700 if (u.uswallow) {
701 /* barrier between you and the floor */
702 pline("%s %s into %s %s.", str, vtense(str, "drop"),
703 s_suffix(mon_nam(u.ustuck)), mbodypart(u.ustuck, STOMACH));
704 } else {
705 pline("%s %s %s your %s!", str,
706 Blind ? "lands" : vtense(str, "appear"),
707 Levitation ? "beneath" : "at", makeplural(body_part(FOOT)));
711 STATIC_OVL void
712 gcrownu()
714 struct obj *obj;
715 boolean already_exists, in_hand;
716 short class_gift;
717 int sp_no;
718 #define ok_wep(o) ((o) && ((o)->oclass == WEAPON_CLASS || is_weptool(o)))
720 HSee_invisible |= FROMOUTSIDE;
721 HFire_resistance |= FROMOUTSIDE;
722 HCold_resistance |= FROMOUTSIDE;
723 HShock_resistance |= FROMOUTSIDE;
724 HSleep_resistance |= FROMOUTSIDE;
725 HPoison_resistance |= FROMOUTSIDE;
726 godvoice(u.ualign.type, (char *) 0);
728 obj = ok_wep(uwep) ? uwep : 0;
729 already_exists = in_hand = FALSE; /* lint suppression */
730 switch (u.ualign.type) {
731 case A_LAWFUL:
732 u.uevent.uhand_of_elbereth = 1;
733 verbalize("I crown thee... The Hand of Elbereth!");
734 break;
735 case A_NEUTRAL:
736 u.uevent.uhand_of_elbereth = 2;
737 in_hand = (uwep && uwep->oartifact == ART_VORPAL_BLADE);
738 already_exists =
739 exist_artifact(LONG_SWORD, artiname(ART_VORPAL_BLADE));
740 verbalize("Thou shalt be my Envoy of Balance!");
741 break;
742 case A_CHAOTIC:
743 u.uevent.uhand_of_elbereth = 3;
744 in_hand = (uwep && uwep->oartifact == ART_STORMBRINGER);
745 already_exists =
746 exist_artifact(RUNESWORD, artiname(ART_STORMBRINGER));
747 verbalize("Thou art chosen to %s for My Glory!",
748 already_exists && !in_hand ? "take lives" : "steal souls");
749 break;
752 class_gift = STRANGE_OBJECT;
753 /* 3.3.[01] had this in the A_NEUTRAL case below,
754 preventing chaotic wizards from receiving a spellbook */
755 if (Role_if(PM_WIZARD)
756 && (!uwep || (uwep->oartifact != ART_VORPAL_BLADE
757 && uwep->oartifact != ART_STORMBRINGER))
758 && !carrying(SPE_FINGER_OF_DEATH)) {
759 class_gift = SPE_FINGER_OF_DEATH;
760 make_splbk:
761 obj = mksobj(class_gift, TRUE, FALSE);
762 bless(obj);
763 obj->bknown = TRUE;
764 at_your_feet("A spellbook");
765 dropy(obj);
766 u.ugifts++;
767 /* when getting a new book for known spell, enhance
768 currently wielded weapon rather than the book */
769 for (sp_no = 0; sp_no < MAXSPELL; sp_no++)
770 if (spl_book[sp_no].sp_id == class_gift) {
771 if (ok_wep(uwep))
772 obj = uwep; /* to be blessed,&c */
773 break;
775 } else if (Role_if(PM_MONK) && (!uwep || !uwep->oartifact)
776 && !carrying(SPE_RESTORE_ABILITY)) {
777 /* monks rarely wield a weapon */
778 class_gift = SPE_RESTORE_ABILITY;
779 goto make_splbk;
782 switch (u.ualign.type) {
783 case A_LAWFUL:
784 if (class_gift != STRANGE_OBJECT) {
785 ; /* already got bonus above */
786 } else if (obj && obj->otyp == LONG_SWORD && !obj->oartifact) {
787 if (!Blind)
788 Your("sword shines brightly for a moment.");
789 obj = oname(obj, artiname(ART_EXCALIBUR));
790 if (obj && obj->oartifact == ART_EXCALIBUR)
791 u.ugifts++;
793 /* acquire Excalibur's skill regardless of weapon or gift */
794 unrestrict_weapon_skill(P_LONG_SWORD);
795 if (obj && obj->oartifact == ART_EXCALIBUR)
796 discover_artifact(ART_EXCALIBUR);
797 break;
798 case A_NEUTRAL:
799 if (class_gift != STRANGE_OBJECT) {
800 ; /* already got bonus above */
801 } else if (obj && in_hand) {
802 Your("%s goes snicker-snack!", xname(obj));
803 obj->dknown = TRUE;
804 } else if (!already_exists) {
805 obj = mksobj(LONG_SWORD, FALSE, FALSE);
806 obj = oname(obj, artiname(ART_VORPAL_BLADE));
807 obj->spe = 1;
808 at_your_feet("A sword");
809 dropy(obj);
810 u.ugifts++;
812 /* acquire Vorpal Blade's skill regardless of weapon or gift */
813 unrestrict_weapon_skill(P_LONG_SWORD);
814 if (obj && obj->oartifact == ART_VORPAL_BLADE)
815 discover_artifact(ART_VORPAL_BLADE);
816 break;
817 case A_CHAOTIC: {
818 char swordbuf[BUFSZ];
820 Sprintf(swordbuf, "%s sword", hcolor(NH_BLACK));
821 if (class_gift != STRANGE_OBJECT) {
822 ; /* already got bonus above */
823 } else if (obj && in_hand) {
824 Your("%s hums ominously!", swordbuf);
825 obj->dknown = TRUE;
826 } else if (!already_exists) {
827 obj = mksobj(RUNESWORD, FALSE, FALSE);
828 obj = oname(obj, artiname(ART_STORMBRINGER));
829 obj->spe = 1;
830 at_your_feet(An(swordbuf));
831 dropy(obj);
832 u.ugifts++;
834 /* acquire Stormbringer's skill regardless of weapon or gift */
835 unrestrict_weapon_skill(P_BROAD_SWORD);
836 if (obj && obj->oartifact == ART_STORMBRINGER)
837 discover_artifact(ART_STORMBRINGER);
838 break;
840 default:
841 obj = 0; /* lint */
842 break;
845 /* enhance weapon regardless of alignment or artifact status */
846 if (ok_wep(obj)) {
847 bless(obj);
848 obj->oeroded = obj->oeroded2 = 0;
849 obj->oerodeproof = TRUE;
850 obj->bknown = obj->rknown = TRUE;
851 if (obj->spe < 1)
852 obj->spe = 1;
853 /* acquire skill in this weapon */
854 unrestrict_weapon_skill(weapon_type(obj));
855 } else if (class_gift == STRANGE_OBJECT) {
856 /* opportunity knocked, but there was nobody home... */
857 You_feel("unworthy.");
859 update_inventory();
861 /* lastly, confer an extra skill slot/credit beyond the
862 up-to-29 you can get from gaining experience levels */
863 add_weapon_skill(1);
864 return;
867 STATIC_OVL void
868 pleased(g_align)
869 aligntyp g_align;
871 /* don't use p_trouble, worst trouble may get fixed while praying */
872 int trouble = in_trouble(); /* what's your worst difficulty? */
873 int pat_on_head = 0, kick_on_butt;
875 You_feel("that %s is %s.", align_gname(g_align),
876 (u.ualign.record >= DEVOUT)
877 ? Hallucination ? "pleased as punch" : "well-pleased"
878 : (u.ualign.record >= STRIDENT)
879 ? Hallucination ? "ticklish" : "pleased"
880 : Hallucination ? "full" : "satisfied");
882 /* not your deity */
883 if (on_altar() && p_aligntyp != u.ualign.type) {
884 adjalign(-1);
885 return;
886 } else if (u.ualign.record < 2 && trouble <= 0)
887 adjalign(1);
890 * Depending on your luck & align level, the god you prayed to will:
891 * - fix your worst problem if it's major;
892 * - fix all your major problems;
893 * - fix your worst problem if it's minor;
894 * - fix all of your problems;
895 * - do you a gratuitous favor.
897 * If you make it to the the last category, you roll randomly again
898 * to see what they do for you.
900 * If your luck is at least 0, then you are guaranteed rescued from
901 * your worst major problem.
903 if (!trouble && u.ualign.record >= DEVOUT) {
904 /* if hero was in trouble, but got better, no special favor */
905 if (p_trouble == 0)
906 pat_on_head = 1;
907 } else {
908 int action, prayer_luck;
909 int tryct = 0;
911 /* Negative luck is normally impossible here (can_pray() forces
912 prayer failure in that situation), but it's possible for
913 Luck to drop during the period of prayer occupation and
914 become negative by the time we get here. [Reported case
915 was lawful character whose stinking cloud caused a delayed
916 killing of a peaceful human, triggering the "murderer"
917 penalty while successful prayer was in progress. It could
918 also happen due to inconvenient timing on Friday 13th, but
919 the magnitude there (-1) isn't big enough to cause trouble.]
920 We don't bother remembering start-of-prayer luck, just make
921 sure it's at least -1 so that Luck+2 is big enough to avoid
922 a divide by zero crash when generating a random number. */
923 prayer_luck = max(Luck, -1); /* => (prayer_luck + 2 > 0) */
924 action = rn1(prayer_luck + (on_altar() ? 3 + on_shrine() : 2), 1);
925 if (!on_altar())
926 action = min(action, 3);
927 if (u.ualign.record < STRIDENT)
928 action = (u.ualign.record > 0 || !rnl(2)) ? 1 : 0;
930 switch (min(action, 5)) {
931 case 5:
932 pat_on_head = 1;
933 case 4:
935 fix_worst_trouble(trouble);
936 while ((trouble = in_trouble()) != 0);
937 break;
939 case 3:
940 fix_worst_trouble(trouble);
941 case 2:
942 /* arbitrary number of tries */
943 while ((trouble = in_trouble()) > 0 && (++tryct < 10))
944 fix_worst_trouble(trouble);
945 break;
947 case 1:
948 if (trouble > 0)
949 fix_worst_trouble(trouble);
950 case 0:
951 break; /* your god blows you off, too bad */
955 /* note: can't get pat_on_head unless all troubles have just been
956 fixed or there were no troubles to begin with; hallucination
957 won't be in effect so special handling for it is superfluous */
958 if (pat_on_head)
959 switch (rn2((Luck + 6) >> 1)) {
960 case 0:
961 break;
962 case 1:
963 if (uwep && (welded(uwep) || uwep->oclass == WEAPON_CLASS
964 || is_weptool(uwep))) {
965 char repair_buf[BUFSZ];
967 *repair_buf = '\0';
968 if (uwep->oeroded || uwep->oeroded2)
969 Sprintf(repair_buf, " and %s now as good as new",
970 otense(uwep, "are"));
972 if (uwep->cursed) {
973 if (!Blind) {
974 pline("%s %s%s.", Yobjnam2(uwep, "softly glow"),
975 hcolor(NH_AMBER), repair_buf);
976 iflags.last_msg = PLNMSG_OBJ_GLOWS;
977 } else
978 You_feel("the power of %s over %s.", u_gname(),
979 yname(uwep));
980 uncurse(uwep);
981 uwep->bknown = TRUE;
982 *repair_buf = '\0';
983 } else if (!uwep->blessed) {
984 if (!Blind) {
985 pline("%s with %s aura%s.",
986 Yobjnam2(uwep, "softly glow"),
987 an(hcolor(NH_LIGHT_BLUE)), repair_buf);
988 iflags.last_msg = PLNMSG_OBJ_GLOWS;
989 } else
990 You_feel("the blessing of %s over %s.", u_gname(),
991 yname(uwep));
992 bless(uwep);
993 uwep->bknown = TRUE;
994 *repair_buf = '\0';
997 /* fix any rust/burn/rot damage, but don't protect
998 against future damage */
999 if (uwep->oeroded || uwep->oeroded2) {
1000 uwep->oeroded = uwep->oeroded2 = 0;
1001 /* only give this message if we didn't just bless
1002 or uncurse (which has already given a message) */
1003 if (*repair_buf)
1004 pline("%s as good as new!",
1005 Yobjnam2(uwep, Blind ? "feel" : "look"));
1007 update_inventory();
1009 break;
1010 case 3:
1011 /* takes 2 hints to get the music to enter the stronghold;
1012 skip if you've solved it via mastermind or destroyed the
1013 drawbridge (both set uopened_dbridge) or if you've already
1014 travelled past the Valley of the Dead (gehennom_entered) */
1015 if (!u.uevent.uopened_dbridge && !u.uevent.gehennom_entered) {
1016 if (u.uevent.uheard_tune < 1) {
1017 godvoice(g_align, (char *) 0);
1018 verbalize("Hark, %s!", youmonst.data->mlet == S_HUMAN
1019 ? "mortal"
1020 : "creature");
1021 verbalize(
1022 "To enter the castle, thou must play the right tune!");
1023 u.uevent.uheard_tune++;
1024 break;
1025 } else if (u.uevent.uheard_tune < 2) {
1026 You_hear("a divine music...");
1027 pline("It sounds like: \"%s\".", tune);
1028 u.uevent.uheard_tune++;
1029 break;
1032 /* Otherwise, falls into next case */
1033 case 2:
1034 if (!Blind)
1035 You("are surrounded by %s glow.", an(hcolor(NH_GOLDEN)));
1036 /* if any levels have been lost (and not yet regained),
1037 treat this effect like blessed full healing */
1038 if (u.ulevel < u.ulevelmax) {
1039 u.ulevelmax -= 1; /* see potion.c */
1040 pluslvl(FALSE);
1041 } else {
1042 u.uhpmax += 5;
1043 if (Upolyd)
1044 u.mhmax += 5;
1046 u.uhp = u.uhpmax;
1047 if (Upolyd)
1048 u.mh = u.mhmax;
1049 ABASE(A_STR) = AMAX(A_STR);
1050 if (u.uhunger < 900)
1051 init_uhunger();
1052 /* luck couldn't have been negative at start of prayer because
1053 the prayer would have failed, but might have been decremented
1054 due to a timed event (delayed death of peaceful monster hit
1055 by hero-created stinking cloud) during the praying interval */
1056 if (u.uluck < 0)
1057 u.uluck = 0;
1058 /* superfluous; if hero was blinded we'd be handling trouble
1059 rather than issuing a pat-on-head */
1060 u.ucreamed = 0;
1061 make_blinded(0L, TRUE);
1062 context.botl = 1;
1063 break;
1064 case 4: {
1065 register struct obj *otmp;
1066 int any = 0;
1068 if (Blind)
1069 You_feel("the power of %s.", u_gname());
1070 else
1071 You("are surrounded by %s aura.", an(hcolor(NH_LIGHT_BLUE)));
1072 for (otmp = invent; otmp; otmp = otmp->nobj) {
1073 if (otmp->cursed) {
1074 if (!Blind) {
1075 pline("%s %s.", Yobjnam2(otmp, "softly glow"),
1076 hcolor(NH_AMBER));
1077 iflags.last_msg = PLNMSG_OBJ_GLOWS;
1078 otmp->bknown = TRUE;
1079 ++any;
1081 uncurse(otmp);
1084 if (any)
1085 update_inventory();
1086 break;
1088 case 5: {
1089 static NEARDATA const char msg[] =
1090 "\"and thus I grant thee the gift of %s!\"";
1092 godvoice(u.ualign.type,
1093 "Thou hast pleased me with thy progress,");
1094 if (!(HTelepat & INTRINSIC)) {
1095 HTelepat |= FROMOUTSIDE;
1096 pline(msg, "Telepathy");
1097 if (Blind)
1098 see_monsters();
1099 } else if (!(HFast & INTRINSIC)) {
1100 HFast |= FROMOUTSIDE;
1101 pline(msg, "Speed");
1102 } else if (!(HStealth & INTRINSIC)) {
1103 HStealth |= FROMOUTSIDE;
1104 pline(msg, "Stealth");
1105 } else {
1106 if (!(HProtection & INTRINSIC)) {
1107 HProtection |= FROMOUTSIDE;
1108 if (!u.ublessed)
1109 u.ublessed = rn1(3, 2);
1110 } else
1111 u.ublessed++;
1112 pline(msg, "my protection");
1114 verbalize("Use it wisely in my name!");
1115 break;
1117 case 7:
1118 case 8:
1119 if (u.ualign.record >= PIOUS && !u.uevent.uhand_of_elbereth) {
1120 gcrownu();
1121 break;
1122 } /* else FALLTHRU */
1123 case 6: {
1124 struct obj *otmp;
1125 int sp_no, trycnt = u.ulevel + 1;
1127 /* not yet known spells given preference over already known ones
1129 /* Also, try to grant a spell for which there is a skill slot */
1130 otmp = mkobj(SPBOOK_CLASS, TRUE);
1131 while (--trycnt > 0) {
1132 if (otmp->otyp != SPE_BLANK_PAPER) {
1133 for (sp_no = 0; sp_no < MAXSPELL; sp_no++)
1134 if (spl_book[sp_no].sp_id == otmp->otyp)
1135 break;
1136 if (sp_no == MAXSPELL
1137 && !P_RESTRICTED(spell_skilltype(otmp->otyp)))
1138 break; /* usable, but not yet known */
1139 } else {
1140 if (!objects[SPE_BLANK_PAPER].oc_name_known
1141 || carrying(MAGIC_MARKER))
1142 break;
1144 otmp->otyp = rnd_class(bases[SPBOOK_CLASS], SPE_BLANK_PAPER);
1146 bless(otmp);
1147 at_your_feet("A spellbook");
1148 place_object(otmp, u.ux, u.uy);
1149 newsym(u.ux, u.uy);
1150 break;
1152 default:
1153 impossible("Confused deity!");
1154 break;
1157 u.ublesscnt = rnz(350);
1158 kick_on_butt = u.uevent.udemigod ? 1 : 0;
1159 if (u.uevent.uhand_of_elbereth)
1160 kick_on_butt++;
1161 if (kick_on_butt)
1162 u.ublesscnt += kick_on_butt * rnz(1000);
1164 return;
1167 /* either blesses or curses water on the altar,
1168 * returns true if it found any water here.
1170 STATIC_OVL boolean
1171 water_prayer(bless_water)
1172 boolean bless_water;
1174 register struct obj *otmp;
1175 register long changed = 0;
1176 boolean other = FALSE, bc_known = !(Blind || Hallucination);
1178 for (otmp = level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere) {
1179 /* turn water into (un)holy water */
1180 if (otmp->otyp == POT_WATER
1181 && (bless_water ? !otmp->blessed : !otmp->cursed)) {
1182 otmp->blessed = bless_water;
1183 otmp->cursed = !bless_water;
1184 otmp->bknown = bc_known;
1185 changed += otmp->quan;
1186 } else if (otmp->oclass == POTION_CLASS)
1187 other = TRUE;
1189 if (!Blind && changed) {
1190 pline("%s potion%s on the altar glow%s %s for a moment.",
1191 ((other && changed > 1L) ? "Some of the"
1192 : (other ? "One of the" : "The")),
1193 ((other || changed > 1L) ? "s" : ""), (changed > 1L ? "" : "s"),
1194 (bless_water ? hcolor(NH_LIGHT_BLUE) : hcolor(NH_BLACK)));
1196 return (boolean) (changed > 0L);
1199 STATIC_OVL void
1200 godvoice(g_align, words)
1201 aligntyp g_align;
1202 const char *words;
1204 const char *quot = "";
1206 if (words)
1207 quot = "\"";
1208 else
1209 words = "";
1211 pline_The("voice of %s %s: %s%s%s", align_gname(g_align),
1212 godvoices[rn2(SIZE(godvoices))], quot, words, quot);
1215 STATIC_OVL void
1216 gods_angry(g_align)
1217 aligntyp g_align;
1219 godvoice(g_align, "Thou hast angered me.");
1222 /* The g_align god is upset with you. */
1223 STATIC_OVL void
1224 gods_upset(g_align)
1225 aligntyp g_align;
1227 if (g_align == u.ualign.type)
1228 u.ugangr++;
1229 else if (u.ugangr)
1230 u.ugangr--;
1231 angrygods(g_align);
1234 STATIC_OVL void
1235 consume_offering(otmp)
1236 register struct obj *otmp;
1238 if (Hallucination)
1239 switch (rn2(3)) {
1240 case 0:
1241 Your("sacrifice sprouts wings and a propeller and roars away!");
1242 break;
1243 case 1:
1244 Your("sacrifice puffs up, swelling bigger and bigger, and pops!");
1245 break;
1246 case 2:
1247 Your(
1248 "sacrifice collapses into a cloud of dancing particles and fades away!");
1249 break;
1251 else if (Blind && u.ualign.type == A_LAWFUL)
1252 Your("sacrifice disappears!");
1253 else
1254 Your("sacrifice is consumed in a %s!",
1255 u.ualign.type == A_LAWFUL ? "flash of light" : "burst of flame");
1256 if (carried(otmp))
1257 useup(otmp);
1258 else
1259 useupf(otmp, 1L);
1260 exercise(A_WIS, TRUE);
1264 dosacrifice()
1266 static NEARDATA const char cloud_of_smoke[] =
1267 "A cloud of %s smoke surrounds you...";
1268 register struct obj *otmp;
1269 int value = 0, pm;
1270 boolean highaltar;
1271 aligntyp altaralign = a_align(u.ux, u.uy);
1273 if (!on_altar() || u.uswallow) {
1274 You("are not standing on an altar.");
1275 return 0;
1277 highaltar = ((Is_astralevel(&u.uz) || Is_sanctum(&u.uz))
1278 && (levl[u.ux][u.uy].altarmask & AM_SHRINE));
1280 otmp = floorfood("sacrifice", 1);
1281 if (!otmp)
1282 return 0;
1284 * Was based on nutritional value and aging behavior (< 50 moves).
1285 * Sacrificing a food ration got you max luck instantly, making the
1286 * gods as easy to please as an angry dog!
1288 * Now only accepts corpses, based on the game's evaluation of their
1289 * toughness. Human and pet sacrifice, as well as sacrificing unicorns
1290 * of your alignment, is strongly discouraged.
1292 #define MAXVALUE 24 /* Highest corpse value (besides Wiz) */
1294 if (otmp->otyp == CORPSE) {
1295 register struct permonst *ptr = &mons[otmp->corpsenm];
1296 struct monst *mtmp;
1297 extern const int monstr[];
1299 /* KMH, conduct */
1300 u.uconduct.gnostic++;
1302 /* you're handling this corpse, even if it was killed upon the altar
1304 feel_cockatrice(otmp, TRUE);
1305 if (rider_corpse_revival(otmp, FALSE))
1306 return 1;
1308 if (otmp->corpsenm == PM_ACID_BLOB
1309 || (monstermoves <= peek_at_iced_corpse_age(otmp) + 50)) {
1310 value = monstr[otmp->corpsenm] + 1;
1311 if (otmp->oeaten)
1312 value = eaten_stat(value, otmp);
1315 if (your_race(ptr)) {
1316 if (is_demon(youmonst.data)) {
1317 You("find the idea very satisfying.");
1318 exercise(A_WIS, TRUE);
1319 } else if (u.ualign.type != A_CHAOTIC) {
1320 pline("You'll regret this infamous offense!");
1321 exercise(A_WIS, FALSE);
1324 if (highaltar
1325 && (altaralign != A_CHAOTIC || u.ualign.type != A_CHAOTIC)) {
1326 goto desecrate_high_altar;
1327 } else if (altaralign != A_CHAOTIC && altaralign != A_NONE) {
1328 /* curse the lawful/neutral altar */
1329 pline_The("altar is stained with %s blood.", urace.adj);
1330 levl[u.ux][u.uy].altarmask = AM_CHAOTIC;
1331 angry_priest();
1332 } else {
1333 struct monst *dmon;
1334 const char *demonless_msg;
1336 /* Human sacrifice on a chaotic or unaligned altar */
1337 /* is equivalent to demon summoning */
1338 if (altaralign == A_CHAOTIC && u.ualign.type != A_CHAOTIC) {
1339 pline(
1340 "The blood floods the altar, which vanishes in %s cloud!",
1341 an(hcolor(NH_BLACK)));
1342 levl[u.ux][u.uy].typ = ROOM;
1343 levl[u.ux][u.uy].altarmask = 0;
1344 newsym(u.ux, u.uy);
1345 angry_priest();
1346 demonless_msg = "cloud dissipates";
1347 } else {
1348 /* either you're chaotic or altar is Moloch's or both */
1349 pline_The("blood covers the altar!");
1350 change_luck(altaralign == A_NONE ? -2 : 2);
1351 demonless_msg = "blood coagulates";
1353 if ((pm = dlord(altaralign)) != NON_PM
1354 && (dmon = makemon(&mons[pm], u.ux, u.uy, NO_MM_FLAGS))
1355 != 0) {
1356 char dbuf[BUFSZ];
1358 Strcpy(dbuf, a_monnam(dmon));
1359 if (!strcmpi(dbuf, "it"))
1360 Strcpy(dbuf, "something dreadful");
1361 else
1362 dmon->mstrategy &= ~STRAT_APPEARMSG;
1363 You("have summoned %s!", dbuf);
1364 if (sgn(u.ualign.type) == sgn(dmon->data->maligntyp))
1365 dmon->mpeaceful = TRUE;
1366 You("are terrified, and unable to move.");
1367 nomul(-3);
1368 multi_reason = "being terrified of a demon";
1369 nomovemsg = 0;
1370 } else
1371 pline_The("%s.", demonless_msg);
1374 if (u.ualign.type != A_CHAOTIC) {
1375 adjalign(-5);
1376 u.ugangr += 3;
1377 (void) adjattrib(A_WIS, -1, TRUE);
1378 if (!Inhell)
1379 angrygods(u.ualign.type);
1380 change_luck(-5);
1381 } else
1382 adjalign(5);
1383 if (carried(otmp))
1384 useup(otmp);
1385 else
1386 useupf(otmp, 1L);
1387 return 1;
1388 } else if (has_omonst(otmp)
1389 && (mtmp = get_mtraits(otmp, FALSE)) != 0
1390 && mtmp->mtame) {
1391 /* mtmp is a temporary pointer to a tame monster's attributes,
1392 * not a real monster */
1393 pline("So this is how you repay loyalty?");
1394 adjalign(-3);
1395 value = -1;
1396 HAggravate_monster |= FROMOUTSIDE;
1397 } else if (is_undead(ptr)) { /* Not demons--no demon corpses */
1398 if (u.ualign.type != A_CHAOTIC)
1399 value += 1;
1400 } else if (is_unicorn(ptr)) {
1401 int unicalign = sgn(ptr->maligntyp);
1403 if (unicalign == altaralign) {
1404 /* When same as altar, always a very bad action.
1406 pline("Such an action is an insult to %s!",
1407 (unicalign == A_CHAOTIC) ? "chaos"
1408 : unicalign ? "law" : "balance");
1409 (void) adjattrib(A_WIS, -1, TRUE);
1410 value = -5;
1411 } else if (u.ualign.type == altaralign) {
1412 /* When different from altar, and altar is same as yours,
1413 * it's a very good action.
1415 if (u.ualign.record < ALIGNLIM)
1416 You_feel("appropriately %s.", align_str(u.ualign.type));
1417 else
1418 You_feel("you are thoroughly on the right path.");
1419 adjalign(5);
1420 value += 3;
1421 } else if (unicalign == u.ualign.type) {
1422 /* When sacrificing unicorn of your alignment to altar not of
1423 * your alignment, your god gets angry and it's a conversion.
1425 u.ualign.record = -1;
1426 value = 1;
1427 } else {
1428 /* Otherwise, unicorn's alignment is different from yours
1429 * and different from the altar's. It's an ordinary (well,
1430 * with a bonus) sacrifice on a cross-aligned altar.
1432 value += 3;
1435 } /* corpse */
1437 if (otmp->otyp == AMULET_OF_YENDOR) {
1438 if (!highaltar) {
1439 too_soon:
1440 if (altaralign == A_NONE && Inhell)
1441 /* hero has left Moloch's Sanctum so is in the process
1442 of getting away with the Amulet (outside of Gehennom,
1443 fall through to the "ashamed" feedback) */
1444 gods_upset(A_NONE);
1445 else
1446 You_feel("%s.",
1447 Hallucination
1448 ? "homesick"
1449 /* if on track, give a big hint */
1450 : (altaralign == u.ualign.type)
1451 ? "an urge to return to the surface"
1452 /* else headed towards celestial disgrace */
1453 : "ashamed");
1454 return 1;
1455 } else {
1456 /* The final Test. Did you win? */
1457 if (uamul == otmp)
1458 Amulet_off();
1459 u.uevent.ascended = 1;
1460 if (carried(otmp))
1461 useup(otmp); /* well, it's gone now */
1462 else
1463 useupf(otmp, 1L);
1464 You("offer the Amulet of Yendor to %s...", a_gname());
1465 if (altaralign == A_NONE) {
1466 /* Moloch's high altar */
1467 if (u.ualign.record > -99)
1468 u.ualign.record = -99;
1469 /*[apparently shrug/snarl can be sensed without being seen]*/
1470 pline("%s shrugs and retains dominion over %s,", Moloch,
1471 u_gname());
1472 pline("then mercilessly snuffs out your life.");
1473 Sprintf(killer.name, "%s indifference", s_suffix(Moloch));
1474 killer.format = KILLED_BY;
1475 done(DIED);
1476 /* life-saved (or declined to die in wizard/explore mode) */
1477 pline("%s snarls and tries again...", Moloch);
1478 fry_by_god(A_NONE, TRUE); /* wrath of Moloch */
1479 /* declined to die in wizard or explore mode */
1480 pline(cloud_of_smoke, hcolor(NH_BLACK));
1481 done(ESCAPED);
1482 } else if (u.ualign.type != altaralign) {
1483 /* And the opposing team picks you up and
1484 carries you off on their shoulders */
1485 adjalign(-99);
1486 pline("%s accepts your gift, and gains dominion over %s...",
1487 a_gname(), u_gname());
1488 pline("%s is enraged...", u_gname());
1489 pline("Fortunately, %s permits you to live...", a_gname());
1490 pline(cloud_of_smoke, hcolor(NH_ORANGE));
1491 done(ESCAPED);
1492 } else { /* super big win */
1493 adjalign(10);
1494 u.uachieve.ascended = 1;
1495 pline(
1496 "An invisible choir sings, and you are bathed in radiance...");
1497 godvoice(altaralign, "Congratulations, mortal!");
1498 display_nhwindow(WIN_MESSAGE, FALSE);
1499 verbalize(
1500 "In return for thy service, I grant thee the gift of Immortality!");
1501 You("ascend to the status of Demigod%s...",
1502 flags.female ? "dess" : "");
1503 done(ASCENDED);
1506 } /* real Amulet */
1508 if (otmp->otyp == FAKE_AMULET_OF_YENDOR) {
1509 if (!highaltar && !otmp->known)
1510 goto too_soon;
1511 You_hear("a nearby thunderclap.");
1512 if (!otmp->known) {
1513 You("realize you have made a %s.",
1514 Hallucination ? "boo-boo" : "mistake");
1515 otmp->known = TRUE;
1516 change_luck(-1);
1517 return 1;
1518 } else {
1519 /* don't you dare try to fool the gods */
1520 if (Deaf)
1521 pline("Oh, no."); /* didn't hear thunderclap */
1522 change_luck(-3);
1523 adjalign(-1);
1524 u.ugangr += 3;
1525 value = -3;
1527 } /* fake Amulet */
1529 if (value == 0) {
1530 pline1(nothing_happens);
1531 return 1;
1534 if (altaralign != u.ualign.type && highaltar) {
1535 desecrate_high_altar:
1537 * REAL BAD NEWS!!! High altars cannot be converted. Even an attempt
1538 * gets the god who owns it truly pissed off.
1540 You_feel("the air around you grow charged...");
1541 pline("Suddenly, you realize that %s has noticed you...", a_gname());
1542 godvoice(altaralign,
1543 "So, mortal! You dare desecrate my High Temple!");
1544 /* Throw everything we have at the player */
1545 god_zaps_you(altaralign);
1546 } else if (value
1547 < 0) { /* I don't think the gods are gonna like this... */
1548 gods_upset(altaralign);
1549 } else {
1550 int saved_anger = u.ugangr;
1551 int saved_cnt = u.ublesscnt;
1552 int saved_luck = u.uluck;
1554 /* Sacrificing at an altar of a different alignment */
1555 if (u.ualign.type != altaralign) {
1556 /* Is this a conversion ? */
1557 /* An unaligned altar in Gehennom will always elicit rejection. */
1558 if (ugod_is_angry() || (altaralign == A_NONE && Inhell)) {
1559 if (u.ualignbase[A_CURRENT] == u.ualignbase[A_ORIGINAL]
1560 && altaralign != A_NONE) {
1561 You("have a strong feeling that %s is angry...",
1562 u_gname());
1563 consume_offering(otmp);
1564 pline("%s accepts your allegiance.", a_gname());
1566 uchangealign(altaralign, 0);
1567 /* Beware, Conversion is costly */
1568 change_luck(-3);
1569 u.ublesscnt += 300;
1570 } else {
1571 u.ugangr += 3;
1572 adjalign(-5);
1573 pline("%s rejects your sacrifice!", a_gname());
1574 godvoice(altaralign, "Suffer, infidel!");
1575 change_luck(-5);
1576 (void) adjattrib(A_WIS, -2, TRUE);
1577 if (!Inhell)
1578 angrygods(u.ualign.type);
1580 return 1;
1581 } else {
1582 consume_offering(otmp);
1583 You("sense a conflict between %s and %s.", u_gname(),
1584 a_gname());
1585 if (rn2(8 + u.ulevel) > 5) {
1586 struct monst *pri;
1587 You_feel("the power of %s increase.", u_gname());
1588 exercise(A_WIS, TRUE);
1589 change_luck(1);
1590 /* Yes, this is supposed to be &=, not |= */
1591 levl[u.ux][u.uy].altarmask &= AM_SHRINE;
1592 /* the following accommodates stupid compilers */
1593 levl[u.ux][u.uy].altarmask =
1594 levl[u.ux][u.uy].altarmask
1595 | (Align2amask(u.ualign.type));
1596 if (!Blind)
1597 pline_The("altar glows %s.",
1598 hcolor((u.ualign.type == A_LAWFUL)
1599 ? NH_WHITE
1600 : u.ualign.type
1601 ? NH_BLACK
1602 : (const char *) "gray"));
1604 if (rnl(u.ulevel) > 6 && u.ualign.record > 0
1605 && rnd(u.ualign.record) > (3 * ALIGNLIM) / 4)
1606 summon_minion(altaralign, TRUE);
1607 /* anger priest; test handles bones files */
1608 if ((pri = findpriest(temple_occupied(u.urooms)))
1609 && !p_coaligned(pri))
1610 angry_priest();
1611 } else {
1612 pline("Unluckily, you feel the power of %s decrease.",
1613 u_gname());
1614 change_luck(-1);
1615 exercise(A_WIS, FALSE);
1616 if (rnl(u.ulevel) > 6 && u.ualign.record > 0
1617 && rnd(u.ualign.record) > (7 * ALIGNLIM) / 8)
1618 summon_minion(altaralign, TRUE);
1620 return 1;
1624 consume_offering(otmp);
1625 /* OK, you get brownie points. */
1626 if (u.ugangr) {
1627 u.ugangr -= ((value * (u.ualign.type == A_CHAOTIC ? 2 : 3))
1628 / MAXVALUE);
1629 if (u.ugangr < 0)
1630 u.ugangr = 0;
1631 if (u.ugangr != saved_anger) {
1632 if (u.ugangr) {
1633 pline("%s seems %s.", u_gname(),
1634 Hallucination ? "groovy" : "slightly mollified");
1636 if ((int) u.uluck < 0)
1637 change_luck(1);
1638 } else {
1639 pline("%s seems %s.", u_gname(),
1640 Hallucination ? "cosmic (not a new fact)"
1641 : "mollified");
1643 if ((int) u.uluck < 0)
1644 u.uluck = 0;
1646 } else { /* not satisfied yet */
1647 if (Hallucination)
1648 pline_The("gods seem tall.");
1649 else
1650 You("have a feeling of inadequacy.");
1652 } else if (ugod_is_angry()) {
1653 if (value > MAXVALUE)
1654 value = MAXVALUE;
1655 if (value > -u.ualign.record)
1656 value = -u.ualign.record;
1657 adjalign(value);
1658 You_feel("partially absolved.");
1659 } else if (u.ublesscnt > 0) {
1660 u.ublesscnt -= ((value * (u.ualign.type == A_CHAOTIC ? 500 : 300))
1661 / MAXVALUE);
1662 if (u.ublesscnt < 0)
1663 u.ublesscnt = 0;
1664 if (u.ublesscnt != saved_cnt) {
1665 if (u.ublesscnt) {
1666 if (Hallucination)
1667 You("realize that the gods are not like you and I.");
1668 else
1669 You("have a hopeful feeling.");
1670 if ((int) u.uluck < 0)
1671 change_luck(1);
1672 } else {
1673 if (Hallucination)
1674 pline("Overall, there is a smell of fried onions.");
1675 else
1676 You("have a feeling of reconciliation.");
1677 if ((int) u.uluck < 0)
1678 u.uluck = 0;
1681 } else {
1682 int nartifacts = nartifact_exist();
1684 /* you were already in pretty good standing */
1685 /* The player can gain an artifact */
1686 /* The chance goes down as the number of artifacts goes up */
1687 if (u.ulevel > 2 && u.uluck >= 0
1688 && !rn2(10 + (2 * u.ugifts * nartifacts))) {
1689 otmp = mk_artifact((struct obj *) 0, a_align(u.ux, u.uy));
1690 if (otmp) {
1691 if (otmp->spe < 0)
1692 otmp->spe = 0;
1693 if (otmp->cursed)
1694 uncurse(otmp);
1695 otmp->oerodeproof = TRUE;
1696 at_your_feet("An object");
1697 dropy(otmp);
1698 godvoice(u.ualign.type, "Use my gift wisely!");
1699 u.ugifts++;
1700 u.ublesscnt = rnz(300 + (50 * nartifacts));
1701 exercise(A_WIS, TRUE);
1702 /* make sure we can use this weapon */
1703 unrestrict_weapon_skill(weapon_type(otmp));
1704 if (!Hallucination && !Blind) {
1705 otmp->dknown = 1;
1706 makeknown(otmp->otyp);
1707 discover_artifact(otmp->oartifact);
1709 return 1;
1712 change_luck((value * LUCKMAX) / (MAXVALUE * 2));
1713 if ((int) u.uluck < 0)
1714 u.uluck = 0;
1715 if (u.uluck != saved_luck) {
1716 if (Blind)
1717 You("think %s brushed your %s.", something,
1718 body_part(FOOT));
1719 else
1720 You(Hallucination
1721 ? "see crabgrass at your %s. A funny thing in a dungeon."
1722 : "glimpse a four-leaf clover at your %s.",
1723 makeplural(body_part(FOOT)));
1727 return 1;
1730 /* determine prayer results in advance; also used for enlightenment */
1731 boolean
1732 can_pray(praying)
1733 boolean praying; /* false means no messages should be given */
1735 int alignment;
1737 p_aligntyp = on_altar() ? a_align(u.ux, u.uy) : u.ualign.type;
1738 p_trouble = in_trouble();
1740 if (is_demon(youmonst.data) && (p_aligntyp != A_CHAOTIC)) {
1741 if (praying)
1742 pline_The("very idea of praying to a %s god is repugnant to you.",
1743 p_aligntyp ? "lawful" : "neutral");
1744 return FALSE;
1747 if (praying)
1748 You("begin praying to %s.", align_gname(p_aligntyp));
1750 if (u.ualign.type && u.ualign.type == -p_aligntyp)
1751 alignment = -u.ualign.record; /* Opposite alignment altar */
1752 else if (u.ualign.type != p_aligntyp)
1753 alignment = u.ualign.record / 2; /* Different alignment altar */
1754 else
1755 alignment = u.ualign.record;
1757 if ((p_trouble > 0) ? (u.ublesscnt > 200) /* big trouble */
1758 : (p_trouble < 0) ? (u.ublesscnt > 100) /* minor difficulties */
1759 : (u.ublesscnt > 0)) /* not in trouble */
1760 p_type = 0; /* too soon... */
1761 else if ((int) Luck < 0 || u.ugangr || alignment < 0)
1762 p_type = 1; /* too naughty... */
1763 else /* alignment >= 0 */ {
1764 if (on_altar() && u.ualign.type != p_aligntyp)
1765 p_type = 2;
1766 else
1767 p_type = 3;
1770 if (is_undead(youmonst.data) && !Inhell
1771 && (p_aligntyp == A_LAWFUL || (p_aligntyp == A_NEUTRAL && !rn2(10))))
1772 p_type = -1;
1773 /* Note: when !praying, the random factor for neutrals makes the
1774 return value a non-deterministic approximation for enlightenment.
1775 This case should be uncommon enough to live with... */
1777 return !praying ? (boolean) (p_type == 3 && !Inhell) : TRUE;
1780 /* #pray commmand */
1782 dopray()
1784 /* Confirm accidental slips of Alt-P */
1785 if (ParanoidPray && yn("Are you sure you want to pray?") != 'y')
1786 return 0;
1788 u.uconduct.gnostic++;
1790 /* set up p_type and p_alignment */
1791 if (!can_pray(TRUE))
1792 return 0;
1794 if (wizard && p_type >= 0) {
1795 if (yn("Force the gods to be pleased?") == 'y') {
1796 u.ublesscnt = 0;
1797 if (u.uluck < 0)
1798 u.uluck = 0;
1799 if (u.ualign.record <= 0)
1800 u.ualign.record = 1;
1801 u.ugangr = 0;
1802 if (p_type < 2)
1803 p_type = 3;
1806 nomul(-3);
1807 multi_reason = "praying";
1808 nomovemsg = "You finish your prayer.";
1809 afternmv = prayer_done;
1811 if (p_type == 3 && !Inhell) {
1812 /* if you've been true to your god you can't die while you pray */
1813 if (!Blind)
1814 You("are surrounded by a shimmering light.");
1815 u.uinvulnerable = TRUE;
1818 return 1;
1821 STATIC_PTR int
1822 prayer_done() /* M. Stephenson (1.0.3b) */
1824 aligntyp alignment = p_aligntyp;
1826 u.uinvulnerable = FALSE;
1827 if (p_type == -1) {
1828 godvoice(alignment,
1829 (alignment == A_LAWFUL)
1830 ? "Vile creature, thou durst call upon me?"
1831 : "Walk no more, perversion of nature!");
1832 You_feel("like you are falling apart.");
1833 /* KMH -- Gods have mastery over unchanging */
1834 rehumanize();
1835 /* no Half_physical_damage adjustment here */
1836 losehp(rnd(20), "residual undead turning effect", KILLED_BY_AN);
1837 exercise(A_CON, FALSE);
1838 return 1;
1840 if (Inhell) {
1841 pline("Since you are in Gehennom, %s won't help you.",
1842 align_gname(alignment));
1843 /* haltingly aligned is least likely to anger */
1844 if (u.ualign.record <= 0 || rnl(u.ualign.record))
1845 angrygods(u.ualign.type);
1846 return 0;
1849 if (p_type == 0) {
1850 if (on_altar() && u.ualign.type != alignment)
1851 (void) water_prayer(FALSE);
1852 u.ublesscnt += rnz(250);
1853 change_luck(-3);
1854 gods_upset(u.ualign.type);
1855 } else if (p_type == 1) {
1856 if (on_altar() && u.ualign.type != alignment)
1857 (void) water_prayer(FALSE);
1858 angrygods(u.ualign.type); /* naughty */
1859 } else if (p_type == 2) {
1860 if (water_prayer(FALSE)) {
1861 /* attempted water prayer on a non-coaligned altar */
1862 u.ublesscnt += rnz(250);
1863 change_luck(-3);
1864 gods_upset(u.ualign.type);
1865 } else
1866 pleased(alignment);
1867 } else {
1868 /* coaligned */
1869 if (on_altar())
1870 (void) water_prayer(TRUE);
1871 pleased(alignment); /* nice */
1873 return 1;
1876 /* #turn command */
1878 doturn()
1880 /* Knights & Priest(esse)s only please */
1881 struct monst *mtmp, *mtmp2;
1882 int once, range, xlev;
1884 if (!Role_if(PM_PRIEST) && !Role_if(PM_KNIGHT)) {
1885 /* Try to use the "turn undead" spell.
1887 * This used to be based on whether hero knows the name of the
1888 * turn undead spellbook, but it's possible to know--and be able
1889 * to cast--the spell while having lost the book ID to amnesia.
1890 * (It also used to tell spelleffects() to cast at self?)
1892 int sp_no;
1894 for (sp_no = 0; sp_no < MAXSPELL; ++sp_no) {
1895 if (spl_book[sp_no].sp_id == NO_SPELL)
1896 break;
1897 else if (spl_book[sp_no].sp_id == SPE_TURN_UNDEAD)
1898 return spelleffects(sp_no, FALSE);
1900 You("don't know how to turn undead!");
1901 return 0;
1903 u.uconduct.gnostic++;
1905 if ((u.ualign.type != A_CHAOTIC
1906 && (is_demon(youmonst.data) || is_undead(youmonst.data)))
1907 || u.ugangr > 6) { /* "Die, mortal!" */
1908 pline("For some reason, %s seems to ignore you.", u_gname());
1909 aggravate();
1910 exercise(A_WIS, FALSE);
1911 return 0;
1913 if (Inhell) {
1914 pline("Since you are in Gehennom, %s won't help you.", u_gname());
1915 aggravate();
1916 return 0;
1918 pline("Calling upon %s, you chant an arcane formula.", u_gname());
1919 exercise(A_WIS, TRUE);
1921 /* note: does not perform unturn_dead() on victims' inventories */
1922 range = BOLT_LIM + (u.ulevel / 5); /* 5 to 11 */
1923 range *= range;
1924 once = 0;
1925 for (mtmp = fmon; mtmp; mtmp = mtmp2) {
1926 mtmp2 = mtmp->nmon;
1928 if (DEADMONSTER(mtmp))
1929 continue;
1930 if (!cansee(mtmp->mx, mtmp->my) || distu(mtmp->mx, mtmp->my) > range)
1931 continue;
1933 if (!mtmp->mpeaceful
1934 && (is_undead(mtmp->data) || is_vampshifter(mtmp)
1935 || (is_demon(mtmp->data) && (u.ulevel > (MAXULEV / 2))))) {
1936 mtmp->msleeping = 0;
1937 if (Confusion) {
1938 if (!once++)
1939 pline("Unfortunately, your voice falters.");
1940 mtmp->mflee = 0;
1941 mtmp->mfrozen = 0;
1942 mtmp->mcanmove = 1;
1943 } else if (!resist(mtmp, '\0', 0, TELL)) {
1944 xlev = 6;
1945 switch (mtmp->data->mlet) {
1946 /* this is intentional, lichs are tougher
1947 than zombies. */
1948 case S_LICH:
1949 xlev += 2; /*FALLTHRU*/
1950 case S_GHOST:
1951 xlev += 2; /*FALLTHRU*/
1952 case S_VAMPIRE:
1953 xlev += 2; /*FALLTHRU*/
1954 case S_WRAITH:
1955 xlev += 2; /*FALLTHRU*/
1956 case S_MUMMY:
1957 xlev += 2; /*FALLTHRU*/
1958 case S_ZOMBIE:
1959 if (u.ulevel >= xlev && !resist(mtmp, '\0', 0, NOTELL)) {
1960 if (u.ualign.type == A_CHAOTIC) {
1961 mtmp->mpeaceful = 1;
1962 set_malign(mtmp);
1963 } else { /* damn them */
1964 killed(mtmp);
1966 break;
1967 } /* else flee */
1968 /*FALLTHRU*/
1969 default:
1970 monflee(mtmp, 0, FALSE, TRUE);
1971 break;
1976 nomul(-(5 - ((u.ulevel - 1) / 6))); /* -5 .. -1 */
1977 multi_reason = "trying to turn the monsters";
1978 nomovemsg = You_can_move_again;
1979 return 1;
1982 const char *
1983 a_gname()
1985 return a_gname_at(u.ux, u.uy);
1988 /* returns the name of an altar's deity */
1989 const char *
1990 a_gname_at(x, y)
1991 xchar x, y;
1993 if (!IS_ALTAR(levl[x][y].typ))
1994 return (char *) 0;
1996 return align_gname(a_align(x, y));
1999 /* returns the name of the hero's deity */
2000 const char *
2001 u_gname()
2003 return align_gname(u.ualign.type);
2006 const char *
2007 align_gname(alignment)
2008 aligntyp alignment;
2010 const char *gnam;
2012 switch (alignment) {
2013 case A_NONE:
2014 gnam = Moloch;
2015 break;
2016 case A_LAWFUL:
2017 gnam = urole.lgod;
2018 break;
2019 case A_NEUTRAL:
2020 gnam = urole.ngod;
2021 break;
2022 case A_CHAOTIC:
2023 gnam = urole.cgod;
2024 break;
2025 default:
2026 impossible("unknown alignment.");
2027 gnam = "someone";
2028 break;
2030 if (*gnam == '_')
2031 ++gnam;
2032 return gnam;
2035 static const char *hallu_gods[] = {
2036 "the Flying Spaghetti Monster", /* Church of the FSM */
2037 "Eris", /* Discordianism */
2038 "the Martians", /* every science fiction ever */
2039 "Xom", /* Crawl */
2040 "AnDoR dRaKoN", /* ADOM */
2041 "the Central Bank of Yendor", /* economics */
2042 "Tooth Fairy", /* real world(?) */
2043 "Om", /* Discworld */
2044 "Yawgmoth", /* Magic: the Gathering */
2045 "Morgoth", /* LoTR */
2046 "Cthulhu", /* Lovecraft */
2047 "the Ori", /* Stargate */
2048 "destiny", /* why not? */
2049 "your Friend the Computer", /* Paranoia */
2052 /* hallucination handling for priest/minion names: select a random god
2053 iff character is hallucinating */
2054 const char *
2055 halu_gname(alignment)
2056 aligntyp alignment;
2058 const char *gnam = NULL;
2059 int which;
2061 if (!Hallucination)
2062 return align_gname(alignment);
2064 /* The priest may not have initialized god names. If this is the
2065 * case, and we roll priest, we need to try again. */
2067 which = randrole();
2068 while (!roles[which].lgod);
2070 switch (rn2(9)) {
2071 case 0:
2072 case 1:
2073 gnam = roles[which].lgod;
2074 break;
2075 case 2:
2076 case 3:
2077 gnam = roles[which].ngod;
2078 break;
2079 case 4:
2080 case 5:
2081 gnam = roles[which].cgod;
2082 break;
2083 case 6:
2084 case 7:
2085 gnam = hallu_gods[rn2(sizeof hallu_gods / sizeof *hallu_gods)];
2086 break;
2087 case 8:
2088 gnam = Moloch;
2089 break;
2090 default:
2091 impossible("rn2 broken in halu_gname?!?");
2093 if (!gnam) {
2094 impossible("No random god name?");
2095 gnam = "your Friend the Computer"; /* Paranoia */
2097 if (*gnam == '_')
2098 ++gnam;
2099 return gnam;
2102 /* deity's title */
2103 const char *
2104 align_gtitle(alignment)
2105 aligntyp alignment;
2107 const char *gnam, *result = "god";
2109 switch (alignment) {
2110 case A_LAWFUL:
2111 gnam = urole.lgod;
2112 break;
2113 case A_NEUTRAL:
2114 gnam = urole.ngod;
2115 break;
2116 case A_CHAOTIC:
2117 gnam = urole.cgod;
2118 break;
2119 default:
2120 gnam = 0;
2121 break;
2123 if (gnam && *gnam == '_')
2124 result = "goddess";
2125 return result;
2128 void
2129 altar_wrath(x, y)
2130 register int x, y;
2132 aligntyp altaralign = a_align(x, y);
2134 if (!strcmp(align_gname(altaralign), u_gname())) {
2135 godvoice(altaralign, "How darest thou desecrate my altar!");
2136 (void) adjattrib(A_WIS, -1, FALSE);
2137 } else {
2138 pline("A voice (could it be %s?) whispers:", align_gname(altaralign));
2139 verbalize("Thou shalt pay, infidel!");
2140 change_luck(-1);
2144 /* assumes isok() at one space away, but not necessarily at two */
2145 STATIC_OVL boolean
2146 blocked_boulder(dx, dy)
2147 int dx, dy;
2149 register struct obj *otmp;
2150 long count = 0L;
2152 for (otmp = level.objects[u.ux + dx][u.uy + dy]; otmp;
2153 otmp = otmp->nexthere) {
2154 if (otmp->otyp == BOULDER)
2155 count += otmp->quan;
2158 switch (count) {
2159 case 0:
2160 /* no boulders--not blocked */
2161 return FALSE;
2162 case 1:
2163 /* possibly blocked depending on if it's pushable */
2164 break;
2165 default:
2166 /* more than one boulder--blocked after they push the top one;
2167 don't force them to push it first to find out */
2168 return TRUE;
2171 if (!isok(u.ux + 2 * dx, u.uy + 2 * dy))
2172 return TRUE;
2173 if (IS_ROCK(levl[u.ux + 2 * dx][u.uy + 2 * dy].typ))
2174 return TRUE;
2175 if (sobj_at(BOULDER, u.ux + 2 * dx, u.uy + 2 * dy))
2176 return TRUE;
2178 return FALSE;
2181 /*pray.c*/