From de8f8489a0d497cd8288f55a2054747c2e59b19c Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Sat, 14 Nov 2009 14:00:19 +0100 Subject: Add actor::blink_to for handling blink movement and messaging. --- crawl-ref/source/teleport.cc | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'crawl-ref/source/teleport.cc') diff --git a/crawl-ref/source/teleport.cc b/crawl-ref/source/teleport.cc index 30941b1d20..3d0f4d5164 100644 --- a/crawl-ref/source/teleport.cc +++ b/crawl-ref/source/teleport.cc @@ -13,6 +13,8 @@ #include "env.h" #include "fprop.h" #include "los.h" +#include "monster.h" +#include "mon-stuff.h" #include "player.h" #include "random.h" #include "random-weight.h" @@ -46,6 +48,48 @@ static coord_def random_close_space(actor* victim, actor* target) return (choice ? *choice : coord_def(0, 0)); } +bool player::blink_to(const coord_def& dest, bool quiet) +{ + // We rely on the non-generalized move_player_to_cell. + ASSERT(this == &you); + + if (dest == pos()) + return (false); + if (!quiet) + mpr("You blink."); + const coord_def origin = pos(); + if (!move_player_to_grid(dest, false, true, true)) + return (false); + place_cloud(CLOUD_TLOC_ENERGY, origin, 1 + random2(3), KC_YOU); + return (true); +} + +bool monsters::blink_to(const coord_def& dest, bool quiet) +{ + if (dest == pos()) + return (false); + if (!quiet) + simple_monster_message(this, " blinks!"); + + if (!(flags & MF_WAS_IN_VIEW)) + seen_context = "thin air"; + + const coord_def oldplace = pos(); + if (!move_to_pos(dest)) + return (false); + + // Leave a purple cloud. + place_cloud(CLOUD_TLOC_ENERGY, oldplace, 1 + random2(3), + kill_alignment()); + + check_redraw(oldplace); + apply_location_effects(oldplace); + + mons_relocated(this); + + return (true); +} + // Blink the player closer to the monster at target. void blink_closer(const coord_def &target) { -- cgit v1.2.3-54-g00ecf