… | |
… | |
293 | } |
293 | } |
294 | |
294 | |
295 | maxrange = spell_ob->range + SP_level_range_adjust (caster, spell_ob); |
295 | maxrange = spell_ob->range + SP_level_range_adjust (caster, spell_ob); |
296 | for (r = 1; r < maxrange; r++) |
296 | for (r = 1; r < maxrange; r++) |
297 | { |
297 | { |
298 | sint16 x = op->x + r * freearr_x[dir], y = op->y + r * freearr_y[dir]; |
298 | sint16 x = op->x + r * DIRX (dir), y = op->y + r * DIRY (dir); |
299 | |
299 | |
300 | m = op->map; |
300 | m = op->map; |
301 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
301 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
302 | |
302 | |
303 | if (mflags & P_OUT_OF_MAP) |
303 | if (mflags & P_OUT_OF_MAP) |
… | |
… | |
619 | x = op->x; |
619 | x = op->x; |
620 | y = op->y; |
620 | y = op->y; |
621 | } |
621 | } |
622 | else |
622 | else |
623 | { |
623 | { |
624 | x = op->x + freearr_x[dir]; |
624 | x = op->x + DIRX (dir); |
625 | y = op->y + freearr_y[dir]; |
625 | y = op->y + DIRY (dir); |
626 | } |
626 | } |
627 | |
627 | |
628 | m = op->map; |
628 | m = op->map; |
629 | |
629 | |
630 | if ((spell_ob->move_block || x != op->x || y != op->y) && |
630 | if ((spell_ob->move_block || x != op->x || y != op->y) && |
… | |
… | |
720 | { |
720 | { |
721 | int dir2; |
721 | int dir2; |
722 | |
722 | |
723 | dir2 = (dir < 4) ? (dir + 2) : dir - 2; |
723 | dir2 = (dir < 4) ? (dir + 2) : dir - 2; |
724 | |
724 | |
725 | x = tmp->x + i * freearr_x[dir2]; |
725 | x = tmp->x + i * DIRX (dir2); |
726 | y = tmp->y + i * freearr_y[dir2]; |
726 | y = tmp->y + i * DIRY (dir2); |
727 | m = tmp->map; |
727 | m = tmp->map; |
728 | |
728 | |
729 | if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && |
729 | if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && |
730 | ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !posblocked) |
730 | ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !posblocked) |
731 | { |
731 | { |
… | |
… | |
738 | |
738 | |
739 | } |
739 | } |
740 | else |
740 | else |
741 | posblocked = 1; |
741 | posblocked = 1; |
742 | |
742 | |
743 | x = tmp->x - i * freearr_x[dir2]; |
743 | x = tmp->x - i * DIRX (dir2); |
744 | y = tmp->y - i * freearr_y[dir2]; |
744 | y = tmp->y - i * DIRY (dir2); |
745 | m = tmp->map; |
745 | m = tmp->map; |
746 | |
746 | |
747 | if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && |
747 | if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && |
748 | ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !negblocked) |
748 | ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !negblocked) |
749 | { |
749 | { |
… | |
… | |
795 | return 0; |
795 | return 0; |
796 | } |
796 | } |
797 | |
797 | |
798 | for (dist = 0; dist < count; dist++) |
798 | for (dist = 0; dist < count; dist++) |
799 | { |
799 | { |
800 | mflags = get_map_flags (op->map, &m, op->x + freearr_x[dir] * (dist + 1), op->y + freearr_y[dir] * (dist + 1), &sx, &sy); |
800 | mflags = get_map_flags (op->map, &m, op->x + DIRX (dir) * (dist + 1), op->y + DIRY (dir) * (dist + 1), &sx, &sy); |
801 | |
801 | |
802 | if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP)) |
802 | if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP)) |
803 | break; |
803 | break; |
804 | |
804 | |
805 | if ((mflags & P_BLOCKSVIEW) && OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
805 | if ((mflags & P_BLOCKSVIEW) && OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
… | |
… | |
818 | * by such squares). Also, there are probably treasure rooms and |
818 | * by such squares). Also, there are probably treasure rooms and |
819 | * lots of other maps that protect areas with no magic, but the |
819 | * lots of other maps that protect areas with no magic, but the |
820 | * areas themselves don't contain no magic spaces. |
820 | * areas themselves don't contain no magic spaces. |
821 | */ |
821 | */ |
822 | /* This call here is really just to normalize the coordinates */ |
822 | /* This call here is really just to normalize the coordinates */ |
823 | mflags = get_map_flags (op->map, &m, op->x + freearr_x[dir] * dist, op->y + freearr_y[dir] * dist, &sx, &sy); |
823 | mflags = get_map_flags (op->map, &m, op->x + DIRX (dir) * dist, op->y + DIRY (dir) * dist, &sx, &sy); |
824 | if (mflags & P_IS_ALIVE || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
824 | if (mflags & P_IS_ALIVE || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
825 | { |
825 | { |
826 | new_draw_info (NDI_UNIQUE, 0, op, "You cast your spell, but nothing happens.\n"); |
826 | new_draw_info (NDI_UNIQUE, 0, op, "You cast your spell, but nothing happens.\n"); |
827 | return 1; /* Maybe the penalty should be more severe... */ |
827 | return 1; /* Maybe the penalty should be more severe... */ |
828 | } |
828 | } |
… | |
… | |
834 | * spaces that blocked the players view. |
834 | * spaces that blocked the players view. |
835 | */ |
835 | */ |
836 | |
836 | |
837 | for (dist = 0; dist < maxdist; dist++) |
837 | for (dist = 0; dist < maxdist; dist++) |
838 | { |
838 | { |
839 | mflags = get_map_flags (op->map, &m, op->x + freearr_x[dir] * (dist + 1), op->y + freearr_y[dir] * (dist + 1), &sx, &sy); |
839 | mflags = get_map_flags (op->map, &m, op->x + DIRX (dir) * (dist + 1), op->y + DIRY (dir) * (dist + 1), &sx, &sy); |
840 | |
840 | |
841 | if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP)) |
841 | if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP)) |
842 | break; |
842 | break; |
843 | |
843 | |
844 | if ((mflags & P_BLOCKSVIEW) && OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
844 | if ((mflags & P_BLOCKSVIEW) && OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
… | |
… | |
849 | /* If the destination is blocked, keep backing up until we |
849 | /* If the destination is blocked, keep backing up until we |
850 | * find a place for the player. |
850 | * find a place for the player. |
851 | */ |
851 | */ |
852 | for (; dist > 0; dist--) |
852 | for (; dist > 0; dist--) |
853 | { |
853 | { |
854 | if (get_map_flags (op->map, &m, op->x + freearr_x[dir] * dist, op->y + freearr_y[dir] * dist, |
854 | if (get_map_flags (op->map, &m, op->x + DIRX (dir) * dist, op->y + DIRY (dir) * dist, |
855 | &sx, &sy) & (P_OUT_OF_MAP | P_IS_ALIVE)) |
855 | &sx, &sy) & (P_OUT_OF_MAP | P_IS_ALIVE)) |
856 | continue; |
856 | continue; |
857 | |
857 | |
858 | |
858 | |
859 | if (!OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
859 | if (!OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
… | |
… | |
866 | return 0; |
866 | return 0; |
867 | } |
867 | } |
868 | } |
868 | } |
869 | |
869 | |
870 | /* Actually move the player now */ |
870 | /* Actually move the player now */ |
871 | if (!(op = op->map->insert (op, op->x + freearr_x[dir] * dist, op->y + freearr_y[dir] * dist, op))) |
871 | if (!(op = op->map->insert (op, op->x + DIRX (dir) * dist, op->y + DIRY (dir) * dist, op))) |
872 | return 1; |
872 | return 1; |
873 | |
873 | |
874 | op->speed_left = -5. * op->speed; /* Freeze them for a short while */ |
874 | op->speed_left = -5. * op->speed; /* Freeze them for a short while */ |
875 | |
875 | |
876 | return 1; |
876 | return 1; |
… | |
… | |
1768 | sint16 x, y; |
1768 | sint16 x, y; |
1769 | maptile *m; |
1769 | maptile *m; |
1770 | int mflags; |
1770 | int mflags; |
1771 | |
1771 | |
1772 | m = op->map; |
1772 | m = op->map; |
1773 | x = op->x + freearr_x[dir]; |
1773 | x = op->x + DIRX (dir); |
1774 | y = op->y + freearr_y[dir]; |
1774 | y = op->y + DIRY (dir); |
1775 | |
1775 | |
1776 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
1776 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
1777 | |
1777 | |
1778 | if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) |
1778 | if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) |
1779 | { |
1779 | { |
… | |
… | |
1843 | object *tmp, *head, *next; |
1843 | object *tmp, *head, *next; |
1844 | int mflags; |
1844 | int mflags; |
1845 | maptile *m; |
1845 | maptile *m; |
1846 | sint16 sx, sy; |
1846 | sint16 sx, sy; |
1847 | |
1847 | |
1848 | sx = op->x + freearr_x[dir]; |
1848 | sx = op->x + DIRX (dir); |
1849 | sy = op->y + freearr_y[dir]; |
1849 | sy = op->y + DIRY (dir); |
1850 | m = op->map; |
1850 | m = op->map; |
1851 | mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); |
1851 | mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); |
1852 | if (mflags & P_OUT_OF_MAP) |
1852 | if (mflags & P_OUT_OF_MAP) |
1853 | return; |
1853 | return; |
1854 | |
1854 | |
… | |
… | |
1993 | /* if no direction specified, pick one */ |
1993 | /* if no direction specified, pick one */ |
1994 | if (!dir) |
1994 | if (!dir) |
1995 | dir = find_free_spot (spell->other_arch, op->map, op->x, op->y, 1, 9); |
1995 | dir = find_free_spot (spell->other_arch, op->map, op->x, op->y, 1, 9); |
1996 | |
1996 | |
1997 | m = op->map; |
1997 | m = op->map; |
1998 | x = op->x + freearr_x[dir]; |
1998 | x = op->x + DIRX (dir); |
1999 | y = op->y + freearr_y[dir]; |
1999 | y = op->y + DIRY (dir); |
2000 | |
2000 | |
2001 | /* if there's no place to put the golem, abort */ |
2001 | /* if there's no place to put the golem, abort */ |
2002 | if (dir < 0 || (get_map_flags (m, &m, x, y, &x, &y) & P_OUT_OF_MAP) |
2002 | if (dir < 0 || (get_map_flags (m, &m, x, y, &x, &y) & P_OUT_OF_MAP) |
2003 | || ((spell->other_arch->move_type & GET_MAP_MOVE_BLOCK (m, x, y)) == spell->other_arch->move_type)) |
2003 | || ((spell->other_arch->move_type & GET_MAP_MOVE_BLOCK (m, x, y)) == spell->other_arch->move_type)) |
2004 | { |
2004 | { |