diff options
author | Nicholas Feinberg <pleasingfung@gmail.com> | 2014-07-27 23:13:28 -0700 |
---|---|---|
committer | Nicholas Feinberg <pleasingfung@gmail.com> | 2014-07-27 23:13:28 -0700 |
commit | f87c007a08e93a46c9fe349809db53880fe5ba87 (patch) | |
tree | f8a1f1ea9a047939b8c9309c1544d53a13ea7dc5 /crawl-ref/source/melee_attack.cc | |
parent | ac7ffddb0e317f7ef15a02a210f0e7eade5f35dd (diff) | |
download | crawl-ref-f87c007a08e93a46c9fe349809db53880fe5ba87.tar.gz crawl-ref-f87c007a08e93a46c9fe349809db53880fe5ba87.zip |
Move move_stairs() from misc.cc to melee_attack.cc
The only place it was used.
Diffstat (limited to 'crawl-ref/source/melee_attack.cc')
-rw-r--r-- | crawl-ref/source/melee_attack.cc | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/crawl-ref/source/melee_attack.cc b/crawl-ref/source/melee_attack.cc index adb5edf259..08733a3b0e 100644 --- a/crawl-ref/source/melee_attack.cc +++ b/crawl-ref/source/melee_attack.cc @@ -1954,6 +1954,35 @@ void melee_attack::rot_defender(int amount, int immediate) } } +/** + * Attempt to move a set of stairs from one place to another. + * + * @param orig The current location of the stiars. + * @param dest The desired destination. + * @return Whether the stairs were moved. + */ +static bool _move_stairs(coord_def orig, coord_def dest) +{ + const dungeon_feature_type stair_feat = grd(orig); + + if (feat_stair_direction(stair_feat) == CMD_NO_CMD) + return false; + + // The player can't use shops to escape, so don't bother. + if (stair_feat == DNGN_ENTER_SHOP) + return false; + + // Don't move around notable terrain the player is aware of if it's + // out of sight. + if (is_notable_terrain(stair_feat) + && env.map_knowledge(orig).known() && !you.see_cell(orig)) + { + return false; + } + + return slide_feature_over(orig, dest); +} + void melee_attack::chaos_affects_attacker() { if (miscast_level >= 1 || !attacker->alive()) @@ -1965,7 +1994,7 @@ void melee_attack::chaos_affects_attacker() dest = defender->pos(); // Move stairs out from under the attacker. - if (one_chance_in(100) && move_stairs(attack_position, dest)) + if (one_chance_in(100) && _move_stairs(attack_position, dest)) { #ifdef NOTE_DEBUG_CHAOS_EFFECTS take_note(Note(NOTE_MESSAGE, 0, 0, |