Fandom

Wikihack

Source:NetHack 2.2a/pray.c

2,034pages on
this wiki
Add New Page
Talk0

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

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

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

Screenshots and source code from Hack are used under the CWI license.
1.    /*	SCCS Id: @(#)pray.c	2.1	87/10/07
2.    /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3.    
4.    #include "hack.h"
5.    
6.    extern char *nomovemsg;
7.    extern struct monst *mkmon_at();
8.    extern struct obj *mkobj_at();
9.    
10.   dopray() {		/* M. Stephenson (1.0.3b) */
11.   #ifdef PRAYERS
12.   	if (u.ublesscnt > 0)  {		/* disturbing the gods too much */
13.   
14.   		u.ublesscnt += 200;
15.   		u.uluck -= 3;
16.   		if (u.uluck < LUCKMIN)  u.uluck = LUCKMIN;
17.   #ifdef HARD
18.   		u.ugangr++;
19.   		angrygods();
20.   #else
21.   		if (u.ugangr++)	angrygods();
22.   		else {			/* exactly one warning */
23.   			pline("A voice booms out: You have angered us,");
24.   			pline("Disturb us again at your own risk!");
25.   		}
26.   #endif
27.   	} else  if (u.uluck < 0) angrygods();	/* a bad boy/girl */
28.   	else	pleased();	    		/* or a good boy/girl */
29.   #endif
30.   	nomovemsg = "You finished your prayer.";
31.   	nomul(-3);
32.   	return(1);
33.   }
34.   
35.   #ifdef PRAYERS
36.   angrygods() {
37.   	register int	tmp;
38.   
39.   	pline ("You get the feeling the gods are angry...");
40.   	/* changed from tmp = u.ugangr + abs (u.uluck) -- rph */
41.   	tmp =  3*u.ugangr + (u.uluck > 0 ? -u.uluck/3 : -u.uluck);
42.   	tmp =  (tmp > 15 ? 15 : tmp);  /* lets be a little reasonable */
43.   	switch (tmp ? rn2(tmp): 0) {
44.   
45.   	    case 0:
46.   	    case 1:	pline("but nothing appears to happen.");
47.   			break;
48.   	    case 2:
49.   	    case 3:	pline("A voice booms out: You are arrogant, mortal.");
50.   			pline("You must relearn your lessons!");
51.   			if (u.ulevel > 1)	losexp();
52.   			else  {
53.   			    u.uexp = 0;
54.   			    flags.botl = 1;
55.   			}
56.   			break;
57.   	    case 4:
58.   	    case 5:
59.   	    case 6:	pline("A black glow surrounds you.");
60.   			rndcurse();
61.   			break;
62.   	    case 7:
63.   	    case 8:	pline("A voice booms out: You dare to call upon us?");
64.   			pline("Then, die mortal!");
65.   			mkmon_at('&', u.ux, u.uy);
66.   			break;
67.   				
68.   	    default:	pline("Suddenly, a bolt of lightning strikes you!");
69.   			pline("You are fried to a crisp.");
70.   			killer = "pissed off deity";
71.   			done("died");
72.   			break;
73.   	}
74.   	u.ublesscnt = 250;
75.   	return(0);
76.   }
77.   
78.   pleased() {
79.   
80.   	char	*tmp, *hcolor();
81.   
82.   	u.ugangr--;
83.   	if (u.ugangr < 0) u.ugangr = 0;
84.   	pline("You feel the gods are pleased.");
85.   
86.   	switch(rn2((u.uluck + 6)/2))  {
87.   
88.   	    case 0:	pline("but nothing seems to happen.");
89.   			break;
90.   	    case 1:
91.   			if(!uwep) {
92.   			    if(uleft && uleft->cursed) {
93.   				pline("your left hand glows amber.");
94.   				uleft->cursed = 0;
95.   			    } else if(uright && uright->cursed) {
96.   				pline("your right hand glows amber.");
97.   				uright->cursed = 0;
98.   			    } else    pline("but nothing seems to happen.");
99.   			    break;
100.  			}
101.  #ifdef KAA
102.  			if(uwep->olet == WEAPON_SYM) {
103.  			    if (uwep->cursed) {
104.  				uwep->cursed=0;
105.  				pline("Your %s %s.", aobjnam(uwep,"softly glow"), 
106.  				Hallucination ? hcolor() : "amber");
107.  			    } else if(uwep->otyp >= ARROW && uwep->otyp <= SPEAR) {
108.  				uwep->dknown=1;
109.  				tmp = Hallucination ? hcolor() : "light blue";
110.  				pline("Your %s with a%s %s aura.", aobjnam(uwep,"softly glow"),
111.  				index("aeiou",*tmp) ? "n" : "", tmp);
112.  			    }
113.  			} else
114.  #endif
115.  				pline("but nothing seems to happen.");
116.  			break;
117.  	    case 2:
118.  	    case 3:
119.  			pline("A %s glow surrounds you",
120.  			      Hallucination ? hcolor() : "golden");
121.  			u.uhp = u.uhpmax += 5;
122.  			u.ustr = u.ustrmax;
123.  			if (u.uhunger < 900)	init_uhunger();
124.  			if (u.uluck < 0)	u.uluck = 0;
125.  			if (Blinded)		Blinded = 1;
126.  			flags.botl = 1;
127.  			break;
128.  	    case 4:
129.  	    case 5:	pline("A voice booms out: We are pleased with your progress,");
130.  			pline("and grant you the gift of");
131.  			if (!(HTelepat & INTRINSIC))  {
132.  				HTelepat |= INTRINSIC;
133.  				pline ("Telepathy,");
134.  			} else if (!(Fast & INTRINSIC))  {
135.  				Fast |= INTRINSIC;
136.  				pline ("Speed,");
137.  			} else if (!(Stealth & INTRINSIC))  {
138.  				Stealth |= INTRINSIC;
139.  				pline ("Stealth,");
140.  			} else {
141.  			    if (!(Protection & INTRINSIC))  {
142.  				Protection |= INTRINSIC;
143.  				if (!u.ublessed)  u.ublessed = rnd(3) + 1;
144.  			    } else u.ublessed++;
145.  			    pline ("our protection,");
146.  			}
147.  			pline ("Use it wisely in our names!");
148.  			break;
149.  
150.  	    case 6:	pline ("An object appears at your feet!");
151.  #ifdef SPELLS
152.  			mkobj_at('+', u.ux, u.uy);
153.  #else
154.  			mkobj_at('?', u.ux, u.uy);
155.  #endif
156.  			break;
157.  
158.  	    case 7:	pline("A voice booms out:  We crown thee...");
159.  			pline("The Hand of Elbereth!");
160.  			HInvis |= INTRINSIC;
161.  			HSee_invisible |= INTRINSIC;
162.  			HFire_resistance |= INTRINSIC;
163.  			HCold_resistance |= INTRINSIC;
164.  			HPoison_resistance |= INTRINSIC;
165.  #ifdef RPH
166.  			if(uwep && (uwep->otyp == LONG_SWORD))
167.  				oname(uwep, "Excalibur");
168.  #endif
169.  			break;
170.  
171.  	    default:	impossible("Confused deity!");
172.  			break;
173.  	}
174.  	u.ublesscnt = 300;
175.  #ifdef HARD
176.  	u.ublesscnt += (u.udemigod * 1000);
177.  #endif
178.  	return(0);
179.  }
180.  #endif /* PRAYERS /**/
181.  #ifdef NEWCLASS
182.  doturn() {	/* Knights & Priest(esse)s only please */
183.  
184.  	register struct monst *mtmp;
185.  	register int	xlev = 6;
186.  	extern char	pl_character[];
187.  
188.  	if((pl_character[0] != 'P') &&
189.  	   (pl_character[0] != 'K')) {
190.  
191.  		pline("You don't know how to turn undead!");
192.  		return(0);
193.  	}
194.  	if (Inhell) {
195.  
196.  		pline("Being in hell, your gods won't help you.");
197.  		aggravate();
198.  		return(0);
199.  	}
200.  	pline("Calling upon your gods, you chant an arcane formula.");
201.  	for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
202.  	    if(cansee(mtmp->mx,mtmp->my)) {
203.  		if(index(UNDEAD,mtmp->data->mlet) ||
204.  		   ((mtmp->data->mlet == '&') && (u.ulevel > 10))) {
205.  
206.  		    if(Confusion) {
207.  			pline("Unfortunately, your voice falters.");
208.  			mtmp->mflee = mtmp->mfroz = mtmp->msleep = 0;
209.  		    } else if (! resist(mtmp, '+', 0, TELL))
210.  			switch (mtmp->data->mlet) {
211.  			    case 'V':   xlev += 2;
212.  			    case 'W':   xlev += 4;
213.  			    case 'Z':   if(u.ulevel >= xlev)  {
214.  					    if(!resist(mtmp, '+', 0, NOTELL)) {
215.  						pline("You destroy the %s", monnam(mtmp));
216.  						mondied(mtmp);
217.  					    } else	mtmp->mflee = 1;
218.  					} else	mtmp->mflee = 1;
219.  					break;
220.  			    default:    mtmp->mflee = 1;
221.  					break;
222.  			}
223.  		   }
224.  	    }
225.  	    nomul(-5);
226.  	    return(1);
227.  }
228.  #endif /* NEWCLASS /**/
229.  

Also on Fandom

Random Wiki