Source:NetHack 3.4.3/src/priest.c

From NetHackWiki
Jump to: navigation, search

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

Top of file[edit]

  1. /*	SCCS Id: @(#)priest.c	3.4	2002/11/06	*/
  2. /* Copyright (c) Izchak Miller, 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 "mfndpos.h"
  3. #include "eshk.h"
  4. #include "epri.h"
  5. #include "emin.h"
  6.  
  7. /* this matches the categorizations shown by enlightenment */
  8. #define ALGN_SINNED	(-4)	/* worse than strayed */
  9.  
  10. #ifdef OVLB
  11.  
  12. STATIC_DCL boolean FDECL(histemple_at,(struct monst *,XCHAR_P,XCHAR_P));
  13. STATIC_DCL boolean FDECL(has_shrine,(struct monst *));

move_special[edit]

  1. /*
  2. * Move for priests and shopkeepers.  Called from shk_move() and pri_move().
  3. * Valid returns are  1: moved  0: didn't  -1: let m_move do it  -2: died.
  4. */
  5. int
  6. move_special(mtmp,in_his_shop,appr,uondoor,avoid,omx,omy,gx,gy)
  7. register struct monst *mtmp;
  8. boolean in_his_shop;
  9. schar appr;
  10. boolean uondoor,avoid;
  11. register xchar omx,omy,gx,gy;
  12. {
  13. 	register xchar nx,ny,nix,niy;
  14. 	register schar i;
  15. 	schar chcnt,cnt;
  16. 	coord poss[9];
  17. 	long info[9];
  18. 	long allowflags;
  19. 	struct obj *ib = (struct obj *)0;
  20.  
  21. 	if(omx == gx && omy == gy)
  22. 		return(0);
  23. 	if(mtmp->mconf) {
  24. 		avoid = FALSE;
  25. 		appr = 0;
  26. 	}
  27.  
  28. 	nix = omx;
  29. 	niy = omy;
  30. 	if (mtmp->isshk) allowflags = ALLOW_SSM;
  31. 	else allowflags = ALLOW_SSM | ALLOW_SANCT;
  32. 	if (passes_walls(mtmp->data)) allowflags |= (ALLOW_ROCK|ALLOW_WALL);
  33. 	if (throws_rocks(mtmp->data)) allowflags |= ALLOW_ROCK;
  34. 	if (tunnels(mtmp->data)) allowflags |= ALLOW_DIG;
  35. 	if (!nohands(mtmp->data) && !verysmall(mtmp->data)) {
  36. 		allowflags |= OPENDOOR;
  37. 		if (m_carrying(mtmp, SKELETON_KEY)) allowflags |= BUSTDOOR;
  38. 	}
  39. 	if (is_giant(mtmp->data)) allowflags |= BUSTDOOR;
  40. 	cnt = mfndpos(mtmp, poss, info, allowflags);
  41.  
  42. 	if(mtmp->isshk && avoid && uondoor) { /* perhaps we cannot avoid him */
  43. 		for(i=0; i<cnt; i++)
  44. 		    if(!(info[i] & NOTONL)) goto pick_move;
  45. 		avoid = FALSE;
  46. 	}
  47.  
  48. #define GDIST(x,y)	(dist2(x,y,gx,gy))
  49. pick_move:
  50. 	chcnt = 0;
  51. 	for(i=0; i<cnt; i++) {
  52. 		nx = poss[i].x;
  53. 		ny = poss[i].y;
  54. 		if(levl[nx][ny].typ == ROOM ||
  55. 			(mtmp->ispriest &&
  56. 			    levl[nx][ny].typ == ALTAR) ||
  57. 			(mtmp->isshk &&
  58. 			    (!in_his_shop || ESHK(mtmp)->following))) {
  59. 		    if(avoid && (info[i] & NOTONL))
  60. 			continue;
  61. 		    if((!appr && !rn2(++chcnt)) ||
  62. 			(appr && GDIST(nx,ny) < GDIST(nix,niy))) {
  63. 			    nix = nx;
  64. 			    niy = ny;
  65. 		    }
  66. 		}
  67. 	}
  68. 	if(mtmp->ispriest && avoid &&
  69. 			nix == omx && niy == omy && onlineu(omx,omy)) {
  70. 		/* might as well move closer as long it's going to stay
  71. 		 * lined up */
  72. 		avoid = FALSE;
  73. 		goto pick_move;
  74. 	}
  75.  
  76. 	if(nix != omx || niy != omy) {
  77. 		remove_monster(omx, omy);
  78. 		place_monster(mtmp, nix, niy);
  79. 		newsym(nix,niy);
  80. 		if (mtmp->isshk && !in_his_shop && inhishop(mtmp))
  81. 		    check_special_room(FALSE);
  82. 		if(ib) {
  83. 			if (cansee(mtmp->mx,mtmp->my))
  84. 			    pline("%s picks up %s.", Monnam(mtmp),
  85. 				distant_name(ib,doname));
  86. 			obj_extract_self(ib);
  87. 			(void) mpickobj(mtmp, ib);
  88. 		}
  89. 		return(1);
  90. 	}
  91. 	return(0);
  92. }
  93.  
  94. #endif /* OVLB */
  95.  
  96. #ifdef OVL0

temple_occupied[edit]

  1. char
  2. temple_occupied(array)
  3. register char *array;
  4. {
  5. 	register char *ptr;
  6.  
  7. 	for (ptr = array; *ptr; ptr++)
  8. 		if (rooms[*ptr - ROOMOFFSET].rtype == TEMPLE)
  9. 			return(*ptr);
  10. 	return('\0');
  11. }
  12.  
  13. #endif /* OVL0 */
  14. #ifdef OVLB

histemple_at[edit]

  1. STATIC_OVL boolean
  2. histemple_at(priest, x, y)
  3. register struct monst *priest;
  4. register xchar x, y;
  5. {
  6. 	return((boolean)((EPRI(priest)->shroom == *in_rooms(x, y, TEMPLE)) &&
  7. 	       on_level(&(EPRI(priest)->shrlevel), &u.uz)));
  8. }

pri_move[edit]

  1. /*
  2. * pri_move: return 1: moved  0: didn't  -1: let m_move do it  -2: died
  3. */
  4. int
  5. pri_move(priest)
  6. register struct monst *priest;
  7. {
  8. 	register xchar gx,gy,omx,omy;
  9. 	schar temple;
  10. 	boolean avoid = TRUE;
  11.  
  12. 	omx = priest->mx;
  13. 	omy = priest->my;
  14.  
  15. 	if(!histemple_at(priest, omx, omy)) return(-1);
  16.  
  17. 	temple = EPRI(priest)->shroom;
  18.  
  19. 	gx = EPRI(priest)->shrpos.x;
  20. 	gy = EPRI(priest)->shrpos.y;
  21.  
  22. 	gx += rn1(3,-1);	/* mill around the altar */
  23. 	gy += rn1(3,-1);
  24.  
  25. 	if(!priest->mpeaceful ||
  26. 	   (Conflict && !resist(priest, RING_CLASS, 0, 0))) {
  27. 		if(monnear(priest, u.ux, u.uy)) {
  28. 			if(Displaced)
  29. 				Your("displaced image doesn't fool %s!",
  30. 					mon_nam(priest));
  31. 			(void) mattacku(priest);
  32. 			return(0);
  33. 		} else if(index(u.urooms, temple)) {
  34. 			/* chase player if inside temple & can see him */
  35. 			if(priest->mcansee && m_canseeu(priest)) {
  36. 				gx = u.ux;
  37. 				gy = u.uy;
  38. 			}
  39. 			avoid = FALSE;
  40. 		}
  41. 	} else if(Invis) avoid = FALSE;
  42.  
  43. 	return(move_special(priest,FALSE,TRUE,FALSE,avoid,omx,omy,gx,gy));
  44. }

