Source:NetHack 3.3.0/priest.c

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

Warning! This is the source code from an old release. For the latest release, see Source code

1.   /*	SCCS Id: @(#)priest.c	3.3	1999/12/03	*/ 2.   /* Copyright (c) Izchak Miller, Steve Linhart, 1989. */ 3.    /* NetHack may be freely redistributed. See license for details. */ 4.     5.    #include "hack.h"  6.    #include "mfndpos.h"  7.    #include "eshk.h"  8.    #include "epri.h"  9.    #include "emin.h"  10. 11.  #ifdef OVLB 12.   13.   STATIC_DCL boolean FDECL(histemple_at,(struct monst *,XCHAR_P,XCHAR_P)); 14.  STATIC_DCL boolean FDECL(has_shrine,(struct monst *)); 15.   16.   /*  17.    * Move for priests and shopkeepers. Called from shk_move and pri_move. 18.   * Valid returns are  1: moved  0: didn't  -1: let m_move do it  -2: died. 19.   */  20.   int 21.  move_special(mtmp,in_his_shop,appr,uondoor,avoid,omx,omy,gx,gy) 22.  register struct monst *mtmp; 23.  boolean in_his_shop; 24.  schar appr; 25.  boolean uondoor,avoid; 26.  register xchar omx,omy,gx,gy; 27.  {  28.   	register xchar nx,ny,nix,niy; 29.  	register schar i;  30. schar chcnt,cnt; 31.  	coord poss[9]; 32.  	long info[9]; 33.  	long allowflags; 34.  	struct obj *ib = (struct obj *)0; 35.   36.   	if(omx == gx && omy == gy) 37.  		return(0); 38.  	if(mtmp->mconf) { 39.  		avoid = FALSE; 40.  		appr = 0; 41.  	}  42.    43.   	nix = omx; 44.  	niy = omy; 45.  	if (mtmp->isshk) allowflags = ALLOW_SSM; 46.  	else allowflags = ALLOW_SSM | ALLOW_SANCT; 47.  	if (passes_walls(mtmp->data)) allowflags |= (ALLOW_ROCK|ALLOW_WALL); 48.  	if (throws_rocks(mtmp->data)) allowflags |= ALLOW_ROCK; 49.  	if (tunnels(mtmp->data) &&  50.   		    (!needspick(mtmp->data) || m_carrying(mtmp, PICK_AXE) || 51.  		     m_carrying(mtmp, DWARVISH_MATTOCK))) 52.  		allowflags |= ALLOW_DIG; 53.  	if (!nohands(mtmp->data) && !verysmall(mtmp->data)) { 54.  		allowflags |= OPENDOOR; 55.  		if (m_carrying(mtmp, SKELETON_KEY)) allowflags |= BUSTDOOR; 56.  	}  57.   	if (is_giant(mtmp->data)) allowflags |= BUSTDOOR; 58.  	cnt = mfndpos(mtmp, poss, info, allowflags); 59.   60.   	if(mtmp->isshk && avoid && uondoor) { /* perhaps we cannot avoid him */ 61.  		for(i=0; iispriest && 74.  			    levl[nx][ny].typ == ALTAR) ||  75.   			(mtmp->isshk && 76.  			    (!in_his_shop || ESHK(mtmp)->following))) { 77.  		    if(avoid && (info[i] & NOTONL)) 78.  			continue; 79.  		    if((!appr && !rn2(++chcnt)) ||  80.   			(appr && GDIST(nx,ny) < GDIST(nix,niy))) { 81.  			    nix = nx; 82.  			    niy = ny; 83.  		    }  84.   		}  85.   	}  86.   	if(mtmp->ispriest && avoid &&  87.   			nix == omx && niy == omy && onlineu(omx,omy)) { 88.  		/* might as well move closer as long it's going to stay 89.  		 * lined up */ 90.  		avoid = FALSE; 91.  		goto pick_move; 92.  	}  93.    94.   	if(nix != omx || niy != omy) { 95.  		remove_monster(omx, omy); 96.  		place_monster(mtmp, nix, niy); 97.  		newsym(nix,niy); 98.  		if (mtmp->isshk && !in_his_shop && inhishop(mtmp)) 99.  		    check_special_room(FALSE); 100. 		if(ib) { 101. 			if (cansee(mtmp->mx,mtmp->my)) 102. 			    pline("%s picks up %s.", Monnam(mtmp),  103.  				distant_name(ib,doname)); 104. 			obj_extract_self(ib); 105. 			mpickobj(mtmp, ib); 106. 		}  107.  		return(1); 108. 	}  109.  	return(0); 110. }  111.   112.  #endif /* OVLB */ 113.  114.  #ifdef OVL0 115.  116.  char 117. temple_occupied(array) 118. register char *array; 119. {  120.  	register char *ptr; 121.  122.  	for (ptr = array; *ptr; ptr++) 123. 		if (rooms[*ptr - ROOMOFFSET].rtype == TEMPLE) 124. 			return(*ptr); 125. 	return('\0'); 126. }  127.   128.  #endif /* OVL0 */ 129. #ifdef OVLB 130.  131.  STATIC_OVL boolean 132. histemple_at(priest, x, y)  133. register struct monst *priest; 134. register xchar x, y;  135. { 136.  	return((boolean)((EPRI(priest)->shroom == *in_rooms(x, y, TEMPLE)) && 137. 	       on_level(&(EPRI(priest)->shrlevel), &u.uz))); 138. }  139.   140.  /*  141.   * pri_move: return 1: moved  0: didn't  -1: let m_move do it  -2: died 142.  */  143.  int 144. pri_move(priest) 145. register struct monst *priest; 146. {  147.  	register xchar gx,gy,omx,omy; 148. 	schar temple; 149. 	boolean avoid = TRUE; 150.  151.  	omx = priest->mx; 152. 	omy = priest->my; 153.  154.  	if(!histemple_at(priest, omx, omy)) return(-1); 155.  156.  	temple = EPRI(priest)->shroom; 157.  158.  	gx = EPRI(priest)->shrpos.x;  159. gy = EPRI(priest)->shrpos.y; 160. 161. 	gx += rn1(3,-1);	/* mill around the altar */ 162. 	gy += rn1(3,-1); 163.  164.  	if(!priest->mpeaceful ||  165.  	   (Conflict && !resist(priest, RING_CLASS, 0, 0))) { 166. 		if(monnear(priest, u.ux, u.uy)) { 167. 			if(Displaced) 168. 				Your("displaced image doesn't fool %s!",  169.  					mon_nam(priest)); 170. 			(void) mattacku(priest); 171. 			return(0); 172. 		} else if(index(u.urooms, temple)) { 173. 			/* chase player if inside temple & can see him */ 174. 			if(priest->mcansee && m_canseeu(priest)) { 175. 				gx = u.ux; 176. 				gy = u.uy; 177. 			}  178.  			avoid = FALSE; 179. 		}  180.  	} else if(Invis) avoid = FALSE; 181.  182.  	return(move_special(priest,FALSE,TRUE,FALSE,avoid,omx,omy,gx,gy)); 183. }  184.   185.  /* exclusively for mktemple */ 186. void 187. priestini(lvl, sroom, sx, sy, sanctum) 188. d_level	*lvl; 189. struct mkroom *sroom; 190. int sx, sy; 191. boolean sanctum;   /* is it the seat of the high priest? */ 192.  {  193.  	register struct monst *priest; 194. 	register struct obj *otmp; 195. 	register int cnt; 196.  197.  	if(MON_AT(sx+1, sy)) 198. 		rloc(m_at(sx+1, sy)); /* insurance */ 199.  200.  	priest = makemon(&mons[sanctum ? PM_HIGH_PRIEST : PM_ALIGNED_PRIEST],  201.  			 sx + 1, sy, NO_MM_FLAGS); 202. 	if (priest) { 203. 		EPRI(priest)->shroom = (sroom - rooms) + ROOMOFFSET; 204. 		EPRI(priest)->shralign = Amask2align(levl[sx][sy].altarmask); 205. 		EPRI(priest)->shrpos.x = sx; 206. 		EPRI(priest)->shrpos.y = sy; 207. 		assign_level(&(EPRI(priest)->shrlevel), lvl); 208. 		priest->mtrapseen = ~0;	/* traps are known */ 209. 		priest->mpeaceful = 1; 210. 		priest->ispriest = 1; 211. 		priest->msleeping = 0; 212. 		set_malign(priest); /* mpeaceful may have changed */ 213.  214.  		/* now his/her goodies... */ 215.  		if(sanctum && EPRI(priest)->shralign == A_NONE &&  216.  		     on_level(&sanctum_level, &u.uz)) { 217. 			(void) mongets(priest, AMULET_OF_YENDOR); 218. 			flags.made_amulet = 1; 219. 		}  220.  		/* Do NOT put the rest in m_initinv. */ 221.  		/* Priests created elsewhere than in a  */ 222. 		/* temple should not carry these items, */ 223. 		cnt = rn1(2,3); 224. 		while(cnt) { 225. 		    otmp = mkobj(SPBOOK_CLASS, FALSE); 226. 		    if(otmp) mpickobj(priest, otmp); 227. 		    cnt--; 228. 		}  229.  		if(p_coaligned(priest)) 230. 		    (void) mongets(priest, ROBE); 231. 		else { 232. 		    otmp = mksobj(ROBE, TRUE, FALSE); 233. 		    if(otmp) { 234. 			if(!rn2(2)) curse(otmp); 235. 			mpickobj(priest, otmp); 236. 		    }  237.  		}  238.  		m_dowear(priest, TRUE); 239. 	}  240.  }  241.   242.  /*  243.   * Specially aligned monsters are named specially. 244.  *	- aligned priests with ispriest and high priests have shrines 245.  *		they retain ispriest and epri when polymorphed 246.  *	- aligned priests without ispriest and Angels are roamers 247.  *		they retain isminion and access epri as emin when polymorphed 248.  *		(coaligned Angels are also created as minions, but they  249.   *		use the same naming convention) 250.  *	- minions do not have ispriest but have isminion and emin 251.  *	- caller needs to inhibit Hallucination if it wants to force 252.  *		the true name even when under that influence 253.  */  254.  char * 255. priestname(mon, pname) 256. register struct monst *mon; 257. char *pname;		/* caller-supplied output buffer */ 258. {  259.  	const char *what = Hallucination ? rndmonnam : mon->data->mname; 260.  261.  	Strcpy(pname, "the "); 262. 	if (mon->minvis) Strcat(pname, "invisible "); 263. 	if (mon->ispriest || mon->data == &mons[PM_ALIGNED_PRIEST] ||  264.  					mon->data == &mons[PM_ANGEL]) { 265. 		/* use epri */ 266. 		if (mon->mtame && mon->data == &mons[PM_ANGEL]) 267. 			Strcat(pname, "guardian "); 268. 		if (mon->data != &mons[PM_ALIGNED_PRIEST] &&  269.  				mon->data != &mons[PM_HIGH_PRIEST]) { 270. 			Strcat(pname, what); 271. 			Strcat(pname, " "); 272. 		}  273.  		if (mon->data != &mons[PM_ANGEL]) { 274. 			if (!mon->ispriest && EPRI(mon)->renegade) 275. 				Strcat(pname, "renegade "); 276. 			if (mon->data == &mons[PM_HIGH_PRIEST]) 277. 				Strcat(pname, "high "); 278. 			if (Hallucination) 279. 				Strcat(pname, "poohbah "); 280. 			else if (mon->female) 281. 				Strcat(pname, "priestess "); 282. 			else 283. 				Strcat(pname, "priest "); 284. 		}  285.  		Strcat(pname, "of "); 286. 		Strcat(pname, halu_gname((int)EPRI(mon)->shralign)); 287. 		return(pname); 288. 	}  289.  	/* use emin instead of epri */ 290. 	Strcat(pname, what); 291. 	Strcat(pname, " of "); 292. 	Strcat(pname, halu_gname(EMIN(mon)->min_align)); 293. 	return(pname); 294. }  295.   296.  boolean 297. p_coaligned(priest) 298. struct monst *priest; 299. {  300.  	return((boolean)(u.ualign.type == ((int)EPRI(priest)->shralign))); 301. }  302.   303.  STATIC_OVL boolean 304. has_shrine(pri) 305. struct monst *pri; 306. {  307.  	struct rm *lev; 308.  309.  	if(!pri) 310. 		return(FALSE); 311. 	lev = &levl[EPRI(pri)->shrpos.x][EPRI(pri)->shrpos.y]; 312. 	if (!IS_ALTAR(lev->typ) || !(lev->altarmask & AM_SHRINE)) 313. 		return(FALSE); 314. 	return((boolean)(EPRI(pri)->shralign == Amask2align(lev->altarmask & ~AM_SHRINE))); 315. }  316.   317.  struct monst * 318. findpriest(roomno) 319. char roomno; 320. {  321.  	register struct monst *mtmp; 322.  323.  	for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) 324. 	    if(mtmp->ispriest && (EPRI(mtmp)->shroom == roomno) &&  325.  	       histemple_at(mtmp,mtmp->mx,mtmp->my)) 326. 		return(mtmp); 327. 	return (struct monst *)0; 328. }  329.   330.  /* called from check_special_room when the player enters the temple room */ 331. void 332. intemple(roomno) 333. register int roomno; 334. {  335.  	register struct monst *priest = findpriest((char)roomno); 336. 	boolean tended = (priest != (struct monst *)0); 337. 	boolean shrined, sanctum, can_speak; 338. 	const char *msg1, *msg2; 339. 	char buf[BUFSZ]; 340.  341.  	if(!temple_occupied(u.urooms0)) { 342. 	    if(tended) { 343. 		shrined = has_shrine(priest); 344. 		sanctum = (priest->data == &mons[PM_HIGH_PRIEST] &&  345.  			   (Is_sanctum(&u.uz) || In_endgame(&u.uz))); 346. 		can_speak = (priest->mcanmove && !priest->msleeping); 347. 		if (can_speak) 348. 		    pline("%s intones:",  349.  			  (!Blind ? Monnam(priest) : "A nearby voice")); 350. 		msg2 = 0; 351. 		if(sanctum && Is_sanctum(&u.uz)) { 352. 		    if(priest->mpeaceful) { 353. 			msg1 = "Infidel, you entered Moloch's Sanctum!"; 354. 			msg2 = "Be gone!"; 355. 			priest->mpeaceful = 0; 356. 			set_malign(priest); 357. 		    } else 358. 			msg1 = "You desecrate this place by your presence!"; 359. 		} else { 360. 		    Sprintf(buf, "Pilgrim, you enter a %s place!",  361.  			    !shrined ? "desecrated" : "sacred"); 362. 		    msg1 = buf; 363. 		}  364.  		if (can_speak) { 365. 		    verbalize(msg1); 366. 		    if (msg2) verbalize(msg2); 367. 		}  368.  		if(!sanctum) { 369. 		    /* !tended -> !shrined */ 370. 		    if(!shrined || !p_coaligned(priest) ||  371.  						   u.ualign.record < -5) 372. 			You("have a%s forbidding feeling...",  373.  				(!shrined) ? "" : " strange"); 374. 		    else You("experience a strange sense of peace."); 375. 		}  376.  	    } else { 377. 		switch(rn2(3)) { 378. 		  case 0: You("have an eerie feeling..."); break; 379. 		  case 1: You_feel("like you are being watched."); break; 380. 		  default: pline("A shiver runs down your %s.",  381.  			body_part(SPINE)); break; 382. 		}  383.  		if(!rn2(5)) { 384. 		    struct monst *mtmp; 385.  386.  		    if(!(mtmp = makemon(&mons[PM_GHOST],u.ux,u.uy,NO_MM_FLAGS))) 387. 			return; 388. 		    pline("An enormous ghost appears next to you!"); 389. 		    mtmp->mpeaceful = 0; 390. 		    set_malign(mtmp); 391. 		    if(flags.verbose) 392. 			You("are frightened to death, and unable to move."); 393. 		    nomul(-3); 394. 		    nomovemsg = "You regain your composure."; 395. 	       }  396.  	   }  397.         }  398.  }  399.   400.  void 401. priest_talk(priest) 402. register struct monst *priest; 403. {  404.  	boolean coaligned = p_coaligned(priest); 405. 	boolean strayed = (u.ualign.record < 0); 406.  407.   408.  	/* KMH, conduct */ 409. 	u.uconduct.gnostic++; 410.  411.  	if(priest->mflee || (!priest->ispriest && coaligned && strayed)) { 412. 	    pline("%s doesn't want anything to do with you!",  413.  				Monnam(priest)); 414. 	    priest->mpeaceful = 0; 415. 	    return; 416. 	}  417.   418.  	/* priests don't chat unless peaceful and in their own temple */ 419. 	if(!histemple_at(priest,priest->mx,priest->my) ||  420.  		 !priest->mpeaceful || !priest->mcanmove || priest->msleeping) { 421. 	    static const char *cranky_msg[3] = { 422. 		"Thou wouldst have words, eh?  I'll give thee a word or two!", 423. 		"Talk?  Here is what I have to say!", 424. 		"Pilgrim, I would speak no longer with thee." 425. 	    };  426.   427.  	    if(!priest->mcanmove || priest->msleeping) { 428. 		pline("%s breaks out of %s reverie!",  429.  		      Monnam(priest), his[pronoun_gender(priest)]); 430. 		priest->mfrozen = priest->msleeping = 0; 431. 		priest->mcanmove = 1; 432. 	    }  433.  	    priest->mpeaceful = 0; 434. 	    verbalize(cranky_msg[rn2(3)]); 435. 	    return; 436. 	}  437.   438.  	/* you desecrated the temple and now you want to chat? */ 439.  	if(priest->mpeaceful && *in_rooms(priest->mx, priest->my, TEMPLE) &&  440.  		  !has_shrine(priest)) { 441. 	    verbalize("Begone!  Thou desecratest this holy place with thy presence."); 442. 	    priest->mpeaceful = 0; 443. 	    return; 444. 	}  445.   446.  	if(!u.ugold) { 447. 	    if(coaligned && !strayed) { 448. 		if (priest->mgold > 0L) { 449. 		    /* Note: two bits is actually 25 cents. Hmm. */ 450.  		    pline("%s gives you %s for an ale.", Monnam(priest),  451.  			(priest->mgold == 1L) ? "one bit" : "two bits"); 452. 		    if (priest->mgold > 1L) 453. 			u.ugold = 2L; 454. 		    else 455. 			u.ugold = 1L; 456. 		    priest->mgold -= u.ugold; 457. 		    flags.botl = 1; 458. 		} else 459. 		    pline("%s preaches the virtues of poverty.", Monnam(priest)); 460. 		exercise(A_WIS, TRUE); 461. 	    } else 462. 		pline("%s is not interested.", Monnam(priest)); 463. 	    return; 464. 	} else { 465. 	    long offer; 466.  467.  	    pline("%s asks you for a contribution for the temple.",  468.  			Monnam(priest)); 469. 	    if((offer = bribe(priest)) == 0) { 470. 		verbalize("Thou shalt regret thine action!"); 471. 		if(coaligned) adjalign(-1); 472. 	    } else if(offer < (u.ulevel * 200)) { 473. 		if(u.ugold > (offer * 2L)) verbalize("Cheapskate."); 474. 		else { 475. 		    verbalize("I thank thee for thy contribution."); 476. 		    /*  give player some token  */ 477. 		    exercise(A_WIS, TRUE); 478. 		}  479.  	    } else if(offer < (u.ulevel * 400)) { 480. 		verbalize("Thou art indeed a pious individual."); 481. 		if(u.ugold < (offer * 2L)) { 482. 		    if(coaligned && u.ualign.record < -5) adjalign(1); 483. 		    verbalize("I bestow upon thee a blessing."); 484. 		    incr_itimeout(&HClairvoyant, rn1(500,500)); 485. 		}  486.  	    } else if(offer < (u.ulevel * 600) &&  487.  		      u.ublessed < 20 &&  488.  		      (u.ublessed < 9 || !rn2(u.ublessed))) { 489. 		verbalize("Thy devotion has been rewarded."); 490. 		if (!(HProtection & INTRINSIC))  { 491. 			HProtection |= FROMOUTSIDE; 492. 			if (!u.ublessed)  u.ublessed = rn1(3, 2); 493. 		} else u.ublessed++; 494. 	    } else { 495. 		verbalize("Thy selfless generosity is deeply appreciated."); 496. 		if(u.ugold < (offer * 2L) && coaligned) { 497. 		    if(strayed && (moves - u.ucleansed) > 5000L) { 498. 			u.ualign.record = 0; /* cleanse thee */ 499. 			u.ucleansed = moves; 500. 		    } else { 501. 			adjalign(2); 502. 		    }  503.  		}  504.  	    }  505.  	}  506.  }  507.   508.  struct monst * 509. mk_roamer(ptr, alignment, x, y, peaceful) 510. register struct permonst *ptr; 511. aligntyp alignment; 512. xchar x, y;  513. boolean peaceful; 514. {  515.  	register struct monst *roamer; 516. 	register boolean coaligned = (u.ualign.type == alignment); 517.  518.  	if (ptr != &mons[PM_ALIGNED_PRIEST] && ptr != &mons[PM_ANGEL]) 519. 		return((struct monst *)0); 520. 	  521.  	if (MON_AT(x, y)) rloc(m_at(x, y));	/* insurance */ 522.  523.  	if (!(roamer = makemon(ptr, x, y, NO_MM_FLAGS))) 524. 		return((struct monst *)0); 525.  526.  	EPRI(roamer)->shralign = alignment; 527. 	if (coaligned && !peaceful) 528. 		EPRI(roamer)->renegade = TRUE; 529. 	/* roamer->ispriest == FALSE naturally */ 530. 	roamer->isminion = TRUE;	/* borrowing this bit */ 531. 	roamer->mtrapseen = ~0;		/* traps are known */ 532. 	roamer->mpeaceful = peaceful; 533. 	roamer->msleeping = 0; 534. 	set_malign(roamer); /* peaceful may have changed */ 535.  536.  	/* MORE TO COME */ 537. 	return(roamer); 538. }  539.   540.  void 541. reset_hostility(roamer) 542. register struct monst *roamer; 543. {  544.  	if(!(roamer->isminion && (roamer->data == &mons[PM_ALIGNED_PRIEST] ||  545.  				  roamer->data == &mons[PM_ANGEL]))) 546. 	        return; 547.  548.  	if(EPRI(roamer)->shralign != u.ualign.type) { 549. 	    roamer->mpeaceful = roamer->mtame = 0; 550. 	    set_malign(roamer); 551. 	}  552.  	newsym(roamer->mx, roamer->my); 553. }  554.   555.  boolean 556. in_your_sanctuary(mon, x, y)  557. struct monst *mon;	/* if non-null,  overrides  */ 558. xchar x, y;  559. { 560.  	register char roomno; 561. 	register struct monst *priest; 562.  563.  	if (mon) { 564. 	    if (is_minion(mon->data) || is_rider(mon->data)) return FALSE; 565. 	    x = mon->mx, y = mon->my; 566. 	}  567.  	if (u.ualign.record < -3)		/* sinned or worse */ 568. 	    return FALSE; 569. 	if ((roomno = temple_occupied(u.urooms)) == 0 ||  570.  		roomno != *in_rooms(x, y, TEMPLE)) 571. 	    return FALSE; 572. 	if ((priest = findpriest(roomno)) == 0) 573. 	    return FALSE; 574. 	return (boolean)(has_shrine(priest) &&  575.  			 p_coaligned(priest) &&  576.  			 priest->mpeaceful); 577. }  578.   579.  void 580. ghod_hitsu(priest)	/* when attacking "priest" in his temple */ 581. struct monst *priest; 582. {  583.  	int x, y, ax, ay, roomno = (int)temple_occupied(u.urooms); 584. 	struct mkroom *troom; 585.  586.  	if (!roomno || !has_shrine(priest)) 587. 		return; 588.  589.  	ax = x = EPRI(priest)->shrpos.x;  590. ay = y = EPRI(priest)->shrpos.y; 591. troom = &rooms[roomno - ROOMOFFSET]; 592.  593.  	if((u.ux == x && u.uy == y) || !linedup(u.ux, u.uy, x, y)) { 594. 	    if(IS_DOOR(levl[u.ux][u.uy].typ)) { 595.  596.  		if(u.ux == troom->lx - 1) { 597. 		    x = troom->hx; 598. 		    y = u.uy; 599. 		} else if(u.ux == troom->hx + 1) { 600. 		    x = troom->lx; 601. 		    y = u.uy; 602. 		} else if(u.uy == troom->ly - 1) { 603. 		    x = u.ux; 604. 		    y = troom->hy; 605. 		} else if(u.uy == troom->hy + 1) { 606. 		    x = u.ux; 607. 		    y = troom->ly; 608. 		}  609.  	    } else { 610. 		switch(rn2(4)) { 611. 		case 0:  x = u.ux; y = troom->ly; break; 612. 		case 1:  x = u.ux; y = troom->hy; break; 613. 		case 2:  x = troom->lx; y = u.uy; break; 614. 		default: x = troom->hx; y = u.uy; break; 615. 		}  616.  	    }  617.  	    if(!linedup(u.ux, u.uy, x, y)) return; 618. 	}  619.   620.  	switch(rn2(3)) { 621. 	case 0: 622. 	    pline("%s roars in anger:  \"Thou shalt suffer!\"",  623.  			a_gname_at(ax, ay)); 624. 	    break; 625. 	case 1: 626. 	    pline("%s voice booms:  \"How darest thou harm my servant!\"",  627.  			s_suffix(a_gname_at(ax, ay))); 628. 	    break; 629. 	default: 630. 	    pline("%s roars:  \"Thou dost profane my shrine!\"",  631.  			a_gname_at(ax, ay)); 632. 	    break; 633. 	}  634.   635.  	buzz(-10-(AD_ELEC-1), 6, x, y, sgn(tbx), sgn(tby)); /* bolt of lightning */ 636. 	exercise(A_WIS, FALSE); 637. }  638.   639.  void 640. angry_priest 641. {  642.  	register struct monst *priest; 643. 	struct rm *lev; 644.  645.  	if ((priest = findpriest(temple_occupied(u.urooms))) != 0) { 646. 	    wakeup(priest); 647. 	    /*  648.  	     * If the altar has been destroyed or converted, let the 649. 	     * priest run loose. 650. 	     * (When it's just a conversion and there happens to be  651.  	     *	a fresh corpse nearby, the priest ought to have an  652.  	     *	opportunity to try converting it back; maybe someday...) 653. 	     */  654.  	    lev = &levl[EPRI(priest)->shrpos.x][EPRI(priest)->shrpos.y]; 655. 	    if (!IS_ALTAR(lev->typ) ||  656.  		((aligntyp)Amask2align(lev->altarmask & AM_MASK) != 657. 			EPRI(priest)->shralign)) { 658. 		priest->ispriest = 0;		/* now a roamer */ 659. 		priest->isminion = 1;		/* but still aligned */ 660. 		/* this overloads the `shroom' field, which is now clobbered */ 661. 		EPRI(priest)->renegade = 0; 662. 	    }  663.  	}  664.  }  665.   666.  /*  667.   * When saving bones, find priests that aren't on their shrine level, 668.  * and remove them. This avoids big problems when restoring bones. 669.  */  670.  void 671. clearpriests 672. {  673.      register struct monst *mtmp, *mtmp2; 674.  675.      for(mtmp = fmon; mtmp; mtmp = mtmp2) { 676. 	mtmp2 = mtmp->nmon; 677. 	if (mtmp->ispriest && !on_level(&(EPRI(mtmp)->shrlevel), &u.uz)) 678. 	    mongone(mtmp); 679.     }  680.  }  681.   682.  /* munge priest-specific structure when restoring -dlc */ 683. void 684. restpriest(mtmp, ghostly) 685. register struct monst *mtmp; 686. boolean ghostly; 687. {  688.      if(u.uz.dlevel) { 689. 	if (ghostly) 690. 	    assign_level(&(EPRI(mtmp)->shrlevel), &u.uz); 691.     }  692.  }  693.   694.  #endif /* OVLB */ 695.  696.  /*priest.c*/