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.6 by root, Sun Sep 10 15:59:57 2006 UTC vs.
Revision 1.21 by root, Sat May 12 18:14:48 2007 UTC

1
2/* 1/*
3 * static char *rcsid_gods_c =
4 * "$Id: gods.C,v 1.6 2006/09/10 15:59:57 root Exp $";
5 */
6
7/*
8 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game
9 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
10 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team
11 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
12 7 *
13 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
14 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
15 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version. 11 * (at your option) any later version.
17 12 *
18 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,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details. 16 * GNU General Public License for more details.
22 17 *
23 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
24 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 21 *
27 The authors can be reached via e-mail at crossfire-devel@real-time.com 22 * The authors can be reached via e-mail at <crossfire@schmorp.de>
28*/ 23 */
29 24
30 25
31/* 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
32 * monster race initialization. b.t. 27 * monster race initialization. b.t.
33 */ 28 */
37#include <global.h> 32#include <global.h>
38#include <living.h> 33#include <living.h>
39#include <object.h> 34#include <object.h>
40#include <spells.h> 35#include <spells.h>
41#include <sounds.h> 36#include <sounds.h>
42#ifndef __CEXTRACT__
43# include <sproto.h> 37#include <sproto.h>
44#endif
45 38
46/** 39/**
47 * Returns the id of specified god. 40 * Returns the id of specified god.
48 */ 41 */
49int 42int
207 if (tmp->nrof > 1) 200 if (tmp->nrof > 1)
208 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s crumble to dust!", query_short_name (tmp)); 201 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s crumble to dust!", query_short_name (tmp));
209 else 202 else
210 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s crumbles to dust!", query_short_name (tmp)); 203 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s crumbles to dust!", query_short_name (tmp));
211 204
212 remove_ob (tmp); /* remove obj from players inv. */ 205 tmp->remove (); /* remove obj from players inv. */
213 esrv_del_item (op->contr, tmp->count); /* notify client */ 206 esrv_del_item (op->contr, tmp->count); /* notify client */
214 free_object (tmp); /* free object */ 207 tmp->destroy (); /* free object */
215 } 208 }
209
216 if (tmp->inv) 210 if (tmp->inv)
217 follower_remove_similar_item (tmp, item); 211 follower_remove_similar_item (tmp, item);
218 } 212 }
219 } 213 }
220} 214}
246static int 240static int
247god_gives_present (object *op, object *god, treasure *tr) 241god_gives_present (object *op, object *god, treasure *tr)
248{ 242{
249 object *tmp; 243 object *tmp;
250 244
245 if (!tr->item)
246 return 0;
247
251 if (follower_has_similar_item (op, &tr->item->clone)) 248 if (follower_has_similar_item (op, &tr->item->clone))
252 return 0; 249 return 0;
253 250
254 tmp = arch_to_object (tr->item); 251 tmp = arch_to_object (tr->item);
255 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));
256 tmp = insert_ob_in_ob (tmp, op); 253 tmp = insert_ob_in_ob (tmp, op);
257 if (op->type == PLAYER) 254 if (op->type == PLAYER)
258 esrv_send_item (op, tmp); 255 esrv_send_item (op, tmp);
256
259 return 1; 257 return 1;
260} 258}
261 259
262/** 260/**
263 * Player prays at altar. 261 * Player prays at altar.
401 remove = 1; 399 remove = 1;
402 for (tr = god->randomitems->items; tr; tr = tr->next) 400 for (tr = god->randomitems->items; tr; tr = tr->next)
403 { 401 {
404 object *item; 402 object *item;
405 403
406 if (tr->item == NULL) 404 if (!tr->item)
407 continue; 405 continue;
406
408 item = &tr->item->clone; 407 item = &tr->item->clone;
409 408
410 /* Basically, see if the matching spell is granted by this god. */ 409 /* Basically, see if the matching spell is granted by this god. */
411 410
412 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)
420 /* just do the work of removing the spell ourselves - we already 419 /* just do the work of removing the spell ourselves - we already
421 * know that the player knows the spell 420 * know that the player knows the spell
422 */ 421 */
423 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &tmp->name); 422 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &tmp->name);
424 player_unready_range_ob (op->contr, tmp); 423 player_unready_range_ob (op->contr, tmp);
425 remove_ob (tmp); 424 tmp->destroy ();
426 free_object (tmp);
427 } 425 }
428 426
429 } 427 }
430} 428}
431 429
448 446
449 /* take away any special god-characteristic items. */ 447 /* take away any special god-characteristic items. */
450 for (item = op->inv; item != NULL; item = next) 448 for (item = op->inv; item != NULL; item = next)
451 { 449 {
452 next = item->below; 450 next = item->below;
453 /* remove all invisible startequip items which are 451 // remove all invisible startequip items which are not skill, exp or force
454 * not skill, exp or force
455 */
456 if (QUERY_FLAG (item, FLAG_STARTEQUIP) && item->invisible && 452 if (QUERY_FLAG (item, FLAG_STARTEQUIP) && item->invisible &&
457 (item->type != SKILL) && (item->type != EXPERIENCE) && (item->type != FORCE)) 453 (item->type != SKILL) && (item->type != FORCE))
458 { 454 {
459 455
460 if (item->type == SPELL) 456 if (item->type == SPELL)
461 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);
458
462 player_unready_range_ob (op->contr, item); 459 player_unready_range_ob (op->contr, item);
463 remove_ob (item); 460 item->destroy ();
464 free_object (item);
465 } 461 }
466 } 462 }
467 463
468 /* remove any godgiven items from the old god */ 464 /* remove any godgiven items from the old god */
469 if (old_god) 465 if (old_god)
470 {
471 for (tr = old_god->randomitems->items; tr != NULL; tr = tr->next) 466 for (tr = old_god->randomitems->items; tr; tr = tr->next)
472 {
473 if (tr->item && QUERY_FLAG (&tr->item->clone, FLAG_STARTEQUIP)) 467 if (tr->item && QUERY_FLAG (&tr->item->clone, FLAG_STARTEQUIP))
474 follower_remove_similar_item (op, &tr->item->clone); 468 follower_remove_similar_item (op, &tr->item->clone);
475 }
476 }
477 469
478 if (!op || !new_god) 470 if (!op || !new_god)
479 return; 471 return;
480 472
481 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))
482 { 474 {
483 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
484 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)
485 { 478 {
486 object *tmp = get_archetype (LOOSE_MANA); 479 object *tmp = get_archetype (LOOSE_MANA);
487 480
488 cast_magic_storm (op, tmp, new_god->level + 10); 481 cast_magic_storm (op, tmp, new_god->level + 10);
489 } 482 }
483
490 return; 484 return;
491 } 485 }
492 486
493 487
494 /* give the player any special god-characteristic-items. */ 488 /* give the player any special god-characteristic-items. */
495 for (tr = new_god->randomitems->items; tr != NULL; tr = tr->next) 489 for (tr = new_god->randomitems->items; tr; tr = tr->next)
496 { 490 {
497 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
498 tr->item->clone.type != BOOK && tr->item->clone.type != SPELL) 492 && tr->item->clone.type != BOOK && tr->item->clone.type != SPELL)
499 god_gives_present (op, new_god, tr); 493 god_gives_present (op, new_god, tr);
500 } 494 }
501 495
502 496
503 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);
686 { 680 {
687 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");
688 return NULL; 682 return NULL;
689 } 683 }
690 684
691 for (tr = god->randomitems->items; tr != NULL; tr = tr->next) 685 for (tr = god->randomitems->items; tr; tr = tr->next)
692 { 686 {
693 object *item;
694
695 if (!tr->item) 687 if (!tr->item)
696 continue; 688 continue;
689
697 item = &tr->item->clone; 690 object *item = &tr->item->clone;
698 691
699 if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) 692 if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0)
700 return item->other_arch; 693 return item->other_arch;
701 } 694 }
702 return NULL; 695 return NULL;
744 737
745 if (level <= 20) 738 if (level <= 20)
746 return level / difficulty; 739 return level / difficulty;
747 if (level <= 40) 740 if (level <= 40)
748 return (20 + (level - 20) / 2) / difficulty; 741 return (20 + (level - 20) / 2) / difficulty;
742
749 return (30 + (level - 40) / 4) / difficulty; 743 return (30 + (level - 40) / 4) / difficulty;
750} 744}
751 745
752/** 746/**
753 * God wants to enchant weapon. 747 * God wants to enchant weapon.
764 int tmp; 758 int tmp;
765 759
766 for (weapon = op->inv; weapon; weapon = weapon->below) 760 for (weapon = op->inv; weapon; weapon = weapon->below)
767 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))
768 break; 762 break;
763
769 if (weapon == NULL || god_examines_item (god, weapon) <= 0) 764 if (weapon == NULL || god_examines_item (god, weapon) <= 0)
770 return 0; 765 return 0;
771 766
772 /* 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 */
773 if (!weapon->title) 768 if (!weapon->title)
835 if (god_examines_priest (op, god) < 0) 830 if (god_examines_priest (op, god) < 0)
836 return; 831 return;
837 832
838 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!");
839 834
840 for (tr = god->randomitems->items; tr != NULL; tr = tr->next) 835 for (tr = god->randomitems->items; tr; tr = tr->next)
841 { 836 {
842 object *item; 837 object *item;
843 838
844 if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH)) 839 if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH))
845 continue; 840 continue;
846 841
847 /* Treasurelist - generate some treasure for the follower */ 842 /* Treasurelist - generate some treasure for the follower */
848 if (tr->name) 843 if (tr->name)
849 { 844 {
850 treasurelist *tl = find_treasurelist (tr->name); 845 treasurelist *tl = treasurelist::find (tr->name);
851 846
852 if (tl == NULL) 847 if (tl == NULL)
853 continue; 848 continue;
854 849
855 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.");
857 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);
858 return; 853 return;
859 } 854 }
860 855
861 if (!tr->item) 856 if (!tr->item)
862 {
863 LOG (llevError, "BUG: empty entry in %s's treasure list\n", &god->name);
864 continue; 857 continue;
865 } 858
866 item = &tr->item->clone; 859 item = &tr->item->clone;
867 860
868 /* Grace limit */ 861 /* Grace limit */
869 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)
870 { 863 {
875 /* Follower lacks the required grace for the following 868 /* Follower lacks the required grace for the following
876 * treasure list items. */ 869 * treasure list items. */
877 870
878 tmp = get_archetype (HOLY_POSSESSION); 871 tmp = get_archetype (HOLY_POSSESSION);
879 cast_change_ability (op, op, tmp, 0, 1); 872 cast_change_ability (op, op, tmp, 0, 1);
880 free_object (tmp); 873 tmp->destroy ();
881 return; 874 return;
882 } 875 }
883 continue; 876 continue;
884 } 877 }
885 878
924 int success; 917 int success;
925 918
926 tmp = get_archetype_by_object_name (item->slaying); 919 tmp = get_archetype_by_object_name (item->slaying);
927 920
928 success = cast_heal (op, op, tmp, 0); 921 success = cast_heal (op, op, tmp, 0);
929 free_object (tmp); 922 tmp->destroy ();
930 if (success) 923 if (success)
931 return; 924 return;
932 else 925 else
933 continue; 926 continue;
934 } 927 }
956 { 949 {
957 object *depl; 950 object *depl;
958 archetype *at; 951 archetype *at;
959 int i; 952 int i;
960 953
961 if ((at = find_archetype (ARCH_DEPLETION)) == NULL) 954 if ((at = archetype::find (ARCH_DEPLETION)) == NULL)
962 { 955 {
963 LOG (llevError, "Could not find archetype depletion.\n"); 956 LOG (llevError, "Could not find archetype depletion.\n");
964 continue; 957 continue;
965 } 958 }
966 depl = present_arch_in_ob (at, op); 959 depl = present_arch_in_ob (at, op);
960
967 if (depl == NULL) 961 if (depl == NULL)
968 continue; 962 continue;
963
969 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!");
965
970 for (i = 0; i < NUM_STATS; i++) 966 for (i = 0; i < NUM_STATS; i++)
971 if (get_attr_value (&depl->stats, i)) 967 if (depl->stats.stat (i))
972 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); 968 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]);
973 remove_ob (depl); 969
974 free_object (depl); 970 depl->destroy ();
975 fix_player (op); 971 op->update_stats ();
976 return; 972 return;
977 } 973 }
978 974
979 /* Voices */ 975 /* Voices */
980 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)
1153/** 1149/**
1154 * 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.
1155 * 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
1156 * the spell attacktype contains AT_HOLYWORD. -b.t. 1152 * the spell attacktype contains AT_HOLYWORD. -b.t.
1157 */ 1153 */
1158
1159int 1154int
1160tailor_god_spell (object *spellop, object *caster) 1155tailor_god_spell (object *spellop, object *caster)
1161{ 1156{
1162 object *god = find_god (determine_god (caster)); 1157 object *god = find_god (determine_god (caster));
1163 int caster_is_spell = 0; 1158 int caster_is_spell = 0;
1167 1162
1168 /* 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,
1169 * 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
1170 * is relevant, so use that. 1165 * is relevant, so use that.
1171 */ 1166 */
1172 if (!god && get_owner (caster)) 1167 if (!god && caster->owner)
1173 god = find_god (determine_god (get_owner (caster))); 1168 god = find_god (determine_god (caster->owner));
1174 1169
1175 if (!god || (spellop->attacktype & AT_HOLYWORD && !god->race)) 1170 if (!god || (spellop->attacktype & AT_HOLYWORD && !god->race))
1176 { 1171 {
1177 if (!caster_is_spell) 1172 if (!caster_is_spell)
1178 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");
1179 else 1174 else
1180 LOG (llevError, "BUG: tailor_god_spell(): no god\n"); 1175 LOG (llevError, "BUG: tailor_god_spell(): no god\n");
1181 free_object (spellop); 1176
1177 spellop->destroy ();
1182 return 0; 1178 return 0;
1183 } 1179 }
1184 1180
1185 /* either holy word or godpower attacks will set the slaying field */ 1181 /* either holy word or godpower attacks will set the slaying field */
1186 if (spellop->attacktype & AT_HOLYWORD || spellop->attacktype & AT_GODPOWER) 1182 if (spellop->attacktype & AT_HOLYWORD || spellop->attacktype & AT_GODPOWER)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines