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.27 by root, Tue Jun 5 13:05:02 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
3 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
6 7 *
7 This program is free software; you can redistribute it and/or modify 8 * Crossfire TRT is free software; you can redistribute it and/or modify it
8 it under the terms of the GNU General Public License as published by 9 * under the terms of the GNU General Public License as published by the Free
9 the Free Software Foundation; either version 2 of the License, or 10 * Software Foundation; either version 2 of the License, or (at your option)
10 (at your option) any later version. 11 * 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, but
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 GNU General Public License for more details. 16 * 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 along
18 along with this program; if not, write to the Free Software 19 * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 to <crossfire@schmorp.de>
22*/ 23 */
23
24 24
25/* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and 25/* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and
26 * monster race initialization. b.t. 26 * monster race initialization. b.t.
27 */ 27 */
28 28
31#include <global.h> 31#include <global.h>
32#include <living.h> 32#include <living.h>
33#include <object.h> 33#include <object.h>
34#include <spells.h> 34#include <spells.h>
35#include <sounds.h> 35#include <sounds.h>
36#ifndef __CEXTRACT__
37# include <sproto.h> 36#include <sproto.h>
38#endif
39 37
40/** 38/**
41 * Returns the id of specified god. 39 * Returns the id of specified god.
42 */ 40 */
43int 41int
51 godlink *gl; 49 godlink *gl;
52 50
53 for (gl = first_god; gl; gl = gl->next) 51 for (gl = first_god; gl; gl = gl->next)
54 if (!strncmp (name, gl->name, MIN ((size_t) strlen (gl->name), nmlen))) 52 if (!strncmp (name, gl->name, MIN ((size_t) strlen (gl->name), nmlen)))
55 break; 53 break;
54
56 if (gl) 55 if (gl)
57 godnr = gl->id; 56 godnr = gl->id;
58 } 57 }
58
59 return godnr; 59 return godnr;
60} 60}
61 61
62/** 62/**
63 * Returns pointer to specified god's object through pntr_to_god_obj.. 63 * Returns pointer to specified god's object through pntr_to_god_obj..
125 godnr = rndm (1, gl->id); 125 godnr = rndm (1, gl->id);
126 while (gl) 126 while (gl)
127 { 127 {
128 if (gl->id == godnr) 128 if (gl->id == godnr)
129 break; 129 break;
130
130 gl = gl->next; 131 gl = gl->next;
131 } 132 }
133
132 op->title = gl->name; 134 op->title = gl->name;
133 } 135 }
134 136
135 return op->title; 137 return op->title;
136 } 138 }
172 return 0; 174 return 0;
173 else 175 else
174 return strcmp (s1, s2) == 0; 176 return strcmp (s1, s2) == 0;
175} 177}
176 178
177
178/** 179/**
179 * Checks for any occurrence of the given 'item' in the inventory of 'op' (recursively). 180 * Checks for any occurrence of the given 'item' in the inventory of 'op' (recursively).
180 * Any matching items in the inventory are deleted, and a 181 * Any matching items in the inventory are deleted, and a
181 * message is displayed to the player. 182 * message is displayed to the player.
182 */ 183 */
241static int 242static int
242god_gives_present (object *op, object *god, treasure *tr) 243god_gives_present (object *op, object *god, treasure *tr)
243{ 244{
244 object *tmp; 245 object *tmp;
245 246
247 if (!tr->item)
248 return 0;
249
246 if (follower_has_similar_item (op, &tr->item->clone)) 250 if (follower_has_similar_item (op, tr->item))
247 return 0; 251 return 0;
248 252
249 tmp = arch_to_object (tr->item); 253 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)); 254 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); 255 tmp = insert_ob_in_ob (tmp, op);
252 if (op->type == PLAYER) 256 if (op->type == PLAYER)
253 esrv_send_item (op, tmp); 257 esrv_send_item (op, tmp);
258
254 return 1; 259 return 1;
255} 260}
256 261
257/** 262/**
258 * Player prays at altar. 263 * Player prays at altar.
271 return; 276 return;
272 277
273 /* hmm. what happend depends on pl's current god, level, etc */ 278 /* hmm. what happend depends on pl's current god, level, etc */
274 if (!pl_god) 279 if (!pl_god)
275 { /*new convert */ 280 { /*new convert */
276 become_follower (pl, &altar->other_arch->clone); 281 become_follower (pl, altar->other_arch);
277 return; 282 return;
278 283
279 } 284 }
280 else if (!strcmp (&pl_god->name, altar->other_arch->clone.name)) 285 else if (!strcmp (&pl_god->name, altar->other_arch->object::name))
281 { 286 {
282 /* pray at your gods altar */ 287 /* pray at your gods altar */
283 int bonus = (pl->stats.Wis + skill->level) / 10; 288 int bonus = (pl->stats.Wis + skill->level) / 10;
284 289
285 /* we can get neg grace up faster */ 290 /* we can get neg grace up faster */
314 * points to the god of this altar (which we have 319 * points to the god of this altar (which we have
315 * already verified is non null). pl_god->other_arch 320 * already verified is non null). pl_god->other_arch
316 * is the opposing god - we need to verify that exists before 321 * is the opposing god - we need to verify that exists before
317 * using its values. 322 * using its values.
318 */ 323 */
319 if (pl_god->other_arch && (altar->other_arch->name == pl_god->other_arch->name)) 324 if (pl_god->other_arch && (altar->other_arch->archname == pl_god->other_arch->archname))
320 { 325 {
321 angry = 2; 326 angry = 2;
322 if (random_roll (0, skill->level + 2, pl, PREFER_LOW) - 5 > 0) 327 if (random_roll (0, skill->level + 2, pl, PREFER_LOW) - 5 > 0)
323 { 328 {
324 object *tmp; 329 object *tmp;
345 350
346 /* May switch Gods, but its random chance based on our current level 351 /* May switch Gods, but its random chance based on our current level
347 * note it gets harder to swap gods the higher we get 352 * note it gets harder to swap gods the higher we get
348 */ 353 */
349 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) 354 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW)))
350 {
351 become_follower (pl, &altar->other_arch->clone); 355 become_follower (pl, altar->other_arch);
352 }
353 else 356 else
354 { 357 {
355 /* toss this player off the altar. He can try again. */ 358 /* toss this player off the altar. He can try again. */
356 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar."); 359 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar.");
360 pl->contr->fire_on = 0;
361 pl->speed_left = 1.f;
357 move_player (pl, absdir (pl->facing + 4)); /* back him off the way he came. */ 362 move_player (pl, absdir (pl->facing + 4)); /* back him off the way he came. */
358 } 363 }
359 } 364 }
360} 365}
361 366
396 remove = 1; 401 remove = 1;
397 for (tr = god->randomitems->items; tr; tr = tr->next) 402 for (tr = god->randomitems->items; tr; tr = tr->next)
398 { 403 {
399 object *item; 404 object *item;
400 405
401 if (tr->item == NULL) 406 if (!tr->item)
402 continue; 407 continue;
408
403 item = &tr->item->clone; 409 item = tr->item;
404 410
405 /* Basically, see if the matching spell is granted by this god. */ 411 /* Basically, see if the matching spell is granted by this god. */
406 412
407 if (tr->item->clone.type == SPELL && tr->item->clone.name == tmp->name) 413 if (tr->item->type == SPELL && tr->item->object::name == tmp->name)
408 { 414 {
409 remove = 0; 415 remove = 0;
410 break; 416 break;
411 } 417 }
412 } 418 }
457 } 463 }
458 } 464 }
459 465
460 /* remove any godgiven items from the old god */ 466 /* remove any godgiven items from the old god */
461 if (old_god) 467 if (old_god)
462 {
463 for (tr = old_god->randomitems->items; tr != NULL; tr = tr->next) 468 for (tr = old_god->randomitems->items; tr; tr = tr->next)
464 {
465 if (tr->item && QUERY_FLAG (&tr->item->clone, FLAG_STARTEQUIP)) 469 if (tr->item && QUERY_FLAG (tr->item, FLAG_STARTEQUIP))
466 follower_remove_similar_item (op, &tr->item->clone); 470 follower_remove_similar_item (op, tr->item);
467 }
468 }
469 471
470 if (!op || !new_god) 472 if (!op || !new_god)
471 return; 473 return;
472 474
473 if (op->race && new_god->slaying && strstr (op->race, new_god->slaying)) 475 if (op->race && new_god->slaying && strstr (op->race, new_god->slaying))
474 { 476 {
475 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name); 477 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name);
478
476 if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0) 479 if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0)
477 { 480 {
478 object *tmp = get_archetype (LOOSE_MANA); 481 object *tmp = get_archetype (LOOSE_MANA);
479 482
480 cast_magic_storm (op, tmp, new_god->level + 10); 483 cast_magic_storm (op, tmp, new_god->level + 10);
481 } 484 }
485
482 return; 486 return;
483 } 487 }
484 488
485 489
486 /* give the player any special god-characteristic-items. */ 490 /* give the player any special god-characteristic-items. */
487 for (tr = new_god->randomitems->items; tr != NULL; tr = tr->next) 491 for (tr = new_god->randomitems->items; tr; tr = tr->next)
488 { 492 {
489 if (tr->item && tr->item->clone.invisible && tr->item->clone.type != SPELLBOOK && 493 if (tr->item && tr->item->invisible && tr->item->type != SPELLBOOK
490 tr->item->clone.type != BOOK && tr->item->clone.type != SPELL) 494 && tr->item->type != BOOK && tr->item->type != SPELL)
491 god_gives_present (op, new_god, tr); 495 god_gives_present (op, new_god, tr);
492 } 496 }
493 497
494 498
495 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You become a follower of %s!", &new_god->name); 499 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You become a follower of %s!", &new_god->name);
502 if (!skop) 506 if (!skop)
503 { 507 {
504 /* The arhetype should always be defined - if we crash here because it doesn't, 508 /* The arhetype should always be defined - if we crash here because it doesn't,
505 * things are really messed up anyways. 509 * things are really messed up anyways.
506 */ 510 */
507 skop = give_skill_by_name (op, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->clone.skill); 511 skop = give_skill_by_name (op, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->skill);
508 link_player_skills (op); 512 link_player_skills (op);
509 } 513 }
510 514
511 sk_applied = QUERY_FLAG (skop, FLAG_APPLIED); /* save skill status */ 515 sk_applied = QUERY_FLAG (skop, FLAG_APPLIED); /* save skill status */
512 516
607 611
608int 612int
609worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string) 613worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string)
610{ 614{
611 615
612 if (QUERY_FLAG (&op->arch->clone, flag)) 616 if (QUERY_FLAG (op->arch, flag))
613 if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag)) 617 if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag))
614 { 618 {
615 update_priest_flag (exp_obj, op, flag); 619 update_priest_flag (exp_obj, op, flag);
616 if (QUERY_FLAG (op, flag)) 620 if (QUERY_FLAG (op, flag))
617 new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string); 621 new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string);
678 { 682 {
679 LOG (llevError, "BUG: determine_holy_arch(): no god or god without " "randomitems\n"); 683 LOG (llevError, "BUG: determine_holy_arch(): no god or god without " "randomitems\n");
680 return NULL; 684 return NULL;
681 } 685 }
682 686
683 for (tr = god->randomitems->items; tr != NULL; tr = tr->next) 687 for (tr = god->randomitems->items; tr; tr = tr->next)
684 { 688 {
685 object *item;
686
687 if (!tr->item) 689 if (!tr->item)
688 continue; 690 continue;
689 item = &tr->item->clone; 691
692 object *item = tr->item;
690 693
691 if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) 694 if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0)
692 return item->other_arch; 695 return item->other_arch;
693 } 696 }
694 return NULL; 697 return NULL;
736 739
737 if (level <= 20) 740 if (level <= 20)
738 return level / difficulty; 741 return level / difficulty;
739 if (level <= 40) 742 if (level <= 40)
740 return (20 + (level - 20) / 2) / difficulty; 743 return (20 + (level - 20) / 2) / difficulty;
744
741 return (30 + (level - 40) / 4) / difficulty; 745 return (30 + (level - 40) / 4) / difficulty;
742} 746}
743 747
744/** 748/**
745 * God wants to enchant weapon. 749 * God wants to enchant weapon.
756 int tmp; 760 int tmp;
757 761
758 for (weapon = op->inv; weapon; weapon = weapon->below) 762 for (weapon = op->inv; weapon; weapon = weapon->below)
759 if ((weapon->type == WEAPON || weapon->type == BOW) && QUERY_FLAG (weapon, FLAG_APPLIED)) 763 if ((weapon->type == WEAPON || weapon->type == BOW) && QUERY_FLAG (weapon, FLAG_APPLIED))
760 break; 764 break;
765
761 if (weapon == NULL || god_examines_item (god, weapon) <= 0) 766 if (weapon == NULL || god_examines_item (god, weapon) <= 0)
762 return 0; 767 return 0;
763 768
764 /* First give it a title, so other gods won't touch it */ 769 /* First give it a title, so other gods won't touch it */
765 if (!weapon->title) 770 if (!weapon->title)
827 if (god_examines_priest (op, god) < 0) 832 if (god_examines_priest (op, god) < 0)
828 return; 833 return;
829 834
830 new_draw_info (NDI_UNIQUE, 0, op, "You feel a holy presence!"); 835 new_draw_info (NDI_UNIQUE, 0, op, "You feel a holy presence!");
831 836
832 for (tr = god->randomitems->items; tr != NULL; tr = tr->next) 837 for (tr = god->randomitems->items; tr; tr = tr->next)
833 { 838 {
834 object *item; 839 object *item;
835 840
836 if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH)) 841 if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH))
837 continue; 842 continue;
838 843
839 /* Treasurelist - generate some treasure for the follower */ 844 /* Treasurelist - generate some treasure for the follower */
840 if (tr->name) 845 if (tr->name)
841 { 846 {
842 treasurelist *tl = find_treasurelist (tr->name); 847 treasurelist *tl = treasurelist::find (tr->name);
843 848
844 if (tl == NULL) 849 if (tl == NULL)
845 continue; 850 continue;
846 851
847 new_draw_info (NDI_UNIQUE, 0, op, "Something appears before your " "eyes. You catch it before it falls to the ground."); 852 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); 854 create_treasure (tl, op, GT_STARTEQUIP | GT_ONLY_GOOD | GT_UPDATE_INV, skill->level, 0);
850 return; 855 return;
851 } 856 }
852 857
853 if (!tr->item) 858 if (!tr->item)
854 {
855 LOG (llevError, "BUG: empty entry in %s's treasure list\n", &god->name);
856 continue; 859 continue;
857 } 860
858 item = &tr->item->clone; 861 item = tr->item;
859 862
860 /* Grace limit */ 863 /* Grace limit */
861 if (item->type == BOOK && item->invisible && strcmp (item->name, "grace limit") == 0) 864 if (item->type == BOOK && item->invisible && strcmp (item->name, "grace limit") == 0)
862 { 865 {
863 if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace) 866 if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace)
961 continue; 964 continue;
962 965
963 new_draw_info (NDI_UNIQUE, 0, op, "Shimmering light surrounds and restores you!"); 966 new_draw_info (NDI_UNIQUE, 0, op, "Shimmering light surrounds and restores you!");
964 967
965 for (i = 0; i < NUM_STATS; i++) 968 for (i = 0; i < NUM_STATS; i++)
966 if (get_attr_value (&depl->stats, i)) 969 if (depl->stats.stat (i))
967 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); 970 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]);
968 971
969 depl->destroy (); 972 depl->destroy ();
970 fix_player (op); 973 op->update_stats ();
971 return; 974 return;
972 } 975 }
973 976
974 /* Voices */ 977 /* Voices */
975 if (item->type == BOOK && item->invisible && strcmp (item->name, "voice_behind") == 0) 978 if (item->type == BOOK && item->invisible && strcmp (item->name, "voice_behind") == 0)
1133 1136
1134 if (race == NULL) 1137 if (race == NULL)
1135 return NULL; 1138 return NULL;
1136 while (gl) 1139 while (gl)
1137 { 1140 {
1138 if (!strcasecmp (gl->arch->clone.race, race)) 1141 if (!strcasecmp (gl->arch->race, race))
1139 { 1142 {
1140 godname = gl->name; 1143 godname = gl->name;
1141 break; 1144 break;
1142 } 1145 }
1143 gl = gl->next; 1146 gl = gl->next;
1148/** 1151/**
1149 * Changes the attributes of cone, smite, and ball spells as needed by the code. 1152 * 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 1153 * 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. 1154 * the spell attacktype contains AT_HOLYWORD. -b.t.
1152 */ 1155 */
1153
1154int 1156int
1155tailor_god_spell (object *spellop, object *caster) 1157tailor_god_spell (object *spellop, object *caster)
1156{ 1158{
1157 object *god = find_god (determine_god (caster)); 1159 object *god = find_god (determine_god (caster));
1158 int caster_is_spell = 0; 1160 int caster_is_spell = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines