1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game |
3 | |
3 | * |
|
|
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | |
7 | * |
7 | This program is free software; you can redistribute it and/or modify |
8 | * This program 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 2 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, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 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 at <crossfire@schmorp.de> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | |
25 | |
25 | /* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and |
26 | /* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and |
26 | * monster race initialization. b.t. |
27 | * monster race initialization. b.t. |
27 | */ |
28 | */ |
… | |
… | |
239 | static int |
240 | static int |
240 | god_gives_present (object *op, object *god, treasure *tr) |
241 | god_gives_present (object *op, object *god, treasure *tr) |
241 | { |
242 | { |
242 | object *tmp; |
243 | object *tmp; |
243 | |
244 | |
|
|
245 | if (!tr->item) |
|
|
246 | return 0; |
|
|
247 | |
244 | if (follower_has_similar_item (op, &tr->item->clone)) |
248 | if (follower_has_similar_item (op, &tr->item->clone)) |
245 | return 0; |
249 | return 0; |
246 | |
250 | |
247 | tmp = arch_to_object (tr->item); |
251 | tmp = arch_to_object (tr->item); |
248 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s lets %s appear in your hands.", &god->name, query_short_name (tmp)); |
252 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s lets %s appear in your hands.", &god->name, query_short_name (tmp)); |
249 | tmp = insert_ob_in_ob (tmp, op); |
253 | tmp = insert_ob_in_ob (tmp, op); |
250 | if (op->type == PLAYER) |
254 | if (op->type == PLAYER) |
251 | esrv_send_item (op, tmp); |
255 | esrv_send_item (op, tmp); |
|
|
256 | |
252 | return 1; |
257 | return 1; |
253 | } |
258 | } |
254 | |
259 | |
255 | /** |
260 | /** |
256 | * Player prays at altar. |
261 | * Player prays at altar. |
… | |
… | |
394 | remove = 1; |
399 | remove = 1; |
395 | for (tr = god->randomitems->items; tr; tr = tr->next) |
400 | for (tr = god->randomitems->items; tr; tr = tr->next) |
396 | { |
401 | { |
397 | object *item; |
402 | object *item; |
398 | |
403 | |
399 | if (tr->item == NULL) |
404 | if (!tr->item) |
400 | continue; |
405 | continue; |
|
|
406 | |
401 | item = &tr->item->clone; |
407 | item = &tr->item->clone; |
402 | |
408 | |
403 | /* Basically, see if the matching spell is granted by this god. */ |
409 | /* Basically, see if the matching spell is granted by this god. */ |
404 | |
410 | |
405 | if (tr->item->clone.type == SPELL && tr->item->clone.name == tmp->name) |
411 | if (tr->item->clone.type == SPELL && tr->item->clone.name == tmp->name) |
… | |
… | |
455 | } |
461 | } |
456 | } |
462 | } |
457 | |
463 | |
458 | /* remove any godgiven items from the old god */ |
464 | /* remove any godgiven items from the old god */ |
459 | if (old_god) |
465 | if (old_god) |
460 | { |
|
|
461 | for (tr = old_god->randomitems->items; tr != NULL; tr = tr->next) |
466 | for (tr = old_god->randomitems->items; tr; tr = tr->next) |
462 | { |
|
|
463 | if (tr->item && QUERY_FLAG (&tr->item->clone, FLAG_STARTEQUIP)) |
467 | if (tr->item && QUERY_FLAG (&tr->item->clone, FLAG_STARTEQUIP)) |
464 | follower_remove_similar_item (op, &tr->item->clone); |
468 | follower_remove_similar_item (op, &tr->item->clone); |
465 | } |
|
|
466 | } |
|
|
467 | |
469 | |
468 | if (!op || !new_god) |
470 | if (!op || !new_god) |
469 | return; |
471 | return; |
470 | |
472 | |
471 | if (op->race && new_god->slaying && strstr (op->race, new_god->slaying)) |
473 | if (op->race && new_god->slaying && strstr (op->race, new_god->slaying)) |
472 | { |
474 | { |
473 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name); |
475 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name); |
|
|
476 | |
474 | if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0) |
477 | if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0) |
475 | { |
478 | { |
476 | object *tmp = get_archetype (LOOSE_MANA); |
479 | object *tmp = get_archetype (LOOSE_MANA); |
477 | |
480 | |
478 | cast_magic_storm (op, tmp, new_god->level + 10); |
481 | cast_magic_storm (op, tmp, new_god->level + 10); |
479 | } |
482 | } |
|
|
483 | |
480 | return; |
484 | return; |
481 | } |
485 | } |
482 | |
486 | |
483 | |
487 | |
484 | /* give the player any special god-characteristic-items. */ |
488 | /* give the player any special god-characteristic-items. */ |
485 | for (tr = new_god->randomitems->items; tr != NULL; tr = tr->next) |
489 | for (tr = new_god->randomitems->items; tr; tr = tr->next) |
486 | { |
490 | { |
487 | if (tr->item && tr->item->clone.invisible && tr->item->clone.type != SPELLBOOK && |
491 | if (tr->item && tr->item->clone.invisible && tr->item->clone.type != SPELLBOOK |
488 | tr->item->clone.type != BOOK && tr->item->clone.type != SPELL) |
492 | && tr->item->clone.type != BOOK && tr->item->clone.type != SPELL) |
489 | god_gives_present (op, new_god, tr); |
493 | god_gives_present (op, new_god, tr); |
490 | } |
494 | } |
491 | |
495 | |
492 | |
496 | |
493 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You become a follower of %s!", &new_god->name); |
497 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You become a follower of %s!", &new_god->name); |
… | |
… | |
676 | { |
680 | { |
677 | LOG (llevError, "BUG: determine_holy_arch(): no god or god without " "randomitems\n"); |
681 | LOG (llevError, "BUG: determine_holy_arch(): no god or god without " "randomitems\n"); |
678 | return NULL; |
682 | return NULL; |
679 | } |
683 | } |
680 | |
684 | |
681 | for (tr = god->randomitems->items; tr != NULL; tr = tr->next) |
685 | for (tr = god->randomitems->items; tr; tr = tr->next) |
682 | { |
686 | { |
683 | object *item; |
|
|
684 | |
|
|
685 | if (!tr->item) |
687 | if (!tr->item) |
686 | continue; |
688 | continue; |
|
|
689 | |
687 | item = &tr->item->clone; |
690 | object *item = &tr->item->clone; |
688 | |
691 | |
689 | if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) |
692 | if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) |
690 | return item->other_arch; |
693 | return item->other_arch; |
691 | } |
694 | } |
692 | return NULL; |
695 | return NULL; |
… | |
… | |
734 | |
737 | |
735 | if (level <= 20) |
738 | if (level <= 20) |
736 | return level / difficulty; |
739 | return level / difficulty; |
737 | if (level <= 40) |
740 | if (level <= 40) |
738 | return (20 + (level - 20) / 2) / difficulty; |
741 | return (20 + (level - 20) / 2) / difficulty; |
|
|
742 | |
739 | return (30 + (level - 40) / 4) / difficulty; |
743 | return (30 + (level - 40) / 4) / difficulty; |
740 | } |
744 | } |
741 | |
745 | |
742 | /** |
746 | /** |
743 | * God wants to enchant weapon. |
747 | * God wants to enchant weapon. |
… | |
… | |
754 | int tmp; |
758 | int tmp; |
755 | |
759 | |
756 | for (weapon = op->inv; weapon; weapon = weapon->below) |
760 | for (weapon = op->inv; weapon; weapon = weapon->below) |
757 | if ((weapon->type == WEAPON || weapon->type == BOW) && QUERY_FLAG (weapon, FLAG_APPLIED)) |
761 | if ((weapon->type == WEAPON || weapon->type == BOW) && QUERY_FLAG (weapon, FLAG_APPLIED)) |
758 | break; |
762 | break; |
|
|
763 | |
759 | if (weapon == NULL || god_examines_item (god, weapon) <= 0) |
764 | if (weapon == NULL || god_examines_item (god, weapon) <= 0) |
760 | return 0; |
765 | return 0; |
761 | |
766 | |
762 | /* First give it a title, so other gods won't touch it */ |
767 | /* First give it a title, so other gods won't touch it */ |
763 | if (!weapon->title) |
768 | if (!weapon->title) |
… | |
… | |
825 | if (god_examines_priest (op, god) < 0) |
830 | if (god_examines_priest (op, god) < 0) |
826 | return; |
831 | return; |
827 | |
832 | |
828 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a holy presence!"); |
833 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a holy presence!"); |
829 | |
834 | |
830 | for (tr = god->randomitems->items; tr != NULL; tr = tr->next) |
835 | for (tr = god->randomitems->items; tr; tr = tr->next) |
831 | { |
836 | { |
832 | object *item; |
837 | object *item; |
833 | |
838 | |
834 | if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH)) |
839 | if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH)) |
835 | continue; |
840 | continue; |
836 | |
841 | |
837 | /* Treasurelist - generate some treasure for the follower */ |
842 | /* Treasurelist - generate some treasure for the follower */ |
838 | if (tr->name) |
843 | if (tr->name) |
839 | { |
844 | { |
840 | treasurelist *tl = find_treasurelist (tr->name); |
845 | treasurelist *tl = treasurelist::find (tr->name); |
841 | |
846 | |
842 | if (tl == NULL) |
847 | if (tl == NULL) |
843 | continue; |
848 | continue; |
844 | |
849 | |
845 | new_draw_info (NDI_UNIQUE, 0, op, "Something appears before your " "eyes. You catch it before it falls to the ground."); |
850 | new_draw_info (NDI_UNIQUE, 0, op, "Something appears before your " "eyes. You catch it before it falls to the ground."); |
… | |
… | |
847 | create_treasure (tl, op, GT_STARTEQUIP | GT_ONLY_GOOD | GT_UPDATE_INV, skill->level, 0); |
852 | create_treasure (tl, op, GT_STARTEQUIP | GT_ONLY_GOOD | GT_UPDATE_INV, skill->level, 0); |
848 | return; |
853 | return; |
849 | } |
854 | } |
850 | |
855 | |
851 | if (!tr->item) |
856 | if (!tr->item) |
852 | { |
|
|
853 | LOG (llevError, "BUG: empty entry in %s's treasure list\n", &god->name); |
|
|
854 | continue; |
857 | continue; |
855 | } |
858 | |
856 | item = &tr->item->clone; |
859 | item = &tr->item->clone; |
857 | |
860 | |
858 | /* Grace limit */ |
861 | /* Grace limit */ |
859 | if (item->type == BOOK && item->invisible && strcmp (item->name, "grace limit") == 0) |
862 | if (item->type == BOOK && item->invisible && strcmp (item->name, "grace limit") == 0) |
860 | { |
863 | { |
… | |
… | |
959 | continue; |
962 | continue; |
960 | |
963 | |
961 | new_draw_info (NDI_UNIQUE, 0, op, "Shimmering light surrounds and restores you!"); |
964 | new_draw_info (NDI_UNIQUE, 0, op, "Shimmering light surrounds and restores you!"); |
962 | |
965 | |
963 | for (i = 0; i < NUM_STATS; i++) |
966 | for (i = 0; i < NUM_STATS; i++) |
964 | if (get_attr_value (&depl->stats, i)) |
967 | if (depl->stats.stat (i)) |
965 | new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); |
968 | new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); |
966 | |
969 | |
967 | depl->destroy (); |
970 | depl->destroy (); |
968 | op->update_stats (); |
971 | op->update_stats (); |
969 | return; |
972 | return; |
… | |
… | |
1146 | /** |
1149 | /** |
1147 | * Changes the attributes of cone, smite, and ball spells as needed by the code. |
1150 | * Changes the attributes of cone, smite, and ball spells as needed by the code. |
1148 | * Returns false if there was no race to assign to the slaying field of the spell, but |
1151 | * Returns false if there was no race to assign to the slaying field of the spell, but |
1149 | * the spell attacktype contains AT_HOLYWORD. -b.t. |
1152 | * the spell attacktype contains AT_HOLYWORD. -b.t. |
1150 | */ |
1153 | */ |
1151 | |
|
|
1152 | int |
1154 | int |
1153 | tailor_god_spell (object *spellop, object *caster) |
1155 | tailor_god_spell (object *spellop, object *caster) |
1154 | { |
1156 | { |
1155 | object *god = find_god (determine_god (caster)); |
1157 | object *god = find_god (determine_god (caster)); |
1156 | int caster_is_spell = 0; |
1158 | int caster_is_spell = 0; |