priestini[edit]

  1. /* exclusively for mktemple() */
  2. void
  3. priestini(lvl, sroom, sx, sy, sanctum)
  4. d_level	*lvl;
  5. struct mkroom *sroom;
  6. int sx, sy;
  7. boolean sanctum;   /* is it the seat of the high priest? */
  8. {
  9. 	struct monst *priest;
  10. 	struct obj *otmp;
  11. 	int cnt;
  12.  
  13. 	if(MON_AT(sx+1, sy))
  14. 		(void) rloc(m_at(sx+1, sy), FALSE); /* insurance */
  15.  
  16. 	priest = makemon(&mons[sanctum ? PM_HIGH_PRIEST : PM_ALIGNED_PRIEST],
  17. 			 sx + 1, sy, NO_MM_FLAGS);
  18. 	if (priest) {
  19. 		EPRI(priest)->shroom = (sroom - rooms) + ROOMOFFSET;
  20. 		EPRI(priest)->shralign = Amask2align(levl[sx][sy].altarmask);
  21. 		EPRI(priest)->shrpos.x = sx;
  22. 		EPRI(priest)->shrpos.y = sy;
  23. 		assign_level(&(EPRI(priest)->shrlevel), lvl);
  24. 		priest->mtrapseen = ~0;	/* traps are known */
  25. 		priest->mpeaceful = 1;
  26. 		priest->ispriest = 1;
  27. 		priest->msleeping = 0;
  28. 		set_malign(priest); /* mpeaceful may have changed */
  29.  
  30. 		/* now his/her goodies... */
  31. 		if(sanctum && EPRI(priest)->shralign == A_NONE &&
  32. 		     on_level(&sanctum_level, &u.uz)) {
  33. 			(void) mongets(priest, AMULET_OF_YENDOR);
  34. 		}
  35. 		/* 2 to 4 spellbooks */
  36. 		for (cnt = rn1(3,2); cnt > 0; --cnt) {
  37. 		    (void) mpickobj(priest, mkobj(SPBOOK_CLASS, FALSE));
  38. 		}
  39. 		/* robe [via makemon()] */
  40. 		if (rn2(2) && (otmp = which_armor(priest, W_ARMC)) != 0) {
  41. 		    if (p_coaligned(priest))
  42. 			uncurse(otmp);
  43. 		    else
  44. 			curse(otmp);
  45. 		}
  46. 	}
  47. }

priestname[edit]

  1. /*
  2. * Specially aligned monsters are named specially.
  3. *	- aligned priests with ispriest and high priests have shrines
  4. *		they retain ispriest and epri when polymorphed
  5. *	- aligned priests without ispriest and Angels are roamers
  6. *		they retain isminion and access epri as emin when polymorphed
  7. *		(coaligned Angels are also created as minions, but they
  8. *		use the same naming convention)
  9. *	- minions do not have ispriest but have isminion and emin
  10. *	- caller needs to inhibit Hallucination if it wants to force
  11. *		the true name even when under that influence
  12. */
  13. char *
  14. priestname(mon, pname)
  15. register struct monst *mon;
  16. char *pname;		/* caller-supplied output buffer */
  17. {
  18. 	const char *what = Hallucination ? rndmonnam() : mon->data->mname;
  19.  
  20. 	Strcpy(pname, "the ");
  21. 	if (mon->minvis) Strcat(pname, "invisible ");
  22. 	if (mon->ispriest || mon->data == &mons[PM_ALIGNED_PRIEST] ||
  23. 					mon->data == &mons[PM_ANGEL]) {
  24. 		/* use epri */
  25. 		if (mon->mtame && mon->data == &mons[PM_ANGEL])
  26. 			Strcat(pname, "guardian ");
  27. 		if (mon->data != &mons[PM_ALIGNED_PRIEST] &&
  28. 				mon->data != &mons[PM_HIGH_PRIEST]) {
  29. 			Strcat(pname, what);
  30. 			Strcat(pname, " ");
  31. 		}
  32. 		if (mon->data != &mons[PM_ANGEL]) {
  33. 			if (!mon->ispriest && EPRI(mon)->renegade)
  34. 				Strcat(pname, "renegade ");
  35. 			if (mon->data == &mons[PM_HIGH_PRIEST])
  36. 				Strcat(pname, "high ");
  37. 			if (Hallucination)
  38. 				Strcat(pname, "poohbah ");
  39. 			else if (mon->female)
  40. 				Strcat(pname, "priestess ");
  41. 			else
  42. 				Strcat(pname, "priest ");
  43. 		}
  44. 		Strcat(pname, "of ");
  45. 		Strcat(pname, halu_gname((int)EPRI(mon)->shralign));
  46. 		return(pname);
  47. 	}
  48. 	/* use emin instead of epri */
  49. 	Strcat(pname, what);
  50. 	Strcat(pname, " of ");
  51. 	Strcat(pname, halu_gname(EMIN(mon)->min_align));
  52. 	return(pname);
  53. }

p_coaligned[edit]

  1. boolean
  2. p_coaligned(priest)
  3. struct monst *priest;
  4. {
  5. 	return((boolean)(u.ualign.type == ((int)EPRI(priest)->shralign)));
  6. }

has_shrine[edit]

  1. STATIC_OVL boolean
  2. has_shrine(pri)
  3. struct monst *pri;
  4. {
  5. 	struct rm *lev;
  6.  
  7. 	if(!pri)
  8. 		return(FALSE);
  9. 	lev = &levl[EPRI(pri)->shrpos.x][EPRI(pri)->shrpos.y];
  10. 	if (!IS_ALTAR(lev->typ) || !(lev->altarmask & AM_SHRINE))
  11. 		return(FALSE);
  12. 	return((boolean)(EPRI(pri)->shralign == Amask2align(lev->altarmask & ~AM_SHRINE)));
  13. }

findpriest[edit]

  1. struct monst *
  2. findpriest(roomno)
  3. char roomno;
  4. {
  5. 	register struct monst *mtmp;
  6.  
  7. 	for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
  8. 	    if (DEADMONSTER(mtmp)) continue;
  9. 	    if(mtmp->ispriest && (EPRI(mtmp)->shroom == roomno) &&
  10. 	       histemple_at(mtmp,mtmp->mx,mtmp->my))
  11. 		return(mtmp);
  12. 	}
  13. 	return (struct monst *)0;
  14. }
  15.  
  16. /* called from check_special_room() when the player enters the temple room */
  17. void

intemple[edit]

  1. intemple(roomno)
  2. register int roomno;
  3. {
  4. 	register struct monst *priest = findpriest((char)roomno);
  5. 	boolean tended = (priest != (struct monst *)0);
  6. 	boolean shrined, sanctum, can_speak;
  7. 	const char *msg1, *msg2;
  8. 	char buf[BUFSZ];
  9.  
  10. 	if(!temple_occupied(u.urooms0)) {
  11. 	    if(tended) {
  12. 		shrined = has_shrine(priest);
  13. 		sanctum = (priest->data == &mons[PM_HIGH_PRIEST] &&
  14. 			   (Is_sanctum(&u.uz) || In_endgame(&u.uz)));
  15. 		can_speak = (priest->mcanmove && !priest->msleeping &&
  16. 			     flags.soundok);
  17. 		if (can_speak) {
  18. 		    unsigned save_priest = priest->ispriest;
  19. 		    /* don't reveal the altar's owner upon temple entry in
  20. 		       the endgame; for the Sanctum, the next message names
  21. 		       Moloch so suppress the "of Moloch" for him here too */
  22. 		    if (sanctum && !Hallucination) priest->ispriest = 0;
  23. 		    pline("%s intones:",
  24. 			canseemon(priest) ? Monnam(priest) : "A nearby voice");
  25. 		    priest->ispriest = save_priest;
  26. 		}
  27. 		msg2 = 0;
  28. 		if(sanctum && Is_sanctum(&u.uz)) {
  29. 		    if(priest->mpeaceful) {
  30. 			msg1 = "Infidel, you have entered Moloch's Sanctum!";
  31. 			msg2 = "Be gone!";
  32. 			priest->mpeaceful = 0;
  33. 			set_malign(priest);
  34. 		    } else
  35. 			msg1 = "You desecrate this place by your presence!";
  36. 		} else {
  37. 		    Sprintf(buf, "Pilgrim, you enter a %s place!",
  38. 			    !shrined ? "desecrated" : "sacred");
  39. 		    msg1 = buf;
  40. 		}
  41. 		if (can_speak) {
  42. 		    verbalize(msg1);
  43. 		    if (msg2) verbalize(msg2);
  44. 		}
  45. 		if(!sanctum) {
  46. 		    /* !tended -> !shrined */
  47. 		    if (!shrined || !p_coaligned(priest) ||
  48. 			    u.ualign.record <= ALGN_SINNED)
  49. 			You("have a%s forbidding feeling...",
  50. 				(!shrined) ? "" : " strange");
  51. 		    else You("experience a strange sense of peace.");
  52. 		}
  53. 	    } else {
  54. 		switch(rn2(3)) {
  55. 		  case 0: You("have an eerie feeling..."); break;
  56. 		  case 1: You_feel("like you are being watched."); break;
  57. 		  default: pline("A shiver runs down your %s.",
  58. 			body_part(SPINE)); break;
  59. 		}
  60. 		if(!rn2(5)) {
  61. 		    struct monst *mtmp;
  62.  
  63. 		    if(!(mtmp = makemon(&mons[PM_GHOST],u.ux,u.uy,NO_MM_FLAGS)))
  64. 			return;
  65. 		    if (!Blind || sensemon(mtmp))
  66. 			pline("An enormous ghost appears next to you!");
  67. 		    else You("sense a presence close by!");
  68. 		    mtmp->mpeaceful = 0;
  69. 		    set_malign(mtmp);
  70. 		    if(flags.verbose)
  71. 			You("are frightened to death, and unable to move.");
  72. 		    nomul(-3);
  73. 		    nomovemsg = "You regain your composure.";
  74. 	       }
  75. 	   }
  76. }
  77. }

