… | |
… | |
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 | } |
… | |
… | |
1552 | * floor. But this is not true for show invisible. |
1552 | * floor. But this is not true for show invisible. |
1553 | * Basically, we just go and find the top object and work |
1553 | * Basically, we just go and find the top object and work |
1554 | * down - that is easier than working up. |
1554 | * down - that is easier than working up. |
1555 | */ |
1555 | */ |
1556 | |
1556 | |
1557 | for (last = NULL, tmp = m->at (nx, ny).bot; tmp; tmp = tmp->above) |
1557 | for (last = 0, tmp = m->at (nx, ny).bot; tmp; tmp = tmp->above) |
1558 | last = tmp; |
1558 | last = tmp; |
1559 | |
1559 | |
1560 | /* Shouldn't happen, but if there are no objects on a space, this |
1560 | /* Shouldn't happen, but if there are no objects on a space, this |
1561 | * would happen. |
1561 | * would happen. |
1562 | */ |
1562 | */ |
1563 | if (!last) |
1563 | if (!last) |
1564 | continue; |
1564 | continue; |
1565 | |
1565 | |
1566 | done_one = 0; |
1566 | done_one = 0; |
1567 | floor = 0; |
1567 | floor = 0; |
1568 | detect = NULL; |
1568 | detect = 0; |
1569 | for (tmp = last; tmp; tmp = tmp->below) |
1569 | for (tmp = last; tmp; tmp = tmp->below) |
1570 | { |
1570 | { |
1571 | /* show invisible */ |
1571 | /* show invisible */ |
1572 | if (spell->flag [FLAG_MAKE_INVIS] |
1572 | if (spell->flag [FLAG_MAKE_INVIS] |
1573 | /* Might there be other objects that we can make visible? */ |
1573 | /* Might there be other objects that we can make visible? */ |
… | |
… | |
1581 | || tmp->type == TELEPORTER |
1581 | || tmp->type == TELEPORTER |
1582 | || tmp->type == GATE |
1582 | || tmp->type == GATE |
1583 | || tmp->type == LOCKED_DOOR |
1583 | || tmp->type == LOCKED_DOOR |
1584 | || tmp->type == WEAPON |
1584 | || tmp->type == WEAPON |
1585 | || tmp->type == ALTAR |
1585 | || tmp->type == ALTAR |
1586 | || tmp->type == SIGN |
1586 | || (tmp->type == SIGN && tmp->face != magicmouth_face) |
1587 | || tmp->type == TRIGGER_PEDESTAL |
1587 | || tmp->type == TRIGGER_PEDESTAL |
1588 | || tmp->type == SPECIAL_KEY |
1588 | || tmp->type == SPECIAL_KEY |
1589 | || tmp->type == TREASURE |
1589 | || tmp->type == TREASURE |
1590 | || tmp->type == BOOK |
1590 | || tmp->type == BOOK |
1591 | || tmp->type == HOLY_ALTAR |
1591 | || tmp->type == HOLY_ALTAR |
1592 | || tmp->type == CONTAINER))) |
1592 | || tmp->type == CONTAINER))) |
1593 | { |
1593 | { |
|
|
1594 | printf ("show inv %s\n", tmp->debug_desc());//D |
1594 | if (random_roll (0, skill->level - 1, op, PREFER_HIGH) > level / 4) |
1595 | if (random_roll (0, skill->level - 1, op, PREFER_HIGH) > level / 4) |
1595 | { |
1596 | { |
1596 | tmp->invisible = 0; |
1597 | tmp->invisible = 0; |
1597 | done_one = 1; |
1598 | done_one = 1; |
1598 | } |
1599 | } |
… | |
… | |
1802 | if (plyr != op && plyr->flag [FLAG_ALIVE]) |
1803 | if (plyr != op && plyr->flag [FLAG_ALIVE]) |
1803 | break; |
1804 | break; |
1804 | |
1805 | |
1805 | if (!plyr) |
1806 | if (!plyr) |
1806 | { |
1807 | { |
1807 | new_draw_info (NDI_BLACK, 0, op, "There is no one there."); |
1808 | op->failmsg ("There is no one there."); |
1808 | return 0; |
1809 | return 0; |
1809 | } |
1810 | } |
1810 | /* give sp */ |
1811 | /* give sp */ |
1811 | if (spell->stats.dam > 0) |
1812 | if (spell->stats.dam > 0) |
1812 | { |
1813 | { |
… | |
… | |
1927 | |
1928 | |
1928 | object *tmp, *god = find_god (determine_god (op)); |
1929 | object *tmp, *god = find_god (determine_god (op)); |
1929 | |
1930 | |
1930 | if (!god) |
1931 | if (!god) |
1931 | { |
1932 | { |
1932 | new_draw_info (NDI_UNIQUE, 0, op, "You can't consecrate anything if you don't worship a god!"); |
1933 | op->failmsg ("You can't consecrate anything if you don't worship a god!"); |
1933 | return 0; |
1934 | return 0; |
1934 | } |
1935 | } |
1935 | |
1936 | |
1936 | for (tmp = op->below; tmp; tmp = tmp->below) |
1937 | for (tmp = op->below; tmp; tmp = tmp->below) |
1937 | { |
1938 | { |
… | |
… | |
1940 | if (tmp->type == HOLY_ALTAR) |
1941 | if (tmp->type == HOLY_ALTAR) |
1941 | { |
1942 | { |
1942 | |
1943 | |
1943 | if (tmp->level > casting_level (caster, spell)) |
1944 | if (tmp->level > casting_level (caster, spell)) |
1944 | { |
1945 | { |
1945 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are not powerful enough to reconsecrate the %s", &tmp->name); |
1946 | op->failmsgf ("You are not powerful enough to reconsecrate the %s", &tmp->name); |
1946 | return 0; |
1947 | return 0; |
1947 | } |
1948 | } |
1948 | else |
1949 | else |
1949 | { |
1950 | { |
1950 | /* If we got here, we are consecrating an altar */ |
1951 | /* 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); |
1960 | new_draw_info_format (NDI_UNIQUE, 0, op, "You consecrated the altar to %s!", &god->name); |
1960 | return 1; |
1961 | return 1; |
1961 | } |
1962 | } |
1962 | } |
1963 | } |
1963 | } |
1964 | } |
1964 | new_draw_info (NDI_UNIQUE, 0, op, "You are not standing over an altar!"); |
1965 | |
|
|
1966 | op->failmsg ("You are not standing over an altar!"); |
1965 | return 0; |
1967 | return 0; |
1966 | } |
1968 | } |
1967 | |
1969 | |
1968 | /* animate_weapon - |
1970 | /* animate_weapon - |
1969 | * Generalization of staff_to_snake. Makes a golem out of the caster's weapon. |
1971 | * Generalization of staff_to_snake. Makes a golem out of the caster's weapon. |
… | |
… | |
2011 | |
2013 | |
2012 | /* if there's no place to put the golem, abort */ |
2014 | /* 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) |
2015 | 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)) |
2016 | || ((spell->other_arch->move_type & GET_MAP_MOVE_BLOCK (m, x, y)) == spell->other_arch->move_type)) |
2015 | { |
2017 | { |
2016 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
2018 | op->failmsg ("There is something in the way."); |
2017 | return 0; |
2019 | return 0; |
2018 | } |
2020 | } |
2019 | |
2021 | |
2020 | /* Use the weapon marked by the player. */ |
2022 | /* Use the weapon marked by the player. */ |
2021 | weapon = find_marked_object (op); |
2023 | weapon = find_marked_object (op); |
2022 | |
2024 | |
2023 | if (!weapon) |
2025 | if (!weapon) |
2024 | { |
2026 | { |
2025 | new_draw_info (NDI_BLACK, 0, op, "You must mark a weapon to use with this spell!"); |
2027 | op->failmsg ("You must mark a weapon to use with this spell!"); |
2026 | return 0; |
2028 | return 0; |
2027 | } |
2029 | } |
2028 | |
2030 | |
2029 | if (spell->race && weapon->arch->archname != spell->race) |
2031 | if (spell->race && weapon->arch->archname != spell->race) |
2030 | { |
2032 | { |
2031 | new_draw_info (NDI_UNIQUE, 0, op, "The spell fails to transform your weapon."); |
2033 | op->failmsg ("The spell fails to transform your weapon."); |
2032 | return 0; |
2034 | return 0; |
2033 | } |
2035 | } |
2034 | |
2036 | |
2035 | if (weapon->type != WEAPON) |
2037 | if (weapon->type != WEAPON) |
2036 | { |
2038 | { |
2037 | new_draw_info (NDI_UNIQUE, 0, op, "You need to wield a weapon to animate it."); |
2039 | op->failmsg ("You need to wield a weapon to animate it."); |
2038 | return 0; |
2040 | return 0; |
2039 | } |
2041 | } |
2040 | |
2042 | |
2041 | if (weapon->flag [FLAG_APPLIED]) |
2043 | if (weapon->flag [FLAG_APPLIED]) |
2042 | { |
2044 | { |
2043 | new_draw_info_format (NDI_BLACK, 0, op, "You need to unequip %s before using it in this spell", query_name (weapon)); |
2045 | op->failmsgf ("You need to unequip %s before using it in this spell", query_name (weapon)); |
2044 | return 0; |
2046 | return 0; |
2045 | } |
2047 | } |
2046 | |
2048 | |
2047 | weapon = weapon->split (); |
2049 | weapon = weapon->split (); |
2048 | |
2050 | |
… | |
… | |
2167 | success = op->map->change_map_light (spell->stats.dam); |
2169 | success = op->map->change_map_light (spell->stats.dam); |
2168 | |
2170 | |
2169 | if (!success) |
2171 | if (!success) |
2170 | { |
2172 | { |
2171 | if (spell->stats.dam < 0) |
2173 | if (spell->stats.dam < 0) |
2172 | new_draw_info (NDI_UNIQUE, 0, op, "It can be no brighter here."); |
2174 | op->failmsg ("It can be no brighter here."); |
2173 | else |
2175 | else |
2174 | new_draw_info (NDI_UNIQUE, 0, op, "It can be no darker here."); |
2176 | op->failmsg ("It can be no darker here."); |
2175 | } |
2177 | } |
2176 | |
2178 | |
2177 | return success; |
2179 | return success; |
2178 | } |
2180 | } |
2179 | |
2181 | |
… | |
… | |
2332 | int |
2334 | int |
2333 | write_mark (object *op, object *spell, const char *msg) |
2335 | write_mark (object *op, object *spell, const char *msg) |
2334 | { |
2336 | { |
2335 | if (!msg || msg[0] == 0) |
2337 | if (!msg || msg[0] == 0) |
2336 | { |
2338 | { |
2337 | new_draw_info (NDI_UNIQUE, 0, op, "Write what?"); |
2339 | op->failmsg ("Write what?"); |
2338 | return 0; |
2340 | return 0; |
2339 | } |
2341 | } |
2340 | |
2342 | |
2341 | if (!msg_is_safe (msg)) |
2343 | if (!msg_is_safe (msg)) |
2342 | { |
2344 | { |
2343 | new_draw_info (NDI_UNIQUE, 0, op, "Trying to cheat are we?"); |
2345 | 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); |
2346 | LOG (llevInfo, "write_mark: player %s tried to write bogus rune %s\n", &op->name, msg); |
2345 | return 0; |
2347 | return 0; |
2346 | } |
2348 | } |
2347 | |
2349 | |
2348 | if (!spell->other_arch) |
2350 | if (!spell->other_arch) |