From 5511b48771d9a12e3e622e375220091cf94023dd Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Fri, 3 Oct 2008 16:17:52 +0000 Subject: * Make movement restrictions when beheld also apply to blinking and controlled teleport. * Highlight restricted grids when beheld (ASCII only): - main screen: restricted grids in LOS are darkgrey - X screen: unrestricted grids in view around the mermaid(s) are lightgrey * switch xx command back to leaving examine mode git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7105 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/spells3.cc | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'crawl-ref/source/spells3.cc') diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index 8d1f5d8410..3a00fd310d 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -1204,7 +1204,7 @@ bool cast_death_channel(int pow, god_type god) bool allow_control_teleport(bool quiet) { bool retval = !(testbits(env.level_flags, LFLAG_NO_TELE_CONTROL) - || testbits(get_branch_flags(), BFLAG_NO_TELE_CONTROL)); + || testbits(get_branch_flags(), BFLAG_NO_TELE_CONTROL)); // Tell the player why if they have teleport control. if (!quiet && !retval && player_control_teleport()) @@ -1281,14 +1281,42 @@ static bool _teleport_player( bool allow_control, bool new_abyss_area ) mpr("Expect minor deviation."); more(); - show_map(pos, false); - - redraw_screen(); + while (true) + { + show_map(pos, false); + redraw_screen(); #if DEBUG_DIAGNOSTICS - mprf(MSGCH_DIAGNOSTICS, "Target square (%d,%d)", pos.x, pos.y ); + mprf(MSGCH_DIAGNOSTICS, "Target square (%d,%d)", pos.x, pos.y ); #endif + if (you.duration[DUR_BEHELD]) + { + bool blocked_movement = false; + for (unsigned int i = 0; i < you.beheld_by.size(); i++) + { + monsters& mon = menv[you.beheld_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; + } + break; + } + pos.x += random2(3) - 1; pos.y += random2(3) - 1; -- cgit v1.2.3-54-g00ecf