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.42 by root, Wed Dec 31 18:07:41 2008 UTC vs.
Revision 1.45 by root, Thu Jan 1 16:05:13 2009 UTC

36 36
37/** 37/**
38 * Returns the id of specified god. 38 * Returns the id of specified god.
39 */ 39 */
40int 40int
41lookup_god_by_name (const char *name) 41lookup_god_by_name (shstr_cmp name)
42{ 42{
43 shstr_cmp sname (name);
44
45 if (sname) 43 if (name)
46 for (godlink *gl = first_god; gl; gl = gl->next) 44 for (godlink *gl = first_god; gl; gl = gl->next)
47 if (gl->name == name) 45 if (gl->name == name)
48 return gl->id; 46 return gl->id;
49 47
50 return -1; 48 return -1;
52 50
53/** 51/**
54 * Returns pointer to specified god's object through pntr_to_god_obj.. 52 * Returns pointer to specified god's object through pntr_to_god_obj..
55 */ 53 */
56object * 54object *
57find_god (const char *name) 55find_god (shstr_cmp name)
58{ 56{
59 if (name) 57 if (name)
60 for (godlink *gl = first_god; gl; gl = gl->next) 58 for (godlink *gl = first_god; gl; gl = gl->next)
61 if (!strcmp (name, gl->name)) 59 if (gl->name == name)
62 return pntr_to_god_obj (gl); 60 return pntr_to_god_obj (gl);
63 61
64 return 0; 62 return 0;
63}
64
65/**
66 * Returns a string that is the name of the god that should be natively worshipped by a
67 * creature of who has race *race
68 * if we can't find a god that is appropriate, we return NULL
69 */
70static shstr_tmp
71get_god_for_race (shstr_cmp race)
72{
73 if (race)
74 for (godlink *gl = first_god; gl; gl = gl->next)
75 if (gl->arch->race == race)
76 return gl->name;
77
78 return shstr_tmp ();
65} 79}
66 80
67/** 81/**
68 * Determines if op worships a god. 82 * Determines if op worships a god.
69 * Returns the godname if they do or "none" if they have no god. 83 * Returns the godname if they do or "none" if they have no god.
409 follower_remove_similar_item (op, tr->item); 423 follower_remove_similar_item (op, tr->item);
410 424
411 if (!op || !new_god) 425 if (!op || !new_god)
412 return; 426 return;
413 427
414 if (op->race && new_god->slaying && strstr (op->race, new_god->slaying)) 428 if (op->race && new_god->slaying && op->race.contains (new_god->slaying))
415 { 429 {
416 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name); 430 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name);
417 431
418 if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0) 432 if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0)
419 { 433 {
606 CLEAR_FLAG (exp_ob, flag); 620 CLEAR_FLAG (exp_ob, flag);
607 }; 621 };
608} 622}
609 623
610archetype * 624archetype *
611determine_holy_arch (object *god, const char *type) 625determine_holy_arch (object *god, shstr_cmp type)
612{ 626{
613 treasure *tr; 627 treasure *tr;
614 628
615 if (!god || !god->randomitems) 629 if (!god || !god->randomitems)
616 { 630 {
623 if (!tr->item) 637 if (!tr->item)
624 continue; 638 continue;
625 639
626 object *item = tr->item; 640 object *item = tr->item;
627 641
628 if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) 642 if (item->type == BOOK && item->invisible && item->name == type)
629 return item->other_arch; 643 return item->other_arch;
630 } 644 }
631 645
632 return 0; 646 return 0;
633} 647}
799 continue; 813 continue;
800 814
801 item = tr->item; 815 item = tr->item;
802 816
803 /* Grace limit */ 817 /* Grace limit */
804 if (item->type == BOOK && item->invisible && strcmp (item->name, "grace limit") == 0) 818 if (item->type == BOOK && item->invisible && item->name == shstr_grace_limit)
805 { 819 {
806 if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace) 820 if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace)
807 { 821 {
808 object *tmp;
809
810 /* Follower lacks the required grace for the following 822 /* Follower lacks the required grace for the following
811 * treasure list items. */ 823 * treasure list items. */
812 824
813 tmp = get_archetype (HOLY_POSSESSION); 825 object *tmp = get_archetype (HOLY_POSSESSION);
814 cast_change_ability (op, op, tmp, 0, 1); 826 cast_change_ability (op, op, tmp, 0, 1);
815 tmp->destroy (); 827 tmp->destroy ();
816 return; 828 return;
817 } 829 }
818 830
819 continue; 831 continue;
820 } 832 }
821 833
822 /* Restore grace */ 834 /* Restore grace */
823 if (item->type == BOOK && item->invisible && strcmp (item->name, "restore grace") == 0) 835 if (item->type == BOOK && item->invisible && item->name == shstr_restore_grace)
824 { 836 {
825 if (op->stats.grace >= 0) 837 if (op->stats.grace >= 0)
826 continue; 838 continue;
839
827 op->stats.grace = random_roll (0, 9, op, PREFER_HIGH); 840 op->stats.grace = random_roll (0, 9, op, PREFER_HIGH);
828 new_draw_info (NDI_UNIQUE, 0, op, "You are returned to a state of grace."); 841 new_draw_info (NDI_UNIQUE, 0, op, "You are returned to a state of grace.");
829 return; 842 return;
830 } 843 }
831 844
832 /* Heal damage */ 845 /* Heal damage */
833 if (item->type == BOOK && item->invisible && strcmp (item->name, "restore hitpoints") == 0) 846 if (item->type == BOOK && item->invisible && strcmp (item->name, "restore hitpoints") == 0)
834 { 847 {
835 if (op->stats.hp >= op->stats.maxhp) 848 if (op->stats.hp >= op->stats.maxhp)
836 continue; 849 continue;
850
837 new_draw_info (NDI_UNIQUE, 0, op, "A white light surrounds and heals you!"); 851 new_draw_info (NDI_UNIQUE, 0, op, "A white light surrounds and heals you!");
838 op->stats.hp = op->stats.maxhp; 852 op->stats.hp = op->stats.maxhp;
839 return; 853 return;
840 } 854 }
841 855
895 if ((at = archetype::find (ARCH_DEPLETION)) == NULL) 909 if ((at = archetype::find (ARCH_DEPLETION)) == NULL)
896 { 910 {
897 LOG (llevError, "Could not find archetype depletion.\n"); 911 LOG (llevError, "Could not find archetype depletion.\n");
898 continue; 912 continue;
899 } 913 }
914
900 depl = present_arch_in_ob (at, op); 915 depl = present_arch_in_ob (at, op);
901 916
902 if (depl == NULL) 917 if (depl == NULL)
903 continue; 918 continue;
904 919
1012 * God checks item the player is using. 1027 * God checks item the player is using.
1013 * Return either -1 (bad), 0 (neutral) or 1028 * Return either -1 (bad), 0 (neutral) or
1014 * 1 (item is ok). If you are using the item of an enemy 1029 * 1 (item is ok). If you are using the item of an enemy
1015 * god, it can be bad...-b.t. 1030 * god, it can be bad...-b.t.
1016 */ 1031 */
1017
1018int 1032int
1019god_examines_item (object *god, object *item) 1033god_examines_item (object *god, object *item)
1020{ 1034{
1021 char buf[MAX_BUF]; 1035 char buf[MAX_BUF];
1022 1036
1025 1039
1026 if (!item->title) 1040 if (!item->title)
1027 return 1; /* unclaimed item are ok */ 1041 return 1; /* unclaimed item are ok */
1028 1042
1029 sprintf (buf, "of %s", &god->name); 1043 sprintf (buf, "of %s", &god->name);
1030 if (!strcmp (item->title, buf)) 1044 if (!strcmp (&item->title, buf))
1031 return 1; /* belongs to that God */ 1045 return 1; /* belongs to that God */
1032 1046
1033 if (god->title) 1047 if (god->title)
1034 { /* check if we have any enemy blessed item */ 1048 { /* check if we have any enemy blessed item */
1035 sprintf (buf, "of %s", &god->title); 1049 sprintf (buf, "of %s", &god->title);
1036 if (!strcmp (item->title, buf)) 1050 if (!strcmp (&item->title, buf))
1037 { 1051 {
1038 if (item->env) 1052 if (item->env)
1039 { 1053 {
1040 char buf[MAX_BUF]; 1054 char buf[MAX_BUF];
1041 1055
1042 sprintf (buf, "Heretic! You are using %s!", query_name (item)); 1056 sprintf (buf, "Heretic! You are using %s!", query_name (item));
1043 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, item->env, buf); 1057 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, item->env, buf);
1044 } 1058 }
1059
1045 return -1; 1060 return -1;
1046 } 1061 }
1047 } 1062 }
1048 1063
1049 return 0; /* item is sacred to a non-enemy god/or is otherwise magical */ 1064 return 0; /* item is sacred to a non-enemy god/or is otherwise magical */
1051 1066
1052/** 1067/**
1053 * Returns priest's god's id. 1068 * Returns priest's god's id.
1054 * Straight calls lookup_god_by_name 1069 * Straight calls lookup_god_by_name
1055 */ 1070 */
1056
1057int 1071int
1058get_god (object *priest) 1072get_god (object *priest)
1059{ 1073{
1060 return lookup_god_by_name (determine_god (priest)); 1074 return lookup_god_by_name (determine_god (priest));
1061}
1062
1063/**
1064 * Returns a string that is the name of the god that should be natively worshipped by a
1065 * creature of who has race *race
1066 * if we can't find a god that is appropriate, we return NULL
1067 */
1068shstr_tmp
1069get_god_for_race (const char *race)
1070{
1071 if (race)
1072 for (godlink *gl = first_god; gl; gl = gl->next)
1073 if (!strcasecmp (gl->arch->race, race))
1074 return gl->name;
1075
1076 return shstr_tmp ();
1077} 1075}
1078 1076
1079/** 1077/**
1080 * Changes the attributes of cone, smite, and ball spells as needed by the code. 1078 * Changes the attributes of cone, smite, and ball spells as needed by the code.
1081 * Returns false if there was no race to assign to the slaying field of the spell, but 1079 * Returns false if there was no race to assign to the slaying field of the spell, but

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines