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