summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spells4.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-12-01 12:29:48 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-12-01 12:31:03 +0100
commita825726eed2e6f9387c495d6858170aa22983bed (patch)
tree6da0cb06674610c11f02d60e65b353b206b87c08 /crawl-ref/source/spells4.cc
parentbce5f7020a13edbceb605979a3b73fdfe590a0cf (diff)
downloadcrawl-ref-a825726eed2e6f9387c495d6858170aa22983bed.tar.gz
crawl-ref-a825726eed2e6f9387c495d6858170aa22983bed.zip
Simplify passwall.
Treatment of entry point and later obstacles is unified. It doesn't work as "detect secret door" anymore. This also means that you can now passwall into statues -- before, you could passwall through them but not start with one.
Diffstat (limited to 'crawl-ref/source/spells4.cc')
-rw-r--r--crawl-ref/source/spells4.cc83
1 files changed, 37 insertions, 46 deletions
diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc
index 242d8c6c9e..eea4f514e8 100644
--- a/crawl-ref/source/spells4.cc
+++ b/crawl-ref/source/spells4.cc
@@ -898,67 +898,58 @@ int make_a_normal_cloud(coord_def where, int pow, int spread_rate,
return 1;
}
-bool cast_passwall(const coord_def& delta, int pow)
+bool _feat_is_passwallable(dungeon_feature_type feat)
{
- 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.
+ // Irony: you can passwall through 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(n) != DNGN_ROCK_WALL && grd(n) != DNGN_CLEAR_ROCK_WALL)
+ switch (feat)
{
- mpr("That's not a passable wall.");
+ case DNGN_ROCK_WALL:
+ case DNGN_CLEAR_ROCK_WALL:
+ case DNGN_ORCISH_IDOL:
+ case DNGN_GRANITE_STATUE:
+ case DNGN_SECRET_DOOR:
+ return (true);
+ default:
return (false);
}
+}
- // Below here, failing to cast yields information to the
- // player, so we don't make the spell abort (return true).
+bool cast_passwall(const coord_def& delta, int pow)
+{
+ int shallow = 1 + (you.skills[SK_EARTH_MAGIC] / 8);
+ int range = shallow + random2(pow) / 25;
+ int maxrange = shallow + pow / 25;
- while (!done)
+ coord_def n = you.pos() + delta;
+ if (!_feat_is_passwallable(grid_appearance(n)))
{
- if (!in_bounds(n))
- {
- mpr("You sense an overwhelming volume of rock.");
- return (true);
- }
-
- switch (grd(n))
- {
- default:
- if (feat_is_solid(grd(n)))
- {
- mpr("Something is blocking your path through the rock.");
- return (true);
- }
- done = true;
- break;
-
- case DNGN_ROCK_WALL:
- case DNGN_CLEAR_ROCK_WALL:
- case DNGN_ORCISH_IDOL:
- case DNGN_GRANITE_STATUE:
- case DNGN_SECRET_DOOR:
- n += delta;
- howdeep++;
- break;
- }
+ mpr("That's not a passable wall.");
+ return (false);
}
- int range = shallow + random2(pow) / 25;
- int maxrange = shallow + pow / 25;
+ // Below here, failing to cast yields information to the
+ // player, so we don't make the spell abort (return true).
- if (howdeep >= maxrange)
- mprf("This rock feels extremely deep.");
+ int howdeep;
+ for (howdeep = 1; in_bounds(n) && _feat_is_passwallable(grd(n));
+ n += delta, howdeep++);
+
+ if (!in_bounds(n))
+ mpr("You sense an overwhelming volume of rock.");
+ else if (feat_is_solid(grd(n)))
+ mpr("Something is blocking your path through the rock.");
+ else if (howdeep > maxrange)
+ mpr("This rock feels extremely deep.");
else if (howdeep > range)
- mprf("You fail to penetrate the rock.");
- else // Passwall delay is reduced, and the delay cannot be interrupted.
+ mpr("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 (true);
}