1 /* aNetHack 0.0.1 pray.c $ANH-Date: 1450577672 2015/12/20 02:14:32 $ $ANH-Branch: master $:$ANH-Revision: 1.89 $ */
2 /* Copyright (c) Benson I. Margulies, Mike Stephenson, Steve Linhart, 1989. */
3 /* aNetHack may be freely redistributed. See license for details. */
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 them,
525 * they reply 'Oh, but you forget the good God'. Apparently they conceive of
526 * the Deity as a Peeping Tom, whose omnipotence enables Him to see through
527 * bathroom walls, but who is foiled by bathrobes." --Bertrand Russell, 1943
528 * Divine wrath, dungeon walls, and armor follow the same principle.
531 god_zaps_you(resp_god
)
536 "Suddenly a bolt of lightning comes down at you from the heavens!");
537 pline("It strikes %s!", mon_nam(u
.ustuck
));
538 if (!resists_elec(u
.ustuck
)) {
539 pline("%s fries to a crisp!", Monnam(u
.ustuck
));
540 /* Yup, you get experience. It takes guts to successfully
541 * pull off this trick on your god, anyway.
542 * Other credit/blame applies (luck or alignment adjustments),
543 * but not direct kill count (pacifist conduct).
545 xkilled(u
.ustuck
, XKILL_NOMSG
| XKILL_NOCONDUCT
);
547 pline("%s seems unaffected.", Monnam(u
.ustuck
));
549 pline("Suddenly, a bolt of lightning strikes you!");
551 shieldeff(u
.ux
, u
.uy
);
553 pline("For some reason you're unaffected.");
555 (void) ureflects("%s reflects from your %s.", "It");
556 } else if (Shock_resistance
) {
557 shieldeff(u
.ux
, u
.uy
);
558 pline("It seems not to affect you.");
560 fry_by_god(resp_god
, FALSE
);
563 pline("%s is not deterred...", align_gname(resp_god
));
565 pline("A wide-angle disintegration beam aimed at you hits %s!",
567 if (!resists_disint(u
.ustuck
)) {
568 pline("%s disintegrates into a pile of dust!", Monnam(u
.ustuck
));
569 xkilled(u
.ustuck
, XKILL_NOMSG
| XKILL_NOCORPSE
| XKILL_NOCONDUCT
);
571 pline("%s seems unaffected.", Monnam(u
.ustuck
));
573 pline("A wide-angle disintegration beam hits you!");
575 /* disintegrate shield and body armor before disintegrating
576 * the impudent mortal, like black dragon breath -3.
578 if (uarms
&& !(EReflecting
& W_ARMS
)
579 && !(EDisint_resistance
& W_ARMS
))
580 (void) destroy_arm(uarms
);
581 if (uarmc
&& !(EReflecting
& W_ARMC
)
582 && !(EDisint_resistance
& W_ARMC
))
583 (void) destroy_arm(uarmc
);
584 if (uarm
&& !(EReflecting
& W_ARM
) && !(EDisint_resistance
& W_ARM
)
586 (void) destroy_arm(uarm
);
587 if (uarmu
&& !uarm
&& !uarmc
)
588 (void) destroy_arm(uarmu
);
589 if (!Disint_resistance
) {
590 fry_by_god(resp_god
, TRUE
);
592 You("bask in its %s glow for a minute...", NH_BLACK
);
593 godvoice(resp_god
, "I believe it not!");
595 if (Is_astralevel(&u
.uz
) || Is_sanctum(&u
.uz
)) {
596 /* one more try for high altars */
597 verbalize("Thou cannot escape my wrath, mortal!");
598 summon_minion(resp_god
, FALSE
);
599 summon_minion(resp_god
, FALSE
);
600 summon_minion(resp_god
, FALSE
);
601 verbalize("Destroy %s, my servants!", uhim());
607 fry_by_god(resp_god
, via_disintegration
)
609 boolean via_disintegration
;
611 You("%s!", !via_disintegration
? "fry to a crisp"
612 : "disintegrate into a pile of dust");
613 killer
.format
= KILLED_BY
;
614 Sprintf(killer
.name
, "the wrath of %s", align_gname(resp_god
));
628 /* changed from tmp = u.ugangr + abs (u.uluck) -- rph */
629 /* added test for alignment diff -dlc */
630 if (resp_god
!= u
.ualign
.type
)
631 maxanger
= u
.ualign
.record
/ 2 + (Luck
> 0 ? -Luck
/ 3 : -Luck
);
633 maxanger
= 3 * u
.ugangr
+ ((Luck
> 0 || u
.ualign
.record
>= STRIDENT
)
637 maxanger
= 1; /* possible if bad align & good luck */
638 else if (maxanger
> 15)
639 maxanger
= 15; /* be reasonable */
641 switch (rn2(maxanger
)) {
644 You_feel("that %s is %s.", align_gname(resp_god
),
645 Hallucination
? "bummed" : "displeased");
649 godvoice(resp_god
, (char *) 0);
650 pline("\"Thou %s, %s.\"",
651 (ugod_is_angry() && resp_god
== u
.ualign
.type
)
652 ? "hast strayed from the path"
654 youmonst
.data
->mlet
== S_HUMAN
? "mortal" : "creature");
655 verbalize("Thou must relearn thy lessons!");
656 (void) adjattrib(A_WIS
, -1, FALSE
);
661 gods_angry(resp_god
);
662 punish((struct obj
*) 0);
664 } /* else fall thru */
667 gods_angry(resp_god
);
668 if (!Blind
&& !Antimagic
)
669 pline("%s glow surrounds you.", An(hcolor(NH_BLACK
)));
674 godvoice(resp_god
, (char *) 0);
675 verbalize("Thou durst %s me?",
676 (on_altar() && (a_align(u
.ux
, u
.uy
) != resp_god
))
679 pline("\"Then die, %s!\"",
680 youmonst
.data
->mlet
== S_HUMAN
? "mortal" : "creature");
681 summon_minion(resp_god
, FALSE
);
685 gods_angry(resp_god
);
686 god_zaps_you(resp_god
);
689 u
.ublesscnt
= rnz(300);
693 /* helper to print "str appears at your feet", or appropriate */
701 /* barrier between you and the floor */
702 pline("%s %s into %s %s.", str
, vtense(str
, "drop"),
703 s_suffix(mon_nam(u
.ustuck
)), mbodypart(u
.ustuck
, STOMACH
));
705 pline("%s %s %s your %s!", str
,
706 Blind
? "lands" : vtense(str
, "appear"),
707 Levitation
? "beneath" : "at", makeplural(body_part(FOOT
)));
715 boolean already_exists
, in_hand
;
718 #define ok_wep(o) ((o) && ((o)->oclass == WEAPON_CLASS || is_weptool(o)))
720 HSee_invisible
|= FROMOUTSIDE
;
721 HFire_resistance
|= FROMOUTSIDE
;
722 HCold_resistance
|= FROMOUTSIDE
;
723 HShock_resistance
|= FROMOUTSIDE
;
724 HSleep_resistance
|= FROMOUTSIDE
;
725 HPoison_resistance
|= FROMOUTSIDE
;
726 godvoice(u
.ualign
.type
, (char *) 0);
728 obj
= ok_wep(uwep
) ? uwep
: 0;
729 already_exists
= in_hand
= FALSE
; /* lint suppression */
730 switch (u
.ualign
.type
) {
732 u
.uevent
.uhand_of_elbereth
= 1;
733 verbalize("I crown thee... The Hand of Elbereth!");
736 u
.uevent
.uhand_of_elbereth
= 2;
737 in_hand
= (uwep
&& uwep
->oartifact
== ART_VORPAL_BLADE
);
739 exist_artifact(LONG_SWORD
, artiname(ART_VORPAL_BLADE
));
740 verbalize("Thou shalt be my Envoy of Balance!");
743 u
.uevent
.uhand_of_elbereth
= 3;
744 in_hand
= (uwep
&& uwep
->oartifact
== ART_STORMBRINGER
);
746 exist_artifact(RUNESWORD
, artiname(ART_STORMBRINGER
));
747 verbalize("Thou art chosen to %s for My Glory!",
748 already_exists
&& !in_hand
? "take lives" : "steal souls");
752 class_gift
= STRANGE_OBJECT
;
753 /* 3.3.[01] had this in the A_NEUTRAL case below,
754 preventing chaotic wizards from receiving a spellbook */
755 if (Role_if(PM_WIZARD
)
756 && (!uwep
|| (uwep
->oartifact
!= ART_VORPAL_BLADE
757 && uwep
->oartifact
!= ART_STORMBRINGER
))
758 && !carrying(SPE_FINGER_OF_DEATH
)) {
759 class_gift
= SPE_FINGER_OF_DEATH
;
761 obj
= mksobj(class_gift
, TRUE
, FALSE
);
764 at_your_feet("A spellbook");
767 /* when getting a new book for known spell, enhance
768 currently wielded weapon rather than the book */
769 for (sp_no
= 0; sp_no
< MAXSPELL
; sp_no
++)
770 if (spl_book
[sp_no
].sp_id
== class_gift
) {
772 obj
= uwep
; /* to be blessed,&c */
775 } else if (Role_if(PM_MONK
) && (!uwep
|| !uwep
->oartifact
)
776 && !carrying(SPE_RESTORE_ABILITY
)) {
777 /* monks rarely wield a weapon */
778 class_gift
= SPE_RESTORE_ABILITY
;
782 switch (u
.ualign
.type
) {
784 if (class_gift
!= STRANGE_OBJECT
) {
785 ; /* already got bonus above */
786 } else if (obj
&& obj
->otyp
== LONG_SWORD
&& !obj
->oartifact
) {
788 Your("sword shines brightly for a moment.");
789 obj
= oname(obj
, artiname(ART_EXCALIBUR
));
790 if (obj
&& obj
->oartifact
== ART_EXCALIBUR
)
793 /* acquire Excalibur's skill regardless of weapon or gift */
794 unrestrict_weapon_skill(P_LONG_SWORD
);
795 if (obj
&& obj
->oartifact
== ART_EXCALIBUR
)
796 discover_artifact(ART_EXCALIBUR
);
799 if (class_gift
!= STRANGE_OBJECT
) {
800 ; /* already got bonus above */
801 } else if (obj
&& in_hand
) {
802 Your("%s goes snicker-snack!", xname(obj
));
804 } else if (!already_exists
) {
805 obj
= mksobj(LONG_SWORD
, FALSE
, FALSE
);
806 obj
= oname(obj
, artiname(ART_VORPAL_BLADE
));
808 at_your_feet("A sword");
812 /* acquire Vorpal Blade's skill regardless of weapon or gift */
813 unrestrict_weapon_skill(P_LONG_SWORD
);
814 if (obj
&& obj
->oartifact
== ART_VORPAL_BLADE
)
815 discover_artifact(ART_VORPAL_BLADE
);
818 char swordbuf
[BUFSZ
];
820 Sprintf(swordbuf
, "%s sword", hcolor(NH_BLACK
));
821 if (class_gift
!= STRANGE_OBJECT
) {
822 ; /* already got bonus above */
823 } else if (obj
&& in_hand
) {
824 Your("%s hums ominously!", swordbuf
);
826 } else if (!already_exists
) {
827 obj
= mksobj(RUNESWORD
, FALSE
, FALSE
);
828 obj
= oname(obj
, artiname(ART_STORMBRINGER
));
830 at_your_feet(An(swordbuf
));
834 /* acquire Stormbringer's skill regardless of weapon or gift */
835 unrestrict_weapon_skill(P_BROAD_SWORD
);
836 if (obj
&& obj
->oartifact
== ART_STORMBRINGER
)
837 discover_artifact(ART_STORMBRINGER
);
845 /* enhance weapon regardless of alignment or artifact status */
848 obj
->oeroded
= obj
->oeroded2
= 0;
849 obj
->oerodeproof
= TRUE
;
850 obj
->bknown
= obj
->rknown
= TRUE
;
853 /* acquire skill in this weapon */
854 unrestrict_weapon_skill(weapon_type(obj
));
855 } else if (class_gift
== STRANGE_OBJECT
) {
856 /* opportunity knocked, but there was nobody home... */
857 You_feel("unworthy.");
861 /* lastly, confer an extra skill slot/credit beyond the
862 up-to-29 you can get from gaining experience levels */
871 /* don't use p_trouble, worst trouble may get fixed while praying */
872 int trouble
= in_trouble(); /* what's your worst difficulty? */
873 int pat_on_head
= 0, kick_on_butt
;
875 You_feel("that %s is %s.", align_gname(g_align
),
876 (u
.ualign
.record
>= DEVOUT
)
877 ? Hallucination
? "pleased as punch" : "well-pleased"
878 : (u
.ualign
.record
>= STRIDENT
)
879 ? Hallucination
? "ticklish" : "pleased"
880 : Hallucination
? "full" : "satisfied");
883 if (on_altar() && p_aligntyp
!= u
.ualign
.type
) {
886 } else if (u
.ualign
.record
< 2 && trouble
<= 0)
890 * Depending on your luck & align level, the god you prayed to will:
891 * - fix your worst problem if it's major;
892 * - fix all your major problems;
893 * - fix your worst problem if it's minor;
894 * - fix all of your problems;
895 * - do you a gratuitous favor.
897 * If you make it to the the last category, you roll randomly again
898 * to see what they do for you.
900 * If your luck is at least 0, then you are guaranteed rescued from
901 * your worst major problem.
903 if (!trouble
&& u
.ualign
.record
>= DEVOUT
) {
904 /* if hero was in trouble, but got better, no special favor */
908 int action
, prayer_luck
;
911 /* Negative luck is normally impossible here (can_pray() forces
912 prayer failure in that situation), but it's possible for
913 Luck to drop during the period of prayer occupation and
914 become negative by the time we get here. [Reported case
915 was lawful character whose stinking cloud caused a delayed
916 killing of a peaceful human, triggering the "murderer"
917 penalty while successful prayer was in progress. It could
918 also happen due to inconvenient timing on Friday 13th, but
919 the magnitude there (-1) isn't big enough to cause trouble.]
920 We don't bother remembering start-of-prayer luck, just make
921 sure it's at least -1 so that Luck+2 is big enough to avoid
922 a divide by zero crash when generating a random number. */
923 prayer_luck
= max(Luck
, -1); /* => (prayer_luck + 2 > 0) */
924 action
= rn1(prayer_luck
+ (on_altar() ? 3 + on_shrine() : 2), 1);
926 action
= min(action
, 3);
927 if (u
.ualign
.record
< STRIDENT
)
928 action
= (u
.ualign
.record
> 0 || !rnl(2)) ? 1 : 0;
930 switch (min(action
, 5)) {
935 fix_worst_trouble(trouble
);
936 while ((trouble
= in_trouble()) != 0);
940 fix_worst_trouble(trouble
);
942 /* arbitrary number of tries */
943 while ((trouble
= in_trouble()) > 0 && (++tryct
< 10))
944 fix_worst_trouble(trouble
);
949 fix_worst_trouble(trouble
);
951 break; /* your god blows you off, too bad */
955 /* note: can't get pat_on_head unless all troubles have just been
956 fixed or there were no troubles to begin with; hallucination
957 won't be in effect so special handling for it is superfluous */
959 switch (rn2((Luck
+ 6) >> 1)) {
963 if (uwep
&& (welded(uwep
) || uwep
->oclass
== WEAPON_CLASS
964 || is_weptool(uwep
))) {
965 char repair_buf
[BUFSZ
];
968 if (uwep
->oeroded
|| uwep
->oeroded2
)
969 Sprintf(repair_buf
, " and %s now as good as new",
970 otense(uwep
, "are"));
974 pline("%s %s%s.", Yobjnam2(uwep
, "softly glow"),
975 hcolor(NH_AMBER
), repair_buf
);
976 iflags
.last_msg
= PLNMSG_OBJ_GLOWS
;
978 You_feel("the power of %s over %s.", u_gname(),
983 } else if (!uwep
->blessed
) {
985 pline("%s with %s aura%s.",
986 Yobjnam2(uwep
, "softly glow"),
987 an(hcolor(NH_LIGHT_BLUE
)), repair_buf
);
988 iflags
.last_msg
= PLNMSG_OBJ_GLOWS
;
990 You_feel("the blessing of %s over %s.", u_gname(),
997 /* fix any rust/burn/rot damage, but don't protect
998 against future damage */
999 if (uwep
->oeroded
|| uwep
->oeroded2
) {
1000 uwep
->oeroded
= uwep
->oeroded2
= 0;
1001 /* only give this message if we didn't just bless
1002 or uncurse (which has already given a message) */
1004 pline("%s as good as new!",
1005 Yobjnam2(uwep
, Blind
? "feel" : "look"));
1011 /* takes 2 hints to get the music to enter the stronghold;
1012 skip if you've solved it via mastermind or destroyed the
1013 drawbridge (both set uopened_dbridge) or if you've already
1014 travelled past the Valley of the Dead (gehennom_entered) */
1015 if (!u
.uevent
.uopened_dbridge
&& !u
.uevent
.gehennom_entered
) {
1016 if (u
.uevent
.uheard_tune
< 1) {
1017 godvoice(g_align
, (char *) 0);
1018 verbalize("Hark, %s!", youmonst
.data
->mlet
== S_HUMAN
1022 "To enter the castle, thou must play the right tune!");
1023 u
.uevent
.uheard_tune
++;
1025 } else if (u
.uevent
.uheard_tune
< 2) {
1026 You_hear("a divine music...");
1027 pline("It sounds like: \"%s\".", tune
);
1028 u
.uevent
.uheard_tune
++;
1032 /* Otherwise, falls into next case */
1035 You("are surrounded by %s glow.", an(hcolor(NH_GOLDEN
)));
1036 /* if any levels have been lost (and not yet regained),
1037 treat this effect like blessed full healing */
1038 if (u
.ulevel
< u
.ulevelmax
) {
1039 u
.ulevelmax
-= 1; /* see potion.c */
1049 ABASE(A_STR
) = AMAX(A_STR
);
1050 if (u
.uhunger
< 900)
1052 /* luck couldn't have been negative at start of prayer because
1053 the prayer would have failed, but might have been decremented
1054 due to a timed event (delayed death of peaceful monster hit
1055 by hero-created stinking cloud) during the praying interval */
1058 /* superfluous; if hero was blinded we'd be handling trouble
1059 rather than issuing a pat-on-head */
1061 make_blinded(0L, TRUE
);
1065 register struct obj
*otmp
;
1069 You_feel("the power of %s.", u_gname());
1071 You("are surrounded by %s aura.", an(hcolor(NH_LIGHT_BLUE
)));
1072 for (otmp
= invent
; otmp
; otmp
= otmp
->nobj
) {
1075 pline("%s %s.", Yobjnam2(otmp
, "softly glow"),
1077 iflags
.last_msg
= PLNMSG_OBJ_GLOWS
;
1078 otmp
->bknown
= TRUE
;
1089 static NEARDATA
const char msg
[] =
1090 "\"and thus I grant thee the gift of %s!\"";
1092 godvoice(u
.ualign
.type
,
1093 "Thou hast pleased me with thy progress,");
1094 if (!(HTelepat
& INTRINSIC
)) {
1095 HTelepat
|= FROMOUTSIDE
;
1096 pline(msg
, "Telepathy");
1099 } else if (!(HFast
& INTRINSIC
)) {
1100 HFast
|= FROMOUTSIDE
;
1101 pline(msg
, "Speed");
1102 } else if (!(HStealth
& INTRINSIC
)) {
1103 HStealth
|= FROMOUTSIDE
;
1104 pline(msg
, "Stealth");
1106 if (!(HProtection
& INTRINSIC
)) {
1107 HProtection
|= FROMOUTSIDE
;
1109 u
.ublessed
= rn1(3, 2);
1112 pline(msg
, "my protection");
1114 verbalize("Use it wisely in my name!");
1119 if (u
.ualign
.record
>= PIOUS
&& !u
.uevent
.uhand_of_elbereth
) {
1122 } /* else FALLTHRU */
1125 int sp_no
, trycnt
= u
.ulevel
+ 1;
1127 /* not yet known spells given preference over already known ones
1129 /* Also, try to grant a spell for which there is a skill slot */
1130 otmp
= mkobj(SPBOOK_CLASS
, TRUE
);
1131 while (--trycnt
> 0) {
1132 if (otmp
->otyp
!= SPE_BLANK_PAPER
) {
1133 for (sp_no
= 0; sp_no
< MAXSPELL
; sp_no
++)
1134 if (spl_book
[sp_no
].sp_id
== otmp
->otyp
)
1136 if (sp_no
== MAXSPELL
1137 && !P_RESTRICTED(spell_skilltype(otmp
->otyp
)))
1138 break; /* usable, but not yet known */
1140 if (!objects
[SPE_BLANK_PAPER
].oc_name_known
1141 || carrying(MAGIC_MARKER
))
1144 otmp
->otyp
= rnd_class(bases
[SPBOOK_CLASS
], SPE_BLANK_PAPER
);
1147 at_your_feet("A spellbook");
1148 place_object(otmp
, u
.ux
, u
.uy
);
1153 impossible("Confused deity!");
1157 u
.ublesscnt
= rnz(350);
1158 kick_on_butt
= u
.uevent
.udemigod
? 1 : 0;
1159 if (u
.uevent
.uhand_of_elbereth
)
1162 u
.ublesscnt
+= kick_on_butt
* rnz(1000);
1167 /* either blesses or curses water on the altar,
1168 * returns true if it found any water here.
1171 water_prayer(bless_water
)
1172 boolean bless_water
;
1174 register struct obj
*otmp
;
1175 register long changed
= 0;
1176 boolean other
= FALSE
, bc_known
= !(Blind
|| Hallucination
);
1178 for (otmp
= level
.objects
[u
.ux
][u
.uy
]; otmp
; otmp
= otmp
->nexthere
) {
1179 /* turn water into (un)holy water */
1180 if (otmp
->otyp
== POT_WATER
1181 && (bless_water
? !otmp
->blessed
: !otmp
->cursed
)) {
1182 otmp
->blessed
= bless_water
;
1183 otmp
->cursed
= !bless_water
;
1184 otmp
->bknown
= bc_known
;
1185 changed
+= otmp
->quan
;
1186 } else if (otmp
->oclass
== POTION_CLASS
)
1189 if (!Blind
&& changed
) {
1190 pline("%s potion%s on the altar glow%s %s for a moment.",
1191 ((other
&& changed
> 1L) ? "Some of the"
1192 : (other
? "One of the" : "The")),
1193 ((other
|| changed
> 1L) ? "s" : ""), (changed
> 1L ? "" : "s"),
1194 (bless_water
? hcolor(NH_LIGHT_BLUE
) : hcolor(NH_BLACK
)));
1196 return (boolean
) (changed
> 0L);
1200 godvoice(g_align
, words
)
1204 const char *quot
= "";
1211 pline_The("voice of %s %s: %s%s%s", align_gname(g_align
),
1212 godvoices
[rn2(SIZE(godvoices
))], quot
, words
, quot
);
1219 godvoice(g_align
, "Thou hast angered me.");
1222 /* The g_align god is upset with you. */
1227 if (g_align
== u
.ualign
.type
)
1235 consume_offering(otmp
)
1236 register struct obj
*otmp
;
1241 Your("sacrifice sprouts wings and a propeller and roars away!");
1244 Your("sacrifice puffs up, swelling bigger and bigger, and pops!");
1248 "sacrifice collapses into a cloud of dancing particles and fades away!");
1251 else if (Blind
&& u
.ualign
.type
== A_LAWFUL
)
1252 Your("sacrifice disappears!");
1254 Your("sacrifice is consumed in a %s!",
1255 u
.ualign
.type
== A_LAWFUL
? "flash of light" : "burst of flame");
1260 exercise(A_WIS
, TRUE
);
1266 static NEARDATA
const char cloud_of_smoke
[] =
1267 "A cloud of %s smoke surrounds you...";
1268 register struct obj
*otmp
;
1271 aligntyp altaralign
= a_align(u
.ux
, u
.uy
);
1273 if (!on_altar() || u
.uswallow
) {
1274 You("are not standing on an altar.");
1277 highaltar
= ((Is_astralevel(&u
.uz
) || Is_sanctum(&u
.uz
))
1278 && (levl
[u
.ux
][u
.uy
].altarmask
& AM_SHRINE
));
1280 otmp
= floorfood("sacrifice", 1);
1284 * Was based on nutritional value and aging behavior (< 50 moves).
1285 * Sacrificing a food ration got you max luck instantly, making the
1286 * gods as easy to please as an angry dog!
1288 * Now only accepts corpses, based on the game's evaluation of their
1289 * toughness. Human and pet sacrifice, as well as sacrificing unicorns
1290 * of your alignment, is strongly discouraged.
1292 #define MAXVALUE 24 /* Highest corpse value (besides Wiz) */
1294 if (otmp
->otyp
== CORPSE
) {
1295 register struct permonst
*ptr
= &mons
[otmp
->corpsenm
];
1297 extern const int monstr
[];
1300 u
.uconduct
.gnostic
++;
1302 /* you're handling this corpse, even if it was killed upon the altar
1304 feel_cockatrice(otmp
, TRUE
);
1305 if (rider_corpse_revival(otmp
, FALSE
))
1308 if (otmp
->corpsenm
== PM_ACID_BLOB
1309 || (monstermoves
<= peek_at_iced_corpse_age(otmp
) + 50)) {
1310 value
= monstr
[otmp
->corpsenm
] + 1;
1312 value
= eaten_stat(value
, otmp
);
1315 if (your_race(ptr
)) {
1316 if (is_demon(youmonst
.data
)) {
1317 You("find the idea very satisfying.");
1318 exercise(A_WIS
, TRUE
);
1319 } else if (u
.ualign
.type
!= A_CHAOTIC
) {
1320 pline("You'll regret this infamous offense!");
1321 exercise(A_WIS
, FALSE
);
1325 && (altaralign
!= A_CHAOTIC
|| u
.ualign
.type
!= A_CHAOTIC
)) {
1326 goto desecrate_high_altar
;
1327 } else if (altaralign
!= A_CHAOTIC
&& altaralign
!= A_NONE
) {
1328 /* curse the lawful/neutral altar */
1329 pline_The("altar is stained with %s blood.", urace
.adj
);
1330 levl
[u
.ux
][u
.uy
].altarmask
= AM_CHAOTIC
;
1334 const char *demonless_msg
;
1336 /* Human sacrifice on a chaotic or unaligned altar */
1337 /* is equivalent to demon summoning */
1338 if (altaralign
== A_CHAOTIC
&& u
.ualign
.type
!= A_CHAOTIC
) {
1340 "The blood floods the altar, which vanishes in %s cloud!",
1341 an(hcolor(NH_BLACK
)));
1342 levl
[u
.ux
][u
.uy
].typ
= ROOM
;
1343 levl
[u
.ux
][u
.uy
].altarmask
= 0;
1346 demonless_msg
= "cloud dissipates";
1348 /* either you're chaotic or altar is Moloch's or both */
1349 pline_The("blood covers the altar!");
1350 change_luck(altaralign
== A_NONE
? -2 : 2);
1351 demonless_msg
= "blood coagulates";
1353 if ((pm
= dlord(altaralign
)) != NON_PM
1354 && (dmon
= makemon(&mons
[pm
], u
.ux
, u
.uy
, NO_MM_FLAGS
))
1358 Strcpy(dbuf
, a_monnam(dmon
));
1359 if (!strcmpi(dbuf
, "it"))
1360 Strcpy(dbuf
, "something dreadful");
1362 dmon
->mstrategy
&= ~STRAT_APPEARMSG
;
1363 You("have summoned %s!", dbuf
);
1364 if (sgn(u
.ualign
.type
) == sgn(dmon
->data
->maligntyp
))
1365 dmon
->mpeaceful
= TRUE
;
1366 You("are terrified, and unable to move.");
1368 multi_reason
= "being terrified of a demon";
1371 pline_The("%s.", demonless_msg
);
1374 if (u
.ualign
.type
!= A_CHAOTIC
) {
1377 (void) adjattrib(A_WIS
, -1, TRUE
);
1379 angrygods(u
.ualign
.type
);
1388 } else if (has_omonst(otmp
)
1389 && (mtmp
= get_mtraits(otmp
, FALSE
)) != 0
1391 /* mtmp is a temporary pointer to a tame monster's attributes,
1392 * not a real monster */
1393 pline("So this is how you repay loyalty?");
1396 HAggravate_monster
|= FROMOUTSIDE
;
1397 } else if (is_undead(ptr
)) { /* Not demons--no demon corpses */
1398 if (u
.ualign
.type
!= A_CHAOTIC
)
1400 } else if (is_unicorn(ptr
)) {
1401 int unicalign
= sgn(ptr
->maligntyp
);
1403 if (unicalign
== altaralign
) {
1404 /* When same as altar, always a very bad action.
1406 pline("Such an action is an insult to %s!",
1407 (unicalign
== A_CHAOTIC
) ? "chaos"
1408 : unicalign
? "law" : "balance");
1409 (void) adjattrib(A_WIS
, -1, TRUE
);
1411 } else if (u
.ualign
.type
== altaralign
) {
1412 /* When different from altar, and altar is same as yours,
1413 * it's a very good action.
1415 if (u
.ualign
.record
< ALIGNLIM
)
1416 You_feel("appropriately %s.", align_str(u
.ualign
.type
));
1418 You_feel("you are thoroughly on the right path.");
1421 } else if (unicalign
== u
.ualign
.type
) {
1422 /* When sacrificing unicorn of your alignment to altar not of
1423 * your alignment, your god gets angry and it's a conversion.
1425 u
.ualign
.record
= -1;
1428 /* Otherwise, unicorn's alignment is different from yours
1429 * and different from the altar's. It's an ordinary (well,
1430 * with a bonus) sacrifice on a cross-aligned altar.
1437 if (otmp
->otyp
== AMULET_OF_YENDOR
) {
1440 if (altaralign
== A_NONE
&& Inhell
)
1441 /* hero has left Moloch's Sanctum so is in the process
1442 of getting away with the Amulet (outside of Gehennom,
1443 fall through to the "ashamed" feedback) */
1449 /* if on track, give a big hint */
1450 : (altaralign
== u
.ualign
.type
)
1451 ? "an urge to return to the surface"
1452 /* else headed towards celestial disgrace */
1456 /* The final Test. Did you win? */
1459 u
.uevent
.ascended
= 1;
1461 useup(otmp
); /* well, it's gone now */
1464 You("offer the Amulet of Yendor to %s...", a_gname());
1465 if (altaralign
== A_NONE
) {
1466 /* Moloch's high altar */
1467 if (u
.ualign
.record
> -99)
1468 u
.ualign
.record
= -99;
1469 /*[apparently shrug/snarl can be sensed without being seen]*/
1470 pline("%s shrugs and retains dominion over %s,", Moloch
,
1472 pline("then mercilessly snuffs out your life.");
1473 Sprintf(killer
.name
, "%s indifference", s_suffix(Moloch
));
1474 killer
.format
= KILLED_BY
;
1476 /* life-saved (or declined to die in wizard/explore mode) */
1477 pline("%s snarls and tries again...", Moloch
);
1478 fry_by_god(A_NONE
, TRUE
); /* wrath of Moloch */
1479 /* declined to die in wizard or explore mode */
1480 pline(cloud_of_smoke
, hcolor(NH_BLACK
));
1482 } else if (u
.ualign
.type
!= altaralign
) {
1483 /* And the opposing team picks you up and
1484 carries you off on their shoulders */
1486 pline("%s accepts your gift, and gains dominion over %s...",
1487 a_gname(), u_gname());
1488 pline("%s is enraged...", u_gname());
1489 pline("Fortunately, %s permits you to live...", a_gname());
1490 pline(cloud_of_smoke
, hcolor(NH_ORANGE
));
1492 } else { /* super big win */
1494 u
.uachieve
.ascended
= 1;
1496 "An invisible choir sings, and you are bathed in radiance...");
1497 godvoice(altaralign
, "Congratulations, mortal!");
1498 display_nhwindow(WIN_MESSAGE
, FALSE
);
1500 "In return for thy service, I grant thee the gift of Immortality!");
1501 You("ascend to the status of Demigod%s...",
1502 flags
.female
? "dess" : "");
1508 if (otmp
->otyp
== FAKE_AMULET_OF_YENDOR
) {
1509 if (!highaltar
&& !otmp
->known
)
1511 You_hear("a nearby thunderclap.");
1513 You("realize you have made a %s.",
1514 Hallucination
? "boo-boo" : "mistake");
1519 /* don't you dare try to fool the gods */
1521 pline("Oh, no."); /* didn't hear thunderclap */
1530 pline1(nothing_happens
);
1534 if (altaralign
!= u
.ualign
.type
&& highaltar
) {
1535 desecrate_high_altar
:
1537 * REAL BAD NEWS!!! High altars cannot be converted. Even an attempt
1538 * gets the god who owns it truly pissed off.
1540 You_feel("the air around you grow charged...");
1541 pline("Suddenly, you realize that %s has noticed you...", a_gname());
1542 godvoice(altaralign
,
1543 "So, mortal! You dare desecrate my High Temple!");
1544 /* Throw everything we have at the player */
1545 god_zaps_you(altaralign
);
1547 < 0) { /* I don't think the gods are gonna like this... */
1548 gods_upset(altaralign
);
1550 int saved_anger
= u
.ugangr
;
1551 int saved_cnt
= u
.ublesscnt
;
1552 int saved_luck
= u
.uluck
;
1554 /* Sacrificing at an altar of a different alignment */
1555 if (u
.ualign
.type
!= altaralign
) {
1556 /* Is this a conversion ? */
1557 /* An unaligned altar in Gehennom will always elicit rejection. */
1558 if (ugod_is_angry() || (altaralign
== A_NONE
&& Inhell
)) {
1559 if (u
.ualignbase
[A_CURRENT
] == u
.ualignbase
[A_ORIGINAL
]
1560 && altaralign
!= A_NONE
) {
1561 You("have a strong feeling that %s is angry...",
1563 consume_offering(otmp
);
1564 pline("%s accepts your allegiance.", a_gname());
1566 uchangealign(altaralign
, 0);
1567 /* Beware, Conversion is costly */
1573 pline("%s rejects your sacrifice!", a_gname());
1574 godvoice(altaralign
, "Suffer, infidel!");
1576 (void) adjattrib(A_WIS
, -2, TRUE
);
1578 angrygods(u
.ualign
.type
);
1582 consume_offering(otmp
);
1583 You("sense a conflict between %s and %s.", u_gname(),
1585 if (rn2(8 + u
.ulevel
) > 5) {
1587 You_feel("the power of %s increase.", u_gname());
1588 exercise(A_WIS
, TRUE
);
1590 /* Yes, this is supposed to be &=, not |= */
1591 levl
[u
.ux
][u
.uy
].altarmask
&= AM_SHRINE
;
1592 /* the following accommodates stupid compilers */
1593 levl
[u
.ux
][u
.uy
].altarmask
=
1594 levl
[u
.ux
][u
.uy
].altarmask
1595 | (Align2amask(u
.ualign
.type
));
1597 pline_The("altar glows %s.",
1598 hcolor((u
.ualign
.type
== A_LAWFUL
)
1602 : (const char *) "gray"));
1604 if (rnl(u
.ulevel
) > 6 && u
.ualign
.record
> 0
1605 && rnd(u
.ualign
.record
) > (3 * ALIGNLIM
) / 4)
1606 summon_minion(altaralign
, TRUE
);
1607 /* anger priest; test handles bones files */
1608 if ((pri
= findpriest(temple_occupied(u
.urooms
)))
1609 && !p_coaligned(pri
))
1612 pline("Unluckily, you feel the power of %s decrease.",
1615 exercise(A_WIS
, FALSE
);
1616 if (rnl(u
.ulevel
) > 6 && u
.ualign
.record
> 0
1617 && rnd(u
.ualign
.record
) > (7 * ALIGNLIM
) / 8)
1618 summon_minion(altaralign
, TRUE
);
1624 consume_offering(otmp
);
1625 /* OK, you get brownie points. */
1627 u
.ugangr
-= ((value
* (u
.ualign
.type
== A_CHAOTIC
? 2 : 3))
1631 if (u
.ugangr
!= saved_anger
) {
1633 pline("%s seems %s.", u_gname(),
1634 Hallucination
? "groovy" : "slightly mollified");
1636 if ((int) u
.uluck
< 0)
1639 pline("%s seems %s.", u_gname(),
1640 Hallucination
? "cosmic (not a new fact)"
1643 if ((int) u
.uluck
< 0)
1646 } else { /* not satisfied yet */
1648 pline_The("gods seem tall.");
1650 You("have a feeling of inadequacy.");
1652 } else if (ugod_is_angry()) {
1653 if (value
> MAXVALUE
)
1655 if (value
> -u
.ualign
.record
)
1656 value
= -u
.ualign
.record
;
1658 You_feel("partially absolved.");
1659 } else if (u
.ublesscnt
> 0) {
1660 u
.ublesscnt
-= ((value
* (u
.ualign
.type
== A_CHAOTIC
? 500 : 300))
1662 if (u
.ublesscnt
< 0)
1664 if (u
.ublesscnt
!= saved_cnt
) {
1667 You("realize that the gods are not like you and I.");
1669 You("have a hopeful feeling.");
1670 if ((int) u
.uluck
< 0)
1674 pline("Overall, there is a smell of fried onions.");
1676 You("have a feeling of reconciliation.");
1677 if ((int) u
.uluck
< 0)
1682 int nartifacts
= nartifact_exist();
1684 /* you were already in pretty good standing */
1685 /* The player can gain an artifact */
1686 /* The chance goes down as the number of artifacts goes up */
1687 if (u
.ulevel
> 2 && u
.uluck
>= 0
1688 && !rn2(10 + (2 * u
.ugifts
* nartifacts
))) {
1689 otmp
= mk_artifact((struct obj
*) 0, a_align(u
.ux
, u
.uy
));
1695 otmp
->oerodeproof
= TRUE
;
1696 at_your_feet("An object");
1698 godvoice(u
.ualign
.type
, "Use my gift wisely!");
1700 u
.ublesscnt
= rnz(300 + (50 * nartifacts
));
1701 exercise(A_WIS
, TRUE
);
1702 /* make sure we can use this weapon */
1703 unrestrict_weapon_skill(weapon_type(otmp
));
1704 if (!Hallucination
&& !Blind
) {
1706 makeknown(otmp
->otyp
);
1707 discover_artifact(otmp
->oartifact
);
1712 change_luck((value
* LUCKMAX
) / (MAXVALUE
* 2));
1713 if ((int) u
.uluck
< 0)
1715 if (u
.uluck
!= saved_luck
) {
1717 You("think %s brushed your %s.", something
,
1721 ? "see crabgrass at your %s. A funny thing in a dungeon."
1722 : "glimpse a four-leaf clover at your %s.",
1723 makeplural(body_part(FOOT
)));
1730 /* determine prayer results in advance; also used for enlightenment */
1733 boolean praying
; /* false means no messages should be given */
1737 p_aligntyp
= on_altar() ? a_align(u
.ux
, u
.uy
) : u
.ualign
.type
;
1738 p_trouble
= in_trouble();
1740 if (is_demon(youmonst
.data
) && (p_aligntyp
!= A_CHAOTIC
)) {
1742 pline_The("very idea of praying to a %s god is repugnant to you.",
1743 p_aligntyp
? "lawful" : "neutral");
1748 You("begin praying to %s.", align_gname(p_aligntyp
));
1750 if (u
.ualign
.type
&& u
.ualign
.type
== -p_aligntyp
)
1751 alignment
= -u
.ualign
.record
; /* Opposite alignment altar */
1752 else if (u
.ualign
.type
!= p_aligntyp
)
1753 alignment
= u
.ualign
.record
/ 2; /* Different alignment altar */
1755 alignment
= u
.ualign
.record
;
1757 if ((p_trouble
> 0) ? (u
.ublesscnt
> 200) /* big trouble */
1758 : (p_trouble
< 0) ? (u
.ublesscnt
> 100) /* minor difficulties */
1759 : (u
.ublesscnt
> 0)) /* not in trouble */
1760 p_type
= 0; /* too soon... */
1761 else if ((int) Luck
< 0 || u
.ugangr
|| alignment
< 0)
1762 p_type
= 1; /* too naughty... */
1763 else /* alignment >= 0 */ {
1764 if (on_altar() && u
.ualign
.type
!= p_aligntyp
)
1770 if (is_undead(youmonst
.data
) && !Inhell
1771 && (p_aligntyp
== A_LAWFUL
|| (p_aligntyp
== A_NEUTRAL
&& !rn2(10))))
1773 /* Note: when !praying, the random factor for neutrals makes the
1774 return value a non-deterministic approximation for enlightenment.
1775 This case should be uncommon enough to live with... */
1777 return !praying
? (boolean
) (p_type
== 3 && !Inhell
) : TRUE
;
1780 /* #pray commmand */
1784 /* Confirm accidental slips of Alt-P */
1785 if (ParanoidPray
&& yn("Are you sure you want to pray?") != 'y')
1788 u
.uconduct
.gnostic
++;
1790 /* set up p_type and p_alignment */
1791 if (!can_pray(TRUE
))
1794 if (wizard
&& p_type
>= 0) {
1795 if (yn("Force the gods to be pleased?") == 'y') {
1799 if (u
.ualign
.record
<= 0)
1800 u
.ualign
.record
= 1;
1807 multi_reason
= "praying";
1808 nomovemsg
= "You finish your prayer.";
1809 afternmv
= prayer_done
;
1811 if (p_type
== 3 && !Inhell
) {
1812 /* if you've been true to your god you can't die while you pray */
1814 You("are surrounded by a shimmering light.");
1815 u
.uinvulnerable
= TRUE
;
1822 prayer_done() /* M. Stephenson (1.0.3b) */
1824 aligntyp alignment
= p_aligntyp
;
1826 u
.uinvulnerable
= FALSE
;
1829 (alignment
== A_LAWFUL
)
1830 ? "Vile creature, thou durst call upon me?"
1831 : "Walk no more, perversion of nature!");
1832 You_feel("like you are falling apart.");
1833 /* KMH -- Gods have mastery over unchanging */
1835 /* no Half_physical_damage adjustment here */
1836 losehp(rnd(20), "residual undead turning effect", KILLED_BY_AN
);
1837 exercise(A_CON
, FALSE
);
1841 pline("Since you are in Gehennom, %s won't help you.",
1842 align_gname(alignment
));
1843 /* haltingly aligned is least likely to anger */
1844 if (u
.ualign
.record
<= 0 || rnl(u
.ualign
.record
))
1845 angrygods(u
.ualign
.type
);
1850 if (on_altar() && u
.ualign
.type
!= alignment
)
1851 (void) water_prayer(FALSE
);
1852 u
.ublesscnt
+= rnz(250);
1854 gods_upset(u
.ualign
.type
);
1855 } else if (p_type
== 1) {
1856 if (on_altar() && u
.ualign
.type
!= alignment
)
1857 (void) water_prayer(FALSE
);
1858 angrygods(u
.ualign
.type
); /* naughty */
1859 } else if (p_type
== 2) {
1860 if (water_prayer(FALSE
)) {
1861 /* attempted water prayer on a non-coaligned altar */
1862 u
.ublesscnt
+= rnz(250);
1864 gods_upset(u
.ualign
.type
);
1870 (void) water_prayer(TRUE
);
1871 pleased(alignment
); /* nice */
1880 /* Knights & Priest(esse)s only please */
1881 struct monst
*mtmp
, *mtmp2
;
1882 int once
, range
, xlev
;
1884 if (!Role_if(PM_PRIEST
) && !Role_if(PM_KNIGHT
)) {
1885 /* Try to use the "turn undead" spell.
1887 * This used to be based on whether hero knows the name of the
1888 * turn undead spellbook, but it's possible to know--and be able
1889 * to cast--the spell while having lost the book ID to amnesia.
1890 * (It also used to tell spelleffects() to cast at self?)
1894 for (sp_no
= 0; sp_no
< MAXSPELL
; ++sp_no
) {
1895 if (spl_book
[sp_no
].sp_id
== NO_SPELL
)
1897 else if (spl_book
[sp_no
].sp_id
== SPE_TURN_UNDEAD
)
1898 return spelleffects(sp_no
, FALSE
);
1900 You("don't know how to turn undead!");
1903 u
.uconduct
.gnostic
++;
1905 if ((u
.ualign
.type
!= A_CHAOTIC
1906 && (is_demon(youmonst
.data
) || is_undead(youmonst
.data
)))
1907 || u
.ugangr
> 6) { /* "Die, mortal!" */
1908 pline("For some reason, %s seems to ignore you.", u_gname());
1910 exercise(A_WIS
, FALSE
);
1914 pline("Since you are in Gehennom, %s won't help you.", u_gname());
1918 pline("Calling upon %s, you chant an arcane formula.", u_gname());
1919 exercise(A_WIS
, TRUE
);
1921 /* note: does not perform unturn_dead() on victims' inventories */
1922 range
= BOLT_LIM
+ (u
.ulevel
/ 5); /* 5 to 11 */
1925 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp2
) {
1928 if (DEADMONSTER(mtmp
))
1930 if (!cansee(mtmp
->mx
, mtmp
->my
) || distu(mtmp
->mx
, mtmp
->my
) > range
)
1933 if (!mtmp
->mpeaceful
1934 && (is_undead(mtmp
->data
) || is_vampshifter(mtmp
)
1935 || (is_demon(mtmp
->data
) && (u
.ulevel
> (MAXULEV
/ 2))))) {
1936 mtmp
->msleeping
= 0;
1939 pline("Unfortunately, your voice falters.");
1943 } else if (!resist(mtmp
, '\0', 0, TELL
)) {
1945 switch (mtmp
->data
->mlet
) {
1946 /* this is intentional, lichs are tougher
1949 xlev
+= 2; /*FALLTHRU*/
1951 xlev
+= 2; /*FALLTHRU*/
1953 xlev
+= 2; /*FALLTHRU*/
1955 xlev
+= 2; /*FALLTHRU*/
1957 xlev
+= 2; /*FALLTHRU*/
1959 if (u
.ulevel
>= xlev
&& !resist(mtmp
, '\0', 0, NOTELL
)) {
1960 if (u
.ualign
.type
== A_CHAOTIC
) {
1961 mtmp
->mpeaceful
= 1;
1963 } else { /* damn them */
1970 monflee(mtmp
, 0, FALSE
, TRUE
);
1976 nomul(-(5 - ((u
.ulevel
- 1) / 6))); /* -5 .. -1 */
1977 multi_reason
= "trying to turn the monsters";
1978 nomovemsg
= You_can_move_again
;
1985 return a_gname_at(u
.ux
, u
.uy
);
1988 /* returns the name of an altar's deity */
1993 if (!IS_ALTAR(levl
[x
][y
].typ
))
1996 return align_gname(a_align(x
, y
));
1999 /* returns the name of the hero's deity */
2003 return align_gname(u
.ualign
.type
);
2007 align_gname(alignment
)
2012 switch (alignment
) {
2026 impossible("unknown alignment.");
2035 static const char *hallu_gods
[] = {
2036 "the Flying Spaghetti Monster", /* Church of the FSM */
2037 "Eris", /* Discordianism */
2038 "the Martians", /* every science fiction ever */
2040 "AnDoR dRaKoN", /* ADOM */
2041 "the Central Bank of Yendor", /* economics */
2042 "Tooth Fairy", /* real world(?) */
2043 "Om", /* Discworld */
2044 "Yawgmoth", /* Magic: the Gathering */
2045 "Morgoth", /* LoTR */
2046 "Cthulhu", /* Lovecraft */
2047 "the Ori", /* Stargate */
2048 "destiny", /* why not? */
2049 "your Friend the Computer", /* Paranoia */
2052 /* hallucination handling for priest/minion names: select a random god
2053 iff character is hallucinating */
2055 halu_gname(alignment
)
2058 const char *gnam
= NULL
;
2062 return align_gname(alignment
);
2064 /* The priest may not have initialized god names. If this is the
2065 * case, and we roll priest, we need to try again. */
2068 while (!roles
[which
].lgod
);
2073 gnam
= roles
[which
].lgod
;
2077 gnam
= roles
[which
].ngod
;
2081 gnam
= roles
[which
].cgod
;
2085 gnam
= hallu_gods
[rn2(sizeof hallu_gods
/ sizeof *hallu_gods
)];
2091 impossible("rn2 broken in halu_gname?!?");
2094 impossible("No random god name?");
2095 gnam
= "your Friend the Computer"; /* Paranoia */
2104 align_gtitle(alignment
)
2107 const char *gnam
, *result
= "god";
2109 switch (alignment
) {
2123 if (gnam
&& *gnam
== '_')
2132 aligntyp altaralign
= a_align(x
, y
);
2134 if (!strcmp(align_gname(altaralign
), u_gname())) {
2135 godvoice(altaralign
, "How darest thou desecrate my altar!");
2136 (void) adjattrib(A_WIS
, -1, FALSE
);
2138 pline("A voice (could it be %s?) whispers:", align_gname(altaralign
));
2139 verbalize("Thou shalt pay, infidel!");
2144 /* assumes isok() at one space away, but not necessarily at two */
2146 blocked_boulder(dx
, dy
)
2149 register struct obj
*otmp
;
2152 for (otmp
= level
.objects
[u
.ux
+ dx
][u
.uy
+ dy
]; otmp
;
2153 otmp
= otmp
->nexthere
) {
2154 if (otmp
->otyp
== BOULDER
)
2155 count
+= otmp
->quan
;
2160 /* no boulders--not blocked */
2163 /* possibly blocked depending on if it's pushable */
2166 /* more than one boulder--blocked after they push the top one;
2167 don't force them to push it first to find out */
2171 if (!isok(u
.ux
+ 2 * dx
, u
.uy
+ 2 * dy
))
2173 if (IS_ROCK(levl
[u
.ux
+ 2 * dx
][u
.uy
+ 2 * dy
].typ
))
2175 if (sobj_at(BOULDER
, u
.ux
+ 2 * dx
, u
.uy
+ 2 * dy
))