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.7 by root, Thu Sep 14 21:16:12 2006 UTC vs.
Revision 1.18 by pippijn, Mon Jan 15 21:06:20 2007 UTC

1
2/* 1/*
3 * static char *rcsid_gods_c =
4 * "$Id: gods.C,v 1.7 2006/09/14 21:16:12 root Exp $";
5 */
6
7/*
8 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game for X-windows
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;
408 item = &tr->item->clone; 406 item = &tr->item->clone;
409 407
410 /* Basically, see if the matching spell is granted by this god. */ 408 /* Basically, see if the matching spell is granted by this god. */
411 409
420 /* just do the work of removing the spell ourselves - we already 418 /* just do the work of removing the spell ourselves - we already
421 * know that the player knows the spell 419 * know that the player knows the spell
422 */ 420 */
423 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &tmp->name); 421 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); 422 player_unready_range_ob (op->contr, tmp);
425 remove_ob (tmp); 423 tmp->destroy ();
426 free_object (tmp);
427 } 424 }
428 425
429 } 426 }
430} 427}
431 428
448 445
449 /* take away any special god-characteristic items. */ 446 /* take away any special god-characteristic items. */
450 for (item = op->inv; item != NULL; item = next) 447 for (item = op->inv; item != NULL; item = next)
451 { 448 {
452 next = item->below; 449 next = item->below;
453 /* remove all invisible startequip items which are 450 // 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 && 451 if (QUERY_FLAG (item, FLAG_STARTEQUIP) && item->invisible &&
457 (item->type != SKILL) && (item->type != EXPERIENCE) && (item->type != FORCE)) 452 (item->type != SKILL) && (item->type != FORCE))
458 { 453 {
459 454
460 if (item->type == SPELL) 455 if (item->type == SPELL)
461 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &item->name); 456 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &item->name);
457
462 player_unready_range_ob (op->contr, item); 458 player_unready_range_ob (op->contr, item);
463 remove_ob (item); 459 item->destroy ();
464 free_object (item);
465 } 460 }
466 } 461 }
467 462
468 /* remove any godgiven items from the old god */ 463 /* remove any godgiven items from the old god */
469 if (old_god) 464 if (old_god)
692 { 687 {
693 object *item; 688 object *item;
694 689
695 if (!tr->item) 690 if (!tr->item)
696 continue; 691 continue;
692
697 item = &tr->item->clone; 693 item = &tr->item->clone;
698 694
699 if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) 695 if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0)
700 return item->other_arch; 696 return item->other_arch;
701 } 697 }
857 create_treasure (tl, op, GT_STARTEQUIP | GT_ONLY_GOOD | GT_UPDATE_INV, skill->level, 0); 853 create_treasure (tl, op, GT_STARTEQUIP | GT_ONLY_GOOD | GT_UPDATE_INV, skill->level, 0);
858 return; 854 return;
859 } 855 }
860 856
861 if (!tr->item) 857 if (!tr->item)
862 {
863 LOG (llevError, "BUG: empty entry in %s's treasure list\n", &god->name);
864 continue; 858 continue;
865 } 859
866 item = &tr->item->clone; 860 item = &tr->item->clone;
867 861
868 /* Grace limit */ 862 /* Grace limit */
869 if (item->type == BOOK && item->invisible && strcmp (item->name, "grace limit") == 0) 863 if (item->type == BOOK && item->invisible && strcmp (item->name, "grace limit") == 0)
870 { 864 {
875 /* Follower lacks the required grace for the following 869 /* Follower lacks the required grace for the following
876 * treasure list items. */ 870 * treasure list items. */
877 871
878 tmp = get_archetype (HOLY_POSSESSION); 872 tmp = get_archetype (HOLY_POSSESSION);
879 cast_change_ability (op, op, tmp, 0, 1); 873 cast_change_ability (op, op, tmp, 0, 1);
880 free_object (tmp); 874 tmp->destroy ();
881 return; 875 return;
882 } 876 }
883 continue; 877 continue;
884 } 878 }
885 879
924 int success; 918 int success;
925 919
926 tmp = get_archetype_by_object_name (item->slaying); 920 tmp = get_archetype_by_object_name (item->slaying);
927 921
928 success = cast_heal (op, op, tmp, 0); 922 success = cast_heal (op, op, tmp, 0);
929 free_object (tmp); 923 tmp->destroy ();
930 if (success) 924 if (success)
931 return; 925 return;
932 else 926 else
933 continue; 927 continue;
934 } 928 }
962 { 956 {
963 LOG (llevError, "Could not find archetype depletion.\n"); 957 LOG (llevError, "Could not find archetype depletion.\n");
964 continue; 958 continue;
965 } 959 }
966 depl = present_arch_in_ob (at, op); 960 depl = present_arch_in_ob (at, op);
961
967 if (depl == NULL) 962 if (depl == NULL)
968 continue; 963 continue;
964
969 new_draw_info (NDI_UNIQUE, 0, op, "Shimmering light surrounds and restores you!"); 965 new_draw_info (NDI_UNIQUE, 0, op, "Shimmering light surrounds and restores you!");
966
970 for (i = 0; i < NUM_STATS; i++) 967 for (i = 0; i < NUM_STATS; i++)
971 if (get_attr_value (&depl->stats, i)) 968 if (get_attr_value (&depl->stats, i))
972 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); 969 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]);
973 remove_ob (depl); 970
974 free_object (depl); 971 depl->destroy ();
975 fix_player (op); 972 op->update_stats ();
976 return; 973 return;
977 } 974 }
978 975
979 /* Voices */ 976 /* Voices */
980 if (item->type == BOOK && item->invisible && strcmp (item->name, "voice_behind") == 0) 977 if (item->type == BOOK && item->invisible && strcmp (item->name, "voice_behind") == 0)
1153/** 1150/**
1154 * Changes the attributes of cone, smite, and ball spells as needed by the code. 1151 * 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 1152 * 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. 1153 * the spell attacktype contains AT_HOLYWORD. -b.t.
1157 */ 1154 */
1158
1159int 1155int
1160tailor_god_spell (object *spellop, object *caster) 1156tailor_god_spell (object *spellop, object *caster)
1161{ 1157{
1162 object *god = find_god (determine_god (caster)); 1158 object *god = find_god (determine_god (caster));
1163 int caster_is_spell = 0; 1159 int caster_is_spell = 0;
1167 1163
1168 /* if caster is a rune or the like, it doesn't worship anything. However, 1164 /* 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 1165 * if this object is owned by someone, then the god that they worship
1170 * is relevant, so use that. 1166 * is relevant, so use that.
1171 */ 1167 */
1172 if (!god && get_owner (caster)) 1168 if (!god && caster->owner)
1173 god = find_god (determine_god (get_owner (caster))); 1169 god = find_god (determine_god (caster->owner));
1174 1170
1175 if (!god || (spellop->attacktype & AT_HOLYWORD && !god->race)) 1171 if (!god || (spellop->attacktype & AT_HOLYWORD && !god->race))
1176 { 1172 {
1177 if (!caster_is_spell) 1173 if (!caster_is_spell)
1178 new_draw_info (NDI_UNIQUE, 0, caster, "This prayer is useless unless you worship an appropriate god"); 1174 new_draw_info (NDI_UNIQUE, 0, caster, "This prayer is useless unless you worship an appropriate god");
1179 else 1175 else
1180 LOG (llevError, "BUG: tailor_god_spell(): no god\n"); 1176 LOG (llevError, "BUG: tailor_god_spell(): no god\n");
1181 free_object (spellop); 1177
1178 spellop->destroy ();
1182 return 0; 1179 return 0;
1183 } 1180 }
1184 1181
1185 /* either holy word or godpower attacks will set the slaying field */ 1182 /* either holy word or godpower attacks will set the slaying field */
1186 if (spellop->attacktype & AT_HOLYWORD || spellop->attacktype & AT_GODPOWER) 1183 if (spellop->attacktype & AT_HOLYWORD || spellop->attacktype & AT_GODPOWER)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines