1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002-2003,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002-2003,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
620 | int mflags; |
620 | int mflags; |
621 | |
621 | |
622 | if (!spob->other_arch) |
622 | if (!spob->other_arch) |
623 | return 0; |
623 | return 0; |
624 | |
624 | |
625 | tmp = arch_to_object (spob->other_arch); |
625 | tmp = spob->other_arch->instance (); |
626 | if (tmp == NULL) |
626 | if (!tmp) |
627 | return 0; |
627 | return 0; |
628 | |
628 | |
629 | /* peterm: level dependency for bolts */ |
629 | /* peterm: level dependency for bolts */ |
630 | tmp->stats.dam = spob->stats.dam + SP_level_dam_adjust (caster, spob); |
630 | tmp->stats.dam = spob->stats.dam + SP_level_dam_adjust (caster, spob); |
631 | tmp->attacktype = spob->attacktype; |
631 | tmp->attacktype = spob->attacktype; |
632 | if (spob->slaying) |
632 | if (spob->slaying) |
633 | tmp->slaying = spob->slaying; |
633 | tmp->slaying = spob->slaying; |
634 | |
634 | |
… | |
… | |
644 | SET_ANIMATION (tmp, dir); |
644 | SET_ANIMATION (tmp, dir); |
645 | |
645 | |
646 | tmp->set_owner (op); |
646 | tmp->set_owner (op); |
647 | set_spell_skill (op, caster, spob, tmp); |
647 | set_spell_skill (op, caster, spob, tmp); |
648 | |
648 | |
649 | tmp->x = op->x + freearr_x[dir]; |
649 | tmp->x = op->x + freearr_x[dir]; |
650 | tmp->y = op->y + freearr_y[dir]; |
650 | tmp->y = op->y + freearr_y[dir]; |
651 | tmp->map = op->map; |
651 | tmp->map = op->map; |
652 | |
652 | |
653 | maptile *newmap; |
653 | maptile *newmap; |
654 | mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y); |
654 | mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y); |
655 | if (mflags & P_OUT_OF_MAP) |
655 | if (mflags & P_OUT_OF_MAP) |
… | |
… | |
948 | if (op->env) |
948 | if (op->env) |
949 | { |
949 | { |
950 | if (env->map == NULL) |
950 | if (env->map == NULL) |
951 | return; |
951 | return; |
952 | |
952 | |
953 | if (env->type == PLAYER) |
|
|
954 | esrv_del_item (env->contr, op->count); |
|
|
955 | |
|
|
956 | if (!(op = op->insert_at (env, op))) |
953 | if (!(op = op->insert_at (env, op))) |
957 | return; |
954 | return; |
958 | } |
955 | } |
959 | |
956 | |
960 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding |
957 | // elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding |
… | |
… | |
999 | } |
996 | } |
1000 | |
997 | |
1001 | int |
998 | int |
1002 | create_bomb (object *op, object *caster, int dir, object *spell) |
999 | create_bomb (object *op, object *caster, int dir, object *spell) |
1003 | { |
1000 | { |
1004 | |
|
|
1005 | object *tmp; |
1001 | object *tmp; |
1006 | int mflags; |
1002 | int mflags; |
1007 | sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir]; |
1003 | sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir]; |
1008 | maptile *m; |
1004 | maptile *m; |
1009 | |
1005 | |
… | |
… | |
1011 | if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK)) |
1007 | if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK)) |
1012 | { |
1008 | { |
1013 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
1009 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
1014 | return 0; |
1010 | return 0; |
1015 | } |
1011 | } |
|
|
1012 | |
1016 | tmp = arch_to_object (spell->other_arch); |
1013 | tmp = arch_to_object (spell->other_arch); |
1017 | |
1014 | |
1018 | /* level dependencies for bomb */ |
1015 | /* level dependencies for bomb */ |
1019 | tmp->range = spell->range + SP_level_range_adjust (caster, spell); |
1016 | tmp->range = spell->range + SP_level_range_adjust (caster, spell); |
1020 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1017 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
… | |
… | |
1601 | } |
1598 | } |
1602 | |
1599 | |
1603 | /* charm */ |
1600 | /* charm */ |
1604 | if (QUERY_FLAG (spell, FLAG_NO_ATTACK) && !QUERY_FLAG (head, FLAG_FRIENDLY)) |
1601 | if (QUERY_FLAG (spell, FLAG_NO_ATTACK) && !QUERY_FLAG (head, FLAG_FRIENDLY)) |
1605 | { |
1602 | { |
|
|
1603 | INVOKE_OBJECT (KILL, head, ARG_OBJECT (caster)); |
|
|
1604 | |
1606 | /* Prevent uncontolled outbreaks of self replicating monsters. |
1605 | /* Prevent uncontrolled outbreaks of self replicating monsters. |
1607 | Typical use case is charm, go somwhere, use aggravation to make hostile. |
1606 | Typical use case is charm, go somwhere, use aggravation to make hostile. |
1608 | This could lead to fun stuff like mice outbreak in bigworld and server crawl. */ |
1607 | This could lead to fun stuff like mice outbreak in bigworld and server crawl. */ |
1609 | CLEAR_FLAG (head, FLAG_GENERATOR); |
1608 | CLEAR_FLAG (head, FLAG_GENERATOR); |
1610 | head->set_owner (op); |
1609 | head->set_owner (op); |
1611 | set_spell_skill (op, caster, spell, head); |
1610 | set_spell_skill (op, caster, spell, head); |
… | |
… | |
1730 | |
1729 | |
1731 | op->direction = i; |
1730 | op->direction = i; |
1732 | } |
1731 | } |
1733 | } |
1732 | } |
1734 | |
1733 | |
1735 | |
|
|
1736 | /* move_swarm_spell: peterm |
1734 | /* move_swarm_spell: peterm |
1737 | * This is an implementation of the swarm spell. It was written for |
1735 | * This is an implementation of the swarm spell. It was written for |
1738 | * meteor swarm, but it could be used for any swarm. A swarm spell |
1736 | * meteor swarm, but it could be used for any swarm. A swarm spell |
1739 | * is a special type of object that casts swarms of other types |
1737 | * is a special type of object that casts swarms of other types |
1740 | * of spells. Which spell it casts is flexible. It fires the spells |
1738 | * of spells. Which spell it casts is flexible. It fires the spells |
1741 | * from a set of squares surrounding the caster, in a given direction. |
1739 | * from a set of squares surrounding the caster, in a given direction. |
1742 | */ |
1740 | */ |
1743 | |
|
|
1744 | void |
1741 | void |
1745 | move_swarm_spell (object *op) |
1742 | move_swarm_spell (object *op) |
1746 | { |
1743 | { |
1747 | #if 0 |
1744 | #if 0 |
1748 | static int cardinal_adjust[9] = { -3, -2, -1, 0, 0, 0, 1, 2, 3 }; |
1745 | static int cardinal_adjust[9] = { -3, -2, -1, 0, 0, 0, 1, 2, 3 }; |
1749 | static int diagonal_adjust[10] = { -3, -2, -2, -1, 0, 0, 1, 2, 2, 3 }; |
1746 | static int diagonal_adjust[10] = { -3, -2, -2, -1, 0, 0, 1, 2, 2, 3 }; |
1750 | sint16 target_x, target_y, origin_x, origin_y; |
1747 | sint16 target_x, target_y, origin_x, origin_y; |
1751 | int adjustdir; |
1748 | int adjustdir; |
1752 | maptile *m; |
1749 | maptile *m; |
1753 | #endif |
1750 | #endif |
1754 | int basedir; |
|
|
1755 | object *owner; |
1751 | object *owner = op->env; |
1756 | |
1752 | |
1757 | owner = op->owner; |
1753 | if (!op->duration || !owner->is_on_map ()) |
1758 | if (op->duration == 0 || owner == NULL) |
|
|
1759 | { |
1754 | { |
1760 | op->destroy (); |
1755 | op->destroy (); |
1761 | return; |
1756 | return; |
1762 | } |
1757 | } |
1763 | |
1758 | |
1764 | op->duration--; |
1759 | op->duration--; |
1765 | |
1760 | |
1766 | basedir = op->direction; |
1761 | int basedir = op->direction; |
1767 | if (basedir == 0) |
1762 | if (!basedir) |
1768 | { |
|
|
1769 | /* spray in all directions! 8) */ |
1763 | /* spray in all directions! 8) */ |
1770 | basedir = rndm (1, 8); |
1764 | basedir = rndm (1, 8); |
1771 | } |
|
|
1772 | |
1765 | |
1773 | #if 0 |
1766 | #if 0 |
1774 | // this is bogus: it causes wrong places to be checked below |
1767 | // this is bogus: it causes wrong places to be checked below |
1775 | // (a wall 2 cells away will block the effect...) and |
1768 | // (a wall 2 cells away will block the effect...) and |
1776 | // doesn't work for SP_BULLET anyhow, so again tests the wrong |
1769 | // doesn't work for SP_BULLET anyhow, so again tests the wrong |
… | |
… | |
1839 | fire_bullet (owner, op, basedir, op->spell); |
1832 | fire_bullet (owner, op, basedir, op->spell); |
1840 | else if (op->spell->subtype == SP_MAGIC_MISSILE) |
1833 | else if (op->spell->subtype == SP_MAGIC_MISSILE) |
1841 | fire_arch_from_position (owner, op, op->x, op->y, basedir, op->spell); |
1834 | fire_arch_from_position (owner, op, op->x, op->y, basedir, op->spell); |
1842 | } |
1835 | } |
1843 | } |
1836 | } |
1844 | |
|
|
1845 | |
|
|
1846 | |
|
|
1847 | |
1837 | |
1848 | /* fire_swarm: |
1838 | /* fire_swarm: |
1849 | * The following routine creates a swarm of objects. It actually |
1839 | * The following routine creates a swarm of objects. It actually |
1850 | * sets up a specific swarm object, which then fires off all |
1840 | * sets up a specific swarm object, which then fires off all |
1851 | * the parts of the swarm. |
1841 | * the parts of the swarm. |
… | |
… | |
1854 | * caster: the caster (owner, wand, rod, scroll) |
1844 | * caster: the caster (owner, wand, rod, scroll) |
1855 | * dir: the direction everything will be fired in |
1845 | * dir: the direction everything will be fired in |
1856 | * spell - the spell that is this spell. |
1846 | * spell - the spell that is this spell. |
1857 | * n: the number to be fired. |
1847 | * n: the number to be fired. |
1858 | */ |
1848 | */ |
1859 | |
|
|
1860 | int |
1849 | int |
1861 | fire_swarm (object *op, object *caster, object *spell, int dir) |
1850 | fire_swarm (object *op, object *caster, object *spell, int dir) |
1862 | { |
1851 | { |
1863 | object *tmp; |
|
|
1864 | int i; |
|
|
1865 | |
|
|
1866 | if (!spell->other_arch) |
1852 | if (!spell->other_arch) |
1867 | return 0; |
1853 | return 0; |
1868 | |
1854 | |
1869 | tmp = get_archetype (SWARM_SPELL); |
1855 | object *tmp = archetype::get (SWARM_SPELL); |
1870 | tmp->set_owner (op); /* needed so that if swarm elements kill, caster gets xp. */ |
|
|
1871 | set_spell_skill (op, caster, spell, tmp); |
1856 | set_spell_skill (op, caster, spell, tmp); |
1872 | |
|
|
1873 | tmp->level = caster_level (caster, spell); /*needed later, to get level dep. right. */ |
1857 | tmp->level = caster_level (caster, spell); /* needed later, to get level dep. right. */ |
1874 | tmp->spell = arch_to_object (spell->other_arch); |
1858 | tmp->spell = spell->other_arch->instance (); |
1875 | |
|
|
1876 | tmp->attacktype = tmp->spell->attacktype; |
1859 | tmp->attacktype = tmp->spell->attacktype; |
1877 | |
1860 | |
1878 | if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) |
1861 | if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) |
1879 | if (!tailor_god_spell (tmp, op)) |
1862 | if (!tailor_god_spell (tmp, op)) |
1880 | return 1; |
1863 | return 1; |
1881 | |
1864 | |
1882 | tmp->duration = SP_level_duration_adjust (caster, spell); |
1865 | tmp->duration = SP_level_duration_adjust (caster, spell); |
1883 | for (i = 0; i < spell->duration; i++) |
1866 | for (int i = 0; i < spell->duration; i++) |
1884 | tmp->duration += die_roll (1, 3, op, PREFER_HIGH); |
1867 | tmp->duration += die_roll (1, 3, op, PREFER_HIGH); |
1885 | |
1868 | |
1886 | tmp->direction = dir; |
1869 | tmp->direction = dir; |
1887 | tmp->invisible = 1; |
1870 | tmp->invisible = 1; |
1888 | |
1871 | |
1889 | tmp->insert_at (op, op); |
1872 | op->insert (tmp); |
|
|
1873 | |
1890 | return 1; |
1874 | return 1; |
1891 | } |
1875 | } |
1892 | |
|
|
1893 | |
1876 | |
1894 | /* See the spells documentation file for why this is its own |
1877 | /* See the spells documentation file for why this is its own |
1895 | * function. |
1878 | * function. |
1896 | */ |
1879 | */ |
1897 | int |
1880 | int |