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

Comparing deliantra/server/server/spell_effect.C (file contents):
Revision 1.145 by root, Wed Nov 16 23:42:03 2016 UTC vs.
Revision 1.148 by root, Sat Nov 17 23:40:04 2018 UTC

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 (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team
4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 5 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team 6 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 Frank Tore Johansen 7 * Copyright (©) 1992 Frank Tore Johansen
7 * 8 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 9 * Deliantra is free software: you can redistribute it and/or modify it under
293 } 294 }
294 295
295 maxrange = spell_ob->range + SP_level_range_adjust (caster, spell_ob); 296 maxrange = spell_ob->range + SP_level_range_adjust (caster, spell_ob);
296 for (r = 1; r < maxrange; r++) 297 for (r = 1; r < maxrange; r++)
297 { 298 {
298 sint16 x = op->x + r * freearr_x[dir], y = op->y + r * freearr_y[dir]; 299 sint16 x = op->x + r * DIRX (dir), y = op->y + r * DIRY (dir);
299 300
300 m = op->map; 301 m = op->map;
301 mflags = get_map_flags (m, &m, x, y, &x, &y); 302 mflags = get_map_flags (m, &m, x, y, &x, &y);
302 303
303 if (mflags & P_OUT_OF_MAP) 304 if (mflags & P_OUT_OF_MAP)
471 472
472 op->destroy (); 473 op->destroy ();
473} 474}
474 475
475/* Word of recall causes the player to return 'home'. 476/* Word of recall causes the player to return 'home'.
476 * we put a force into the player object, so that there is a 477 * we put a force into the player object, so that there is a
477 * time delay effect. 478 * time delay effect.
478 */ 479 */
479int 480int
480cast_word_of_recall (object *op, object *caster, object *spell_ob) 481cast_word_of_recall (object *op, object *caster, object *spell_ob)
481{ 482{
619 x = op->x; 620 x = op->x;
620 y = op->y; 621 y = op->y;
621 } 622 }
622 else 623 else
623 { 624 {
624 x = op->x + freearr_x[dir]; 625 x = op->x + DIRX (dir);
625 y = op->y + freearr_y[dir]; 626 y = op->y + DIRY (dir);
626 } 627 }
627 628
628 m = op->map; 629 m = op->map;
629 630
630 if ((spell_ob->move_block || x != op->x || y != op->y) && 631 if ((spell_ob->move_block || x != op->x || y != op->y) &&
705 /* If this is a spellcasting wall, need to insert the spell object */ 706 /* If this is a spellcasting wall, need to insert the spell object */
706 if (tmp->other_arch && tmp->other_arch->type == SPELL) 707 if (tmp->other_arch && tmp->other_arch->type == SPELL)
707 insert_ob_in_ob (tmp->other_arch->instance (), tmp); 708 insert_ob_in_ob (tmp->other_arch->instance (), tmp);
708 709
709 /* This code causes the wall to extend some distance in 710 /* This code causes the wall to extend some distance in
710 * each direction, or until an obstruction is encountered. 711 * each direction, or until an obstruction is encountered.
711 * posblocked and negblocked help determine how far the 712 * posblocked and negblocked help determine how far the
712 * created wall can extend, it won't go extend through 713 * created wall can extend, it won't go extend through
713 * blocked spaces. 714 * blocked spaces.
714 */ 715 */
715 maxrange = spell_ob->range + SP_level_range_adjust (caster, spell_ob); 716 maxrange = spell_ob->range + SP_level_range_adjust (caster, spell_ob);
720 { 721 {
721 int dir2; 722 int dir2;
722 723
723 dir2 = (dir < 4) ? (dir + 2) : dir - 2; 724 dir2 = (dir < 4) ? (dir + 2) : dir - 2;
724 725
725 x = tmp->x + i * freearr_x[dir2]; 726 x = tmp->x + i * DIRX (dir2);
726 y = tmp->y + i * freearr_y[dir2]; 727 y = tmp->y + i * DIRY (dir2);
727 m = tmp->map; 728 m = tmp->map;
728 729
729 if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && 730 if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) &&
730 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !posblocked) 731 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !posblocked)
731 { 732 {
738 739
739 } 740 }
740 else 741 else
741 posblocked = 1; 742 posblocked = 1;
742 743
743 x = tmp->x - i * freearr_x[dir2]; 744 x = tmp->x - i * DIRX (dir2);
744 y = tmp->y - i * freearr_y[dir2]; 745 y = tmp->y - i * DIRY (dir2);
745 m = tmp->map; 746 m = tmp->map;
746 747
747 if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && 748 if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) &&
748 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !negblocked) 749 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !negblocked)
749 { 750 {
795 return 0; 796 return 0;
796 } 797 }
797 798
798 for (dist = 0; dist < count; dist++) 799 for (dist = 0; dist < count; dist++)
799 { 800 {
800 mflags = get_map_flags (op->map, &m, op->x + freearr_x[dir] * (dist + 1), op->y + freearr_y[dir] * (dist + 1), &sx, &sy); 801 mflags = get_map_flags (op->map, &m, op->x + DIRX (dir) * (dist + 1), op->y + DIRY (dir) * (dist + 1), &sx, &sy);
801 802
802 if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP)) 803 if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP))
803 break; 804 break;
804 805
805 if ((mflags & P_BLOCKSVIEW) && OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) 806 if ((mflags & P_BLOCKSVIEW) && OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy)))
818 * by such squares). Also, there are probably treasure rooms and 819 * by such squares). Also, there are probably treasure rooms and
819 * lots of other maps that protect areas with no magic, but the 820 * lots of other maps that protect areas with no magic, but the
820 * areas themselves don't contain no magic spaces. 821 * areas themselves don't contain no magic spaces.
821 */ 822 */
822 /* This call here is really just to normalize the coordinates */ 823 /* This call here is really just to normalize the coordinates */
823 mflags = get_map_flags (op->map, &m, op->x + freearr_x[dir] * dist, op->y + freearr_y[dir] * dist, &sx, &sy); 824 mflags = get_map_flags (op->map, &m, op->x + DIRX (dir) * dist, op->y + DIRY (dir) * dist, &sx, &sy);
824 if (mflags & P_IS_ALIVE || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) 825 if (mflags & P_IS_ALIVE || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy)))
825 { 826 {
826 new_draw_info (NDI_UNIQUE, 0, op, "You cast your spell, but nothing happens.\n"); 827 new_draw_info (NDI_UNIQUE, 0, op, "You cast your spell, but nothing happens.\n");
827 return 1; /* Maybe the penalty should be more severe... */ 828 return 1; /* Maybe the penalty should be more severe... */
828 } 829 }
834 * spaces that blocked the players view. 835 * spaces that blocked the players view.
835 */ 836 */
836 837
837 for (dist = 0; dist < maxdist; dist++) 838 for (dist = 0; dist < maxdist; dist++)
838 { 839 {
839 mflags = get_map_flags (op->map, &m, op->x + freearr_x[dir] * (dist + 1), op->y + freearr_y[dir] * (dist + 1), &sx, &sy); 840 mflags = get_map_flags (op->map, &m, op->x + DIRX (dir) * (dist + 1), op->y + DIRY (dir) * (dist + 1), &sx, &sy);
840 841
841 if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP)) 842 if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP))
842 break; 843 break;
843 844
844 if ((mflags & P_BLOCKSVIEW) && OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) 845 if ((mflags & P_BLOCKSVIEW) && OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy)))
849 /* If the destination is blocked, keep backing up until we 850 /* If the destination is blocked, keep backing up until we
850 * find a place for the player. 851 * find a place for the player.
851 */ 852 */
852 for (; dist > 0; dist--) 853 for (; dist > 0; dist--)
853 { 854 {
854 if (get_map_flags (op->map, &m, op->x + freearr_x[dir] * dist, op->y + freearr_y[dir] * dist, 855 if (get_map_flags (op->map, &m, op->x + DIRX (dir) * dist, op->y + DIRY (dir) * dist,
855 &sx, &sy) & (P_OUT_OF_MAP | P_IS_ALIVE)) 856 &sx, &sy) & (P_OUT_OF_MAP | P_IS_ALIVE))
856 continue; 857 continue;
857 858
858 859
859 if (!OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))) 860 if (!OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy)))
866 return 0; 867 return 0;
867 } 868 }
868 } 869 }
869 870
870 /* Actually move the player now */ 871 /* Actually move the player now */
871 if (!(op = op->map->insert (op, op->x + freearr_x[dir] * dist, op->y + freearr_y[dir] * dist, op))) 872 if (!(op = op->map->insert (op, op->x + DIRX (dir) * dist, op->y + DIRY (dir) * dist, op)))
872 return 1; 873 return 1;
873 874
874 op->speed_left = -5. * op->speed; /* Freeze them for a short while */ 875 op->speed_left = -5. * op->speed; /* Freeze them for a short while */
875 876
876 return 1; 877 return 1;
1768 sint16 x, y; 1769 sint16 x, y;
1769 maptile *m; 1770 maptile *m;
1770 int mflags; 1771 int mflags;
1771 1772
1772 m = op->map; 1773 m = op->map;
1773 x = op->x + freearr_x[dir]; 1774 x = op->x + DIRX (dir);
1774 y = op->y + freearr_y[dir]; 1775 y = op->y + DIRY (dir);
1775 1776
1776 mflags = get_map_flags (m, &m, x, y, &x, &y); 1777 mflags = get_map_flags (m, &m, x, y, &x, &y);
1777 1778
1778 if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) 1779 if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE)
1779 { 1780 {
1843 object *tmp, *head, *next; 1844 object *tmp, *head, *next;
1844 int mflags; 1845 int mflags;
1845 maptile *m; 1846 maptile *m;
1846 sint16 sx, sy; 1847 sint16 sx, sy;
1847 1848
1848 sx = op->x + freearr_x[dir]; 1849 sx = op->x + DIRX (dir);
1849 sy = op->y + freearr_y[dir]; 1850 sy = op->y + DIRY (dir);
1850 m = op->map; 1851 m = op->map;
1851 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); 1852 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy);
1852 if (mflags & P_OUT_OF_MAP) 1853 if (mflags & P_OUT_OF_MAP)
1853 return; 1854 return;
1854 1855
1867 1868
1868 /* don't attack our own spells */ 1869 /* don't attack our own spells */
1869 if (tmp->owner && tmp->owner == op->owner) 1870 if (tmp->owner && tmp->owner == op->owner)
1870 continue; 1871 continue;
1871 1872
1872 /* Basically, if the object is magical and not counterspell, 1873 /* Basically, if the object is magical and not counterspell,
1873 * we will more or less remove the object. Don't counterspell 1874 * we will more or less remove the object. Don't counterspell
1874 * monsters either. 1875 * monsters either.
1875 */ 1876 */
1876 1877
1877 if (head->attacktype & AT_MAGIC 1878 if (head->attacktype & AT_MAGIC
1878 && !(head->attacktype & AT_COUNTERSPELL) 1879 && !(head->attacktype & AT_COUNTERSPELL)
1879 && !head->flag [FLAG_MONSTER] 1880 && !head->flag [FLAG_MONSTER]
1953 1954
1954 op->failmsg ("You are not standing over an altar!"); 1955 op->failmsg ("You are not standing over an altar!");
1955 return 0; 1956 return 0;
1956} 1957}
1957 1958
1958/* animate_weapon - 1959/* animate_weapon -
1959 * Generalization of staff_to_snake. Makes a golem out of the caster's weapon. 1960 * Generalization of staff_to_snake. Makes a golem out of the caster's weapon.
1960 * The golem is based on the archetype specified, modified by the caster's level 1961 * The golem is based on the archetype specified, modified by the caster's level
1961 * and the attributes of the weapon. The weapon is inserted in the golem's 1962 * and the attributes of the weapon. The weapon is inserted in the golem's
1962 * inventory so that it falls to the ground when the golem dies. 1963 * inventory so that it falls to the ground when the golem dies.
1963 * This code was very odd - code early on would only let players use the spell, 1964 * This code was very odd - code early on would only let players use the spell,
1964 * yet the code wass full of player checks. I've presumed that the code 1965 * yet the code wass full of player checks. I've presumed that the code
1965 * that only let players use it was correct, and removed all the other 1966 * that only let players use it was correct, and removed all the other
1966 * player checks. MSW 2003-01-06 1967 * player checks. MSW 2003-01-06
1993 /* if no direction specified, pick one */ 1994 /* if no direction specified, pick one */
1994 if (!dir) 1995 if (!dir)
1995 dir = find_free_spot (spell->other_arch, op->map, op->x, op->y, 1, 9); 1996 dir = find_free_spot (spell->other_arch, op->map, op->x, op->y, 1, 9);
1996 1997
1997 m = op->map; 1998 m = op->map;
1998 x = op->x + freearr_x[dir]; 1999 x = op->x + DIRX (dir);
1999 y = op->y + freearr_y[dir]; 2000 y = op->y + DIRY (dir);
2000 2001
2001 /* if there's no place to put the golem, abort */ 2002 /* if there's no place to put the golem, abort */
2002 if (dir < 0 || (get_map_flags (m, &m, x, y, &x, &y) & P_OUT_OF_MAP) 2003 if (dir < 0 || (get_map_flags (m, &m, x, y, &x, &y) & P_OUT_OF_MAP)
2003 || ((spell->other_arch->move_type & GET_MAP_MOVE_BLOCK (m, x, y)) == spell->other_arch->move_type)) 2004 || ((spell->other_arch->move_type & GET_MAP_MOVE_BLOCK (m, x, y)) == spell->other_arch->move_type))
2004 { 2005 {
2204 2205
2205/* move aura function. An aura is a part of someone's inventory, 2206/* move aura function. An aura is a part of someone's inventory,
2206 * which he carries with him, but which acts on the map immediately 2207 * which he carries with him, but which acts on the map immediately
2207 * around him. 2208 * around him.
2208 * Aura parameters: 2209 * Aura parameters:
2209 * duration: duration counter. 2210 * duration: duration counter.
2210 * attacktype: aura's attacktype 2211 * attacktype: aura's attacktype
2211 * other_arch: archetype to drop where we attack 2212 * other_arch: archetype to drop where we attack
2212 */ 2213 */
2213void 2214void
2214move_aura (object *aura) 2215move_aura (object *aura)
2215{ 2216{
2216 /* auras belong in inventories */ 2217 /* auras belong in inventories */
2217 object *env = aura->env; 2218 object *env = aura->env;
2218 object *owner = aura->owner; 2219 object *owner = aura->owner;
2219 2220
2220 /* no matter what we've gotta remove the aura... 2221 /* no matter what we've gotta remove the aura...
2221 * we'll put it back if its time isn't up. 2222 * we'll put it back if its time isn't up.
2222 */ 2223 */
2223 aura->remove (); 2224 aura->remove ();
2224 2225
2225 /* exit if we're out of gas */ 2226 /* exit if we're out of gas */
2226 if (aura->duration-- < 0) 2227 if (aura->duration-- < 0)
2235 aura->destroy (); 2236 aura->destroy ();
2236 return; 2237 return;
2237 } 2238 }
2238 2239
2239 /* we need to jump out of the inventory for a bit 2240 /* we need to jump out of the inventory for a bit
2240 * in order to hit the map conveniently. 2241 * in order to hit the map conveniently.
2241 */ 2242 */
2242 aura->insert_at (env, aura); 2243 aura->insert_at (env, aura);
2243 2244
2244 for (int i = 1; i < 9; i++) 2245 for (int i = 1; i < 9; i++)
2245 { 2246 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines