1 /* SCCS Id: @(#)pray.c 3.4 2003/03/23 */
2 /* Copyright (c) Benson I. Margulies, Mike Stephenson, Steve Linhart, 1989. */
3 /* NetHack may be freely redistributed. See license for details. */
8 STATIC_PTR int NDECL(prayer_done);
9 STATIC_DCL struct obj *NDECL(worst_cursed_item);
10 STATIC_DCL int NDECL(in_trouble);
11 STATIC_DCL void FDECL(fix_worst_trouble,(int));
12 STATIC_DCL void FDECL(angrygods,(ALIGNTYP_P));
13 STATIC_DCL void FDECL(at_your_feet, (const char *));
15 STATIC_DCL void NDECL(gcrownu);
17 STATIC_DCL void FDECL(pleased,(ALIGNTYP_P));
18 STATIC_DCL void FDECL(godvoice,(ALIGNTYP_P,const char*));
19 STATIC_DCL void FDECL(god_zaps_you,(ALIGNTYP_P));
20 STATIC_DCL void FDECL(fry_by_god,(ALIGNTYP_P));
21 STATIC_DCL void FDECL(gods_angry,(ALIGNTYP_P));
22 STATIC_DCL void FDECL(gods_upset,(ALIGNTYP_P));
23 STATIC_DCL void FDECL(consume_offering,(struct obj *));
24 STATIC_DCL boolean FDECL(water_prayer,(BOOLEAN_P));
25 STATIC_DCL boolean FDECL(blocked_boulder,(int,int));
27 /* simplify a few tests */
28 #define Cursed_obj(obj,typ) ((obj) && (obj)->otyp == (typ) && (obj)->cursed)
31 * Logic behind deities and altars and such:
32 * + prayers are made to your god if not on an altar, and to the altar's god
33 * if you are on an altar
34 * + If possible, your god answers all prayers, which is why bad things happen
35 * if you try to pray on another god's altar
36 * + sacrifices work basically the same way, but the other god may decide to
37 * accept your allegiance, after which they are your god. If rejected,
38 * your god takes over with your punishment.
39 * + if you're in Gehennom, all messages come from Moloch
43 * Moloch, who dwells in Gehennom, is the "renegade" cruel god
44 * responsible for the theft of the Amulet from Marduk, the Creator.
45 * Moloch is unaligned.
47 static const char *Moloch = "Moloch";
49 static const char *godvoices[] = {
56 /* values calculated when prayer starts, and used when completed */
57 static aligntyp p_aligntyp;
59 static int p_type; /* (-1)-3: (-1)=really naughty, 3=really good */
67 * The actual trouble priority is determined by the order of the
68 * checks performed in in_trouble() rather than by these numeric
69 * values, so keep that code and these values synchronized in
70 * order to have the values be meaningful.
73 #define TROUBLE_STONED 13
74 #define TROUBLE_SLIMED 12
75 #define TROUBLE_STRANGLED 11
76 #define TROUBLE_LAVA 10
77 #define TROUBLE_SICK 9
78 #define TROUBLE_STARVING 8
80 #define TROUBLE_LYCANTHROPE 6
81 #define TROUBLE_COLLAPSING 5
82 #define TROUBLE_STUCK_IN_WALL 4
83 #define TROUBLE_CURSED_LEVITATION 3
84 #define TROUBLE_UNUSEABLE_HANDS 2
85 #define TROUBLE_CURSED_BLINDFOLD 1
87 #define TROUBLE_PUNISHED (-1)
88 #define TROUBLE_FUMBLING (-2)
89 #define TROUBLE_CURSED_ITEMS (-3)
90 #define TROUBLE_SADDLE (-4)
91 #define TROUBLE_BLIND (-5)
92 #define TROUBLE_POISONED (-6)
93 #define TROUBLE_WOUNDED_LEGS (-7)
94 #define TROUBLE_HUNGRY (-8)
95 #define TROUBLE_STUNNED (-9)
96 #define TROUBLE_CONFUSED (-10)
97 #define TROUBLE_HALLUCINATION (-11)
99 /* We could force rehumanize of polyselfed people, but we can't tell
100 unintentional shape changes from the other kind. Oh well.
101 3.4.2: make an exception if polymorphed into a form which lacks
102 hands; that's a case where the ramifications override this doubt.
105 /* Return 0 if nothing particular seems wrong, positive numbers for
106 serious trouble, and negative numbers for comparative annoyances. This
107 returns the worst problem. There may be others, and the gods may fix
110 This could get as bizarre as noting surrounding opponents, (or hostile dogs),
111 but that's really hard.
114 #define ugod_is_angry() (u.ualign.record < 0)
115 #define on_altar() IS_ALTAR(levl[u.ux][u.uy].typ)
116 #define on_shrine() ((levl[u.ux][u.uy].altarmask & AM_SHRINE) != 0)
117 #define a_align(x,y) ((aligntyp)Amask2align(levl[x][y].altarmask & AM_MASK))
125 /* Borrowed from eat.c */
138 if(Stoned) return(TROUBLE_STONED);
139 if(Slimed) return(TROUBLE_SLIMED);
140 if(Strangled) return(TROUBLE_STRANGLED);
141 if(u.utrap && u.utraptype == TT_LAVA) return(TROUBLE_LAVA);
142 if(Sick) return(TROUBLE_SICK);
143 if(u.uhs >= WEAK) return(TROUBLE_STARVING);
144 if (Upolyd ? (u.mh <= 5 || u.mh*7 <= u.mhmax) :
145 (u.uhp <= 5 || u.uhp*7 <= u.uhpmax)) return TROUBLE_HIT;
146 if(u.ulycn >= LOW_PM) return(TROUBLE_LYCANTHROPE);
147 if(near_capacity() >= EXT_ENCUMBER && AMAX(A_STR)-ABASE(A_STR) > 3)
148 return(TROUBLE_COLLAPSING);
150 for (i= -1; i<=1; i++) for(j= -1; j<=1; j++) {
151 if (!i && !j) continue;
152 if (!isok(u.ux+i, u.uy+j) || IS_ROCK(levl[u.ux+i][u.uy+j].typ)
153 || (blocked_boulder(i,j) && !throws_rocks(youmonst.data)))
156 if (count == 8 && !Passes_walls)
157 return(TROUBLE_STUCK_IN_WALL);
159 if (Cursed_obj(uarmf, LEVITATION_BOOTS) ||
160 stuck_ring(uleft, RIN_LEVITATION) ||
161 stuck_ring(uright, RIN_LEVITATION))
162 return(TROUBLE_CURSED_LEVITATION);
163 if (nohands(youmonst.data) || !freehand()) {
164 /* for bag/box access [cf use_container()]...
165 make sure it's a case that we know how to handle;
166 otherwise "fix all troubles" would get stuck in a loop */
167 if (welded(uwep)) return TROUBLE_UNUSEABLE_HANDS;
168 if (Upolyd && nohands(youmonst.data) && (!Unchanging ||
169 ((otmp = unchanger()) != 0 && otmp->cursed)))
170 return TROUBLE_UNUSEABLE_HANDS;
172 if(Blindfolded && ublindf->cursed) return(TROUBLE_CURSED_BLINDFOLD);
177 if(Punished) return(TROUBLE_PUNISHED);
178 if (Cursed_obj(uarmg, GAUNTLETS_OF_FUMBLING) ||
179 Cursed_obj(uarmf, FUMBLE_BOOTS))
180 return TROUBLE_FUMBLING;
181 if (worst_cursed_item()) return TROUBLE_CURSED_ITEMS;
183 if (u.usteed) { /* can't voluntarily dismount from a cursed saddle */
184 otmp = which_armor(u.usteed, W_SADDLE);
185 if (Cursed_obj(otmp, SADDLE)) return TROUBLE_SADDLE;
189 if (Blinded > 1 && haseyes(youmonst.data)) return(TROUBLE_BLIND);
190 for(i=0; i<A_MAX; i++)
191 if(ABASE(i) < AMAX(i)) return(TROUBLE_POISONED);
196 ) return (TROUBLE_WOUNDED_LEGS);
197 if(u.uhs >= HUNGRY) return(TROUBLE_HUNGRY);
198 if(HStun) return (TROUBLE_STUNNED);
199 if(HConfusion) return (TROUBLE_CONFUSED);
200 if(Hallucination) return(TROUBLE_HALLUCINATION);
204 /* select an item for TROUBLE_CURSED_ITEMS */
205 STATIC_OVL struct obj *
208 register struct obj *otmp;
210 /* if strained or worse, check for loadstone first */
211 if (near_capacity() >= HVY_ENCUMBER) {
212 for (otmp = invent; otmp; otmp = otmp->nobj)
213 if (Cursed_obj(otmp, LOADSTONE)) return otmp;
215 /* weapon takes precedence if it is interfering
216 with taking off a ring or putting on a shield */
217 if (welded(uwep) && (uright || bimanual(uwep))) { /* weapon */
219 /* gloves come next, due to rings */
220 } else if (uarmg && uarmg->cursed) { /* gloves */
222 /* then shield due to two handed weapons and spells */
223 } else if (uarms && uarms->cursed) { /* shield */
225 /* then cloak due to body armor */
226 } else if (uarmc && uarmc->cursed) { /* cloak */
228 } else if (uarm && uarm->cursed) { /* suit */
230 } else if (uarmh && uarmh->cursed) { /* helmet */
232 } else if (uarmf && uarmf->cursed) { /* boots */
235 } else if (uarmu && uarmu->cursed) { /* shirt */
238 } else if (uamul && uamul->cursed) { /* amulet */
240 } else if (uleft && uleft->cursed) { /* left ring */
242 } else if (uright && uright->cursed) { /* right ring */
244 } else if (ublindf && ublindf->cursed) { /* eyewear */
245 otmp = ublindf; /* must be non-blinding lenses */
246 /* if weapon wasn't handled above, do it now */
247 } else if (welded(uwep)) { /* weapon */
249 /* active secondary weapon even though it isn't welded */
250 } else if (uswapwep && uswapwep->cursed && u.twoweap) {
252 /* all worn items ought to be handled by now */
254 for (otmp = invent; otmp; otmp = otmp->nobj) {
255 if (!otmp->cursed) continue;
256 if (otmp->otyp == LOADSTONE || confers_luck(otmp))
264 fix_worst_trouble(trouble)
265 register int trouble;
268 struct obj *otmp = 0;
269 const char *what = (const char *)0;
270 static NEARDATA const char leftglow[] = "left ring softly glows",
271 rightglow[] = "right ring softly glows";
275 You_feel("more limber.");
281 pline_The("slime disappears.");
286 case TROUBLE_STRANGLED:
287 if (uamul && uamul->otyp == AMULET_OF_STRANGULATION) {
288 Your("amulet vanishes!");
291 You("can breathe again.");
296 You("are back on solid ground.");
297 /* teleport should always succeed, but if not,
300 if(!safe_teleds(FALSE))
303 case TROUBLE_STARVING:
307 Your("%s feels content.", body_part(STOMACH));
313 make_sick(0L, (char *) 0, FALSE, SICK_ALL);
316 /* "fix all troubles" will keep trying if hero has
317 5 or less hit points, so make sure they're always
318 boosted to be more than that */
319 You_feel("much better.");
322 if (u.mhmax <= 5) u.mhmax = 5+1;
325 if (u.uhpmax < u.ulevel * 5 + 11) u.uhpmax += rnd(5);
326 if (u.uhpmax <= 5) u.uhpmax = 5+1;
330 case TROUBLE_COLLAPSING:
331 ABASE(A_STR) = AMAX(A_STR);
334 case TROUBLE_STUCK_IN_WALL:
335 Your("surroundings change.");
336 /* no control, but works on no-teleport levels */
337 (void) safe_teleds(FALSE);
339 case TROUBLE_CURSED_LEVITATION:
340 if (Cursed_obj(uarmf, LEVITATION_BOOTS)) {
342 } else if ((otmp = stuck_ring(uleft,RIN_LEVITATION)) !=0) {
343 if (otmp == uleft) what = leftglow;
344 } else if ((otmp = stuck_ring(uright,RIN_LEVITATION))!=0) {
345 if (otmp == uright) what = rightglow;
348 case TROUBLE_UNUSEABLE_HANDS:
353 if (Upolyd && nohands(youmonst.data)) {
355 Your("shape becomes uncertain.");
356 rehumanize(); /* "You return to {normal} form." */
357 } else if ((otmp = unchanger()) != 0 && otmp->cursed) {
358 /* otmp is an amulet of unchanging */
362 if (nohands(youmonst.data) || !freehand())
363 impossible("fix_worst_trouble: couldn't cure hands.");
365 case TROUBLE_CURSED_BLINDFOLD:
368 case TROUBLE_LYCANTHROPE:
373 case TROUBLE_PUNISHED:
374 Your("chain disappears.");
377 case TROUBLE_FUMBLING:
378 if (Cursed_obj(uarmg, GAUNTLETS_OF_FUMBLING))
380 else if (Cursed_obj(uarmf, FUMBLE_BOOTS))
385 case TROUBLE_CURSED_ITEMS:
386 otmp = worst_cursed_item();
387 if (otmp == uright) what = rightglow;
388 else if (otmp == uleft) what = leftglow;
391 impossible("fix_worst_trouble: nothing to uncurse.");
396 Your("%s %s.", what ? what :
397 (const char *)aobjnam(otmp, "softly glow"),
403 case TROUBLE_POISONED:
405 pline("There's a tiger in your tank.");
407 You_feel("in good health again.");
408 for(i=0; i<A_MAX; i++) {
409 if(ABASE(i) < AMAX(i)) {
414 (void) encumber_msg();
418 int num_eyes = eyecount(youmonst.data);
419 const char *eye = body_part(EYE);
421 Your("%s feel%s better.",
422 (num_eyes == 1) ? eye : makeplural(eye),
423 (num_eyes == 1) ? "s" : "");
425 make_blinded(0L,FALSE);
428 case TROUBLE_WOUNDED_LEGS:
431 case TROUBLE_STUNNED:
432 make_stunned(0L,TRUE);
434 case TROUBLE_CONFUSED:
435 make_confused(0L,TRUE);
437 case TROUBLE_HALLUCINATION:
438 pline ("Looks like you are back in Kansas.");
439 (void) make_hallucinated(0L,FALSE,0L);
443 otmp = which_armor(u.usteed, W_SADDLE);
447 s_suffix(upstart(y_monnam(u.usteed))),
448 aobjnam(otmp, "softly glow"),
457 /* "I am sometimes shocked by... the nuns who never take a bath without
458 * wearing a bathrobe all the time. When asked why, since no man can see them,
459 * they reply 'Oh, but you forget the good God'. Apparently they conceive of
460 * the Deity as a Peeping Tom, whose omnipotence enables Him to see through
461 * bathroom walls, but who is foiled by bathrobes." --Bertrand Russell, 1943
462 * Divine wrath, dungeon walls, and armor follow the same principle.
465 god_zaps_you(resp_god)
469 pline("Suddenly a bolt of lightning comes down at you from the heavens!");
470 pline("It strikes %s!", mon_nam(u.ustuck));
471 if (!resists_elec(u.ustuck)) {
472 pline("%s fries to a crisp!", Monnam(u.ustuck));
473 /* Yup, you get experience. It takes guts to successfully
474 * pull off this trick on your god, anyway.
476 xkilled(u.ustuck, 0);
478 pline("%s seems unaffected.", Monnam(u.ustuck));
480 pline("Suddenly, a bolt of lightning strikes you!");
482 shieldeff(u.ux, u.uy);
484 pline("For some reason you're unaffected.");
486 (void) ureflects("%s reflects from your %s.", "It");
487 } else if (Shock_resistance) {
488 shieldeff(u.ux, u.uy);
489 pline("It seems not to affect you.");
491 fry_by_god(resp_god);
494 pline("%s is not deterred...", align_gname(resp_god));
496 pline("A wide-angle disintegration beam aimed at you hits %s!",
498 if (!resists_disint(u.ustuck)) {
499 pline("%s fries to a crisp!", Monnam(u.ustuck));
500 xkilled(u.ustuck, 2); /* no corpse */
502 pline("%s seems unaffected.", Monnam(u.ustuck));
504 pline("A wide-angle disintegration beam hits you!");
506 /* disintegrate shield and body armor before disintegrating
507 * the impudent mortal, like black dragon breath -3.
509 if (uarms && !(EReflecting & W_ARMS) &&
510 !(EDisint_resistance & W_ARMS))
511 (void) destroy_arm(uarms);
512 if (uarmc && !(EReflecting & W_ARMC) &&
513 !(EDisint_resistance & W_ARMC))
514 (void) destroy_arm(uarmc);
515 if (uarm && !(EReflecting & W_ARM) &&
516 !(EDisint_resistance & W_ARM) && !uarmc)
517 (void) destroy_arm(uarm);
519 if (uarmu && !uarm && !uarmc) (void) destroy_arm(uarmu);
521 if (!Disint_resistance)
522 fry_by_god(resp_god);
524 You("bask in its %s glow for a minute...", NH_BLACK);
525 godvoice(resp_god, "I believe it not!");
527 if (Is_astralevel(&u.uz) || Is_sanctum(&u.uz)) {
528 /* one more try for high altars */
529 verbalize("Thou cannot escape my wrath, mortal!");
530 summon_minion(resp_god, FALSE);
531 summon_minion(resp_god, FALSE);
532 summon_minion(resp_god, FALSE);
533 verbalize("Destroy %s, my servants!", uhim());
544 You("fry to a crisp.");
545 killer_format = KILLED_BY;
546 Sprintf(killerbuf, "the wrath of %s", align_gname(resp_god));
555 register int maxanger;
557 if(Inhell) resp_god = A_NONE;
560 /* changed from tmp = u.ugangr + abs (u.uluck) -- rph */
561 /* added test for alignment diff -dlc */
562 if(resp_god != u.ualign.type)
563 maxanger = u.ualign.record/2 + (Luck > 0 ? -Luck/3 : -Luck);
565 maxanger = 3*u.ugangr +
566 ((Luck > 0 || u.ualign.record >= STRIDENT) ? -Luck/3 : -Luck);
567 if (maxanger < 1) maxanger = 1; /* possible if bad align & good luck */
568 else if (maxanger > 15) maxanger = 15; /* be reasonable */
570 switch (rn2(maxanger)) {
572 case 1: You_feel("that %s is %s.", align_gname(resp_god),
573 Hallucination ? "bummed" : "displeased");
577 godvoice(resp_god,(char *)0);
578 pline("\"Thou %s, %s.\"",
579 (ugod_is_angry() && resp_god == u.ualign.type)
580 ? "hast strayed from the path" :
582 youmonst.data->mlet == S_HUMAN ? "mortal" : "creature");
583 verbalize("Thou must relearn thy lessons!");
584 (void) adjattrib(A_WIS, -1, FALSE);
587 case 6: if (!Punished) {
588 gods_angry(resp_god);
589 punish((struct obj *)0);
591 } /* else fall thru */
593 case 5: gods_angry(resp_god);
594 if (!Blind && !Antimagic)
595 pline("%s glow surrounds you.",
596 An(hcolor(NH_BLACK)));
600 case 8: godvoice(resp_god,(char *)0);
601 verbalize("Thou durst %s me?",
603 (a_align(u.ux,u.uy) != resp_god)) ?
604 "scorn":"call upon");
605 pline("\"Then die, %s!\"",
606 youmonst.data->mlet == S_HUMAN ? "mortal" : "creature");
607 summon_minion(resp_god, FALSE);
610 default: gods_angry(resp_god);
611 god_zaps_you(resp_god);
614 u.ublesscnt = rnz(300);
618 /* helper to print "str appears at your feet", or appropriate */
623 if (Blind) str = Something;
625 /* barrier between you and the floor */
626 pline("%s %s into %s %s.", str, vtense(str, "drop"),
627 s_suffix(mon_nam(u.ustuck)), mbodypart(u.ustuck, STOMACH));
629 pline("%s %s %s your %s!", str,
630 Blind ? "lands" : vtense(str, "appear"),
631 Levitation ? "beneath" : "at",
632 makeplural(body_part(FOOT)));
641 boolean already_exists, in_hand;
644 #define ok_wep(o) ((o) && ((o)->oclass == WEAPON_CLASS || is_weptool(o)))
646 HSee_invisible |= FROMOUTSIDE;
647 HFire_resistance |= FROMOUTSIDE;
648 HCold_resistance |= FROMOUTSIDE;
649 HShock_resistance |= FROMOUTSIDE;
650 HSleep_resistance |= FROMOUTSIDE;
651 HPoison_resistance |= FROMOUTSIDE;
652 godvoice(u.ualign.type, (char *)0);
654 obj = ok_wep(uwep) ? uwep : 0;
655 already_exists = in_hand = FALSE; /* lint suppression */
656 switch (u.ualign.type) {
658 u.uevent.uhand_of_elbereth = 1;
659 verbalize("I crown thee... The Hand of Elbereth!");
662 u.uevent.uhand_of_elbereth = 2;
663 in_hand = (uwep && uwep->oartifact == ART_VORPAL_BLADE);
664 already_exists = exist_artifact(LONG_SWORD, artiname(ART_VORPAL_BLADE));
665 verbalize("Thou shalt be my Envoy of Balance!");
668 u.uevent.uhand_of_elbereth = 3;
669 in_hand = (uwep && uwep->oartifact == ART_STORMBRINGER);
670 already_exists = exist_artifact(RUNESWORD, artiname(ART_STORMBRINGER));
671 verbalize("Thou art chosen to %s for My Glory!",
672 already_exists && !in_hand ? "take lives" : "steal souls");
676 class_gift = STRANGE_OBJECT;
677 /* 3.3.[01] had this in the A_NEUTRAL case below,
678 preventing chaotic wizards from receiving a spellbook */
679 if (Role_if(PM_WIZARD) &&
680 (!uwep || (uwep->oartifact != ART_VORPAL_BLADE &&
681 uwep->oartifact != ART_STORMBRINGER)) &&
682 !carrying(SPE_FINGER_OF_DEATH)) {
683 class_gift = SPE_FINGER_OF_DEATH;
685 obj = mksobj(class_gift, TRUE, FALSE);
688 at_your_feet("A spellbook");
691 /* when getting a new book for known spell, enhance
692 currently wielded weapon rather than the book */
693 for (sp_no = 0; sp_no < MAXSPELL; sp_no++)
694 if (spl_book[sp_no].sp_id == class_gift) {
695 if (ok_wep(uwep)) obj = uwep; /* to be blessed,&c */
698 } else if (Role_if(PM_MONK) &&
699 (!uwep || !uwep->oartifact) &&
700 !carrying(SPE_RESTORE_ABILITY)) {
701 /* monks rarely wield a weapon */
702 class_gift = SPE_RESTORE_ABILITY;
706 switch (u.ualign.type) {
708 if (class_gift != STRANGE_OBJECT) {
709 ; /* already got bonus above */
710 } else if (obj && obj->otyp == LONG_SWORD && !obj->oartifact) {
711 if (!Blind) Your("sword shines brightly for a moment.");
712 obj = oname(obj, artiname(ART_EXCALIBUR));
713 if (obj && obj->oartifact == ART_EXCALIBUR) u.ugifts++;
715 /* acquire Excalibur's skill regardless of weapon or gift */
716 unrestrict_weapon_skill(P_LONG_SWORD);
717 if (obj && obj->oartifact == ART_EXCALIBUR)
718 discover_artifact(ART_EXCALIBUR);
721 if (class_gift != STRANGE_OBJECT) {
722 ; /* already got bonus above */
723 } else if (in_hand) {
724 Your("%s goes snicker-snack!", xname(obj));
726 } else if (!already_exists) {
727 obj = mksobj(LONG_SWORD, FALSE, FALSE);
728 obj = oname(obj, artiname(ART_VORPAL_BLADE));
730 at_your_feet("A sword");
734 /* acquire Vorpal Blade's skill regardless of weapon or gift */
735 unrestrict_weapon_skill(P_LONG_SWORD);
736 if (obj && obj->oartifact == ART_VORPAL_BLADE)
737 discover_artifact(ART_VORPAL_BLADE);
741 char swordbuf[BUFSZ];
743 Sprintf(swordbuf, "%s sword", hcolor(NH_BLACK));
744 if (class_gift != STRANGE_OBJECT) {
745 ; /* already got bonus above */
746 } else if (in_hand) {
747 Your("%s hums ominously!", swordbuf);
749 } else if (!already_exists) {
750 obj = mksobj(RUNESWORD, FALSE, FALSE);
751 obj = oname(obj, artiname(ART_STORMBRINGER));
752 at_your_feet(An(swordbuf));
757 /* acquire Stormbringer's skill regardless of weapon or gift */
758 unrestrict_weapon_skill(P_BROAD_SWORD);
759 if (obj && obj->oartifact == ART_STORMBRINGER)
760 discover_artifact(ART_STORMBRINGER);
768 /* enhance weapon regardless of alignment or artifact status */
771 obj->oeroded = obj->oeroded2 = 0;
772 obj->oerodeproof = TRUE;
773 obj->bknown = obj->rknown = TRUE;
774 if (obj->spe < 1) obj->spe = 1;
775 /* acquire skill in this weapon */
776 unrestrict_weapon_skill(weapon_type(obj));
777 } else if (class_gift == STRANGE_OBJECT) {
778 /* opportunity knocked, but there was nobody home... */
779 You_feel("unworthy.");
790 /* don't use p_trouble, worst trouble may get fixed while praying */
791 int trouble = in_trouble(); /* what's your worst difficulty? */
792 int pat_on_head = 0, kick_on_butt;
794 You_feel("that %s is %s.", align_gname(g_align),
795 u.ualign.record >= DEVOUT ?
796 Hallucination ? "pleased as punch" : "well-pleased" :
797 u.ualign.record >= STRIDENT ?
798 Hallucination ? "ticklish" : "pleased" :
799 Hallucination ? "full" : "satisfied");
802 if (on_altar() && p_aligntyp != u.ualign.type) {
805 } else if (u.ualign.record < 2 && trouble <= 0) adjalign(1);
807 /* depending on your luck & align level, the god you prayed to will:
808 - fix your worst problem if it's major.
809 - fix all your major problems.
810 - fix your worst problem if it's minor.
811 - fix all of your problems.
812 - do you a gratuitous favor.
814 if you make it to the the last category, you roll randomly again
815 to see what they do for you.
817 If your luck is at least 0, then you are guaranteed rescued
818 from your worst major problem. */
820 if (!trouble && u.ualign.record >= DEVOUT) {
821 /* if hero was in trouble, but got better, no special favor */
822 if (p_trouble == 0) pat_on_head = 1;
824 int action = rn1(Luck + (on_altar() ? 3 + on_shrine() : 2), 1);
826 if (!on_altar()) action = min(action, 3);
827 if (u.ualign.record < STRIDENT)
828 action = (u.ualign.record > 0 || !rnl(2)) ? 1 : 0;
830 switch(min(action,5)) {
831 case 5: pat_on_head = 1;
832 case 4: do fix_worst_trouble(trouble);
833 while ((trouble = in_trouble()) != 0);
836 case 3: fix_worst_trouble(trouble);
837 case 2: while ((trouble = in_trouble()) > 0)
838 fix_worst_trouble(trouble);
841 case 1: if (trouble > 0) fix_worst_trouble(trouble);
842 case 0: break; /* your god blows you off, too bad */
846 /* note: can't get pat_on_head unless all troubles have just been
847 fixed or there were no troubles to begin with; hallucination
848 won't be in effect so special handling for it is superfluous */
850 switch(rn2((Luck + 6)>>1)) {
853 if (uwep && (welded(uwep) || uwep->oclass == WEAPON_CLASS ||
855 char repair_buf[BUFSZ];
858 if (uwep->oeroded || uwep->oeroded2)
859 Sprintf(repair_buf, " and %s now as good as new",
860 otense(uwep, "are"));
866 Your("%s %s%s.", aobjnam(uwep, "softly glow"),
867 hcolor(NH_AMBER), repair_buf);
868 else You_feel("the power of %s over your %s.",
869 u_gname(), xname(uwep));
871 } else if (!uwep->blessed) {
875 Your("%s with %s aura%s.",
876 aobjnam(uwep, "softly glow"),
877 an(hcolor(NH_LIGHT_BLUE)), repair_buf);
878 else You_feel("the blessing of %s over your %s.",
879 u_gname(), xname(uwep));
883 /* fix any rust/burn/rot damage, but don't protect
884 against future damage */
885 if (uwep->oeroded || uwep->oeroded2) {
886 uwep->oeroded = uwep->oeroded2 = 0;
887 /* only give this message if we didn't just bless
888 or uncurse (which has already given a message) */
890 Your("%s as good as new!",
891 aobjnam(uwep, Blind ? "feel" : "look"));
897 /* takes 2 hints to get the music to enter the stronghold */
898 if (!u.uevent.uopened_dbridge) {
899 if (u.uevent.uheard_tune < 1) {
900 godvoice(g_align,(char *)0);
901 verbalize("Hark, %s!",
902 youmonst.data->mlet == S_HUMAN ? "mortal" : "creature");
904 "To enter the castle, thou must play the right tune!");
905 u.uevent.uheard_tune++;
907 } else if (u.uevent.uheard_tune < 2) {
908 You_hear("a divine music...");
909 pline("It sounds like: \"%s\".", tune);
910 u.uevent.uheard_tune++;
914 /* Otherwise, falls into next case */
917 You("are surrounded by %s glow.", an(hcolor(NH_GOLDEN)));
918 /* if any levels have been lost (and not yet regained),
919 treat this effect like blessed full healing */
920 if (u.ulevel < u.ulevelmax) {
921 u.ulevelmax -= 1; /* see potion.c */
925 if (Upolyd) u.mhmax += 5;
928 if (Upolyd) u.mh = u.mhmax;
929 ABASE(A_STR) = AMAX(A_STR);
930 if (u.uhunger < 900) init_uhunger();
931 if (u.uluck < 0) u.uluck = 0;
932 make_blinded(0L,TRUE);
936 register struct obj *otmp;
940 You_feel("the power of %s.", u_gname());
941 else You("are surrounded by %s aura.",
942 an(hcolor(NH_LIGHT_BLUE)));
943 for(otmp=invent; otmp; otmp=otmp->nobj) {
947 Your("%s %s.", aobjnam(otmp, "softly glow"),
954 if (any) update_inventory();
958 const char *msg="\"and thus I grant thee the gift of %s!\"";
959 godvoice(u.ualign.type, "Thou hast pleased me with thy progress,");
960 if (!(HTelepat & INTRINSIC)) {
961 HTelepat |= FROMOUTSIDE;
962 pline(msg, "Telepathy");
963 if (Blind) see_monsters();
964 } else if (!(HFast & INTRINSIC)) {
965 HFast |= FROMOUTSIDE;
967 } else if (!(HStealth & INTRINSIC)) {
968 HStealth |= FROMOUTSIDE;
969 pline(msg, "Stealth");
971 if (!(HProtection & INTRINSIC)) {
972 HProtection |= FROMOUTSIDE;
973 if (!u.ublessed) u.ublessed = rn1(3, 2);
975 pline(msg, "my protection");
977 verbalize("Use it wisely in my name!");
982 case 9: /* KMH -- can occur during full moons */
984 if (u.ualign.record >= PIOUS && !u.uevent.uhand_of_elbereth) {
987 } /* else FALLTHRU */
991 int sp_no, trycnt = u.ulevel + 1;
993 at_your_feet("An object");
994 /* not yet known spells given preference over already known ones */
995 /* Also, try to grant a spell for which there is a skill slot */
996 otmp = mkobj(SPBOOK_CLASS, TRUE);
997 while (--trycnt > 0) {
998 if (otmp->otyp != SPE_BLANK_PAPER) {
999 for (sp_no = 0; sp_no < MAXSPELL; sp_no++)
1000 if (spl_book[sp_no].sp_id == otmp->otyp) break;
1001 if (sp_no == MAXSPELL &&
1002 !P_RESTRICTED(spell_skilltype(otmp->otyp)))
1003 break; /* usable, but not yet known */
1005 if (!objects[SPE_BLANK_PAPER].oc_name_known ||
1006 carrying(MAGIC_MARKER)) break;
1008 otmp->otyp = rnd_class(bases[SPBOOK_CLASS], SPE_BLANK_PAPER);
1011 place_object(otmp, u.ux, u.uy);
1014 default: impossible("Confused deity!");
1018 u.ublesscnt = rnz(350);
1019 kick_on_butt = u.uevent.udemigod ? 1 : 0;
1021 if (u.uevent.uhand_of_elbereth) kick_on_butt++;
1023 if (kick_on_butt) u.ublesscnt += kick_on_butt * rnz(1000);
1028 /* either blesses or curses water on the altar,
1029 * returns true if it found any water here.
1032 water_prayer(bless_water)
1033 boolean bless_water;
1035 register struct obj* otmp;
1036 register long changed = 0;
1037 boolean other = FALSE, bc_known = !(Blind || Hallucination);
1039 for(otmp = level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere) {
1040 /* turn water into (un)holy water */
1041 if (otmp->otyp == POT_WATER &&
1042 (bless_water ? !otmp->blessed : !otmp->cursed)) {
1043 otmp->blessed = bless_water;
1044 otmp->cursed = !bless_water;
1045 otmp->bknown = bc_known;
1046 changed += otmp->quan;
1047 } else if(otmp->oclass == POTION_CLASS)
1050 if(!Blind && changed) {
1051 pline("%s potion%s on the altar glow%s %s for a moment.",
1052 ((other && changed > 1L) ? "Some of the" :
1053 (other ? "One of the" : "The")),
1054 ((other || changed > 1L) ? "s" : ""), (changed > 1L ? "" : "s"),
1055 (bless_water ? hcolor(NH_LIGHT_BLUE) : hcolor(NH_BLACK)));
1057 return((boolean)(changed > 0L));
1061 godvoice(g_align, words)
1065 const char *quot = "";
1071 pline_The("voice of %s %s: %s%s%s", align_gname(g_align),
1072 godvoices[rn2(SIZE(godvoices))], quot, words, quot);
1079 godvoice(g_align, "Thou hast angered me.");
1082 /* The g_align god is upset with you. */
1087 if(g_align == u.ualign.type) u.ugangr++;
1088 else if(u.ugangr) u.ugangr--;
1092 static NEARDATA const char sacrifice_types[] = { FOOD_CLASS, AMULET_CLASS, 0 };
1095 consume_offering(otmp)
1096 register struct obj *otmp;
1101 Your("sacrifice sprouts wings and a propeller and roars away!");
1104 Your("sacrifice puffs up, swelling bigger and bigger, and pops!");
1107 Your("sacrifice collapses into a cloud of dancing particles and fades away!");
1110 else if (Blind && u.ualign.type == A_LAWFUL)
1111 Your("sacrifice disappears!");
1112 else Your("sacrifice is consumed in a %s!",
1113 u.ualign.type == A_LAWFUL ? "flash of light" : "burst of flame");
1114 if (carried(otmp)) useup(otmp);
1115 else useupf(otmp, 1L);
1116 exercise(A_WIS, TRUE);
1122 register struct obj *otmp;
1125 aligntyp altaralign = a_align(u.ux,u.uy);
1127 if (!on_altar() || u.uswallow) {
1128 You("are not standing on an altar.");
1132 if (In_endgame(&u.uz)) {
1133 if (!(otmp = getobj(sacrifice_types, "sacrifice"))) return 0;
1135 if (!(otmp = floorfood("sacrifice", 1))) return 0;
1138 Was based on nutritional value and aging behavior (< 50 moves).
1139 Sacrificing a food ration got you max luck instantly, making the
1140 gods as easy to please as an angry dog!
1142 Now only accepts corpses, based on the game's evaluation of their
1143 toughness. Human and pet sacrifice, as well as sacrificing unicorns
1144 of your alignment, is strongly discouraged.
1147 #define MAXVALUE 24 /* Highest corpse value (besides Wiz) */
1149 if (otmp->otyp == CORPSE) {
1150 register struct permonst *ptr = &mons[otmp->corpsenm];
1152 extern const int monstr[];
1155 u.uconduct.gnostic++;
1157 /* you're handling this corpse, even if it was killed upon the altar */
1158 feel_cockatrice(otmp, TRUE);
1160 if (otmp->corpsenm == PM_ACID_BLOB
1161 || (monstermoves <= peek_at_iced_corpse_age(otmp) + 50)) {
1162 value = monstr[otmp->corpsenm] + 1;
1164 value = eaten_stat(value, otmp);
1167 if (your_race(ptr)) {
1168 if (is_demon(youmonst.data)) {
1169 You("find the idea very satisfying.");
1170 exercise(A_WIS, TRUE);
1171 } else if (u.ualign.type != A_CHAOTIC) {
1172 pline("You'll regret this infamous offense!");
1173 exercise(A_WIS, FALSE);
1176 if (altaralign != A_CHAOTIC && altaralign != A_NONE) {
1177 /* curse the lawful/neutral altar */
1178 pline_The("altar is stained with %s blood.", urace.adj);
1179 if(!Is_astralevel(&u.uz))
1180 levl[u.ux][u.uy].altarmask = AM_CHAOTIC;
1184 const char *demonless_msg;
1186 /* Human sacrifice on a chaotic or unaligned altar */
1187 /* is equivalent to demon summoning */
1188 if (altaralign == A_CHAOTIC && u.ualign.type != A_CHAOTIC) {
1190 "The blood floods the altar, which vanishes in %s cloud!",
1191 an(hcolor(NH_BLACK)));
1192 levl[u.ux][u.uy].typ = ROOM;
1193 levl[u.ux][u.uy].altarmask = 0;
1196 demonless_msg = "cloud dissipates";
1198 /* either you're chaotic or altar is Moloch's or both */
1199 pline_The("blood covers the altar!");
1200 change_luck(altaralign == A_NONE ? -2 : 2);
1201 demonless_msg = "blood coagulates";
1203 if ((pm = dlord(altaralign)) != NON_PM &&
1204 (dmon = makemon(&mons[pm], u.ux, u.uy, NO_MM_FLAGS))) {
1205 You("have summoned %s!", a_monnam(dmon));
1206 if (sgn(u.ualign.type) == sgn(dmon->data->maligntyp))
1207 dmon->mpeaceful = TRUE;
1208 You("are terrified, and unable to move.");
1210 } else pline_The("%s.", demonless_msg);
1213 if (u.ualign.type != A_CHAOTIC) {
1216 (void) adjattrib(A_WIS, -1, TRUE);
1217 if (!Inhell) angrygods(u.ualign.type);
1220 if (carried(otmp)) useup(otmp);
1221 else useupf(otmp, 1L);
1223 } else if (otmp->oxlth && otmp->oattached == OATTACHED_MONST
1224 && ((mtmp = get_mtraits(otmp, FALSE)) != (struct monst *)0)
1226 /* mtmp is a temporary pointer to a tame monster's attributes,
1227 * not a real monster */
1228 pline("So this is how you repay loyalty?");
1231 HAggravate_monster |= FROMOUTSIDE;
1232 } else if (is_undead(ptr)) { /* Not demons--no demon corpses */
1233 if (u.ualign.type != A_CHAOTIC)
1235 } else if (is_unicorn(ptr)) {
1236 int unicalign = sgn(ptr->maligntyp);
1238 /* If same as altar, always a very bad action. */
1239 if (unicalign == altaralign) {
1240 pline("Such an action is an insult to %s!",
1241 (unicalign == A_CHAOTIC)
1242 ? "chaos" : unicalign ? "law" : "balance");
1243 (void) adjattrib(A_WIS, -1, TRUE);
1245 } else if (u.ualign.type == altaralign) {
1246 /* If different from altar, and altar is same as yours, */
1247 /* it's a very good action */
1248 if (u.ualign.record < ALIGNLIM)
1249 You_feel("appropriately %s.", align_str(u.ualign.type));
1250 else You_feel("you are thoroughly on the right path.");
1254 /* If sacrificing unicorn of your alignment to altar not of */
1255 /* your alignment, your god gets angry and it's a conversion */
1256 if (unicalign == u.ualign.type) {
1257 u.ualign.record = -1;
1263 if (otmp->otyp == AMULET_OF_YENDOR) {
1264 if (!Is_astralevel(&u.uz)) {
1266 You_feel("homesick.");
1268 You_feel("an urge to return to the surface.");
1271 /* The final Test. Did you win? */
1272 if(uamul == otmp) Amulet_off();
1273 u.uevent.ascended = 1;
1274 if(carried(otmp)) useup(otmp); /* well, it's gone now */
1275 else useupf(otmp, 1L);
1276 You("offer the Amulet of Yendor to %s...", a_gname());
1277 if (u.ualign.type != altaralign) {
1278 /* And the opposing team picks you up and
1279 carries you off on their shoulders */
1281 pline("%s accepts your gift, and gains dominion over %s...",
1282 a_gname(), u_gname());
1283 pline("%s is enraged...", u_gname());
1284 pline("Fortunately, %s permits you to live...", a_gname());
1285 pline("A cloud of %s smoke surrounds you...",
1286 hcolor((const char *)"orange"));
1288 } else { /* super big win */
1290 pline("An invisible choir sings, and you are bathed in radiance...");
1291 godvoice(altaralign, "Congratulations, mortal!");
1292 display_nhwindow(WIN_MESSAGE, FALSE);
1293 verbalize("In return for thy service, I grant thee the gift of Immortality!");
1294 You("ascend to the status of Demigod%s...",
1295 flags.female ? "dess" : "");
1301 if (otmp->otyp == FAKE_AMULET_OF_YENDOR) {
1303 You_hear("a nearby thunderclap.");
1305 You("realize you have made a %s.",
1306 Hallucination ? "boo-boo" : "mistake");
1311 /* don't you dare try to fool the gods */
1320 pline(nothing_happens);
1324 if (altaralign != u.ualign.type &&
1325 (Is_astralevel(&u.uz) || Is_sanctum(&u.uz))) {
1327 * REAL BAD NEWS!!! High altars cannot be converted. Even an attempt
1328 * gets the god who owns it truely pissed off.
1330 You_feel("the air around you grow charged...");
1331 pline("Suddenly, you realize that %s has noticed you...", a_gname());
1332 godvoice(altaralign, "So, mortal! You dare desecrate my High Temple!");
1333 /* Throw everything we have at the player */
1334 god_zaps_you(altaralign);
1335 } else if (value < 0) { /* I don't think the gods are gonna like this... */
1336 gods_upset(altaralign);
1338 int saved_anger = u.ugangr;
1339 int saved_cnt = u.ublesscnt;
1340 int saved_luck = u.uluck;
1342 /* Sacrificing at an altar of a different alignment */
1343 if (u.ualign.type != altaralign) {
1344 /* Is this a conversion ? */
1345 /* An unaligned altar in Gehennom will always elicit rejection. */
1346 if (ugod_is_angry() || (altaralign == A_NONE && Inhell)) {
1347 if(u.ualignbase[A_CURRENT] == u.ualignbase[A_ORIGINAL] &&
1348 altaralign != A_NONE) {
1349 You("have a strong feeling that %s is angry...", u_gname());
1350 consume_offering(otmp);
1351 pline("%s accepts your allegiance.", a_gname());
1353 /* The player wears a helm of opposite alignment? */
1354 if (uarmh && uarmh->otyp == HELM_OF_OPPOSITE_ALIGNMENT)
1355 u.ualignbase[A_CURRENT] = altaralign;
1357 u.ualign.type = u.ualignbase[A_CURRENT] = altaralign;
1361 You("have a sudden sense of a new direction.");
1362 /* Beware, Conversion is costly */
1365 adjalign((int)(u.ualignbase[A_ORIGINAL] * (ALIGNLIM / 2)));
1369 pline("%s rejects your sacrifice!", a_gname());
1370 godvoice(altaralign, "Suffer, infidel!");
1372 (void) adjattrib(A_WIS, -2, TRUE);
1373 if (!Inhell) angrygods(u.ualign.type);
1377 consume_offering(otmp);
1378 You("sense a conflict between %s and %s.",
1379 u_gname(), a_gname());
1380 if (rn2(8 + u.ulevel) > 5) {
1382 You_feel("the power of %s increase.", u_gname());
1383 exercise(A_WIS, TRUE);
1385 /* Yes, this is supposed to be &=, not |= */
1386 levl[u.ux][u.uy].altarmask &= AM_SHRINE;
1387 /* the following accommodates stupid compilers */
1388 levl[u.ux][u.uy].altarmask =
1389 levl[u.ux][u.uy].altarmask | (Align2amask(u.ualign.type));
1391 pline_The("altar glows %s.",
1393 u.ualign.type == A_LAWFUL ? NH_WHITE :
1394 u.ualign.type ? NH_BLACK : (const char *)"gray"));
1396 if (rnl(u.ulevel) > 6 && u.ualign.record > 0 &&
1397 rnd(u.ualign.record) > (3*ALIGNLIM)/4)
1398 summon_minion(altaralign, TRUE);
1399 /* anger priest; test handles bones files */
1400 if((pri = findpriest(temple_occupied(u.urooms))) &&
1404 pline("Unluckily, you feel the power of %s decrease.",
1407 exercise(A_WIS, FALSE);
1408 if (rnl(u.ulevel) > 6 && u.ualign.record > 0 &&
1409 rnd(u.ualign.record) > (7*ALIGNLIM)/8)
1410 summon_minion(altaralign, TRUE);
1416 consume_offering(otmp);
1417 /* OK, you get brownie points. */
1420 ((value * (u.ualign.type == A_CHAOTIC ? 2 : 3)) / MAXVALUE);
1421 if(u.ugangr < 0) u.ugangr = 0;
1422 if(u.ugangr != saved_anger) {
1424 pline("%s seems %s.", u_gname(),
1425 Hallucination ? "groovy" : "slightly mollified");
1427 if ((int)u.uluck < 0) change_luck(1);
1429 pline("%s seems %s.", u_gname(), Hallucination ?
1430 "cosmic (not a new fact)" : "mollified");
1432 if ((int)u.uluck < 0) u.uluck = 0;
1434 } else { /* not satisfied yet */
1436 pline_The("gods seem tall.");
1437 else You("have a feeling of inadequacy.");
1439 } else if(ugod_is_angry()) {
1440 if(value > MAXVALUE) value = MAXVALUE;
1441 if(value > -u.ualign.record) value = -u.ualign.record;
1443 You_feel("partially absolved.");
1444 } else if (u.ublesscnt > 0) {
1446 ((value * (u.ualign.type == A_CHAOTIC ? 500 : 300)) / MAXVALUE);
1447 if(u.ublesscnt < 0) u.ublesscnt = 0;
1448 if(u.ublesscnt != saved_cnt) {
1451 You("realize that the gods are not like you and I.");
1453 You("have a hopeful feeling.");
1454 if ((int)u.uluck < 0) change_luck(1);
1457 pline("Overall, there is a smell of fried onions.");
1459 You("have a feeling of reconciliation.");
1460 if ((int)u.uluck < 0) u.uluck = 0;
1464 int nartifacts = nartifact_exist();
1466 /* you were already in pretty good standing */
1467 /* The player can gain an artifact */
1468 /* The chance goes down as the number of artifacts goes up */
1469 if (u.ulevel > 2 && u.uluck >= 0 &&
1470 !rn2(10 + (2 * u.ugifts * nartifacts))) {
1471 otmp = mk_artifact((struct obj *)0, a_align(u.ux,u.uy));
1473 if (otmp->spe < 0) otmp->spe = 0;
1474 if (otmp->cursed) uncurse(otmp);
1475 otmp->oerodeproof = TRUE;
1477 at_your_feet("An object");
1478 godvoice(u.ualign.type, "Use my gift wisely!");
1480 u.ublesscnt = rnz(300 + (50 * nartifacts));
1481 exercise(A_WIS, TRUE);
1482 /* make sure we can use this weapon */
1483 unrestrict_weapon_skill(weapon_type(otmp));
1484 discover_artifact(otmp->oartifact);
1488 change_luck((value * LUCKMAX) / (MAXVALUE * 2));
1489 if ((int)u.uluck < 0) u.uluck = 0;
1490 if (u.uluck != saved_luck) {
1492 You("think %s brushed your %s.",something, body_part(FOOT));
1493 else You(Hallucination ?
1494 "see crabgrass at your %s. A funny thing in a dungeon." :
1495 "glimpse a four-leaf clover at your %s.",
1496 makeplural(body_part(FOOT)));
1504 /* determine prayer results in advance; also used for enlightenment */
1507 boolean praying; /* false means no messages should be given */
1511 p_aligntyp = on_altar() ? a_align(u.ux,u.uy) : u.ualign.type;
1512 p_trouble = in_trouble();
1514 if (is_demon(youmonst.data) && (p_aligntyp != A_CHAOTIC)) {
1516 pline_The("very idea of praying to a %s god is repugnant to you.",
1517 p_aligntyp ? "lawful" : "neutral");
1522 You("begin praying to %s.", align_gname(p_aligntyp));
1524 if (u.ualign.type && u.ualign.type == -p_aligntyp)
1525 alignment = -u.ualign.record; /* Opposite alignment altar */
1526 else if (u.ualign.type != p_aligntyp)
1527 alignment = u.ualign.record / 2; /* Different alignment altar */
1528 else alignment = u.ualign.record;
1530 if ((p_trouble > 0) ? (u.ublesscnt > 200) : /* big trouble */
1531 (p_trouble < 0) ? (u.ublesscnt > 100) : /* minor difficulties */
1532 (u.ublesscnt > 0)) /* not in trouble */
1533 p_type = 0; /* too soon... */
1534 else if ((int)Luck < 0 || u.ugangr || alignment < 0)
1535 p_type = 1; /* too naughty... */
1536 else /* alignment >= 0 */ {
1537 if(on_altar() && u.ualign.type != p_aligntyp)
1543 if (is_undead(youmonst.data) && !Inhell &&
1544 (p_aligntyp == A_LAWFUL || (p_aligntyp == A_NEUTRAL && !rn2(10))))
1546 /* Note: when !praying, the random factor for neutrals makes the
1547 return value a non-deterministic approximation for enlightenment.
1548 This case should be uncommon enough to live with... */
1550 return !praying ? (boolean)(p_type == 3 && !Inhell) : TRUE;
1556 /* Confirm accidental slips of Alt-P */
1557 if (flags.prayconfirm)
1558 if (yn("Are you sure you want to pray?") == 'n')
1561 u.uconduct.gnostic++;
1562 /* Praying implies that the hero is conscious and since we have
1563 no deafness attribute this implies that all verbalized messages
1564 can be heard. So, in case the player has used the 'O' command
1565 to toggle this accessible flag off, force it to be on. */
1568 /* set up p_type and p_alignment */
1569 if (!can_pray(TRUE)) return 0;
1572 if (wizard && p_type >= 0) {
1573 if (yn("Force the gods to be pleased?") == 'y') {
1575 if (u.uluck < 0) u.uluck = 0;
1576 if (u.ualign.record <= 0) u.ualign.record = 1;
1578 if(p_type < 2) p_type = 3;
1583 nomovemsg = "You finish your prayer.";
1584 afternmv = prayer_done;
1586 if(p_type == 3 && !Inhell) {
1587 /* if you've been true to your god you can't die while you pray */
1589 You("are surrounded by a shimmering light.");
1590 u.uinvulnerable = TRUE;
1597 prayer_done() /* M. Stephenson (1.0.3b) */
1599 aligntyp alignment = p_aligntyp;
1601 u.uinvulnerable = FALSE;
1604 alignment == A_LAWFUL ?
1605 "Vile creature, thou durst call upon me?" :
1606 "Walk no more, perversion of nature!");
1607 You_feel("like you are falling apart.");
1608 /* KMH -- Gods have mastery over unchanging */
1610 losehp(rnd(20), "residual undead turning effect", KILLED_BY_AN);
1611 exercise(A_CON, FALSE);
1615 pline("Since you are in Gehennom, %s won't help you.",
1616 align_gname(alignment));
1617 /* haltingly aligned is least likely to anger */
1618 if (u.ualign.record <= 0 || rnl(u.ualign.record))
1619 angrygods(u.ualign.type);
1624 if(on_altar() && u.ualign.type != alignment)
1625 (void) water_prayer(FALSE);
1626 u.ublesscnt += rnz(250);
1628 gods_upset(u.ualign.type);
1629 } else if(p_type == 1) {
1630 if(on_altar() && u.ualign.type != alignment)
1631 (void) water_prayer(FALSE);
1632 angrygods(u.ualign.type); /* naughty */
1633 } else if(p_type == 2) {
1634 if(water_prayer(FALSE)) {
1635 /* attempted water prayer on a non-coaligned altar */
1636 u.ublesscnt += rnz(250);
1638 gods_upset(u.ualign.type);
1639 } else pleased(alignment);
1643 (void) water_prayer(TRUE);
1644 pleased(alignment); /* nice */
1651 { /* Knights & Priest(esse)s only please */
1653 struct monst *mtmp, *mtmp2;
1654 int once, range, xlev;
1656 if (!Role_if(PM_PRIEST) && !Role_if(PM_KNIGHT)) {
1657 /* Try to use turn undead spell. */
1658 if (objects[SPE_TURN_UNDEAD].oc_name_known) {
1660 for (sp_no = 0; sp_no < MAXSPELL &&
1661 spl_book[sp_no].sp_id != NO_SPELL &&
1662 spl_book[sp_no].sp_id != SPE_TURN_UNDEAD; sp_no++);
1664 if (sp_no < MAXSPELL &&
1665 spl_book[sp_no].sp_id == SPE_TURN_UNDEAD)
1666 return spelleffects(sp_no, TRUE);
1669 You("don't know how to turn undead!");
1672 u.uconduct.gnostic++;
1674 if ((u.ualign.type != A_CHAOTIC &&
1675 (is_demon(youmonst.data) || is_undead(youmonst.data))) ||
1676 u.ugangr > 6 /* "Die, mortal!" */) {
1678 pline("For some reason, %s seems to ignore you.", u_gname());
1680 exercise(A_WIS, FALSE);
1685 pline("Since you are in Gehennom, %s won't help you.", u_gname());
1689 pline("Calling upon %s, you chant an arcane formula.", u_gname());
1690 exercise(A_WIS, TRUE);
1692 /* note: does not perform unturn_dead() on victims' inventories */
1693 range = BOLT_LIM + (u.ulevel / 5); /* 5 to 11 */
1696 for(mtmp = fmon; mtmp; mtmp = mtmp2) {
1699 if (DEADMONSTER(mtmp)) continue;
1700 if (!cansee(mtmp->mx,mtmp->my) ||
1701 distu(mtmp->mx,mtmp->my) > range) continue;
1703 if (!mtmp->mpeaceful && (is_undead(mtmp->data) ||
1704 (is_demon(mtmp->data) && (u.ulevel > (MAXULEV/2))))) {
1706 mtmp->msleeping = 0;
1709 pline("Unfortunately, your voice falters.");
1713 } else if (!resist(mtmp, '\0', 0, TELL)) {
1715 switch (mtmp->data->mlet) {
1716 /* this is intentional, lichs are tougher
1718 case S_LICH: xlev += 2; /*FALLTHRU*/
1719 case S_GHOST: xlev += 2; /*FALLTHRU*/
1720 case S_VAMPIRE: xlev += 2; /*FALLTHRU*/
1721 case S_WRAITH: xlev += 2; /*FALLTHRU*/
1722 case S_MUMMY: xlev += 2; /*FALLTHRU*/
1724 if (u.ulevel >= xlev &&
1725 !resist(mtmp, '\0', 0, NOTELL)) {
1726 if (u.ualign.type == A_CHAOTIC) {
1727 mtmp->mpeaceful = 1;
1729 } else { /* damn them */
1736 monflee(mtmp, 0, FALSE, TRUE);
1749 return(a_gname_at(u.ux, u.uy));
1753 a_gname_at(x,y) /* returns the name of an altar's deity */
1756 if(!IS_ALTAR(levl[x][y].typ)) return((char *)0);
1758 return align_gname(a_align(x,y));
1762 u_gname() /* returns the name of the player's deity */
1764 return align_gname(u.ualign.type);
1768 align_gname(alignment)
1773 switch (alignment) {
1774 case A_NONE: gnam = Moloch; break;
1775 case A_LAWFUL: gnam = urole.lgod; break;
1776 case A_NEUTRAL: gnam = urole.ngod; break;
1777 case A_CHAOTIC: gnam = urole.cgod; break;
1778 default: impossible("unknown alignment.");
1779 gnam = "someone"; break;
1781 if (*gnam == '_') ++gnam;
1785 /* hallucination handling for priest/minion names: select a random god
1786 iff character is hallucinating */
1788 halu_gname(alignment)
1794 if (!Hallucination) return align_gname(alignment);
1798 case 0: gnam = roles[which].lgod; break;
1799 case 1: gnam = roles[which].ngod; break;
1800 case 2: gnam = roles[which].cgod; break;
1801 default: gnam = 0; break; /* lint suppression */
1803 if (!gnam) gnam = Moloch;
1804 if (*gnam == '_') ++gnam;
1810 align_gtitle(alignment)
1813 const char *gnam, *result = "god";
1815 switch (alignment) {
1816 case A_LAWFUL: gnam = urole.lgod; break;
1817 case A_NEUTRAL: gnam = urole.ngod; break;
1818 case A_CHAOTIC: gnam = urole.cgod; break;
1819 default: gnam = 0; break;
1821 if (gnam && *gnam == '_') result = "goddess";
1829 aligntyp altaralign = a_align(x,y);
1831 if(!strcmp(align_gname(altaralign), u_gname())) {
1832 godvoice(altaralign, "How darest thou desecrate my altar!");
1833 (void) adjattrib(A_WIS, -1, FALSE);
1835 pline("A voice (could it be %s?) whispers:",
1836 align_gname(altaralign));
1837 verbalize("Thou shalt pay, infidel!");
1842 /* assumes isok() at one space away, but not necessarily at two */
1844 blocked_boulder(dx,dy)
1847 register struct obj *otmp;
1850 for(otmp = level.objects[u.ux+dx][u.uy+dy]; otmp; otmp = otmp->nexthere) {
1851 if(otmp->otyp == BOULDER)
1852 count += otmp->quan;
1856 case 0: return FALSE; /* no boulders--not blocked */
1857 case 1: break; /* possibly blocked depending on if it's pushable */
1858 default: return TRUE; /* >1 boulder--blocked after they push the top
1859 one; don't force them to push it first to find out */
1862 if (!isok(u.ux+2*dx, u.uy+2*dy))
1864 if (IS_ROCK(levl[u.ux+2*dx][u.uy+2*dy].typ))
1866 if (sobj_at(BOULDER, u.ux+2*dx, u.uy+2*dy))