… | |
… | |
64 | int ncharges; |
64 | int ncharges; |
65 | |
65 | |
66 | wand = find_marked_object (op); |
66 | wand = find_marked_object (op); |
67 | if (!wand || wand->type != WAND) |
67 | if (!wand || wand->type != WAND) |
68 | { |
68 | { |
69 | new_draw_info (NDI_UNIQUE, 0, op, "You need to mark the wand you want to recharge."); |
69 | op->failmsg ("You need to mark the wand you want to recharge."); |
70 | return 0; |
70 | return 0; |
71 | } |
71 | } |
|
|
72 | |
72 | if (!(random_roll (0, 3, op, PREFER_HIGH))) |
73 | if (!(random_roll (0, 3, op, PREFER_HIGH))) |
73 | { |
74 | { |
74 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s vibrates violently, then explodes!", query_name (wand)); |
75 | op->failmsgf ("The %s vibrates violently, then explodes!", query_name (wand)); |
75 | op->play_sound (sound_find ("ob_explode")); |
76 | op->play_sound (sound_find ("ob_explode")); |
76 | wand->destroy (); |
77 | wand->destroy (); |
77 | tmp = get_archetype (shstr_fireball); |
78 | tmp = get_archetype (shstr_fireball); |
78 | tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; |
79 | tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; |
79 | |
80 | |
… | |
… | |
93 | |
94 | |
94 | if (wand->inv && wand->inv->level) |
95 | if (wand->inv && wand->inv->level) |
95 | ncharges /= wand->inv->level; |
96 | ncharges /= wand->inv->level; |
96 | else |
97 | else |
97 | { |
98 | { |
98 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", query_name (wand)); |
99 | op->failmsgf ("Your %s is broken.", query_name (wand)); |
99 | return 0; |
100 | return 0; |
100 | } |
101 | } |
101 | |
102 | |
102 | if (!ncharges) |
103 | if (!ncharges) |
103 | ncharges = 1; |
104 | ncharges = 1; |
… | |
… | |
158 | break; |
159 | break; |
159 | |
160 | |
160 | if (!al) |
161 | if (!al) |
161 | { |
162 | { |
162 | missile->destroy (); |
163 | missile->destroy (); |
163 | new_draw_info_format (NDI_UNIQUE, 0, op, "No such object %ss of %s", missile_name, spellparam); |
164 | op->failmsgf ("No such object %ss of %s", missile_name, spellparam); |
164 | return 0; |
165 | return 0; |
165 | } |
166 | } |
166 | |
167 | |
167 | if (al->item->slaying) |
168 | if (al->item->slaying) |
168 | { |
169 | { |
169 | missile->destroy (); |
170 | missile->destroy (); |
170 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are not allowed to create %ss of %s", missile_name, spellparam); |
171 | op->failmsgf ("You are not allowed to create %ss of %s", missile_name, spellparam); |
171 | return 0; |
172 | return 0; |
172 | } |
173 | } |
173 | |
174 | |
174 | give_artifact_abilities (missile, al->item); |
175 | give_artifact_abilities (missile, al->item); |
175 | /* These special arrows cost something extra. Don't have them also be magical - |
176 | /* These special arrows cost something extra. Don't have them also be magical - |
… | |
… | |
257 | /* Pretty unlikely (there are some very low food items), but you never |
258 | /* Pretty unlikely (there are some very low food items), but you never |
258 | * know |
259 | * know |
259 | */ |
260 | */ |
260 | if (!at) |
261 | if (!at) |
261 | { |
262 | { |
262 | new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough experience to create any food."); |
263 | op->failmsgf ("You don't have enough experience to create any food."); |
263 | return 0; |
264 | return 0; |
264 | } |
265 | } |
265 | |
266 | |
266 | food_value /= at->stats.food; |
267 | food_value /= at->stats.food; |
267 | new_op = at->instance (); |
268 | new_op = at->instance (); |
… | |
… | |
380 | int |
381 | int |
381 | cast_invisible (object *op, object *caster, object *spell_ob) |
382 | cast_invisible (object *op, object *caster, object *spell_ob) |
382 | { |
383 | { |
383 | if (op->invisible > 1000) |
384 | if (op->invisible > 1000) |
384 | { |
385 | { |
385 | new_draw_info (NDI_UNIQUE, 0, op, "You can not extend the duration of your invisibility any further"); |
386 | op->failmsg ("You can not extend the duration of your invisibility any further"); |
386 | return 0; |
387 | return 0; |
387 | } |
388 | } |
388 | |
389 | |
389 | /* Remove the switch with 90% duplicate code - just handle the differences with |
390 | /* Remove the switch with 90% duplicate code - just handle the differences with |
390 | * and if statement or two. |
391 | * and if statement or two. |
… | |
… | |
645 | |
646 | |
646 | if ((spell_ob->move_block || x != op->x || y != op->y) && |
647 | if ((spell_ob->move_block || x != op->x || y != op->y) && |
647 | (get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE) || |
648 | (get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE) || |
648 | ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) == spell_ob->move_block))) |
649 | ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) == spell_ob->move_block))) |
649 | { |
650 | { |
650 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
651 | op->failmsg ("Something is in the way."); |
651 | return 0; |
652 | return 0; |
652 | } |
653 | } |
653 | |
654 | |
654 | if (spell_ob->other_arch) |
655 | if (spell_ob->other_arch) |
655 | tmp = spell_ob->other_arch->instance (); |
656 | tmp = spell_ob->other_arch->instance (); |
… | |
… | |
805 | { |
806 | { |
806 | int count = atoi (spellparam); |
807 | int count = atoi (spellparam); |
807 | |
808 | |
808 | if (count > maxdist) |
809 | if (count > maxdist) |
809 | { |
810 | { |
810 | new_draw_info (NDI_UNIQUE, 0, op, "You can't dimension door that far!"); |
811 | op->failmsg ("You can't dimension door that far!"); |
811 | return 0; |
812 | return 0; |
812 | } |
813 | } |
813 | |
814 | |
814 | for (dist = 0; dist < count; dist++) |
815 | for (dist = 0; dist < count; dist++) |
815 | { |
816 | { |
… | |
… | |
876 | break; |
877 | break; |
877 | |
878 | |
878 | } |
879 | } |
879 | if (!dist) |
880 | if (!dist) |
880 | { |
881 | { |
881 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell failed!\n"); |
882 | op->failmsg ("Your spell failed!\n"); |
882 | return 0; |
883 | return 0; |
883 | } |
884 | } |
884 | } |
885 | } |
885 | |
886 | |
886 | /* Actually move the player now */ |
887 | /* Actually move the player now */ |
… | |
… | |
1062 | break; |
1063 | break; |
1063 | } |
1064 | } |
1064 | else if (spell_ob->race && spell_ob->race == tmp2->name) |
1065 | else if (spell_ob->race && spell_ob->race == tmp2->name) |
1065 | { |
1066 | { |
1066 | if (!silent) |
1067 | if (!silent) |
1067 | new_draw_info_format (NDI_UNIQUE, 0, op, |
|
|
1068 | "You can not cast %s while %s is in effect", |
1068 | op->failmsgf ("You can not cast %s while %s is in effect", |
1069 | &spell_ob->name, &tmp2->name_pl); |
1069 | &spell_ob->name, &tmp2->name_pl); |
1070 | |
1070 | |
1071 | return 0; |
1071 | return 0; |
1072 | } |
1072 | } |
1073 | } |
1073 | } |
1074 | } |
1074 | } |
… | |
… | |
1802 | if (plyr != op && plyr->flag [FLAG_ALIVE]) |
1802 | if (plyr != op && plyr->flag [FLAG_ALIVE]) |
1803 | break; |
1803 | break; |
1804 | |
1804 | |
1805 | if (!plyr) |
1805 | if (!plyr) |
1806 | { |
1806 | { |
1807 | new_draw_info (NDI_BLACK, 0, op, "There is no one there."); |
1807 | op->failmsg ("There is no one there."); |
1808 | return 0; |
1808 | return 0; |
1809 | } |
1809 | } |
1810 | /* give sp */ |
1810 | /* give sp */ |
1811 | if (spell->stats.dam > 0) |
1811 | if (spell->stats.dam > 0) |
1812 | { |
1812 | { |
… | |
… | |
1927 | |
1927 | |
1928 | object *tmp, *god = find_god (determine_god (op)); |
1928 | object *tmp, *god = find_god (determine_god (op)); |
1929 | |
1929 | |
1930 | if (!god) |
1930 | if (!god) |
1931 | { |
1931 | { |
1932 | new_draw_info (NDI_UNIQUE, 0, op, "You can't consecrate anything if you don't worship a god!"); |
1932 | op->failmsg ("You can't consecrate anything if you don't worship a god!"); |
1933 | return 0; |
1933 | return 0; |
1934 | } |
1934 | } |
1935 | |
1935 | |
1936 | for (tmp = op->below; tmp; tmp = tmp->below) |
1936 | for (tmp = op->below; tmp; tmp = tmp->below) |
1937 | { |
1937 | { |
… | |
… | |
1940 | if (tmp->type == HOLY_ALTAR) |
1940 | if (tmp->type == HOLY_ALTAR) |
1941 | { |
1941 | { |
1942 | |
1942 | |
1943 | if (tmp->level > casting_level (caster, spell)) |
1943 | if (tmp->level > casting_level (caster, spell)) |
1944 | { |
1944 | { |
1945 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are not powerful enough to reconsecrate the %s", &tmp->name); |
1945 | op->failmsgf ("You are not powerful enough to reconsecrate the %s", &tmp->name); |
1946 | return 0; |
1946 | return 0; |
1947 | } |
1947 | } |
1948 | else |
1948 | else |
1949 | { |
1949 | { |
1950 | /* If we got here, we are consecrating an altar */ |
1950 | /* If we got here, we are consecrating an altar */ |
… | |
… | |
1959 | new_draw_info_format (NDI_UNIQUE, 0, op, "You consecrated the altar to %s!", &god->name); |
1959 | new_draw_info_format (NDI_UNIQUE, 0, op, "You consecrated the altar to %s!", &god->name); |
1960 | return 1; |
1960 | return 1; |
1961 | } |
1961 | } |
1962 | } |
1962 | } |
1963 | } |
1963 | } |
1964 | new_draw_info (NDI_UNIQUE, 0, op, "You are not standing over an altar!"); |
1964 | |
|
|
1965 | op->failmsg ("You are not standing over an altar!"); |
1965 | return 0; |
1966 | return 0; |
1966 | } |
1967 | } |
1967 | |
1968 | |
1968 | /* animate_weapon - |
1969 | /* animate_weapon - |
1969 | * Generalization of staff_to_snake. Makes a golem out of the caster's weapon. |
1970 | * Generalization of staff_to_snake. Makes a golem out of the caster's weapon. |
… | |
… | |
2011 | |
2012 | |
2012 | /* if there's no place to put the golem, abort */ |
2013 | /* if there's no place to put the golem, abort */ |
2013 | if (dir < 0 || (get_map_flags (m, &m, x, y, &x, &y) & P_OUT_OF_MAP) |
2014 | if (dir < 0 || (get_map_flags (m, &m, x, y, &x, &y) & P_OUT_OF_MAP) |
2014 | || ((spell->other_arch->move_type & GET_MAP_MOVE_BLOCK (m, x, y)) == spell->other_arch->move_type)) |
2015 | || ((spell->other_arch->move_type & GET_MAP_MOVE_BLOCK (m, x, y)) == spell->other_arch->move_type)) |
2015 | { |
2016 | { |
2016 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
2017 | op->failmsg ("There is something in the way."); |
2017 | return 0; |
2018 | return 0; |
2018 | } |
2019 | } |
2019 | |
2020 | |
2020 | /* Use the weapon marked by the player. */ |
2021 | /* Use the weapon marked by the player. */ |
2021 | weapon = find_marked_object (op); |
2022 | weapon = find_marked_object (op); |
2022 | |
2023 | |
2023 | if (!weapon) |
2024 | if (!weapon) |
2024 | { |
2025 | { |
2025 | new_draw_info (NDI_BLACK, 0, op, "You must mark a weapon to use with this spell!"); |
2026 | op->failmsg ("You must mark a weapon to use with this spell!"); |
2026 | return 0; |
2027 | return 0; |
2027 | } |
2028 | } |
2028 | |
2029 | |
2029 | if (spell->race && weapon->arch->archname != spell->race) |
2030 | if (spell->race && weapon->arch->archname != spell->race) |
2030 | { |
2031 | { |
2031 | new_draw_info (NDI_UNIQUE, 0, op, "The spell fails to transform your weapon."); |
2032 | op->failmsg ("The spell fails to transform your weapon."); |
2032 | return 0; |
2033 | return 0; |
2033 | } |
2034 | } |
2034 | |
2035 | |
2035 | if (weapon->type != WEAPON) |
2036 | if (weapon->type != WEAPON) |
2036 | { |
2037 | { |
2037 | new_draw_info (NDI_UNIQUE, 0, op, "You need to wield a weapon to animate it."); |
2038 | op->failmsg ("You need to wield a weapon to animate it."); |
2038 | return 0; |
2039 | return 0; |
2039 | } |
2040 | } |
2040 | |
2041 | |
2041 | if (weapon->flag [FLAG_APPLIED]) |
2042 | if (weapon->flag [FLAG_APPLIED]) |
2042 | { |
2043 | { |
2043 | new_draw_info_format (NDI_BLACK, 0, op, "You need to unequip %s before using it in this spell", query_name (weapon)); |
2044 | op->failmsgf ("You need to unequip %s before using it in this spell", query_name (weapon)); |
2044 | return 0; |
2045 | return 0; |
2045 | } |
2046 | } |
2046 | |
2047 | |
2047 | weapon = weapon->split (); |
2048 | weapon = weapon->split (); |
2048 | |
2049 | |
… | |
… | |
2167 | success = op->map->change_map_light (spell->stats.dam); |
2168 | success = op->map->change_map_light (spell->stats.dam); |
2168 | |
2169 | |
2169 | if (!success) |
2170 | if (!success) |
2170 | { |
2171 | { |
2171 | if (spell->stats.dam < 0) |
2172 | if (spell->stats.dam < 0) |
2172 | new_draw_info (NDI_UNIQUE, 0, op, "It can be no brighter here."); |
2173 | op->failmsg ("It can be no brighter here."); |
2173 | else |
2174 | else |
2174 | new_draw_info (NDI_UNIQUE, 0, op, "It can be no darker here."); |
2175 | op->failmsg ("It can be no darker here."); |
2175 | } |
2176 | } |
2176 | |
2177 | |
2177 | return success; |
2178 | return success; |
2178 | } |
2179 | } |
2179 | |
2180 | |
… | |
… | |
2332 | int |
2333 | int |
2333 | write_mark (object *op, object *spell, const char *msg) |
2334 | write_mark (object *op, object *spell, const char *msg) |
2334 | { |
2335 | { |
2335 | if (!msg || msg[0] == 0) |
2336 | if (!msg || msg[0] == 0) |
2336 | { |
2337 | { |
2337 | new_draw_info (NDI_UNIQUE, 0, op, "Write what?"); |
2338 | op->failmsg ("Write what?"); |
2338 | return 0; |
2339 | return 0; |
2339 | } |
2340 | } |
2340 | |
2341 | |
2341 | if (!msg_is_safe (msg)) |
2342 | if (!msg_is_safe (msg)) |
2342 | { |
2343 | { |
2343 | new_draw_info (NDI_UNIQUE, 0, op, "Trying to cheat are we?"); |
2344 | op->failmsg ("Trying to cheat are we? H<@-signs are not allowed in marking runes.>"); |
2344 | LOG (llevInfo, "write_mark: player %s tried to write bogus rune %s\n", &op->name, msg); |
2345 | LOG (llevInfo, "write_mark: player %s tried to write bogus rune %s\n", &op->name, msg); |
2345 | return 0; |
2346 | return 0; |
2346 | } |
2347 | } |
2347 | |
2348 | |
2348 | if (!spell->other_arch) |
2349 | if (!spell->other_arch) |