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