… | |
… | |
1008 | int mflags; |
1008 | int mflags; |
1009 | sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir]; |
1009 | sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir]; |
1010 | maptile *m; |
1010 | maptile *m; |
1011 | |
1011 | |
1012 | mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy); |
1012 | mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy); |
|
|
1013 | |
|
|
1014 | // when creating a bomb below ourself it should always work, even |
|
|
1015 | // when movement is blocked (somehow we got here, somehow we are here, |
|
|
1016 | // so we should also be able to make a bomb here). (originally added |
|
|
1017 | // to fix create bomb traps in doors, which cast with dir=0). |
|
|
1018 | if (dir) |
|
|
1019 | { |
1013 | if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK)) |
1020 | if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK)) |
1014 | { |
1021 | { |
1015 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
1022 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
1016 | return 0; |
1023 | return 0; |
|
|
1024 | } |
1017 | } |
1025 | } |
1018 | |
1026 | |
1019 | tmp = arch_to_object (spell->other_arch); |
1027 | tmp = arch_to_object (spell->other_arch); |
1020 | |
1028 | |
1021 | /* level dependencies for bomb */ |
1029 | /* level dependencies for bomb */ |
… | |
… | |
1250 | |
1258 | |
1251 | object *tmp = get_archetype (FORCE_NAME); |
1259 | object *tmp = get_archetype (FORCE_NAME); |
1252 | tmp->speed = 0.01; |
1260 | tmp->speed = 0.01; |
1253 | tmp->stats.food = time; |
1261 | tmp->stats.food = time; |
1254 | SET_FLAG (tmp, FLAG_IS_USED_UP); |
1262 | SET_FLAG (tmp, FLAG_IS_USED_UP); |
1255 | tmp->glow_radius = radius; |
|
|
1256 | if (tmp->glow_radius > MAX_LIGHT_RADII) |
|
|
1257 | tmp->glow_radius = MAX_LIGHT_RADII; |
1263 | tmp->glow_radius = min (MAX_LIGHT_RADIUS, radius); |
1258 | |
|
|
1259 | tmp = insert_ob_in_ob (tmp, op); |
1264 | tmp = insert_ob_in_ob (tmp, op); |
1260 | |
1265 | |
1261 | if (tmp->glow_radius > op->glow_radius) |
1266 | if (tmp->glow_radius > op->glow_radius) |
1262 | op->glow_radius = tmp->glow_radius; |
1267 | op->glow_radius = tmp->glow_radius; |
1263 | |
1268 | |
… | |
… | |
1493 | if (!(mflags & P_IS_ALIVE)) |
1498 | if (!(mflags & P_IS_ALIVE)) |
1494 | continue; |
1499 | continue; |
1495 | |
1500 | |
1496 | // players can only affect spaces that they can actually see |
1501 | // players can only affect spaces that they can actually see |
1497 | if (caster && caster->contr |
1502 | if (caster && caster->contr |
1498 | && caster->contr->visibility_at (m, nx, ny) < 70) |
1503 | && caster->contr->darkness_at (m, nx, ny) == LOS_BLOCKED) |
1499 | continue; |
1504 | continue; |
1500 | |
1505 | |
1501 | for (tmp = GET_MAP_TOP (m, nx, ny); tmp; tmp = tmp->below) |
1506 | for (tmp = GET_MAP_TOP (m, nx, ny); tmp; tmp = tmp->below) |
1502 | if (QUERY_FLAG (tmp, FLAG_MONSTER)) |
1507 | if (QUERY_FLAG (tmp, FLAG_MONSTER)) |
1503 | break; |
1508 | break; |
… | |
… | |
1613 | } /* for y */ |
1618 | } /* for y */ |
1614 | |
1619 | |
1615 | return 1; |
1620 | return 1; |
1616 | } |
1621 | } |
1617 | |
1622 | |
1618 | |
|
|
1619 | /* Move_ball_spell: This handles ball type spells that just sort of wander |
1623 | /* Move_ball_spell: This handles ball type spells that just sort of wander |
1620 | * about. was called move_ball_lightning, but since more than the ball |
1624 | * about. was called move_ball_lightning, but since more than the ball |
1621 | * lightning spell used it, that seemed misnamed. |
1625 | * lightning spell used it, that seemed misnamed. |
1622 | * op is the spell effect. |
1626 | * op is the spell effect. |
1623 | * note that duration is handled by process_object() in time.c |
1627 | * note that duration is handled by process_object() in time.c |
… | |
… | |
1648 | for (i = 1; i < 9; i++) |
1652 | for (i = 1; i < 9; i++) |
1649 | { |
1653 | { |
1650 | /* i bit 0: alters sign of offset |
1654 | /* i bit 0: alters sign of offset |
1651 | * other bits (i / 2): absolute value of offset |
1655 | * other bits (i / 2): absolute value of offset |
1652 | */ |
1656 | */ |
1653 | |
|
|
1654 | int offset = ((i ^ j) & 1) ? (i / 2) : -(i / 2); |
1657 | int offset = ((i ^ j) & 1) ? (i / 2) : -(i / 2); |
1655 | int tmpdir = absdir (op->direction + offset); |
1658 | int tmpdir = absdir (op->direction + offset); |
1656 | |
1659 | |
1657 | nx = op->x + freearr_x[tmpdir]; |
1660 | nx = op->x + freearr_x[tmpdir]; |
1658 | ny = op->y + freearr_y[tmpdir]; |
1661 | ny = op->y + freearr_y[tmpdir]; |
… | |
… | |
1660 | { |
1663 | { |
1661 | dir = tmpdir; |
1664 | dir = tmpdir; |
1662 | break; |
1665 | break; |
1663 | } |
1666 | } |
1664 | } |
1667 | } |
|
|
1668 | |
1665 | if (dir == 0) |
1669 | if (dir == 0) |
1666 | { |
1670 | { |
1667 | nx = op->x; |
1671 | nx = op->x; |
1668 | ny = op->y; |
1672 | ny = op->y; |
1669 | m = op->map; |
1673 | m = op->map; |
… | |
… | |
1890 | int dam, mflags; |
1894 | int dam, mflags; |
1891 | maptile *m; |
1895 | maptile *m; |
1892 | |
1896 | |
1893 | dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1897 | dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1894 | |
1898 | |
1895 | if (!dir) |
1899 | if (dir) |
1896 | { |
|
|
1897 | new_draw_info (NDI_UNIQUE, 0, op, "In what direction?"); |
|
|
1898 | return 0; |
|
|
1899 | } |
1900 | { |
1900 | |
|
|
1901 | x = op->x + freearr_x[dir]; |
1901 | x = op->x + freearr_x[dir]; |
1902 | y = op->y + freearr_y[dir]; |
1902 | y = op->y + freearr_y[dir]; |
1903 | m = op->map; |
1903 | m = op->map; |
1904 | |
1904 | |
1905 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
1905 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
1906 | |
1906 | |
1907 | if (mflags & P_OUT_OF_MAP) |
1907 | if (mflags & P_OUT_OF_MAP) |
1908 | { |
1908 | { |
1909 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing is there."); |
1909 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing is there."); |
1910 | return 0; |
1910 | return 0; |
1911 | } |
1911 | } |
1912 | |
1912 | |
1913 | if (mflags & P_IS_ALIVE && spell->attacktype) |
1913 | if (mflags & P_IS_ALIVE && spell->attacktype) |
1914 | { |
1914 | { |
1915 | for (target = GET_MAP_OB (m, x, y); target; target = target->above) |
1915 | for (target = GET_MAP_OB (m, x, y); target; target = target->above) |
1916 | if (QUERY_FLAG (target, FLAG_MONSTER)) |
1916 | if (QUERY_FLAG (target, FLAG_MONSTER)) |
1917 | { |
1917 | { |
1918 | /* oky doky. got a target monster. Lets make a blinding attack */ |
1918 | /* oky doky. got a target monster. Lets make a blinding attack */ |
1919 | if (target->head) |
1919 | if (target->head) |
1920 | target = target->head; |
1920 | target = target->head; |
1921 | |
1921 | |
1922 | hit_player (target, dam, op, spell->attacktype, 1); |
1922 | hit_player (target, dam, op, spell->attacktype, 1); |
1923 | return 1; /* one success only! */ |
1923 | return 1; /* one success only! */ |
|
|
1924 | } |
1924 | } |
1925 | } |
1925 | } |
|
|
1926 | |
1926 | |
1927 | /* no live target, perhaps a wall is in the way? */ |
1927 | /* no live target, perhaps a wall is in the way? */ |
1928 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, x, y))) |
1928 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, x, y))) |
1929 | { |
1929 | { |
1930 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
1930 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
1931 | return 0; |
1931 | return 0; |
|
|
1932 | } |
1932 | } |
1933 | } |
1933 | |
1934 | |
1934 | /* ok, looks groovy to just insert a new light on the map */ |
1935 | /* ok, looks groovy to just insert a new light on the map */ |
1935 | tmp = arch_to_object (spell->other_arch); |
1936 | tmp = arch_to_object (spell->other_arch); |
1936 | if (!tmp) |
1937 | if (!tmp) |
1937 | { |
1938 | { |
1938 | LOG (llevError, "Error: spell arch for cast_light() missing.\n"); |
1939 | LOG (llevError, "Error: spell arch for cast_light() missing.\n"); |
1939 | return 0; |
1940 | return 0; |
1940 | } |
1941 | } |
|
|
1942 | |
1941 | tmp->stats.food = spell->duration + SP_level_duration_adjust (caster, spell); |
1943 | tmp->stats.food = spell->duration + SP_level_duration_adjust (caster, spell); |
|
|
1944 | |
1942 | if (tmp->glow_radius) |
1945 | if (tmp->glow_radius) |
1943 | { |
|
|
1944 | tmp->glow_radius = spell->range + SP_level_range_adjust (caster, spell); |
1946 | tmp->glow_radius = min (MAX_LIGHT_RADIUS, spell->range + SP_level_range_adjust (caster, spell)); |
1945 | if (tmp->glow_radius > MAX_LIGHT_RADII) |
|
|
1946 | tmp->glow_radius = MAX_LIGHT_RADII; |
|
|
1947 | } |
|
|
1948 | |
1947 | |
|
|
1948 | if (dir) |
1949 | m->insert (tmp, x, y, op); |
1949 | m->insert (tmp, x, y, op); |
|
|
1950 | else |
|
|
1951 | caster->outer_env ()->insert (tmp); |
|
|
1952 | |
1950 | return 1; |
1953 | return 1; |
1951 | } |
1954 | } |
1952 | |
1955 | |
1953 | /* cast_cause_disease: this spell looks along <dir> from the |
1956 | /* cast_cause_disease: this spell looks along <dir> from the |
1954 | * player and infects someone. |
1957 | * player and infects someone. |