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.149 by root, Sat Dec 1 20:22:13 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 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
9 * the terms of the Affero GNU General Public License as published by the 10 * the terms of the Affero GNU General Public License as published by the
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)
404 405
405 if (spell_ob->flag [FLAG_MAKE_INVIS]) 406 if (spell_ob->flag [FLAG_MAKE_INVIS])
406 op->contr->tmp_invis = 0; 407 op->contr->tmp_invis = 0;
407 else 408 else
408 op->contr->tmp_invis = 1; 409 op->contr->tmp_invis = 1;
409
410 op->contr->hidden = 0;
411 } 410 }
412 411
413 if (makes_invisible_to (op, op)) 412 if (makes_invisible_to (op, op))
414 new_draw_info (NDI_UNIQUE, 0, op, "You can't see your hands!"); 413 new_draw_info (NDI_UNIQUE, 0, op, "You can't see your hands!");
415 else 414 else
473 472
474 op->destroy (); 473 op->destroy ();
475} 474}
476 475
477/* Word of recall causes the player to return 'home'. 476/* Word of recall causes the player to return 'home'.
478 * 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
479 * time delay effect. 478 * time delay effect.
480 */ 479 */
481int 480int
482cast_word_of_recall (object *op, object *caster, object *spell_ob) 481cast_word_of_recall (object *op, object *caster, object *spell_ob)
483{ 482{
621 x = op->x; 620 x = op->x;
622 y = op->y; 621 y = op->y;
623 } 622 }
624 else 623 else
625 { 624 {
626 x = op->x + freearr_x[dir]; 625 x = op->x + DIRX (dir);
627 y = op->y + freearr_y[dir]; 626 y = op->y + DIRY (dir);
628 } 627 }
629 628
630 m = op->map; 629 m = op->map;
631 630
632 if ((spell_ob->move_block || x != op->x || y != op->y) && 631 if ((spell_ob->move_block || x != op->x || y != op->y) &&
707 /* 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 */
708 if (tmp->other_arch && tmp->other_arch->type == SPELL) 707 if (tmp->other_arch && tmp->other_arch->type == SPELL)
709 insert_ob_in_ob (tmp->other_arch->instance (), tmp); 708 insert_ob_in_ob (tmp->other_arch->instance (), tmp);
710 709
711 /* This code causes the wall to extend some distance in 710 /* This code causes the wall to extend some distance in
712 * each direction, or until an obstruction is encountered. 711 * each direction, or until an obstruction is encountered.
713 * posblocked and negblocked help determine how far the 712 * posblocked and negblocked help determine how far the
714 * created wall can extend, it won't go extend through 713 * created wall can extend, it won't go extend through
715 * blocked spaces. 714 * blocked spaces.
716 */ 715 */
717 maxrange = spell_ob->range + SP_level_range_adjust (caster, spell_ob); 716 maxrange = spell_ob->range + SP_level_range_adjust (caster, spell_ob);
722 { 721 {
723 int dir2; 722 int dir2;
724 723
725 dir2 = (dir < 4) ? (dir + 2) : dir - 2; 724 dir2 = (dir < 4) ? (dir + 2) : dir - 2;
726 725
727 x = tmp->x + i * freearr_x[dir2]; 726 x = tmp->x + i * DIRX (dir2);
728 y = tmp->y + i * freearr_y[dir2]; 727 y = tmp->y + i * DIRY (dir2);
729 m = tmp->map; 728 m = tmp->map;
730 729
731 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)) &&
732 ((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)
733 { 732 {
740 739
741 } 740 }
742 else 741 else
743 posblocked = 1; 742 posblocked = 1;
744 743
745 x = tmp->x - i * freearr_x[dir2]; 744 x = tmp->x - i * DIRX (dir2);
746 y = tmp->y - i * freearr_y[dir2]; 745 y = tmp->y - i * DIRY (dir2);
747 m = tmp->map; 746 m = tmp->map;
748 747
749 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)) &&
750 ((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)
751 { 750 {
797 return 0; 796 return 0;
798 } 797 }
799 798
800 for (dist = 0; dist < count; dist++) 799 for (dist = 0; dist < count; dist++)
801 { 800 {
802 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);
803 802
804 if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP)) 803 if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP))
805 break; 804 break;
806 805
807 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)))
820 * by such squares). Also, there are probably treasure rooms and 819 * by such squares). Also, there are probably treasure rooms and
821 * 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
822 * areas themselves don't contain no magic spaces. 821 * areas themselves don't contain no magic spaces.
823 */ 822 */
824 /* This call here is really just to normalize the coordinates */ 823 /* 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); 824 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))) 825 if (mflags & P_IS_ALIVE || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy)))
827 { 826 {
828 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");
829 return 1; /* Maybe the penalty should be more severe... */ 828 return 1; /* Maybe the penalty should be more severe... */
830 } 829 }
836 * spaces that blocked the players view. 835 * spaces that blocked the players view.
837 */ 836 */
838 837
839 for (dist = 0; dist < maxdist; dist++) 838 for (dist = 0; dist < maxdist; dist++)
840 { 839 {
841 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);
842 841
843 if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP)) 842 if (mflags & (P_NO_MAGIC | P_OUT_OF_MAP))
844 break; 843 break;
845 844
846 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)))
851 /* If the destination is blocked, keep backing up until we 850 /* If the destination is blocked, keep backing up until we
852 * find a place for the player. 851 * find a place for the player.
853 */ 852 */
854 for (; dist > 0; dist--) 853 for (; dist > 0; dist--)
855 { 854 {
856 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,
857 &sx, &sy) & (P_OUT_OF_MAP | P_IS_ALIVE)) 856 &sx, &sy) & (P_OUT_OF_MAP | P_IS_ALIVE))
858 continue; 857 continue;
859 858
860 859
861 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)))
868 return 0; 867 return 0;
869 } 868 }
870 } 869 }
871 870
872 /* Actually move the player now */ 871 /* 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))) 872 if (!(op = op->map->insert (op, op->x + DIRX (dir) * dist, op->y + DIRY (dir) * dist, op)))
874 return 1; 873 return 1;
875 874
876 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 */
877 876
878 return 1; 877 return 1;
1372 } 1371 }
1373 1372
1374 value -= rndm (value >> 4); 1373 value -= rndm (value >> 4);
1375 value = min (value, value_max); 1374 value = min (value, value_max);
1376 1375
1377 for (int i = 0; i < array_length (nugget); ++i) 1376 for (int i = 0; i < ecb_array_length (nugget); ++i)
1378 if (int nrof = value / nugget [i]->value) 1377 if (int nrof = value / nugget [i]->value)
1379 { 1378 {
1380 value -= nrof * nugget[i]->value; 1379 value -= nrof * nugget[i]->value;
1381 1380
1382 object *tmp = nugget[i]->instance (); 1381 object *tmp = nugget[i]->instance ();
1770 sint16 x, y; 1769 sint16 x, y;
1771 maptile *m; 1770 maptile *m;
1772 int mflags; 1771 int mflags;
1773 1772
1774 m = op->map; 1773 m = op->map;
1775 x = op->x + freearr_x[dir]; 1774 x = op->x + DIRX (dir);
1776 y = op->y + freearr_y[dir]; 1775 y = op->y + DIRY (dir);
1777 1776
1778 mflags = get_map_flags (m, &m, x, y, &x, &y); 1777 mflags = get_map_flags (m, &m, x, y, &x, &y);
1779 1778
1780 if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) 1779 if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE)
1781 { 1780 {
1845 object *tmp, *head, *next; 1844 object *tmp, *head, *next;
1846 int mflags; 1845 int mflags;
1847 maptile *m; 1846 maptile *m;
1848 sint16 sx, sy; 1847 sint16 sx, sy;
1849 1848
1850 sx = op->x + freearr_x[dir]; 1849 sx = op->x + DIRX (dir);
1851 sy = op->y + freearr_y[dir]; 1850 sy = op->y + DIRY (dir);
1852 m = op->map; 1851 m = op->map;
1853 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); 1852 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy);
1854 if (mflags & P_OUT_OF_MAP) 1853 if (mflags & P_OUT_OF_MAP)
1855 return; 1854 return;
1856 1855
1869 1868
1870 /* don't attack our own spells */ 1869 /* don't attack our own spells */
1871 if (tmp->owner && tmp->owner == op->owner) 1870 if (tmp->owner && tmp->owner == op->owner)
1872 continue; 1871 continue;
1873 1872
1874 /* Basically, if the object is magical and not counterspell, 1873 /* Basically, if the object is magical and not counterspell,
1875 * we will more or less remove the object. Don't counterspell 1874 * we will more or less remove the object. Don't counterspell
1876 * monsters either. 1875 * monsters either.
1877 */ 1876 */
1878 1877
1879 if (head->attacktype & AT_MAGIC 1878 if (head->attacktype & AT_MAGIC
1880 && !(head->attacktype & AT_COUNTERSPELL) 1879 && !(head->attacktype & AT_COUNTERSPELL)
1881 && !head->flag [FLAG_MONSTER] 1880 && !head->flag [FLAG_MONSTER]
1955 1954
1956 op->failmsg ("You are not standing over an altar!"); 1955 op->failmsg ("You are not standing over an altar!");
1957 return 0; 1956 return 0;
1958} 1957}
1959 1958
1960/* animate_weapon - 1959/* animate_weapon -
1961 * 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.
1962 * 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
1963 * 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
1964 * 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.
1965 * 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,
1966 * 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
1967 * 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
1968 * player checks. MSW 2003-01-06 1967 * player checks. MSW 2003-01-06
1995 /* if no direction specified, pick one */ 1994 /* if no direction specified, pick one */
1996 if (!dir) 1995 if (!dir)
1997 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);
1998 1997
1999 m = op->map; 1998 m = op->map;
2000 x = op->x + freearr_x[dir]; 1999 x = op->x + DIRX (dir);
2001 y = op->y + freearr_y[dir]; 2000 y = op->y + DIRY (dir);
2002 2001
2003 /* if there's no place to put the golem, abort */ 2002 /* 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) 2003 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)) 2004 || ((spell->other_arch->move_type & GET_MAP_MOVE_BLOCK (m, x, y)) == spell->other_arch->move_type))
2006 { 2005 {
2206 2205
2207/* 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,
2208 * 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
2209 * around him. 2208 * around him.
2210 * Aura parameters: 2209 * Aura parameters:
2211 * duration: duration counter. 2210 * duration: duration counter.
2212 * attacktype: aura's attacktype 2211 * attacktype: aura's attacktype
2213 * other_arch: archetype to drop where we attack 2212 * other_arch: archetype to drop where we attack
2214 */ 2213 */
2215void 2214void
2216move_aura (object *aura) 2215move_aura (object *aura)
2217{ 2216{
2218 /* auras belong in inventories */ 2217 /* auras belong in inventories */
2219 object *env = aura->env; 2218 object *env = aura->env;
2220 object *owner = aura->owner; 2219 object *owner = aura->owner;
2221 2220
2222 /* no matter what we've gotta remove the aura... 2221 /* no matter what we've gotta remove the aura...
2223 * we'll put it back if its time isn't up. 2222 * we'll put it back if its time isn't up.
2224 */ 2223 */
2225 aura->remove (); 2224 aura->remove ();
2226 2225
2227 /* exit if we're out of gas */ 2226 /* exit if we're out of gas */
2228 if (aura->duration-- < 0) 2227 if (aura->duration-- < 0)
2237 aura->destroy (); 2236 aura->destroy ();
2238 return; 2237 return;
2239 } 2238 }
2240 2239
2241 /* we need to jump out of the inventory for a bit 2240 /* we need to jump out of the inventory for a bit
2242 * in order to hit the map conveniently. 2241 * in order to hit the map conveniently.
2243 */ 2242 */
2244 aura->insert_at (env, aura); 2243 aura->insert_at (env, aura);
2245 2244
2246 for (int i = 1; i < 9; i++) 2245 for (int i = 1; i < 9; i++)
2247 { 2246 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines