ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/gods.C
(Generate patch)

Comparing deliantra/server/server/gods.C (file contents):
Revision 1.12 by elmex, Wed Dec 20 10:31:00 2006 UTC vs.
Revision 1.20 by root, Fri Apr 20 18:18:53 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game for X-windows
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 */
31#include <global.h> 32#include <global.h>
32#include <living.h> 33#include <living.h>
33#include <object.h> 34#include <object.h>
34#include <spells.h> 35#include <spells.h>
35#include <sounds.h> 36#include <sounds.h>
36#ifndef __CEXTRACT__
37# include <sproto.h> 37#include <sproto.h>
38#endif
39 38
40/** 39/**
41 * Returns the id of specified god. 40 * Returns the id of specified god.
42 */ 41 */
43int 42int
241static int 240static int
242god_gives_present (object *op, object *god, treasure *tr) 241god_gives_present (object *op, object *god, treasure *tr)
243{ 242{
244 object *tmp; 243 object *tmp;
245 244
245 if (!tr->item)
246 return 0;
247
246 if (follower_has_similar_item (op, &tr->item->clone)) 248 if (follower_has_similar_item (op, &tr->item->clone))
247 return 0; 249 return 0;
248 250
249 tmp = arch_to_object (tr->item); 251 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)); 252 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); 253 tmp = insert_ob_in_ob (tmp, op);
252 if (op->type == PLAYER) 254 if (op->type == PLAYER)
253 esrv_send_item (op, tmp); 255 esrv_send_item (op, tmp);
256
254 return 1; 257 return 1;
255} 258}
256 259
257/** 260/**
258 * Player prays at altar. 261 * Player prays at altar.
396 remove = 1; 399 remove = 1;
397 for (tr = god->randomitems->items; tr; tr = tr->next) 400 for (tr = god->randomitems->items; tr; tr = tr->next)
398 { 401 {
399 object *item; 402 object *item;
400 403
401 if (tr->item == NULL) 404 if (!tr->item)
402 continue; 405 continue;
406
403 item = &tr->item->clone; 407 item = &tr->item->clone;
404 408
405 /* Basically, see if the matching spell is granted by this god. */ 409 /* Basically, see if the matching spell is granted by this god. */
406 410
407 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)
457 } 461 }
458 } 462 }
459 463
460 /* remove any godgiven items from the old god */ 464 /* remove any godgiven items from the old god */
461 if (old_god) 465 if (old_god)
462 {
463 for (tr = old_god->randomitems->items; tr != NULL; tr = tr->next) 466 for (tr = old_god->randomitems->items; tr; tr = tr->next)
464 {
465 if (tr->item && QUERY_FLAG (&tr->item->clone, FLAG_STARTEQUIP)) 467 if (tr->item && QUERY_FLAG (&tr->item->clone, FLAG_STARTEQUIP))
466 follower_remove_similar_item (op, &tr->item->clone); 468 follower_remove_similar_item (op, &tr->item->clone);
467 }
468 }
469 469
470 if (!op || !new_god) 470 if (!op || !new_god)
471 return; 471 return;
472 472
473 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))
474 { 474 {
475 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
476 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)
477 { 478 {
478 object *tmp = get_archetype (LOOSE_MANA); 479 object *tmp = get_archetype (LOOSE_MANA);
479 480
480 cast_magic_storm (op, tmp, new_god->level + 10); 481 cast_magic_storm (op, tmp, new_god->level + 10);
481 } 482 }
483
482 return; 484 return;
483 } 485 }
484 486
485 487
486 /* give the player any special god-characteristic-items. */ 488 /* give the player any special god-characteristic-items. */
487 for (tr = new_god->randomitems->items; tr != NULL; tr = tr->next) 489 for (tr = new_god->randomitems->items; tr; tr = tr->next)
488 { 490 {
489 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
490 tr->item->clone.type != BOOK && tr->item->clone.type != SPELL) 492 && tr->item->clone.type != BOOK && tr->item->clone.type != SPELL)
491 god_gives_present (op, new_god, tr); 493 god_gives_present (op, new_god, tr);
492 } 494 }
493 495
494 496
495 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);
678 { 680 {
679 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");
680 return NULL; 682 return NULL;
681 } 683 }
682 684
683 for (tr = god->randomitems->items; tr != NULL; tr = tr->next) 685 for (tr = god->randomitems->items; tr; tr = tr->next)
684 { 686 {
685 object *item;
686
687 if (!tr->item) 687 if (!tr->item)
688 continue; 688 continue;
689
689 item = &tr->item->clone; 690 object *item = &tr->item->clone;
690 691
691 if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) 692 if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0)
692 return item->other_arch; 693 return item->other_arch;
693 } 694 }
694 return NULL; 695 return NULL;
736 737
737 if (level <= 20) 738 if (level <= 20)
738 return level / difficulty; 739 return level / difficulty;
739 if (level <= 40) 740 if (level <= 40)
740 return (20 + (level - 20) / 2) / difficulty; 741 return (20 + (level - 20) / 2) / difficulty;
742
741 return (30 + (level - 40) / 4) / difficulty; 743 return (30 + (level - 40) / 4) / difficulty;
742} 744}
743 745
744/** 746/**
745 * God wants to enchant weapon. 747 * God wants to enchant weapon.
756 int tmp; 758 int tmp;
757 759
758 for (weapon = op->inv; weapon; weapon = weapon->below) 760 for (weapon = op->inv; weapon; weapon = weapon->below)
759 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))
760 break; 762 break;
763
761 if (weapon == NULL || god_examines_item (god, weapon) <= 0) 764 if (weapon == NULL || god_examines_item (god, weapon) <= 0)
762 return 0; 765 return 0;
763 766
764 /* 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 */
765 if (!weapon->title) 768 if (!weapon->title)
827 if (god_examines_priest (op, god) < 0) 830 if (god_examines_priest (op, god) < 0)
828 return; 831 return;
829 832
830 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!");
831 834
832 for (tr = god->randomitems->items; tr != NULL; tr = tr->next) 835 for (tr = god->randomitems->items; tr; tr = tr->next)
833 { 836 {
834 object *item; 837 object *item;
835 838
836 if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH)) 839 if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH))
837 continue; 840 continue;
838 841
839 /* Treasurelist - generate some treasure for the follower */ 842 /* Treasurelist - generate some treasure for the follower */
840 if (tr->name) 843 if (tr->name)
841 { 844 {
842 treasurelist *tl = find_treasurelist (tr->name); 845 treasurelist *tl = treasurelist::find (tr->name);
843 846
844 if (tl == NULL) 847 if (tl == NULL)
845 continue; 848 continue;
846 849
847 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.");
849 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);
850 return; 853 return;
851 } 854 }
852 855
853 if (!tr->item) 856 if (!tr->item)
854 {
855 LOG (llevError, "BUG: empty entry in %s's treasure list\n", &god->name);
856 continue; 857 continue;
857 } 858
858 item = &tr->item->clone; 859 item = &tr->item->clone;
859 860
860 /* Grace limit */ 861 /* Grace limit */
861 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)
862 { 863 {
965 for (i = 0; i < NUM_STATS; i++) 966 for (i = 0; i < NUM_STATS; i++)
966 if (get_attr_value (&depl->stats, i)) 967 if (get_attr_value (&depl->stats, i))
967 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); 968 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]);
968 969
969 depl->destroy (); 970 depl->destroy ();
970 fix_player (op); 971 op->update_stats ();
971 return; 972 return;
972 } 973 }
973 974
974 /* Voices */ 975 /* Voices */
975 if (item->type == BOOK && item->invisible && strcmp (item->name, "voice_behind") == 0) 976 if (item->type == BOOK && item->invisible && strcmp (item->name, "voice_behind") == 0)
1148/** 1149/**
1149 * 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.
1150 * 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
1151 * the spell attacktype contains AT_HOLYWORD. -b.t. 1152 * the spell attacktype contains AT_HOLYWORD. -b.t.
1152 */ 1153 */
1153
1154int 1154int
1155tailor_god_spell (object *spellop, object *caster) 1155tailor_god_spell (object *spellop, object *caster)
1156{ 1156{
1157 object *god = find_god (determine_god (caster)); 1157 object *god = find_god (determine_god (caster));
1158 int caster_is_spell = 0; 1158 int caster_is_spell = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines