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.10 by root, Tue Dec 12 21:39:57 2006 UTC vs.
Revision 1.21 by root, Sat May 12 18:14:48 2007 UTC

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 */
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)
442 446
443 /* take away any special god-characteristic items. */ 447 /* take away any special god-characteristic items. */
444 for (item = op->inv; item != NULL; item = next) 448 for (item = op->inv; item != NULL; item = next)
445 { 449 {
446 next = item->below; 450 next = item->below;
447 /* remove all invisible startequip items which are 451 // remove all invisible startequip items which are not skill, exp or force
448 * not skill, exp or force
449 */
450 if (QUERY_FLAG (item, FLAG_STARTEQUIP) && item->invisible && 452 if (QUERY_FLAG (item, FLAG_STARTEQUIP) && item->invisible &&
451 (item->type != SKILL) && (item->type != EXPERIENCE) && (item->type != FORCE)) 453 (item->type != SKILL) && (item->type != FORCE))
452 { 454 {
453 455
454 if (item->type == SPELL) 456 if (item->type == SPELL)
455 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &item->name); 457 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &item->name);
456 458
459 } 461 }
460 } 462 }
461 463
462 /* remove any godgiven items from the old god */ 464 /* remove any godgiven items from the old god */
463 if (old_god) 465 if (old_god)
464 {
465 for (tr = old_god->randomitems->items; tr != NULL; tr = tr->next) 466 for (tr = old_god->randomitems->items; tr; tr = tr->next)
466 {
467 if (tr->item && QUERY_FLAG (&tr->item->clone, FLAG_STARTEQUIP)) 467 if (tr->item && QUERY_FLAG (&tr->item->clone, FLAG_STARTEQUIP))
468 follower_remove_similar_item (op, &tr->item->clone); 468 follower_remove_similar_item (op, &tr->item->clone);
469 }
470 }
471 469
472 if (!op || !new_god) 470 if (!op || !new_god)
473 return; 471 return;
474 472
475 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))
476 { 474 {
477 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
478 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)
479 { 478 {
480 object *tmp = get_archetype (LOOSE_MANA); 479 object *tmp = get_archetype (LOOSE_MANA);
481 480
482 cast_magic_storm (op, tmp, new_god->level + 10); 481 cast_magic_storm (op, tmp, new_god->level + 10);
483 } 482 }
483
484 return; 484 return;
485 } 485 }
486 486
487 487
488 /* give the player any special god-characteristic-items. */ 488 /* give the player any special god-characteristic-items. */
489 for (tr = new_god->randomitems->items; tr != NULL; tr = tr->next) 489 for (tr = new_god->randomitems->items; tr; tr = tr->next)
490 { 490 {
491 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
492 tr->item->clone.type != BOOK && tr->item->clone.type != SPELL) 492 && tr->item->clone.type != BOOK && tr->item->clone.type != SPELL)
493 god_gives_present (op, new_god, tr); 493 god_gives_present (op, new_god, tr);
494 } 494 }
495 495
496 496
497 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);
680 { 680 {
681 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");
682 return NULL; 682 return NULL;
683 } 683 }
684 684
685 for (tr = god->randomitems->items; tr != NULL; tr = tr->next) 685 for (tr = god->randomitems->items; tr; tr = tr->next)
686 { 686 {
687 object *item;
688
689 if (!tr->item) 687 if (!tr->item)
690 continue; 688 continue;
689
691 item = &tr->item->clone; 690 object *item = &tr->item->clone;
692 691
693 if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) 692 if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0)
694 return item->other_arch; 693 return item->other_arch;
695 } 694 }
696 return NULL; 695 return NULL;
738 737
739 if (level <= 20) 738 if (level <= 20)
740 return level / difficulty; 739 return level / difficulty;
741 if (level <= 40) 740 if (level <= 40)
742 return (20 + (level - 20) / 2) / difficulty; 741 return (20 + (level - 20) / 2) / difficulty;
742
743 return (30 + (level - 40) / 4) / difficulty; 743 return (30 + (level - 40) / 4) / difficulty;
744} 744}
745 745
746/** 746/**
747 * God wants to enchant weapon. 747 * God wants to enchant weapon.
758 int tmp; 758 int tmp;
759 759
760 for (weapon = op->inv; weapon; weapon = weapon->below) 760 for (weapon = op->inv; weapon; weapon = weapon->below)
761 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))
762 break; 762 break;
763
763 if (weapon == NULL || god_examines_item (god, weapon) <= 0) 764 if (weapon == NULL || god_examines_item (god, weapon) <= 0)
764 return 0; 765 return 0;
765 766
766 /* 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 */
767 if (!weapon->title) 768 if (!weapon->title)
829 if (god_examines_priest (op, god) < 0) 830 if (god_examines_priest (op, god) < 0)
830 return; 831 return;
831 832
832 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!");
833 834
834 for (tr = god->randomitems->items; tr != NULL; tr = tr->next) 835 for (tr = god->randomitems->items; tr; tr = tr->next)
835 { 836 {
836 object *item; 837 object *item;
837 838
838 if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH)) 839 if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH))
839 continue; 840 continue;
840 841
841 /* Treasurelist - generate some treasure for the follower */ 842 /* Treasurelist - generate some treasure for the follower */
842 if (tr->name) 843 if (tr->name)
843 { 844 {
844 treasurelist *tl = find_treasurelist (tr->name); 845 treasurelist *tl = treasurelist::find (tr->name);
845 846
846 if (tl == NULL) 847 if (tl == NULL)
847 continue; 848 continue;
848 849
849 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.");
851 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);
852 return; 853 return;
853 } 854 }
854 855
855 if (!tr->item) 856 if (!tr->item)
856 {
857 LOG (llevError, "BUG: empty entry in %s's treasure list\n", &god->name);
858 continue; 857 continue;
859 } 858
860 item = &tr->item->clone; 859 item = &tr->item->clone;
861 860
862 /* Grace limit */ 861 /* Grace limit */
863 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)
864 { 863 {
963 continue; 962 continue;
964 963
965 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!");
966 965
967 for (i = 0; i < NUM_STATS; i++) 966 for (i = 0; i < NUM_STATS; i++)
968 if (get_attr_value (&depl->stats, i)) 967 if (depl->stats.stat (i))
969 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); 968 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]);
970 969
971 depl->destroy (); 970 depl->destroy ();
972 fix_player (op); 971 op->update_stats ();
973 return; 972 return;
974 } 973 }
975 974
976 /* Voices */ 975 /* Voices */
977 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)
1150/** 1149/**
1151 * 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.
1152 * 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
1153 * the spell attacktype contains AT_HOLYWORD. -b.t. 1152 * the spell attacktype contains AT_HOLYWORD. -b.t.
1154 */ 1153 */
1155
1156int 1154int
1157tailor_god_spell (object *spellop, object *caster) 1155tailor_god_spell (object *spellop, object *caster)
1158{ 1156{
1159 object *god = find_god (determine_god (caster)); 1157 object *god = find_god (determine_god (caster));
1160 int caster_is_spell = 0; 1158 int caster_is_spell = 0;
1164 1162
1165 /* if caster is a rune or the like, it doesn't worship anything. However, 1163 /* if caster is a rune or the like, it doesn't worship anything. However,
1166 * if this object is owned by someone, then the god that they worship 1164 * if this object is owned by someone, then the god that they worship
1167 * is relevant, so use that. 1165 * is relevant, so use that.
1168 */ 1166 */
1169 if (!god && get_owner (caster)) 1167 if (!god && caster->owner)
1170 god = find_god (determine_god (get_owner (caster))); 1168 god = find_god (determine_god (caster->owner));
1171 1169
1172 if (!god || (spellop->attacktype & AT_HOLYWORD && !god->race)) 1170 if (!god || (spellop->attacktype & AT_HOLYWORD && !god->race))
1173 { 1171 {
1174 if (!caster_is_spell) 1172 if (!caster_is_spell)
1175 new_draw_info (NDI_UNIQUE, 0, caster, "This prayer is useless unless you worship an appropriate god"); 1173 new_draw_info (NDI_UNIQUE, 0, caster, "This prayer is useless unless you worship an appropriate god");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines