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

Comparing deliantra/server/server/spell_attack.C (file contents):
Revision 1.108 by root, Tue Jan 3 11:25:37 2012 UTC vs.
Revision 1.115 by root, Sun Jan 29 02:47:06 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-2003 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002-2003 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
10 * Free Software Foundation, either version 3 of the License, or (at your 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the Affero GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * and the GNU General Public License along with this program. If not, see 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>. 20 * <http://www.gnu.org/licenses/>.
21 * 21 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 23 */
24 24
25/* This file contains all the spell attack code. Grouping this code 25/* This file contains all the spell attack code. Grouping this code
26 * together should hopefully make it easier to find the relevent bits 26 * together should hopefully make it easier to find the relevent bits
86 if (tmp->move_type & MOVE_FLYING) 86 if (tmp->move_type & MOVE_FLYING)
87 frictionmod = 1; /* flying objects loose the friction modifier */ 87 frictionmod = 1; /* flying objects loose the friction modifier */
88 88
89 if (rndm (0, weight_move - 1) > ((tmp->weight / num_sections) * frictionmod)) 89 if (rndm (0, weight_move - 1) > ((tmp->weight / num_sections) * frictionmod))
90 { /* move it. */ 90 { /* move it. */
91 /* move_object is really for monsters, but looking at 91 /* move_object is really for monsters, but looking at
92 * the move_object function, it appears that it should 92 * the move_object function, it appears that it should
93 * also be safe for objects. 93 * also be safe for objects.
94 * This does return if successful or not, but 94 * This does return if successful or not, but
95 * I don't see us doing anything useful with that information 95 * I don't see us doing anything useful with that information
96 * right now. 96 * right now.
247 tmp->speed_left = -0.1f; 247 tmp->speed_left = -0.1f;
248 /* To make up for the decrease at the top of the function */ 248 /* To make up for the decrease at the top of the function */
249 tmp->duration++; 249 tmp->duration++;
250 250
251 /* New forking code. Possibly create forks of this object 251 /* New forking code. Possibly create forks of this object
252 * going off in other directions. 252 * going off in other directions.
253 */ 253 */
254 if (tmp->stats.Dex && rndm (0, 99) < tmp->stats.Dex) 254 if (tmp->stats.Dex && rndm (0, 99) < tmp->stats.Dex)
255 forklightning (op, tmp); /* stats.Dex % of forking */ 255 forklightning (op, tmp); /* stats.Dex % of forking */
256 256
257 /* In this way, the object left behind sticks on the space, but 257 /* In this way, the object left behind sticks on the space, but
367 sint16 dx, dy; 367 sint16 dx, dy;
368 368
369 dx = op->x + freearr_x[i]; 369 dx = op->x + freearr_x[i];
370 dy = op->y + freearr_y[i]; 370 dy = op->y + freearr_y[i];
371 371
372 /* ok_to_put_more already does things like checks for walls, 372 /* ok_to_put_more already does things like checks for walls,
373 * out of map, etc. 373 * out of map, etc.
374 */ 374 */
375 if (ok_to_put_more (op->map, dx, dy, op, op->attacktype)) 375 if (ok_to_put_more (op->map, dx, dy, op, op->attacktype))
376 { 376 {
377 object *tmp = op->clone (); 377 object *tmp = op->clone ();
549move_bullet (object *op) 549move_bullet (object *op)
550{ 550{
551#if 0 551#if 0
552 /* We need a better general purpose way to do this */ 552 /* We need a better general purpose way to do this */
553 553
554 /* peterm: added to make comet leave a trail of burnouts 554 /* peterm: added to make comet leave a trail of burnouts
555 it's an unadulterated hack, but the effect is cool. */ 555 it's an unadulterated hack, but the effect is cool. */
556 if (op->stats.sp == SP_METEOR) 556 if (op->stats.sp == SP_METEOR)
557 { 557 {
558 replace_insert_ob_in_map ("fire_trail", op); 558 replace_insert_ob_in_map ("fire_trail", op);
559 if (op->destroyed ()) 559 if (op->destroyed ())
754 if (!op->is_on_map ()) 754 if (!op->is_on_map ())
755 return; 755 return;
756 756
757 /* Check to see if we should push anything. 757 /* Check to see if we should push anything.
758 * Spell objects with weight push whatever they encounter to some 758 * Spell objects with weight push whatever they encounter to some
759 * degree. 759 * degree.
760 */ 760 */
761 if (op->weight) 761 if (op->weight)
762 { 762 {
763 check_spell_knockback (op); 763 check_spell_knockback (op);
764 764
1096 } 1096 }
1097 1097
1098 return NULL; 1098 return NULL;
1099} 1099}
1100 1100
1101/* cast_smite_arch() - the priest points to a creature and causes 1101/* cast_smite_spell() - the priest points to a creature and causes
1102 * a 'godly curse' to decend. 1102 * a 'godly curse' to decend.
1103 * usual params - 1103 * usual params -
1104 * op = player 1104 * op = player
1105 * caster = object casting the spell. 1105 * caster = object casting the spell.
1106 * dir = direction being cast 1106 * dir = direction being cast
1107 * spell = spell object 1107 * spell = spell object
1109int 1109int
1110cast_smite_spell (object *op, object *caster, int dir, object *spell) 1110cast_smite_spell (object *op, object *caster, int dir, object *spell)
1111{ 1111{
1112 object *effect, *target; 1112 object *effect, *target;
1113 object *god = find_god (determine_god (op)); 1113 object *god = find_god (determine_god (op));
1114 int range;
1115 1114
1116 range = spell->range + SP_level_range_adjust (caster, spell);
1117 target = get_pointed_target (op, dir, 50, spell->stats.grace ? SPELL_GRACE : SPELL_MANA); 1115 target = get_pointed_target (op, dir, 50, spell->stats.grace ? SPELL_GRACE : SPELL_MANA);
1118 1116
1119 /* Bunch of conditions for casting this spell. Note that only 1117 /* Bunch of conditions for casting this spell. Note that only
1120 * require a god if this is a cleric spell (requires grace). 1118 * require a god if this is a cleric spell (requires grace).
1121 * This makes this spell much more general purpose - it can be used 1119 * This makes this spell much more general purpose - it can be used
1122 * by wizards also, which is good, because I think this is a very 1120 * by wizards also, which is good, because I think this is a very
1123 * interesting spell. 1121 * interesting spell.
1124 * if it is a cleric spell, you need a god, and the creature 1122 * if it is a cleric spell, you need a god, and the creature
1252/**************************************************************************** 1250/****************************************************************************
1253 * Destruction 1251 * Destruction
1254 ****************************************************************************/ 1252 ****************************************************************************/
1255 1253
1256/* make_object_glow() - currently only makes living objects glow. 1254/* make_object_glow() - currently only makes living objects glow.
1257 * we do this by creating a force and inserting it in the 1255 * we do this by creating a force and inserting it in the
1258 * object. if time is 0, the object glows permanently. To truely 1256 * object. if time is 0, the object glows permanently. To truely
1259 * make this work for non-living objects, we would have to 1257 * make this work for non-living objects, we would have to
1260 * give them the capability to have an inventory. b.t. 1258 * give them the capability to have an inventory. b.t.
1261 */ 1259 */
1262static int 1260static int
1263make_object_glow (object *op, int radius, int time) 1261make_object_glow (object *op, int radius, int time)
1264{ 1262{
1461 unordered_mapwalk (buf, op, -range, -range, range, range) 1459 unordered_mapwalk (buf, op, -range, -range, range, range)
1462 { 1460 {
1463 mapspace &ms = m->at (nx, ny); 1461 mapspace &ms = m->at (nx, ny);
1464 1462
1465 /* If there is nothing living on this space, no need to go further */ 1463 /* If there is nothing living on this space, no need to go further */
1466 if (!ms.flags () & P_IS_ALIVE) 1464 if (!(ms.flags () & P_IS_ALIVE))
1467 continue; 1465 continue;
1468 1466
1469 // players can only affect spaces that they can actually see 1467 // players can only affect spaces that they can actually see
1470 if (caster 1468 if (caster
1471 && caster->contr 1469 && caster->contr
1641 m = op->map; 1639 m = op->map;
1642 } 1640 }
1643 1641
1644 m->insert (op, nx, ny, op); 1642 m->insert (op, nx, ny, op);
1645 1643
1646 dam_save = op->stats.dam; /* save the original dam: we do halfdam on 1644 dam_save = op->stats.dam; /* save the original dam: we do halfdam on
1647 surrounding squares */ 1645 surrounding squares */
1648 1646
1649 /* loop over current square and neighbors to hit. 1647 /* loop over current square and neighbors to hit.
1650 * if this has an other_arch field, we insert that in 1648 * if this has an other_arch field, we insert that in
1651 * the surround spaces. 1649 * the surround spaces.
1692 1690
1693 op->direction = i; 1691 op->direction = i;
1694 } 1692 }
1695} 1693}
1696 1694
1697/* move_swarm_spell: peterm 1695/* move_swarm_spell: peterm
1698 * This is an implementation of the swarm spell. It was written for 1696 * This is an implementation of the swarm spell. It was written for
1699 * meteor swarm, but it could be used for any swarm. A swarm spell 1697 * meteor swarm, but it could be used for any swarm. A swarm spell
1700 * is a special type of object that casts swarms of other types 1698 * is a special type of object that casts swarms of other types
1701 * of spells. Which spell it casts is flexible. It fires the spells 1699 * of spells. Which spell it casts is flexible. It fires the spells
1702 * from a set of squares surrounding the caster, in a given direction. 1700 * from a set of squares surrounding the caster, in a given direction.
1703 */ 1701 */
1704void 1702void
1705move_swarm_spell (object *op) 1703move_swarm_spell (object *op)
1706{ 1704{
1707#if 0 1705#if 0
1743 // space. 1741 // space.
1744 // should be fixed later, but correctness before features... 1742 // should be fixed later, but correctness before features...
1745 // (schmorp) 1743 // (schmorp)
1746 1744
1747 /* new offset calculation to make swarm element distribution 1745 /* new offset calculation to make swarm element distribution
1748 * more uniform 1746 * more uniform
1749 */ 1747 */
1750 if (op->duration) 1748 if (op->duration)
1751 { 1749 {
1752 if (basedir & 1) 1750 if (basedir & 1)
1753 { 1751 {
1765 1763
1766 target_x = op->x + freearr_x[absdir (basedir + adjustdir)]; 1764 target_x = op->x + freearr_x[absdir (basedir + adjustdir)];
1767 target_y = op->y + freearr_y[absdir (basedir + adjustdir)]; 1765 target_y = op->y + freearr_y[absdir (basedir + adjustdir)];
1768 1766
1769 /* back up one space so we can hit point-blank targets, but this 1767 /* back up one space so we can hit point-blank targets, but this
1770 * necessitates extra out_of_map check below 1768 * necessitates extra out_of_map check below
1771 */ 1769 */
1772 origin_x = target_x - freearr_x[basedir]; 1770 origin_x = target_x - freearr_x[basedir];
1773 origin_y = target_y - freearr_y[basedir]; 1771 origin_y = target_y - freearr_y[basedir];
1774 1772
1775 1773
1809} 1807}
1810 1808
1811/* fire_swarm: 1809/* fire_swarm:
1812 * The following routine creates a swarm of objects. It actually 1810 * The following routine creates a swarm of objects. It actually
1813 * sets up a specific swarm object, which then fires off all 1811 * sets up a specific swarm object, which then fires off all
1814 * the parts of the swarm. 1812 * the parts of the swarm.
1815 * 1813 *
1816 * op: the owner 1814 * op: the owner
1817 * caster: the caster (owner, wand, rod, scroll) 1815 * caster: the caster (owner, wand, rod, scroll)
1818 * dir: the direction everything will be fired in 1816 * dir: the direction everything will be fired in
1819 * spell - the spell that is this spell. 1817 * spell - the spell that is this spell.
1922 1920
1923 return 1; 1921 return 1;
1924} 1922}
1925 1923
1926/* cast_cause_disease: this spell looks along <dir> from the 1924/* cast_cause_disease: this spell looks along <dir> from the
1927 * player and infects someone. 1925 * player and infects someone.
1928 * op is the player/monster, caster is the object, dir is the direction 1926 * op is the player/monster, caster is the object, dir is the direction
1929 * to cast, disease_arch is the specific disease, and type is the spell number 1927 * to cast, disease_arch is the specific disease, and type is the spell number
1930 * perhaps this should actually be in disease.c? 1928 * perhaps this should actually be in disease.c?
1931 */ 1929 */
1932int 1930int
1938 maptile *m; 1936 maptile *m;
1939 1937
1940 x = op->x; 1938 x = op->x;
1941 y = op->y; 1939 y = op->y;
1942 1940
1943 /* If casting from a scroll, no direction will be available, so refer to the 1941 /* If casting from a scroll, no direction will be available, so refer to the
1944 * direction the player is pointing. 1942 * direction the player is pointing.
1945 */ 1943 */
1946 if (!dir) 1944 if (!dir)
1947 dir = op->facing; 1945 dir = op->facing;
1948 1946
1996 1994
1997 if (disease->last_sp < 1) 1995 if (disease->last_sp < 1)
1998 disease->last_sp = 1; 1996 disease->last_sp = 1;
1999 } 1997 }
2000 1998
2001 if (disease->stats.dam ) disease->stats.dam += copysign (disease->stats.dam , dam_mod); 1999 if (disease->stats.dam ) disease->stats.dam += copysignl (disease->stats.dam , dam_mod);
2002 if (disease->stats.maxsp) disease->stats.maxsp += copysign (disease->stats.maxsp, dam_mod); 2000 if (disease->stats.maxsp) disease->stats.maxsp += copysignl (disease->stats.maxsp, dam_mod);
2003 if (disease->stats.ac ) disease->stats.ac += dam_mod; 2001 if (disease->stats.ac ) disease->stats.ac += dam_mod;
2004 if (disease->last_eat ) disease->last_eat -= dam_mod; 2002 if (disease->last_eat ) disease->last_eat -= dam_mod;
2005 if (disease->stats.hp ) disease->stats.hp -= dam_mod; 2003 if (disease->stats.hp ) disease->stats.hp -= dam_mod;
2006 if (disease->stats.sp ) disease->stats.sp -= dam_mod; 2004 if (disease->stats.sp ) disease->stats.sp -= dam_mod;
2007 2005

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines