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 it |
8 | 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 |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | * Software Foundation; either version 2 of the License, or (at your option) |
10 | (at your option) any later version. |
11 | * 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, but |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
15 | GNU General Public License for more details. |
16 | * 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 along |
18 | 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 |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 | |
21 | * |
21 | 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> |
22 | */ |
23 | */ |
23 | |
|
|
24 | |
24 | |
25 | /* 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 |
26 | * monster race initialization. b.t. |
26 | * monster race initialization. b.t. |
27 | */ |
27 | */ |
28 | |
28 | |
… | |
… | |
31 | #include <global.h> |
31 | #include <global.h> |
32 | #include <living.h> |
32 | #include <living.h> |
33 | #include <object.h> |
33 | #include <object.h> |
34 | #include <spells.h> |
34 | #include <spells.h> |
35 | #include <sounds.h> |
35 | #include <sounds.h> |
36 | #ifndef __CEXTRACT__ |
|
|
37 | # include <sproto.h> |
36 | #include <sproto.h> |
38 | #endif |
|
|
39 | |
37 | |
40 | /** |
38 | /** |
41 | * Returns the id of specified god. |
39 | * Returns the id of specified god. |
42 | */ |
40 | */ |
43 | int |
41 | int |
… | |
… | |
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->clone)) |
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. |
… | |
… | |
345 | |
347 | |
346 | /* 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 |
347 | * note it gets harder to swap gods the higher we get |
349 | * note it gets harder to swap gods the higher we get |
348 | */ |
350 | */ |
349 | if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) |
351 | if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) |
350 | { |
|
|
351 | become_follower (pl, &altar->other_arch->clone); |
352 | become_follower (pl, &altar->other_arch->clone); |
352 | } |
|
|
353 | else |
353 | else |
354 | { |
354 | { |
355 | /* toss this player off the altar. He can try again. */ |
355 | /* 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."); |
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; |
357 | 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. */ |
358 | } |
360 | } |
359 | } |
361 | } |
360 | } |
362 | } |
361 | |
363 | |
… | |
… | |
396 | remove = 1; |
398 | remove = 1; |
397 | for (tr = god->randomitems->items; tr; tr = tr->next) |
399 | for (tr = god->randomitems->items; tr; tr = tr->next) |
398 | { |
400 | { |
399 | object *item; |
401 | object *item; |
400 | |
402 | |
401 | if (tr->item == NULL) |
403 | if (!tr->item) |
402 | continue; |
404 | continue; |
|
|
405 | |
403 | item = &tr->item->clone; |
406 | item = &tr->item->clone; |
404 | |
407 | |
405 | /* Basically, see if the matching spell is granted by this god. */ |
408 | /* Basically, see if the matching spell is granted by this god. */ |
406 | |
409 | |
407 | 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) |
… | |
… | |
457 | } |
460 | } |
458 | } |
461 | } |
459 | |
462 | |
460 | /* remove any godgiven items from the old god */ |
463 | /* remove any godgiven items from the old god */ |
461 | if (old_god) |
464 | if (old_god) |
462 | { |
|
|
463 | for (tr = old_god->randomitems->items; tr != NULL; tr = tr->next) |
465 | for (tr = old_god->randomitems->items; tr; tr = tr->next) |
464 | { |
|
|
465 | if (tr->item && QUERY_FLAG (&tr->item->clone, FLAG_STARTEQUIP)) |
466 | if (tr->item && QUERY_FLAG (&tr->item->clone, FLAG_STARTEQUIP)) |
466 | follower_remove_similar_item (op, &tr->item->clone); |
467 | follower_remove_similar_item (op, &tr->item->clone); |
467 | } |
|
|
468 | } |
|
|
469 | |
468 | |
470 | if (!op || !new_god) |
469 | if (!op || !new_god) |
471 | return; |
470 | return; |
472 | |
471 | |
473 | 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)) |
474 | { |
473 | { |
475 | 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 | |
476 | 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) |
477 | { |
477 | { |
478 | object *tmp = get_archetype (LOOSE_MANA); |
478 | object *tmp = get_archetype (LOOSE_MANA); |
479 | |
479 | |
480 | cast_magic_storm (op, tmp, new_god->level + 10); |
480 | cast_magic_storm (op, tmp, new_god->level + 10); |
481 | } |
481 | } |
|
|
482 | |
482 | return; |
483 | return; |
483 | } |
484 | } |
484 | |
485 | |
485 | |
486 | |
486 | /* give the player any special god-characteristic-items. */ |
487 | /* give the player any special god-characteristic-items. */ |
487 | for (tr = new_god->randomitems->items; tr != NULL; tr = tr->next) |
488 | for (tr = new_god->randomitems->items; tr; tr = tr->next) |
488 | { |
489 | { |
489 | 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 |
490 | tr->item->clone.type != BOOK && tr->item->clone.type != SPELL) |
491 | && tr->item->clone.type != BOOK && tr->item->clone.type != SPELL) |
491 | god_gives_present (op, new_god, tr); |
492 | god_gives_present (op, new_god, tr); |
492 | } |
493 | } |
493 | |
494 | |
494 | |
495 | |
495 | 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); |
… | |
… | |
678 | { |
679 | { |
679 | 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"); |
680 | return NULL; |
681 | return NULL; |
681 | } |
682 | } |
682 | |
683 | |
683 | for (tr = god->randomitems->items; tr != NULL; tr = tr->next) |
684 | for (tr = god->randomitems->items; tr; tr = tr->next) |
684 | { |
685 | { |
685 | object *item; |
|
|
686 | |
|
|
687 | if (!tr->item) |
686 | if (!tr->item) |
688 | continue; |
687 | continue; |
|
|
688 | |
689 | item = &tr->item->clone; |
689 | object *item = &tr->item->clone; |
690 | |
690 | |
691 | if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) |
691 | if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) |
692 | return item->other_arch; |
692 | return item->other_arch; |
693 | } |
693 | } |
694 | return NULL; |
694 | return NULL; |
… | |
… | |
736 | |
736 | |
737 | if (level <= 20) |
737 | if (level <= 20) |
738 | return level / difficulty; |
738 | return level / difficulty; |
739 | if (level <= 40) |
739 | if (level <= 40) |
740 | return (20 + (level - 20) / 2) / difficulty; |
740 | return (20 + (level - 20) / 2) / difficulty; |
|
|
741 | |
741 | return (30 + (level - 40) / 4) / difficulty; |
742 | return (30 + (level - 40) / 4) / difficulty; |
742 | } |
743 | } |
743 | |
744 | |
744 | /** |
745 | /** |
745 | * God wants to enchant weapon. |
746 | * God wants to enchant weapon. |
… | |
… | |
756 | int tmp; |
757 | int tmp; |
757 | |
758 | |
758 | for (weapon = op->inv; weapon; weapon = weapon->below) |
759 | for (weapon = op->inv; weapon; weapon = weapon->below) |
759 | 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)) |
760 | break; |
761 | break; |
|
|
762 | |
761 | if (weapon == NULL || god_examines_item (god, weapon) <= 0) |
763 | if (weapon == NULL || god_examines_item (god, weapon) <= 0) |
762 | return 0; |
764 | return 0; |
763 | |
765 | |
764 | /* 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 */ |
765 | if (!weapon->title) |
767 | if (!weapon->title) |
… | |
… | |
827 | if (god_examines_priest (op, god) < 0) |
829 | if (god_examines_priest (op, god) < 0) |
828 | return; |
830 | return; |
829 | |
831 | |
830 | 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!"); |
831 | |
833 | |
832 | for (tr = god->randomitems->items; tr != NULL; tr = tr->next) |
834 | for (tr = god->randomitems->items; tr; tr = tr->next) |
833 | { |
835 | { |
834 | object *item; |
836 | object *item; |
835 | |
837 | |
836 | if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH)) |
838 | if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH)) |
837 | continue; |
839 | continue; |
838 | |
840 | |
839 | /* Treasurelist - generate some treasure for the follower */ |
841 | /* Treasurelist - generate some treasure for the follower */ |
840 | if (tr->name) |
842 | if (tr->name) |
841 | { |
843 | { |
842 | treasurelist *tl = find_treasurelist (tr->name); |
844 | treasurelist *tl = treasurelist::find (tr->name); |
843 | |
845 | |
844 | if (tl == NULL) |
846 | if (tl == NULL) |
845 | continue; |
847 | continue; |
846 | |
848 | |
847 | 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."); |
… | |
… | |
849 | create_treasure (tl, op, GT_STARTEQUIP | GT_ONLY_GOOD | GT_UPDATE_INV, skill->level, 0); |
851 | create_treasure (tl, op, GT_STARTEQUIP | GT_ONLY_GOOD | GT_UPDATE_INV, skill->level, 0); |
850 | return; |
852 | return; |
851 | } |
853 | } |
852 | |
854 | |
853 | if (!tr->item) |
855 | if (!tr->item) |
854 | { |
|
|
855 | LOG (llevError, "BUG: empty entry in %s's treasure list\n", &god->name); |
|
|
856 | continue; |
856 | continue; |
857 | } |
857 | |
858 | item = &tr->item->clone; |
858 | item = &tr->item->clone; |
859 | |
859 | |
860 | /* Grace limit */ |
860 | /* Grace limit */ |
861 | if (item->type == BOOK && item->invisible && strcmp (item->name, "grace limit") == 0) |
861 | if (item->type == BOOK && item->invisible && strcmp (item->name, "grace limit") == 0) |
862 | { |
862 | { |
… | |
… | |
961 | continue; |
961 | continue; |
962 | |
962 | |
963 | 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!"); |
964 | |
964 | |
965 | for (i = 0; i < NUM_STATS; i++) |
965 | for (i = 0; i < NUM_STATS; i++) |
966 | if (get_attr_value (&depl->stats, i)) |
966 | if (depl->stats.stat (i)) |
967 | new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); |
967 | new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); |
968 | |
968 | |
969 | depl->destroy (); |
969 | depl->destroy (); |
970 | fix_player (op); |
970 | op->update_stats (); |
971 | return; |
971 | return; |
972 | } |
972 | } |
973 | |
973 | |
974 | /* Voices */ |
974 | /* Voices */ |
975 | if (item->type == BOOK && item->invisible && strcmp (item->name, "voice_behind") == 0) |
975 | if (item->type == BOOK && item->invisible && strcmp (item->name, "voice_behind") == 0) |
… | |
… | |
1148 | /** |
1148 | /** |
1149 | * Changes the attributes of cone, smite, and ball spells as needed by the code. |
1149 | * 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 |
1150 | * 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. |
1151 | * the spell attacktype contains AT_HOLYWORD. -b.t. |
1152 | */ |
1152 | */ |
1153 | |
|
|
1154 | int |
1153 | int |
1155 | tailor_god_spell (object *spellop, object *caster) |
1154 | tailor_god_spell (object *spellop, object *caster) |
1156 | { |
1155 | { |
1157 | object *god = find_god (determine_god (caster)); |
1156 | object *god = find_god (determine_god (caster)); |
1158 | int caster_is_spell = 0; |
1157 | int caster_is_spell = 0; |