1 /* omega copyright (C) by Laurence Raphael Brothers, 1987,1988,1989 */
2 /* priest.c */
3 /* functions for clerics. */
4 
5 #include "glob.h"
6 
7 /* prayer occurs at altars, hence name of function */
l_altar()8 void l_altar()
9 {
10   int i,deity;
11   char response;
12 
13   if (Current_Environment == E_COUNTRYSIDE) deity = DRUID;
14   else deity = Level->site[Player.x][Player.y].aux;
15 
16   switch(deity) {
17     default:
18       print1("This rude altar has no markings.");
19       break;
20     case ODIN:
21       print1("This granite altar is graven with a gallows.");
22       break;
23     case SET:
24       print1("This sandstone altar has a black hand drawn on it.");
25       break;
26     case HECATE:
27       print1("This silver altar is inlaid with a black crescent moon.");
28       break;
29     case ATHENA:
30       print1("This golden altar is inscribed with an owl.");
31       break;
32     case DESTINY:
33       print1("This crystal altar is in the form of an omega.");
34       break;
35     case DRUID:
36       print1("This oaken altar is ornately engraved with leaves.");
37       break;
38   }
39   print2("Worship at this altar? [yn] ");
40   if (ynq2() == 'y') {
41     if (Player.rank[PRIESTHOOD] == 0)
42       increase_priest_rank(deity);
43     else if (! check_sacrilege(deity)) {
44       if (Blessing) print1("You have a sense of immanence.");
45       print2("Request a Blessing, Sacrifice an item, or just Pray [b,s,p] ");
46       do response = (char) mcigetc();
47       while ((response != 'b') &&
48 	     (response != 's') &&
49 	     (response != 'p') &&
50 	     (response != ESCAPE));
51       if (response == 'b') {
52 	print1("You beg a heavenly benefice.");
53 	print2("You hear a gong resonating throughout eternity....");
54 	morewait();
55 	if (Blessing) {
56 	  print1("A shaft of lucent radiance lances down from the heavens!");
57 	  print2("You feel uplifted....");
58 	  morewait();
59 	  gain_experience(Player.rank[PRIESTHOOD]*Player.rank[PRIESTHOOD]*50);
60 	  cleanse(1);
61 	  heal(10);
62 	  bless(1);
63 	  Blessing = FALSE;
64 	  increase_priest_rank(deity);
65 	}
66 	else {
67 	  print1("Your ardent plea is ignored.");
68 	  print2("You feel ashamed.");
69 	  Player.xp -= (Player.xp/4);
70 	}
71 	calc_melee();
72       }
73       else if (response == 's') {
74 	print1("Which item to Sacrifice?");
75 	i = getitem(NULL_ITEM);
76 	if (i==ABORT) i = 0;
77 	if (Player.possessions[i] == NULL) {
78 	  print1("You have insulted your deity!");
79 	  print2("Not a good idea, as it turns out...");
80 	  dispel(-1);
81 	  p_damage(Player.hp-1,UNSTOPPABLE,"a god's pique");
82 	}
83 	else if (true_item_value(Player.possessions[i]) >
84 		 (long) (Player.rank[PRIESTHOOD] *
85 		  Player.rank[PRIESTHOOD] *
86 		  Player.rank[PRIESTHOOD] * 50)) {
87 	  print1("With a burst of blue flame, your offering vanishes!");
88 	  dispose_lost_objects(1,Player.possessions[i]);
89 	  print2("A violet nimbus settles around your head and slowly fades.");
90 	  morewait();
91 	  Blessing = TRUE;
92 	}
93 	else {
94 	  print1("A darkling glow envelopes your offering!");
95 	  print2("The glow slowly fades....");
96 	  morewait();
97 	  setgamestatus(SUPPRESS_PRINTING);
98 	  if (Player.possessions[i]->used) {
99 	    Player.possessions[i]->used = FALSE;
100 	    item_use(Player.possessions[i]);
101 	    Player.possessions[i]->blessing =
102 	      -1 - abs(Player.possessions[i]->blessing);
103 	    Player.possessions[i]->used = TRUE;
104 	    item_use(Player.possessions[i]);
105 	  }
106 	  else Player.possessions[i]->blessing =
107 	    -1 - abs(Player.possessions[i]->blessing);
108 	  resetgamestatus(SUPPRESS_PRINTING);
109 	}
110       }
111       else if (response == 'p') {
112 	if (deity != Player.patron)
113 	  print1("Nothing seems to happen.");
114 	else if (!increase_priest_rank(deity))
115 	  answer_prayer();
116       }
117     }
118   }
119 }
120 
121 
122 
123 
check_sacrilege(deity)124 int check_sacrilege(deity)
125 int deity;
126 {
127   int i,sacrilege=FALSE;
128   if ((Player.patron != deity) && (Player.patron > 0)) {
129     sacrilege=TRUE;
130     Player.pow--;
131     Player.maxpow--;
132     switch(Player.patron) {
133     case ODIN:
134       print1("Odin notices your lack of faith! ");
135       morewait();
136       if (deity == ATHENA) {
137 	print2("However, Athena intercedes on your behalf.");
138 	sacrilege = FALSE;
139       }
140       else {
141 	print2("You are struck by a thunderbolt!");
142 	p_damage(Player.level*5,UNSTOPPABLE,"Odin's wrath");
143 	if (Player.hp > 0) {
144 	  morewait();
145 	  print2("The bolt warps your feeble frame....");
146 	  Player.maxcon = Player.maxcon/2;
147 	  Player.con = min(Player.con,Player.maxcon);
148 	  Player.maxstr = Player.maxstr/2;
149 	  Player.con = min(Player.str,Player.maxstr);
150 	}
151       }
152       morewait();
153       break;
154     case SET:
155       print1("Set notices your lack of faith! ");
156       morewait();
157       if (deity == HECATE) {
158 	print1("But since you pray to a friendly deity,");
159 	print2("Set decides not to punish you.");
160 	sacrilege = FALSE;
161       }
162       else {
163 	print2("You are blasted by a shaft of black fire!");
164 	p_damage(Player.level*5,UNSTOPPABLE,"Set's anger");
165 	if (Player.hp > 0) {
166 	  morewait();
167 	  print1("You are wreathed in clouds of smoke.");
168 	  for(i=0;i<MAXITEMS;i++)
169 	    if ((Player.possessions[i] != NULL) &&
170 		(Player.possessions[i]->blessing > -1))
171 	      conform_lost_object(Player.possessions[i]);
172 	  morewait();
173 	  print2("You feel Set's Black Hand on your heart....");
174 	  Player.con = Player.maxcon = Player.maxcon / 4;
175 	}
176       }
177       morewait();
178       break;
179     case HECATE:
180       print1("Hecate notices your lack of faith! ");
181       morewait();
182       if (deity == SET) {
183 	print1("But ignores the affront since she likes Set.");
184 	sacrilege = FALSE;
185       }
186       else {
187 	print1("You are zapped by dark moonbeams!");
188 	p_damage(Player.level*5,UNSTOPPABLE,"Hecate's malice");
189 	if (Player.hp > 0) {
190 	  print2("The beams leach you of magical power!");
191 	  Player.maxpow = Player.maxpow/5;
192 	  Player.pow = min(Player.pow,Player.maxpow);
193 	  for(i=0;i<NUMSPELLS;i++)
194 	    Spells[i].known = FALSE;
195 	}
196       }
197       morewait();
198       break;
199     case ATHENA:
200       print1("Athena notices your lack of faith! ");
201       morewait();
202       if (deity == ODIN) {
203 	print2("But lets you off this time since Odin is also Lawful.");
204 	sacrilege = FALSE;
205       }
206       else {
207 	print2("You are zorched by godsfire!");
208 	if (Player.hp > 0) {
209 	  morewait();
210 	  print1("The fire burns away your worldly experience!");
211 		Player.level = 0;
212 	  Player.xp = 0;
213 	  Player.maxhp = Player.hp = Player.con;
214 	  print2("Your power is reduced by the blast!!!");
215 	  Player.pow = Player.maxpow = Player.maxpow/3;
216 	  Player.mana = min(Player.mana,calcmana());
217 	}
218       }
219       morewait();
220       break;
221     case DESTINY:
222       print2("The Lords of Destiny ignore your lack of faith.");
223       sacrilege = FALSE;
224       morewait();
225       break;
226     case DRUID:
227       print2("Your treachery to the ArchDruid has been noted.");
228       if (random_range(2) == 1)
229 	Player.alignment += 40;
230       else Player.alignment -= 40;
231       morewait();
232       break;
233     }
234     if (sacrilege) {
235       Player.patron = 0;
236       Player.rank[PRIESTHOOD] = 0;
237     }
238   }
239   return(sacrilege);
240 }
241 
increase_priest_rank(deity)242 int increase_priest_rank(deity)
243 int deity;
244 {
245   if (Player.rank[PRIESTHOOD] == 0) switch(deity) {
246   default:
247     print2("Some nameless god blesses you....");
248     Player.hp = max(Player.hp, Player.maxhp);
249     morewait();
250     print2("The altar crumbles to dust and blows away.");
251     Level->site[Player.x][Player.y].locchar = FLOOR;
252     Level->site[Player.x][Player.y].p_locf = L_NO_OP;
253     lset(Player.x, Player.y, CHANGED);
254     break;
255   case ODIN:
256     if (Player.alignment > 0) {
257       print1("Odin hears your prayer!");
258       print2(Priest[ODIN]);
259       nprint2(" personally blesses you.");
260       nprint2(" You are now a lay devotee of Odin.");
261       Player.patron = ODIN;
262       Player.rank[PRIESTHOOD] = LAY;
263       Player.guildxp[PRIESTHOOD] = 1;
264       morewait();
265       learnclericalspells(ODIN,LAY);
266     }
267     else print1("Odin ignores you.");
268     break;
269   case SET:
270     if (Player.alignment < 0) {
271       print1("Set hears your prayer!");
272       print2(Priest[SET]);
273       nprint2(" personally blesses you. ");
274       nprint2(" You are now a lay devotee of Set.");
275       Player.patron = SET;
276       Player.rank[PRIESTHOOD] = LAY;
277       Player.guildxp[PRIESTHOOD] = 1;
278       morewait();
279       learnclericalspells(SET,LAY);
280     }
281     else print1("Set ignores you.");
282     break;
283   case ATHENA:
284     if (Player.alignment > 0) {
285       print1("Athena hears your prayer!");
286       print2(Priest[ATHENA]);
287       nprint2(" personally blesses you.");
288       nprint2(" You are now a lay devotee of Athena.");
289       Player.patron = ATHENA;
290       Player.rank[PRIESTHOOD] = LAY;
291       Player.guildxp[PRIESTHOOD] = 1;
292       morewait();
293       learnclericalspells(ATHENA,LAY);
294     }
295     else print1("Athena ignores you.");
296     break;
297   case HECATE:
298     if (Player.alignment < 0) {
299       print1("Hecate hears your prayer!");
300       print2(Priest[HECATE]);
301       nprint2(" personally blesses you.");
302       nprint2(" You are now a lay devotee of Hecate.");
303       Player.patron = HECATE;
304       Player.rank[PRIESTHOOD] = LAY;
305       Player.guildxp[PRIESTHOOD] = 1;
306       morewait();
307       learnclericalspells(HECATE,LAY);
308     }
309     else print1("Hecate ignores you.");
310     break;
311   case DRUID:
312     if (abs(Player.alignment) < 10) {
313       print1(Priest[DRUID]);
314       nprint1(" personally blesses you.");
315       print2("You are now a lay devotee of the Druids.");
316       Player.patron = DRUID;
317       Player.rank[PRIESTHOOD] = LAY;
318       Player.guildxp[PRIESTHOOD] = 1;
319       morewait();
320       learnclericalspells(DRUID,LAY);
321     }
322     else {
323       print1("You hear a voice....");
324       morewait();
325       print2("'Only those who embody the Balance may become Druids.'");
326     }
327     break;
328   case DESTINY:
329     print1("The Lords of Destiny could hardly care less.");
330     print2("But you can consider yourself now to be a lay devotee.");
331     Player.patron = DESTINY;
332     Player.rank[PRIESTHOOD] = LAY;
333       Player.guildxp[PRIESTHOOD] = 1;
334     break;
335   }
336   else if (deity == Player.patron) {
337     if ((((deity == ODIN) || (deity == ATHENA)) &&
338 	 (Player.alignment < 1)) ||
339 	(((deity == SET) || (deity == HECATE)) &&
340 	 (Player.alignment > 1)) ||
341 	((deity == DRUID) && (abs(Player.alignment) > 10))) {
342       print1("You have swerved from the One True Path!");
343       print2("Your deity is greatly displeased...");
344       Player.xp -= Player.level*Player.level;
345       Player.xp = max(0,Player.xp);
346     }
347     else if (Player.rank[PRIESTHOOD]== HIGHPRIEST) return 0;
348     else if (Player.rank[PRIESTHOOD]== SPRIEST) {
349       if (Player.level > Priestlevel[deity])
350 	hp_req_test();
351       else return 0;
352     }
353     else if (Player.rank[PRIESTHOOD]==PRIEST) {
354       if (Player.guildxp[PRIESTHOOD] >= 4000) {
355 	print1("An heavenly fanfare surrounds you!");
356 	print2("Your deity raises you to the post of Senior Priest.");
357 	hp_req_print();
358 	Player.rank[PRIESTHOOD] = SPRIEST;
359 	morewait();
360 	learnclericalspells(deity,SPRIEST);
361       }
362       else return 0;
363     }
364     else if (Player.rank[PRIESTHOOD]==ACOLYTE) {
365       if (Player.guildxp[PRIESTHOOD] >= 1500) {
366 	print1("A trumpet sounds in the distance.");
367 	print2("Your deity raises you to the post of Priest.");
368 	Player.rank[PRIESTHOOD] = PRIEST;
369 	morewait();
370 	learnclericalspells(deity,PRIEST);
371       }
372       else return 0;
373     }
374     else if (Player.rank[PRIESTHOOD]==LAY) {
375       if (Player.guildxp[PRIESTHOOD] >= 400) {
376 	print1("A mellifluous chime sounds from above the altar.");
377 	print2("Your deity raises you to the post of Acolyte.");
378 	Player.rank[PRIESTHOOD] = ACOLYTE;
379 	morewait();
380 	learnclericalspells(deity,ACOLYTE);
381       }
382       else return 0;
383     }
384   }
385   return 1;
386 }
387 
388 
answer_prayer()389 void answer_prayer()
390 {
391   clearmsg();
392   switch(random_range(12)) {
393   case 0: print1("You have a revelation!"); break;
394   case 1: print1("You feel pious."); break;
395   case 2: print1("A feeling of sanctity comes over you."); break;
396   default: print1("Nothing unusual seems to happen."); break;
397   }
398 }
399 
400 
hp_req_test()401 void hp_req_test()
402 {
403   pob o;
404   switch  (Player.patron) {
405   case ODIN:
406     if (find_item(&o,ARTIFACTID+15,-1))
407       make_hp(o);
408     else hp_req_print();
409     break;
410   case SET:
411     if (find_item(&o,ARTIFACTID+14,-1))
412       make_hp(o);
413     else hp_req_print();
414     break;
415   case ATHENA:
416     if (find_item(&o,ARTIFACTID+17,-1))
417       make_hp(o);
418     else hp_req_print();
419     break;
420   case HECATE:
421     if (find_item(&o,ARTIFACTID+16,-1))
422       make_hp(o);
423     else hp_req_print();
424     break;
425   case DRUID:
426     if (find_item(&o,ARTIFACTID+14,-1))
427       make_hp(o);
428     else if (find_item(&o,ARTIFACTID+15,-1))
429       make_hp(o);
430     else if (find_item(&o,ARTIFACTID+16,-1))
431       make_hp(o);
432     else if (find_item(&o,ARTIFACTID+17,-1))
433       make_hp(o);
434     else hp_req_print();
435     break;
436   case DESTINY:
437     if (find_item(&o,ARTIFACTID+19,-1))
438       make_hp(o);
439     else hp_req_print();
440     break;
441   }
442 }
443 
444 
hp_req_print()445 void hp_req_print()
446 {
447   morewait();
448   print1("To advance further, you must obtain the Holy Symbol of ");
449   switch(Player.patron) {
450   case ODIN:
451     nprint1(Priest[SET]);
452     print2("who may be found in the main Temple of Set.");
453     break;
454   case SET:
455     nprint1(Priest[ODIN]);
456     print2("who may be found in the main Temple of Odin.");
457     break;
458   case ATHENA:
459     nprint1(Priest[HECATE]);
460     print2("who may be found in the main Temple of Hecate.");
461     break;
462   case HECATE:
463     nprint1(Priest[ATHENA]);
464     print2("who may be found in the main Temple of Athena.");
465     break;
466   case DRUID:
467     print2("any of the aligned priests who may be found in their main Temples.");
468     break;
469   case DESTINY:
470     nprint1(Priest[DESTINY]);
471     print2("who may be found in the main Temple of Destiny.");
472     break;
473   }
474 }
475 
make_hp(o)476 void make_hp(o)
477 pob o;
478 {
479   print1("A full-scale heavenly choir chants 'Hallelujah' all around you!");
480   print2("You notice a change in the symbol you carry....");
481   switch(Player.patron) {
482   case ODIN:
483     *o = Objects[ARTIFACTID+14];
484     break;
485   case SET:
486     *o = Objects[ARTIFACTID+15];
487     break;
488   case ATHENA:
489     *o = Objects[ARTIFACTID+16];
490     break;
491   case HECATE:
492     *o = Objects[ARTIFACTID+17];
493     break;
494   case DRUID:
495     *o = Objects[ARTIFACTID+18];
496     break;
497   case DESTINY:
498     *o = Objects[ARTIFACTID+19];
499     break;
500   }
501   o->known = 2;
502   o->charge = 17; /* random hack to convey bit that symbol is functional */
503   morewait();
504   if (Player.patron == DRUID)
505     print1("Your deity raises you to the post of ArchDruid!");
506   else print1("Your deity raises you to the post of High Priest!");
507   print2("You feel holy.");
508   strcpy(Priest[Player.patron],Player.name);
509   Priestlevel[Player.patron] = Player.level;
510   Player.rank[PRIESTHOOD] = HIGHPRIEST;
511   morewait();
512   Priestbehavior[Player.patron] = fixnpc(4);
513   save_hiscore_npc(Player.patron);
514   learnclericalspells(Player.patron,HIGHPRIEST);
515 }
516