… | |
… | |
36 | |
36 | |
37 | /** |
37 | /** |
38 | * Returns the id of specified god. |
38 | * Returns the id of specified god. |
39 | */ |
39 | */ |
40 | int |
40 | int |
41 | lookup_god_by_name (const char *name) |
41 | lookup_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 | */ |
56 | object * |
54 | object * |
57 | find_god (const char *name) |
55 | find_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 | */ |
|
|
70 | static shstr_tmp |
|
|
71 | get_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. |
… | |
… | |
606 | CLEAR_FLAG (exp_ob, flag); |
620 | CLEAR_FLAG (exp_ob, flag); |
607 | }; |
621 | }; |
608 | } |
622 | } |
609 | |
623 | |
610 | archetype * |
624 | archetype * |
611 | determine_holy_arch (object *god, const char *type) |
625 | determine_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 | |
… | |
… | |
1056 | |
1071 | |
1057 | int |
1072 | int |
1058 | get_god (object *priest) |
1073 | get_god (object *priest) |
1059 | { |
1074 | { |
1060 | return lookup_god_by_name (determine_god (priest)); |
1075 | 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 | */ |
|
|
1068 | shstr_tmp |
|
|
1069 | get_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 | } |
1076 | } |
1078 | |
1077 | |
1079 | /** |
1078 | /** |
1080 | * Changes the attributes of cone, smite, and ball spells as needed by the code. |
1079 | * 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 |
1080 | * Returns false if there was no race to assign to the slaying field of the spell, but |