Source:NetHack 3.4.3/src/pray.c

From NetHackWiki
(Redirected from Source:Ref/u gname)
Jump to: navigation, search

Below is the full text to src/pray.c from NetHack 3.4.3. To link to a particular line, write [[pray.c#line123]], for example.

Top of file

  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. */

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

  1. #include "hack.h"
  2. #include "epri.h"
  3.  
  4. STATIC_PTR int NDECL(prayer_done);
  5. STATIC_DCL struct obj *NDECL(worst_cursed_item);
  6. STATIC_DCL int NDECL(in_trouble);
  7. STATIC_DCL void FDECL(fix_worst_trouble,(int));
  8. STATIC_DCL void FDECL(angrygods,(ALIGNTYP_P));
  9. STATIC_DCL void FDECL(at_your_feet, (const char *));
  10. #ifdef ELBERETH
  11. STATIC_DCL void NDECL(gcrownu);
  12. #endif	/*ELBERETH*/
  13. STATIC_DCL void FDECL(pleased,(ALIGNTYP_P));
  14. STATIC_DCL void FDECL(godvoice,(ALIGNTYP_P,const char*));
  15. STATIC_DCL void FDECL(god_zaps_you,(ALIGNTYP_P));
  16. STATIC_DCL void FDECL(fry_by_god,(ALIGNTYP_P));
  17. STATIC_DCL void FDECL(gods_angry,(ALIGNTYP_P));
  18. STATIC_DCL void FDECL(gods_upset,(ALIGNTYP_P));
  19. STATIC_DCL void FDECL(consume_offering,(struct obj *));
  20. STATIC_DCL boolean FDECL(water_prayer,(BOOLEAN_P));
  21. STATIC_DCL boolean FDECL(blocked_boulder,(int,int));
  22.  
  23. /* simplify a few tests */
  24. #define Cursed_obj(obj,typ) ((obj) && (obj)->otyp == (typ) && (obj)->cursed)
  25.  
  26. /*
  27. * Logic behind deities and altars and such:
  28. * + prayers are made to your god if not on an altar, and to the altar's god
  29. *   if you are on an altar
  30. * + If possible, your god answers all prayers, which is why bad things happen
  31. *   if you try to pray on another god's altar
  32. * + sacrifices work basically the same way, but the other god may decide to
  33. *   accept your allegiance, after which they are your god.  If rejected,
  34. *   your god takes over with your punishment.
  35. * + if you're in Gehennom, all messages come from Moloch
  36. */
  37.  
  38. /*
  39. *	Moloch, who dwells in Gehennom, is the "renegade" cruel god
  40. *	responsible for the theft of the Amulet from Marduk, the Creator.
  41. *	Moloch is unaligned.
  42. */
  43. static const char	*Moloch = "Moloch";
  44.  
  45. static const char *godvoices[] = {
  46. "booms out",
  47. "thunders",
  48. "rings out",
  49. "booms",
  50. };
  51.  
  52. /* values calculated when prayer starts, and used when completed */
  53. static aligntyp p_aligntyp;
  54. static int p_trouble;
  55. static int p_type; /* (-1)-3: (-1)=really naughty, 3=really good */
  56.  
  57. #define PIOUS 20
  58. #define DEVOUT 14
  59. #define FERVENT 9
  60. #define STRIDENT 4
  61.  
  62. /*
  63. * The actual trouble priority is determined by the order of the
  64. * checks performed in in_trouble() rather than by these numeric
  65. * values, so keep that code and these values synchronized in
  66. * order to have the values be meaningful.
  67. */
  68.  
  69. #define TROUBLE_STONED			13
  70. #define TROUBLE_SLIMED			12
  71. #define TROUBLE_STRANGLED		11
  72. #define TROUBLE_LAVA			10
  73. #define TROUBLE_SICK			 9
  74. #define TROUBLE_STARVING		 8
  75. #define TROUBLE_HIT			 7
  76. #define TROUBLE_LYCANTHROPE		 6
  77. #define TROUBLE_COLLAPSING		 5
  78. #define TROUBLE_STUCK_IN_WALL		 4
  79. #define TROUBLE_CURSED_LEVITATION	 3
  80. #define TROUBLE_UNUSEABLE_HANDS		 2
  81. #define TROUBLE_CURSED_BLINDFOLD	 1
  82.  
  83. #define TROUBLE_PUNISHED	       (-1)
  84. #define TROUBLE_FUMBLING	       (-2)
  85. #define TROUBLE_CURSED_ITEMS	       (-3)
  86. #define TROUBLE_SADDLE		       (-4)
  87. #define TROUBLE_BLIND		       (-5)
  88. #define TROUBLE_POISONED	       (-6)
  89. #define TROUBLE_WOUNDED_LEGS	       (-7)
  90. #define TROUBLE_HUNGRY		       (-8)
  91. #define TROUBLE_STUNNED		       (-9)
  92. #define TROUBLE_CONFUSED	      (-10)
  93. #define TROUBLE_HALLUCINATION	      (-11)
  94.  
  95. /* We could force rehumanize of polyselfed people, but we can't tell
  96. unintentional shape changes from the other kind. Oh well.
  97. 3.4.2: make an exception if polymorphed into a form which lacks
  98. hands; that's a case where the ramifications override this doubt.
  99. */

in_trouble

  1. /* Return 0 if nothing particular seems wrong, positive numbers for
  2. serious trouble, and negative numbers for comparative annoyances. This
  3. returns the worst problem. There may be others, and the gods may fix
  4. more than one.
  5.  
  6. This could get as bizarre as noting surrounding opponents, (or hostile dogs),
  7. but that's really hard.
  8. */
  9.  
  10. #define ugod_is_angry() (u.ualign.record < 0)
  11. #define on_altar()	IS_ALTAR(levl[u.ux][u.uy].typ)
  12. #define on_shrine()	((levl[u.ux][u.uy].altarmask & AM_SHRINE) != 0)
  13. #define a_align(x,y)	((aligntyp)Amask2align(levl[x][y].altarmask & AM_MASK))
  14.  
  15. STATIC_OVL int
  16. in_trouble()
  17. {
  18. 	struct obj *otmp;
  19. 	int i, j, count=0;
  20.  
  21. /* Borrowed from eat.c */
  22.  
  23. #define SATIATED	0
  24. #define NOT_HUNGRY	1
  25. #define HUNGRY		2
  26. #define WEAK		3
  27. #define FAINTING	4
  28. #define FAINTED		5
  29. #define STARVED		6
  30.  
  31. 	/*
  32. 	 * major troubles
  33. 	 */
  34. 	if(Stoned) return(TROUBLE_STONED);
  35. 	if(Slimed) return(TROUBLE_SLIMED);
  36. 	if(Strangled) return(TROUBLE_STRANGLED);
  37. 	if(u.utrap && u.utraptype == TT_LAVA) return(TROUBLE_LAVA);
  38. 	if(Sick) return(TROUBLE_SICK);
  39. 	if(u.uhs >= WEAK) return(TROUBLE_STARVING);
  40. 	if (Upolyd ? (u.mh <= 5 || u.mh*7 <= u.mhmax) :
  41. 		(u.uhp <= 5 || u.uhp*7 <= u.uhpmax)) return TROUBLE_HIT;
  42. 	if(u.ulycn >= LOW_PM) return(TROUBLE_LYCANTHROPE);
  43. 	if(near_capacity() >= EXT_ENCUMBER && AMAX(A_STR)-ABASE(A_STR) > 3)
  44. 		return(TROUBLE_COLLAPSING);
  45.  
  46. 	for (i= -1; i<=1; i++) for(j= -1; j<=1; j++) {
  47. 		if (!i && !j) continue;
  48. 		if (!isok(u.ux+i, u.uy+j) || IS_ROCK(levl[u.ux+i][u.uy+j].typ)
  49. 		    || (blocked_boulder(i,j) && !throws_rocks(youmonst.data)))
  50. 			count++;
  51. 	}
  52. 	if (count == 8 && !Passes_walls)
  53. 		return(TROUBLE_STUCK_IN_WALL);
  54.  
  55. 	if (Cursed_obj(uarmf, LEVITATION_BOOTS) ||
  56. 		stuck_ring(uleft, RIN_LEVITATION) ||
  57. 		stuck_ring(uright, RIN_LEVITATION))
  58. 		return(TROUBLE_CURSED_LEVITATION);
  59. 	if (nohands(youmonst.data) || !freehand()) {
  60. 	    /* for bag/box access [cf use_container()]...
  61. 	       make sure it's a case that we know how to handle;
  62. 	       otherwise "fix all troubles" would get stuck in a loop */
  63. 	    if (welded(uwep)) return TROUBLE_UNUSEABLE_HANDS;
  64. 	    if (Upolyd && nohands(youmonst.data) && (!Unchanging ||
  65. 		    ((otmp = unchanger()) != 0 && otmp->cursed)))
  66. 		return TROUBLE_UNUSEABLE_HANDS;
  67. 	}
  68. 	if(Blindfolded && ublindf->cursed) return(TROUBLE_CURSED_BLINDFOLD);
  69.  
  70. 	/*
  71. 	 * minor troubles
  72. 	 */
  73. 	if(Punished) return(TROUBLE_PUNISHED);
  74. 	if (Cursed_obj(uarmg, GAUNTLETS_OF_FUMBLING) ||
  75. 		Cursed_obj(uarmf, FUMBLE_BOOTS))
  76. 	    return TROUBLE_FUMBLING;
  77. 	if (worst_cursed_item()) return TROUBLE_CURSED_ITEMS;
  78. #ifdef STEED
  79. 	if (u.usteed) {	/* can't voluntarily dismount from a cursed saddle */
  80. 	    otmp = which_armor(u.usteed, W_SADDLE);
  81. 	    if (Cursed_obj(otmp, SADDLE)) return TROUBLE_SADDLE;
  82. 	}
  83. #endif
  84.  
  85. 	if (Blinded > 1 && haseyes(youmonst.data)) return(TROUBLE_BLIND);
  86. 	for(i=0; i<A_MAX; i++)
  87. 	    if(ABASE(i) < AMAX(i)) return(TROUBLE_POISONED);
  88. 	if(Wounded_legs
  89. #ifdef STEED
  90. 		    && !u.usteed
  91. #endif
  92. 				) return (TROUBLE_WOUNDED_LEGS);
  93. 	if(u.uhs >= HUNGRY) return(TROUBLE_HUNGRY);
  94. 	if(HStun) return (TROUBLE_STUNNED);
  95. 	if(HConfusion) return (TROUBLE_CONFUSED);
  96. 	if(Hallucination) return(TROUBLE_HALLUCINATION);
  97. 	return(0);
  98. }

worst_cursed_item

  1. /* select an item for TROUBLE_CURSED_ITEMS */
  2. STATIC_OVL struct obj *
  3. worst_cursed_item()
  4. {
  5. register struct obj *otmp;
  6.  
  7. /* if strained or worse, check for loadstone first */
  8. if (near_capacity() >= HVY_ENCUMBER) {
  9. 	for (otmp = invent; otmp; otmp = otmp->nobj)
  10. 	    if (Cursed_obj(otmp, LOADSTONE)) return otmp;
  11. }
  12. /* weapon takes precedence if it is interfering
  13. with taking off a ring or putting on a shield */
  14. if (welded(uwep) && (uright || bimanual(uwep))) {	/* weapon */
  15. 	otmp = uwep;
  16. /* gloves come next, due to rings */
  17. } else if (uarmg && uarmg->cursed) {		/* gloves */
  18. 	otmp = uarmg;
  19. /* then shield due to two handed weapons and spells */
  20. } else if (uarms && uarms->cursed) {		/* shield */
  21. 	otmp = uarms;
  22. /* then cloak due to body armor */
  23. } else if (uarmc && uarmc->cursed) {		/* cloak */
  24. 	otmp = uarmc;
  25. } else if (uarm && uarm->cursed) {			/* suit */
  26. 	otmp = uarm;
  27. } else if (uarmh && uarmh->cursed) {		/* helmet */
  28. 	otmp = uarmh;
  29. } else if (uarmf && uarmf->cursed) {		/* boots */
  30. 	otmp = uarmf;
  31. #ifdef TOURIST
  32. } else if (uarmu && uarmu->cursed) {		/* shirt */
  33. 	otmp = uarmu;
  34. #endif
  35. } else if (uamul && uamul->cursed) {		/* amulet */
  36. 	otmp = uamul;
  37. } else if (uleft && uleft->cursed) {		/* left ring */
  38. 	otmp = uleft;
  39. } else if (uright && uright->cursed) {		/* right ring */
  40. 	otmp = uright;
  41. } else if (ublindf && ublindf->cursed) {		/* eyewear */
  42. 	otmp = ublindf;	/* must be non-blinding lenses */
  43. /* if weapon wasn't handled above, do it now */
  44. } else if (welded(uwep)) {				/* weapon */
  45. 	otmp = uwep;
  46. /* active secondary weapon even though it isn't welded */
  47. } else if (uswapwep && uswapwep->cursed && u.twoweap) {
  48. 	otmp = uswapwep;
  49. /* all worn items ought to be handled by now */
  50. } else {
  51. 	for (otmp = invent; otmp; otmp = otmp->nobj) {
  52. 	    if (!otmp->cursed) continue;
  53. 	    if (otmp->otyp == LOADSTONE || confers_luck(otmp))
  54. 		break;
  55. 	}
  56. }
  57. return otmp;
  58. }

fix_worst_trouble

  1. STATIC_OVL void
  2. fix_worst_trouble(trouble)
  3. register int trouble;
  4. {
  5. 	int i;
  6. 	struct obj *otmp = 0;
  7. 	const char *what = (const char *)0;
  8. 	static NEARDATA const char leftglow[] = "left ring softly glows",
  9. 				   rightglow[] = "right ring softly glows";
  10.  
  11. 	switch (trouble) {
  12. 	    case TROUBLE_STONED:
  13. 		    You_feel("more limber.");
  14. 		    Stoned = 0;
  15. 		    flags.botl = 1;
  16. 		    delayed_killer = 0;
  17. 		    break;
  18. 	    case TROUBLE_SLIMED:
  19. 		    pline_The("slime disappears.");
  20. 		    Slimed = 0;
  21. 		    flags.botl = 1;
  22. 		    delayed_killer = 0;
  23. 		    break;
  24. 	    case TROUBLE_STRANGLED:
  25. 		    if (uamul && uamul->otyp == AMULET_OF_STRANGULATION) {
  26. 			Your("amulet vanishes!");
  27. 			useup(uamul);
  28. 		    }
  29. 		    You("can breathe again.");
  30. 		    Strangled = 0;
  31. 		    flags.botl = 1;
  32. 		    break;
  33. 	    case TROUBLE_LAVA:
  34. 		    You("are back on solid ground.");
  35. 		    /* teleport should always succeed, but if not,
  36. 		     * just untrap them.
  37. 		     */
  38. 		    if(!safe_teleds(FALSE))
  39. 			u.utrap = 0;
  40. 		    break;
  41. 	    case TROUBLE_STARVING:
  42. 		    losestr(-1);
  43. 		    /* fall into... */
  44. 	    case TROUBLE_HUNGRY:
  45. 		    Your("%s feels content.", body_part(STOMACH));
  46. 		    init_uhunger();
  47. 		    flags.botl = 1;
  48. 		    break;
  49. 	    case TROUBLE_SICK:
  50. 		    You_feel("better.");
  51. 		    make_sick(0L, (char *) 0, FALSE, SICK_ALL);
  52. 		    break;
  53. 	    case TROUBLE_HIT:
  54. 		    /* "fix all troubles" will keep trying if hero has
  55. 		       5 or less hit points, so make sure they're always
  56. 		       boosted to be more than that */
  57. 		    You_feel("much better.");
  58. 		    if (Upolyd) {
  59. 			u.mhmax += rnd(5);
  60. 			if (u.mhmax <= 5) u.mhmax = 5+1;
  61. 			u.mh = u.mhmax;
  62. 		    }
  63. 		    if (u.uhpmax < u.ulevel * 5 + 11) u.uhpmax += rnd(5);
  64. 		    if (u.uhpmax <= 5) u.uhpmax = 5+1;
  65. 		    u.uhp = u.uhpmax;
  66. 		    flags.botl = 1;
  67. 		    break;
  68. 	    case TROUBLE_COLLAPSING:
  69. 		    ABASE(A_STR) = AMAX(A_STR);
  70. 		    flags.botl = 1;
  71. 		    break;
  72. 	    case TROUBLE_STUCK_IN_WALL:
  73. 		    Your("surroundings change.");
  74. 		    /* no control, but works on no-teleport levels */
  75. 		    (void) safe_teleds(FALSE);
  76. 		    break;
  77. 	    case TROUBLE_CURSED_LEVITATION:
  78. 		    if (Cursed_obj(uarmf, LEVITATION_BOOTS)) {
  79. 			otmp = uarmf;
  80. 		    } else if ((otmp = stuck_ring(uleft,RIN_LEVITATION)) !=0) {
  81. 			if (otmp == uleft) what = leftglow;
  82. 		    } else if ((otmp = stuck_ring(uright,RIN_LEVITATION))!=0) {
  83. 			if (otmp == uright) what = rightglow;
  84. 		    }
  85. 		    goto decurse;
  86. 	    case TROUBLE_UNUSEABLE_HANDS:
  87. 		    if (welded(uwep)) {
  88. 			otmp = uwep;
  89. 			goto decurse;
  90. 		    }
  91. 		    if (Upolyd && nohands(youmonst.data)) {
  92. 			if (!Unchanging) {
  93. 			    Your("shape becomes uncertain.");
  94. 			    rehumanize();  /* "You return to {normal} form." */
  95. 			} else if ((otmp = unchanger()) != 0 && otmp->cursed) {
  96. 			    /* otmp is an amulet of unchanging */
  97. 			    goto decurse;
  98. 			}
  99. 		    }
  100. 		    if (nohands(youmonst.data) || !freehand())
  101. 			impossible("fix_worst_trouble: couldn't cure hands.");
  102. 		    break;
  103. 	    case TROUBLE_CURSED_BLINDFOLD:
  104. 		    otmp = ublindf;
  105. 		    goto decurse;
  106. 	    case TROUBLE_LYCANTHROPE:
  107. 		    you_unwere(TRUE);
  108. 		    break;
  109. 	/*
  110. 	 */
  111. 	    case TROUBLE_PUNISHED:
  112. 		    Your("chain disappears.");
  113. 		    unpunish();
  114. 		    break;
  115. 	    case TROUBLE_FUMBLING:
  116. 		    if (Cursed_obj(uarmg, GAUNTLETS_OF_FUMBLING))
  117. 			otmp = uarmg;
  118. 		    else if (Cursed_obj(uarmf, FUMBLE_BOOTS))
  119. 			otmp = uarmf;
  120. 		    goto decurse;
  121. 		    /*NOTREACHED*/
  122. 		    break;
  123. 	    case TROUBLE_CURSED_ITEMS:
  124. 		    otmp = worst_cursed_item();
  125. 		    if (otmp == uright) what = rightglow;
  126. 		    else if (otmp == uleft) what = leftglow;
  127. decurse:
  128. 		    if (!otmp) {
  129. 			impossible("fix_worst_trouble: nothing to uncurse.");
  130. 			return;
  131. 		    }
  132. 		    uncurse(otmp);
  133. 		    if (!Blind) {
  134. 			Your("%s %s.", what ? what :
  135. 				(const char *)aobjnam(otmp, "softly glow"),
  136. 			     hcolor(NH_AMBER));
  137. 			otmp->bknown = TRUE;
  138. 		    }
  139. 		    update_inventory();
  140. 		    break;
  141. 	    case TROUBLE_POISONED:
  142. 		    if (Hallucination)
  143. 			pline("There's a tiger in your tank.");
  144. 		    else
  145. 			You_feel("in good health again.");
  146. 		    for(i=0; i<A_MAX; i++) {
  147. 			if(ABASE(i) < AMAX(i)) {
  148. 				ABASE(i) = AMAX(i);
  149. 				flags.botl = 1;
  150. 			}
  151. 		    }
  152. 		    (void) encumber_msg();
  153. 		    break;
  154. 	    case TROUBLE_BLIND:
  155. 		{
  156. 		    int num_eyes = eyecount(youmonst.data);
  157. 		    const char *eye = body_part(EYE);
  158.  
  159. 		    Your("%s feel%s better.",
  160. 			 (num_eyes == 1) ? eye : makeplural(eye),
  161. 			 (num_eyes == 1) ? "s" : "");
  162. 		    u.ucreamed = 0;
  163. 		    make_blinded(0L,FALSE);
  164. 		    break;
  165. 		}
  166. 	    case TROUBLE_WOUNDED_LEGS:
  167. 		    heal_legs();
  168. 		    break;
  169. 	    case TROUBLE_STUNNED:
  170. 		    make_stunned(0L,TRUE);
  171. 		    break;
  172. 	    case TROUBLE_CONFUSED:
  173. 		    make_confused(0L,TRUE);
  174. 		    break;
  175. 	    case TROUBLE_HALLUCINATION:
  176. 		    pline ("Looks like you are back in Kansas.");
  177. 		    (void) make_hallucinated(0L,FALSE,0L);
  178. 		    break;
  179. #ifdef STEED
  180. 	    case TROUBLE_SADDLE:
  181. 		    otmp = which_armor(u.usteed, W_SADDLE);
  182. 		    uncurse(otmp);
  183. 		    if (!Blind) {
  184. 			pline("%s %s %s.",
  185. 			      s_suffix(upstart(y_monnam(u.usteed))),
  186. 			      aobjnam(otmp, "softly glow"),
  187. 			      hcolor(NH_AMBER));
  188. 			otmp->bknown = TRUE;
  189. 		    }
  190. 		    break;
  191. #endif
  192. 	}
  193. }

god_zaps_you

  1. /* "I am sometimes shocked by...  the nuns who never take a bath without
  2. * wearing a bathrobe all the time.  When asked why, since no man can see them,
  3. * they reply 'Oh, but you forget the good God'.  Apparently they conceive of
  4. * the Deity as a Peeping Tom, whose omnipotence enables Him to see through
  5. * bathroom walls, but who is foiled by bathrobes." --Bertrand Russell, 1943
  6. * Divine wrath, dungeon walls, and armor follow the same principle.
  7. */
  8. STATIC_OVL void
  9. god_zaps_you(resp_god)
  10. aligntyp resp_god;
  11. {
  12. 	if (u.uswallow) {
  13. 	    pline("Suddenly a bolt of lightning comes down at you from the heavens!");
  14. 	    pline("It strikes %s!", mon_nam(u.ustuck));
  15. 	    if (!resists_elec(u.ustuck)) {
  16. 		pline("%s fries to a crisp!", Monnam(u.ustuck));
  17. 		/* Yup, you get experience.  It takes guts to successfully
  18. 		 * pull off this trick on your god, anyway.
  19. 		 */
  20. 		xkilled(u.ustuck, 0);
  21. 	    } else
  22. 		pline("%s seems unaffected.", Monnam(u.ustuck));
  23. 	} else {
  24. 	    pline("Suddenly, a bolt of lightning strikes you!");
  25. 	    if (Reflecting) {
  26. 		shieldeff(u.ux, u.uy);
  27. 		if (Blind)
  28. 		    pline("For some reason you're unaffected.");
  29. 		else
  30. 		    (void) ureflects("%s reflects from your %s.", "It");
  31. 	    } else if (Shock_resistance) {
  32. 		shieldeff(u.ux, u.uy);
  33. 		pline("It seems not to affect you.");
  34. 	    } else
  35. 		fry_by_god(resp_god);
  36. 	}
  37.  
  38. 	pline("%s is not deterred...", align_gname(resp_god));
  39. 	if (u.uswallow) {
  40. 	    pline("A wide-angle disintegration beam aimed at you hits %s!",
  41. 			mon_nam(u.ustuck));
  42. 	    if (!resists_disint(u.ustuck)) {
  43. 		pline("%s fries to a crisp!", Monnam(u.ustuck));
  44. 		xkilled(u.ustuck, 2); /* no corpse */
  45. 	    } else
  46. 		pline("%s seems unaffected.", Monnam(u.ustuck));
  47. 	} else {
  48. 	    pline("A wide-angle disintegration beam hits you!");
  49.  
  50. 	    /* disintegrate shield and body armor before disintegrating
  51. 	     * the impudent mortal, like black dragon breath -3.
  52. 	     */
  53. 	    if (uarms && !(EReflecting & W_ARMS) &&
  54. 	    		!(EDisint_resistance & W_ARMS))
  55. 		(void) destroy_arm(uarms);
  56. 	    if (uarmc && !(EReflecting & W_ARMC) &&
  57. 	    		!(EDisint_resistance & W_ARMC))
  58. 		(void) destroy_arm(uarmc);
  59. 	    if (uarm && !(EReflecting & W_ARM) &&
  60. 	    		!(EDisint_resistance & W_ARM) && !uarmc)
  61. 		(void) destroy_arm(uarm);
  62. #ifdef TOURIST
  63. 	    if (uarmu && !uarm && !uarmc) (void) destroy_arm(uarmu);
  64. #endif
  65. 	    if (!Disint_resistance)
  66. 		fry_by_god(resp_god);
  67. 	    else {
  68. 		You("bask in its %s glow for a minute...", NH_BLACK);
  69. 		godvoice(resp_god, "I believe it not!");
  70. 	    }
  71. 	    if (Is_astralevel(&u.uz) || Is_sanctum(&u.uz)) {
  72. 		/* one more try for high altars */
  73. 		verbalize("Thou cannot escape my wrath, mortal!");
  74. 		summon_minion(resp_god, FALSE);
  75. 		summon_minion(resp_god, FALSE);
  76. 		summon_minion(resp_god, FALSE);
  77. 		verbalize("Destroy %s, my servants!", uhim());
  78. 	    }
  79. 	}
  80. }

fry_by_god

  1. STATIC_OVL void
  2. fry_by_god(resp_god)
  3. aligntyp resp_god;
  4. {
  5. 	char killerbuf[64];
  6.  
  7. 	You("fry to a crisp.");
  8. 	killer_format = KILLED_BY;
  9. 	Sprintf(killerbuf, "the wrath of %s", align_gname(resp_god));
  10. 	killer = killerbuf;
  11. 	done(DIED);
  12. }

angrygods

  1. STATIC_OVL void
  2. angrygods(resp_god)
  3. aligntyp resp_god;
  4. {
  5. 	register int	maxanger;
  6.  
  7. 	if(Inhell) resp_god = A_NONE;
  8. 	u.ublessed = 0;
  9.  
  10. 	/* changed from tmp = u.ugangr + abs (u.uluck) -- rph */
  11. 	/* added test for alignment diff -dlc */
  12. 	if(resp_god != u.ualign.type)
  13. 	    maxanger =  u.ualign.record/2 + (Luck > 0 ? -Luck/3 : -Luck);
  14. 	else
  15. 	    maxanger =  3*u.ugangr +
  16. 		((Luck > 0 || u.ualign.record >= STRIDENT) ? -Luck/3 : -Luck);
  17. 	if (maxanger < 1) maxanger = 1; /* possible if bad align & good luck */
  18. 	else if (maxanger > 15) maxanger = 15;	/* be reasonable */
  19.  
  20. 	switch (rn2(maxanger)) {
  21. 	    case 0:
  22. 	    case 1:	You_feel("that %s is %s.", align_gname(resp_god),
  23. 			    Hallucination ? "bummed" : "displeased");
  24. 			break;
  25. 	    case 2:
  26. 	    case 3:
  27. 			godvoice(resp_god,(char *)0);
  28. 			pline("\"Thou %s, %s.\"",
  29. 			    (ugod_is_angry() && resp_god == u.ualign.type)
  30. 				? "hast strayed from the path" :
  31. 						"art arrogant",
  32. 			      youmonst.data->mlet == S_HUMAN ? "mortal" : "creature");
  33. 			verbalize("Thou must relearn thy lessons!");
  34. 			(void) adjattrib(A_WIS, -1, FALSE);
  35. 			losexp((char *)0);
  36. 			break;
  37. 	    case 6:	if (!Punished) {
  38. 			    gods_angry(resp_god);
  39. 			    punish((struct obj *)0);
  40. 			    break;
  41. 			} /* else fall thru */
  42. 	    case 4:
  43. 	    case 5:	gods_angry(resp_god);
  44. 			if (!Blind && !Antimagic)
  45. 			    pline("%s glow surrounds you.",
  46. 				  An(hcolor(NH_BLACK)));
  47. 			rndcurse();
  48. 			break;
  49. 	    case 7:
  50. 	    case 8:	godvoice(resp_god,(char *)0);
  51. 			verbalize("Thou durst %s me?",
  52. 				  (on_altar() &&
  53. 				   (a_align(u.ux,u.uy) != resp_god)) ?
  54. 				  "scorn":"call upon");
  55. 			pline("\"Then die, %s!\"",
  56. 			      youmonst.data->mlet == S_HUMAN ? "mortal" : "creature");
  57. 			summon_minion(resp_god, FALSE);
  58. 			break;
  59.  
  60. 	    default:	gods_angry(resp_god);
  61. 			god_zaps_you(resp_god);
  62. 			break;
  63. 	}
  64. 	u.ublesscnt = rnz(300);
  65. 	return;
  66. }

at_your_feet

  1. /* helper to print "str appears at your feet", or appropriate */
  2. static void
  3. at_your_feet(str)
  4. 	const char *str;
  5. {
  6. 	if (Blind) str = Something;
  7. 	if (u.uswallow) {
  8. 	    /* barrier between you and the floor */
  9. 	    pline("%s %s into %s %s.", str, vtense(str, "drop"),
  10. 		  s_suffix(mon_nam(u.ustuck)), mbodypart(u.ustuck, STOMACH));
  11. 	} else {
  12. 	    pline("%s %s %s your %s!", str,
  13. 		  Blind ? "lands" : vtense(str, "appear"),
  14. 		  Levitation ? "beneath" : "at",
  15. 		  makeplural(body_part(FOOT)));
  16. 	}
  17. }
  18.  
  19. #ifdef ELBERETH

gcrownu

  1. STATIC_OVL void
  2. gcrownu()
  3. {
  4. struct obj *obj;
  5. boolean already_exists, in_hand;
  6. short class_gift;
  7. int sp_no;
  8. #define ok_wep(o) ((o) && ((o)->oclass == WEAPON_CLASS || is_weptool(o)))
  9.  
  10. HSee_invisible |= FROMOUTSIDE;
  11. HFire_resistance |= FROMOUTSIDE;
  12. HCold_resistance |= FROMOUTSIDE;
  13. HShock_resistance |= FROMOUTSIDE;
  14. HSleep_resistance |= FROMOUTSIDE;
  15. HPoison_resistance |= FROMOUTSIDE;
  16. godvoice(u.ualign.type, (char *)0);
  17.  
  18. obj = ok_wep(uwep) ? uwep : 0;
  19. already_exists = in_hand = FALSE;	/* lint suppression */
  20. switch (u.ualign.type) {
  21. case A_LAWFUL:
  22. 	u.uevent.uhand_of_elbereth = 1;
  23. 	verbalize("I crown thee...  The Hand of Elbereth!");
  24. 	break;
  25. case A_NEUTRAL:
  26. 	u.uevent.uhand_of_elbereth = 2;
  27. 	in_hand = (uwep && uwep->oartifact == ART_VORPAL_BLADE);
  28. 	already_exists = exist_artifact(LONG_SWORD, artiname(ART_VORPAL_BLADE));
  29. 	verbalize("Thou shalt be my Envoy of Balance!");
  30. 	break;
  31. case A_CHAOTIC:
  32. 	u.uevent.uhand_of_elbereth = 3;
  33. 	in_hand = (uwep && uwep->oartifact == ART_STORMBRINGER);
  34. 	already_exists = exist_artifact(RUNESWORD, artiname(ART_STORMBRINGER));
  35. 	verbalize("Thou art chosen to %s for My Glory!",
  36. 		  already_exists && !in_hand ? "take lives" : "steal souls");
  37. 	break;
  38. }
  39.  
  40. class_gift = STRANGE_OBJECT;
  41. /* 3.3.[01] had this in the A_NEUTRAL case below,
  42. preventing chaotic wizards from receiving a spellbook */
  43. if (Role_if(PM_WIZARD) &&
  44. 	    (!uwep || (uwep->oartifact != ART_VORPAL_BLADE &&
  45. 		       uwep->oartifact != ART_STORMBRINGER)) &&
  46. 	    !carrying(SPE_FINGER_OF_DEATH)) {
  47. 	class_gift = SPE_FINGER_OF_DEATH;
  48. make_splbk:
  49. 	obj = mksobj(class_gift, TRUE, FALSE);
  50. 	bless(obj);
  51. 	obj->bknown = TRUE;
  52. 	at_your_feet("A spellbook");
  53. 	dropy(obj);
  54. 	u.ugifts++;
  55. 	/* when getting a new book for known spell, enhance
  56. 	   currently wielded weapon rather than the book */
  57. 	for (sp_no = 0; sp_no < MAXSPELL; sp_no++)
  58. 	    if (spl_book[sp_no].sp_id == class_gift) {
  59. 		if (ok_wep(uwep)) obj = uwep;	/* to be blessed,&c */
  60. 		break;
  61. 	    }
  62. } else if (Role_if(PM_MONK) &&
  63. 	    (!uwep || !uwep->oartifact) &&
  64. 	    !carrying(SPE_RESTORE_ABILITY)) {
  65. 	/* monks rarely wield a weapon */
  66. 	class_gift = SPE_RESTORE_ABILITY;
  67. 	goto make_splbk;
  68. }
  69.  
  70. switch (u.ualign.type) {
  71. case A_LAWFUL:
  72. 	if (class_gift != STRANGE_OBJECT) {
  73. 	    ;		/* already got bonus above */
  74. 	} else if (obj && obj->otyp == LONG_SWORD && !obj->oartifact) {
  75. 	    if (!Blind) Your("sword shines brightly for a moment.");
  76. 	    obj = oname(obj, artiname(ART_EXCALIBUR));
  77. 	    if (obj && obj->oartifact == ART_EXCALIBUR) u.ugifts++;
  78. 	}
  79. 	/* acquire Excalibur's skill regardless of weapon or gift */
  80. 	unrestrict_weapon_skill(P_LONG_SWORD);
  81. 	if (obj && obj->oartifact == ART_EXCALIBUR)
  82. 	    discover_artifact(ART_EXCALIBUR);
  83. 	break;
  84. case A_NEUTRAL:
  85. 	if (class_gift != STRANGE_OBJECT) {
  86. 	    ;		/* already got bonus above */
  87. 	} else if (in_hand) {
  88. 	    Your("%s goes snicker-snack!", xname(obj));
  89. 	    obj->dknown = TRUE;
  90. 	} else if (!already_exists) {
  91. 	    obj = mksobj(LONG_SWORD, FALSE, FALSE);
  92. 	    obj = oname(obj, artiname(ART_VORPAL_BLADE));
  93. 	    obj->spe = 1;
  94. 	    at_your_feet("A sword");
  95. 	    dropy(obj);
  96. 	    u.ugifts++;
  97. 	}
  98. 	/* acquire Vorpal Blade's skill regardless of weapon or gift */
  99. 	unrestrict_weapon_skill(P_LONG_SWORD);
  100. 	if (obj && obj->oartifact == ART_VORPAL_BLADE)
  101. 	    discover_artifact(ART_VORPAL_BLADE);
  102. 	break;
  103. case A_CHAOTIC:
  104. {
  105. 	char swordbuf[BUFSZ];
  106.  
  107. 	Sprintf(swordbuf, "%s sword", hcolor(NH_BLACK));
  108. 	if (class_gift != STRANGE_OBJECT) {
  109. 	    ;		/* already got bonus above */
  110. 	} else if (in_hand) {
  111. 	    Your("%s hums ominously!", swordbuf);
  112. 	    obj->dknown = TRUE;
  113. 	} else if (!already_exists) {
  114. 	    obj = mksobj(RUNESWORD, FALSE, FALSE);
  115. 	    obj = oname(obj, artiname(ART_STORMBRINGER));
  116. 	    at_your_feet(An(swordbuf));
  117. 	    obj->spe = 1;
  118. 	    dropy(obj);
  119. 	    u.ugifts++;
  120. 	}
  121. 	/* acquire Stormbringer's skill regardless of weapon or gift */
  122. 	unrestrict_weapon_skill(P_BROAD_SWORD);
  123. 	if (obj && obj->oartifact == ART_STORMBRINGER)
  124. 	    discover_artifact(ART_STORMBRINGER);
  125. 	break;
  126. }
  127. default:
  128. 	obj = 0;	/* lint */
  129. 	break;
  130. }
  131.  
  132. /* enhance weapon regardless of alignment or artifact status */
  133. if (ok_wep(obj)) {
  134. 	bless(obj);
  135. 	obj->oeroded = obj->oeroded2 = 0;
  136. 	obj->oerodeproof = TRUE;
  137. 	obj->bknown = obj->rknown = TRUE;
  138. 	if (obj->spe < 1) obj->spe = 1;
  139. 	/* acquire skill in this weapon */
  140. 	unrestrict_weapon_skill(weapon_type(obj));
  141. } else if (class_gift == STRANGE_OBJECT) {
  142. 	/* opportunity knocked, but there was nobody home... */
  143. 	You_feel("unworthy.");
  144. }
  145. update_inventory();
  146. return;
  147. }
  148. #endif	/*ELBERETH*/

pleased

  1. STATIC_OVL void
  2. pleased(g_align)
  3. 	aligntyp g_align;
  4. {
  5. 	/* don't use p_trouble, worst trouble may get fixed while praying */
  6. 	int trouble = in_trouble();	/* what's your worst difficulty? */
  7. 	int pat_on_head = 0, kick_on_butt;
  8.  
  9. 	You_feel("that %s is %s.", align_gname(g_align),
  10. 	    u.ualign.record >= DEVOUT ?
  11. 	    Hallucination ? "pleased as punch" : "well-pleased" :
  12. 	    u.ualign.record >= STRIDENT ?
  13. 	    Hallucination ? "ticklish" : "pleased" :
  14. 	    Hallucination ? "full" : "satisfied");
  15.  
  16. 	/* not your deity */
  17. 	if (on_altar() && p_aligntyp != u.ualign.type) {
  18. 		adjalign(-1);
  19. 		return;
  20. 	} else if (u.ualign.record < 2 && trouble <= 0) adjalign(1);
  21.  
  22. 	/* depending on your luck & align level, the god you prayed to will:
  23. 	   - fix your worst problem if it's major.
  24. 	   - fix all your major problems.
  25. 	   - fix your worst problem if it's minor.
  26. 	   - fix all of your problems.
  27. 	   - do you a gratuitous favor.
  28.  
  29. 	   if you make it to the the last category, you roll randomly again
  30. 	   to see what they do for you.
  31.  
  32. 	   If your luck is at least 0, then you are guaranteed rescued
  33. 	   from your worst major problem. */
  34.  
  35. 	if (!trouble && u.ualign.record >= DEVOUT) {
  36. 	    /* if hero was in trouble, but got better, no special favor */
  37. 	    if (p_trouble == 0) pat_on_head = 1;
  38. 	} else {
  39. 	    int action = rn1(Luck + (on_altar() ? 3 + on_shrine() : 2), 1);
  40.  
  41. 	    if (!on_altar()) action = min(action, 3);
  42. 	    if (u.ualign.record < STRIDENT)
  43. 		action = (u.ualign.record > 0 || !rnl(2)) ? 1 : 0;
  44.  
  45. 	    switch(min(action,5)) {
  46. 	    case 5: pat_on_head = 1;
  47. 	    case 4: do fix_worst_trouble(trouble);
  48. 		    while ((trouble = in_trouble()) != 0);
  49. 		    break;
  50.  
  51. 	    case 3: fix_worst_trouble(trouble);
  52. 	    case 2: while ((trouble = in_trouble()) > 0)
  53. 		    fix_worst_trouble(trouble);
  54. 		    break;
  55.  
  56. 	    case 1: if (trouble > 0) fix_worst_trouble(trouble);
  57. 	    case 0: break; /* your god blows you off, too bad */
  58. 	    }
  59. 	}
  60.  
  61. /* note: can't get pat_on_head unless all troubles have just been
  62. fixed or there were no troubles to begin with; hallucination
  63. won't be in effect so special handling for it is superfluous */
  64. if(pat_on_head)
  65. 	switch(rn2((Luck + 6)>>1)) {
  66. 	case 0:	break;
  67. 	case 1:
  68. 	    if (uwep && (welded(uwep) || uwep->oclass == WEAPON_CLASS ||
  69. 			 is_weptool(uwep))) {
  70. 		char repair_buf[BUFSZ];
  71.  
  72. 		*repair_buf = '\0';
  73. 		if (uwep->oeroded || uwep->oeroded2)
  74. 		    Sprintf(repair_buf, " and %s now as good as new",
  75. 			    otense(uwep, "are"));
  76.  
  77. 		if (uwep->cursed) {
  78. 		    uncurse(uwep);
  79. 		    uwep->bknown = TRUE;
  80. 		    if (!Blind)
  81. 			Your("%s %s%s.", aobjnam(uwep, "softly glow"),
  82. 			     hcolor(NH_AMBER), repair_buf);
  83. 		    else You_feel("the power of %s over your %s.",
  84. 			u_gname(), xname(uwep));
  85. 		    *repair_buf = '\0';
  86. 		} else if (!uwep->blessed) {
  87. 		    bless(uwep);
  88. 		    uwep->bknown = TRUE;
  89. 		    if (!Blind)
  90. 			Your("%s with %s aura%s.",
  91. 			     aobjnam(uwep, "softly glow"),
  92. 			     an(hcolor(NH_LIGHT_BLUE)), repair_buf);
  93. 		    else You_feel("the blessing of %s over your %s.",
  94. 			u_gname(), xname(uwep));
  95. 		    *repair_buf = '\0';
  96. 		}
  97.  
  98. 		/* fix any rust/burn/rot damage, but don't protect
  99. 		   against future damage */
  100. 		if (uwep->oeroded || uwep->oeroded2) {
  101. 		    uwep->oeroded = uwep->oeroded2 = 0;
  102. 		    /* only give this message if we didn't just bless
  103. 		       or uncurse (which has already given a message) */
  104. 		    if (*repair_buf)
  105. 			Your("%s as good as new!",
  106. 			     aobjnam(uwep, Blind ? "feel" : "look"));
  107. 		}
  108. 		update_inventory();
  109. 	    }
  110. 	    break;
  111. 	case 3:
  112. 	    /* takes 2 hints to get the music to enter the stronghold */
  113. 	    if (!u.uevent.uopened_dbridge) {
  114. 		if (u.uevent.uheard_tune < 1) {
  115. 		    godvoice(g_align,(char *)0);
  116. 		    verbalize("Hark, %s!",
  117. 			  youmonst.data->mlet == S_HUMAN ? "mortal" : "creature");
  118. 		    verbalize(
  119. 			"To enter the castle, thou must play the right tune!");
  120. 		    u.uevent.uheard_tune++;
  121. 		    break;
  122. 		} else if (u.uevent.uheard_tune < 2) {
  123. 		    You_hear("a divine music...");
  124. 		    pline("It sounds like:  \"%s\".", tune);
  125. 		    u.uevent.uheard_tune++;
  126. 		    break;
  127. 		}
  128. 	    }
  129. 	    /* Otherwise, falls into next case */
  130. 	case 2:
  131. 	    if (!Blind)
  132. 		You("are surrounded by %s glow.", an(hcolor(NH_GOLDEN)));
  133. 	    /* if any levels have been lost (and not yet regained),
  134. 	       treat this effect like blessed full healing */
  135. 	    if (u.ulevel < u.ulevelmax) {
  136. 		u.ulevelmax -= 1;	/* see potion.c */
  137. 		pluslvl(FALSE);
  138. 	    } else {
  139. 		u.uhpmax += 5;
  140. 		if (Upolyd) u.mhmax += 5;
  141. 	    }
  142. 	    u.uhp = u.uhpmax;
  143. 	    if (Upolyd) u.mh = u.mhmax;
  144. 	    ABASE(A_STR) = AMAX(A_STR);
  145. 	    if (u.uhunger < 900) init_uhunger();
  146. 	    if (u.uluck < 0) u.uluck = 0;
  147. 	    make_blinded(0L,TRUE);
  148. 	    flags.botl = 1;
  149. 	    break;
  150. 	case 4: {
  151. 	    register struct obj *otmp;
  152. 	    int any = 0;
  153.  
  154. 	    if (Blind)
  155. 		You_feel("the power of %s.", u_gname());
  156. 	    else You("are surrounded by %s aura.",
  157. 		     an(hcolor(NH_LIGHT_BLUE)));
  158. 	    for(otmp=invent; otmp; otmp=otmp->nobj) {
  159. 		if (otmp->cursed) {
  160. 		    uncurse(otmp);
  161. 		    if (!Blind) {
  162. 			Your("%s %s.", aobjnam(otmp, "softly glow"),
  163. 			     hcolor(NH_AMBER));
  164. 			otmp->bknown = TRUE;
  165. 			++any;
  166. 		    }
  167. 		}
  168. 	    }
  169. 	    if (any) update_inventory();
  170. 	    break;
  171. 	}
  172. 	case 5: {
  173. 	    const char *msg="\"and thus I grant thee the gift of %s!\"";
  174. 	    godvoice(u.ualign.type, "Thou hast pleased me with thy progress,");
  175. 	    if (!(HTelepat & INTRINSIC))  {
  176. 		HTelepat |= FROMOUTSIDE;
  177. 		pline(msg, "Telepathy");
  178. 		if (Blind) see_monsters();
  179. 	    } else if (!(HFast & INTRINSIC))  {
  180. 		HFast |= FROMOUTSIDE;
  181. 		pline(msg, "Speed");
  182. 	    } else if (!(HStealth & INTRINSIC))  {
  183. 		HStealth |= FROMOUTSIDE;
  184. 		pline(msg, "Stealth");
  185. 	    } else {
  186. 		if (!(HProtection & INTRINSIC))  {
  187. 		    HProtection |= FROMOUTSIDE;
  188. 		    if (!u.ublessed)  u.ublessed = rn1(3, 2);
  189. 		} else u.ublessed++;
  190. 		pline(msg, "my protection");
  191. 	    }
  192. 	    verbalize("Use it wisely in my name!");
  193. 	    break;
  194. 	}
  195. 	case 7:
  196. 	case 8:
  197. 	case 9:		/* KMH -- can occur during full moons */
  198. #ifdef ELBERETH
  199. 	    if (u.ualign.record >= PIOUS && !u.uevent.uhand_of_elbereth) {
  200. 		gcrownu();
  201. 		break;
  202. 	    } /* else FALLTHRU */
  203. #endif	/*ELBERETH*/
  204. 	case 6:	{
  205. 	    struct obj *otmp;
  206. 	    int sp_no, trycnt = u.ulevel + 1;
  207.  
  208. 	    at_your_feet("An object");
  209. 	    /* not yet known spells given preference over already known ones */
  210. 	    /* Also, try to grant a spell for which there is a skill slot */
  211. 	    otmp = mkobj(SPBOOK_CLASS, TRUE);
  212. 	    while (--trycnt > 0) {
  213. 		if (otmp->otyp != SPE_BLANK_PAPER) {
  214. 		    for (sp_no = 0; sp_no < MAXSPELL; sp_no++)
  215. 			if (spl_book[sp_no].sp_id == otmp->otyp) break;
  216. 		    if (sp_no == MAXSPELL &&
  217. 			!P_RESTRICTED(spell_skilltype(otmp->otyp)))
  218. 			break;	/* usable, but not yet known */
  219. 		} else {
  220. 		    if (!objects[SPE_BLANK_PAPER].oc_name_known ||
  221. 			    carrying(MAGIC_MARKER)) break;
  222. 		}
  223. 		otmp->otyp = rnd_class(bases[SPBOOK_CLASS], SPE_BLANK_PAPER);
  224. 	    }
  225. 	    bless(otmp);
  226. 	    place_object(otmp, u.ux, u.uy);
  227. 	    break;
  228. 	}
  229. 	default:	impossible("Confused deity!");
  230. 	    break;
  231. 	}
  232.  
  233. 	u.ublesscnt = rnz(350);
  234. 	kick_on_butt = u.uevent.udemigod ? 1 : 0;
  235. #ifdef ELBERETH
  236. 	if (u.uevent.uhand_of_elbereth) kick_on_butt++;
  237. #endif
  238. 	if (kick_on_butt) u.ublesscnt += kick_on_butt * rnz(1000);
  239.  
  240. 	return;
  241. }

water_prayer

  1. /* either blesses or curses water on the altar,
  2. * returns true if it found any water here.
  3. */
  4. STATIC_OVL boolean
  5. water_prayer(bless_water)
  6. boolean bless_water;
  7. {
  8. register struct obj* otmp;
  9. register long changed = 0;
  10. boolean other = FALSE, bc_known = !(Blind || Hallucination);
  11.  
  12. for(otmp = level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere) {
  13. 	/* turn water into (un)holy water */
  14. 	if (otmp->otyp == POT_WATER &&
  15. 		(bless_water ? !otmp->blessed : !otmp->cursed)) {
  16. 	    otmp->blessed = bless_water;
  17. 	    otmp->cursed = !bless_water;
  18. 	    otmp->bknown = bc_known;
  19. 	    changed += otmp->quan;
  20. 	} else if(otmp->oclass == POTION_CLASS)
  21. 	    other = TRUE;
  22. }
  23. if(!Blind && changed) {
  24. 	pline("%s potion%s on the altar glow%s %s for a moment.",
  25. 	      ((other && changed > 1L) ? "Some of the" :
  26. 					(other ? "One of the" : "The")),
  27. 	      ((other || changed > 1L) ? "s" : ""), (changed > 1L ? "" : "s"),
  28. 	      (bless_water ? hcolor(NH_LIGHT_BLUE) : hcolor(NH_BLACK)));
  29. }
  30. return((boolean)(changed > 0L));
  31. }

godvoice

  1. STATIC_OVL void
  2. godvoice(g_align, words)
  3. aligntyp g_align;
  4. const char *words;
  5. {
  6. const char *quot = "";
  7. if(words)
  8. 	quot = "\"";
  9. else
  10. 	words = "";
  11.  
  12. pline_The("voice of %s %s: %s%s%s", align_gname(g_align),
  13. 	  godvoices[rn2(SIZE(godvoices))], quot, words, quot);
  14. }
  15.  
  16. STATIC_OVL void
  17. gods_angry(g_align)
  18. aligntyp g_align;
  19. {
  20. godvoice(g_align, "Thou hast angered me.");
  21. }
  22.  
  23. /* The g_align god is upset with you. */
  24. STATIC_OVL void
  25. gods_upset(g_align)
  26. 	aligntyp g_align;
  27. {
  28. 	if(g_align == u.ualign.type) u.ugangr++;
  29. 	else if(u.ugangr) u.ugangr--;
  30. 	angrygods(g_align);
  31. }
  32.  
  33. static NEARDATA const char sacrifice_types[] = { FOOD_CLASS, AMULET_CLASS, 0 };

consume_offering

  1. STATIC_OVL void
  2. consume_offering(otmp)
  3. register struct obj *otmp;
  4. {
  5. if (Hallucination)
  6. 	switch (rn2(3)) {
  7. 	    case 0:
  8. 		Your("sacrifice sprouts wings and a propeller and roars away!");
  9. 		break;
  10. 	    case 1:
  11. 		Your("sacrifice puffs up, swelling bigger and bigger, and pops!");
  12. 		break;
  13. 	    case 2:
  14. 		Your("sacrifice collapses into a cloud of dancing particles and fades away!");
  15. 		break;
  16. 	}
  17. else if (Blind && u.ualign.type == A_LAWFUL)
  18. 	Your("sacrifice disappears!");
  19. else Your("sacrifice is consumed in a %s!",
  20. 	      u.ualign.type == A_LAWFUL ? "flash of light" : "burst of flame");
  21. if (carried(otmp)) useup(otmp);
  22. else useupf(otmp, 1L);
  23. exercise(A_WIS, TRUE);
  24. }

dosacrifice

  1. int
  2. dosacrifice()
  3. {
  4. register struct obj *otmp;
  5. int value = 0;
  6. int pm;
  7. aligntyp altaralign = a_align(u.ux,u.uy);
  8.  
  9. if (!on_altar() || u.uswallow) {
  10. You("are not standing on an altar.");
  11. return 0;
  12. }
  13.  
  14. if (In_endgame(&u.uz)) {
  15. if (!(otmp = getobj(sacrifice_types, "sacrifice"))) return 0;
  16. } else {
  17. if (!(otmp = floorfood("sacrifice", 1))) return 0;
  18. }
  19. /*
  20. Was based on nutritional value and aging behavior (< 50 moves).
  21. Sacrificing a food ration got you max luck instantly, making the
  22. gods as easy to please as an angry dog!
  23.  
  24. Now only accepts corpses, based on the game's evaluation of their
  25. toughness.  Human and pet sacrifice, as well as sacrificing unicorns
  26. of your alignment, is strongly discouraged.
  27. */
  28.  
  29. #define MAXVALUE 24 /* Highest corpse value (besides Wiz) */
  30.  
  31. if (otmp->otyp == CORPSE) {
  32. register struct permonst *ptr = &mons[otmp->corpsenm];
  33. struct monst *mtmp;
  34. extern const int monstr[];
  35.  
  36. /* KMH, conduct */
  37. u.uconduct.gnostic++;

Obviously, you're no longer an atheist.

  1. /* you're handling this corpse, even if it was killed upon the altar */
  2. feel_cockatrice(otmp, TRUE);

Cockatrices will kill you if you aren't careful!

  1. if (otmp->corpsenm == PM_ACID_BLOB
  2. || (monstermoves <= peek_at_iced_corpse_age(otmp) + 50)) {
  3. value = monstr[otmp->corpsenm] + 1;
  4. if (otmp->oeaten)
  5. value = eaten_stat(value, otmp);
  6. }

The value of a monster is given by monstr[otmp->corpsenm] + 1, which if the monster difficulty level from monst.c; it is also the number that determines which monsters the RNG generates. If it's partially eaten, that's multiplied by (roughly) the percentage remaining. If it's more than fifty moves old, adjusted for ice, it's worthless, unless it's an acid blob. These never expire (although they may, of course, rot).

  1.  

Sacrificing your own race

Note that your_race() apparently returns true based on your actual race, which you chose at the start of the game. Thus polymorphing will not change your race for this purpose.

  1. if (your_race(ptr)) {
  2. if (is_demon(youmonst.data)) {
  3. You("find the idea very satisfying.");
  4. exercise(A_WIS, TRUE);
  5. } else if (u.ualign.type != A_CHAOTIC) {
  6. pline("You'll regret this infamous offense!");
  7. exercise(A_WIS, FALSE);
  8. }

Demons exercise wisdom by sacrificing their own race. Non-chaotic characters will abuse it. Chaotic non-demons do neither.

  1. if (altaralign != A_CHAOTIC && altaralign != A_NONE) {
  2. /* curse the lawful/neutral altar */
  3. pline_The("altar is stained with %s blood.", urace.adj);
  4. if(!Is_astralevel(&u.uz))
  5. levl[u.ux][u.uy].altarmask = AM_CHAOTIC;
  6. angry_priest();

A lawful or neutral altar will immediately be converted to chaos (outside the astral level). This will, obviously, anger any attendant priests.

  1. } else {
  2. struct monst *dmon;
  3. const char *demonless_msg;
  4.  
  5. /* Human sacrifice on a chaotic or unaligned altar */
  6. /* is equivalent to demon summoning */
  7. if (altaralign == A_CHAOTIC && u.ualign.type != A_CHAOTIC) {
  8. pline(
  9. "The blood floods the altar, which vanishes in %s cloud!",
  10. an(hcolor(NH_BLACK)));
  11. levl[u.ux][u.uy].typ = ROOM;
  12. levl[u.ux][u.uy].altarmask = 0;
  13. newsym(u.ux, u.uy);
  14. angry_priest();
  15. demonless_msg = "cloud dissipates";
  16. } else {
  17. /* either you're chaotic or altar is Moloch's or both */
  18. pline_The("blood covers the altar!");
  19. change_luck(altaralign == A_NONE ? -2 : 2);
  20. demonless_msg = "blood coagulates";
  21. }

If the altar is Moloch's, you lose two luck. If you're chaotic and the altar is chaotic (i.e., not Moloch's), you gain two. If it's not Moloch's altar and you're not chaotic, your luck is unaffected (so far), but you've destroyed the altar and angered the priest. Thus any attempt by a non-chaotic character to sacrifice a character of their own race will anger the priest, if any, except at Moloch's altar.

  1. if ((pm = dlord(altaralign)) != NON_PM &&
  2. (dmon = makemon(&mons[pm], u.ux, u.uy, NO_MM_FLAGS))) {
  3. You("have summoned %s!", a_monnam(dmon));
  4. if (sgn(u.ualign.type) == sgn(dmon->data->maligntyp))
  5. dmon->mpeaceful = TRUE;
  6. You("are terrified, and unable to move.");
  7. nomul(-3);
  8. } else pline_The("%s.", demonless_msg);
  9. }

A random demon lord between Juiblex and Yeenoghu inclusive is chosen up to 20 times, in an attempt to find one that has not been created already. Unless the altar is unaligned, the alignment of the demon lord must match the alignment of the altar. Currently, Yeenoghu follows Juiblex in monst.c. Thus only these two demon lords are eligible to appear. They are both chaotic.

Otherwise a random demon is chosen up to 20 times, respecting extinction and with the same alignment requirements.

If there is space for it adjacent to you, the chosen demon appears, peaceful if it matches your alignment and hostile otherwise. Three turns pass. If no matching demon is found, none appears.

  1. if (u.ualign.type != A_CHAOTIC) {
  2. adjalign(-5);
  3. u.ugangr += 3;
  4. (void) adjattrib(A_WIS, -1, TRUE);
  5. if (!Inhell) angrygods(u.ualign.type);
  6. change_luck(-5);
  7. } else adjalign(5);
  8. if (carried(otmp)) useup(otmp);
  9. else useupf(otmp, 1L);
  10. return(1);

If you aren't chaotic, you lose 5 alignment, your god's anger increases by three, your wisdom decreases by one point, your luck decreases by 5, and unless you're in Gehennom, your god potentially punishes you as for praying too much. If you are chaotic, instead your alignment increases by 5. The corpse disappears, and nothing more happens for the case of sacrificing a creature of your own race. The value of the sacrifice (calculated immediately preceding this section) is ignored, so sacrificing a rotten corpse of your own race (e.g. from a zombie of your race) has the same effect as sacrificing a fresh one.

Sacrificing pets

  1. } else if (otmp->oxlth && otmp->oattached == OATTACHED_MONST
  2. && ((mtmp = get_mtraits(otmp, FALSE)) != (struct monst *)0)
  3. && mtmp->mtame) {
  4. /* mtmp is a temporary pointer to a tame monster's attributes,
  5. * not a real monster */
  6. pline("So this is how you repay loyalty?");
  7. adjalign(-3);
  8. value = -1;
  9. HAggravate_monster |= FROMOUTSIDE;

If you try to sacrifice a pet, you lose three alignment and gain the aggravate monster intrinsic. The pet's corpse has a value of -1. This does not apply if the pet is of your own race, in which case the code doesn't reach this point (bug?).

Yes, that entire conditional is to see if it's a former pet's corpse. In order, it does the following: (Note that if any step returns false, the if fails immediately and the remaining steps are not executed, which prevents lots of nasty invalid pointer dereferencing)

1. Does the object have extra data? (oxlth is "Object eXtra data LengTH") 2. Is the extra data that of a monster? 3. Get a pointer to an object containing the traits of that monster and put it in a temporary variable 4. Is the pointer non-null? 5. Was the monster tame?

Sacrificing undead

  1. } else if (is_undead(ptr)) { /* Not demons--no demon corpses */
  2. if (u.ualign.type != A_CHAOTIC)
  3. value += 1;

The corpse of an undead creature has an additional +1 value for non-chaotic characters.

Sacrificing unicorns

  1. } else if (is_unicorn(ptr)) {
  2. int unicalign = sgn(ptr->maligntyp);
  3.  
  4. /* If same as altar, always a very bad action. */
  5. if (unicalign == altaralign) {
  6. pline("Such an action is an insult to %s!",
  7. (unicalign == A_CHAOTIC)
  8. ? "chaos" : unicalign ? "law" : "balance");
  9. (void) adjattrib(A_WIS, -1, TRUE);
  10. value = -5;
  11. } else if (u.ualign.type == altaralign) {
  12. /* If different from altar, and altar is same as yours, */
  13. /* it's a very good action */
  14. if (u.ualign.record < ALIGNLIM)
  15. You_feel("appropriately %s.", align_str(u.ualign.type));
  16. else You_feel("you are thoroughly on the right path.");
  17. adjalign(5);
  18. value += 3;
  19. } else
  20. /* If sacrificing unicorn of your alignment to altar not of */
  21. /* your alignment, your god gets angry and it's a conversion */
  22. if (unicalign == u.ualign.type) {
  23. u.ualign.record = -1;
  24. value = 1;
  25. } else value += 3;

Sacrificing a unicorn on an altar aligned with it will set its sacrifice value to -5 and reduce your wisdom by 1. But sacrificing a non-aligned unicorn on a coaligned altar gives you +5 alignment, and gives it +3 value. Sacrificing a unicorn of your alignment on an altar not of your alignment sets the value to one and your alignment to -1 (actually worse than sacrificing on a coaligned altar). Finally, sacrificing a unicorn not aligned with either you or the altar increases its value by 3 and has no other effects.

  1. }
  2. } /* corpse */

Sacrificing the Amulet of Yendor

  1. if (otmp->otyp == AMULET_OF_YENDOR) {
  2. if (!Is_astralevel(&u.uz)) {
  3. if (Hallucination)
  4. You_feel("homesick.");
  5. else
  6. You_feel("an urge to return to the surface.");
  7. return 1;

This code is supposed to give a hint if you try to sacrifice the Amulet of Yendor on an ordinary altar in the dungeon; however, it seems it can never run, because floorfood() (called on line 1135 above) won't let the player even select the amulet for sacrifice. (All you get if you try is "You don't have anything to sacrifice," or, if also carrying a corpse and selecting the amulet instead, "That is a silly thing to sacrifice.") The message above can be triggered in wizard mode by wishing for an altar on the elemental planes (other than Astral) and trying to sacrifice the amulet there, but no altars are normally generated on those levels.

  1. } else {
  2. /* The final Test.    Did you win? */
  3. if(uamul == otmp) Amulet_off();
  4. u.uevent.ascended = 1;
  5. if(carried(otmp)) useup(otmp); /* well, it's gone now */
  6. else useupf(otmp, 1L);
  7. You("offer the Amulet of Yendor to %s...", a_gname());
  8. if (u.ualign.type != altaralign) {
  9. /* And the opposing team picks you up and
  10. carries you off on their shoulders */
  11. adjalign(-99);
  12. pline("%s accepts your gift, and gains dominion over %s...",
  13. a_gname(), u_gname());
  14. pline("%s is enraged...", u_gname());
  15. pline("Fortunately, %s permits you to live...", a_gname());
  16. pline("A cloud of %s smoke surrounds you...",
  17. hcolor((const char *)"orange"));
  18. done(ESCAPED);

You sacrificed the Amulet on the wrong altar, and so escaped the Dungeon "in celestial disgrace".

  1. } else { /* super big win */
  2. adjalign(10);
  3. pline("An invisible choir sings, and you are bathed in radiance...");
  4. godvoice(altaralign, "Congratulations, mortal!");
  5. display_nhwindow(WIN_MESSAGE, FALSE);
  6. verbalize("In return for thy service, I grant thee the gift of Immortality!");
  7. You("ascend to the status of Demigod%s...",
  8. flags.female ? "dess" : "");
  9. done(ASCENDED);
  10. }
  11. }
  12. } /* real Amulet */

You ascended. Congrats, welcome to the demigod bar.

  1. if (otmp->otyp == FAKE_AMULET_OF_YENDOR) {
  2. if (flags.soundok)
  3. You_hear("a nearby thunderclap.");
  4. if (!otmp->known) {
  5. You("realize you have made a %s.",
  6. Hallucination ? "boo-boo" : "mistake");
  7. otmp->known = TRUE;
  8. change_luck(-1);
  9. return 1;

Sacrificing a fake Amulet: if un-ID'd, you simply lose 1 luck.

  1. } else {
  2. /* don't you dare try to fool the gods */
  3. change_luck(-3);
  4. adjalign(-1);
  5. u.ugangr += 3;
  6. value = -3;
  7. }
  8. } /* fake Amulet */

Offering a known fake amulet, however, costs you 3 luck and 1 alignment; and angers your god.

Worthless sacrifice

  1. if (value == 0) {
  2. pline(nothing_happens);
  3. return (1);
  4. }

If the value is zero, "nothing happens".

  1.  

Converting altars

  1. if (altaralign != u.ualign.type &&
  2. (Is_astralevel(&u.uz) || Is_sanctum(&u.uz))) {
  3. /*
  4. * REAL BAD NEWS!!! High altars cannot be converted.  Even an attempt
  5. * gets the god who owns it truely pissed off.
  6. */
  7. You_feel("the air around you grow charged...");
  8. pline("Suddenly, you realize that %s has noticed you...", a_gname());
  9. godvoice(altaralign, "So, mortal!  You dare desecrate my High Temple!");
  10. /* Throw everything we have at the player */
  11. god_zaps_you(altaralign);
  12. } else if (value < 0) { /* I don't think the gods are gonna like this... */
  13. gods_upset(altaralign);
  14. } else {
  15. int saved_anger = u.ugangr;
  16. int saved_cnt = u.ublesscnt;
  17. int saved_luck = u.uluck;

Altars on the Astral Plane cannot be converted.

  1. /* Sacrificing at an altar of a different alignment */
  2. if (u.ualign.type != altaralign) {
  3. /* Is this a conversion ? */
  4. /* An unaligned altar in Gehennom will always elicit rejection. */
  5. if (ugod_is_angry() || (altaralign == A_NONE && Inhell)) {
  6. if(u.ualignbase[A_CURRENT] == u.ualignbase[A_ORIGINAL] &&
  7. altaralign != A_NONE) {
  8. You("have a strong feeling that %s is angry...", u_gname());
  9. consume_offering(otmp);
  10. pline("%s accepts your allegiance.", a_gname());

Your alignment record was negative, and you converted your alignment to that of the altar. (Note: this cannot happen on an altar to Moloch.)

  1. /* The player wears a helm of opposite alignment? */
  2. if (uarmh && uarmh->otyp == HELM_OF_OPPOSITE_ALIGNMENT)
  3. u.ualignbase[A_CURRENT] = altaralign;

Handle conversion whilst wearing a Helm of opposite alignment.

  1. else
  2. u.ualign.type = u.ualignbase[A_CURRENT] = altaralign;
  3. u.ublessed = 0;
  4. flags.botl = 1;
  5.  
  6. You("have a sudden sense of a new direction.");
  7. /* Beware, Conversion is costly */
  8. change_luck(-3);
  9. u.ublesscnt += 300;
  10. adjalign((int)(u.ualignbase[A_ORIGINAL] * (ALIGNLIM / 2)));

Whether wearing the Helm or not, you lose 3 luck, half your alignment record and any intrinsic protection; and your prayer timeout is increased.

  1. } else {
  2. u.ugangr += 3;
  3. adjalign(-5);
  4. pline("%s rejects your sacrifice!", a_gname());
  5. godvoice(altaralign, "Suffer, infidel!");
  6. change_luck(-5);
  7. (void) adjattrib(A_WIS, -2, TRUE);
  8. if (!Inhell) angrygods(u.ualign.type);
  9. }
  10. return(1);

Attempting to convert yourself a second time will anger your god. This code also handles attempted sacrifice to Moloch, which is always rejected.

  1. } else {
  2. consume_offering(otmp);
  3. You("sense a conflict between %s and %s.",
  4. u_gname(), a_gname());
  5. if (rn2(8 + u.ulevel) > 5) {
  6. struct monst *pri;
  7. You_feel("the power of %s increase.", u_gname());
  8. exercise(A_WIS, TRUE);
  9. change_luck(1);
  10. /* Yes, this is supposed to be &=, not |= */
  11. levl[u.ux][u.uy].altarmask &= AM_SHRINE;
  12. /* the following accommodates stupid compilers */
  13. levl[u.ux][u.uy].altarmask =
  14. levl[u.ux][u.uy].altarmask | (Align2amask(u.ualign.type));
  15. if (!Blind)
  16. pline_The("altar glows %s.",
  17. hcolor(
  18. u.ualign.type == A_LAWFUL ? NH_WHITE :
  19. u.ualign.type ? NH_BLACK : (const char *)"gray"));

Otherwise, attempt to convert the altar. If successful (random number between 0 and level+8 is greater than 5), you get +1 luck and exercise wisdom...

  1. if (rnl(u.ulevel) > 6 && u.ualign.record > 0 &&
  2. rnd(u.ualign.record) > (3*ALIGNLIM)/4)
  3. summon_minion(altaralign, TRUE);
  4. /* anger priest; test handles bones files */
  5. if((pri = findpriest(temple_occupied(u.urooms))) &&
  6. !p_coaligned(pri))
  7. angry_priest();

... but may summon a random minion of the altar's original god, and will anger any attendant priest.

  1. } else {
  2. pline("Unluckily, you feel the power of %s decrease.",
  3. u_gname());
  4. change_luck(-1);
  5. exercise(A_WIS, FALSE);
  6. if (rnl(u.ulevel) > 6 && u.ualign.record > 0 &&
  7. rnd(u.ualign.record) > (7*ALIGNLIM)/8)
  8. summon_minion(altaralign, TRUE);
  9. }
  10. return(1);

Failed conversion results in -1 luck and abusing wisdom, and may still summon a minion.

  1. }
  2. }

Normal, successful offering

  1. consume_offering(otmp);
  2. /* OK, you get brownie points. */
  3. if(u.ugangr) {
  4. u.ugangr -=
  5. ((value * (u.ualign.type == A_CHAOTIC ? 2 : 3)) / MAXVALUE);
  6. if(u.ugangr < 0) u.ugangr = 0;

If your god is angry, their anger is reduced by 1/12 the value of the sacrifice (rounded down) if chaotic, and 1/8 of its value if lawful or neutral. If this would reduce it below 0; set it to 0 instead.

  1. if(u.ugangr != saved_anger) {
  2. if (u.ugangr) {
  3. pline("%s seems %s.", u_gname(),
  4. Hallucination ? "groovy" : "slightly mollified");
  5.  
  6. if ((int)u.uluck < 0) change_luck(1);

The sacrifice has reduced your god's anger, but it is not yet zero. If your luck is negative, increase it by one point.

  1. } else {
  2. pline("%s seems %s.", u_gname(), Hallucination ?
  3. "cosmic (not a new fact)" : "mollified");
  4.  
  5. if ((int)u.uluck < 0) u.uluck = 0;
  6. }

The sacrifice has reduced your god's anger to zero. If your luck is negative, it is also set to zero.

  1. } else { /* not satisfied yet */
  2. if (Hallucination)
  3. pline_The("gods seem tall.");
  4. else You("have a feeling of inadequacy.");
  5. }

The sacrifice has not affected your god's anger.

  1. } else if(ugod_is_angry()) {
  2. if(value > MAXVALUE) value = MAXVALUE;
  3. if(value > -u.ualign.record) value = -u.ualign.record;
  4. adjalign(value);
  5. You_feel("partially absolved.");

Your god was not angry, but your alignment is negative. It is increased by the least of:

  • The value of the sacrifice,
  • 24 points, or
  • To zero.
  1. } else if (u.ublesscnt > 0) {
  2. u.ublesscnt -=
  3. ((value * (u.ualign.type == A_CHAOTIC ? 500 : 300)) / MAXVALUE);
  4. if(u.ublesscnt < 0) u.ublesscnt = 0;

Your god was not angry and your alignment is at least zero, but your prayer timeout has not yet expired. Reduce it by 20.83 times the value of the sacrifice (again, rounded down) if chaotic, or 12.5 times its value otherwise. If this would reduce it to 0; set it to 0 instead.

  1. if(u.ublesscnt != saved_cnt) {
  2. if (u.ublesscnt) {
  3. if (Hallucination)
  4. You("realize that the gods are not like you and I.");
  5. else
  6. You("have a hopeful feeling.");
  7. if ((int)u.uluck < 0) change_luck(1);

The sacrifice has reduced your prayer timeout, but it is not yet zero. Your luck is increased by one if negative, but you may not yet pray.

  1. } else {
  2. if (Hallucination)
  3. pline("Overall, there is a smell of fried onions.");
  4. else
  5. You("have a feeling of reconciliation.");
  6. if ((int)u.uluck < 0) u.uluck = 0;

Your prayer timeout has been reduced to zero by the sacrifice. Your luck is set to zero if negative, and it is safe to pray.

  1. }
  2. }
  3. } else {
  4. int nartifacts = nartifact_exist();
  5.  
  6. /* you were already in pretty good standing */
  7. /* The player can gain an artifact */
  8. /* The chance goes down as the number of artifacts goes up */
  9. if (u.ulevel > 2 && u.uluck >= 0 &&
  10. !rn2(10 + (2 * u.ugifts * nartifacts))) {
  11. otmp = mk_artifact((struct obj *)0, a_align(u.ux,u.uy));
  12. if (otmp) {
  13. if (otmp->spe < 0) otmp->spe = 0;
  14. if (otmp->cursed) uncurse(otmp);
  15. otmp->oerodeproof = TRUE;
  16. dropy(otmp);
  17. at_your_feet(";An object");
  18. godvoice(u.ualign.type, "Use my gift wisely!");
  19. u.ugifts++;
  20. u.ublesscnt = rnz(300 + (50 * nartifacts));
  21. exercise(A_WIS, TRUE);
  22. /* make sure we can use this weapon */
  23. unrestrict_weapon_skill(weapon_type(otmp));
  24. discover_artifact(otmp->oartifact);
  25. return(1);
  26. }
  27. }

If you are in generally good standing, have non-negative Luck, and are at least level 3, you may get an artifact as a gift. The odds of this decrease with both the number of artifacts already existing and the number of gifts previously granted.

The artifact you receive is guaranteed to be non-cursed, erodeproof, and have a non-negative enchantment; you will be unrestricted in the needed weapon skill if necessary; and your wisdom is exercised. Your prayer timeout is reset to rnz(300 + 50 * number of artifacts already existing).

  1. change_luck((value * LUCKMAX) / (MAXVALUE * 2));
  2. if ((int)u.uluck < 0) u.uluck = 0;
  3. if (u.uluck != saved_luck) {
  4. if (Blind)
  5. You("think %s brushed your %s.",something, body_part(FOOT));
  6. else You(Hallucination ?
  7. "see crabgrass at your %s.  A funny thing in a dungeon." :
  8. "glimpse a four-leaf clover at your %s.",
  9. makeplural(body_part(FOOT)));
  10. }
  11. }
  12. }
  13. return(1);
  14. }

If none of the other cases apply, your luck is increased by 10/48 of the value of the sacrifice (again, rounded down), and set to zero if it is still negative after this.

can_pray

  1. /* determine prayer results in advance; also used for enlightenment */
  2. boolean
  3. can_pray(praying)
  4. boolean praying;	/* false means no messages should be given */
  5. {
  6. int alignment;
  7.  
  8. p_aligntyp = on_altar() ? a_align(u.ux,u.uy) : u.ualign.type;
  9. p_trouble = in_trouble();
  10.  
  11. if (is_demon(youmonst.data) && (p_aligntyp != A_CHAOTIC)) {
  12. 	if (praying)
  13. 	    pline_The("very idea of praying to a %s god is repugnant to you.",
  14. 		  p_aligntyp ? "lawful" : "neutral");
  15. 	return FALSE;
  16. }
  17.  
  18. if (praying)
  19. 	You("begin praying to %s.", align_gname(p_aligntyp));
  20.  
  21. if (u.ualign.type && u.ualign.type == -p_aligntyp)
  22. 	alignment = -u.ualign.record;		/* Opposite alignment altar */
  23. else if (u.ualign.type != p_aligntyp)
  24. 	alignment = u.ualign.record / 2;	/* Different alignment altar */
  25. else alignment = u.ualign.record;
  26.  
  27. if ((p_trouble > 0) ? (u.ublesscnt > 200) : /* big trouble */
  28. 	(p_trouble < 0) ? (u.ublesscnt > 100) : /* minor difficulties */
  29. 	(u.ublesscnt > 0))			/* not in trouble */
  30. 	p_type = 0;		/* too soon... */
  31. else if ((int)Luck < 0 || u.ugangr || alignment < 0)
  32. 	p_type = 1;		/* too naughty... */
  33. else /* alignment >= 0 */ {
  34. 	if(on_altar() && u.ualign.type != p_aligntyp)
  35. 	    p_type = 2;
  36. 	else
  37. 	    p_type = 3;
  38. }
  39.  
  40. if (is_undead(youmonst.data) && !Inhell &&
  41. 	(p_aligntyp == A_LAWFUL || (p_aligntyp == A_NEUTRAL && !rn2(10))))
  42. 	p_type = -1;
  43. /* Note:  when !praying, the random factor for neutrals makes the
  44. return value a non-deterministic approximation for enlightenment.
  45. This case should be uncommon enough to live with... */
  46.  
  47. return !praying ? (boolean)(p_type == 3 && !Inhell) : TRUE;
  48. }

dopray

  1. int
  2. dopray()
  3. {
  4. /* Confirm accidental slips of Alt-P */
  5. if (flags.prayconfirm)
  6. 	if (yn("Are you sure you want to pray?") == 'n')
  7. 	    return 0;
  8.  
  9. u.uconduct.gnostic++;
  10. /* Praying implies that the hero is conscious and since we have
  11. no deafness attribute this implies that all verbalized messages
  12. can be heard.  So, in case the player has used the 'O' command
  13. to toggle this accessible flag off, force it to be on. */
  14. flags.soundok = 1;
  15.  
  16. /* set up p_type and p_alignment */
  17. if (!can_pray(TRUE)) return 0;
  18.  
  19. #ifdef WIZARD
  20. if (wizard && p_type >= 0) {
  21. 	if (yn("Force the gods to be pleased?") == 'y') {
  22. 	    u.ublesscnt = 0;
  23. 	    if (u.uluck < 0) u.uluck = 0;
  24. 	    if (u.ualign.record <= 0) u.ualign.record = 1;
  25. 	    u.ugangr = 0;
  26. 	    if(p_type < 2) p_type = 3;
  27. 	}
  28. }
  29. #endif
  30. nomul(-3);
  31. nomovemsg = "You finish your prayer.";
  32. afternmv = prayer_done;
  33.  
  34. if(p_type == 3 && !Inhell) {
  35. 	/* if you've been true to your god you can't die while you pray */
  36. 	if (!Blind)
  37. 	    You("are surrounded by a shimmering light.");
  38. 	u.uinvulnerable = TRUE;
  39. }
  40.  
  41. return(1);
  42. }

prayer_done

  1. STATIC_PTR int
  2. prayer_done()		/* M. Stephenson (1.0.3b) */
  3. {
  4. aligntyp alignment = p_aligntyp;
  5.  
  6. u.uinvulnerable = FALSE;
  7. if(p_type == -1) {
  8. 	godvoice(alignment,
  9. 		 alignment == A_LAWFUL ?
  10. 		 "Vile creature, thou durst call upon me?" :
  11. 		 "Walk no more, perversion of nature!");
  12. 	You_feel("like you are falling apart.");
  13. 	/* KMH -- Gods have mastery over unchanging */
  14. 	rehumanize();
  15. 	losehp(rnd(20), "residual undead turning effect", KILLED_BY_AN);
  16. 	exercise(A_CON, FALSE);
  17. 	return(1);
  18. }
  19. if (Inhell) {
  20. 	pline("Since you are in Gehennom, %s won't help you.",
  21. 	      align_gname(alignment));
  22. 	/* haltingly aligned is least likely to anger */
  23. 	if (u.ualign.record <= 0 || rnl(u.ualign.record))
  24. 	    angrygods(u.ualign.type);
  25. 	return(0);
  26. }
  27.  
  28. if (p_type == 0) {
  29. 	if(on_altar() && u.ualign.type != alignment)
  30. 	    (void) water_prayer(FALSE);
  31. 	u.ublesscnt += rnz(250);
  32. 	change_luck(-3);
  33. 	gods_upset(u.ualign.type);
  34. } else if(p_type == 1) {
  35. 	if(on_altar() && u.ualign.type != alignment)
  36. 	    (void) water_prayer(FALSE);
  37. 	angrygods(u.ualign.type);	/* naughty */
  38. } else if(p_type == 2) {
  39. 	if(water_prayer(FALSE)) {
  40. 	    /* attempted water prayer on a non-coaligned altar */
  41. 	    u.ublesscnt += rnz(250);
  42. 	    change_luck(-3);
  43. 	    gods_upset(u.ualign.type);
  44. 	} else pleased(alignment);
  45. } else {
  46. 	/* coaligned */
  47. 	if(on_altar())
  48. 	    (void) water_prayer(TRUE);
  49. 	pleased(alignment); /* nice */
  50. }
  51. return(1);
  52. }

doturn

  1. int
  2. doturn()
  3. {	/* Knights & Priest(esse)s only please */
  4.  
  5. 	struct monst *mtmp, *mtmp2;
  6. 	int once, range, xlev;
  7.  
  8. 	if (!Role_if(PM_PRIEST) && !Role_if(PM_KNIGHT)) {
  9. 		/* Try to use turn undead spell. */
  10. 		if (objects[SPE_TURN_UNDEAD].oc_name_known) {
  11. 		    register int sp_no;
  12. 		    for (sp_no = 0; sp_no < MAXSPELL &&
  13. 			 spl_book[sp_no].sp_id != NO_SPELL &&
  14. 			 spl_book[sp_no].sp_id != SPE_TURN_UNDEAD; sp_no++);
  15.  
  16. 		    if (sp_no < MAXSPELL &&
  17. 			spl_book[sp_no].sp_id == SPE_TURN_UNDEAD)
  18. 			    return spelleffects(sp_no, TRUE);
  19. 		}
  20.  
  21. 		You("don't know how to turn undead!");
  22. 		return(0);
  23. 	}
  24. 	u.uconduct.gnostic++;
  25.  
  26. 	if ((u.ualign.type != A_CHAOTIC &&
  27. 		    (is_demon(youmonst.data) || is_undead(youmonst.data))) ||
  28. 				u.ugangr > 6 /* "Die, mortal!" */) {
  29.  
  30. 		pline("For some reason, %s seems to ignore you.", u_gname());
  31. 		aggravate();
  32. 		exercise(A_WIS, FALSE);
  33. 		return(0);
  34. 	}
  35.  
  36. 	if (Inhell) {
  37. 	    pline("Since you are in Gehennom, %s won't help you.", u_gname());
  38. 	    aggravate();
  39. 	    return(0);
  40. 	}
  41. 	pline("Calling upon %s, you chant an arcane formula.", u_gname());
  42. 	exercise(A_WIS, TRUE);
  43.  
  44. 	/* note: does not perform unturn_dead() on victims' inventories */
  45. 	range = BOLT_LIM + (u.ulevel / 5);	/* 5 to 11 */
  46. 	range *= range;
  47. 	once = 0;
  48. 	for(mtmp = fmon; mtmp; mtmp = mtmp2) {
  49. 	    mtmp2 = mtmp->nmon;
  50.  
  51. 	    if (DEADMONSTER(mtmp)) continue;
  52. 	    if (!cansee(mtmp->mx,mtmp->my) ||
  53. 		distu(mtmp->mx,mtmp->my) > range) continue;
  54.  
  55. 	    if (!mtmp->mpeaceful && (is_undead(mtmp->data) ||
  56. 		   (is_demon(mtmp->data) && (u.ulevel > (MAXULEV/2))))) {
  57.  
  58. 		    mtmp->msleeping = 0;
  59. 		    if (Confusion) {
  60. 			if (!once++)
  61. 			    pline("Unfortunately, your voice falters.");
  62. 			mtmp->mflee = 0;
  63. 			mtmp->mfrozen = 0;
  64. 			mtmp->mcanmove = 1;
  65. 		    } else if (!resist(mtmp, '\0', 0, TELL)) {
  66. 			xlev = 6;
  67. 			switch (mtmp->data->mlet) {
  68. 			    /* this is intentional, lichs are tougher
  69. 			       than zombies. */
  70. 			case S_LICH:    xlev += 2;  /*FALLTHRU*/
  71. 			case S_GHOST:   xlev += 2;  /*FALLTHRU*/
  72. 			case S_VAMPIRE: xlev += 2;  /*FALLTHRU*/
  73. 			case S_WRAITH:  xlev += 2;  /*FALLTHRU*/
  74. 			case S_MUMMY:   xlev += 2;  /*FALLTHRU*/
  75. 			case S_ZOMBIE:
  76. 			    if (u.ulevel >= xlev &&
  77. 				    !resist(mtmp, '\0', 0, NOTELL)) {
  78. 				if (u.ualign.type == A_CHAOTIC) {
  79. 				    mtmp->mpeaceful = 1;
  80. 				    set_malign(mtmp);
  81. 				} else { /* damn them */
  82. 				    killed(mtmp);
  83. 				}
  84. 				break;
  85. 			    } /* else flee */
  86. 			    /*FALLTHRU*/
  87. 			default:
  88. 			    monflee(mtmp, 0, FALSE, TRUE);
  89. 			    break;
  90. 			}
  91. 		    }
  92. 	    }
  93. 	}
  94. 	nomul(-5);
  95. 	return(1);
  96. }

a_gname

  1. const char *
  2. a_gname()
  3. {
  4. return(a_gname_at(u.ux, u.uy));
  5. }

a_gname_at

  1. const char *
  2. a_gname_at(x,y)     /* returns the name of an altar's deity */
  3. xchar x, y;
  4. {
  5. if(!IS_ALTAR(levl[x][y].typ)) return((char *)0);
  6.  
  7. return align_gname(a_align(x,y));
  8. }

u_gname

  1. const char *
  2. u_gname()  /* returns the name of the player's deity */
  3. {
  4. return align_gname(u.ualign.type);
  5. }

align_gname

  1. const char *
  2. align_gname(alignment)
  3. aligntyp alignment;
  4. {
  5. const char *gnam;
  6.  
  7. switch (alignment) {
  8. case A_NONE:	gnam = Moloch; break;
  9. case A_LAWFUL:	gnam = urole.lgod; break;
  10. case A_NEUTRAL:	gnam = urole.ngod; break;
  11. case A_CHAOTIC:	gnam = urole.cgod; break;
  12. default:		impossible("unknown alignment.");
  13. 			gnam = "someone"; break;
  14. }
  15. if (*gnam == '_') ++gnam;
  16. return gnam;
  17. }

hallu_gname

  1. /* hallucination handling for priest/minion names: select a random god
  2. iff character is hallucinating */
  3. const char *
  4. halu_gname(alignment)
  5. aligntyp alignment;
  6. {
  7. const char *gnam;
  8. int which;
  9.  
  10. if (!Hallucination) return align_gname(alignment);
  11.  
  12. which = randrole();
  13. switch (rn2(3)) {
  14. case 0:	gnam = roles[which].lgod; break;
  15. case 1:	gnam = roles[which].ngod; break;
  16. case 2:	gnam = roles[which].cgod; break;
  17. default:	gnam = 0; break;		/* lint suppression */
  18. }
  19. if (!gnam) gnam = Moloch;
  20. if (*gnam == '_') ++gnam;
  21. return gnam;
  22. }

align_gtitle

  1. /* deity's title */
  2. const char *
  3. align_gtitle(alignment)
  4. aligntyp alignment;
  5. {
  6. const char *gnam, *result = "god";
  7.  
  8. switch (alignment) {
  9. case A_LAWFUL:	gnam = urole.lgod; break;
  10. case A_NEUTRAL:	gnam = urole.ngod; break;
  11. case A_CHAOTIC:	gnam = urole.cgod; break;
  12. default:		gnam = 0; break;
  13. }
  14. if (gnam && *gnam == '_') result = "goddess";
  15. return result;
  16. }

altar_wrath

  1. void
  2. altar_wrath(x, y)
  3. register int x, y;
  4. {
  5. aligntyp altaralign = a_align(x,y);
  6.  
  7. if(!strcmp(align_gname(altaralign), u_gname())) {
  8. 	godvoice(altaralign, "How darest thou desecrate my altar!");
  9. 	(void) adjattrib(A_WIS, -1, FALSE);
  10. } else {
  11. 	pline("A voice (could it be %s?) whispers:",
  12. 	      align_gname(altaralign));
  13. 	verbalize("Thou shalt pay, infidel!");
  14. 	change_luck(-1);
  15. }
  16. }

blocked_boulder

  1. /* assumes isok() at one space away, but not necessarily at two */
  2. STATIC_OVL boolean
  3. blocked_boulder(dx,dy)
  4. int dx,dy;
  5. {
  6. register struct obj *otmp;
  7. long count = 0L;
  8.  
  9. for(otmp = level.objects[u.ux+dx][u.uy+dy]; otmp; otmp = otmp->nexthere) {
  10. 	if(otmp->otyp == BOULDER)
  11. 	    count += otmp->quan;
  12. }
  13.  
  14. switch(count) {
  15. 	case 0: return FALSE; /* no boulders--not blocked */
  16. 	case 1: break; /* possibly blocked depending on if it's pushable */
  17. 	default: return TRUE; /* >1 boulder--blocked after they push the top
  18. 	    one; don't force them to push it first to find out */
  19. }
  20.  
  21. if (!isok(u.ux+2*dx, u.uy+2*dy))
  22. 	return TRUE;
  23. if (IS_ROCK(levl[u.ux+2*dx][u.uy+2*dy].typ))
  24. 	return TRUE;
  25. if (sobj_at(BOULDER, u.ux+2*dx, u.uy+2*dy))
  26. 	return TRUE;
  27.  
  28. return FALSE;
  29. }
  30.  
  31. /*pray.c*/