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 (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * 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 it |
9 | * it under the terms of the GNU General Public License as published by |
9 | * under the terms of the GNU General Public License as published by the Free |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | * Software Foundation; either version 2 of the License, or (at your option) |
11 | * (at your option) any later version. |
11 | * any later version. |
12 | * |
12 | * |
13 | * 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, but |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
16 | * GNU General Public License for more details. |
16 | * for more details. |
17 | * |
17 | * |
18 | * 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 along |
19 | * along with this program; if not, write to the Free Software |
19 | * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51 |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
23 | */ |
23 | */ |
24 | |
|
|
25 | |
24 | |
26 | /* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and |
25 | /* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and |
27 | * monster race initialization. b.t. |
26 | * monster race initialization. b.t. |
28 | */ |
27 | */ |
29 | |
28 | |
… | |
… | |
317 | * points to the god of this altar (which we have |
316 | * points to the god of this altar (which we have |
318 | * already verified is non null). pl_god->other_arch |
317 | * already verified is non null). pl_god->other_arch |
319 | * is the opposing god - we need to verify that exists before |
318 | * is the opposing god - we need to verify that exists before |
320 | * using its values. |
319 | * using its values. |
321 | */ |
320 | */ |
322 | if (pl_god->other_arch && (altar->other_arch->name == pl_god->other_arch->name)) |
321 | if (pl_god->other_arch && (altar->other_arch->archname == pl_god->other_arch->archname)) |
323 | { |
322 | { |
324 | angry = 2; |
323 | angry = 2; |
325 | if (random_roll (0, skill->level + 2, pl, PREFER_LOW) - 5 > 0) |
324 | if (random_roll (0, skill->level + 2, pl, PREFER_LOW) - 5 > 0) |
326 | { |
325 | { |
327 | object *tmp; |
326 | object *tmp; |
… | |
… | |
348 | |
347 | |
349 | /* May switch Gods, but its random chance based on our current level |
348 | /* May switch Gods, but its random chance based on our current level |
350 | * note it gets harder to swap gods the higher we get |
349 | * note it gets harder to swap gods the higher we get |
351 | */ |
350 | */ |
352 | if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) |
351 | if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) |
353 | { |
|
|
354 | become_follower (pl, &altar->other_arch->clone); |
352 | become_follower (pl, &altar->other_arch->clone); |
355 | } |
|
|
356 | else |
353 | else |
357 | { |
354 | { |
358 | /* toss this player off the altar. He can try again. */ |
355 | /* toss this player off the altar. He can try again. */ |
359 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar."); |
356 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar."); |
|
|
357 | pl->contr->fire_on = 0; |
|
|
358 | pl->speed_left = 1.f; |
360 | move_player (pl, absdir (pl->facing + 4)); /* back him off the way he came. */ |
359 | move_player (pl, absdir (pl->facing + 4)); /* back him off the way he came. */ |
361 | } |
360 | } |
362 | } |
361 | } |
363 | } |
362 | } |
364 | |
363 | |
… | |
… | |
401 | { |
400 | { |
402 | object *item; |
401 | object *item; |
403 | |
402 | |
404 | if (!tr->item) |
403 | if (!tr->item) |
405 | continue; |
404 | continue; |
|
|
405 | |
406 | item = &tr->item->clone; |
406 | item = &tr->item->clone; |
407 | |
407 | |
408 | /* Basically, see if the matching spell is granted by this god. */ |
408 | /* Basically, see if the matching spell is granted by this god. */ |
409 | |
409 | |
410 | if (tr->item->clone.type == SPELL && tr->item->clone.name == tmp->name) |
410 | if (tr->item->clone.type == SPELL && tr->item->clone.name == tmp->name) |
… | |
… | |
460 | } |
460 | } |
461 | } |
461 | } |
462 | |
462 | |
463 | /* remove any godgiven items from the old god */ |
463 | /* remove any godgiven items from the old god */ |
464 | if (old_god) |
464 | if (old_god) |
465 | { |
|
|
466 | for (tr = old_god->randomitems->items; tr != NULL; tr = tr->next) |
465 | for (tr = old_god->randomitems->items; tr; tr = tr->next) |
467 | { |
|
|
468 | if (tr->item && QUERY_FLAG (&tr->item->clone, FLAG_STARTEQUIP)) |
466 | if (tr->item && QUERY_FLAG (&tr->item->clone, FLAG_STARTEQUIP)) |
469 | follower_remove_similar_item (op, &tr->item->clone); |
467 | follower_remove_similar_item (op, &tr->item->clone); |
470 | } |
|
|
471 | } |
|
|
472 | |
468 | |
473 | if (!op || !new_god) |
469 | if (!op || !new_god) |
474 | return; |
470 | return; |
475 | |
471 | |
476 | if (op->race && new_god->slaying && strstr (op->race, new_god->slaying)) |
472 | if (op->race && new_god->slaying && strstr (op->race, new_god->slaying)) |
477 | { |
473 | { |
478 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name); |
474 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name); |
|
|
475 | |
479 | if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0) |
476 | if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0) |
480 | { |
477 | { |
481 | object *tmp = get_archetype (LOOSE_MANA); |
478 | object *tmp = get_archetype (LOOSE_MANA); |
482 | |
479 | |
483 | cast_magic_storm (op, tmp, new_god->level + 10); |
480 | cast_magic_storm (op, tmp, new_god->level + 10); |
484 | } |
481 | } |
|
|
482 | |
485 | return; |
483 | return; |
486 | } |
484 | } |
487 | |
485 | |
488 | |
486 | |
489 | /* give the player any special god-characteristic-items. */ |
487 | /* give the player any special god-characteristic-items. */ |
490 | for (tr = new_god->randomitems->items; tr != NULL; tr = tr->next) |
488 | for (tr = new_god->randomitems->items; tr; tr = tr->next) |
491 | { |
489 | { |
492 | if (tr->item && tr->item->clone.invisible && tr->item->clone.type != SPELLBOOK && |
490 | if (tr->item && tr->item->clone.invisible && tr->item->clone.type != SPELLBOOK |
493 | tr->item->clone.type != BOOK && tr->item->clone.type != SPELL) |
491 | && tr->item->clone.type != BOOK && tr->item->clone.type != SPELL) |
494 | god_gives_present (op, new_god, tr); |
492 | god_gives_present (op, new_god, tr); |
495 | } |
493 | } |
496 | |
494 | |
497 | |
495 | |
498 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You become a follower of %s!", &new_god->name); |
496 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You become a follower of %s!", &new_god->name); |
… | |
… | |
681 | { |
679 | { |
682 | LOG (llevError, "BUG: determine_holy_arch(): no god or god without " "randomitems\n"); |
680 | LOG (llevError, "BUG: determine_holy_arch(): no god or god without " "randomitems\n"); |
683 | return NULL; |
681 | return NULL; |
684 | } |
682 | } |
685 | |
683 | |
686 | for (tr = god->randomitems->items; tr != NULL; tr = tr->next) |
684 | for (tr = god->randomitems->items; tr; tr = tr->next) |
687 | { |
685 | { |
688 | object *item; |
|
|
689 | |
|
|
690 | if (!tr->item) |
686 | if (!tr->item) |
691 | continue; |
687 | continue; |
692 | |
688 | |
693 | item = &tr->item->clone; |
689 | object *item = &tr->item->clone; |
694 | |
690 | |
695 | if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) |
691 | if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) |
696 | return item->other_arch; |
692 | return item->other_arch; |
697 | } |
693 | } |
698 | return NULL; |
694 | return NULL; |
… | |
… | |
740 | |
736 | |
741 | if (level <= 20) |
737 | if (level <= 20) |
742 | return level / difficulty; |
738 | return level / difficulty; |
743 | if (level <= 40) |
739 | if (level <= 40) |
744 | return (20 + (level - 20) / 2) / difficulty; |
740 | return (20 + (level - 20) / 2) / difficulty; |
|
|
741 | |
745 | return (30 + (level - 40) / 4) / difficulty; |
742 | return (30 + (level - 40) / 4) / difficulty; |
746 | } |
743 | } |
747 | |
744 | |
748 | /** |
745 | /** |
749 | * God wants to enchant weapon. |
746 | * God wants to enchant weapon. |
… | |
… | |
760 | int tmp; |
757 | int tmp; |
761 | |
758 | |
762 | for (weapon = op->inv; weapon; weapon = weapon->below) |
759 | for (weapon = op->inv; weapon; weapon = weapon->below) |
763 | if ((weapon->type == WEAPON || weapon->type == BOW) && QUERY_FLAG (weapon, FLAG_APPLIED)) |
760 | if ((weapon->type == WEAPON || weapon->type == BOW) && QUERY_FLAG (weapon, FLAG_APPLIED)) |
764 | break; |
761 | break; |
|
|
762 | |
765 | if (weapon == NULL || god_examines_item (god, weapon) <= 0) |
763 | if (weapon == NULL || god_examines_item (god, weapon) <= 0) |
766 | return 0; |
764 | return 0; |
767 | |
765 | |
768 | /* First give it a title, so other gods won't touch it */ |
766 | /* First give it a title, so other gods won't touch it */ |
769 | if (!weapon->title) |
767 | if (!weapon->title) |
… | |
… | |
831 | if (god_examines_priest (op, god) < 0) |
829 | if (god_examines_priest (op, god) < 0) |
832 | return; |
830 | return; |
833 | |
831 | |
834 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a holy presence!"); |
832 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a holy presence!"); |
835 | |
833 | |
836 | for (tr = god->randomitems->items; tr != NULL; tr = tr->next) |
834 | for (tr = god->randomitems->items; tr; tr = tr->next) |
837 | { |
835 | { |
838 | object *item; |
836 | object *item; |
839 | |
837 | |
840 | if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH)) |
838 | if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH)) |
841 | continue; |
839 | continue; |
842 | |
840 | |
843 | /* Treasurelist - generate some treasure for the follower */ |
841 | /* Treasurelist - generate some treasure for the follower */ |
844 | if (tr->name) |
842 | if (tr->name) |
845 | { |
843 | { |
846 | treasurelist *tl = find_treasurelist (tr->name); |
844 | treasurelist *tl = treasurelist::find (tr->name); |
847 | |
845 | |
848 | if (tl == NULL) |
846 | if (tl == NULL) |
849 | continue; |
847 | continue; |
850 | |
848 | |
851 | new_draw_info (NDI_UNIQUE, 0, op, "Something appears before your " "eyes. You catch it before it falls to the ground."); |
849 | new_draw_info (NDI_UNIQUE, 0, op, "Something appears before your " "eyes. You catch it before it falls to the ground."); |
… | |
… | |
963 | continue; |
961 | continue; |
964 | |
962 | |
965 | new_draw_info (NDI_UNIQUE, 0, op, "Shimmering light surrounds and restores you!"); |
963 | new_draw_info (NDI_UNIQUE, 0, op, "Shimmering light surrounds and restores you!"); |
966 | |
964 | |
967 | for (i = 0; i < NUM_STATS; i++) |
965 | for (i = 0; i < NUM_STATS; i++) |
968 | if (get_attr_value (&depl->stats, i)) |
966 | if (depl->stats.stat (i)) |
969 | new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); |
967 | new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); |
970 | |
968 | |
971 | depl->destroy (); |
969 | depl->destroy (); |
972 | op->update_stats (); |
970 | op->update_stats (); |
973 | return; |
971 | return; |