--- deliantra/server/server/spell_attack.C 2012/01/03 11:25:37 1.108
+++ deliantra/server/server/spell_attack.C 2017/09/16 22:17:42 1.116
@@ -1,24 +1,24 @@
/*
* This file is part of Deliantra, the Roguelike Realtime MMORPG.
- *
- * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
+ *
+ * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
* Copyright (©) 2002-2003 Mark Wedel & Crossfire Development Team
* Copyright (©) 1992 Frank Tore Johansen
- *
+ *
* Deliantra is free software: you can redistribute it and/or modify it under
* the terms of the Affero GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the Affero GNU General Public License
* and the GNU General Public License along with this program. If not, see
* .
- *
+ *
* The authors can be reached via e-mail to
*/
@@ -88,7 +88,7 @@
if (rndm (0, weight_move - 1) > ((tmp->weight / num_sections) * frictionmod))
{ /* move it. */
- /* move_object is really for monsters, but looking at
+ /* move_object is really for monsters, but looking at
* the move_object function, it appears that it should
* also be safe for objects.
* This does return if successful or not, but
@@ -131,7 +131,7 @@
/* check the new dir for a wall and in the map */
t_dir = absdir (tmp->direction + new_dir);
- if (get_map_flags (tmp->map, &m, tmp->x + freearr_x[t_dir], tmp->y + freearr_y[t_dir], &sx, &sy) & P_OUT_OF_MAP)
+ if (get_map_flags (tmp->map, &m, tmp->x + DIRX (t_dir), tmp->y + DIRY (t_dir), &sx, &sy) & P_OUT_OF_MAP)
return;
if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (m, sx, sy)))
@@ -181,8 +181,8 @@
op->range = 0;
else
{
- x = op->x + DIRX (op);
- y = op->y + DIRY (op);
+ x = op->x + DIRX (op->direction);
+ y = op->y + DIRY (op->direction);
m = op->map;
mflags = get_map_flags (m, &m, x, y, &x, &y);
@@ -219,13 +219,13 @@
* op->direction is within an adjacent map but either
* op->direction-1 or op->direction+1 does not exist.
*/
- mflags = get_map_flags (op->map, &m, op->x + freearr_x[absdir (op->direction - 1)],
- op->y + freearr_y[absdir (op->direction - 1)], &x, &y);
+ mflags = get_map_flags (op->map, &m, op->x + DIRX (absdir (op->direction - 1)),
+ op->y + DIRY (absdir (op->direction - 1)), &x, &y);
left = (mflags & P_OUT_OF_MAP) ? 0 : OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, x, y));
- mflags = get_map_flags (op->map, &m, op->x + freearr_x[absdir (op->direction + 1)],
- op->y + freearr_y[absdir (op->direction + 1)], &x, &y);
+ mflags = get_map_flags (op->map, &m, op->x + DIRX (absdir (op->direction + 1)),
+ op->y + DIRY (absdir (op->direction + 1)), &x, &y);
right = (mflags & P_OUT_OF_MAP) ? 0 : OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, x, y));
if (left == right)
@@ -249,7 +249,7 @@
tmp->duration++;
/* New forking code. Possibly create forks of this object
- * going off in other directions.
+ * going off in other directions.
*/
if (tmp->stats.Dex && rndm (0, 99) < tmp->stats.Dex)
forklightning (op, tmp); /* stats.Dex % of forking */
@@ -302,8 +302,8 @@
tmp->set_owner (op);
set_spell_skill (op, caster, spob, tmp);
- tmp->x = op->x + DIRX (tmp);
- tmp->y = op->y + DIRY (tmp);
+ tmp->x = op->x + DIRX (tmp->direction);
+ tmp->y = op->y + DIRY (tmp->direction);
tmp->map = op->map;
maptile *newmap;
@@ -366,10 +366,10 @@
{
sint16 dx, dy;
- dx = op->x + freearr_x[i];
- dy = op->y + freearr_y[i];
+ dx = op->x + DIRX (i);
+ dy = op->y + DIRY (i);
- /* ok_to_put_more already does things like checks for walls,
+ /* ok_to_put_more already does things like checks for walls,
* out of map, etc.
*/
if (ok_to_put_more (op->map, dx, dy, op, op->attacktype))
@@ -551,7 +551,7 @@
#if 0
/* We need a better general purpose way to do this */
- /* peterm: added to make comet leave a trail of burnouts
+ /* peterm: added to make comet leave a trail of burnouts
it's an unadulterated hack, but the effect is cool. */
if (op->stats.sp == SP_METEOR)
{
@@ -648,8 +648,8 @@
tmp->set_owner (op);
set_spell_skill (op, caster, spob, tmp);
- tmp->x = op->x + freearr_x[dir];
- tmp->y = op->y + freearr_y[dir];
+ tmp->x = op->x + DIRX (dir);
+ tmp->y = op->y + DIRY (dir);
tmp->map = op->map;
maptile *newmap;
@@ -756,7 +756,7 @@
/* Check to see if we should push anything.
* Spell objects with weight push whatever they encounter to some
- * degree.
+ * degree.
*/
if (op->weight)
{
@@ -783,7 +783,7 @@
for (int i = -1; i <= 1; i++)
{
- sint16 x = op->x + freearr_x[absdir (op->stats.sp + i)], y = op->y + freearr_y[absdir (op->stats.sp + i)];
+ sint16 x = op->x + DIRX (absdir (op->stats.sp + i)), y = op->y + DIRY (absdir (op->stats.sp + i));
if (ok_to_put_more (op->map, x, y, op, op->attacktype))
{
@@ -866,8 +866,8 @@
continue;
}
- x = op->x + freearr_x[d];
- y = op->y + freearr_y[d];
+ x = op->x + DIRX (d);
+ y = op->y + DIRY (d);
if (get_map_flags (op->map, &m, x, y, &sx, &sy) & P_OUT_OF_MAP)
continue;
@@ -985,7 +985,7 @@
{
for (int i = 1; i < 9; i++)
{
- if (out_of_map (op->map, op->x + freearr_x[i], op->y + freearr_x[i]))
+ if (out_of_map (op->map, op->x + DIRX (i), op->y + DIRX (i)))
continue;
object *tmp = at->instance ();
@@ -1001,7 +1001,7 @@
if (tmp->flag [FLAG_IS_TURNABLE])
SET_ANIMATION (tmp, i);
- op->map->insert (tmp, op->x + freearr_x[i], op->y + freearr_x[i], op);
+ op->map->insert (tmp, op->x + DIRX (i), op->y + DIRX (i), op);
move_bullet (tmp);
}
}
@@ -1014,7 +1014,7 @@
{
object *tmp;
int mflags;
- sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir];
+ sint16 dx = op->x + DIRX (dir), dy = op->y + DIRY (dir);
maptile *m;
mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy);
@@ -1075,8 +1075,8 @@
for (dist = 1; dist < range; dist++)
{
- x = op->x + freearr_x[dir] * dist;
- y = op->y + freearr_y[dir] * dist;
+ x = op->x + DIRX (dir) * dist;
+ y = op->y + DIRY (dir) * dist;
mp = op->map;
mflags = get_map_flags (op->map, &mp, x, y, &x, &y);
@@ -1098,8 +1098,8 @@
return NULL;
}
-/* cast_smite_arch() - the priest points to a creature and causes
- * a 'godly curse' to decend.
+/* cast_smite_spell() - the priest points to a creature and causes
+ * a 'godly curse' to decend.
* usual params -
* op = player
* caster = object casting the spell.
@@ -1111,12 +1111,10 @@
{
object *effect, *target;
object *god = find_god (determine_god (op));
- int range;
- range = spell->range + SP_level_range_adjust (caster, spell);
target = get_pointed_target (op, dir, 50, spell->stats.grace ? SPELL_GRACE : SPELL_MANA);
- /* Bunch of conditions for casting this spell. Note that only
+ /* Bunch of conditions for casting this spell. Note that only
* require a god if this is a cleric spell (requires grace).
* This makes this spell much more general purpose - it can be used
* by wizards also, which is good, because I think this is a very
@@ -1254,9 +1252,9 @@
****************************************************************************/
/* make_object_glow() - currently only makes living objects glow.
- * we do this by creating a force and inserting it in the
+ * we do this by creating a force and inserting it in the
* object. if time is 0, the object glows permanently. To truely
- * make this work for non-living objects, we would have to
+ * make this work for non-living objects, we would have to
* give them the capability to have an inventory. b.t.
*/
static int
@@ -1463,7 +1461,7 @@
mapspace &ms = m->at (nx, ny);
/* If there is nothing living on this space, no need to go further */
- if (!ms.flags () & P_IS_ALIVE)
+ if (!(ms.flags () & P_IS_ALIVE))
continue;
// players can only affect spaces that they can actually see
@@ -1625,8 +1623,8 @@
int offset = ((i ^ j) & 1) ? (i / 2) : -(i / 2);
int tmpdir = absdir (op->direction + offset);
- nx = op->x + freearr_x[tmpdir];
- ny = op->y + freearr_y[tmpdir];
+ nx = op->x + DIRX (tmpdir);
+ ny = op->y + DIRY (tmpdir);
if (!(get_map_flags (op->map, &m, nx, ny, &nx, &ny) & P_OUT_OF_MAP) && !(OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, nx, ny))))
{
dir = tmpdir;
@@ -1643,7 +1641,7 @@
m->insert (op, nx, ny, op);
- dam_save = op->stats.dam; /* save the original dam: we do halfdam on
+ dam_save = op->stats.dam; /* save the original dam: we do halfdam on
surrounding squares */
/* loop over current square and neighbors to hit.
@@ -1652,8 +1650,8 @@
*/
for (j = 0; j < 9; j++)
{
- hx = nx + freearr_x[j];
- hy = ny + freearr_y[j];
+ hx = nx + DIRX (j);
+ hy = ny + DIRY (j);
m = op->map;
mflags = get_map_flags (m, &m, hx, hy, &hx, &hy);
@@ -1686,7 +1684,7 @@
if (i >= 0)
{ /* we have a preferred direction! */
/* pick another direction if the preferred dir is blocked. */
- if (get_map_flags (op->map, &m, nx + freearr_x[i], ny + freearr_y[i], &hx, &hy) & P_OUT_OF_MAP ||
+ if (get_map_flags (op->map, &m, nx + DIRX (i), ny + DIRY (i), &hx, &hy) & P_OUT_OF_MAP ||
OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, hx, hy)))
i = absdir (i + rndm (0, 2) - 1); /* -1, 0, +1 */
@@ -1694,12 +1692,12 @@
}
}
-/* move_swarm_spell: peterm
+/* move_swarm_spell: peterm
* This is an implementation of the swarm spell. It was written for
* meteor swarm, but it could be used for any swarm. A swarm spell
* is a special type of object that casts swarms of other types
* of spells. Which spell it casts is flexible. It fires the spells
- * from a set of squares surrounding the caster, in a given direction.
+ * from a set of squares surrounding the caster, in a given direction.
*/
void
move_swarm_spell (object *op)
@@ -1745,7 +1743,7 @@
// (schmorp)
/* new offset calculation to make swarm element distribution
- * more uniform
+ * more uniform
*/
if (op->duration)
{
@@ -1763,14 +1761,14 @@
adjustdir = 0; /* fire the last one from forward. */
}
- target_x = op->x + freearr_x[absdir (basedir + adjustdir)];
- target_y = op->y + freearr_y[absdir (basedir + adjustdir)];
+ target_x = op->x + DIRX (absdir (basedir + adjustdir));
+ target_y = op->y + DIRY (absdir (basedir + adjustdir));
/* back up one space so we can hit point-blank targets, but this
- * necessitates extra out_of_map check below
+ * necessitates extra out_of_map check below
*/
- origin_x = target_x - freearr_x[basedir];
- origin_y = target_y - freearr_y[basedir];
+ origin_x = target_x - DIRX (basedir);
+ origin_y = target_y - DIRY (basedir);
/* spell pointer is set up for the spell this casts. Since this
@@ -1811,7 +1809,7 @@
/* fire_swarm:
* The following routine creates a swarm of objects. It actually
* sets up a specific swarm object, which then fires off all
- * the parts of the swarm.
+ * the parts of the swarm.
*
* op: the owner
* caster: the caster (owner, wand, rod, scroll)
@@ -1866,8 +1864,8 @@
if (dir)
{
- x = op->x + freearr_x[dir];
- y = op->y + freearr_y[dir];
+ x = op->x + DIRX (dir);
+ y = op->y + DIRY (dir);
m = op->map;
mflags = get_map_flags (m, &m, x, y, &x, &y);
@@ -1924,7 +1922,7 @@
}
/* cast_cause_disease: this spell looks along from the
- * player and infects someone.
+ * player and infects someone.
* op is the player/monster, caster is the object, dir is the direction
* to cast, disease_arch is the specific disease, and type is the spell number
* perhaps this should actually be in disease.c?
@@ -1940,7 +1938,7 @@
x = op->x;
y = op->y;
- /* If casting from a scroll, no direction will be available, so refer to the
+ /* If casting from a scroll, no direction will be available, so refer to the
* direction the player is pointing.
*/
if (!dir)
@@ -1957,8 +1955,8 @@
/* search in a line for a victim */
for (i = 1; i < range; i++)
{
- x = op->x + i * freearr_x[dir];
- y = op->y + i * freearr_y[dir];
+ x = op->x + i * DIRX (dir);
+ y = op->y + i * DIRY (dir);
m = op->map;
mflags = get_map_flags (m, &m, x, y, &x, &y);
@@ -1998,8 +1996,8 @@
disease->last_sp = 1;
}
- if (disease->stats.dam ) disease->stats.dam += copysign (disease->stats.dam , dam_mod);
- if (disease->stats.maxsp) disease->stats.maxsp += copysign (disease->stats.maxsp, dam_mod);
+ if (disease->stats.dam ) disease->stats.dam += copysignl (disease->stats.dam , dam_mod);
+ if (disease->stats.maxsp) disease->stats.maxsp += copysignl (disease->stats.maxsp, dam_mod);
if (disease->stats.ac ) disease->stats.ac += dam_mod;
if (disease->last_eat ) disease->last_eat -= dam_mod;
if (disease->stats.hp ) disease->stats.hp -= dam_mod;