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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines