1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. |
3 | |
3 | * |
|
|
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | |
7 | * |
7 | This program is free software; you can redistribute it and/or modify |
8 | * Crossfire TRT is free software: you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | (at your option) any later version. |
11 | * (at your option) any later version. |
11 | |
12 | * |
12 | This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
16 | |
17 | * |
17 | You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * |
20 | |
|
|
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
21 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
22 | */ |
22 | */ |
23 | |
|
|
24 | |
23 | |
25 | /* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and |
24 | /* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and |
26 | * monster race initialization. b.t. |
25 | * monster race initialization. b.t. |
27 | */ |
26 | */ |
28 | |
27 | |
… | |
… | |
31 | #include <global.h> |
30 | #include <global.h> |
32 | #include <living.h> |
31 | #include <living.h> |
33 | #include <object.h> |
32 | #include <object.h> |
34 | #include <spells.h> |
33 | #include <spells.h> |
35 | #include <sounds.h> |
34 | #include <sounds.h> |
36 | #ifndef __CEXTRACT__ |
|
|
37 | # include <sproto.h> |
35 | #include <sproto.h> |
38 | #endif |
|
|
39 | |
36 | |
40 | /** |
37 | /** |
41 | * Returns the id of specified god. |
38 | * Returns the id of specified god. |
42 | */ |
39 | */ |
43 | int |
40 | int |
… | |
… | |
51 | godlink *gl; |
48 | godlink *gl; |
52 | |
49 | |
53 | for (gl = first_god; gl; gl = gl->next) |
50 | for (gl = first_god; gl; gl = gl->next) |
54 | if (!strncmp (name, gl->name, MIN ((size_t) strlen (gl->name), nmlen))) |
51 | if (!strncmp (name, gl->name, MIN ((size_t) strlen (gl->name), nmlen))) |
55 | break; |
52 | break; |
|
|
53 | |
56 | if (gl) |
54 | if (gl) |
57 | godnr = gl->id; |
55 | godnr = gl->id; |
58 | } |
56 | } |
|
|
57 | |
59 | return godnr; |
58 | return godnr; |
60 | } |
59 | } |
61 | |
60 | |
62 | /** |
61 | /** |
63 | * Returns pointer to specified god's object through pntr_to_god_obj.. |
62 | * Returns pointer to specified god's object through pntr_to_god_obj.. |
… | |
… | |
105 | { |
104 | { |
106 | |
105 | |
107 | /* find a god based on race */ |
106 | /* find a god based on race */ |
108 | if (!op->title) |
107 | if (!op->title) |
109 | { |
108 | { |
110 | if (op->race != NULL) |
109 | if (op->race) |
111 | { |
110 | { |
112 | godname = get_god_for_race (op->race); |
111 | godname = get_god_for_race (op->race); |
|
|
112 | |
113 | if (godname != NULL) |
113 | if (godname) |
114 | { |
|
|
115 | op->title = godname; |
114 | op->title = godname; |
116 | } |
|
|
117 | } |
115 | } |
118 | } |
116 | } |
119 | |
117 | |
120 | /* find a random god */ |
118 | /* find a random god */ |
121 | if (!op->title) |
119 | if (!op->title) |
… | |
… | |
125 | godnr = rndm (1, gl->id); |
123 | godnr = rndm (1, gl->id); |
126 | while (gl) |
124 | while (gl) |
127 | { |
125 | { |
128 | if (gl->id == godnr) |
126 | if (gl->id == godnr) |
129 | break; |
127 | break; |
|
|
128 | |
130 | gl = gl->next; |
129 | gl = gl->next; |
131 | } |
130 | } |
|
|
131 | |
132 | op->title = gl->name; |
132 | op->title = gl->name; |
133 | } |
133 | } |
134 | |
134 | |
135 | return op->title; |
135 | return op->title; |
136 | } |
136 | } |
… | |
… | |
141 | * that skill, once we find it, we can return, either with the |
141 | * that skill, once we find it, we can return, either with the |
142 | * title or "none". |
142 | * title or "none". |
143 | */ |
143 | */ |
144 | if (op->type == PLAYER) |
144 | if (op->type == PLAYER) |
145 | { |
145 | { |
146 | object *tmp; |
|
|
147 | |
|
|
148 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
146 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
149 | if (tmp->type == SKILL && tmp->subtype == SK_PRAYING) |
147 | if (tmp->type == SKILL && tmp->subtype == SK_PRAYING) |
150 | { |
148 | { |
151 | if (tmp->title) |
149 | if (tmp->title) |
152 | return (tmp->title); |
150 | return tmp->title; |
153 | else |
151 | else |
154 | return ("none"); |
152 | return "none"; |
155 | } |
153 | } |
156 | } |
154 | } |
|
|
155 | |
157 | return ("none"); |
156 | return "none"; |
158 | } |
157 | } |
159 | |
158 | |
160 | /** |
159 | /** |
161 | * Returns 1 if s1 and s2 are the same - either both NULL, or strcmp( ) == 0 |
160 | * Returns 1 if s1 and s2 are the same - either both NULL, or strcmp( ) == 0 |
162 | */ |
161 | */ |
… | |
… | |
172 | return 0; |
171 | return 0; |
173 | else |
172 | else |
174 | return strcmp (s1, s2) == 0; |
173 | return strcmp (s1, s2) == 0; |
175 | } |
174 | } |
176 | |
175 | |
177 | |
|
|
178 | /** |
176 | /** |
179 | * Checks for any occurrence of the given 'item' in the inventory of 'op' (recursively). |
177 | * Checks for any occurrence of the given 'item' in the inventory of 'op' (recursively). |
180 | * Any matching items in the inventory are deleted, and a |
178 | * Any matching items in the inventory are deleted, and a |
181 | * message is displayed to the player. |
179 | * message is displayed to the player. |
182 | */ |
180 | */ |
… | |
… | |
241 | static int |
239 | static int |
242 | god_gives_present (object *op, object *god, treasure *tr) |
240 | god_gives_present (object *op, object *god, treasure *tr) |
243 | { |
241 | { |
244 | object *tmp; |
242 | object *tmp; |
245 | |
243 | |
|
|
244 | if (!tr->item) |
|
|
245 | return 0; |
|
|
246 | |
246 | if (follower_has_similar_item (op, &tr->item->clone)) |
247 | if (follower_has_similar_item (op, tr->item)) |
247 | return 0; |
248 | return 0; |
248 | |
249 | |
249 | tmp = arch_to_object (tr->item); |
250 | tmp = arch_to_object (tr->item); |
250 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s lets %s appear in your hands.", &god->name, query_short_name (tmp)); |
251 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s lets %s appear in your hands.", &god->name, query_short_name (tmp)); |
251 | tmp = insert_ob_in_ob (tmp, op); |
252 | tmp = insert_ob_in_ob (tmp, op); |
252 | if (op->type == PLAYER) |
253 | if (op->type == PLAYER) |
253 | esrv_send_item (op, tmp); |
254 | esrv_send_item (op, tmp); |
|
|
255 | |
254 | return 1; |
256 | return 1; |
255 | } |
257 | } |
256 | |
258 | |
257 | /** |
259 | /** |
258 | * Player prays at altar. |
260 | * Player prays at altar. |
… | |
… | |
271 | return; |
273 | return; |
272 | |
274 | |
273 | /* hmm. what happend depends on pl's current god, level, etc */ |
275 | /* hmm. what happend depends on pl's current god, level, etc */ |
274 | if (!pl_god) |
276 | if (!pl_god) |
275 | { /*new convert */ |
277 | { /*new convert */ |
276 | become_follower (pl, &altar->other_arch->clone); |
278 | become_follower (pl, altar->other_arch); |
277 | return; |
279 | return; |
278 | |
|
|
279 | } |
280 | } |
280 | else if (!strcmp (&pl_god->name, altar->other_arch->clone.name)) |
281 | else if (!strcmp (&pl_god->name, altar->other_arch->object::name)) |
281 | { |
282 | { |
282 | /* pray at your gods altar */ |
283 | /* pray at your gods altar */ |
283 | int bonus = (pl->stats.Wis + skill->level) / 10; |
284 | int bonus = (pl->stats.Wis + skill->level) / 10; |
284 | |
285 | |
285 | /* we can get neg grace up faster */ |
286 | /* we can get neg grace up faster */ |
286 | if (pl->stats.grace < 0) |
287 | if (pl->stats.grace < 0) |
287 | pl->stats.grace += (bonus > -1 * (pl->stats.grace / 10) ? bonus : -1 * (pl->stats.grace / 10)); |
288 | pl->stats.grace += (bonus > -1 * (pl->stats.grace / 10) ? bonus : -1 * (pl->stats.grace / 10)); |
|
|
289 | |
288 | /* we can super-charge grace to 2x max */ |
290 | /* we can super-charge grace to 2x max */ |
289 | if (pl->stats.grace < (2 * pl->stats.maxgrace)) |
291 | if (pl->stats.grace < 2 * pl->stats.maxgrace) |
290 | { |
|
|
291 | pl->stats.grace += bonus / 2; |
292 | pl->stats.grace += bonus / 2; |
292 | } |
293 | else |
293 | if (pl->stats.grace > (2 * pl->stats.maxgrace)) |
|
|
294 | { |
|
|
295 | pl->stats.grace = (2 * pl->stats.maxgrace); |
294 | pl->stats.grace = 2 * pl->stats.maxgrace; |
296 | } |
|
|
297 | |
295 | |
298 | /* Every once in a while, the god decides to checkup on their |
296 | /* Every once in a while, the god decides to checkup on their |
299 | * follower, and may intervene to help them out. |
297 | * follower, and may intervene to help them out. |
300 | */ |
298 | */ |
301 | bonus = MAX (1, bonus + MAX (pl->stats.luck, -3)); /* -- DAMN -- */ |
299 | bonus = MAX (1, bonus + MAX (pl->stats.luck, -3)); /* -- DAMN -- */ |
302 | |
300 | |
303 | if (((random_roll (0, 399, pl, PREFER_LOW)) - bonus) < 0) |
301 | if (((random_roll (0, 399, pl, PREFER_LOW)) - bonus) < 0) |
304 | god_intervention (pl, pl_god, skill); |
302 | god_intervention (pl, pl_god, skill); |
305 | |
|
|
306 | } |
303 | } |
307 | else |
304 | else |
308 | { /* praying to another god! */ |
305 | { /* praying to another god! */ |
309 | uint64 loss = 0; |
306 | uint64 loss = 0; |
310 | int angry = 1; |
307 | int angry = 1; |
… | |
… | |
314 | * points to the god of this altar (which we have |
311 | * points to the god of this altar (which we have |
315 | * already verified is non null). pl_god->other_arch |
312 | * already verified is non null). pl_god->other_arch |
316 | * is the opposing god - we need to verify that exists before |
313 | * is the opposing god - we need to verify that exists before |
317 | * using its values. |
314 | * using its values. |
318 | */ |
315 | */ |
319 | if (pl_god->other_arch && (altar->other_arch->name == pl_god->other_arch->name)) |
316 | if (pl_god->other_arch && (altar->other_arch->archname == pl_god->other_arch->archname)) |
320 | { |
317 | { |
321 | angry = 2; |
318 | angry = 2; |
322 | if (random_roll (0, skill->level + 2, pl, PREFER_LOW) - 5 > 0) |
319 | if (random_roll (0, skill->level + 2, pl, PREFER_LOW) - 5 > 0) |
323 | { |
320 | { |
324 | object *tmp; |
321 | object *tmp; |
… | |
… | |
345 | |
342 | |
346 | /* May switch Gods, but its random chance based on our current level |
343 | /* May switch Gods, but its random chance based on our current level |
347 | * note it gets harder to swap gods the higher we get |
344 | * note it gets harder to swap gods the higher we get |
348 | */ |
345 | */ |
349 | if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) |
346 | if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) |
350 | { |
|
|
351 | become_follower (pl, &altar->other_arch->clone); |
347 | become_follower (pl, altar->other_arch); |
352 | } |
|
|
353 | else |
348 | else |
354 | { |
349 | { |
355 | /* toss this player off the altar. He can try again. */ |
350 | /* toss this player off the altar. He can try again. */ |
356 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar."); |
351 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar."); |
|
|
352 | pl->contr->fire_on = 0; |
|
|
353 | pl->speed_left = 1.f; |
357 | move_player (pl, absdir (pl->facing + 4)); /* back him off the way he came. */ |
354 | move_player (pl, absdir (pl->facing + 4)); /* back him off the way he came. */ |
358 | } |
355 | } |
359 | } |
356 | } |
360 | } |
357 | } |
361 | |
358 | |
… | |
… | |
396 | remove = 1; |
393 | remove = 1; |
397 | for (tr = god->randomitems->items; tr; tr = tr->next) |
394 | for (tr = god->randomitems->items; tr; tr = tr->next) |
398 | { |
395 | { |
399 | object *item; |
396 | object *item; |
400 | |
397 | |
401 | if (tr->item == NULL) |
398 | if (!tr->item) |
402 | continue; |
399 | continue; |
|
|
400 | |
403 | item = &tr->item->clone; |
401 | item = tr->item; |
404 | |
402 | |
405 | /* Basically, see if the matching spell is granted by this god. */ |
403 | /* Basically, see if the matching spell is granted by this god. */ |
406 | |
404 | |
407 | if (tr->item->clone.type == SPELL && tr->item->clone.name == tmp->name) |
405 | if (tr->item->type == SPELL && tr->item->object::name == tmp->name) |
408 | { |
406 | { |
409 | remove = 0; |
407 | remove = 0; |
410 | break; |
408 | break; |
411 | } |
409 | } |
412 | } |
410 | } |
… | |
… | |
457 | } |
455 | } |
458 | } |
456 | } |
459 | |
457 | |
460 | /* remove any godgiven items from the old god */ |
458 | /* remove any godgiven items from the old god */ |
461 | if (old_god) |
459 | if (old_god) |
462 | { |
|
|
463 | for (tr = old_god->randomitems->items; tr != NULL; tr = tr->next) |
460 | for (tr = old_god->randomitems->items; tr; tr = tr->next) |
464 | { |
|
|
465 | if (tr->item && QUERY_FLAG (&tr->item->clone, FLAG_STARTEQUIP)) |
461 | if (tr->item && QUERY_FLAG (tr->item, FLAG_STARTEQUIP)) |
466 | follower_remove_similar_item (op, &tr->item->clone); |
462 | follower_remove_similar_item (op, tr->item); |
467 | } |
|
|
468 | } |
|
|
469 | |
463 | |
470 | if (!op || !new_god) |
464 | if (!op || !new_god) |
471 | return; |
465 | return; |
472 | |
466 | |
473 | if (op->race && new_god->slaying && strstr (op->race, new_god->slaying)) |
467 | if (op->race && new_god->slaying && strstr (op->race, new_god->slaying)) |
474 | { |
468 | { |
475 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name); |
469 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name); |
|
|
470 | |
476 | if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0) |
471 | if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0) |
477 | { |
472 | { |
478 | object *tmp = get_archetype (LOOSE_MANA); |
473 | object *tmp = get_archetype (LOOSE_MANA); |
479 | |
474 | |
480 | cast_magic_storm (op, tmp, new_god->level + 10); |
475 | cast_magic_storm (op, tmp, new_god->level + 10); |
481 | } |
476 | } |
|
|
477 | |
482 | return; |
478 | return; |
483 | } |
479 | } |
484 | |
480 | |
485 | |
481 | |
486 | /* give the player any special god-characteristic-items. */ |
482 | /* give the player any special god-characteristic-items. */ |
487 | for (tr = new_god->randomitems->items; tr != NULL; tr = tr->next) |
483 | for (tr = new_god->randomitems->items; tr; tr = tr->next) |
488 | { |
484 | { |
489 | if (tr->item && tr->item->clone.invisible && tr->item->clone.type != SPELLBOOK && |
485 | if (tr->item && tr->item->invisible && tr->item->type != SPELLBOOK |
490 | tr->item->clone.type != BOOK && tr->item->clone.type != SPELL) |
486 | && tr->item->type != BOOK && tr->item->type != SPELL) |
491 | god_gives_present (op, new_god, tr); |
487 | god_gives_present (op, new_god, tr); |
492 | } |
488 | } |
493 | |
489 | |
494 | |
490 | |
495 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You become a follower of %s!", &new_god->name); |
491 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You become a follower of %s!", &new_god->name); |
… | |
… | |
502 | if (!skop) |
498 | if (!skop) |
503 | { |
499 | { |
504 | /* The arhetype should always be defined - if we crash here because it doesn't, |
500 | /* The arhetype should always be defined - if we crash here because it doesn't, |
505 | * things are really messed up anyways. |
501 | * things are really messed up anyways. |
506 | */ |
502 | */ |
507 | skop = give_skill_by_name (op, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->clone.skill); |
503 | skop = give_skill_by_name (op, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->skill); |
508 | link_player_skills (op); |
504 | link_player_skills (op); |
509 | } |
505 | } |
510 | |
506 | |
511 | sk_applied = QUERY_FLAG (skop, FLAG_APPLIED); /* save skill status */ |
507 | sk_applied = QUERY_FLAG (skop, FLAG_APPLIED); /* save skill status */ |
512 | |
508 | |
… | |
… | |
607 | |
603 | |
608 | int |
604 | int |
609 | worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string) |
605 | worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string) |
610 | { |
606 | { |
611 | |
607 | |
612 | if (QUERY_FLAG (&op->arch->clone, flag)) |
608 | if (QUERY_FLAG (op->arch, flag)) |
613 | if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag)) |
609 | if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag)) |
614 | { |
610 | { |
615 | update_priest_flag (exp_obj, op, flag); |
611 | update_priest_flag (exp_obj, op, flag); |
616 | if (QUERY_FLAG (op, flag)) |
612 | if (QUERY_FLAG (op, flag)) |
617 | new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string); |
613 | new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string); |
… | |
… | |
678 | { |
674 | { |
679 | LOG (llevError, "BUG: determine_holy_arch(): no god or god without " "randomitems\n"); |
675 | LOG (llevError, "BUG: determine_holy_arch(): no god or god without " "randomitems\n"); |
680 | return NULL; |
676 | return NULL; |
681 | } |
677 | } |
682 | |
678 | |
683 | for (tr = god->randomitems->items; tr != NULL; tr = tr->next) |
679 | for (tr = god->randomitems->items; tr; tr = tr->next) |
684 | { |
680 | { |
685 | object *item; |
|
|
686 | |
|
|
687 | if (!tr->item) |
681 | if (!tr->item) |
688 | continue; |
682 | continue; |
689 | item = &tr->item->clone; |
683 | |
|
|
684 | object *item = tr->item; |
690 | |
685 | |
691 | if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) |
686 | if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) |
692 | return item->other_arch; |
687 | return item->other_arch; |
693 | } |
688 | } |
694 | return NULL; |
689 | return NULL; |
… | |
… | |
736 | |
731 | |
737 | if (level <= 20) |
732 | if (level <= 20) |
738 | return level / difficulty; |
733 | return level / difficulty; |
739 | if (level <= 40) |
734 | if (level <= 40) |
740 | return (20 + (level - 20) / 2) / difficulty; |
735 | return (20 + (level - 20) / 2) / difficulty; |
|
|
736 | |
741 | return (30 + (level - 40) / 4) / difficulty; |
737 | return (30 + (level - 40) / 4) / difficulty; |
742 | } |
738 | } |
743 | |
739 | |
744 | /** |
740 | /** |
745 | * God wants to enchant weapon. |
741 | * God wants to enchant weapon. |
… | |
… | |
756 | int tmp; |
752 | int tmp; |
757 | |
753 | |
758 | for (weapon = op->inv; weapon; weapon = weapon->below) |
754 | for (weapon = op->inv; weapon; weapon = weapon->below) |
759 | if ((weapon->type == WEAPON || weapon->type == BOW) && QUERY_FLAG (weapon, FLAG_APPLIED)) |
755 | if ((weapon->type == WEAPON || weapon->type == BOW) && QUERY_FLAG (weapon, FLAG_APPLIED)) |
760 | break; |
756 | break; |
|
|
757 | |
761 | if (weapon == NULL || god_examines_item (god, weapon) <= 0) |
758 | if (weapon == NULL || god_examines_item (god, weapon) <= 0) |
762 | return 0; |
759 | return 0; |
763 | |
760 | |
764 | /* First give it a title, so other gods won't touch it */ |
761 | /* First give it a title, so other gods won't touch it */ |
765 | if (!weapon->title) |
762 | if (!weapon->title) |
… | |
… | |
800 | } |
797 | } |
801 | |
798 | |
802 | return 0; |
799 | return 0; |
803 | } |
800 | } |
804 | |
801 | |
805 | |
|
|
806 | /** |
802 | /** |
807 | * Every once in a while the god will intervene to help the worshiper. |
803 | * Every once in a while the god will intervene to help the worshiper. |
808 | * Later, this fctn can be used to supply quests, etc for the |
804 | * Later, this fctn can be used to supply quests, etc for the |
809 | * priest. -b.t. |
805 | * priest. -b.t. |
810 | * called from pray_at_altar() currently. |
806 | * called from pray_at_altar() currently. |
811 | */ |
807 | */ |
812 | |
|
|
813 | void |
808 | void |
814 | god_intervention (object *op, object *god, object *skill) |
809 | god_intervention (object *op, object *god, object *skill) |
815 | { |
810 | { |
816 | treasure *tr; |
811 | treasure *tr; |
817 | |
812 | |
… | |
… | |
825 | |
820 | |
826 | /* lets do some checks of whether we are kosher with our god */ |
821 | /* lets do some checks of whether we are kosher with our god */ |
827 | if (god_examines_priest (op, god) < 0) |
822 | if (god_examines_priest (op, god) < 0) |
828 | return; |
823 | return; |
829 | |
824 | |
|
|
825 | op->play_sound (sound_find ("god_intervention")); |
830 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a holy presence!"); |
826 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a holy presence!"); |
831 | |
827 | |
832 | for (tr = god->randomitems->items; tr != NULL; tr = tr->next) |
828 | for (tr = god->randomitems->items; tr; tr = tr->next) |
833 | { |
829 | { |
834 | object *item; |
830 | object *item; |
835 | |
831 | |
836 | if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH)) |
832 | if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH)) |
837 | continue; |
833 | continue; |
838 | |
834 | |
839 | /* Treasurelist - generate some treasure for the follower */ |
835 | /* Treasurelist - generate some treasure for the follower */ |
840 | if (tr->name) |
836 | if (tr->name) |
841 | { |
837 | { |
842 | treasurelist *tl = find_treasurelist (tr->name); |
838 | treasurelist *tl = treasurelist::find (tr->name); |
843 | |
839 | |
844 | if (tl == NULL) |
840 | if (tl == NULL) |
845 | continue; |
841 | continue; |
846 | |
842 | |
847 | new_draw_info (NDI_UNIQUE, 0, op, "Something appears before your " "eyes. You catch it before it falls to the ground."); |
843 | new_draw_info (NDI_UNIQUE, 0, op, "Something appears before your eyes. You catch it before it falls to the ground."); |
848 | |
844 | |
849 | create_treasure (tl, op, GT_STARTEQUIP | GT_ONLY_GOOD | GT_UPDATE_INV, skill->level, 0); |
845 | create_treasure (tl, op, GT_STARTEQUIP | GT_ONLY_GOOD | GT_UPDATE_INV, skill->level, 0); |
850 | return; |
846 | return; |
851 | } |
847 | } |
852 | |
848 | |
853 | if (!tr->item) |
849 | if (!tr->item) |
854 | { |
|
|
855 | LOG (llevError, "BUG: empty entry in %s's treasure list\n", &god->name); |
|
|
856 | continue; |
850 | continue; |
857 | } |
851 | |
858 | item = &tr->item->clone; |
852 | item = tr->item; |
859 | |
853 | |
860 | /* Grace limit */ |
854 | /* Grace limit */ |
861 | if (item->type == BOOK && item->invisible && strcmp (item->name, "grace limit") == 0) |
855 | if (item->type == BOOK && item->invisible && strcmp (item->name, "grace limit") == 0) |
862 | { |
856 | { |
863 | if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace) |
857 | if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace) |
… | |
… | |
870 | tmp = get_archetype (HOLY_POSSESSION); |
864 | tmp = get_archetype (HOLY_POSSESSION); |
871 | cast_change_ability (op, op, tmp, 0, 1); |
865 | cast_change_ability (op, op, tmp, 0, 1); |
872 | tmp->destroy (); |
866 | tmp->destroy (); |
873 | return; |
867 | return; |
874 | } |
868 | } |
|
|
869 | |
875 | continue; |
870 | continue; |
876 | } |
871 | } |
877 | |
872 | |
878 | /* Restore grace */ |
873 | /* Restore grace */ |
879 | if (item->type == BOOK && item->invisible && strcmp (item->name, "restore grace") == 0) |
874 | if (item->type == BOOK && item->invisible && strcmp (item->name, "restore grace") == 0) |
… | |
… | |
961 | continue; |
956 | continue; |
962 | |
957 | |
963 | new_draw_info (NDI_UNIQUE, 0, op, "Shimmering light surrounds and restores you!"); |
958 | new_draw_info (NDI_UNIQUE, 0, op, "Shimmering light surrounds and restores you!"); |
964 | |
959 | |
965 | for (i = 0; i < NUM_STATS; i++) |
960 | for (i = 0; i < NUM_STATS; i++) |
966 | if (get_attr_value (&depl->stats, i)) |
961 | if (depl->stats.stat (i)) |
967 | new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); |
962 | new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); |
968 | |
963 | |
969 | depl->destroy (); |
964 | depl->destroy (); |
970 | fix_player (op); |
965 | op->update_stats (); |
971 | return; |
966 | return; |
972 | } |
967 | } |
973 | |
968 | |
974 | /* Voices */ |
969 | /* Voices */ |
975 | if (item->type == BOOK && item->invisible && strcmp (item->name, "voice_behind") == 0) |
970 | if (item->type == BOOK && item->invisible && strcmp (item->name, "voice_behind") == 0) |
976 | { |
971 | { |
977 | new_draw_info (NDI_UNIQUE, 0, op, "You hear a voice from behind you, but you don't dare to " "turn around:"); |
972 | new_draw_info (NDI_UNIQUE, 0, op, "You hear a voice from behind you, but you don't dare to turn around:"); |
978 | new_draw_info (NDI_WHITE, 0, op, item->msg); |
973 | new_draw_info (NDI_WHITE, 0, op, item->msg); |
979 | return; |
974 | return; |
980 | } |
975 | } |
981 | |
976 | |
982 | /* Messages */ |
977 | /* Messages */ |
… | |
… | |
1133 | |
1128 | |
1134 | if (race == NULL) |
1129 | if (race == NULL) |
1135 | return NULL; |
1130 | return NULL; |
1136 | while (gl) |
1131 | while (gl) |
1137 | { |
1132 | { |
1138 | if (!strcasecmp (gl->arch->clone.race, race)) |
1133 | if (!strcasecmp (gl->arch->race, race)) |
1139 | { |
1134 | { |
1140 | godname = gl->name; |
1135 | godname = gl->name; |
1141 | break; |
1136 | break; |
1142 | } |
1137 | } |
1143 | gl = gl->next; |
1138 | gl = gl->next; |
… | |
… | |
1148 | /** |
1143 | /** |
1149 | * Changes the attributes of cone, smite, and ball spells as needed by the code. |
1144 | * Changes the attributes of cone, smite, and ball spells as needed by the code. |
1150 | * Returns false if there was no race to assign to the slaying field of the spell, but |
1145 | * Returns false if there was no race to assign to the slaying field of the spell, but |
1151 | * the spell attacktype contains AT_HOLYWORD. -b.t. |
1146 | * the spell attacktype contains AT_HOLYWORD. -b.t. |
1152 | */ |
1147 | */ |
1153 | |
|
|
1154 | int |
1148 | int |
1155 | tailor_god_spell (object *spellop, object *caster) |
1149 | tailor_god_spell (object *spellop, object *caster) |
1156 | { |
1150 | { |
1157 | object *god = find_god (determine_god (caster)); |
1151 | object *god = find_god (determine_god (caster)); |
1158 | int caster_is_spell = 0; |
1152 | int caster_is_spell = 0; |