summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spells3.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-05 20:50:54 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-05 22:30:03 +0100
commitdc3f573c6ef467ddcc4a837ce90ca9df3b502c2e (patch)
treef7915736d0a9bad11d83c3ff8a0263577a27e979 /crawl-ref/source/spells3.cc
parent31124ec682c2b826f169c23e808fa741a3033a04 (diff)
downloadcrawl-ref-dc3f573c6ef467ddcc4a837ce90ca9df3b502c2e.tar.gz
crawl-ref-dc3f573c6ef467ddcc4a837ce90ca9df3b502c2e.zip
Unify mesmerisation code.
There were several places that had copies of the same code, checking whether mesmerisation blocked movement to a given target. The various mesmerisation functions have become methods of player and were moved into behold.cc.
Diffstat (limited to 'crawl-ref/source/spells3.cc')
-rw-r--r--crawl-ref/source/spells3.cc50
1 files changed, 9 insertions, 41 deletions
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc
index d6293b7063..9ccd1ec3e7 100644
--- a/crawl-ref/source/spells3.cc
+++ b/crawl-ref/source/spells3.cc
@@ -1478,30 +1478,16 @@ static bool _teleport_player(bool allow_control, bool new_abyss_area)
return (false);
}
- if (you.duration[DUR_MESMERISED])
+ monsters *beholder = you.get_beholder(pos);
+ if (beholder)
{
- bool blocked_movement = false;
- for (unsigned int i = 0; i < you.mesmerised_by.size(); i++)
- {
- monsters& mon = menv[you.mesmerised_by[i]];
- const int olddist = grid_distance(you.pos(), mon.pos());
- const int newdist = grid_distance(pos, mon.pos());
-
- if (olddist < newdist)
- {
- mprf("You cannot teleport away from %s!",
- mon.name(DESC_NOCAP_THE, true).c_str());
- mpr("Choose another destination (press '.' or delete to select).");
- more();
-
- blocked_movement = true;
- break;
- }
- }
-
- if (blocked_movement)
- continue;
+ mprf("You cannot teleport away from %s!",
+ beholder->name(DESC_NOCAP_THE, true).c_str());
+ mpr("Choose another destination (press '.' or delete to select).");
+ more();
+ continue;
}
+
break;
}
@@ -1717,25 +1703,7 @@ bool entomb(int powc)
if (number_built > 0)
{
mpr("Walls emerge from the floor!");
-
- for (int i = you.mesmerised_by.size() - 1; i >= 0; i--)
- {
- const monsters* mon = &menv[you.mesmerised_by[i]];
- int walls = num_feats_between(you.pos(), mon->pos(),
- DNGN_UNSEEN, DNGN_MAXWALL,
- true, true);
-
- if (walls > 0)
- {
- update_beholders(mon, true);
- if (you.mesmerised_by.empty())
- {
- you.duration[DUR_MESMERISED] = 0;
- break;
- }
- continue;
- }
- }
+ you.update_beholders();
}
else
canned_msg(MSG_NOTHING_HAPPENS);