ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/spell_attack.C
(Generate patch)

Comparing deliantra/server/server/spell_attack.C (file contents):
Revision 1.67 by root, Mon Sep 29 10:32:50 2008 UTC vs.
Revision 1.73 by root, Sun Dec 28 06:59:27 2008 UTC

737 } 737 }
738#endif 738#endif
739 739
740 hit_map (op, 0, op->attacktype, 0); 740 hit_map (op, 0, op->attacktype, 0);
741 741
742 if (!op->is_on_map ())
743 return;
744
742 /* Check to see if we should push anything. 745 /* Check to see if we should push anything.
743 * Spell objects with weight push whatever they encounter to some 746 * Spell objects with weight push whatever they encounter to some
744 * degree. 747 * degree.
745 */ 748 */
746 if (op->weight) 749 if (op->weight)
750 {
747 check_spell_knockback (op); 751 check_spell_knockback (op);
748 752
749 if (op->destroyed ()) 753 if (!op->is_on_map ())
750 return; 754 return;
755 }
751 756
752 if (op->duration-- < 0) 757 if (op->duration-- < 0)
753 { 758 {
754 op->destroy (); 759 op->destroy ();
755 return; 760 return;
1003 int mflags; 1008 int mflags;
1004 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];
1005 maptile *m; 1010 maptile *m;
1006 1011
1007 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 {
1008 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))
1009 { 1021 {
1010 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.");
1011 return 0; 1023 return 0;
1024 }
1012 } 1025 }
1013 1026
1014 tmp = arch_to_object (spell->other_arch); 1027 tmp = arch_to_object (spell->other_arch);
1015 1028
1016 /* level dependencies for bomb */ 1029 /* level dependencies for bomb */
1245 1258
1246 object *tmp = get_archetype (FORCE_NAME); 1259 object *tmp = get_archetype (FORCE_NAME);
1247 tmp->speed = 0.01; 1260 tmp->speed = 0.01;
1248 tmp->stats.food = time; 1261 tmp->stats.food = time;
1249 SET_FLAG (tmp, FLAG_IS_USED_UP); 1262 SET_FLAG (tmp, FLAG_IS_USED_UP);
1250 tmp->glow_radius = radius;
1251 if (tmp->glow_radius > MAX_LIGHT_RADII)
1252 tmp->glow_radius = MAX_LIGHT_RADII; 1263 tmp->glow_radius = min (MAX_LIGHT_RADIUS, radius);
1253
1254 tmp = insert_ob_in_ob (tmp, op); 1264 tmp = insert_ob_in_ob (tmp, op);
1255 1265
1256 if (tmp->glow_radius > op->glow_radius) 1266 if (tmp->glow_radius > op->glow_radius)
1257 op->glow_radius = tmp->glow_radius; 1267 op->glow_radius = tmp->glow_radius;
1258 1268
1487 /* If there is nothing living on this space, no need to go further */ 1497 /* If there is nothing living on this space, no need to go further */
1488 if (!(mflags & P_IS_ALIVE)) 1498 if (!(mflags & P_IS_ALIVE))
1489 continue; 1499 continue;
1490 1500
1491 // players can only affect spaces that they can actually see 1501 // players can only affect spaces that they can actually see
1502 if (caster
1492 if (caster && caster->contr 1503 && caster->contr
1493 && caster->contr->visibility_at (m, nx, ny) < 70) 1504 && caster->contr->darkness_at (m, nx, ny) == LOS_BLOCKED)
1494 continue; 1505 continue;
1495 1506
1496 for (tmp = GET_MAP_TOP (m, nx, ny); tmp; tmp = tmp->below) 1507 for (tmp = GET_MAP_TOP (m, nx, ny); tmp; tmp = tmp->below)
1497 if (QUERY_FLAG (tmp, FLAG_MONSTER)) 1508 if (QUERY_FLAG (tmp, FLAG_MONSTER))
1498 break; 1509 break;
1608 } /* for y */ 1619 } /* for y */
1609 1620
1610 return 1; 1621 return 1;
1611} 1622}
1612 1623
1613
1614/* Move_ball_spell: This handles ball type spells that just sort of wander 1624/* Move_ball_spell: This handles ball type spells that just sort of wander
1615 * about. was called move_ball_lightning, but since more than the ball 1625 * about. was called move_ball_lightning, but since more than the ball
1616 * lightning spell used it, that seemed misnamed. 1626 * lightning spell used it, that seemed misnamed.
1617 * op is the spell effect. 1627 * op is the spell effect.
1618 * note that duration is handled by process_object() in time.c 1628 * note that duration is handled by process_object() in time.c
1643 for (i = 1; i < 9; i++) 1653 for (i = 1; i < 9; i++)
1644 { 1654 {
1645 /* i bit 0: alters sign of offset 1655 /* i bit 0: alters sign of offset
1646 * other bits (i / 2): absolute value of offset 1656 * other bits (i / 2): absolute value of offset
1647 */ 1657 */
1648
1649 int offset = ((i ^ j) & 1) ? (i / 2) : -(i / 2); 1658 int offset = ((i ^ j) & 1) ? (i / 2) : -(i / 2);
1650 int tmpdir = absdir (op->direction + offset); 1659 int tmpdir = absdir (op->direction + offset);
1651 1660
1652 nx = op->x + freearr_x[tmpdir]; 1661 nx = op->x + freearr_x[tmpdir];
1653 ny = op->y + freearr_y[tmpdir]; 1662 ny = op->y + freearr_y[tmpdir];
1655 { 1664 {
1656 dir = tmpdir; 1665 dir = tmpdir;
1657 break; 1666 break;
1658 } 1667 }
1659 } 1668 }
1669
1660 if (dir == 0) 1670 if (dir == 0)
1661 { 1671 {
1662 nx = op->x; 1672 nx = op->x;
1663 ny = op->y; 1673 ny = op->y;
1664 m = op->map; 1674 m = op->map;
1885 int dam, mflags; 1895 int dam, mflags;
1886 maptile *m; 1896 maptile *m;
1887 1897
1888 dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 1898 dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
1889 1899
1890 if (!dir) 1900 if (dir)
1891 {
1892 new_draw_info (NDI_UNIQUE, 0, op, "In what direction?");
1893 return 0;
1894 } 1901 {
1895
1896 x = op->x + freearr_x[dir]; 1902 x = op->x + freearr_x[dir];
1897 y = op->y + freearr_y[dir]; 1903 y = op->y + freearr_y[dir];
1898 m = op->map; 1904 m = op->map;
1899 1905
1900 mflags = get_map_flags (m, &m, x, y, &x, &y); 1906 mflags = get_map_flags (m, &m, x, y, &x, &y);
1901 1907
1902 if (mflags & P_OUT_OF_MAP) 1908 if (mflags & P_OUT_OF_MAP)
1903 { 1909 {
1904 new_draw_info (NDI_UNIQUE, 0, op, "Nothing is there."); 1910 new_draw_info (NDI_UNIQUE, 0, op, "Nothing is there.");
1905 return 0; 1911 return 0;
1906 } 1912 }
1907 1913
1908 if (mflags & P_IS_ALIVE && spell->attacktype) 1914 if (mflags & P_IS_ALIVE && spell->attacktype)
1909 { 1915 {
1910 for (target = GET_MAP_OB (m, x, y); target; target = target->above) 1916 for (target = GET_MAP_OB (m, x, y); target; target = target->above)
1911 if (QUERY_FLAG (target, FLAG_MONSTER)) 1917 if (QUERY_FLAG (target, FLAG_MONSTER))
1912 { 1918 {
1913 /* oky doky. got a target monster. Lets make a blinding attack */ 1919 /* oky doky. got a target monster. Lets make a blinding attack */
1914 if (target->head) 1920 if (target->head)
1915 target = target->head; 1921 target = target->head;
1916 1922
1917 hit_player (target, dam, op, spell->attacktype, 1); 1923 hit_player (target, dam, op, spell->attacktype, 1);
1918 return 1; /* one success only! */ 1924 return 1; /* one success only! */
1925 }
1919 } 1926 }
1920 }
1921 1927
1922 /* no live target, perhaps a wall is in the way? */ 1928 /* no live target, perhaps a wall is in the way? */
1923 if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, x, y))) 1929 if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, x, y)))
1924 { 1930 {
1925 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); 1931 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way.");
1926 return 0; 1932 return 0;
1933 }
1927 } 1934 }
1928 1935
1929 /* ok, looks groovy to just insert a new light on the map */ 1936 /* ok, looks groovy to just insert a new light on the map */
1930 tmp = arch_to_object (spell->other_arch); 1937 tmp = arch_to_object (spell->other_arch);
1931 if (!tmp) 1938 if (!tmp)
1932 { 1939 {
1933 LOG (llevError, "Error: spell arch for cast_light() missing.\n"); 1940 LOG (llevError, "Error: spell arch for cast_light() missing.\n");
1934 return 0; 1941 return 0;
1935 } 1942 }
1943
1936 tmp->stats.food = spell->duration + SP_level_duration_adjust (caster, spell); 1944 tmp->stats.food = spell->duration + SP_level_duration_adjust (caster, spell);
1945
1937 if (tmp->glow_radius) 1946 if (tmp->glow_radius)
1938 {
1939 tmp->glow_radius = spell->range + SP_level_range_adjust (caster, spell); 1947 tmp->glow_radius = min (MAX_LIGHT_RADIUS, spell->range + SP_level_range_adjust (caster, spell));
1940 if (tmp->glow_radius > MAX_LIGHT_RADII)
1941 tmp->glow_radius = MAX_LIGHT_RADII;
1942 }
1943 1948
1949 if (dir)
1944 m->insert (tmp, x, y, op); 1950 m->insert (tmp, x, y, op);
1951 else
1952 caster->outer_env ()->insert (tmp);
1953
1945 return 1; 1954 return 1;
1946} 1955}
1947 1956
1948/* cast_cause_disease: this spell looks along <dir> from the 1957/* cast_cause_disease: this spell looks along <dir> from the
1949 * player and infects someone. 1958 * player and infects someone.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines