summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/acr.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-15 06:36:07 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-15 06:36:07 +0000
commit62cba73fa0b680b992c6c11ba59268617abd35ae (patch)
tree2895b3f5acd644d2579c5798c913207d0cf8cf33 /crawl-ref/source/acr.cc
parenta1b82e6be0343a691d342b48dd9f9076ad53453a (diff)
downloadcrawl-ref-62cba73fa0b680b992c6c11ba59268617abd35ae.tar.gz
crawl-ref-62cba73fa0b680b992c6c11ba59268617abd35ae.zip
Some fixes for mermaid beholding:
* A mermaid stops beholding if it polymorphs into something else. * If new walls are created, then Crawl stops the beholdment of any mermaid that gets hidden by the new walls. * Do paranoid sanity checking on beholders before each command with check_beholders() and try to restore sanity if any bugs are found (and give a diagnostics message if DEBUG is set). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2465 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/acr.cc')
-rw-r--r--crawl-ref/source/acr.cc30
1 files changed, 26 insertions, 4 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index c52b723e25..fa477bac6d 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -1231,6 +1231,7 @@ bool apply_berserk_penalty = false;
static void input()
{
crawl_state.clear_god_acting();
+ check_beholders();
if (crawl_state.is_replaying_keys() && crawl_state.is_repeating_cmd()
&& kbhit())
@@ -1454,11 +1455,26 @@ static bool toggle_flag( bool* flag, const char* flagname )
return *flag;
}
+static bool stairs_check_beheld()
+{
+ if (you.duration[DUR_BEHELD] && !you.duration[DUR_CONF])
+ {
+ mprf("You cannot move away from %s!",
+ menv[you.beheld_by[0]].name(DESC_NOCAP_THE, true).c_str());
+ return true;
+ }
+
+ return false;
+}
+
static void go_downstairs();
static void go_upstairs()
{
const dungeon_feature_type ygrd = grd(you.pos());
+ if (stairs_check_beheld())
+ return;
+
// Allow both < and > to work for Abyss exits.
if (ygrd == DNGN_EXIT_ABYSS)
{
@@ -1500,6 +1516,10 @@ static void go_downstairs()
bool shaft = (trap_type_at_xy(you.x_pos, you.y_pos) == TRAP_SHAFT
&& grd[you.x_pos][you.y_pos] != DNGN_UNDISCOVERED_TRAP);
+
+ if (stairs_check_beheld())
+ return;
+
if (shaft && you.flies() == FL_LEVITATE)
{
mpr("You can't fall through a shaft while levitating.");
@@ -3663,14 +3683,16 @@ static void move_player(int move_x, int move_y)
{
for (unsigned int i = 0; i < you.beheld_by.size(); i++)
{
- coord_def pos = menv[you.beheld_by[i]].pos();
+ monsters* mon = &menv[you.beheld_by[i]];
+ coord_def pos = mon->pos();
int olddist = distance(you.x_pos, you.y_pos, pos.x, pos.y);
- int newdist = distance(you.x_pos + move_x, you.y_pos + move_y, pos.x, pos.y);
-
+ int newdist = distance(you.x_pos + move_x, you.y_pos + move_y,
+ pos.x, pos.y);
+
if (olddist < newdist)
{
mprf("You cannot move away from %s!",
- (menv[you.beheld_by[i]]).name(DESC_NOCAP_THE, true).c_str());
+ mon->name(DESC_NOCAP_THE, true).c_str());
move_x = 0;
move_y = 0;