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.26 by root, Mon Jun 4 13:04:00 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
243 object *tmp; 242 object *tmp;
244 243
245 if (!tr->item) 244 if (!tr->item)
246 return 0; 245 return 0;
247 246
248 if (follower_has_similar_item (op, &tr->item->clone)) 247 if (follower_has_similar_item (op, tr->item))
249 return 0; 248 return 0;
250 249
251 tmp = arch_to_object (tr->item); 250 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)); 251 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); 252 tmp = insert_ob_in_ob (tmp, op);
274 return; 273 return;
275 274
276 /* hmm. what happend depends on pl's current god, level, etc */ 275 /* hmm. what happend depends on pl's current god, level, etc */
277 if (!pl_god) 276 if (!pl_god)
278 { /*new convert */ 277 { /*new convert */
279 become_follower (pl, &altar->other_arch->clone); 278 become_follower (pl, altar->other_arch);
280 return; 279 return;
281 280
282 } 281 }
283 else if (!strcmp (&pl_god->name, altar->other_arch->clone.name)) 282 else if (!strcmp (&pl_god->name, altar->other_arch->object::name))
284 { 283 {
285 /* pray at your gods altar */ 284 /* pray at your gods altar */
286 int bonus = (pl->stats.Wis + skill->level) / 10; 285 int bonus = (pl->stats.Wis + skill->level) / 10;
287 286
288 /* we can get neg grace up faster */ 287 /* we can get neg grace up faster */
317 * points to the god of this altar (which we have 316 * points to the god of this altar (which we have
318 * already verified is non null). pl_god->other_arch 317 * already verified is non null). pl_god->other_arch
319 * is the opposing god - we need to verify that exists before 318 * is the opposing god - we need to verify that exists before
320 * using its values. 319 * using its values.
321 */ 320 */
322 if (pl_god->other_arch && (altar->other_arch->name == pl_god->other_arch->name)) 321 if (pl_god->other_arch && (altar->other_arch->archname == pl_god->other_arch->archname))
323 { 322 {
324 angry = 2; 323 angry = 2;
325 if (random_roll (0, skill->level + 2, pl, PREFER_LOW) - 5 > 0) 324 if (random_roll (0, skill->level + 2, pl, PREFER_LOW) - 5 > 0)
326 { 325 {
327 object *tmp; 326 object *tmp;
348 347
349 /* May switch Gods, but its random chance based on our current level 348 /* May switch Gods, but its random chance based on our current level
350 * note it gets harder to swap gods the higher we get 349 * note it gets harder to swap gods the higher we get
351 */ 350 */
352 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) 351 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW)))
353 {
354 become_follower (pl, &altar->other_arch->clone); 352 become_follower (pl, altar->other_arch);
355 }
356 else 353 else
357 { 354 {
358 /* toss this player off the altar. He can try again. */ 355 /* 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."); 356 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar.");
357 pl->contr->fire_on = 0;
358 pl->speed_left = 1.f;
360 move_player (pl, absdir (pl->facing + 4)); /* back him off the way he came. */ 359 move_player (pl, absdir (pl->facing + 4)); /* back him off the way he came. */
361 } 360 }
362 } 361 }
363} 362}
364 363
401 { 400 {
402 object *item; 401 object *item;
403 402
404 if (!tr->item) 403 if (!tr->item)
405 continue; 404 continue;
405
406 item = &tr->item->clone; 406 item = tr->item;
407 407
408 /* Basically, see if the matching spell is granted by this god. */ 408 /* Basically, see if the matching spell is granted by this god. */
409 409
410 if (tr->item->clone.type == SPELL && tr->item->clone.name == tmp->name) 410 if (tr->item->type == SPELL && tr->item->object::name == tmp->name)
411 { 411 {
412 remove = 0; 412 remove = 0;
413 break; 413 break;
414 } 414 }
415 } 415 }
460 } 460 }
461 } 461 }
462 462
463 /* remove any godgiven items from the old god */ 463 /* remove any godgiven items from the old god */
464 if (old_god) 464 if (old_god)
465 {
466 for (tr = old_god->randomitems->items; tr != NULL; tr = tr->next) 465 for (tr = old_god->randomitems->items; tr; tr = tr->next)
467 {
468 if (tr->item && QUERY_FLAG (&tr->item->clone, FLAG_STARTEQUIP)) 466 if (tr->item && QUERY_FLAG (tr->item, FLAG_STARTEQUIP))
469 follower_remove_similar_item (op, &tr->item->clone); 467 follower_remove_similar_item (op, tr->item);
470 }
471 }
472 468
473 if (!op || !new_god) 469 if (!op || !new_god)
474 return; 470 return;
475 471
476 if (op->race && new_god->slaying && strstr (op->race, new_god->slaying)) 472 if (op->race && new_god->slaying && strstr (op->race, new_god->slaying))
477 { 473 {
478 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name); 474 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name);
475
479 if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0) 476 if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0)
480 { 477 {
481 object *tmp = get_archetype (LOOSE_MANA); 478 object *tmp = get_archetype (LOOSE_MANA);
482 479
483 cast_magic_storm (op, tmp, new_god->level + 10); 480 cast_magic_storm (op, tmp, new_god->level + 10);
484 } 481 }
482
485 return; 483 return;
486 } 484 }
487 485
488 486
489 /* give the player any special god-characteristic-items. */ 487 /* give the player any special god-characteristic-items. */
490 for (tr = new_god->randomitems->items; tr != NULL; tr = tr->next) 488 for (tr = new_god->randomitems->items; tr; tr = tr->next)
491 { 489 {
492 if (tr->item && tr->item->clone.invisible && tr->item->clone.type != SPELLBOOK && 490 if (tr->item && tr->item->invisible && tr->item->type != SPELLBOOK
493 tr->item->clone.type != BOOK && tr->item->clone.type != SPELL) 491 && tr->item->type != BOOK && tr->item->type != SPELL)
494 god_gives_present (op, new_god, tr); 492 god_gives_present (op, new_god, tr);
495 } 493 }
496 494
497 495
498 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You become a follower of %s!", &new_god->name); 496 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You become a follower of %s!", &new_god->name);
505 if (!skop) 503 if (!skop)
506 { 504 {
507 /* The arhetype should always be defined - if we crash here because it doesn't, 505 /* The arhetype should always be defined - if we crash here because it doesn't,
508 * things are really messed up anyways. 506 * things are really messed up anyways.
509 */ 507 */
510 skop = give_skill_by_name (op, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->clone.skill); 508 skop = give_skill_by_name (op, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->skill);
511 link_player_skills (op); 509 link_player_skills (op);
512 } 510 }
513 511
514 sk_applied = QUERY_FLAG (skop, FLAG_APPLIED); /* save skill status */ 512 sk_applied = QUERY_FLAG (skop, FLAG_APPLIED); /* save skill status */
515 513
610 608
611int 609int
612worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string) 610worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string)
613{ 611{
614 612
615 if (QUERY_FLAG (&op->arch->clone, flag)) 613 if (QUERY_FLAG (op->arch, flag))
616 if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag)) 614 if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag))
617 { 615 {
618 update_priest_flag (exp_obj, op, flag); 616 update_priest_flag (exp_obj, op, flag);
619 if (QUERY_FLAG (op, flag)) 617 if (QUERY_FLAG (op, flag))
620 new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string); 618 new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string);
681 { 679 {
682 LOG (llevError, "BUG: determine_holy_arch(): no god or god without " "randomitems\n"); 680 LOG (llevError, "BUG: determine_holy_arch(): no god or god without " "randomitems\n");
683 return NULL; 681 return NULL;
684 } 682 }
685 683
686 for (tr = god->randomitems->items; tr != NULL; tr = tr->next) 684 for (tr = god->randomitems->items; tr; tr = tr->next)
687 { 685 {
688 object *item;
689
690 if (!tr->item) 686 if (!tr->item)
691 continue; 687 continue;
692 688
693 item = &tr->item->clone; 689 object *item = tr->item;
694 690
695 if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) 691 if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0)
696 return item->other_arch; 692 return item->other_arch;
697 } 693 }
698 return NULL; 694 return NULL;
740 736
741 if (level <= 20) 737 if (level <= 20)
742 return level / difficulty; 738 return level / difficulty;
743 if (level <= 40) 739 if (level <= 40)
744 return (20 + (level - 20) / 2) / difficulty; 740 return (20 + (level - 20) / 2) / difficulty;
741
745 return (30 + (level - 40) / 4) / difficulty; 742 return (30 + (level - 40) / 4) / difficulty;
746} 743}
747 744
748/** 745/**
749 * God wants to enchant weapon. 746 * God wants to enchant weapon.
760 int tmp; 757 int tmp;
761 758
762 for (weapon = op->inv; weapon; weapon = weapon->below) 759 for (weapon = op->inv; weapon; weapon = weapon->below)
763 if ((weapon->type == WEAPON || weapon->type == BOW) && QUERY_FLAG (weapon, FLAG_APPLIED)) 760 if ((weapon->type == WEAPON || weapon->type == BOW) && QUERY_FLAG (weapon, FLAG_APPLIED))
764 break; 761 break;
762
765 if (weapon == NULL || god_examines_item (god, weapon) <= 0) 763 if (weapon == NULL || god_examines_item (god, weapon) <= 0)
766 return 0; 764 return 0;
767 765
768 /* First give it a title, so other gods won't touch it */ 766 /* First give it a title, so other gods won't touch it */
769 if (!weapon->title) 767 if (!weapon->title)
831 if (god_examines_priest (op, god) < 0) 829 if (god_examines_priest (op, god) < 0)
832 return; 830 return;
833 831
834 new_draw_info (NDI_UNIQUE, 0, op, "You feel a holy presence!"); 832 new_draw_info (NDI_UNIQUE, 0, op, "You feel a holy presence!");
835 833
836 for (tr = god->randomitems->items; tr != NULL; tr = tr->next) 834 for (tr = god->randomitems->items; tr; tr = tr->next)
837 { 835 {
838 object *item; 836 object *item;
839 837
840 if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH)) 838 if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH))
841 continue; 839 continue;
842 840
843 /* Treasurelist - generate some treasure for the follower */ 841 /* Treasurelist - generate some treasure for the follower */
844 if (tr->name) 842 if (tr->name)
845 { 843 {
846 treasurelist *tl = find_treasurelist (tr->name); 844 treasurelist *tl = treasurelist::find (tr->name);
847 845
848 if (tl == NULL) 846 if (tl == NULL)
849 continue; 847 continue;
850 848
851 new_draw_info (NDI_UNIQUE, 0, op, "Something appears before your " "eyes. You catch it before it falls to the ground."); 849 new_draw_info (NDI_UNIQUE, 0, op, "Something appears before your " "eyes. You catch it before it falls to the ground.");
855 } 853 }
856 854
857 if (!tr->item) 855 if (!tr->item)
858 continue; 856 continue;
859 857
860 item = &tr->item->clone; 858 item = tr->item;
861 859
862 /* Grace limit */ 860 /* Grace limit */
863 if (item->type == BOOK && item->invisible && strcmp (item->name, "grace limit") == 0) 861 if (item->type == BOOK && item->invisible && strcmp (item->name, "grace limit") == 0)
864 { 862 {
865 if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace) 863 if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace)
963 continue; 961 continue;
964 962
965 new_draw_info (NDI_UNIQUE, 0, op, "Shimmering light surrounds and restores you!"); 963 new_draw_info (NDI_UNIQUE, 0, op, "Shimmering light surrounds and restores you!");
966 964
967 for (i = 0; i < NUM_STATS; i++) 965 for (i = 0; i < NUM_STATS; i++)
968 if (get_attr_value (&depl->stats, i)) 966 if (depl->stats.stat (i))
969 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); 967 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]);
970 968
971 depl->destroy (); 969 depl->destroy ();
972 op->update_stats (); 970 op->update_stats ();
973 return; 971 return;
1135 1133
1136 if (race == NULL) 1134 if (race == NULL)
1137 return NULL; 1135 return NULL;
1138 while (gl) 1136 while (gl)
1139 { 1137 {
1140 if (!strcasecmp (gl->arch->clone.race, race)) 1138 if (!strcasecmp (gl->arch->race, race))
1141 { 1139 {
1142 godname = gl->name; 1140 godname = gl->name;
1143 break; 1141 break;
1144 } 1142 }
1145 gl = gl->next; 1143 gl = gl->next;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines