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.18 by pippijn, Mon Jan 15 21:06:20 2007 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 (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * 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
9 * 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
10 * the Free Software Foundation; either version 2 of the License, or 10 * Software Foundation; either version 2 of the License, or (at your option)
11 * (at your option) any later version. 11 * any later version.
12 * 12 *
13 * 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
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * GNU General Public License for more details. 16 * for more details.
17 * 17 *
18 * 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
19 * 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
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * 21 *
22 * 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>
23 */ 23 */
24
25 24
26/* 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
27 * monster race initialization. b.t. 26 * monster race initialization. b.t.
28 */ 27 */
29 28
50 godlink *gl; 49 godlink *gl;
51 50
52 for (gl = first_god; gl; gl = gl->next) 51 for (gl = first_god; gl; gl = gl->next)
53 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)))
54 break; 53 break;
54
55 if (gl) 55 if (gl)
56 godnr = gl->id; 56 godnr = gl->id;
57 } 57 }
58
58 return godnr; 59 return godnr;
59} 60}
60 61
61/** 62/**
62 * 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..
124 godnr = rndm (1, gl->id); 125 godnr = rndm (1, gl->id);
125 while (gl) 126 while (gl)
126 { 127 {
127 if (gl->id == godnr) 128 if (gl->id == godnr)
128 break; 129 break;
130
129 gl = gl->next; 131 gl = gl->next;
130 } 132 }
133
131 op->title = gl->name; 134 op->title = gl->name;
132 } 135 }
133 136
134 return op->title; 137 return op->title;
135 } 138 }
171 return 0; 174 return 0;
172 else 175 else
173 return strcmp (s1, s2) == 0; 176 return strcmp (s1, s2) == 0;
174} 177}
175 178
176
177/** 179/**
178 * 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).
179 * Any matching items in the inventory are deleted, and a 181 * Any matching items in the inventory are deleted, and a
180 * message is displayed to the player. 182 * message is displayed to the player.
181 */ 183 */
243 object *tmp; 245 object *tmp;
244 246
245 if (!tr->item) 247 if (!tr->item)
246 return 0; 248 return 0;
247 249
248 if (follower_has_similar_item (op, &tr->item->clone)) 250 if (follower_has_similar_item (op, tr->item))
249 return 0; 251 return 0;
250 252
251 tmp = arch_to_object (tr->item); 253 tmp = arch_to_object (tr->item);
252 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));
253 tmp = insert_ob_in_ob (tmp, op); 255 tmp = insert_ob_in_ob (tmp, op);
274 return; 276 return;
275 277
276 /* hmm. what happend depends on pl's current god, level, etc */ 278 /* hmm. what happend depends on pl's current god, level, etc */
277 if (!pl_god) 279 if (!pl_god)
278 { /*new convert */ 280 { /*new convert */
279 become_follower (pl, &altar->other_arch->clone); 281 become_follower (pl, altar->other_arch);
280 return; 282 return;
281 283
282 } 284 }
283 else if (!strcmp (&pl_god->name, altar->other_arch->clone.name)) 285 else if (!strcmp (&pl_god->name, altar->other_arch->object::name))
284 { 286 {
285 /* pray at your gods altar */ 287 /* pray at your gods altar */
286 int bonus = (pl->stats.Wis + skill->level) / 10; 288 int bonus = (pl->stats.Wis + skill->level) / 10;
287 289
288 /* we can get neg grace up faster */ 290 /* we can get neg grace up faster */
317 * points to the god of this altar (which we have 319 * points to the god of this altar (which we have
318 * already verified is non null). pl_god->other_arch 320 * already verified is non null). pl_god->other_arch
319 * is the opposing god - we need to verify that exists before 321 * is the opposing god - we need to verify that exists before
320 * using its values. 322 * using its values.
321 */ 323 */
322 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))
323 { 325 {
324 angry = 2; 326 angry = 2;
325 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)
326 { 328 {
327 object *tmp; 329 object *tmp;
348 350
349 /* 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
350 * note it gets harder to swap gods the higher we get 352 * note it gets harder to swap gods the higher we get
351 */ 353 */
352 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) 354 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW)))
353 {
354 become_follower (pl, &altar->other_arch->clone); 355 become_follower (pl, altar->other_arch);
355 }
356 else 356 else
357 { 357 {
358 /* toss this player off the altar. He can try again. */ 358 /* toss this player off the altar. He can try again. */
359 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;
360 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. */
361 } 363 }
362 } 364 }
363} 365}
364 366
401 { 403 {
402 object *item; 404 object *item;
403 405
404 if (!tr->item) 406 if (!tr->item)
405 continue; 407 continue;
408
406 item = &tr->item->clone; 409 item = tr->item;
407 410
408 /* Basically, see if the matching spell is granted by this god. */ 411 /* Basically, see if the matching spell is granted by this god. */
409 412
410 if (tr->item->clone.type == SPELL && tr->item->clone.name == tmp->name) 413 if (tr->item->type == SPELL && tr->item->object::name == tmp->name)
411 { 414 {
412 remove = 0; 415 remove = 0;
413 break; 416 break;
414 } 417 }
415 } 418 }
460 } 463 }
461 } 464 }
462 465
463 /* remove any godgiven items from the old god */ 466 /* remove any godgiven items from the old god */
464 if (old_god) 467 if (old_god)
465 {
466 for (tr = old_god->randomitems->items; tr != NULL; tr = tr->next) 468 for (tr = old_god->randomitems->items; tr; tr = tr->next)
467 {
468 if (tr->item && QUERY_FLAG (&tr->item->clone, FLAG_STARTEQUIP)) 469 if (tr->item && QUERY_FLAG (tr->item, FLAG_STARTEQUIP))
469 follower_remove_similar_item (op, &tr->item->clone); 470 follower_remove_similar_item (op, tr->item);
470 }
471 }
472 471
473 if (!op || !new_god) 472 if (!op || !new_god)
474 return; 473 return;
475 474
476 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))
477 { 476 {
478 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
479 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)
480 { 480 {
481 object *tmp = get_archetype (LOOSE_MANA); 481 object *tmp = get_archetype (LOOSE_MANA);
482 482
483 cast_magic_storm (op, tmp, new_god->level + 10); 483 cast_magic_storm (op, tmp, new_god->level + 10);
484 } 484 }
485
485 return; 486 return;
486 } 487 }
487 488
488 489
489 /* give the player any special god-characteristic-items. */ 490 /* give the player any special god-characteristic-items. */
490 for (tr = new_god->randomitems->items; tr != NULL; tr = tr->next) 491 for (tr = new_god->randomitems->items; tr; tr = tr->next)
491 { 492 {
492 if (tr->item && tr->item->clone.invisible && tr->item->clone.type != SPELLBOOK && 493 if (tr->item && tr->item->invisible && tr->item->type != SPELLBOOK
493 tr->item->clone.type != BOOK && tr->item->clone.type != SPELL) 494 && tr->item->type != BOOK && tr->item->type != SPELL)
494 god_gives_present (op, new_god, tr); 495 god_gives_present (op, new_god, tr);
495 } 496 }
496 497
497 498
498 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);
505 if (!skop) 506 if (!skop)
506 { 507 {
507 /* 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,
508 * things are really messed up anyways. 509 * things are really messed up anyways.
509 */ 510 */
510 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);
511 link_player_skills (op); 512 link_player_skills (op);
512 } 513 }
513 514
514 sk_applied = QUERY_FLAG (skop, FLAG_APPLIED); /* save skill status */ 515 sk_applied = QUERY_FLAG (skop, FLAG_APPLIED); /* save skill status */
515 516
610 611
611int 612int
612worship_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)
613{ 614{
614 615
615 if (QUERY_FLAG (&op->arch->clone, flag)) 616 if (QUERY_FLAG (op->arch, flag))
616 if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag)) 617 if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag))
617 { 618 {
618 update_priest_flag (exp_obj, op, flag); 619 update_priest_flag (exp_obj, op, flag);
619 if (QUERY_FLAG (op, flag)) 620 if (QUERY_FLAG (op, flag))
620 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);
681 { 682 {
682 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");
683 return NULL; 684 return NULL;
684 } 685 }
685 686
686 for (tr = god->randomitems->items; tr != NULL; tr = tr->next) 687 for (tr = god->randomitems->items; tr; tr = tr->next)
687 { 688 {
688 object *item;
689
690 if (!tr->item) 689 if (!tr->item)
691 continue; 690 continue;
692 691
693 item = &tr->item->clone; 692 object *item = tr->item;
694 693
695 if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) 694 if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0)
696 return item->other_arch; 695 return item->other_arch;
697 } 696 }
698 return NULL; 697 return NULL;
740 739
741 if (level <= 20) 740 if (level <= 20)
742 return level / difficulty; 741 return level / difficulty;
743 if (level <= 40) 742 if (level <= 40)
744 return (20 + (level - 20) / 2) / difficulty; 743 return (20 + (level - 20) / 2) / difficulty;
744
745 return (30 + (level - 40) / 4) / difficulty; 745 return (30 + (level - 40) / 4) / difficulty;
746} 746}
747 747
748/** 748/**
749 * God wants to enchant weapon. 749 * God wants to enchant weapon.
760 int tmp; 760 int tmp;
761 761
762 for (weapon = op->inv; weapon; weapon = weapon->below) 762 for (weapon = op->inv; weapon; weapon = weapon->below)
763 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))
764 break; 764 break;
765
765 if (weapon == NULL || god_examines_item (god, weapon) <= 0) 766 if (weapon == NULL || god_examines_item (god, weapon) <= 0)
766 return 0; 767 return 0;
767 768
768 /* 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 */
769 if (!weapon->title) 770 if (!weapon->title)
831 if (god_examines_priest (op, god) < 0) 832 if (god_examines_priest (op, god) < 0)
832 return; 833 return;
833 834
834 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!");
835 836
836 for (tr = god->randomitems->items; tr != NULL; tr = tr->next) 837 for (tr = god->randomitems->items; tr; tr = tr->next)
837 { 838 {
838 object *item; 839 object *item;
839 840
840 if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH)) 841 if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH))
841 continue; 842 continue;
842 843
843 /* Treasurelist - generate some treasure for the follower */ 844 /* Treasurelist - generate some treasure for the follower */
844 if (tr->name) 845 if (tr->name)
845 { 846 {
846 treasurelist *tl = find_treasurelist (tr->name); 847 treasurelist *tl = treasurelist::find (tr->name);
847 848
848 if (tl == NULL) 849 if (tl == NULL)
849 continue; 850 continue;
850 851
851 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.");
855 } 856 }
856 857
857 if (!tr->item) 858 if (!tr->item)
858 continue; 859 continue;
859 860
860 item = &tr->item->clone; 861 item = tr->item;
861 862
862 /* Grace limit */ 863 /* Grace limit */
863 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)
864 { 865 {
865 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)
963 continue; 964 continue;
964 965
965 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!");
966 967
967 for (i = 0; i < NUM_STATS; i++) 968 for (i = 0; i < NUM_STATS; i++)
968 if (get_attr_value (&depl->stats, i)) 969 if (depl->stats.stat (i))
969 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); 970 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]);
970 971
971 depl->destroy (); 972 depl->destroy ();
972 op->update_stats (); 973 op->update_stats ();
973 return; 974 return;
1135 1136
1136 if (race == NULL) 1137 if (race == NULL)
1137 return NULL; 1138 return NULL;
1138 while (gl) 1139 while (gl)
1139 { 1140 {
1140 if (!strcasecmp (gl->arch->clone.race, race)) 1141 if (!strcasecmp (gl->arch->race, race))
1141 { 1142 {
1142 godname = gl->name; 1143 godname = gl->name;
1143 break; 1144 break;
1144 } 1145 }
1145 gl = gl->next; 1146 gl = gl->next;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines