1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
|
|
4 | * Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
8 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
12 | * option) any later version. |
12 | * |
13 | * |
13 | * This program is distributed in the hope that it will be useful, |
14 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
17 | * GNU General Public License for more details. |
17 | * |
18 | * |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * You should have received a copy of the Affero GNU General Public License |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
21 | * <http://www.gnu.org/licenses/>. |
21 | * |
22 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
24 | */ |
24 | |
25 | |
25 | #include <global.h> |
26 | #include <global.h> |
26 | #include <object.h> |
27 | #include <object.h> |
… | |
… | |
73 | if (!(random_roll (0, 3, op, PREFER_HIGH))) |
74 | if (!(random_roll (0, 3, op, PREFER_HIGH))) |
74 | { |
75 | { |
75 | op->failmsgf ("The %s vibrates violently, then explodes!", query_name (wand)); |
76 | op->failmsgf ("The %s vibrates violently, then explodes!", query_name (wand)); |
76 | op->play_sound (sound_find ("ob_explode")); |
77 | op->play_sound (sound_find ("ob_explode")); |
77 | wand->destroy (); |
78 | wand->destroy (); |
78 | object *tmp = get_archetype (shstr_fireball); |
79 | object *tmp = archetype::get (shstr_fireball); |
79 | tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; |
80 | tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; |
80 | |
81 | |
81 | if (!tmp->stats.dam) |
82 | if (!tmp->stats.dam) |
82 | tmp->stats.dam = 1; |
83 | tmp->stats.dam = 1; |
83 | |
84 | |
… | |
… | |
196 | /* Can't get any money for these objects */ |
197 | /* Can't get any money for these objects */ |
197 | missile->value = 0; |
198 | missile->value = 0; |
198 | |
199 | |
199 | missile->set_flag (FLAG_IDENTIFIED); |
200 | missile->set_flag (FLAG_IDENTIFIED); |
200 | |
201 | |
201 | if (!cast_create_obj (op, caster, missile, dir) && op->type == PLAYER && !missile->destroyed ()) |
202 | cast_create_obj (op, caster, missile, dir); |
|
|
203 | |
|
|
204 | if (!dir |
|
|
205 | && op->type == PLAYER |
|
|
206 | && !missile->destroyed ()) |
202 | pick_up (op, missile); |
207 | pick_up (op, missile); |
203 | |
208 | |
204 | return 1; |
209 | return 1; |
205 | } |
210 | } |
206 | |
|
|
207 | |
211 | |
208 | /* allows the choice of what sort of food object to make. |
212 | /* allows the choice of what sort of food object to make. |
209 | * If spellparam is NULL, it will create food dependent on level --PeterM*/ |
213 | * If spellparam is NULL, it will create food dependent on level --PeterM*/ |
210 | int |
214 | int |
211 | cast_create_food (object *op, object *caster, object *spell_ob, int dir, const char *spellparam) |
215 | cast_create_food (object *op, object *caster, object *spell_ob, int dir, const char *spellparam) |
… | |
… | |
290 | } |
294 | } |
291 | |
295 | |
292 | maxrange = spell_ob->range + SP_level_range_adjust (caster, spell_ob); |
296 | maxrange = spell_ob->range + SP_level_range_adjust (caster, spell_ob); |
293 | for (r = 1; r < maxrange; r++) |
297 | for (r = 1; r < maxrange; r++) |
294 | { |
298 | { |
295 | sint16 x = op->x + r * freearr_x[dir], y = op->y + r * freearr_y[dir]; |
299 | sint16 x = op->x + r * DIRX (dir), y = op->y + r * DIRY (dir); |
296 | |
300 | |
297 | m = op->map; |
301 | m = op->map; |
298 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
302 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
299 | |
303 | |
300 | if (mflags & P_OUT_OF_MAP) |
304 | if (mflags & P_OUT_OF_MAP) |
… | |
… | |
389 | |
393 | |
390 | /* Remove the switch with 90% duplicate code - just handle the differences with |
394 | /* Remove the switch with 90% duplicate code - just handle the differences with |
391 | * and if statement or two. |
395 | * and if statement or two. |
392 | */ |
396 | */ |
393 | op->invisible += spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); |
397 | op->invisible += spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); |
|
|
398 | |
394 | /* max duration */ |
399 | /* limit duration */ |
395 | if (op->invisible > 1000) |
400 | min_it (op->invisible, 1000); |
396 | op->invisible = 1000; |
|
|
397 | |
401 | |
398 | if (op->type == PLAYER) |
402 | if (op->type == PLAYER) |
399 | { |
403 | { |
400 | op->contr->invis_race = spell_ob->race; |
404 | op->contr->invis_race = spell_ob->race; |
401 | |
405 | |
402 | if (spell_ob->flag [FLAG_MAKE_INVIS]) |
406 | if (spell_ob->flag [FLAG_MAKE_INVIS]) |
403 | op->contr->tmp_invis = 0; |
407 | op->contr->tmp_invis = 0; |
404 | else |
408 | else |
405 | op->contr->tmp_invis = 1; |
409 | op->contr->tmp_invis = 1; |
406 | |
|
|
407 | op->contr->hidden = 0; |
|
|
408 | } |
410 | } |
409 | |
411 | |
410 | if (makes_invisible_to (op, op)) |
412 | if (makes_invisible_to (op, op)) |
411 | new_draw_info (NDI_UNIQUE, 0, op, "You can't see your hands!"); |
413 | new_draw_info (NDI_UNIQUE, 0, op, "You can't see your hands!"); |
412 | else |
414 | else |
… | |
… | |
470 | |
472 | |
471 | op->destroy (); |
473 | op->destroy (); |
472 | } |
474 | } |
473 | |
475 | |
474 | /* Word of recall causes the player to return 'home'. |
476 | /* Word of recall causes the player to return 'home'. |
475 | * we put a force into the player object, so that there is a |
477 | * we put a force into the player object, so that there is a |
476 | * time delay effect. |
478 | * time delay effect. |
477 | */ |
479 | */ |
478 | int |
480 | int |
479 | cast_word_of_recall (object *op, object *caster, object *spell_ob) |
481 | cast_word_of_recall (object *op, object *caster, object *spell_ob) |
480 | { |
482 | { |
… | |
… | |
485 | { |
487 | { |
486 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a force starting to build up inside you."); |
488 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a force starting to build up inside you."); |
487 | return 1; |
489 | return 1; |
488 | } |
490 | } |
489 | |
491 | |
490 | object *dummy = get_archetype (FORCE_NAME); |
492 | object *dummy = archetype::get (FORCE_NAME); |
491 | |
493 | |
492 | int time = max (1, spell_ob->duration - SP_level_duration_adjust (caster, spell_ob)); |
494 | int time = max (1, spell_ob->duration - SP_level_duration_adjust (caster, spell_ob)); |
493 | |
495 | |
494 | /* value of speed really doesn't make much difference, as long as it is |
496 | /* value of speed really doesn't make much difference, as long as it is |
495 | * positive. Lower value may be useful so that the problem doesn't |
497 | * positive. Lower value may be useful so that the problem doesn't |
… | |
… | |
618 | x = op->x; |
620 | x = op->x; |
619 | y = op->y; |
621 | y = op->y; |
620 | } |
622 | } |
621 | else |
623 | else |
622 | { |
624 | { |
623 | x = op->x + freearr_x[dir]; |
625 | x = op->x + DIRX (dir); |
624 | y = op->y + freearr_y[dir]; |
626 | y = op->y + DIRY (dir); |
625 | } |
627 | } |
626 | |
628 | |
627 | m = op->map; |
629 | m = op->map; |
628 | |
630 | |
629 | if ((spell_ob->move_block || x != op->x || y != op->y) && |
631 | if ((spell_ob->move_block || x != op->x || y != op->y) && |
… | |
… | |
704 | /* If this is a spellcasting wall, need to insert the spell object */ |
706 | /* If this is a spellcasting wall, need to insert the spell object */ |
705 | if (tmp->other_arch && tmp->other_arch->type == SPELL) |
707 | if (tmp->other_arch && tmp->other_arch->type == SPELL) |
706 | insert_ob_in_ob (tmp->other_arch->instance (), tmp); |
708 | insert_ob_in_ob (tmp->other_arch->instance (), tmp); |
707 | |
709 | |
708 | /* This code causes the wall to extend some distance in |
710 | /* This code causes the wall to extend some distance in |
709 | * each direction, or until an obstruction is encountered. |
711 | * each direction, or until an obstruction is encountered. |
710 | * posblocked and negblocked help determine how far the |
712 | * posblocked and negblocked help determine how far the |
711 | * created wall can extend, it won't go extend through |
713 | * created wall can extend, it won't go extend through |
712 | * blocked spaces. |
714 | * blocked spaces. |
713 | */ |
715 | */ |
714 | maxrange = spell_ob->range + SP_level_range_adjust (caster, spell_ob); |
716 | maxrange = spell_ob->range + SP_level_range_adjust (caster, spell_ob); |
… | |
… | |
719 | { |
721 | { |
720 | int dir2; |
722 | int dir2; |
721 | |
723 | |
722 | dir2 = (dir < 4) ? (dir + 2) : dir - 2; |
724 | dir2 = (dir < 4) ? (dir + 2) : dir - 2; |
723 | |
725 | |
724 | x = tmp->x + i * freearr_x[dir2]; |
726 | x = tmp->x + i * DIRX (dir2); |
725 | y = tmp->y + i * freearr_y[dir2]; |
727 | y = tmp->y + i * DIRY (dir2); |
726 | m = tmp->map; |
728 | m = tmp->map; |
727 | |
729 | |
728 | if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && |
730 | if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && |
729 | ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !posblocked) |
731 | ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !posblocked) |
730 | { |
732 | { |
… | |
… | |
737 | |
739 | |
738 | } |
740 | } |
739 | else |
741 | else |
740 | posblocked = 1; |
742 | posblocked = 1; |
741 | |
743 | |
742 | x = tmp->x - i * freearr_x[dir2]; |
744 | x = tmp->x - i * DIRX (dir2); |
743 | y = tmp->y - i * freearr_y[dir2]; |
745 | y = tmp->y - i * DIRY (dir2); |
744 | m = tmp->map; |
746 | m = tmp->map; |
745 | |
747 | |
746 | if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && |
748 | if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && |
747 | ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !negblocked) |
749 | ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !negblocked) |
748 | { |
750 | { |
… | |
… | |
794 | return 0; |
796 | return 0; |
795 | } |
797 | } |
796 | |
798 | |
797 | for (dist = 0; dist < count; dist++) |
799 | for (dist = 0; dist < count; dist++) |
798 | { |
800 | { |
799 | mflags = get_map_flags (op->map, &m, op->x + freearr_x[dir] * (dist + 1), op->y + freearr_y[dir] * (dist + 1), &sx, &sy); |
801 | mflags = get_map_flags (op->map, &m, op->x + DIRX (dir) * (dist + 1), op->y + DIRY (dir) * (dist + 1), &sx, &sy); |
800 | |
802 | |
801 | if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP)) |
803 | if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP)) |
802 | break; |
804 | break; |
803 | |
805 | |
804 | if ((mflags & P_BLOCKSVIEW) && OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
806 | if ((mflags & P_BLOCKSVIEW) && OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
… | |
… | |
817 | * by such squares). Also, there are probably treasure rooms and |
819 | * by such squares). Also, there are probably treasure rooms and |
818 | * lots of other maps that protect areas with no magic, but the |
820 | * lots of other maps that protect areas with no magic, but the |
819 | * areas themselves don't contain no magic spaces. |
821 | * areas themselves don't contain no magic spaces. |
820 | */ |
822 | */ |
821 | /* This call here is really just to normalize the coordinates */ |
823 | /* This call here is really just to normalize the coordinates */ |
822 | mflags = get_map_flags (op->map, &m, op->x + freearr_x[dir] * dist, op->y + freearr_y[dir] * dist, &sx, &sy); |
824 | mflags = get_map_flags (op->map, &m, op->x + DIRX (dir) * dist, op->y + DIRY (dir) * dist, &sx, &sy); |
823 | if (mflags & P_IS_ALIVE || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
825 | if (mflags & P_IS_ALIVE || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
824 | { |
826 | { |
825 | new_draw_info (NDI_UNIQUE, 0, op, "You cast your spell, but nothing happens.\n"); |
827 | new_draw_info (NDI_UNIQUE, 0, op, "You cast your spell, but nothing happens.\n"); |
826 | return 1; /* Maybe the penalty should be more severe... */ |
828 | return 1; /* Maybe the penalty should be more severe... */ |
827 | } |
829 | } |
… | |
… | |
833 | * spaces that blocked the players view. |
835 | * spaces that blocked the players view. |
834 | */ |
836 | */ |
835 | |
837 | |
836 | for (dist = 0; dist < maxdist; dist++) |
838 | for (dist = 0; dist < maxdist; dist++) |
837 | { |
839 | { |
838 | mflags = get_map_flags (op->map, &m, op->x + freearr_x[dir] * (dist + 1), op->y + freearr_y[dir] * (dist + 1), &sx, &sy); |
840 | mflags = get_map_flags (op->map, &m, op->x + DIRX (dir) * (dist + 1), op->y + DIRY (dir) * (dist + 1), &sx, &sy); |
839 | |
841 | |
840 | if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP)) |
842 | if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP)) |
841 | break; |
843 | break; |
842 | |
844 | |
843 | if ((mflags & P_BLOCKSVIEW) && OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
845 | if ((mflags & P_BLOCKSVIEW) && OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
… | |
… | |
848 | /* If the destination is blocked, keep backing up until we |
850 | /* If the destination is blocked, keep backing up until we |
849 | * find a place for the player. |
851 | * find a place for the player. |
850 | */ |
852 | */ |
851 | for (; dist > 0; dist--) |
853 | for (; dist > 0; dist--) |
852 | { |
854 | { |
853 | if (get_map_flags (op->map, &m, op->x + freearr_x[dir] * dist, op->y + freearr_y[dir] * dist, |
855 | if (get_map_flags (op->map, &m, op->x + DIRX (dir) * dist, op->y + DIRY (dir) * dist, |
854 | &sx, &sy) & (P_OUT_OF_MAP | P_IS_ALIVE)) |
856 | &sx, &sy) & (P_OUT_OF_MAP | P_IS_ALIVE)) |
855 | continue; |
857 | continue; |
856 | |
858 | |
857 | |
859 | |
858 | if (!OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
860 | if (!OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
… | |
… | |
865 | return 0; |
867 | return 0; |
866 | } |
868 | } |
867 | } |
869 | } |
868 | |
870 | |
869 | /* Actually move the player now */ |
871 | /* Actually move the player now */ |
870 | if (!(op = op->map->insert (op, op->x + freearr_x[dir] * dist, op->y + freearr_y[dir] * dist, op))) |
872 | if (!(op = op->map->insert (op, op->x + DIRX (dir) * dist, op->y + DIRY (dir) * dist, op))) |
871 | return 1; |
873 | return 1; |
872 | |
874 | |
873 | op->speed_left = -5. * op->speed; /* Freeze them for a short while */ |
875 | op->speed_left = -5. * op->speed; /* Freeze them for a short while */ |
874 | |
876 | |
875 | return 1; |
877 | return 1; |
… | |
… | |
1072 | |
1074 | |
1073 | new_draw_info_format (NDI_UNIQUE, 0, op, |
1075 | new_draw_info_format (NDI_UNIQUE, 0, op, |
1074 | "You create an aura of magical force. H<The effect will last for about %.10g seconds.>", |
1076 | "You create an aura of magical force. H<The effect will last for about %.10g seconds.>", |
1075 | TICK2TIME (duration)); |
1077 | TICK2TIME (duration)); |
1076 | |
1078 | |
1077 | force = get_archetype (FORCE_NAME); |
1079 | force = archetype::get (FORCE_NAME); |
1078 | force->subtype = FORCE_CHANGE_ABILITY; |
1080 | force->subtype = FORCE_CHANGE_ABILITY; |
1079 | force->duration = duration; |
1081 | force->duration = duration; |
1080 | |
1082 | |
1081 | if (spell_ob->race) |
1083 | if (spell_ob->race) |
1082 | force->name = spell_ob->race; |
1084 | force->name = spell_ob->race; |
… | |
… | |
1186 | } |
1188 | } |
1187 | } |
1189 | } |
1188 | |
1190 | |
1189 | if (force == NULL) |
1191 | if (force == NULL) |
1190 | { |
1192 | { |
1191 | force = get_archetype (FORCE_NAME); |
1193 | force = archetype::get (FORCE_NAME); |
1192 | force->subtype = FORCE_CHANGE_ABILITY; |
1194 | force->subtype = FORCE_CHANGE_ABILITY; |
1193 | if (spell_ob->race) |
1195 | if (spell_ob->race) |
1194 | force->name = spell_ob->race; |
1196 | force->name = spell_ob->race; |
1195 | else |
1197 | else |
1196 | force->name = spell_ob->name; |
1198 | force->name = spell_ob->name; |
… | |
… | |
1257 | |
1259 | |
1258 | /* Alchemy code by Mark Wedel |
1260 | /* Alchemy code by Mark Wedel |
1259 | * |
1261 | * |
1260 | * This code adds a new spell, called alchemy. Alchemy will turn |
1262 | * This code adds a new spell, called alchemy. Alchemy will turn |
1261 | * objects to pyrite ("false gold"), henceforth called gold nuggets. |
1263 | * objects to pyrite ("false gold"), henceforth called gold nuggets. |
1262 | * |
1264 | * |
1263 | * The value of the gold nuggets being about 90% of that of the item |
1265 | * The value of the gold nuggets being about 90% of that of the item |
1264 | * itself. It uses the value of the object before charisma adjustments, |
1266 | * itself. It uses the value of the object before charisma adjustments, |
1265 | * because the nuggets themselves will be will be adjusted by charisma |
1267 | * because the nuggets themselves will be will be adjusted by charisma |
1266 | * when sold. |
1268 | * when sold. |
1267 | * |
1269 | * |
… | |
… | |
1401 | |
1403 | |
1402 | int num_uncurse = max (1, spell->stats.dam + SP_level_dam_adjust (caster, spell)); |
1404 | int num_uncurse = max (1, spell->stats.dam + SP_level_dam_adjust (caster, spell)); |
1403 | |
1405 | |
1404 | op->splay_marked (); |
1406 | op->splay_marked (); |
1405 | |
1407 | |
|
|
1408 | int typeflag = spell->last_sp ? FLAG_DAMNED : FLAG_CURSED; |
|
|
1409 | |
1406 | for (object *tmp = op->inv; tmp && num_uncurse; tmp = tmp->below) |
1410 | for (object *tmp = op->inv; tmp && num_uncurse; tmp = tmp->below) |
1407 | if (!tmp->invisible |
1411 | if (!tmp->invisible && tmp->flag [typeflag]) |
1408 | && (((tmp->flag [FLAG_CURSED] && spell->flag [FLAG_CURSED]) |
|
|
1409 | || (tmp->flag [FLAG_DAMNED] && spell->flag [FLAG_DAMNED])))) |
|
|
1410 | { |
1412 | { |
1411 | ++was_one; |
1413 | ++was_one; |
1412 | |
1414 | |
1413 | if (tmp->level <= casting_level (caster, spell)) |
1415 | if (tmp->level <= casting_level (caster, spell)) |
1414 | { |
1416 | { |
1415 | ++success; |
1417 | ++success; |
1416 | --num_uncurse; |
1418 | --num_uncurse; |
1417 | |
1419 | |
1418 | if (spell->flag [FLAG_DAMNED]) |
1420 | tmp->clr_flag (typeflag); |
1419 | tmp->clr_flag (FLAG_DAMNED); |
|
|
1420 | |
|
|
1421 | tmp->clr_flag (FLAG_CURSED); |
1421 | tmp->clr_flag (FLAG_CURSED); |
1422 | tmp->clr_flag (FLAG_KNOWN_CURSED); |
1422 | tmp->clr_flag (FLAG_KNOWN_CURSED); |
1423 | tmp->value = 0; /* Still can't sell it */ |
1423 | tmp->value = 0; /* Still can't sell it */ |
1424 | |
1424 | |
1425 | if (object *pl = tmp->visible_to ()) |
1425 | if (object *pl = tmp->visible_to ()) |
… | |
… | |
1434 | else |
1434 | else |
1435 | { |
1435 | { |
1436 | if (was_one) |
1436 | if (was_one) |
1437 | new_draw_info (NDI_UNIQUE, 0, op, "You failed to remove any curse. H<The spell was not strong enough.>"); |
1437 | new_draw_info (NDI_UNIQUE, 0, op, "You failed to remove any curse. H<The spell was not strong enough.>"); |
1438 | else |
1438 | else |
1439 | new_draw_info (NDI_UNIQUE, 0, op, "You are not having any cursed items."); |
1439 | new_draw_info (NDI_UNIQUE, 0, op, "You are not having any cursed items. H<Epic fail.>"); |
1440 | } |
1440 | } |
1441 | } |
1441 | } |
1442 | |
1442 | |
1443 | return success; |
1443 | return success; |
1444 | } |
1444 | } |
… | |
… | |
1513 | |
1513 | |
1514 | int |
1514 | int |
1515 | cast_detection (object *op, object *caster, object *spell, object *skill) |
1515 | cast_detection (object *op, object *caster, object *spell, object *skill) |
1516 | { |
1516 | { |
1517 | object *tmp, *last, *god, *detect; |
1517 | object *tmp, *last, *god, *detect; |
1518 | int done_one, range, mflags, floor, level; |
1518 | int done_one, range, floor, level; |
1519 | sint16 x, y, nx, ny; |
1519 | sint16 x, y, nx, ny; |
1520 | maptile *m; |
1520 | maptile *m; |
1521 | |
1521 | |
1522 | /* We precompute some values here so that we don't have to keep |
1522 | /* We precompute some values here so that we don't have to keep |
1523 | * doing it over and over again. |
1523 | * doing it over and over again. |
… | |
… | |
1769 | sint16 x, y; |
1769 | sint16 x, y; |
1770 | maptile *m; |
1770 | maptile *m; |
1771 | int mflags; |
1771 | int mflags; |
1772 | |
1772 | |
1773 | m = op->map; |
1773 | m = op->map; |
1774 | x = op->x + freearr_x[dir]; |
1774 | x = op->x + DIRX (dir); |
1775 | y = op->y + freearr_y[dir]; |
1775 | y = op->y + DIRY (dir); |
1776 | |
1776 | |
1777 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
1777 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
1778 | |
1778 | |
1779 | if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) |
1779 | if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) |
1780 | { |
1780 | { |
… | |
… | |
1844 | object *tmp, *head, *next; |
1844 | object *tmp, *head, *next; |
1845 | int mflags; |
1845 | int mflags; |
1846 | maptile *m; |
1846 | maptile *m; |
1847 | sint16 sx, sy; |
1847 | sint16 sx, sy; |
1848 | |
1848 | |
1849 | sx = op->x + freearr_x[dir]; |
1849 | sx = op->x + DIRX (dir); |
1850 | sy = op->y + freearr_y[dir]; |
1850 | sy = op->y + DIRY (dir); |
1851 | m = op->map; |
1851 | m = op->map; |
1852 | mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); |
1852 | mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); |
1853 | if (mflags & P_OUT_OF_MAP) |
1853 | if (mflags & P_OUT_OF_MAP) |
1854 | return; |
1854 | return; |
1855 | |
1855 | |
… | |
… | |
1868 | |
1868 | |
1869 | /* don't attack our own spells */ |
1869 | /* don't attack our own spells */ |
1870 | if (tmp->owner && tmp->owner == op->owner) |
1870 | if (tmp->owner && tmp->owner == op->owner) |
1871 | continue; |
1871 | continue; |
1872 | |
1872 | |
1873 | /* Basically, if the object is magical and not counterspell, |
1873 | /* Basically, if the object is magical and not counterspell, |
1874 | * we will more or less remove the object. Don't counterspell |
1874 | * we will more or less remove the object. Don't counterspell |
1875 | * monsters either. |
1875 | * monsters either. |
1876 | */ |
1876 | */ |
1877 | |
1877 | |
1878 | if (head->attacktype & AT_MAGIC |
1878 | if (head->attacktype & AT_MAGIC |
1879 | && !(head->attacktype & AT_COUNTERSPELL) |
1879 | && !(head->attacktype & AT_COUNTERSPELL) |
1880 | && !head->flag [FLAG_MONSTER] |
1880 | && !head->flag [FLAG_MONSTER] |
… | |
… | |
1954 | |
1954 | |
1955 | op->failmsg ("You are not standing over an altar!"); |
1955 | op->failmsg ("You are not standing over an altar!"); |
1956 | return 0; |
1956 | return 0; |
1957 | } |
1957 | } |
1958 | |
1958 | |
1959 | /* animate_weapon - |
1959 | /* animate_weapon - |
1960 | * Generalization of staff_to_snake. Makes a golem out of the caster's weapon. |
1960 | * Generalization of staff_to_snake. Makes a golem out of the caster's weapon. |
1961 | * The golem is based on the archetype specified, modified by the caster's level |
1961 | * The golem is based on the archetype specified, modified by the caster's level |
1962 | * and the attributes of the weapon. The weapon is inserted in the golem's |
1962 | * and the attributes of the weapon. The weapon is inserted in the golem's |
1963 | * inventory so that it falls to the ground when the golem dies. |
1963 | * inventory so that it falls to the ground when the golem dies. |
1964 | * This code was very odd - code early on would only let players use the spell, |
1964 | * This code was very odd - code early on would only let players use the spell, |
1965 | * yet the code wass full of player checks. I've presumed that the code |
1965 | * yet the code wass full of player checks. I've presumed that the code |
1966 | * that only let players use it was correct, and removed all the other |
1966 | * that only let players use it was correct, and removed all the other |
1967 | * player checks. MSW 2003-01-06 |
1967 | * player checks. MSW 2003-01-06 |
… | |
… | |
1994 | /* if no direction specified, pick one */ |
1994 | /* if no direction specified, pick one */ |
1995 | if (!dir) |
1995 | if (!dir) |
1996 | dir = find_free_spot (spell->other_arch, op->map, op->x, op->y, 1, 9); |
1996 | dir = find_free_spot (spell->other_arch, op->map, op->x, op->y, 1, 9); |
1997 | |
1997 | |
1998 | m = op->map; |
1998 | m = op->map; |
1999 | x = op->x + freearr_x[dir]; |
1999 | x = op->x + DIRX (dir); |
2000 | y = op->y + freearr_y[dir]; |
2000 | y = op->y + DIRY (dir); |
2001 | |
2001 | |
2002 | /* if there's no place to put the golem, abort */ |
2002 | /* if there's no place to put the golem, abort */ |
2003 | if (dir < 0 || (get_map_flags (m, &m, x, y, &x, &y) & P_OUT_OF_MAP) |
2003 | if (dir < 0 || (get_map_flags (m, &m, x, y, &x, &y) & P_OUT_OF_MAP) |
2004 | || ((spell->other_arch->move_type & GET_MAP_MOVE_BLOCK (m, x, y)) == spell->other_arch->move_type)) |
2004 | || ((spell->other_arch->move_type & GET_MAP_MOVE_BLOCK (m, x, y)) == spell->other_arch->move_type)) |
2005 | { |
2005 | { |
… | |
… | |
2111 | /* Improve weapon's armour value according to best save vs. physical of its material */ |
2111 | /* Improve weapon's armour value according to best save vs. physical of its material */ |
2112 | |
2112 | |
2113 | if (a > 14) |
2113 | if (a > 14) |
2114 | a = 14; |
2114 | a = 14; |
2115 | |
2115 | |
2116 | tmp->resist[ATNR_PHYSICAL] = 100 - (int) ((100.0 - (float) tmp->resist[ATNR_PHYSICAL]) / (30.0 - 2.0 * a)); |
2116 | tmp->resist[ATNR_PHYSICAL] = 100 - (int) ((100.f - (float) tmp->resist[ATNR_PHYSICAL]) / (30.f - 2.f * a)); |
2117 | |
2117 | |
2118 | /* Determine golem's speed */ |
2118 | /* Determine golem's speed */ |
2119 | tmp->set_speed (min (3.33, 0.4 + 0.1 * SP_level_range_adjust (caster, spell))); |
2119 | tmp->set_speed (min (3.33f, 0.4f + 0.1f * SP_level_range_adjust (caster, spell))); |
2120 | |
2120 | |
2121 | if (!spell->race) |
2121 | if (!spell->race) |
2122 | { |
2122 | { |
2123 | sprintf (buf, "animated %s", &weapon->name); |
2123 | sprintf (buf, "animated %s", &weapon->name); |
2124 | tmp->name = buf; |
2124 | tmp->name = buf; |
… | |
… | |
2205 | |
2205 | |
2206 | /* move aura function. An aura is a part of someone's inventory, |
2206 | /* move aura function. An aura is a part of someone's inventory, |
2207 | * which he carries with him, but which acts on the map immediately |
2207 | * which he carries with him, but which acts on the map immediately |
2208 | * around him. |
2208 | * around him. |
2209 | * Aura parameters: |
2209 | * Aura parameters: |
2210 | * duration: duration counter. |
2210 | * duration: duration counter. |
2211 | * attacktype: aura's attacktype |
2211 | * attacktype: aura's attacktype |
2212 | * other_arch: archetype to drop where we attack |
2212 | * other_arch: archetype to drop where we attack |
2213 | */ |
2213 | */ |
2214 | void |
2214 | void |
2215 | move_aura (object *aura) |
2215 | move_aura (object *aura) |
2216 | { |
2216 | { |
2217 | /* auras belong in inventories */ |
2217 | /* auras belong in inventories */ |
2218 | object *env = aura->env; |
2218 | object *env = aura->env; |
2219 | object *owner = aura->owner; |
2219 | object *owner = aura->owner; |
2220 | |
2220 | |
2221 | /* no matter what we've gotta remove the aura... |
2221 | /* no matter what we've gotta remove the aura... |
2222 | * we'll put it back if its time isn't up. |
2222 | * we'll put it back if its time isn't up. |
2223 | */ |
2223 | */ |
2224 | aura->remove (); |
2224 | aura->remove (); |
2225 | |
2225 | |
2226 | /* exit if we're out of gas */ |
2226 | /* exit if we're out of gas */ |
2227 | if (aura->duration-- < 0) |
2227 | if (aura->duration-- < 0) |
… | |
… | |
2236 | aura->destroy (); |
2236 | aura->destroy (); |
2237 | return; |
2237 | return; |
2238 | } |
2238 | } |
2239 | |
2239 | |
2240 | /* we need to jump out of the inventory for a bit |
2240 | /* we need to jump out of the inventory for a bit |
2241 | * in order to hit the map conveniently. |
2241 | * in order to hit the map conveniently. |
2242 | */ |
2242 | */ |
2243 | aura->insert_at (env, aura); |
2243 | aura->insert_at (env, aura); |
2244 | |
2244 | |
2245 | for (int i = 1; i < 9; i++) |
2245 | for (int i = 1; i < 9; i++) |
2246 | { |
2246 | { |