summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-12-01 12:09:07 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-12-01 12:12:34 +0100
commitbce5f7020a13edbceb605979a3b73fdfe590a0cf (patch)
treef35f77649b8fc49939c67608d415dbd9b8c0efcf
parent20889107ee4ef5e7f61b1facfdf4da4bc97935b6 (diff)
downloadcrawl-ref-bce5f7020a13edbceb605979a3b73fdfe590a0cf.tar.gz
crawl-ref-bce5f7020a13edbceb605979a3b73fdfe590a0cf.zip
Make passwall use standard targetting system.
This means it's properly abortable now.
-rw-r--r--crawl-ref/source/spells4.cc28
-rw-r--r--crawl-ref/source/spells4.h2
-rw-r--r--crawl-ref/source/spl-cast.cc4
-rw-r--r--crawl-ref/source/spl-data.h6
-rw-r--r--crawl-ref/source/spl-util.cc7
5 files changed, 18 insertions, 29 deletions
diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc
index 1a03080638..242d8c6c9e 100644
--- a/crawl-ref/source/spells4.cc
+++ b/crawl-ref/source/spells4.cc
@@ -898,32 +898,33 @@ int make_a_normal_cloud(coord_def where, int pow, int spread_rate,
return 1;
}
-static int _passwall(coord_def where, int pow, int, actor *)
+bool cast_passwall(const coord_def& delta, int pow)
{
int howdeep = 0;
bool done = false;
int shallow = 1 + (you.skills[SK_EARTH_MAGIC] / 8);
+ coord_def n = you.pos() + delta;
// Irony: you can start on a secret door but not a door.
// Worked stone walls are out, they're not diggable and
// are used for impassable walls... I'm not sure we should
// even allow statues (should be contiguous rock). -- bwr
// XXX: Allow statues as entry points?
- if (grd(where) != DNGN_ROCK_WALL && grd(where) != DNGN_CLEAR_ROCK_WALL)
+ if (grd(n) != DNGN_ROCK_WALL && grd(n) != DNGN_CLEAR_ROCK_WALL)
{
mpr("That's not a passable wall.");
- return 0;
+ return (false);
}
- coord_def delta = where - you.pos();
- coord_def n = where;
+ // Below here, failing to cast yields information to the
+ // player, so we don't make the spell abort (return true).
while (!done)
{
if (!in_bounds(n))
{
mpr("You sense an overwhelming volume of rock.");
- return 0;
+ return (true);
}
switch (grd(n))
@@ -932,7 +933,7 @@ static int _passwall(coord_def where, int pow, int, actor *)
if (feat_is_solid(grd(n)))
{
mpr("Something is blocking your path through the rock.");
- return 0;
+ return (true);
}
done = true;
break;
@@ -952,22 +953,13 @@ static int _passwall(coord_def where, int pow, int, actor *)
int maxrange = shallow + pow / 25;
if (howdeep >= maxrange)
- {
mprf("This rock feels extremely deep.");
- return 0;
- }
-
- if (howdeep > range)
+ else if (howdeep > range)
mprf("You fail to penetrate the rock.");
else // Passwall delay is reduced, and the delay cannot be interrupted.
start_delay(DELAY_PASSWALL, 1 + howdeep, n.x, n.y);
- return 1;
-}
-
-void cast_passwall(int pow)
-{
- apply_one_neighbouring_square(_passwall, pow);
+ return (true);
}
static int _intoxicate_monsters(coord_def where, int pow, int, actor *)
diff --git a/crawl-ref/source/spells4.h b/crawl-ref/source/spells4.h
index f587f661ca..fbadac0203 100644
--- a/crawl-ref/source/spells4.h
+++ b/crawl-ref/source/spells4.h
@@ -33,7 +33,7 @@ bool cast_apportation(int powc, const coord_def& where);
void cast_ignite_poison(int pow);
void cast_intoxicate(int pow);
void cast_mass_sleep(int pow);
-void cast_passwall(int pow);
+bool cast_passwall(const coord_def& delta, int pow);
bool wielding_rocks();
bool cast_sandblast(int powc, bolt &beam);
void cast_see_invisible(int pow);
diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc
index 9f73adf013..e35944c8ce 100644
--- a/crawl-ref/source/spl-cast.cc
+++ b/crawl-ref/source/spl-cast.cc
@@ -195,6 +195,7 @@ static bool _spell_no_hostile_in_range(spell_type spell, int minRange)
case SPELL_PROJECTED_NOISE:
case SPELL_CONJURE_FLAME:
case SPELL_DIG:
+ case SPELL_PASSWALL:
// Airstrike has LOS_RANGE and can go through glass walls.
case SPELL_AIRSTRIKE:
@@ -2192,7 +2193,8 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail)
break;
case SPELL_PASSWALL:
- cast_passwall(powc);
+ if (!cast_passwall(spd.delta, powc))
+ return (SPRET_ABORT);
break;
case SPELL_APPORTATION:
diff --git a/crawl-ref/source/spl-data.h b/crawl-ref/source/spl-data.h
index 8b6392e322..27f1ea2632 100644
--- a/crawl-ref/source/spl-data.h
+++ b/crawl-ref/source/spl-data.h
@@ -1625,12 +1625,12 @@
},
{
- SPELL_PASSWALL, "Passwall",
+ SPELL_PASSWALL, "Passwall",
SPTYP_TRANSMUTATION | SPTYP_EARTH,
- SPFLAG_ESCAPE,
+ SPFLAG_DIR | SPFLAG_ESCAPE,
3,
200,
- -1, -1,
+ 1, 1,
-3, // make silent to keep passwall a viable stabbing spell [rob]
NULL,
false,
diff --git a/crawl-ref/source/spl-util.cc b/crawl-ref/source/spl-util.cc
index a374f18771..2f32ea67e1 100644
--- a/crawl-ref/source/spl-util.cc
+++ b/crawl-ref/source/spl-util.cc
@@ -652,12 +652,7 @@ int apply_one_neighbouring_square(cell_func cf, int power, actor *agent)
return (-1);
}
- int rv = cf(you.pos() + bmove.delta, power, 1, agent);
-
- if (rv == 0)
- canned_msg(MSG_NOTHING_HAPPENS);
-
- return (rv);
+ return cf(you.pos() + bmove.delta, power, 1, agent);
}
int apply_area_within_radius(cell_func cf, const coord_def& where,