abstract
| - Below is the full text to pray.c from the source code of NetHack 3.0.0. To link to a particular line, write [[NetHack 3.0.0/pray.c#line123]], for example. Warning! This is the source code from an old release. For the latest release, see Source code 1. /* SCCS Id: @(#)pray.c 3.0 89/01/10 2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3. /* NetHack may be freely redistributed. See license for details. */ 4. 5. #include "hack.h" 6. 7. #ifdef THEOLOGY 8. 9. #define ALIGNLIM (5L + (moves/200L)) 10. 11. struct ghods { 12. 13. char classlet; 14. char *law, *balance, *chaos; 15. } gods[] = { 16. 17. 'A', /* Central American */ "Quetzalcotl", "Camaxtli", "Huhetotl", 18. 'B', /* Celtic */ "Nuada", "Dagda", "Morrigan", 19. 'C', /* Babylonian */ "Anu", "Ishtar", "Anshar", 20. 'E', /* Elven */ "Solonor Thelandira", 21. "Aerdrie Faenya", "Erevan Ilesere", 22. 'H', /* Greek */ "Athena", "Hermes", "Poseidon", 23. 'K', /* Celtic */ "Lugh", "Brigit", "Macannan Mac Lir", 24. #ifdef NAMED_ITEMS 25. /* It'd look funny if someone got a sword to steal souls for Arioch but Arioch 26. * goes with the wrong character class... 27. */ 28. 'P', /* Hyborian */ "Mitra", "Crom", "Set", 29. #else 30. 'P', /* Melnibonean */ "Donblas", "Grome", "Arioch", 31. #endif 32. 'R', /* Nehwon */ "Votishal", "Death", "Rat God", 33. 'S', /* Japanese */ "Amaterasu Omikami", "Raiden", "Susanowo", 34. 'T', /* Chinese */ "Shan Lai Ching", "Chih Sung-tzu", "Huan Ti", 35. 'V', /* Norse */ "Tyr", "Balder", "Loki", 36. 'W', /* Egyptian */ "Ptah", "Thoth", "Anhur", 37. 0,0,0,0 38. }; 39. 40. #define TROUBLE_STONED 1 41. #define TROUBLE_STRANGLED 2 42. #define TROUBLE_SICK 3 43. #define TROUBLE_STARVING 4 44. #define TROUBLE_HIT 5 45. #define TROUBLE_STUCK_IN_WALL 6 46. 47. #define TROUBLE_PUNISHED (-1) 48. #define TROUBLE_LYCANTHROPE (-2) 49. #define TROUBLE_CURSED_ITEMS (-3) 50. #define TROUBLE_HUNGRY (-4) 51. #define TROUBLE_POISONED (-5) 52. #define TROUBLE_HALLUCINATION (-6) 53. #define TROUBLE_BLIND (-7) 54. #define TROUBLE_WOUNDED_LEGS (-8) 55. #define TROUBLE_STUNNED (-9) 56. #define TROUBLE_CONFUSED (-10) 57. 58. /* We could force rehumanize of polyselfed people, but we can't tell 59. unintentional shape changes from the other kind. Oh well. */ 60. 61. /* Return 0 if nothing particular seems wrong, positive numbers for 62. serious trouble, and negative numbers for comparative annoyances. This 63. returns the worst problem. There may be others, and the gods may fix 64. more than one. 65. 66. This could get as bizarre as noting surrounding opponents, (or hostile dogs), 67. but that's really hard. 68. */ 69. 70. #define ugod_is_angry() (u.ualign < 0) 71. #ifdef ALTARS 72. #define on_altar() IS_ALTAR(levl[u.ux][u.uy].typ) 73. #define on_shrine() ((levl[u.ux][u.uy].altarmask & A_SHRINE) != 0) 74. #endif 75. 76. static int 77. in_trouble() 78. { 79. register struct obj *otmp; 80. int i, j, count=0; 81. 82. /* Borrowed from eat.c */ 83. 84. #define SATIATED 0 85. #define NOT_HUNGRY 1 86. #define HUNGRY 2 87. #define WEAK 3 88. #define FAINTING 4 89. #define FAINTED 5 90. #define STARVED 6 91. 92. if(Stoned) return(TROUBLE_STONED); 93. if(Strangled) return(TROUBLE_STRANGLED); 94. if(Sick) return(TROUBLE_SICK); 95. if(u.uhs >= WEAK) return(TROUBLE_STARVING); 96. if(u.uhp < 5 || (u.uhp*7 < u.uhpmax)) return(TROUBLE_HIT); 97. for (i= -1; i<=1; i++) for(j= -1; j<=1; j++) { 98. if (!i && !j) continue; 99. if (!isok(u.ux+i, u.uy+j) || IS_ROCK(levl[u.ux+i][u.uy+j].typ)) 100. count++; 101. } 102. if(count==8 103. #ifdef POLYSELF 104. && !passes_walls(uasmon) 105. #endif 106. ) return(TROUBLE_STUCK_IN_WALL); 107. if(Punished) return(TROUBLE_PUNISHED); 108. #ifdef POLYSELF 109. if(u.ulycn >= 0) return(TROUBLE_LYCANTHROPE); 110. #endif 111. for(otmp=invent; otmp; otmp=otmp->nobj) 112. if((otmp->otyp==LOADSTONE || otmp->otyp==LUCKSTONE) && 113. otmp->cursed) 114. return(TROUBLE_CURSED_ITEMS); 115. if((uarmh && uarmh->cursed) || /* helmet */ 116. (uarms && uarms->cursed) || /* shield */ 117. (uarmg && uarmg->cursed) || /* gloves */ 118. (uarm && uarm->cursed) || /* armor */ 119. (uarmc && uarmc->cursed) || /* cloak */ 120. (uarmf && uarmf->cursed) || /* boots */ 121. #ifdef SHIRT 122. (uarmu && uarmu->cursed) || /* shirt */ 123. #endif 124. (uwep && (uwep->olet == WEAPON_SYM || uwep->otyp==PICK_AXE 125. || uwep->otyp==TIN_OPENER || uwep->otyp==HEAVY_IRON_BALL) && 126. (uwep->cursed)) || 127. (uleft && uleft->cursed) || 128. (uright && uright->cursed) || 129. (uamul && uamul->cursed) || 130. (ublindf && ublindf->cursed)) 131. 132. return(TROUBLE_CURSED_ITEMS); 133. 134. if(u.uhs >= HUNGRY) return(TROUBLE_HUNGRY); 135. for(i=0; i 136. if(ABASE(i) < AMAX(i)) return(TROUBLE_POISONED); 137. if(Hallucination) return(TROUBLE_HALLUCINATION); 138. if(Blinded > 1) return(TROUBLE_BLIND); 139. if(Wounded_legs) return (TROUBLE_WOUNDED_LEGS); 140. if(HStun) return (TROUBLE_STUNNED); 141. if(HConfusion) return (TROUBLE_CONFUSED); 142. 143. return(0); 144. } 145. 146. static void 147. fix_worst_trouble(trouble) 148. register int trouble; 149. { 150. int i; 151. u.ublesscnt += rnz(100); 152. switch (trouble) { 153. case TROUBLE_STONED: 154. You("feel more limber."); 155. Stoned = 0; 156. break; 157. case TROUBLE_STRANGLED: 158. You("can breathe again."); 159. Strangled = 0; 160. break; 161. case TROUBLE_HUNGRY: 162. case TROUBLE_STARVING: 163. Your("stomach feels content."); 164. init_uhunger (); 165. losestr(-1); 166. flags.botl = 1; 167. break; 168. case TROUBLE_SICK: 169. You("feel better."); 170. make_sick(0L,FALSE); 171. break; 172. case TROUBLE_HIT: 173. if (!Blind) { 174. const char *tmp = Hallucination ? hcolor() : golden; 175. pline("A%s %s glow surrounds you.", 176. index(vowels,*tmp) ? "n" : "", tmp); 177. } else You("feel much better."); 178. u.uhp = u.uhpmax += 5; 179. flags.botl = 1; 180. break; 181. case TROUBLE_STUCK_IN_WALL: 182. Your("surroundings change."); 183. tele(); 184. break; 185. case TROUBLE_PUNISHED: 186. Your("chain disappears."); 187. unpunish(); 188. break; 189. #ifdef POLYSELF 190. case TROUBLE_LYCANTHROPE: 191. You("feel purified."); 192. if(uasmon == &mons[u.ulycn] && !Polymorph_control) 193. rehumanize(); 194. u.ulycn = -1; /* now remove the curse */ 195. break; 196. #endif 197. case TROUBLE_CURSED_ITEMS: 198. { struct obj *otmp; 199. char * what; 200. otmp = (struct obj *)0; 201. what = NULL; 202. if (uarmh && uarmh->cursed) /* helmet */ 203. otmp = uarmh; 204. else if (uarms && uarms->cursed) /* shield */ 205. otmp = uarms; 206. else if (uarmg && uarmg->cursed) /* gloves */ 207. otmp = uarmg; 208. else if (uarm && uarm->cursed) /* armor */ 209. otmp = uarm; 210. else if (uarmc && uarmc->cursed) /* cloak */ 211. otmp = uarmc; 212. else if (uarmf && uarmf->cursed) /* boots */ 213. otmp = uarmf; 214. #ifdef SHIRT 215. else if (uarmu && uarmu->cursed) /* shirt */ 216. otmp = uarmu; 217. #endif 218. else if (uleft && uleft->cursed) { 219. otmp = uleft; 220. what = "left ring softly glows"; 221. } else if (uright && uright->cursed) { 222. otmp = uright; 223. what = "right ring softly glows"; 224. } else if (uamul && uamul->cursed) /* amulet */ 225. otmp = uamul; 226. else if (ublindf && ublindf->cursed) /* blindfold */ 227. otmp = ublindf; 228. else if (welded(uwep)) otmp = uwep; 229. else { 230. for(otmp=invent; otmp; otmp=otmp->nobj) 231. if ((otmp->otyp==LOADSTONE || 232. otmp->otyp==LUCKSTONE) && otmp->cursed) 233. break; 234. } 235. 236. otmp->cursed = 0; 237. otmp->bknown = 1; 238. if (!Blind) 239. Your("%s %s.", 240. what ? what : aobjnam (otmp, "softly glow"), 241. Hallucination ? hcolor() : amber); 242. break; 243. } 244. case TROUBLE_HALLUCINATION: 245. pline ("Looks like you are back in Kansas."); 246. make_hallucinated(0L,FALSE); 247. break; 248. case TROUBLE_BLIND: 249. pline ("Your %s feel better.", makeplural(body_part(EYE))); 250. make_blinded(0L,FALSE); 251. break; 252. case TROUBLE_POISONED: 253. if (Hallucination) 254. pline("There's a tiger in your tank."); 255. else 256. You("feel in good health again."); 257. for(i=0; i 258. if(ABASE(i) < AMAX(i)) { 259. ABASE(i) = AMAX(i); 260. flags.botl = 1; 261. } 262. } 263. break; 264. case TROUBLE_WOUNDED_LEGS: 265. heal_legs(); 266. break; 267. case TROUBLE_STUNNED: 268. make_stunned(0L,TRUE); 269. break; 270. case TROUBLE_CONFUSED: 271. make_confused(0L,TRUE); 272. break; 273. } 274. } 275. 276. static void 277. angrygods() { 278. register int tmp; 279. 280. u.ublessed = 0; 281. 282. /* changed from tmp = u.ugangr + abs (u.uluck) -- rph */ 283. tmp = 3*u.ugangr + 284. (u.uluck > 0 || u.ualign > 3 ? -u.uluck/3 : -u.uluck); 285. if (tmp < 0) tmp = 0; /* possible if bad alignment but good luck */ 286. tmp = (tmp > 15 ? 15 : tmp); /* lets be a little reasonable */ 287. switch (tmp ? rn2(tmp): 0) { 288. 289. case 0: 290. case 1: if (Hallucination) 291. You("feel %sholy dread.", 292. u.ualigntyp == U_CHAOTIC ? "an un" : "a "); 293. else You("feel that %s is %s.", 294. # ifdef ALTARS 295. on_altar() ? a_gname() : u_gname(), 296. # else 297. u_gname(), 298. # endif 299. u.ualigntyp == U_NEUTRAL ? "offended" : "angry"); 300. break; 301. case 2: 302. case 3: 303. # ifdef POLYSELF 304. pline("A voice booms out: \"Thou %s, %s.\"", 305. ugod_is_angry() ? "hast strayed from the path" : 306. "art arrogant", 307. u.usym == S_HUMAN ? "mortal" : "creature"); 308. # else 309. pline("A voice booms out: \"Thou %s, mortal.\"", 310. ugod_is_angry() ? "hast strayed from the path" : 311. "art arrogant"); 312. # endif 313. pline("\"Thou must relearn thy lessons!\""); 314. adjattrib(A_WIS, -1, FALSE); 315. if (u.ulevel > 1) { 316. losexp(); 317. if(u.uhp < 1) u.uhp = 1; 318. if(u.uhpmax < 1) u.uhpmax = 1; 319. } else { 320. u.uexp = 0; 321. flags.botl = 1; 322. } 323. break; 324. case 6: if (!Punished) { 325. punish((struct obj *)0); 326. break; 327. } /* else fall thru */ 328. case 4: 329. case 5: if (!Blind) { 330. const char *temp = Hallucination ? hcolor() : black; 331. pline("A%s %s glow surrounds you.", 332. index(vowels,*temp) ? "n" : "", temp); 333. } 334. rndcurse(); 335. break; 336. case 7: 337. case 8: pline("A voice booms out: \"Thou durst call upon me?\""); 338. # ifdef POLYSELF 339. pline("\"Then die, %s!\"", 340. u.usym == S_HUMAN ? "mortal" : "creature"); 341. # else 342. pline("\"Then die, mortal!\""); 343. # endif 344. (void) makemon(&mons[ndemon()], u.ux, u.uy); 345. break; 346. 347. default: pline("Suddenly, a bolt of lightning strikes you!"); 348. if (Reflecting) { 349. shieldeff(u.ux, u.uy); 350. if (Blind) 351. pline("For some reason you're unaffected."); 352. else { 353. if (Reflecting & W_AMUL) { 354. pline("It reflects from your medallion."); 355. #if defined(EXPLORE_MODE) || defined(WIZARD) 356. makeknown(AMULET_OF_REFLECTION); 357. #endif 358. } else { 359. pline("It reflects from your shield."); 360. /* No ifdef here since they could survive with an amulet of 361. * life saving which wasn't possible above. 362. */ 363. makeknown(SHIELD_OF_REFLECTION); 364. } 365. } 366. You("hear a cosmic sigh, and sense a decision being made."); 367. pline("A wide-angle disintegration beam hits you!"); 368. goto ohno; 369. } else if (Shock_resistance) { 370. shieldeff(u.ux, u.uy); 371. pline("It seems not to affect you."); 372. pline("However, the ensuing disintegration beam does."); 373. ohno: 374. if (Disint_resistance) { 375. You("bask in the disintegration beam for a minute..."); 376. pline("A voice rings out: \"I believe it not!\""); 377. break; 378. } 379. } 380. You("fry to a crisp."); 381. killer = "holy wrath"; 382. done("died"); 383. break; 384. } 385. u.ublesscnt = rnz(300); 386. return; 387. } 388. 389. static void 390. pleased() { 391. char *tmp; 392. int trouble = in_trouble (); /* what's your worst difficulty? */ 393. int pat_on_head = 0; 394. 395. if (u.ugangr > 0) u.ugangr--; 396. You("feel that %s is pleased.", 397. #ifndef ALTARS 398. u_gname()); 399. #else 400. on_altar() ? a_gname() : u_gname()); 401. 402. /* not your deity */ 403. if (on_altar() && 404. (levl[u.ux][u.uy].altarmask & ~A_SHRINE) != u.ualigntyp + 1) { 405. adjalign(-1); 406. return; 407. } else if (u.ualign < 2) adjalign(1); 408. #endif 409. 410. 411. /* depending on your luck, the gods will: 412. - fix your worst problem if it's major. 413. - fix all your major problems. 414. - fix your worst problem if it's minor. 415. - fix all of your problems. 416. - do you a gratuitous favor. 417. 418. if you make it to the the last category, you roll randomly again 419. to see what they do for you. 420. 421. If your luck is at least 0, then you are guaranteed rescued 422. from your worst major problem. */ 423. 424. if (!trouble) pat_on_head = 1; 425. else { 426. #ifdef ALTARS 427. int action = rn1(on_altar() ? 3 + on_shrine() : 2, u.uluck+1); 428. 429. if (!on_altar()) action = max(action,2); 430. #else 431. int action = rn1(4,u.uluck+1); 432. #endif 433. 434. switch(min(action,5)) { 435. case 5: pat_on_head = 1; 436. case 4: do fix_worst_trouble(trouble); 437. while(trouble = in_trouble()); 438. break; 439. 440. case 3: fix_worst_trouble(trouble); 441. case 2: while((trouble = in_trouble()) > 0) 442. fix_worst_trouble(trouble); 443. break; 444. 445. case 1: if (trouble > 0) fix_worst_trouble(trouble); 446. } 447. } 448. 449. if(pat_on_head) 450. switch(rn2((u.uluck + 6)>>1)) { 451. 452. case 0: break; 453. case 1: 454. if(uwep && (uwep->olet == WEAPON_SYM || uwep->otyp 455. == PICK_AXE) && (!uwep->blessed)) { 456. if (uwep->cursed) { 457. uwep->cursed = 0; 458. uwep->bknown = 1; 459. if (!Blind) 460. Your("%s %s.", 461. aobjnam(uwep, "softly glow"), 462. Hallucination ? hcolor() : amber); 463. } else if(uwep->otyp < BOW) { 464. uwep->blessed = uwep->bknown = 1; 465. if (!Blind) { 466. tmp = Hallucination ? hcolor() : light_blue; 467. Your("%s with a%s %s aura.", 468. aobjnam(uwep, "softly glow"), 469. index(vowels,*tmp) ? "n" : "", tmp); 470. } 471. } 472. } 473. break; 474. case 3: 475. #if defined(STRONGHOLD) && defined(MUSIC) 476. /* takes 2 hints to get the music to enter the Stronghold */ 477. if (flags.soundok) { 478. if(music_heard < 1) { 479. pline("A voice booms out: \"Hark, mortal!\""); 480. verbalize("To enter the castle, thou must play the right tune!"); 481. music_heard++; 482. break; 483. } else if (music_heard < 2) { 484. You("hear a divine music..."); 485. pline("It sounds like: \"%s\".", tune); 486. music_heard++; 487. break; 488. } 489. } 490. /* Otherwise, falls into next case */ 491. #endif 492. case 2: if (!Blind) { 493. tmp = Hallucination ? hcolor() : golden; 494. You("are surrounded by a%s %s glow.", 495. index(vowels,*tmp) ? "n" : "", tmp); 496. } 497. u.uhp = u.uhpmax += 5; 498. ABASE(A_STR) = AMAX(A_STR); 499. if (u.uhunger < 900) init_uhunger(); 500. if (u.uluck < 0) u.uluck = 0; 501. make_blinded(0L,TRUE); 502. flags.botl = 1; 503. break; 504. case 4: 505. { register struct obj *otmp; 506. 507. tmp = Hallucination ? hcolor() : light_blue; 508. if (Blind) 509. You("feel the power of %s.", u_gname()); 510. else You("are surrounded by a%s %s aura.", 511. index(vowels,*tmp) ? "n" : "", tmp); 512. for(otmp=invent; otmp; otmp=otmp->nobj) { 513. if (otmp->cursed) { 514. otmp->cursed = 0; 515. if (!Blind) 516. Your("%s %s.", 517. aobjnam(otmp, "softly glow"), 518. Hallucination ? hcolor() : amber); 519. } 520. } 521. break; 522. } 523. case 5: pline("A voice booms out: \"Thou hast pleased me with thy progress,\""); 524. pline("\"and thus I grant thee the gift of "); 525. if (!(HTelepat & INTRINSIC)) { 526. HTelepat |= INTRINSIC; 527. addtopl("Telepathy!\""); 528. } else if (!(Fast & INTRINSIC)) { 529. Fast |= INTRINSIC; 530. addtopl("Speed!\""); 531. } else if (!(Stealth & INTRINSIC)) { 532. Stealth |= INTRINSIC; 533. addtopl("Stealth!\""); 534. } else { 535. if (!(Protection & INTRINSIC)) { 536. Protection |= INTRINSIC; 537. if (!u.ublessed) u.ublessed = rnd(3) + 1; 538. } else u.ublessed++; 539. addtopl("our protection!\""); 540. } 541. pline ("\"Use it wisely in my name!\""); 542. break; 543. 544. case 7: 545. #ifdef ELBERETH 546. if (u.ualign > 3 && !u.uhand_of_elbereth) { 547. u.uhand_of_elbereth = TRUE; 548. HSee_invisible |= INTRINSIC; 549. HFire_resistance |= INTRINSIC; 550. HCold_resistance |= INTRINSIC; 551. HPoison_resistance |= INTRINSIC; 552. if (u.ualigntyp != U_CHAOTIC) { 553. pline("A voice booms out: \"I crown thee...\""); 554. pline("\"The Hand of Elbereth!\""); 555. #ifdef NAMED_ITEMS 556. if(uwep && (uwep->otyp == LONG_SWORD)) { 557. bless(uwep); 558. uwep->bknown = 1; 559. uwep->rustfree = 1; 560. (void)oname(uwep, "Excalibur", 1); 561. } 562. #endif 563. } else { 564. register struct obj *obj; 565. pline("A voice booms out: \"Thou art chosen to steal souls for Arioch!\""); 566. /* This does the same damage as Excalibur. 567. * Disadvantages: doesn't do bonuses to undead; 568. * doesn't aid searching. 569. * Advantages: part of that bonus is a level 570. * drain. 571. * Disadvantage: player cannot start with a 572. * +5 weapon and turn it into a Stormbringer. 573. * Advantage: they don't need to already have a 574. * sword of the right type to get it... 575. */ 576. if (Blind) 577. pline("Something appears at your %s.", 578. makeplural(body_part(FOOT))); 579. else 580. pline("A %s sword appears at your %s!", 581. Hallucination ? hcolor() : "black", 582. makeplural(body_part(FOOT))); 583. obj = mksobj(BROADSWORD, FALSE); 584. obj = oname(obj, "Stormbringer", 0); 585. obj->rustfree = 1; 586. obj->cursed = 0; 587. obj->blessed = 1; 588. /* Why bless it? Why not. After all, chaotic gods 589. * will bless regular weapons. And blessed really 590. * means given sanctified to a deity, which is certainly 591. * sensible even for Stormbringer and a chaotic deity... 592. */ 593. obj->spe = 1; 594. dropy(obj); 595. } 596. break; 597. } 598. #endif 599. 600. case 6: pline ("An object appears at your %s!", 601. makeplural(body_part(FOOT))); 602. #ifdef SPELLS 603. (void) mkobj_at(SPBOOK_SYM, u.ux, u.uy); 604. #else 605. (void) mkobj_at(SCROLL_SYM, u.ux, u.uy); 606. #endif 607. break; 608. 609. default: impossible("Confused deity!"); 610. break; 611. } 612. u.ublesscnt = rnz(350); 613. #ifdef HARD 614. # ifndef ELBERETH 615. u.ublesscnt += (u.udemigod * rnz(1000)); 616. # else 617. u.ublesscnt += ((u.udemigod + u.uhand_of_elbereth) * rnz(1000)); 618. # endif 619. #endif 620. return; 621. } 622. 623. static void 624. gods_upset() 625. { 626. #ifdef HARD 627. u.ugangr++; 628. angrygods(); 629. #else 630. if (u.ugangr++) angrygods(); 631. else { /* exactly one warning */ 632. #ifdef ALTARS 633. pline("The voice of %s booms out: \"Thou hast angered me.\"", 634. a_gname()); 635. #else 636. pline("A voice booms out: \"Thou hast angered me.\""); 637. #endif 638. pline("\"Disturb me again at thine own risk!\""); 639. } 640. #endif 641. } 642. 643. #ifdef ENDGAME 644. static const char sacrifice_types[] = { FOOD_SYM, AMULET_SYM, 0 }; 645. #endif 646. 647. static void 648. consume_offering(otmp) 649. register struct obj *otmp; 650. { 651. if (Hallucination) 652. pline ("Your sacrifice sprouts wings and a propeller and roars away!"); 653. else pline ("Your sacrifice is consumed in a %s!", 654. u.ualigntyp == U_LAWFUL ? "flash of light" : "burst of flame"); 655. useup(otmp); 656. } 657. 658. int 659. dosacrifice() 660. { 661. register struct obj *otmp; 662. int value = 0; 663. 664. #ifdef ALTARS 665. if (!on_altar()) { 666. You("are not standing on an altar."); 667. return 0; 668. } 669. #endif /* ALTARS /**/ 670. 671. #ifdef ENDGAME 672. if (dlevel == ENDLEVEL) { 673. if (!(otmp = getobj(sacrifice_types, "sacrifice"))) return 0; 674. } else 675. if (!(otmp = floorfood("sacrifice", 0))) return 0; 676. #else 677. if (!(otmp = floorfood("sacrifice", 0))) return 0; 678. #endif 679. /* 680. Was based on nutritional value and aging behavior (< 50 moves). 681. Sacrificing a food ration got you max luck instantly, making the 682. gods as easy to please as an angry dog! 683. 684. Now only accepts corpses, based on their level (presumably, how hard 685. they were to kill). Human sacrifice, as well as sacrificing unicorns 686. of your alignment, is strongly discouraged. (We can't tell whether a dog 687. corpse was tame, so you can still sacrifice it.) 688. */ 689. 690. #define MAXVALUE 17 /* Highest corpse value */ 691. 692. if (otmp->otyp == CORPSE) { 693. register struct permonst *mtmp = &mons[otmp->corpsenm]; 694. 695. if (otmp->corpsenm == PM_ACID_BLOB || (moves <= otmp->age + 50)) 696. value = mtmp->mlevel + 1; /* only fresh kills */ 697. 698. if (is_human(mtmp)) { /* Human sacrifice! */ 699. #ifdef POLYSELF 700. if (is_demon(uasmon)) 701. You("find the idea very satisfying."); 702. else 703. #endif 704. if (u.ualigntyp != U_CHAOTIC) 705. pline("You'll regret this infamous offense!"); 706. #ifdef ALTARS 707. if (levl[u.ux][u.uy].altarmask & ~A_SHRINE) { 708. /* curse the lawful/neutral altar */ 709. pline("The altar is stained with human blood."); 710. levl[u.ux][u.uy].altarmask = A_CHAOS; 711. angry_priest(); 712. } else { 713. register struct monst *dmon; 714. const char *color = Hallucination ? hcolor() : black; 715. /* Human sacrifice on a chaotic altar is equivalent to demon summoning */ 716. pline("The blood floods over the altar, which vanishes in a%s %s cloud!", 717. index(vowels, *color) ? "n" : "", color); 718. levl[u.ux][u.uy].typ = ROOM; 719. if(Invisible) newsym(u.ux, u.uy); 720. if(dmon = makemon(&mons[dlord()], u.ux, u.uy)) { 721. You("have summoned a demon lord!"); 722. if (u.ualigntyp == U_CHAOTIC) 723. dmon->mpeaceful = 1; 724. You("are terrified, and unable to move."); 725. nomul(-3); 726. } else pline("The cloud dissipates."); 727. } 728. #endif 729. if (u.ualigntyp != U_CHAOTIC) { 730. adjalign(-5); 731. u.ugangr += 3; 732. adjattrib(A_WIS, -1, TRUE); 733. if (!Inhell) angrygods(); 734. change_luck(-5); 735. } else adjalign(5); 736. useup(otmp); 737. return(1); 738. } else if (is_undead(mtmp)) { /* Not demons--no demon corpses */ 739. if (u.ualigntyp != U_CHAOTIC) 740. value += 1; 741. } else if (mtmp->mlet == S_UNICORN) { 742. int unicalign; 743. 744. if (mtmp == &mons[PM_BLACK_UNICORN]) unicalign = -1; 745. else if (mtmp == &mons[PM_GREY_UNICORN]) unicalign = 0; 746. else if (mtmp == &mons[PM_WHITE_UNICORN]) unicalign = 1; 747. if (unicalign == u.ualigntyp) { 748. pline("Such an action is an insult to %s!", (unicalign== -1) 749. ? "chaos" : unicalign ? "law" : "neutrality"); 750. adjattrib(A_WIS, -1, TRUE); 751. value = -5; 752. } else if ((unicalign == -u.ualigntyp) || 753. (!u.ualigntyp && unicalign)) { 754. if (u.ualign < ALIGNLIM) 755. You("feel stridently %s!", (u.ualigntyp== U_CHAOTIC) ? 756. "chaotic" : u.ualigntyp ? "lawful" : "neutral"); 757. else You("feel you are thoroughly on the right path."); 758. u.ualign = ALIGNLIM; 759. value += 3; 760. } 761. } 762. } 763. #ifdef ENDGAME 764. if (otmp->otyp == AMULET_OF_YENDOR) { 765. if (dlevel != ENDLEVEL) { 766. if (otmp->spe == 0) { 767. if (Hallucination) 768. You("feel homesick."); 769. else 770. You("feel an urge to return to the surface."); 771. return (1); 772. } 773. } else 774. if (otmp->spe < 0) { /* fake! */ 775. if (flags.soundok) 776. You("hear a nearby thunderclap."); 777. if (!otmp->known) { 778. You("realize you have made a %s.", 779. Hallucination ? "boo-boo" : "mistake"); 780. otmp->known = 1; 781. return (1); 782. } else { 783. /* don't you dare try to fool the gods */ 784. change_luck(-3); 785. u.ugangr += 3; 786. value = -3; 787. } 788. } 789. else { 790. /* The final Test. Did you win? */ 791. if(uamul && uamul->otyp == otmp->otyp) Amulet_off(); 792. useup(otmp); /* well, it's gone now */ 793. You("offer the Amulet to %s...", a_gname()); 794. if (u.ualigntyp != 795. (levl[u.ux][u.uy].altarmask & ~A_SHRINE) - 1) { 796. /* And the opposing team picks him up and 797. carries him off on their shoulders */ 798. pline("%s accepts your gift, and gains dominion over %s...", 799. a_gname(), u_gname()); 800. pline("%s is enraged...", u_gname()); 801. pline("Fortunately, %s permits you to live...", a_gname()); 802. pline("A cloud of %s smoke surrounds you...", 803. Hallucination ? hcolor() : "orange"); 804. done("escaped"); 805. } else { /* super big win */ 806. pline("An invisible choir sings, and you are bathed in radiance..."); 807. pline("\"Congratulations, mortal! In return for thy service,"); 808. pline("\"I grant thee the gift of Immortality!\""); 809. You("ascend to the status of Demigod..."); 810. done("ascended"); 811. } 812. } 813. } 814. #endif /* ENDGAME */ 815. 816. #ifndef ALTARS /* No altars in shops */ 817. if (otmp->unpaid && u.ualigntyp != U_CHAOTIC) { 818. You("realize sacrificing what is not yours is a very chaotic act."); 819. value = -3; 820. } 821. #endif 822. 823. if (value == 0 824. #ifndef ALTARS 825. || Inhell 826. #endif 827. ) { 828. pline(nothing_happens); 829. return (1); 830. } 831. 832. if (value < 0) /* I don't think the gods are gonna like this... */ 833. gods_upset(); 834. else { 835. 836. int saved_anger = u.ugangr; 837. int saved_cnt = u.ublesscnt; 838. int saved_luck = u.uluck; 839. boolean consumed = FALSE; 840. #ifdef ALTARS 841. /* Sacrificing at an altar of a different alignment */ 842. if (u.ualigntyp != (levl[u.ux][u.uy].altarmask & ~A_SHRINE) - 1) { 843. /* Is this a conversion ? */ 844. if(ugod_is_angry()) { 845. if(u.ualignbase[0] == u.ualignbase[1]) { 846. consume_offering(otmp); 847. You("have a strong feeling that %s is angry...", 848. u_gname()); 849. pline("%s accepts your allegiance.",a_gname()); 850. You("have a sudden sense of a new direction."); 851. /* The player wears a helm of opposite alignment? */ 852. if (uarmh && uarmh->otyp == HELM_OF_OPPOSITE_ALIGNMENT) 853. u.ualignbase[0] = 854. (levl[u.ux][u.uy].altarmask & ~A_SHRINE) - 1; 855. else 856. u.ualigntyp = u.ualignbase[0] = 857. (levl[u.ux][u.uy].altarmask & ~A_SHRINE) - 1; 858. flags.botl = 1; 859. /* Beware, Conversion is costly */ 860. change_luck(-3); 861. u.ublesscnt += 300; 862. adjalign((int)(u.ualignbase[1] * (ALIGNLIM / 2))); 863. } else { 864. pline("%s rejects your sacrifice!",a_gname()); 865. pline("The voice of %s booms: \"Suffer, infidel!\"", 866. u_gname()); 867. adjalign(-5); 868. u.ugangr += 3; 869. adjattrib(A_WIS, -2, TRUE); 870. if (!Inhell) angrygods(); 871. change_luck(-5); 872. } 873. return(1); 874. } else { 875. consume_offering(otmp); 876. consumed = TRUE; 877. You("sense a conflict between %s and %s.", 878. u_gname(), a_gname()); 879. if (rn2(8 + (int)u.ulevel) > 5) { 880. You("feel the power of %s increase.", 881. u_gname()); 882. change_luck(1); 883. levl[u.ux][u.uy].altarmask &= A_SHRINE; 884. /* the following accommodates stupid compilers */ 885. levl[u.ux][u.uy].altarmask = 886. levl[u.ux][u.uy].altarmask | (u.ualigntyp + 1); 887. if (!Blind) 888. pline("The newly consecrated altar glows %s.", 889. Hallucination ? hcolor() : 890. u.ualigntyp == U_LAWFUL ? white : 891. u.ualigntyp ? black : "gray"); 892. } else { 893. pline("Unluckily, you feel the power of %s decrease.", 894. u_gname()); 895. change_luck(-1); 896. } 897. return(1); 898. } 899. } 900. #endif 901. if(!consumed) consume_offering(otmp); 902. /* OK, you get brownie points. */ 903. if(u.ugangr) { 904. u.ugangr -= ((value * (u.ualigntyp == U_CHAOTIC ? 2 : 3)) / MAXVALUE); 905. if(u.ugangr < 0) u.ugangr = 0; 906. if(u.ugangr != saved_anger) { 907. if (u.ugangr) { 908. if(Hallucination) 909. pline("The gods seem %s.", hcolor()); 910. else pline("The gods seem slightly mollified."); 911. 912. if ((int)u.uluck < 0) change_luck(1); 913. } else { 914. if (Hallucination) 915. pline("The gods seem cosmic (not a new fact)."); 916. else pline ("The gods seem mollified."); 917. 918. if ((int)u.uluck < 0) u.uluck = 0; 919. } 920. } else { /* not satisfied yet */ 921. if (Hallucination) 922. pline("The gods seem tall."); 923. else You("have a feeling of inadequacy."); 924. } 925. } 926. else if (u.ublesscnt > 0) { 927. u.ublesscnt -= ((value * (u.ualigntyp == U_CHAOTIC ? 500 : 300)) 928. / MAXVALUE); 929. if(u.ublesscnt < 0) u.ublesscnt = 0; 930. if(u.ublesscnt != saved_cnt) { 931. 932. if (u.ublesscnt) { 933. if (Hallucination) 934. You("realize that the gods are not like you and I."); 935. else 936. You("have a hopeful feeling."); 937. if ((int)u.uluck < 0) change_luck(1); 938. } else { 939. if (Hallucination) 940. pline("Overall, there is a smell of fried onions."); 941. else 942. You("have a feeling of reconciliation."); 943. if ((int)u.uluck < 0) u.uluck = 0; 944. } 945. } 946. } else { 947. /* you were already in pretty good standing */ 948. #if defined(ALTARS) && defined(NAMED_ITEMS) 949. /* The player can gain an artifact */ 950. if(!rn2(10)) { 951. otmp = mk_aligned_artifact((int)(levl[u.ux][u.uy].altarmask & ~A_SHRINE) - 1); 952. if(otmp) { 953. dropy(otmp); 954. pline("An object appears at your %s!", 955. makeplural(body_part(FOOT))); 956. return(1); 957. } 958. } 959. #endif 960. change_luck((value * LUCKMAX) / (MAXVALUE * 2)); 961. if (u.uluck != saved_luck) { 962. You(Hallucination ? 963. "see crabgrass at your %s. A funny thing in a dungeon." : 964. "glimpse a four-leaf clover at your %s.", 965. makeplural(body_part(FOOT))); 966. } 967. } 968. } 969. return(1); 970. } 971. 972. int 973. dopray() { /* M. Stephenson (1.0.3b) */ 974. int trouble = in_trouble(); 975. #ifdef ALTARS 976. int aligntyp = 977. on_altar() ? 978. (int)(levl[u.ux][u.uy].altarmask & ~A_SHRINE) - 1 : 979. u.ualigntyp; 980. int align; 981. 982. if (u.ualigntyp && u.ualigntyp == -aligntyp) align = -u.ualign; 983. /* Opposite alignment altar */ 984. else if (u.ualigntyp != aligntyp) align = u.ualign / 2; 985. /* Different (but non-opposite) alignment altar */ 986. else align = u.ualign; 987. #else 988. int aligntyp = u.ualigntyp; 989. int align = u.ualign; 990. #endif 991. 992. #ifdef POLYSELF 993. if (is_undead(uasmon)) { 994. if (aligntyp == 1 || (aligntyp == 0 && !rn2(10))) { 995. pline(aligntyp == 1 ? 996. "\"Vile creature, thou durst call upon me?\"" : 997. "\"Walk no more, perversion of nature!\""); 998. You("feel like you are falling apart."); 999. rehumanize(); 1000. losehp(rnd(20), "residual undead turning effect"); 1001. return(1); 1002. } 1003. } 1004. if (is_demon(uasmon) && (aligntyp != -1)) { 1005. pline("The very idea of praying to a %s god is repugnant to you.", 1006. u.ualigntyp ? "lawful" : "neutral"); 1007. return(0); 1008. } 1009. #endif 1010. if (Inhell && u.ualigntyp != U_CHAOTIC) { 1011. pline("Since you are in hell, %s won't help you.", 1012. # ifdef ALTARS 1013. on_altar() ? a_gname() : 1014. # endif 1015. u_gname()); 1016. aggravate(); 1017. return(0); 1018. } 1019. 1020. #ifdef WIZARD 1021. if (wizard) { 1022. pline("Force the gods to be pleased? "); 1023. if (yn() == 'y') { 1024. u.ublesscnt = 0; 1025. if (u.uluck < 0) u.uluck = 0; 1026. u.ugangr = 0; 1027. if (align < 1) align = 1; 1028. } 1029. } 1030. #endif 1031. if ((!trouble && (u.ublesscnt > 0)) || 1032. ((trouble < 0) && (u.ublesscnt > 100)) /* minor difficulties */ || 1033. ((trouble > 0) && (u.ublesscnt > 200)) /* big trouble */ 1034. ) { 1035. u.ublesscnt += rnz(250); 1036. change_luck(-3); 1037. gods_upset(); 1038. } else if ((int)u.uluck < 0 || u.ugangr || align < 0) 1039. angrygods(); /* naughty */ 1040. else if (align >= 0) pleased(); /* nice */ 1041. nomovemsg = "You finish your prayer."; 1042. nomul(-3); 1043. return(1); 1044. } 1045. #endif /* THEOLOGY */ 1046. 1047. int 1048. doturn() 1049. { /* Knights & Priest(esse)s only please */ 1050. 1051. register struct monst *mtmp; 1052. register int xlev = 6; 1053. 1054. if((pl_character[0] != 'P') && 1055. (pl_character[0] != 'K')) { 1056. 1057. You("don't know how to turn undead!"); 1058. return(0); 1059. } 1060. #if defined(POLYSELF) || defined(THEOLOGY) 1061. if ( 1062. # ifdef POLYSELF 1063. (u.ualigntyp != U_CHAOTIC && (is_demon(uasmon) || is_undead(uasmon))) 1064. # endif 1065. # if defined(POLYSELF) && defined(THEOLOGY) 1066. || 1067. # endif 1068. # ifdef THEOLOGY 1069. u.ugangr > 6 /* "Die, mortal!" */ 1070. # endif 1071. ) { 1072. 1073. pline("For some reason, the gods seem not to listen to you."); 1074. aggravate(); 1075. return(0); 1076. } 1077. #endif 1078. if (Inhell && u.ualigntyp != U_CHAOTIC) { 1079. #ifdef THEOLOGY 1080. pline("Since you are in hell, %s won't help you.", u_gname()); 1081. #else 1082. pline("Since you are in hell, the gods won't help you."); 1083. #endif 1084. aggravate(); 1085. return(0); 1086. } 1087. #ifdef THEOLOGY 1088. pline("Calling upon %s, you chant an arcane formula.", u_gname()); 1089. #else 1090. pline("Calling upon the gods, you chant an arcane formula."); 1091. #endif 1092. for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) 1093. if(cansee(mtmp->mx,mtmp->my)) { 1094. if(!mtmp->mtame && !mtmp->mpeaceful && (is_undead(mtmp->data) || 1095. (is_demon(mtmp->data) && (u.ulevel > (MAXULEV/2))))) { 1096. 1097. if(Confusion) { 1098. pline("Unfortunately, your voice falters."); 1099. mtmp->mflee = mtmp->mfroz = mtmp->msleep = 0; 1100. } else if (! resist(mtmp, '\0', 0, TELL)) 1101. switch (mtmp->data->mlet) { 1102. /* this is intentional, lichs are tougher 1103. than zombies. */ 1104. case S_LICH: xlev += 2; 1105. case S_GHOST: xlev += 2; 1106. case S_VAMPIRE: xlev += 2; 1107. case S_WRAITH: xlev += 2; 1108. case S_MUMMY: xlev += 2; 1109. case S_ZOMBIE: 1110. mtmp->mflee = 1; /* at least */ 1111. if(u.ulevel >= xlev) { 1112. if(!resist(mtmp, '\0', 0, NOTELL)) { 1113. if(u.ualigntyp == U_CHAOTIC) { 1114. mtmp->mpeaceful = 1; /* make them friendly */ 1115. } else { /* damn them */ 1116. You("destroy %s!", mon_nam(mtmp)); 1117. mondied(mtmp); 1118. } 1119. } 1120. } 1121. break; 1122. default: mtmp->mflee = 1; 1123. break; 1124. } 1125. } 1126. } 1127. nomul(-5); 1128. return(1); 1129. } 1130. 1131. #ifdef ALTARS 1132. char * 1133. a_gname() 1134. { 1135. return(a_gname_at(u.ux, u.uy)); 1136. } 1137. 1138. char * 1139. a_gname_at(x,y) /* returns the name of an altar's deity */ 1140. xchar x, y; 1141. { 1142. register int align; 1143. 1144. if(!IS_ALTAR(levl[x][y].typ)) return((char *)0); 1145. 1146. align = levl[x][y].altarmask & ~A_SHRINE; 1147. # ifdef THEOLOGY 1148. {struct ghods *aghod; 1149. 1150. for(aghod=gods; aghod->classlet; aghod++) 1151. if(aghod->classlet == pl_character[0]) 1152. switch(align) { 1153. case A_CHAOS: return(aghod->chaos); 1154. case A_NEUTRAL: return(aghod->balance); 1155. case A_LAW: return(aghod->law); 1156. default: impossible("unknown altar alignment."); 1157. return("Balance"); 1158. } 1159. impossible("Altar to unknown character's god?"); 1160. return("someone"); 1161. } 1162. # else 1163. switch(align) { 1164. case A_CHAOS: return("Chaos"); 1165. case A_NEUTRAL: return("Balance"); 1166. case A_LAW: return("Law"); 1167. default: impossible("unknown altar alignment."); 1168. return("Balance"); 1169. } 1170. # endif /* THEOLOGY */ 1171. } 1172. 1173. # ifdef THEOLOGY 1174. void 1175. altar_wrath(x, y) 1176. register int x, y; 1177. { 1178. if(!strcmp(a_gname_at(x,y), u_gname())) { 1179. pline("%s's voice booms: \"How darest thou desecrate my altar!\"", 1180. a_gname_at(x,y)); 1181. adjattrib(A_WIS, -1, FALSE); 1182. } else { 1183. pline("A voice whispers in your ear: \"Thou shalt pay, infidel!\""); 1184. change_luck(-1); 1185. } 1186. } 1187. # endif /* THEOLOGY */ 1188. #endif /* ALTARS */ 1189. 1190. #ifdef THEOLOGY 1191. char * 1192. u_gname() { /* returns the name of the player's deity */ 1193. register struct ghods *aghod; 1194. 1195. for(aghod=gods; aghod->classlet; aghod++) 1196. if(aghod->classlet == pl_character[0]) 1197. switch(u.ualigntyp) { 1198. case 1: return(aghod->law); 1199. case 0: return(aghod->balance); 1200. case -1: return(aghod->chaos); 1201. default: impossible("unknown character alignment."); 1202. return("Balance"); 1203. } 1204. impossible("atheist player?"); 1205. return("someone"); 1206. } 1207. #endif /* THEOLOGY */
|