summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/decks.cc116
-rw-r--r--crawl-ref/source/xom.cc9
-rw-r--r--crawl-ref/source/xom.h2
3 files changed, 9 insertions, 118 deletions
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index 3ed36f6f9d..8c6aaad9e3 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -1559,120 +1559,6 @@ static void _minefield_card(int power, deck_rarity_type rarity)
static int stair_draw_count = 0;
-static void _move_stair(coord_def stair_pos, bool away)
-{
- ASSERT(stair_pos != you.pos());
-
- dungeon_feature_type feat = grd(stair_pos);
- ASSERT(grid_stair_direction(feat) != CMD_NO_CMD);
-
- coord_def begin, towards;
-
- if (away)
- {
- begin = you.pos();
- towards = stair_pos;
- }
- else
- {
- // Can't move towards player if it's already adjacent.
- if (adjacent(you.pos(), stair_pos))
- return;
-
- begin = stair_pos;
- towards = you.pos();
- }
-
- ray_def ray;
- if (!find_ray(begin, towards, ray))
- {
- mpr("Couldn't find ray between player and stairs.", MSGCH_ERROR);
- return;
- }
-
- // Don't start off under the player.
- if (away)
- ray.advance();
-
- bool found_stairs = false;
- int past_stairs = 0;
- while ( in_bounds(ray.pos()) && see_grid(ray.pos())
- && !grid_is_solid(ray.pos()) && ray.pos() != you.pos() )
- {
- if (ray.pos() == stair_pos)
- found_stairs = true;
- if (found_stairs)
- past_stairs++;
- ray.advance();
- }
- past_stairs--;
-
- if (!away && grid_is_solid(ray.pos()))
- // Transparent wall between stair and player.
- return;
-
- if (away && !found_stairs)
- {
- if (grid_is_solid(ray.pos()))
- // Transparent wall between stair and player.
- return;
-
- mpr("Ray didn't cross stairs.", MSGCH_ERROR);
- }
-
- if (away && past_stairs <= 0)
- // Stairs already at edge, can't move further away.
- return;
-
- if (!in_bounds(ray.pos()) || ray.pos() == you.pos())
- ray.regress();
-
- while (!see_grid(ray.pos()) || grd(ray.pos()) != DNGN_FLOOR)
- {
- ray.regress();
- if (!in_bounds(ray.pos()) || ray.pos() == you.pos()
- || ray.pos() == stair_pos)
- {
- // No squares in path are a plain floor.
- return;
- }
- }
-
- ASSERT(stair_pos != ray.pos());
-
- std::string stair_str =
- feature_description(stair_pos, false, DESC_CAP_THE, false);
-
- mprf("%s slides %s you!", stair_str.c_str(),
- away ? "away from" : "towards");
-
- // Animate stair moving.
- const feature_def &feat_def = get_feature_def(feat);
-
- bolt beam;
-
- beam.range = INFINITE_DISTANCE;
- beam.flavour = BEAM_VISUAL;
- beam.type = feat_def.symbol;
- beam.colour = feat_def.colour;
- beam.source = stair_pos;
- beam.target = ray.pos();
- beam.name = "STAIR BEAM";
- beam.draw_delay = 50; // Make beam animation slower than normal.
-
- beam.aimed_at_spot = true;
- beam.fire();
-
- // Clear out "missile trails"
- viewwindow(true, false);
-
- if (!swap_features(stair_pos, ray.pos(), false, false))
- {
- mprf(MSGCH_ERROR, "_move_stair(): failed to move %s",
- stair_str.c_str());
- }
-}
-
// This does not describe an actual card. Instead, it only exists to test
// the stair movement effect in wizard mode ("&c stairs").
static void _stairs_card(int power, deck_rarity_type rarity)
@@ -1709,7 +1595,7 @@ static void _stairs_card(int power, deck_rarity_type rarity)
std::random_shuffle(stairs_avail.begin(), stairs_avail.end());
for (unsigned int i = 0; i < stairs_avail.size(); ++i)
- _move_stair(stairs_avail[i], stair_draw_count % 2);
+ move_stair(stairs_avail[i], stair_draw_count % 2, false);
stair_draw_count++;
}
diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc
index 839853b40b..8c30858bcb 100644
--- a/crawl-ref/source/xom.cc
+++ b/crawl-ref/source/xom.cc
@@ -2877,8 +2877,11 @@ static bool _valid_floor_grid(coord_def pos)
return (grd(pos) == DNGN_FLOOR);
}
-static bool _move_stair(coord_def stair_pos, bool away)
+bool move_stair(coord_def stair_pos, bool away, bool allow_under)
{
+ if (!allow_under)
+ ASSERT(stair_pos != you.pos());
+
dungeon_feature_type feat = grd(stair_pos);
ASSERT(grid_stair_direction(feat) != CMD_NO_CMD);
@@ -2889,7 +2892,7 @@ static bool _move_stair(coord_def stair_pos, bool away)
{
// If the staircase starts out under the player, first shove it
// onto a neighbouring grid.
- if (stair_pos == you.pos())
+ if (allow_under && stair_pos == you.pos())
{
coord_def new_pos(stair_pos);
// Loop twice through all adjacent grids. In the first round,
@@ -3094,7 +3097,7 @@ static int _xom_repel_stairs(bool debug = false)
std::random_shuffle(stairs_avail.begin(), stairs_avail.end());
int count_moved = 0;
for (unsigned int i = 0; i < stairs_avail.size(); i++)
- if (_move_stair(stairs_avail[i], true))
+ if (move_stair(stairs_avail[i], true, true))
count_moved++;
if (!count_moved)
diff --git a/crawl-ref/source/xom.h b/crawl-ref/source/xom.h
index 047f5196b5..25706fb1ab 100644
--- a/crawl-ref/source/xom.h
+++ b/crawl-ref/source/xom.h
@@ -90,4 +90,6 @@ void xom_death_message(const kill_method_type killed_by);
void debug_xom_effects();
#endif
+bool move_stair(coord_def stair_pos, bool away, bool allow_under);
+
#endif