priest_talk[edit]

  1. void
  2. priest_talk(priest)
  3. register struct monst *priest;
  4. {
  5. 	boolean coaligned = p_coaligned(priest);
  6. 	boolean strayed = (u.ualign.record < 0);
  7.  
  8. 	/* KMH, conduct */
  9. 	u.uconduct.gnostic++;
  10.  
  11. 	if(priest->mflee || (!priest->ispriest && coaligned && strayed)) {
  12. 	    pline("%s doesn't want anything to do with you!",
  13. 				Monnam(priest));
  14. 	    priest->mpeaceful = 0;
  15. 	    return;
  16. 	}
  17.  
  18. 	/* priests don't chat unless peaceful and in their own temple */
  19. 	if(!histemple_at(priest,priest->mx,priest->my) ||
  20. 		 !priest->mpeaceful || !priest->mcanmove || priest->msleeping) {
  21. 	    static const char *cranky_msg[3] = {
  22. 		"Thou wouldst have words, eh?  I'll give thee a word or two!",
  23. 		"Talk?  Here is what I have to say!",
  24. 		"Pilgrim, I would speak no longer with thee."
  25. 	    };
  26.  
  27. 	    if(!priest->mcanmove || priest->msleeping) {
  28. 		pline("%s breaks out of %s reverie!",
  29. 		      Monnam(priest), mhis(priest));
  30. 		priest->mfrozen = priest->msleeping = 0;
  31. 		priest->mcanmove = 1;
  32. 	    }
  33. 	    priest->mpeaceful = 0;
  34. 	    verbalize(cranky_msg[rn2(3)]);
  35. 	    return;
  36. 	}
  37.  
  38. 	/* you desecrated the temple and now you want to chat? */
  39. 	if(priest->mpeaceful && *in_rooms(priest->mx, priest->my, TEMPLE) &&
  40. 		  !has_shrine(priest)) {
  41. 	    verbalize("Begone!  Thou desecratest this holy place with thy presence.");
  42. 	    priest->mpeaceful = 0;
  43. 	    return;
  44. 	}
  45. #ifndef GOLDOBJ
  46. 	if(!u.ugold) {
  47. 	    if(coaligned && !strayed) {
  48. 		if (priest->mgold > 0L) {
  49. 		    /* Note: two bits is actually 25 cents.  Hmm. */
  50. 		    pline("%s gives you %s for an ale.", Monnam(priest),
  51. 			(priest->mgold == 1L) ? "one bit" : "two bits");
  52. 		    if (priest->mgold > 1L)
  53. 			u.ugold = 2L;
  54. 		    else
  55. 			u.ugold = 1L;
  56. 		    priest->mgold -= u.ugold;
  57. 		    flags.botl = 1;
  58. #else
  59. 	if(!money_cnt(invent)) {
  60. 	    if(coaligned && !strayed) {
  61. long pmoney = money_cnt(priest->minvent);
  62. 		if (pmoney > 0L) {
  63. 		    /* Note: two bits is actually 25 cents.  Hmm. */
  64. 		    pline("%s gives you %s for an ale.", Monnam(priest),
  65. 			(pmoney == 1L) ? "one bit" : "two bits");
  66. 		     money2u(priest, pmoney > 1L ? 2 : 1);
  67. #endif
  68. 		} else
  69. 		    pline("%s preaches the virtues of poverty.", Monnam(priest));
  70. 		exercise(A_WIS, TRUE);
  71. 	    } else
  72. 		pline("%s is not interested.", Monnam(priest));
  73. 	    return;
  74. 	} else {
  75. 	    long offer;
  76.  
  77. 	    pline("%s asks you for a contribution for the temple.",
  78. 			Monnam(priest));
  79. 	    if((offer = bribe(priest)) == 0) {
  80. 		verbalize("Thou shalt regret thine action!");
  81. 		if(coaligned) adjalign(-1);
  82. 	    } else if(offer < (u.ulevel * 200)) {
  83. #ifndef GOLDOBJ
  84. 		if(u.ugold > (offer * 2L)) verbalize("Cheapskate.");
  85. #else
  86. 		if(money_cnt(invent) > (offer * 2L)) verbalize("Cheapskate.");
  87. #endif
  88. 		else {
  89. 		    verbalize("I thank thee for thy contribution.");
  90. 		    /*  give player some token  */
  91. 		    exercise(A_WIS, TRUE);
  92. 		}
  93. 	    } else if(offer < (u.ulevel * 400)) {
  94. 		verbalize("Thou art indeed a pious individual.");
  95. #ifndef GOLDOBJ
  96. 		if(u.ugold < (offer * 2L)) {
  97. #else
  98. 		if(money_cnt(invent) < (offer * 2L)) {
  99. #endif
  100. 		    if (coaligned && u.ualign.record <= ALGN_SINNED)
  101. 			adjalign(1);
  102. 		    verbalize("I bestow upon thee a blessing.");
  103. 		    incr_itimeout(&HClairvoyant, rn1(500,500));
  104. 		}
  105. 	    } else if(offer < (u.ulevel * 600) &&
  106. 		      u.ublessed < 20 &&
  107. 		      (u.ublessed < 9 || !rn2(u.ublessed))) {
  108. 		verbalize("Thy devotion has been rewarded.");
  109. 		if (!(HProtection & INTRINSIC))  {
  110. 			HProtection |= FROMOUTSIDE;
  111. 			if (!u.ublessed)  u.ublessed = rn1(3, 2);
  112. 		} else u.ublessed++;
  113. 	    } else {
  114. 		verbalize("Thy selfless generosity is deeply appreciated.");
  115. #ifndef GOLDOBJ
  116. 		if(u.ugold < (offer * 2L) && coaligned) {
  117. #else
  118. 		if(money_cnt(invent) < (offer * 2L) && coaligned) {
  119. #endif
  120. 		    if(strayed && (moves - u.ucleansed) > 5000L) {
  121. 			u.ualign.record = 0; /* cleanse thee */
  122. 			u.ucleansed = moves;
  123. 		    } else {
  124. 			adjalign(2);
  125. 		    }
  126. 		}
  127. 	    }
  128. 	}
  129. }

mk_roamer[edit]

  1. struct monst *
  2. mk_roamer(ptr, alignment, x, y, peaceful)
  3. register struct permonst *ptr;
  4. aligntyp alignment;
  5. xchar x, y;
  6. boolean peaceful;
  7. {
  8. 	register struct monst *roamer;
  9. 	register boolean coaligned = (u.ualign.type == alignment);
  10.  
  11. 	if (ptr != &mons[PM_ALIGNED_PRIEST] && ptr != &mons[PM_ANGEL])
  12. 		return((struct monst *)0);
  13.  
  14. 	if (MON_AT(x, y)) (void) rloc(m_at(x, y), FALSE);	/* insurance */
  15.  
  16. 	if (!(roamer = makemon(ptr, x, y, NO_MM_FLAGS)))
  17. 		return((struct monst *)0);
  18.  
  19. 	EPRI(roamer)->shralign = alignment;
  20. 	if (coaligned && !peaceful)
  21. 		EPRI(roamer)->renegade = TRUE;
  22. 	/* roamer->ispriest == FALSE naturally */
  23. 	roamer->isminion = TRUE;	/* borrowing this bit */
  24. 	roamer->mtrapseen = ~0;		/* traps are known */
  25. 	roamer->mpeaceful = peaceful;
  26. 	roamer->msleeping = 0;
  27. 	set_malign(roamer); /* peaceful may have changed */
  28.  
  29. 	/* MORE TO COME */
  30. 	return(roamer);
  31. }

reset_hostility[edit]

  1. void
  2. reset_hostility(roamer)
  3. register struct monst *roamer;
  4. {
  5. 	if(!(roamer->isminion && (roamer->data == &mons[PM_ALIGNED_PRIEST] ||
  6. 				  roamer->data == &mons[PM_ANGEL])))
  7. 	        return;
  8.  
  9. 	if(EPRI(roamer)->shralign != u.ualign.type) {
  10. 	    roamer->mpeaceful = roamer->mtame = 0;
  11. 	    set_malign(roamer);
  12. 	}
  13. 	newsym(roamer->mx, roamer->my);
  14. }

in_your_sanctuary[edit]

  1. boolean
  2. in_your_sanctuary(mon, x, y)
  3. struct monst *mon;	/* if non-null, <mx,my> overrides <x,y> */
  4. xchar x, y;
  5. {
  6. 	register char roomno;
  7. 	register struct monst *priest;
  8.  
  9. 	if (mon) {
  10. 	    if (is_minion(mon->data) || is_rider(mon->data)) return FALSE;
  11. 	    x = mon->mx, y = mon->my;
  12. 	}
  13. 	if (u.ualign.record <= ALGN_SINNED)	/* sinned or worse */
  14. 	    return FALSE;
  15. 	if ((roomno = temple_occupied(u.urooms)) == 0 ||
  16. 		roomno != *in_rooms(x, y, TEMPLE))
  17. 	    return FALSE;
  18. 	if ((priest = findpriest(roomno)) == 0)
  19. 	    return FALSE;
  20. 	return (boolean)(has_shrine(priest) &&
  21. 			 p_coaligned(priest) &&
  22. 			 priest->mpeaceful);
  23. }

ghod_hitsu[edit]

  1. void
  2. ghod_hitsu(priest)	/* when attacking "priest" in his temple */
  3. struct monst *priest;
  4. {
  5. 	int x, y, ax, ay, roomno = (int)temple_occupied(u.urooms);
  6. 	struct mkroom *troom;
  7.  
  8. 	if (!roomno || !has_shrine(priest))
  9. 		return;
  10.  
  11. 	ax = x = EPRI(priest)->shrpos.x;
  12. 	ay = y = EPRI(priest)->shrpos.y;
  13. 	troom = &rooms[roomno - ROOMOFFSET];
  14.  
  15. 	if((u.ux == x && u.uy == y) || !linedup(u.ux, u.uy, x, y)) {
  16. 	    if(IS_DOOR(levl[u.ux][u.uy].typ)) {
  17.  
  18. 		if(u.ux == troom->lx - 1) {
  19. 		    x = troom->hx;
  20. 		    y = u.uy;
  21. 		} else if(u.ux == troom->hx + 1) {
  22. 		    x = troom->lx;
  23. 		    y = u.uy;
  24. 		} else if(u.uy == troom->ly - 1) {
  25. 		    x = u.ux;
  26. 		    y = troom->hy;
  27. 		} else if(u.uy == troom->hy + 1) {
  28. 		    x = u.ux;
  29. 		    y = troom->ly;
  30. 		}
  31. 	    } else {
  32. 		switch(rn2(4)) {
  33. 		case 0:  x = u.ux; y = troom->ly; break;
  34. 		case 1:  x = u.ux; y = troom->hy; break;
  35. 		case 2:  x = troom->lx; y = u.uy; break;
  36. 		default: x = troom->hx; y = u.uy; break;
  37. 		}
  38. 	    }
  39. 	    if(!linedup(u.ux, u.uy, x, y)) return;
  40. 	}
  41.  
  42. 	switch(rn2(3)) {
  43. 	case 0:
  44. 	    pline("%s roars in anger:  \"Thou shalt suffer!\"",
  45. 			a_gname_at(ax, ay));
  46. 	    break;
  47. 	case 1:
  48. 	    pline("%s voice booms:  \"How darest thou harm my servant!\"",
  49. 			s_suffix(a_gname_at(ax, ay)));
  50. 	    break;
  51. 	default:
  52. 	    pline("%s roars:  \"Thou dost profane my shrine!\"",
  53. 			a_gname_at(ax, ay));
  54. 	    break;
  55. 	}
  56.  
  57. 	buzz(-10-(AD_ELEC-1), 6, x, y, sgn(tbx), sgn(tby)); /* bolt of lightning */
  58. 	exercise(A_WIS, FALSE);
  59. }

angry_priest[edit]

  1. void
  2. angry_priest()
  3. {
  4. 	register struct monst *priest;
  5. 	struct rm *lev;
  6.  
  7. 	if ((priest = findpriest(temple_occupied(u.urooms))) != 0) {
  8. 	    wakeup(priest);
  9. 	    /*
  10. 	     * If the altar has been destroyed or converted, let the
  11. 	     * priest run loose.
  12. 	     * (When it's just a conversion and there happens to be
  13. 	     *	a fresh corpse nearby, the priest ought to have an
  14. 	     *	opportunity to try converting it back; maybe someday...)
  15. 	     */
  16. 	    lev = &levl[EPRI(priest)->shrpos.x][EPRI(priest)->shrpos.y];
  17. 	    if (!IS_ALTAR(lev->typ) ||
  18. 		((aligntyp)Amask2align(lev->altarmask & AM_MASK) !=
  19. 			EPRI(priest)->shralign)) {
  20. 		priest->ispriest = 0;		/* now a roamer */
  21. 		priest->isminion = 1;		/* but still aligned */
  22. 		/* this overloads the `shroom' field, which is now clobbered */
  23. 		EPRI(priest)->renegade = 0;
  24. 	    }
  25. 	}
  26. }

clearpriests[edit]

  1. /*
  2. * When saving bones, find priests that aren't on their shrine level,
  3. * and remove them.   This avoids big problems when restoring bones.
  4. */
  5. void
  6. clearpriests()
  7. {
  8. register struct monst *mtmp, *mtmp2;
  9.  
  10. for(mtmp = fmon; mtmp; mtmp = mtmp2) {
  11. 	mtmp2 = mtmp->nmon;
  12. 	if (!DEADMONSTER(mtmp) && mtmp->ispriest && !on_level(&(EPRI(mtmp)->shrlevel), &u.uz))
  13. 	    mongone(mtmp);
  14. }
  15. }

restpriest[edit]

  1. /* munge priest-specific structure when restoring -dlc */
  2. void
  3. restpriest(mtmp, ghostly)
  4. register struct monst *mtmp;
  5. boolean ghostly;
  6. {
  7. if(u.uz.dlevel) {
  8. 	if (ghostly)
  9. 	    assign_level(&(EPRI(mtmp)->shrlevel), &u.uz);
  10. }
  11. }
  12.  
  13. #endif /* OVLB */
  14.  
  15. /*priest.c*/