From dc3f573c6ef467ddcc4a837ce90ca9df3b502c2e Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Thu, 5 Nov 2009 20:50:54 +0100 Subject: 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. --- crawl-ref/source/spells1.cc | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'crawl-ref/source/spells1.cc') diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index 0267230e41..e94fc43957 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -117,27 +117,12 @@ int blink(int pow, bool high_level_controlled_blink, bool wizard_blink) return (-1); // early return {dlb} } - if (!wizard_blink && you.duration[DUR_MESMERISED]) + monsters* beholder = you.get_beholder(beam.target); + if (!wizard_blink && 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(beam.target, mon.pos()); - - if (olddist < newdist) - { - mprf("You cannot blink away from %s!", - mon.name(DESC_NOCAP_THE, true).c_str()); - - blocked_movement = true; - break; - } - } - - if (blocked_movement) - continue; + mprf("You cannot blink away from %s!", + beholder->name(DESC_NOCAP_THE, true).c_str()); + continue; } if (grd(beam.target) == DNGN_OPEN_SEA) -- cgit v1.2.3-54-g00ecf