1 /* NetHack 3.6 pray.c $NHDT-Date: 1450577672 2015/12/20 02:14:32 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.89 $ */
2 /* Copyright (c) Benson I. Margulies, Mike Stephenson, Steve Linhart, 1989. */
3 /* NetHack may be freely redistributed. See license for details. */
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
;
53 static int p_type
; /* (-1)-3: (-1)=really naughty, 3=really good */
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 */
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 */
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
))
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
;
117 /* 7 used to be the unconditional divisor */
118 switch (xlev_to_rank(u
.ulevel
)) { /* maps 1..30 into 0..8 */
122 break; /* explvl 1 to 5 */
126 break; /* explvl 6 to 13 */
130 break; /* explvl 14 to 21 */
134 break; /* explvl 22 to 29 */
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.
167 return TROUBLE_STONED
;
169 return TROUBLE_SLIMED
;
171 return TROUBLE_STRANGLED
;
172 if (u
.utrap
&& u
.utraptype
== TT_LAVA
)
177 return TROUBLE_STARVING
;
179 return TROUBLE_REGION
;
180 if (critically_low_hp(FALSE
))
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
++) {
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
)))
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 */
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
;
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
)
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
;
242 return TROUBLE_HUNGRY
;
244 return TROUBLE_STUNNED
;
245 if (HConfusion
& TIMEOUT
)
246 return TROUBLE_CONFUSED
;
247 if (HHallucination
& TIMEOUT
)
248 return TROUBLE_HALLUCINATION
;
252 /* select an item for TROUBLE_CURSED_ITEMS */
253 STATIC_OVL
struct obj
*
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
))
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 */
268 /* gloves come next, due to rings */
269 } else if (uarmg
&& uarmg
->cursed
) { /* gloves */
271 /* then shield due to two handed weapons and spells */
272 } else if (uarms
&& uarms
->cursed
) { /* shield */
274 /* then cloak due to body armor */
275 } else if (uarmc
&& uarmc
->cursed
) { /* cloak */
277 } else if (uarm
&& uarm
->cursed
) { /* suit */
279 } else if (uarmh
&& uarmh
->cursed
) { /* helmet */
281 } else if (uarmf
&& uarmf
->cursed
) { /* boots */
283 } else if (uarmu
&& uarmu
->cursed
) { /* shirt */
285 } else if (uamul
&& uamul
->cursed
) { /* amulet */
287 } else if (uleft
&& uleft
->cursed
) { /* left ring */
289 } else if (uright
&& uright
->cursed
) { /* right ring */
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 */
296 /* active secondary weapon even though it isn't welded */
297 } else if (uswapwep
&& uswapwep
->cursed
&& u
.twoweap
) {
299 /* all worn items ought to be handled by now */
301 for (otmp
= invent
; otmp
; otmp
= otmp
->nobj
) {
304 if (otmp
->otyp
== LOADSTONE
|| confers_luck(otmp
))
312 fix_worst_trouble(trouble
)
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";
323 make_stoned(0L, "You feel more limber.", 0, (char *) 0);
326 make_slimed(0L, "The slime disappears.");
328 case TROUBLE_STRANGLED
:
329 if (uamul
&& uamul
->otyp
== AMULET_OF_STRANGULATION
) {
330 Your("amulet vanishes!");
333 You("can breathe again.");
338 You("are back on solid ground.");
339 /* teleport should always succeed, but if not,
342 if (!safe_teleds(FALSE
))
345 case TROUBLE_STARVING
:
349 Your("%s feels content.", body_part(STOMACH
));
355 make_sick(0L, (char *) 0, FALSE
, SICK_ALL
);
358 /* stinking cloud, with hero vulnerable to HP loss */
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.");
372 if (u
.uhpmax
< u
.ulevel
* 5 + 11)
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
);
386 if ((otmp
= stuck_ring(uleft
, RIN_SUSTAIN_ABILITY
)) != 0) {
389 } else if ((otmp
= stuck_ring(uright
, RIN_SUSTAIN_ABILITY
))
398 case TROUBLE_STUCK_IN_WALL
:
399 Your("surroundings change.");
400 /* no control, but works on no-teleport levels */
401 (void) safe_teleds(FALSE
);
403 case TROUBLE_CURSED_LEVITATION
:
404 if (Cursed_obj(uarmf
, LEVITATION_BOOTS
)) {
406 } else if ((otmp
= stuck_ring(uleft
, RIN_LEVITATION
)) != 0) {
409 } else if ((otmp
= stuck_ring(uright
, RIN_LEVITATION
)) != 0) {
414 case TROUBLE_UNUSEABLE_HANDS
:
419 if (Upolyd
&& nohands(youmonst
.data
)) {
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 */
428 if (nohands(youmonst
.data
) || !freehand())
429 impossible("fix_worst_trouble: couldn't cure hands.");
431 case TROUBLE_CURSED_BLINDFOLD
:
434 case TROUBLE_LYCANTHROPE
:
439 case TROUBLE_PUNISHED
:
440 Your("chain disappears.");
441 if (u
.utrap
&& u
.utraptype
== TT_BURIEDBALL
)
442 buried_ball_to_freedom();
446 case TROUBLE_FUMBLING
:
447 if (Cursed_obj(uarmg
, GAUNTLETS_OF_FUMBLING
))
449 else if (Cursed_obj(uarmf
, FUMBLE_BOOTS
))
454 case TROUBLE_CURSED_ITEMS
:
455 otmp
= worst_cursed_item();
458 else if (otmp
== uleft
)
462 impossible("fix_worst_trouble: nothing to uncurse.");
465 if (!Blind
|| (otmp
== ublindf
&& Blindfolded_only
)) {
467 what
? what
: (const char *) Yobjnam2(otmp
, "softly glow"),
469 iflags
.last_msg
= PLNMSG_OBJ_GLOWS
;
470 otmp
->bknown
= !Hallucination
;
475 case TROUBLE_POISONED
:
476 /* override Fixed_abil; ignore items which confer that */
478 pline("There's a tiger in your tank.");
480 You_feel("in good health again.");
481 for (i
= 0; i
< A_MAX
; i
++) {
482 if (ABASE(i
) < AMAX(i
)) {
487 (void) encumber_msg();
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"));
496 make_blinded(0L, FALSE
);
499 case TROUBLE_WOUNDED_LEGS
:
502 case TROUBLE_STUNNED
:
503 make_stunned(0L, TRUE
);
505 case TROUBLE_CONFUSED
:
506 make_confused(0L, TRUE
);
508 case TROUBLE_HALLUCINATION
:
509 pline("Looks like you are back in Kansas.");
510 (void) make_hallucinated(0L, FALSE
, 0L);
513 otmp
= which_armor(u
.usteed
, W_SADDLE
);
515 pline("%s %s.", Yobjnam2(otmp
, "softly glow"), hcolor(NH_AMBER
));
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
526 * they reply 'Oh, but you forget the good God'. Apparently they conceive of
527 * the Deity as a Peeping Tom, whose omnipotence enables Him to see through
528 * bathroom walls, but who is foiled by bathrobes." --Bertrand Russell, 1943
529 * Divine wrath, dungeon walls, and armor follow the same principle.
532 god_zaps_you(resp_god
)
537 "Suddenly a bolt of lightning comes down at you from the heavens!");
538 pline("It strikes %s!", mon_nam(u
.ustuck
));
539 if (!resists_elec(u
.ustuck
)) {
540 pline("%s fries to a crisp!", Monnam(u
.ustuck
));
541 /* Yup, you get experience. It takes guts to successfully
542 * pull off this trick on your god, anyway.
544 xkilled(u
.ustuck
, 0);
546 pline("%s seems unaffected.", Monnam(u
.ustuck
));
548 pline("Suddenly, a bolt of lightning strikes you!");
550 shieldeff(u
.ux
, u
.uy
);
552 pline("For some reason you're unaffected.");
554 (void) ureflects("%s reflects from your %s.", "It");
555 } else if (Shock_resistance
) {
556 shieldeff(u
.ux
, u
.uy
);
557 pline("It seems not to affect you.");
559 fry_by_god(resp_god
, FALSE
);
562 pline("%s is not deterred...", align_gname(resp_god
));
564 pline("A wide-angle disintegration beam aimed at you hits %s!",
566 if (!resists_disint(u
.ustuck
)) {
567 pline("%s disintegrates into a pile of dust!", Monnam(u
.ustuck
));
568 xkilled(u
.ustuck
, 2); /* no corpse */
570 pline("%s seems unaffected.", Monnam(u
.ustuck
));
572 pline("A wide-angle disintegration beam hits you!");
574 /* disintegrate shield and body armor before disintegrating
575 * the impudent mortal, like black dragon breath -3.
577 if (uarms
&& !(EReflecting
& W_ARMS
)
578 && !(EDisint_resistance
& W_ARMS
))
579 (void) destroy_arm(uarms
);
580 if (uarmc
&& !(EReflecting
& W_ARMC
)
581 && !(EDisint_resistance
& W_ARMC
))
582 (void) destroy_arm(uarmc
);
583 if (uarm
&& !(EReflecting
& W_ARM
) && !(EDisint_resistance
& W_ARM
)
585 (void) destroy_arm(uarm
);
586 if (uarmu
&& !uarm
&& !uarmc
)
587 (void) destroy_arm(uarmu
);
588 if (!Disint_resistance
)
589 fry_by_god(resp_god
, TRUE
);
591 You("bask in its %s glow for a minute...", NH_BLACK
);
592 godvoice(resp_god
, "I believe it not!");
594 if (Is_astralevel(&u
.uz
) || Is_sanctum(&u
.uz
)) {
595 /* one more try for high altars */
596 verbalize("Thou cannot escape my wrath, mortal!");
597 summon_minion(resp_god
, FALSE
);
598 summon_minion(resp_god
, FALSE
);
599 summon_minion(resp_god
, FALSE
);
600 verbalize("Destroy %s, my servants!", uhim());
606 fry_by_god(resp_god
, via_disintegration
)
608 boolean via_disintegration
;
610 You("%s!", !via_disintegration
? "fry to a crisp"
611 : "disintegrate into a pile of dust");
612 killer
.format
= KILLED_BY
;
613 Sprintf(killer
.name
, "the wrath of %s", align_gname(resp_god
));
627 /* changed from tmp = u.ugangr + abs (u.uluck) -- rph */
628 /* added test for alignment diff -dlc */
629 if (resp_god
!= u
.ualign
.type
)
630 maxanger
= u
.ualign
.record
/ 2 + (Luck
> 0 ? -Luck
/ 3 : -Luck
);
632 maxanger
= 3 * u
.ugangr
+ ((Luck
> 0 || u
.ualign
.record
>= STRIDENT
)
636 maxanger
= 1; /* possible if bad align & good luck */
637 else if (maxanger
> 15)
638 maxanger
= 15; /* be reasonable */
640 switch (rn2(maxanger
)) {
643 You_feel("that %s is %s.", align_gname(resp_god
),
644 Hallucination
? "bummed" : "displeased");
648 godvoice(resp_god
, (char *) 0);
649 pline("\"Thou %s, %s.\"",
650 (ugod_is_angry() && resp_god
== u
.ualign
.type
)
651 ? "hast strayed from the path"
653 youmonst
.data
->mlet
== S_HUMAN
? "mortal" : "creature");
654 verbalize("Thou must relearn thy lessons!");
655 (void) adjattrib(A_WIS
, -1, FALSE
);
660 gods_angry(resp_god
);
661 punish((struct obj
*) 0);
663 } /* else fall thru */
666 gods_angry(resp_god
);
667 if (!Blind
&& !Antimagic
)
668 pline("%s glow surrounds you.", An(hcolor(NH_BLACK
)));
673 godvoice(resp_god
, (char *) 0);
674 verbalize("Thou durst %s me?",
675 (on_altar() && (a_align(u
.ux
, u
.uy
) != resp_god
))
678 pline("\"Then die, %s!\"",
679 youmonst
.data
->mlet
== S_HUMAN
? "mortal" : "creature");
680 summon_minion(resp_god
, FALSE
);
684 gods_angry(resp_god
);
685 god_zaps_you(resp_god
);
688 u
.ublesscnt
= rnz(300);
692 /* helper to print "str appears at your feet", or appropriate */
700 /* barrier between you and the floor */
701 pline("%s %s into %s %s.", str
, vtense(str
, "drop"),
702 s_suffix(mon_nam(u
.ustuck
)), mbodypart(u
.ustuck
, STOMACH
));
704 pline("%s %s %s your %s!", str
,
705 Blind
? "lands" : vtense(str
, "appear"),
706 Levitation
? "beneath" : "at", makeplural(body_part(FOOT
)));
714 boolean already_exists
, in_hand
;
717 #define ok_wep(o) ((o) && ((o)->oclass == WEAPON_CLASS || is_weptool(o)))
719 HSee_invisible
|= FROMOUTSIDE
;
720 HFire_resistance
|= FROMOUTSIDE
;
721 HCold_resistance
|= FROMOUTSIDE
;
722 HShock_resistance
|= FROMOUTSIDE
;
723 HSleep_resistance
|= FROMOUTSIDE
;
724 HPoison_resistance
|= FROMOUTSIDE
;
725 godvoice(u
.ualign
.type
, (char *) 0);
727 obj
= ok_wep(uwep
) ? uwep
: 0;
728 already_exists
= in_hand
= FALSE
; /* lint suppression */
729 switch (u
.ualign
.type
) {
731 u
.uevent
.uhand_of_elbereth
= 1;
732 verbalize("I crown thee... The Hand of Elbereth!");
735 u
.uevent
.uhand_of_elbereth
= 2;
736 in_hand
= (uwep
&& uwep
->oartifact
== ART_VORPAL_BLADE
);
738 exist_artifact(LONG_SWORD
, artiname(ART_VORPAL_BLADE
));
739 verbalize("Thou shalt be my Envoy of Balance!");
742 u
.uevent
.uhand_of_elbereth
= 3;
743 in_hand
= (uwep
&& uwep
->oartifact
== ART_STORMBRINGER
);
745 exist_artifact(RUNESWORD
, artiname(ART_STORMBRINGER
));
746 verbalize("Thou art chosen to %s for My Glory!",
747 already_exists
&& !in_hand
? "take lives" : "steal souls");
751 class_gift
= STRANGE_OBJECT
;
752 /* 3.3.[01] had this in the A_NEUTRAL case below,
753 preventing chaotic wizards from receiving a spellbook */
754 if (Role_if(PM_WIZARD
)
755 && (!uwep
|| (uwep
->oartifact
!= ART_VORPAL_BLADE
756 && uwep
->oartifact
!= ART_STORMBRINGER
))
757 && !carrying(SPE_FINGER_OF_DEATH
)) {
758 class_gift
= SPE_FINGER_OF_DEATH
;
760 obj
= mksobj(class_gift
, TRUE
, FALSE
);
763 at_your_feet("A spellbook");
766 /* when getting a new book for known spell, enhance
767 currently wielded weapon rather than the book */
768 for (sp_no
= 0; sp_no
< MAXSPELL
; sp_no
++)
769 if (spl_book
[sp_no
].sp_id
== class_gift
) {
771 obj
= uwep
; /* to be blessed,&c */
774 } else if (Role_if(PM_MONK
) && (!uwep
|| !uwep
->oartifact
)
775 && !carrying(SPE_RESTORE_ABILITY
)) {
776 /* monks rarely wield a weapon */
777 class_gift
= SPE_RESTORE_ABILITY
;
781 switch (u
.ualign
.type
) {
783 if (class_gift
!= STRANGE_OBJECT
) {
784 ; /* already got bonus above */
785 } else if (obj
&& obj
->otyp
== LONG_SWORD
&& !obj
->oartifact
) {
787 Your("sword shines brightly for a moment.");
788 obj
= oname(obj
, artiname(ART_EXCALIBUR
));
789 if (obj
&& obj
->oartifact
== ART_EXCALIBUR
)
792 /* acquire Excalibur's skill regardless of weapon or gift */
793 unrestrict_weapon_skill(P_LONG_SWORD
);
794 if (obj
&& obj
->oartifact
== ART_EXCALIBUR
)
795 discover_artifact(ART_EXCALIBUR
);
798 if (class_gift
!= STRANGE_OBJECT
) {
799 ; /* already got bonus above */
800 } else if (obj
&& in_hand
) {
801 Your("%s goes snicker-snack!", xname(obj
));
803 } else if (!already_exists
) {
804 obj
= mksobj(LONG_SWORD
, FALSE
, FALSE
);
805 obj
= oname(obj
, artiname(ART_VORPAL_BLADE
));
807 at_your_feet("A sword");
811 /* acquire Vorpal Blade's skill regardless of weapon or gift */
812 unrestrict_weapon_skill(P_LONG_SWORD
);
813 if (obj
&& obj
->oartifact
== ART_VORPAL_BLADE
)
814 discover_artifact(ART_VORPAL_BLADE
);
817 char swordbuf
[BUFSZ
];
819 Sprintf(swordbuf
, "%s sword", hcolor(NH_BLACK
));
820 if (class_gift
!= STRANGE_OBJECT
) {
821 ; /* already got bonus above */
822 } else if (obj
&& in_hand
) {
823 Your("%s hums ominously!", swordbuf
);
825 } else if (!already_exists
) {
826 obj
= mksobj(RUNESWORD
, FALSE
, FALSE
);
827 obj
= oname(obj
, artiname(ART_STORMBRINGER
));
829 at_your_feet(An(swordbuf
));
833 /* acquire Stormbringer's skill regardless of weapon or gift */
834 unrestrict_weapon_skill(P_BROAD_SWORD
);
835 if (obj
&& obj
->oartifact
== ART_STORMBRINGER
)
836 discover_artifact(ART_STORMBRINGER
);
844 /* enhance weapon regardless of alignment or artifact status */
847 obj
->oeroded
= obj
->oeroded2
= 0;
848 obj
->oerodeproof
= TRUE
;
849 obj
->bknown
= obj
->rknown
= TRUE
;
852 /* acquire skill in this weapon */
853 unrestrict_weapon_skill(weapon_type(obj
));
854 } else if (class_gift
== STRANGE_OBJECT
) {
855 /* opportunity knocked, but there was nobody home... */
856 You_feel("unworthy.");
860 /* lastly, confer an extra skill slot/credit beyond the
861 up-to-29 you can get from gaining experience levels */
870 /* don't use p_trouble, worst trouble may get fixed while praying */
871 int trouble
= in_trouble(); /* what's your worst difficulty? */
872 int pat_on_head
= 0, kick_on_butt
;
874 You_feel("that %s is %s.", align_gname(g_align
),
875 (u
.ualign
.record
>= DEVOUT
)
876 ? Hallucination
? "pleased as punch" : "well-pleased"
877 : (u
.ualign
.record
>= STRIDENT
)
878 ? Hallucination
? "ticklish" : "pleased"
879 : Hallucination
? "full" : "satisfied");
882 if (on_altar() && p_aligntyp
!= u
.ualign
.type
) {
885 } else if (u
.ualign
.record
< 2 && trouble
<= 0)
889 * Depending on your luck & align level, the god you prayed to will:
890 * - fix your worst problem if it's major;
891 * - fix all your major problems;
892 * - fix your worst problem if it's minor;
893 * - fix all of your problems;
894 * - do you a gratuitous favor.
896 * If you make it to the the last category, you roll randomly again
897 * to see what they do for you.
899 * If your luck is at least 0, then you are guaranteed rescued from
900 * your worst major problem.
902 if (!trouble
&& u
.ualign
.record
>= DEVOUT
) {
903 /* if hero was in trouble, but got better, no special favor */
907 int action
, prayer_luck
;
910 /* Negative luck is normally impossible here (can_pray() forces
911 prayer failure in that situation), but it's possible for
912 Luck to drop during the period of prayer occupation and
913 become negative by the time we get here. [Reported case
914 was lawful character whose stinking cloud caused a delayed
915 killing of a peaceful human, triggering the "murderer"
916 penalty while successful prayer was in progress. It could
917 also happen due to inconvenient timing on Friday 13th, but
918 the magnitude there (-1) isn't big enough to cause trouble.]
919 We don't bother remembering start-of-prayer luck, just make
920 sure it's at least -1 so that Luck+2 is big enough to avoid
921 a divide by zero crash when generating a random number. */
922 prayer_luck
= max(Luck
, -1); /* => (prayer_luck + 2 > 0) */
923 action
= rn1(prayer_luck
+ (on_altar() ? 3 + on_shrine() : 2), 1);
925 action
= min(action
, 3);
926 if (u
.ualign
.record
< STRIDENT
)
927 action
= (u
.ualign
.record
> 0 || !rnl(2)) ? 1 : 0;
929 switch (min(action
, 5)) {
934 fix_worst_trouble(trouble
);
935 while ((trouble
= in_trouble()) != 0);
939 fix_worst_trouble(trouble
);
941 /* arbitrary number of tries */
942 while ((trouble
= in_trouble()) > 0 && (++tryct
< 10))
943 fix_worst_trouble(trouble
);
948 fix_worst_trouble(trouble
);
950 break; /* your god blows you off, too bad */
954 /* note: can't get pat_on_head unless all troubles have just been
955 fixed or there were no troubles to begin with; hallucination
956 won't be in effect so special handling for it is superfluous */
958 switch (rn2((Luck
+ 6) >> 1)) {
962 if (uwep
&& (welded(uwep
) || uwep
->oclass
== WEAPON_CLASS
963 || is_weptool(uwep
))) {
964 char repair_buf
[BUFSZ
];
967 if (uwep
->oeroded
|| uwep
->oeroded2
)
968 Sprintf(repair_buf
, " and %s now as good as new",
969 otense(uwep
, "are"));
973 pline("%s %s%s.", Yobjnam2(uwep
, "softly glow"),
974 hcolor(NH_AMBER
), repair_buf
);
975 iflags
.last_msg
= PLNMSG_OBJ_GLOWS
;
977 You_feel("the power of %s over %s.", u_gname(),
982 } else if (!uwep
->blessed
) {
984 pline("%s with %s aura%s.",
985 Yobjnam2(uwep
, "softly glow"),
986 an(hcolor(NH_LIGHT_BLUE
)), repair_buf
);
987 iflags
.last_msg
= PLNMSG_OBJ_GLOWS
;
989 You_feel("the blessing of %s over %s.", u_gname(),
996 /* fix any rust/burn/rot damage, but don't protect
997 against future damage */
998 if (uwep
->oeroded
|| uwep
->oeroded2
) {
999 uwep
->oeroded
= uwep
->oeroded2
= 0;
1000 /* only give this message if we didn't just bless
1001 or uncurse (which has already given a message) */
1003 pline("%s as good as new!",
1004 Yobjnam2(uwep
, Blind
? "feel" : "look"));
1010 /* takes 2 hints to get the music to enter the stronghold;
1011 skip if you've solved it via mastermind or destroyed the
1012 drawbridge (both set uopened_dbridge) or if you've already
1013 travelled past the Valley of the Dead (gehennom_entered) */
1014 if (!u
.uevent
.uopened_dbridge
&& !u
.uevent
.gehennom_entered
) {
1015 if (u
.uevent
.uheard_tune
< 1) {
1016 godvoice(g_align
, (char *) 0);
1017 verbalize("Hark, %s!", youmonst
.data
->mlet
== S_HUMAN
1021 "To enter the castle, thou must play the right tune!");
1022 u
.uevent
.uheard_tune
++;
1024 } else if (u
.uevent
.uheard_tune
< 2) {
1025 You_hear("a divine music...");
1026 pline("It sounds like: \"%s\".", tune
);
1027 u
.uevent
.uheard_tune
++;
1031 /* Otherwise, falls into next case */
1034 You("are surrounded by %s glow.", an(hcolor(NH_GOLDEN
)));
1035 /* if any levels have been lost (and not yet regained),
1036 treat this effect like blessed full healing */
1037 if (u
.ulevel
< u
.ulevelmax
) {
1038 u
.ulevelmax
-= 1; /* see potion.c */
1048 ABASE(A_STR
) = AMAX(A_STR
);
1049 if (u
.uhunger
< 900)
1051 /* luck couldn't have been negative at start of prayer because
1052 the prayer would have failed, but might have been decremented
1053 due to a timed event (delayed death of peaceful monster hit
1054 by hero-created stinking cloud) during the praying interval */
1057 /* superfluous; if hero was blinded we'd be handling trouble
1058 rather than issuing a pat-on-head */
1060 make_blinded(0L, TRUE
);
1064 register struct obj
*otmp
;
1068 You_feel("the power of %s.", u_gname());
1070 You("are surrounded by %s aura.", an(hcolor(NH_LIGHT_BLUE
)));
1071 for (otmp
= invent
; otmp
; otmp
= otmp
->nobj
) {
1074 pline("%s %s.", Yobjnam2(otmp
, "softly glow"),
1076 iflags
.last_msg
= PLNMSG_OBJ_GLOWS
;
1077 otmp
->bknown
= TRUE
;
1088 static NEARDATA
const char msg
[] =
1089 "\"and thus I grant thee the gift of %s!\"";
1091 godvoice(u
.ualign
.type
,
1092 "Thou hast pleased me with thy progress,");
1093 if (!(HTelepat
& INTRINSIC
)) {
1094 HTelepat
|= FROMOUTSIDE
;
1095 pline(msg
, "Telepathy");
1098 } else if (!(HFast
& INTRINSIC
)) {
1099 HFast
|= FROMOUTSIDE
;
1100 pline(msg
, "Speed");
1101 } else if (!(HStealth
& INTRINSIC
)) {
1102 HStealth
|= FROMOUTSIDE
;
1103 pline(msg
, "Stealth");
1105 if (!(HProtection
& INTRINSIC
)) {
1106 HProtection
|= FROMOUTSIDE
;
1108 u
.ublessed
= rn1(3, 2);
1111 pline(msg
, "my protection");
1113 verbalize("Use it wisely in my name!");
1118 if (u
.ualign
.record
>= PIOUS
&& !u
.uevent
.uhand_of_elbereth
) {
1121 } /* else FALLTHRU */
1124 int sp_no
, trycnt
= u
.ulevel
+ 1;
1126 /* not yet known spells given preference over already known ones
1128 /* Also, try to grant a spell for which there is a skill slot */
1129 otmp
= mkobj(SPBOOK_CLASS
, TRUE
);
1130 while (--trycnt
> 0) {
1131 if (otmp
->otyp
!= SPE_BLANK_PAPER
) {
1132 for (sp_no
= 0; sp_no
< MAXSPELL
; sp_no
++)
1133 if (spl_book
[sp_no
].sp_id
== otmp
->otyp
)
1135 if (sp_no
== MAXSPELL
1136 && !P_RESTRICTED(spell_skilltype(otmp
->otyp
)))
1137 break; /* usable, but not yet known */
1139 if (!objects
[SPE_BLANK_PAPER
].oc_name_known
1140 || carrying(MAGIC_MARKER
))
1143 otmp
->otyp
= rnd_class(bases
[SPBOOK_CLASS
], SPE_BLANK_PAPER
);
1146 at_your_feet("A spellbook");
1147 place_object(otmp
, u
.ux
, u
.uy
);
1152 impossible("Confused deity!");
1156 u
.ublesscnt
= rnz(350);
1157 kick_on_butt
= u
.uevent
.udemigod
? 1 : 0;
1158 if (u
.uevent
.uhand_of_elbereth
)
1161 u
.ublesscnt
+= kick_on_butt
* rnz(1000);
1166 /* either blesses or curses water on the altar,
1167 * returns true if it found any water here.
1170 water_prayer(bless_water
)
1171 boolean bless_water
;
1173 register struct obj
*otmp
;
1174 register long changed
= 0;
1175 boolean other
= FALSE
, bc_known
= !(Blind
|| Hallucination
);
1177 for (otmp
= level
.objects
[u
.ux
][u
.uy
]; otmp
; otmp
= otmp
->nexthere
) {
1178 /* turn water into (un)holy water */
1179 if (otmp
->otyp
== POT_WATER
1180 && (bless_water
? !otmp
->blessed
: !otmp
->cursed
)) {
1181 otmp
->blessed
= bless_water
;
1182 otmp
->cursed
= !bless_water
;
1183 otmp
->bknown
= bc_known
;
1184 changed
+= otmp
->quan
;
1185 } else if (otmp
->oclass
== POTION_CLASS
)
1188 if (!Blind
&& changed
) {
1189 pline("%s potion%s on the altar glow%s %s for a moment.",
1190 ((other
&& changed
> 1L) ? "Some of the"
1191 : (other
? "One of the" : "The")),
1192 ((other
|| changed
> 1L) ? "s" : ""), (changed
> 1L ? "" : "s"),
1193 (bless_water
? hcolor(NH_LIGHT_BLUE
) : hcolor(NH_BLACK
)));
1195 return (boolean
) (changed
> 0L);
1199 godvoice(g_align
, words
)
1203 const char *quot
= "";
1210 pline_The("voice of %s %s: %s%s%s", align_gname(g_align
),
1211 godvoices
[rn2(SIZE(godvoices
))], quot
, words
, quot
);
1218 godvoice(g_align
, "Thou hast angered me.");
1221 /* The g_align god is upset with you. */
1226 if (g_align
== u
.ualign
.type
)
1234 consume_offering(otmp
)
1235 register struct obj
*otmp
;
1240 Your("sacrifice sprouts wings and a propeller and roars away!");
1243 Your("sacrifice puffs up, swelling bigger and bigger, and pops!");
1247 "sacrifice collapses into a cloud of dancing particles and fades away!");
1250 else if (Blind
&& u
.ualign
.type
== A_LAWFUL
)
1251 Your("sacrifice disappears!");
1253 Your("sacrifice is consumed in a %s!",
1254 u
.ualign
.type
== A_LAWFUL
? "flash of light" : "burst of flame");
1259 exercise(A_WIS
, TRUE
);
1265 static NEARDATA
const char cloud_of_smoke
[] =
1266 "A cloud of %s smoke surrounds you...";
1267 register struct obj
*otmp
;
1270 aligntyp altaralign
= a_align(u
.ux
, u
.uy
);
1272 if (!on_altar() || u
.uswallow
) {
1273 You("are not standing on an altar.");
1276 highaltar
= ((Is_astralevel(&u
.uz
) || Is_sanctum(&u
.uz
))
1277 && (levl
[u
.ux
][u
.uy
].altarmask
& AM_SHRINE
));
1279 otmp
= floorfood("sacrifice", 1);
1283 * Was based on nutritional value and aging behavior (< 50 moves).
1284 * Sacrificing a food ration got you max luck instantly, making the
1285 * gods as easy to please as an angry dog!
1287 * Now only accepts corpses, based on the game's evaluation of their
1288 * toughness. Human and pet sacrifice, as well as sacrificing unicorns
1289 * of your alignment, is strongly discouraged.
1291 #define MAXVALUE 24 /* Highest corpse value (besides Wiz) */
1293 if (otmp
->otyp
== CORPSE
) {
1294 register struct permonst
*ptr
= &mons
[otmp
->corpsenm
];
1296 extern const int monstr
[];
1299 u
.uconduct
.gnostic
++;
1301 /* you're handling this corpse, even if it was killed upon the altar
1303 feel_cockatrice(otmp
, TRUE
);
1304 if (rider_corpse_revival(otmp
, FALSE
))
1307 if (otmp
->corpsenm
== PM_ACID_BLOB
1308 || (monstermoves
<= peek_at_iced_corpse_age(otmp
) + 50)) {
1309 value
= monstr
[otmp
->corpsenm
] + 1;
1311 value
= eaten_stat(value
, otmp
);
1314 if (your_race(ptr
)) {
1315 if (is_demon(youmonst
.data
)) {
1316 You("find the idea very satisfying.");
1317 exercise(A_WIS
, TRUE
);
1318 } else if (u
.ualign
.type
!= A_CHAOTIC
) {
1319 pline("You'll regret this infamous offense!");
1320 exercise(A_WIS
, FALSE
);
1324 && (altaralign
!= A_CHAOTIC
|| u
.ualign
.type
!= A_CHAOTIC
)) {
1325 goto desecrate_high_altar
;
1326 } else if (altaralign
!= A_CHAOTIC
&& altaralign
!= A_NONE
) {
1327 /* curse the lawful/neutral altar */
1328 pline_The("altar is stained with %s blood.", urace
.adj
);
1329 levl
[u
.ux
][u
.uy
].altarmask
= AM_CHAOTIC
;
1333 const char *demonless_msg
;
1335 /* Human sacrifice on a chaotic or unaligned altar */
1336 /* is equivalent to demon summoning */
1337 if (altaralign
== A_CHAOTIC
&& u
.ualign
.type
!= A_CHAOTIC
) {
1339 "The blood floods the altar, which vanishes in %s cloud!",
1340 an(hcolor(NH_BLACK
)));
1341 levl
[u
.ux
][u
.uy
].typ
= ROOM
;
1342 levl
[u
.ux
][u
.uy
].altarmask
= 0;
1345 demonless_msg
= "cloud dissipates";
1347 /* either you're chaotic or altar is Moloch's or both */
1348 pline_The("blood covers the altar!");
1349 change_luck(altaralign
== A_NONE
? -2 : 2);
1350 demonless_msg
= "blood coagulates";
1352 if ((pm
= dlord(altaralign
)) != NON_PM
1353 && (dmon
= makemon(&mons
[pm
], u
.ux
, u
.uy
, NO_MM_FLAGS
))
1357 Strcpy(dbuf
, a_monnam(dmon
));
1358 if (!strcmpi(dbuf
, "it"))
1359 Strcpy(dbuf
, "something dreadful");
1361 dmon
->mstrategy
&= ~STRAT_APPEARMSG
;
1362 You("have summoned %s!", dbuf
);
1363 if (sgn(u
.ualign
.type
) == sgn(dmon
->data
->maligntyp
))
1364 dmon
->mpeaceful
= TRUE
;
1365 You("are terrified, and unable to move.");
1367 multi_reason
= "being terrified of a demon";
1370 pline_The("%s.", demonless_msg
);
1373 if (u
.ualign
.type
!= A_CHAOTIC
) {
1376 (void) adjattrib(A_WIS
, -1, TRUE
);
1378 angrygods(u
.ualign
.type
);
1387 } else if (has_omonst(otmp
)
1388 && (mtmp
= get_mtraits(otmp
, FALSE
)) != 0
1390 /* mtmp is a temporary pointer to a tame monster's attributes,
1391 * not a real monster */
1392 pline("So this is how you repay loyalty?");
1395 HAggravate_monster
|= FROMOUTSIDE
;
1396 } else if (is_undead(ptr
)) { /* Not demons--no demon corpses */
1397 if (u
.ualign
.type
!= A_CHAOTIC
)
1399 } else if (is_unicorn(ptr
)) {
1400 int unicalign
= sgn(ptr
->maligntyp
);
1402 if (unicalign
== altaralign
) {
1403 /* When same as altar, always a very bad action.
1405 pline("Such an action is an insult to %s!",
1406 (unicalign
== A_CHAOTIC
) ? "chaos"
1407 : unicalign
? "law" : "balance");
1408 (void) adjattrib(A_WIS
, -1, TRUE
);
1410 } else if (u
.ualign
.type
== altaralign
) {
1411 /* When different from altar, and altar is same as yours,
1412 * it's a very good action.
1414 if (u
.ualign
.record
< ALIGNLIM
)
1415 You_feel("appropriately %s.", align_str(u
.ualign
.type
));
1417 You_feel("you are thoroughly on the right path.");
1420 } else if (unicalign
== u
.ualign
.type
) {
1421 /* When sacrificing unicorn of your alignment to altar not of
1422 * your alignment, your god gets angry and it's a conversion.
1424 u
.ualign
.record
= -1;
1427 /* Otherwise, unicorn's alignment is different from yours
1428 * and different from the altar's. It's an ordinary (well,
1429 * with a bonus) sacrifice on a cross-aligned altar.
1436 if (otmp
->otyp
== AMULET_OF_YENDOR
) {
1439 if (altaralign
== A_NONE
&& Inhell
)
1440 /* hero has left Moloch's Sanctum so is in the process
1441 of getting away with the Amulet (outside of Gehennom,
1442 fall through to the "ashamed" feedback) */
1448 /* if on track, give a big hint */
1449 : (altaralign
== u
.ualign
.type
)
1450 ? "an urge to return to the surface"
1451 /* else headed towards celestial disgrace */
1455 /* The final Test. Did you win? */
1458 u
.uevent
.ascended
= 1;
1460 useup(otmp
); /* well, it's gone now */
1463 You("offer the Amulet of Yendor to %s...", a_gname());
1464 if (altaralign
== A_NONE
) {
1465 /* Moloch's high altar */
1466 if (u
.ualign
.record
> -99)
1467 u
.ualign
.record
= -99;
1468 /*[apparently shrug/snarl can be sensed without being seen]*/
1469 pline("%s shrugs and retains dominion over %s,", Moloch
,
1471 pline("then mercilessly snuffs out your life.");
1472 Sprintf(killer
.name
, "%s indifference", s_suffix(Moloch
));
1473 killer
.format
= KILLED_BY
;
1475 /* life-saved (or declined to die in wizard/explore mode) */
1476 pline("%s snarls and tries again...", Moloch
);
1477 fry_by_god(A_NONE
, TRUE
); /* wrath of Moloch */
1478 /* declined to die in wizard or explore mode */
1479 pline(cloud_of_smoke
, hcolor(NH_BLACK
));
1481 } else if (u
.ualign
.type
!= altaralign
) {
1482 /* And the opposing team picks you up and
1483 carries you off on their shoulders */
1485 pline("%s accepts your gift, and gains dominion over %s...",
1486 a_gname(), u_gname());
1487 pline("%s is enraged...", u_gname());
1488 pline("Fortunately, %s permits you to live...", a_gname());
1489 pline(cloud_of_smoke
, hcolor(NH_ORANGE
));
1491 } else { /* super big win */
1493 u
.uachieve
.ascended
= 1;
1495 "An invisible choir sings, and you are bathed in radiance...");
1496 godvoice(altaralign
, "Congratulations, mortal!");
1497 display_nhwindow(WIN_MESSAGE
, FALSE
);
1499 "In return for thy service, I grant thee the gift of Immortality!");
1500 You("ascend to the status of Demigod%s...",
1501 flags
.female
? "dess" : "");
1507 if (otmp
->otyp
== FAKE_AMULET_OF_YENDOR
) {
1508 if (!highaltar
&& !otmp
->known
)
1510 You_hear("a nearby thunderclap.");
1512 You("realize you have made a %s.",
1513 Hallucination
? "boo-boo" : "mistake");
1518 /* don't you dare try to fool the gods */
1520 pline("Oh, no."); /* didn't hear thunderclap */
1529 pline1(nothing_happens
);
1533 if (altaralign
!= u
.ualign
.type
&& highaltar
) {
1534 desecrate_high_altar
:
1536 * REAL BAD NEWS!!! High altars cannot be converted. Even an attempt
1537 * gets the god who owns it truly pissed off.
1539 You_feel("the air around you grow charged...");
1540 pline("Suddenly, you realize that %s has noticed you...", a_gname());
1541 godvoice(altaralign
,
1542 "So, mortal! You dare desecrate my High Temple!");
1543 /* Throw everything we have at the player */
1544 god_zaps_you(altaralign
);
1546 < 0) { /* I don't think the gods are gonna like this... */
1547 gods_upset(altaralign
);
1549 int saved_anger
= u
.ugangr
;
1550 int saved_cnt
= u
.ublesscnt
;
1551 int saved_luck
= u
.uluck
;
1553 /* Sacrificing at an altar of a different alignment */
1554 if (u
.ualign
.type
!= altaralign
) {
1555 /* Is this a conversion ? */
1556 /* An unaligned altar in Gehennom will always elicit rejection. */
1557 if (ugod_is_angry() || (altaralign
== A_NONE
&& Inhell
)) {
1558 if (u
.ualignbase
[A_CURRENT
] == u
.ualignbase
[A_ORIGINAL
]
1559 && altaralign
!= A_NONE
) {
1560 You("have a strong feeling that %s is angry...",
1562 consume_offering(otmp
);
1563 pline("%s accepts your allegiance.", a_gname());
1565 uchangealign(altaralign
, 0);
1566 /* Beware, Conversion is costly */
1572 pline("%s rejects your sacrifice!", a_gname());
1573 godvoice(altaralign
, "Suffer, infidel!");
1575 (void) adjattrib(A_WIS
, -2, TRUE
);
1577 angrygods(u
.ualign
.type
);
1581 consume_offering(otmp
);
1582 You("sense a conflict between %s and %s.", u_gname(),
1584 if (rn2(8 + u
.ulevel
) > 5) {
1586 You_feel("the power of %s increase.", u_gname());
1587 exercise(A_WIS
, TRUE
);
1589 /* Yes, this is supposed to be &=, not |= */
1590 levl
[u
.ux
][u
.uy
].altarmask
&= AM_SHRINE
;
1591 /* the following accommodates stupid compilers */
1592 levl
[u
.ux
][u
.uy
].altarmask
=
1593 levl
[u
.ux
][u
.uy
].altarmask
1594 | (Align2amask(u
.ualign
.type
));
1596 pline_The("altar glows %s.",
1597 hcolor((u
.ualign
.type
== A_LAWFUL
)
1601 : (const char *) "gray"));
1603 if (rnl(u
.ulevel
) > 6 && u
.ualign
.record
> 0
1604 && rnd(u
.ualign
.record
) > (3 * ALIGNLIM
) / 4)
1605 summon_minion(altaralign
, TRUE
);
1606 /* anger priest; test handles bones files */
1607 if ((pri
= findpriest(temple_occupied(u
.urooms
)))
1608 && !p_coaligned(pri
))
1611 pline("Unluckily, you feel the power of %s decrease.",
1614 exercise(A_WIS
, FALSE
);
1615 if (rnl(u
.ulevel
) > 6 && u
.ualign
.record
> 0
1616 && rnd(u
.ualign
.record
) > (7 * ALIGNLIM
) / 8)
1617 summon_minion(altaralign
, TRUE
);
1623 consume_offering(otmp
);
1624 /* OK, you get brownie points. */
1626 u
.ugangr
-= ((value
* (u
.ualign
.type
== A_CHAOTIC
? 2 : 3))
1630 if (u
.ugangr
!= saved_anger
) {
1632 pline("%s seems %s.", u_gname(),
1633 Hallucination
? "groovy" : "slightly mollified");
1635 if ((int) u
.uluck
< 0)
1638 pline("%s seems %s.", u_gname(),
1639 Hallucination
? "cosmic (not a new fact)"
1642 if ((int) u
.uluck
< 0)
1645 } else { /* not satisfied yet */
1647 pline_The("gods seem tall.");
1649 You("have a feeling of inadequacy.");
1651 } else if (ugod_is_angry()) {
1652 if (value
> MAXVALUE
)
1654 if (value
> -u
.ualign
.record
)
1655 value
= -u
.ualign
.record
;
1657 You_feel("partially absolved.");
1658 } else if (u
.ublesscnt
> 0) {
1659 u
.ublesscnt
-= ((value
* (u
.ualign
.type
== A_CHAOTIC
? 500 : 300))
1661 if (u
.ublesscnt
< 0)
1663 if (u
.ublesscnt
!= saved_cnt
) {
1666 You("realize that the gods are not like you and I.");
1668 You("have a hopeful feeling.");
1669 if ((int) u
.uluck
< 0)
1673 pline("Overall, there is a smell of fried onions.");
1675 You("have a feeling of reconciliation.");
1676 if ((int) u
.uluck
< 0)
1681 int nartifacts
= nartifact_exist();
1683 /* you were already in pretty good standing */
1684 /* The player can gain an artifact */
1685 /* The chance goes down as the number of artifacts goes up */
1686 if (u
.ulevel
> 2 && u
.uluck
>= 0
1687 && !rn2(10 + (2 * u
.ugifts
* nartifacts
))) {
1688 otmp
= mk_artifact((struct obj
*) 0, a_align(u
.ux
, u
.uy
));
1694 otmp
->oerodeproof
= TRUE
;
1695 at_your_feet("An object");
1697 godvoice(u
.ualign
.type
, "Use my gift wisely!");
1699 u
.ublesscnt
= rnz(300 + (50 * nartifacts
));
1700 exercise(A_WIS
, TRUE
);
1701 /* make sure we can use this weapon */
1702 unrestrict_weapon_skill(weapon_type(otmp
));
1703 if (!Hallucination
&& !Blind
) {
1705 makeknown(otmp
->otyp
);
1706 discover_artifact(otmp
->oartifact
);
1711 change_luck((value
* LUCKMAX
) / (MAXVALUE
* 2));
1712 if ((int) u
.uluck
< 0)
1714 if (u
.uluck
!= saved_luck
) {
1716 You("think %s brushed your %s.", something
,
1720 ? "see crabgrass at your %s. A funny thing in a dungeon."
1721 : "glimpse a four-leaf clover at your %s.",
1722 makeplural(body_part(FOOT
)));
1729 /* determine prayer results in advance; also used for enlightenment */
1732 boolean praying
; /* false means no messages should be given */
1736 p_aligntyp
= on_altar() ? a_align(u
.ux
, u
.uy
) : u
.ualign
.type
;
1737 p_trouble
= in_trouble();
1739 if (is_demon(youmonst
.data
) && (p_aligntyp
!= A_CHAOTIC
)) {
1741 pline_The("very idea of praying to a %s god is repugnant to you.",
1742 p_aligntyp
? "lawful" : "neutral");
1747 You("begin praying to %s.", align_gname(p_aligntyp
));
1749 if (u
.ualign
.type
&& u
.ualign
.type
== -p_aligntyp
)
1750 alignment
= -u
.ualign
.record
; /* Opposite alignment altar */
1751 else if (u
.ualign
.type
!= p_aligntyp
)
1752 alignment
= u
.ualign
.record
/ 2; /* Different alignment altar */
1754 alignment
= u
.ualign
.record
;
1756 if ((p_trouble
> 0) ? (u
.ublesscnt
> 200) /* big trouble */
1757 : (p_trouble
< 0) ? (u
.ublesscnt
> 100) /* minor difficulties */
1758 : (u
.ublesscnt
> 0)) /* not in trouble */
1759 p_type
= 0; /* too soon... */
1760 else if ((int) Luck
< 0 || u
.ugangr
|| alignment
< 0)
1761 p_type
= 1; /* too naughty... */
1762 else /* alignment >= 0 */ {
1763 if (on_altar() && u
.ualign
.type
!= p_aligntyp
)
1769 if (is_undead(youmonst
.data
) && !Inhell
1770 && (p_aligntyp
== A_LAWFUL
|| (p_aligntyp
== A_NEUTRAL
&& !rn2(10))))
1772 /* Note: when !praying, the random factor for neutrals makes the
1773 return value a non-deterministic approximation for enlightenment.
1774 This case should be uncommon enough to live with... */
1776 return !praying
? (boolean
) (p_type
== 3 && !Inhell
) : TRUE
;
1779 /* #pray commmand */
1783 /* Confirm accidental slips of Alt-P */
1784 if (ParanoidPray
&& yn("Are you sure you want to pray?") != 'y')
1787 u
.uconduct
.gnostic
++;
1789 /* set up p_type and p_alignment */
1790 if (!can_pray(TRUE
))
1793 if (wizard
&& p_type
>= 0) {
1794 if (yn("Force the gods to be pleased?") == 'y') {
1798 if (u
.ualign
.record
<= 0)
1799 u
.ualign
.record
= 1;
1806 multi_reason
= "praying";
1807 nomovemsg
= "You finish your prayer.";
1808 afternmv
= prayer_done
;
1810 if (p_type
== 3 && !Inhell
) {
1811 /* if you've been true to your god you can't die while you pray */
1813 You("are surrounded by a shimmering light.");
1814 u
.uinvulnerable
= TRUE
;
1821 prayer_done() /* M. Stephenson (1.0.3b) */
1823 aligntyp alignment
= p_aligntyp
;
1825 u
.uinvulnerable
= FALSE
;
1828 (alignment
== A_LAWFUL
)
1829 ? "Vile creature, thou durst call upon me?"
1830 : "Walk no more, perversion of nature!");
1831 You_feel("like you are falling apart.");
1832 /* KMH -- Gods have mastery over unchanging */
1834 /* no Half_physical_damage adjustment here */
1835 losehp(rnd(20), "residual undead turning effect", KILLED_BY_AN
);
1836 exercise(A_CON
, FALSE
);
1840 pline("Since you are in Gehennom, %s won't help you.",
1841 align_gname(alignment
));
1842 /* haltingly aligned is least likely to anger */
1843 if (u
.ualign
.record
<= 0 || rnl(u
.ualign
.record
))
1844 angrygods(u
.ualign
.type
);
1849 if (on_altar() && u
.ualign
.type
!= alignment
)
1850 (void) water_prayer(FALSE
);
1851 u
.ublesscnt
+= rnz(250);
1853 gods_upset(u
.ualign
.type
);
1854 } else if (p_type
== 1) {
1855 if (on_altar() && u
.ualign
.type
!= alignment
)
1856 (void) water_prayer(FALSE
);
1857 angrygods(u
.ualign
.type
); /* naughty */
1858 } else if (p_type
== 2) {
1859 if (water_prayer(FALSE
)) {
1860 /* attempted water prayer on a non-coaligned altar */
1861 u
.ublesscnt
+= rnz(250);
1863 gods_upset(u
.ualign
.type
);
1869 (void) water_prayer(TRUE
);
1870 pleased(alignment
); /* nice */
1879 /* Knights & Priest(esse)s only please */
1880 struct monst
*mtmp
, *mtmp2
;
1881 int once
, range
, xlev
;
1883 if (!Role_if(PM_PRIEST
) && !Role_if(PM_KNIGHT
)) {
1884 /* Try to use the "turn undead" spell.
1886 * This used to be based on whether hero knows the name of the
1887 * turn undead spellbook, but it's possible to know--and be able
1888 * to cast--the spell while having lost the book ID to amnesia.
1889 * (It also used to tell spelleffects() to cast at self?)
1893 for (sp_no
= 0; sp_no
< MAXSPELL
; ++sp_no
) {
1894 if (spl_book
[sp_no
].sp_id
== NO_SPELL
)
1896 else if (spl_book
[sp_no
].sp_id
== SPE_TURN_UNDEAD
)
1897 return spelleffects(sp_no
, FALSE
);
1899 You("don't know how to turn undead!");
1902 u
.uconduct
.gnostic
++;
1904 if ((u
.ualign
.type
!= A_CHAOTIC
1905 && (is_demon(youmonst
.data
) || is_undead(youmonst
.data
)))
1906 || u
.ugangr
> 6) { /* "Die, mortal!" */
1907 pline("For some reason, %s seems to ignore you.", u_gname());
1909 exercise(A_WIS
, FALSE
);
1913 pline("Since you are in Gehennom, %s won't help you.", u_gname());
1917 pline("Calling upon %s, you chant an arcane formula.", u_gname());
1918 exercise(A_WIS
, TRUE
);
1920 /* note: does not perform unturn_dead() on victims' inventories */
1921 range
= BOLT_LIM
+ (u
.ulevel
/ 5); /* 5 to 11 */
1924 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp2
) {
1927 if (DEADMONSTER(mtmp
))
1929 if (!cansee(mtmp
->mx
, mtmp
->my
) || distu(mtmp
->mx
, mtmp
->my
) > range
)
1932 if (!mtmp
->mpeaceful
1933 && (is_undead(mtmp
->data
) || is_vampshifter(mtmp
)
1934 || (is_demon(mtmp
->data
) && (u
.ulevel
> (MAXULEV
/ 2))))) {
1935 mtmp
->msleeping
= 0;
1938 pline("Unfortunately, your voice falters.");
1942 } else if (!resist(mtmp
, '\0', 0, TELL
)) {
1944 switch (mtmp
->data
->mlet
) {
1945 /* this is intentional, lichs are tougher
1948 xlev
+= 2; /*FALLTHRU*/
1950 xlev
+= 2; /*FALLTHRU*/
1952 xlev
+= 2; /*FALLTHRU*/
1954 xlev
+= 2; /*FALLTHRU*/
1956 xlev
+= 2; /*FALLTHRU*/
1958 if (u
.ulevel
>= xlev
&& !resist(mtmp
, '\0', 0, NOTELL
)) {
1959 if (u
.ualign
.type
== A_CHAOTIC
) {
1960 mtmp
->mpeaceful
= 1;
1962 } else { /* damn them */
1969 monflee(mtmp
, 0, FALSE
, TRUE
);
1976 multi_reason
= "trying to turn the monsters";
1977 nomovemsg
= You_can_move_again
;
1984 return a_gname_at(u
.ux
, u
.uy
);
1987 /* returns the name of an altar's deity */
1992 if (!IS_ALTAR(levl
[x
][y
].typ
))
1995 return align_gname(a_align(x
, y
));
1998 /* returns the name of the hero's deity */
2002 return align_gname(u
.ualign
.type
);
2006 align_gname(alignment
)
2011 switch (alignment
) {
2025 impossible("unknown alignment.");
2034 static const char *hallu_gods
[] = {
2035 "the Flying Spaghetti Monster", /* Church of the FSM */
2036 "Eris", /* Discordianism */
2037 "the Martians", /* every science fiction ever */
2039 "AnDoR dRaKoN", /* ADOM */
2040 "the Central Bank of Yendor", /* economics */
2041 "Tooth Fairy", /* real world(?) */
2042 "Om", /* Discworld */
2043 "Yawgmoth", /* Magic: the Gathering */
2044 "Morgoth", /* LoTR */
2045 "Cthulhu", /* Lovecraft */
2046 "the Ori", /* Stargate */
2047 "destiny", /* why not? */
2048 "your Friend the Computer", /* Paranoia */
2051 /* hallucination handling for priest/minion names: select a random god
2052 iff character is hallucinating */
2054 halu_gname(alignment
)
2057 const char *gnam
= NULL
;
2061 return align_gname(alignment
);
2063 /* The priest may not have initialized god names. If this is the
2064 * case, and we roll priest, we need to try again. */
2067 while (!roles
[which
].lgod
);
2072 gnam
= roles
[which
].lgod
;
2076 gnam
= roles
[which
].ngod
;
2080 gnam
= roles
[which
].cgod
;
2084 gnam
= hallu_gods
[rn2(sizeof hallu_gods
/ sizeof *hallu_gods
)];
2090 impossible("rn2 broken in halu_gname?!?");
2093 impossible("No random god name?");
2094 gnam
= "your Friend the Computer"; /* Paranoia */
2103 align_gtitle(alignment
)
2106 const char *gnam
, *result
= "god";
2108 switch (alignment
) {
2122 if (gnam
&& *gnam
== '_')
2131 aligntyp altaralign
= a_align(x
, y
);
2133 if (!strcmp(align_gname(altaralign
), u_gname())) {
2134 godvoice(altaralign
, "How darest thou desecrate my altar!");
2135 (void) adjattrib(A_WIS
, -1, FALSE
);
2137 pline("A voice (could it be %s?) whispers:", align_gname(altaralign
));
2138 verbalize("Thou shalt pay, infidel!");
2143 /* assumes isok() at one space away, but not necessarily at two */
2145 blocked_boulder(dx
, dy
)
2148 register struct obj
*otmp
;
2151 for (otmp
= level
.objects
[u
.ux
+ dx
][u
.uy
+ dy
]; otmp
;
2152 otmp
= otmp
->nexthere
) {
2153 if (otmp
->otyp
== BOULDER
)
2154 count
+= otmp
->quan
;
2159 /* no boulders--not blocked */
2162 /* possibly blocked depending on if it's pushable */
2165 /* more than one boulder--blocked after they push the top one;
2166 don't force them to push it first to find out */
2170 if (!isok(u
.ux
+ 2 * dx
, u
.uy
+ 2 * dy
))
2172 if (IS_ROCK(levl
[u
.ux
+ 2 * dx
][u
.uy
+ 2 * dy
].typ
))
2174 if (sobj_at(BOULDER
, u
.ux
+ 2 * dx
, u
.uy
+ 2 * dy
))