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.62 by root, Mon Jul 14 00:04:57 2008 UTC vs.
Revision 1.73 by root, Sun Dec 28 06:59:27 2008 UTC

165 sint16 x, y; 165 sint16 x, y;
166 maptile *m; 166 maptile *m;
167 167
168 if (--op->duration < 0) 168 if (--op->duration < 0)
169 { 169 {
170 op->destroy (); 170 op->drop_and_destroy ();
171 return; 171 return;
172 } 172 }
173 173
174 hit_map (op, 0, op->attacktype, 1); 174 hit_map (op, 0, op->attacktype, 1);
175 175
307 307
308 maptile *newmap; 308 maptile *newmap;
309 mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y); 309 mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y);
310 if (mflags & P_OUT_OF_MAP) 310 if (mflags & P_OUT_OF_MAP)
311 { 311 {
312 tmp->destroy (); 312 tmp->drop_and_destroy ();
313 return 0; 313 return 0;
314 } 314 }
315 315
316 tmp->map = newmap; 316 tmp->map = newmap;
317 317
318 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) 318 if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y)))
319 { 319 {
320 if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) 320 if (!QUERY_FLAG (tmp, FLAG_REFLECTING))
321 { 321 {
322 tmp->destroy (); 322 tmp->drop_and_destroy ();
323 return 0; 323 return 0;
324 } 324 }
325 325
326 tmp->x = op->x; 326 tmp->x = op->x;
327 tmp->y = op->y; 327 tmp->y = op->y;
393void 393void
394explode_bullet (object *op) 394explode_bullet (object *op)
395{ 395{
396 object *tmp, *owner; 396 object *tmp, *owner;
397 397
398 if (op->other_arch == NULL) 398 if (!op->other_arch)
399 { 399 {
400 LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); 400 LOG (llevError, "BUG: explode_bullet(): op without other_arch\n");
401 op->destroy (); 401 op->destroy ();
402 return; 402 return;
403 } 403 }
445 tmp->set_owner (op); 445 tmp->set_owner (op);
446 tmp->skill = op->skill; 446 tmp->skill = op->skill;
447 447
448 owner = op->owner; 448 owner = op->owner;
449 449
450 if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && !tailor_god_spell (tmp, owner)) 450 if ((tmp->attacktype & AT_HOLYWORD
451 || tmp->attacktype & AT_GODPOWER)
452 && owner
453 && !tailor_god_spell (tmp, owner))
451 { 454 {
452 op->destroy (); 455 op->destroy ();
453 return; 456 return;
454 } 457 }
455 458
521 { 524 {
522 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 525 if (QUERY_FLAG (tmp, FLAG_ALIVE))
523 { 526 {
524 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); 527 dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1);
525 528
529 // TODO: can't understand the following if's
526 if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) 530 if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0)
527 { 531 {
528 if (!QUERY_FLAG (op, FLAG_REMOVED)) 532 if (!QUERY_FLAG (op, FLAG_REMOVED))
529 { 533 {
530 op->destroy (); 534 op->destroy ();
733 } 737 }
734#endif 738#endif
735 739
736 hit_map (op, 0, op->attacktype, 0); 740 hit_map (op, 0, op->attacktype, 0);
737 741
742 if (!op->is_on_map ())
743 return;
744
738 /* Check to see if we should push anything. 745 /* Check to see if we should push anything.
739 * Spell objects with weight push whatever they encounter to some 746 * Spell objects with weight push whatever they encounter to some
740 * degree. 747 * degree.
741 */ 748 */
742 if (op->weight) 749 if (op->weight)
750 {
743 check_spell_knockback (op); 751 check_spell_knockback (op);
744 752
745 if (op->destroyed ()) 753 if (!op->is_on_map ())
746 return; 754 return;
755 }
747 756
748 if (op->duration-- < 0) 757 if (op->duration-- < 0)
749 { 758 {
750 op->destroy (); 759 op->destroy ();
751 return; 760 return;
860 869
861 success = 1; 870 success = 1;
862 tmp = arch_to_object (spell->other_arch); 871 tmp = arch_to_object (spell->other_arch);
863 tmp->set_owner (op); 872 tmp->set_owner (op);
864 set_spell_skill (op, caster, spell, tmp); 873 set_spell_skill (op, caster, spell, tmp);
865 tmp->level = caster_level (caster, spell); 874 tmp->level = casting_level (caster, spell);
866 tmp->attacktype = spell->attacktype; 875 tmp->attacktype = spell->attacktype;
867 876
868 /* holy word stuff */ 877 /* holy word stuff */
869 if ((tmp->attacktype & AT_HOLYWORD) || (tmp->attacktype & AT_GODPOWER)) 878 if ((tmp->attacktype & AT_HOLYWORD) || (tmp->attacktype & AT_GODPOWER))
870 if (!tailor_god_spell (tmp, op)) 879 if (!tailor_god_spell (tmp, op))
999 int mflags; 1008 int mflags;
1000 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];
1001 maptile *m; 1010 maptile *m;
1002 1011
1003 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 {
1004 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))
1005 { 1021 {
1006 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.");
1007 return 0; 1023 return 0;
1024 }
1008 } 1025 }
1009 1026
1010 tmp = arch_to_object (spell->other_arch); 1027 tmp = arch_to_object (spell->other_arch);
1011 1028
1012 /* level dependencies for bomb */ 1029 /* level dependencies for bomb */
1112 effect = arch_to_object (spell->other_arch); 1129 effect = arch_to_object (spell->other_arch);
1113 else 1130 else
1114 return 0; 1131 return 0;
1115 1132
1116 /* tailor the effect by priest level and worshipped God */ 1133 /* tailor the effect by priest level and worshipped God */
1117 effect->level = caster_level (caster, spell); 1134 effect->level = casting_level (caster, spell);
1118 effect->attacktype = spell->attacktype; 1135 effect->attacktype = spell->attacktype;
1119 if (effect->attacktype & (AT_HOLYWORD | AT_GODPOWER)) 1136 if (effect->attacktype & (AT_HOLYWORD | AT_GODPOWER))
1120 { 1137 {
1121 if (tailor_god_spell (effect, op)) 1138 if (tailor_god_spell (effect, op))
1122 new_draw_info_format (NDI_UNIQUE, 0, op, "%s answers your call!", determine_god (op)); 1139 new_draw_info_format (NDI_UNIQUE, 0, op, "%s answers your call!", determine_god (op));
1179void 1196void
1180move_missile (object *op) 1197move_missile (object *op)
1181{ 1198{
1182 if (op->range-- <= 0) 1199 if (op->range-- <= 0)
1183 { 1200 {
1184 op->destroy (); 1201 op->drop_and_destroy ();
1185 return; 1202 return;
1186 } 1203 }
1187 1204
1188 mapxy pos (op); 1205 mapxy pos (op);
1189 pos.move (op->direction); 1206 pos.move (op->direction);
1241 1258
1242 object *tmp = get_archetype (FORCE_NAME); 1259 object *tmp = get_archetype (FORCE_NAME);
1243 tmp->speed = 0.01; 1260 tmp->speed = 0.01;
1244 tmp->stats.food = time; 1261 tmp->stats.food = time;
1245 SET_FLAG (tmp, FLAG_IS_USED_UP); 1262 SET_FLAG (tmp, FLAG_IS_USED_UP);
1246 tmp->glow_radius = radius;
1247 if (tmp->glow_radius > MAX_LIGHT_RADII)
1248 tmp->glow_radius = MAX_LIGHT_RADII; 1263 tmp->glow_radius = min (MAX_LIGHT_RADIUS, radius);
1249
1250 tmp = insert_ob_in_ob (tmp, op); 1264 tmp = insert_ob_in_ob (tmp, op);
1251 1265
1252 if (tmp->glow_radius > op->glow_radius) 1266 if (tmp->glow_radius > op->glow_radius)
1253 op->glow_radius = tmp->glow_radius; 1267 op->glow_radius = tmp->glow_radius;
1254 1268
1451 1465
1452 /* We precompute some values here so that we don't have to keep 1466 /* We precompute some values here so that we don't have to keep
1453 * doing it over and over again. 1467 * doing it over and over again.
1454 */ 1468 */
1455 god = find_god (determine_god (op)); 1469 god = find_god (determine_god (op));
1456 level = caster_level (caster, spell); 1470 level = casting_level (caster, spell);
1457 range = spell->range + SP_level_range_adjust (caster, spell); 1471 range = spell->range + SP_level_range_adjust (caster, spell);
1458 1472
1459 /* On the bright side, no monster should ever have a race of GOD_... 1473 /* On the bright side, no monster should ever have a race of GOD_...
1460 * so even if the player doesn't worship a god, if race=GOD_.., it 1474 * so even if the player doesn't worship a god, if race=GOD_.., it
1461 * won't ever match anything. 1475 * won't ever match anything.
1483 /* 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 */
1484 if (!(mflags & P_IS_ALIVE)) 1498 if (!(mflags & P_IS_ALIVE))
1485 continue; 1499 continue;
1486 1500
1487 // players can only affect spaces that they can actually see 1501 // players can only affect spaces that they can actually see
1502 if (caster
1488 if (caster && caster->contr 1503 && caster->contr
1489 && caster->contr->visibility_at (m, nx, ny) < 70) 1504 && caster->contr->darkness_at (m, nx, ny) == LOS_BLOCKED)
1490 continue; 1505 continue;
1491 1506
1492 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)
1493 if (QUERY_FLAG (tmp, FLAG_MONSTER)) 1508 if (QUERY_FLAG (tmp, FLAG_MONSTER))
1494 break; 1509 break;
1604 } /* for y */ 1619 } /* for y */
1605 1620
1606 return 1; 1621 return 1;
1607} 1622}
1608 1623
1609
1610/* 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
1611 * 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
1612 * lightning spell used it, that seemed misnamed. 1626 * lightning spell used it, that seemed misnamed.
1613 * op is the spell effect. 1627 * op is the spell effect.
1614 * note that duration is handled by process_object() in time.c 1628 * note that duration is handled by process_object() in time.c
1639 for (i = 1; i < 9; i++) 1653 for (i = 1; i < 9; i++)
1640 { 1654 {
1641 /* i bit 0: alters sign of offset 1655 /* i bit 0: alters sign of offset
1642 * other bits (i / 2): absolute value of offset 1656 * other bits (i / 2): absolute value of offset
1643 */ 1657 */
1644
1645 int offset = ((i ^ j) & 1) ? (i / 2) : -(i / 2); 1658 int offset = ((i ^ j) & 1) ? (i / 2) : -(i / 2);
1646 int tmpdir = absdir (op->direction + offset); 1659 int tmpdir = absdir (op->direction + offset);
1647 1660
1648 nx = op->x + freearr_x[tmpdir]; 1661 nx = op->x + freearr_x[tmpdir];
1649 ny = op->y + freearr_y[tmpdir]; 1662 ny = op->y + freearr_y[tmpdir];
1651 { 1664 {
1652 dir = tmpdir; 1665 dir = tmpdir;
1653 break; 1666 break;
1654 } 1667 }
1655 } 1668 }
1669
1656 if (dir == 0) 1670 if (dir == 0)
1657 { 1671 {
1658 nx = op->x; 1672 nx = op->x;
1659 ny = op->y; 1673 ny = op->y;
1660 m = op->map; 1674 m = op->map;
1739 return; 1753 return;
1740 } 1754 }
1741 1755
1742 if (!op->duration || !owner->is_on_map ()) 1756 if (!op->duration || !owner->is_on_map ())
1743 { 1757 {
1744 op->destroy (); 1758 op->drop_and_destroy ();
1745 return; 1759 return;
1746 } 1760 }
1747 1761
1748 op->duration--; 1762 op->duration--;
1749 1763
1845 return 0; 1859 return 0;
1846 1860
1847 object *tmp = archetype::get (SWARM_SPELL); 1861 object *tmp = archetype::get (SWARM_SPELL);
1848 1862
1849 set_spell_skill (op, caster, spell, tmp); 1863 set_spell_skill (op, caster, spell, tmp);
1850 tmp->level = caster_level (caster, spell); /* needed later, to get level dep. right. */ 1864 tmp->level = casting_level (caster, spell); /* needed later, to get level dep. right. */
1851 tmp->spell = spell->other_arch->instance (); 1865 tmp->spell = spell->other_arch->instance ();
1852 tmp->attacktype = tmp->spell->attacktype; 1866 tmp->attacktype = tmp->spell->attacktype;
1853 1867
1854 if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) 1868 if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER)
1855 if (!tailor_god_spell (tmp, op)) 1869 if (!tailor_god_spell (tmp, op))
1881 int dam, mflags; 1895 int dam, mflags;
1882 maptile *m; 1896 maptile *m;
1883 1897
1884 dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 1898 dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
1885 1899
1886 if (!dir) 1900 if (dir)
1887 {
1888 new_draw_info (NDI_UNIQUE, 0, op, "In what direction?");
1889 return 0;
1890 } 1901 {
1891
1892 x = op->x + freearr_x[dir]; 1902 x = op->x + freearr_x[dir];
1893 y = op->y + freearr_y[dir]; 1903 y = op->y + freearr_y[dir];
1894 m = op->map; 1904 m = op->map;
1895 1905
1896 mflags = get_map_flags (m, &m, x, y, &x, &y); 1906 mflags = get_map_flags (m, &m, x, y, &x, &y);
1897 1907
1898 if (mflags & P_OUT_OF_MAP) 1908 if (mflags & P_OUT_OF_MAP)
1899 { 1909 {
1900 new_draw_info (NDI_UNIQUE, 0, op, "Nothing is there."); 1910 new_draw_info (NDI_UNIQUE, 0, op, "Nothing is there.");
1901 return 0; 1911 return 0;
1902 } 1912 }
1903 1913
1904 if (mflags & P_IS_ALIVE && spell->attacktype) 1914 if (mflags & P_IS_ALIVE && spell->attacktype)
1905 { 1915 {
1906 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)
1907 if (QUERY_FLAG (target, FLAG_MONSTER)) 1917 if (QUERY_FLAG (target, FLAG_MONSTER))
1908 { 1918 {
1909 /* oky doky. got a target monster. Lets make a blinding attack */ 1919 /* oky doky. got a target monster. Lets make a blinding attack */
1910 if (target->head) 1920 if (target->head)
1911 target = target->head; 1921 target = target->head;
1912 1922
1913 hit_player (target, dam, op, spell->attacktype, 1); 1923 hit_player (target, dam, op, spell->attacktype, 1);
1914 return 1; /* one success only! */ 1924 return 1; /* one success only! */
1925 }
1915 } 1926 }
1916 }
1917 1927
1918 /* no live target, perhaps a wall is in the way? */ 1928 /* no live target, perhaps a wall is in the way? */
1919 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)))
1920 { 1930 {
1921 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.");
1922 return 0; 1932 return 0;
1933 }
1923 } 1934 }
1924 1935
1925 /* 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 */
1926 tmp = arch_to_object (spell->other_arch); 1937 tmp = arch_to_object (spell->other_arch);
1927 if (!tmp) 1938 if (!tmp)
1928 { 1939 {
1929 LOG (llevError, "Error: spell arch for cast_light() missing.\n"); 1940 LOG (llevError, "Error: spell arch for cast_light() missing.\n");
1930 return 0; 1941 return 0;
1931 } 1942 }
1943
1932 tmp->stats.food = spell->duration + SP_level_duration_adjust (caster, spell); 1944 tmp->stats.food = spell->duration + SP_level_duration_adjust (caster, spell);
1945
1933 if (tmp->glow_radius) 1946 if (tmp->glow_radius)
1934 {
1935 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));
1936 if (tmp->glow_radius > MAX_LIGHT_RADII)
1937 tmp->glow_radius = MAX_LIGHT_RADII;
1938 }
1939 1948
1949 if (dir)
1940 m->insert (tmp, x, y, op); 1950 m->insert (tmp, x, y, op);
1951 else
1952 caster->outer_env ()->insert (tmp);
1953
1941 return 1; 1954 return 1;
1942} 1955}
1943 1956
1944/* cast_cause_disease: this spell looks along <dir> from the 1957/* cast_cause_disease: this spell looks along <dir> from the
1945 * player and infects someone. 1958 * player and infects someone.
1998 object *disease = arch_to_object (spell->other_arch); 2011 object *disease = arch_to_object (spell->other_arch);
1999 2012
2000 disease->set_owner (op); 2013 disease->set_owner (op);
2001 set_spell_skill (op, caster, spell, disease); 2014 set_spell_skill (op, caster, spell, disease);
2002 disease->stats.exp = 0; 2015 disease->stats.exp = 0;
2003 disease->level = caster_level (caster, spell); 2016 disease->level = casting_level (caster, spell);
2004 2017
2005 /* do level adjustments */ 2018 /* do level adjustments */
2006 if (disease->stats.wc) 2019 if (disease->stats.wc)
2007 disease->stats.wc += dur_mod / 2; 2020 disease->stats.wc += dur_mod / 2;
2008 2021

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines