… | |
… | |
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; |
… | |
… | |
393 | void |
393 | void |
394 | explode_bullet (object *op) |
394 | explode_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; |
752 | } |
761 | } |
753 | /* Object has hit maximum range, so don't have it move |
762 | /* Object has hit maximum range, so don't have it move |
… | |
… | |
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)) |
… | |
… | |
1112 | effect = arch_to_object (spell->other_arch); |
1121 | effect = arch_to_object (spell->other_arch); |
1113 | else |
1122 | else |
1114 | return 0; |
1123 | return 0; |
1115 | |
1124 | |
1116 | /* tailor the effect by priest level and worshipped God */ |
1125 | /* tailor the effect by priest level and worshipped God */ |
1117 | effect->level = caster_level (caster, spell); |
1126 | effect->level = casting_level (caster, spell); |
1118 | effect->attacktype = spell->attacktype; |
1127 | effect->attacktype = spell->attacktype; |
1119 | if (effect->attacktype & (AT_HOLYWORD | AT_GODPOWER)) |
1128 | if (effect->attacktype & (AT_HOLYWORD | AT_GODPOWER)) |
1120 | { |
1129 | { |
1121 | if (tailor_god_spell (effect, op)) |
1130 | if (tailor_god_spell (effect, op)) |
1122 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s answers your call!", determine_god (op)); |
1131 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s answers your call!", determine_god (op)); |
… | |
… | |
1179 | void |
1188 | void |
1180 | move_missile (object *op) |
1189 | move_missile (object *op) |
1181 | { |
1190 | { |
1182 | if (op->range-- <= 0) |
1191 | if (op->range-- <= 0) |
1183 | { |
1192 | { |
1184 | op->destroy (); |
1193 | op->drop_and_destroy (); |
1185 | return; |
1194 | return; |
1186 | } |
1195 | } |
1187 | |
1196 | |
1188 | mapxy pos (op); |
1197 | mapxy pos (op); |
1189 | pos.move (op->direction); |
1198 | pos.move (op->direction); |
… | |
… | |
1241 | |
1250 | |
1242 | object *tmp = get_archetype (FORCE_NAME); |
1251 | object *tmp = get_archetype (FORCE_NAME); |
1243 | tmp->speed = 0.01; |
1252 | tmp->speed = 0.01; |
1244 | tmp->stats.food = time; |
1253 | tmp->stats.food = time; |
1245 | SET_FLAG (tmp, FLAG_IS_USED_UP); |
1254 | 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; |
1255 | tmp->glow_radius = min (MAX_LIGHT_RADIUS, radius); |
1249 | |
|
|
1250 | tmp = insert_ob_in_ob (tmp, op); |
1256 | tmp = insert_ob_in_ob (tmp, op); |
1251 | |
1257 | |
1252 | if (tmp->glow_radius > op->glow_radius) |
1258 | if (tmp->glow_radius > op->glow_radius) |
1253 | op->glow_radius = tmp->glow_radius; |
1259 | op->glow_radius = tmp->glow_radius; |
1254 | |
1260 | |
… | |
… | |
1451 | |
1457 | |
1452 | /* We precompute some values here so that we don't have to keep |
1458 | /* We precompute some values here so that we don't have to keep |
1453 | * doing it over and over again. |
1459 | * doing it over and over again. |
1454 | */ |
1460 | */ |
1455 | god = find_god (determine_god (op)); |
1461 | god = find_god (determine_god (op)); |
1456 | level = caster_level (caster, spell); |
1462 | level = casting_level (caster, spell); |
1457 | range = spell->range + SP_level_range_adjust (caster, spell); |
1463 | range = spell->range + SP_level_range_adjust (caster, spell); |
1458 | |
1464 | |
1459 | /* On the bright side, no monster should ever have a race of GOD_... |
1465 | /* 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 |
1466 | * so even if the player doesn't worship a god, if race=GOD_.., it |
1461 | * won't ever match anything. |
1467 | * won't ever match anything. |
… | |
… | |
1739 | return; |
1745 | return; |
1740 | } |
1746 | } |
1741 | |
1747 | |
1742 | if (!op->duration || !owner->is_on_map ()) |
1748 | if (!op->duration || !owner->is_on_map ()) |
1743 | { |
1749 | { |
1744 | op->destroy (); |
1750 | op->drop_and_destroy (); |
1745 | return; |
1751 | return; |
1746 | } |
1752 | } |
1747 | |
1753 | |
1748 | op->duration--; |
1754 | op->duration--; |
1749 | |
1755 | |
1750 | int basedir = op->direction; |
1756 | int basedir = op->direction; |
1751 | if (!basedir) |
1757 | if (!basedir) |
|
|
1758 | { |
1752 | /* spray in all directions! 8) */ |
1759 | /* spray in all directions! 8) */ |
1753 | basedir = (op->facing += op->state) % 8 + 1; |
1760 | op->facing = (op->facing + op->state) & 7; |
|
|
1761 | basedir = op->facing + 1; |
|
|
1762 | } |
1754 | |
1763 | |
1755 | #if 0 |
1764 | #if 0 |
1756 | // this is bogus: it causes wrong places to be checked below |
1765 | // this is bogus: it causes wrong places to be checked below |
1757 | // (a wall 2 cells away will block the effect...) and |
1766 | // (a wall 2 cells away will block the effect...) and |
1758 | // doesn't work for SP_BULLET anyhow, so again tests the wrong |
1767 | // doesn't work for SP_BULLET anyhow, so again tests the wrong |
… | |
… | |
1840 | { |
1849 | { |
1841 | if (!spell->other_arch) |
1850 | if (!spell->other_arch) |
1842 | return 0; |
1851 | return 0; |
1843 | |
1852 | |
1844 | object *tmp = archetype::get (SWARM_SPELL); |
1853 | object *tmp = archetype::get (SWARM_SPELL); |
|
|
1854 | |
1845 | set_spell_skill (op, caster, spell, tmp); |
1855 | set_spell_skill (op, caster, spell, tmp); |
1846 | tmp->level = caster_level (caster, spell); /* needed later, to get level dep. right. */ |
1856 | tmp->level = casting_level (caster, spell); /* needed later, to get level dep. right. */ |
1847 | tmp->spell = spell->other_arch->instance (); |
1857 | tmp->spell = spell->other_arch->instance (); |
1848 | tmp->attacktype = tmp->spell->attacktype; |
1858 | tmp->attacktype = tmp->spell->attacktype; |
1849 | |
1859 | |
1850 | if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) |
1860 | if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) |
1851 | if (!tailor_god_spell (tmp, op)) |
1861 | if (!tailor_god_spell (tmp, op)) |
… | |
… | |
1877 | int dam, mflags; |
1887 | int dam, mflags; |
1878 | maptile *m; |
1888 | maptile *m; |
1879 | |
1889 | |
1880 | dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1890 | dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1881 | |
1891 | |
1882 | if (!dir) |
1892 | if (dir) |
1883 | { |
|
|
1884 | new_draw_info (NDI_UNIQUE, 0, op, "In what direction?"); |
|
|
1885 | return 0; |
|
|
1886 | } |
1893 | { |
1887 | |
|
|
1888 | x = op->x + freearr_x[dir]; |
1894 | x = op->x + freearr_x[dir]; |
1889 | y = op->y + freearr_y[dir]; |
1895 | y = op->y + freearr_y[dir]; |
1890 | m = op->map; |
1896 | m = op->map; |
1891 | |
1897 | |
1892 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
1898 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
1893 | |
1899 | |
1894 | if (mflags & P_OUT_OF_MAP) |
1900 | if (mflags & P_OUT_OF_MAP) |
1895 | { |
1901 | { |
1896 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing is there."); |
1902 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing is there."); |
1897 | return 0; |
1903 | return 0; |
1898 | } |
1904 | } |
1899 | |
1905 | |
1900 | if (mflags & P_IS_ALIVE && spell->attacktype) |
1906 | if (mflags & P_IS_ALIVE && spell->attacktype) |
1901 | { |
1907 | { |
1902 | for (target = GET_MAP_OB (m, x, y); target; target = target->above) |
1908 | for (target = GET_MAP_OB (m, x, y); target; target = target->above) |
1903 | if (QUERY_FLAG (target, FLAG_MONSTER)) |
1909 | if (QUERY_FLAG (target, FLAG_MONSTER)) |
1904 | { |
1910 | { |
1905 | /* oky doky. got a target monster. Lets make a blinding attack */ |
1911 | /* oky doky. got a target monster. Lets make a blinding attack */ |
1906 | if (target->head) |
1912 | if (target->head) |
1907 | target = target->head; |
1913 | target = target->head; |
1908 | |
1914 | |
1909 | hit_player (target, dam, op, spell->attacktype, 1); |
1915 | hit_player (target, dam, op, spell->attacktype, 1); |
1910 | return 1; /* one success only! */ |
1916 | return 1; /* one success only! */ |
|
|
1917 | } |
1911 | } |
1918 | } |
1912 | } |
|
|
1913 | |
1919 | |
1914 | /* no live target, perhaps a wall is in the way? */ |
1920 | /* no live target, perhaps a wall is in the way? */ |
1915 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, x, y))) |
1921 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, x, y))) |
1916 | { |
1922 | { |
1917 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
1923 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
1918 | return 0; |
1924 | return 0; |
|
|
1925 | } |
1919 | } |
1926 | } |
1920 | |
1927 | |
1921 | /* ok, looks groovy to just insert a new light on the map */ |
1928 | /* ok, looks groovy to just insert a new light on the map */ |
1922 | tmp = arch_to_object (spell->other_arch); |
1929 | tmp = arch_to_object (spell->other_arch); |
1923 | if (!tmp) |
1930 | if (!tmp) |
1924 | { |
1931 | { |
1925 | LOG (llevError, "Error: spell arch for cast_light() missing.\n"); |
1932 | LOG (llevError, "Error: spell arch for cast_light() missing.\n"); |
1926 | return 0; |
1933 | return 0; |
1927 | } |
1934 | } |
|
|
1935 | |
1928 | tmp->stats.food = spell->duration + SP_level_duration_adjust (caster, spell); |
1936 | tmp->stats.food = spell->duration + SP_level_duration_adjust (caster, spell); |
|
|
1937 | |
1929 | if (tmp->glow_radius) |
1938 | if (tmp->glow_radius) |
1930 | { |
|
|
1931 | tmp->glow_radius = spell->range + SP_level_range_adjust (caster, spell); |
1939 | tmp->glow_radius = min (MAX_LIGHT_RADIUS, spell->range + SP_level_range_adjust (caster, spell)); |
1932 | if (tmp->glow_radius > MAX_LIGHT_RADII) |
|
|
1933 | tmp->glow_radius = MAX_LIGHT_RADII; |
|
|
1934 | } |
|
|
1935 | |
1940 | |
|
|
1941 | if (dir) |
1936 | m->insert (tmp, x, y, op); |
1942 | m->insert (tmp, x, y, op); |
|
|
1943 | else |
|
|
1944 | caster->outer_env ()->insert (tmp); |
|
|
1945 | |
1937 | return 1; |
1946 | return 1; |
1938 | } |
1947 | } |
1939 | |
1948 | |
1940 | /* cast_cause_disease: this spell looks along <dir> from the |
1949 | /* cast_cause_disease: this spell looks along <dir> from the |
1941 | * player and infects someone. |
1950 | * player and infects someone. |
… | |
… | |
1994 | object *disease = arch_to_object (spell->other_arch); |
2003 | object *disease = arch_to_object (spell->other_arch); |
1995 | |
2004 | |
1996 | disease->set_owner (op); |
2005 | disease->set_owner (op); |
1997 | set_spell_skill (op, caster, spell, disease); |
2006 | set_spell_skill (op, caster, spell, disease); |
1998 | disease->stats.exp = 0; |
2007 | disease->stats.exp = 0; |
1999 | disease->level = caster_level (caster, spell); |
2008 | disease->level = casting_level (caster, spell); |
2000 | |
2009 | |
2001 | /* do level adjustments */ |
2010 | /* do level adjustments */ |
2002 | if (disease->stats.wc) |
2011 | if (disease->stats.wc) |
2003 | disease->stats.wc += dur_mod / 2; |
2012 | disease->stats.wc += dur_mod / 2; |
2004 | |
2013 | |