From ccda4c78a720bd7c7f96bfa510131adf077ca1f2 Mon Sep 17 00:00:00 2001 From: dolorous Date: Tue, 4 Dec 2007 06:11:53 +0000 Subject: Fix [1842182]: Casting either "Detect Traps" or "Detect Creatures" now displays "You detect nothing." if nothing is found, just as casting "Detect Traps" does. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2993 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/spells2.cc | 19 ++++++++++++------- crawl-ref/source/spl-cast.cc | 8 +++++--- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index 4f257cd7e5..80dbdbb276 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -105,8 +105,6 @@ unsigned char detect_items( int pow ) unsigned char items_found = 0; const int map_radius = 8 + random2(8) + pow; - mpr("You detect items!"); - for (int i = you.x_pos - map_radius; i < you.x_pos + map_radius; i++) { for (int j = you.y_pos - map_radius; j < you.y_pos + map_radius; j++) @@ -117,6 +115,8 @@ unsigned char detect_items( int pow ) if (igrd[i][j] != NON_ITEM && (!get_envmap_obj(i, j) || !is_envmap_item(i, j))) { + items_found++; + set_envmap_obj(i, j, DNGN_ITEM_DETECTED); set_envmap_detected_item(i, j); } @@ -144,15 +144,16 @@ static void fuzz_detect_creatures(int pow, int *fuzz_radius, int *fuzz_chance) *fuzz_chance = 10; } -static void mark_detected_creature(int gridx, int gridy, const monsters *mon, +static bool mark_detected_creature(int gridx, int gridy, const monsters *mon, int fuzz_chance, int fuzz_radius) { + bool found_good = false; + if (fuzz_radius && fuzz_chance > random2(100)) { const int fuzz_diam = 2 * fuzz_radius + 1; int gx, gy; - bool found_good = false; for (int itry = 0; itry < 5; ++itry) { gx = gridx + random2(fuzz_diam) - fuzz_radius; @@ -175,6 +176,8 @@ static void mark_detected_creature(int gridx, int gridy, const monsters *mon, set_envmap_obj(gridx, gridy, mon->type + DNGN_START_OF_MONSTERS); set_envmap_detected_mons(gridx, gridy); + + return found_good; } unsigned char detect_creatures( int pow ) @@ -192,8 +195,6 @@ unsigned char detect_creatures( int pow ) // fuzz is harder to analyse by averaging. clear_map(false); - mpr("You detect creatures!"); - for (int i = you.x_pos - map_radius; i < you.x_pos + map_radius; i++) { for (int j = you.y_pos - map_radius; j < you.y_pos + map_radius; j++) @@ -204,7 +205,11 @@ unsigned char detect_creatures( int pow ) if (mgrd[i][j] != NON_MONSTER) { struct monsters *mon = &menv[ mgrd[i][j] ]; - mark_detected_creature(i, j, mon, fuzz_chance, fuzz_radius); + if (mark_detected_creature(i, j, mon, fuzz_chance, + fuzz_radius)) + { + creatures_found++; + } // Assuming that highly intelligent spellcasters can // detect scrying. -- bwr diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index e4d05849c6..79d792e072 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -1275,7 +1275,7 @@ spret_type your_spells( spell_type spell, int powc, bool allow_fail ) case SPELL_DETECT_TRAPS: mprf("You detect %s", - (detect_traps(powc) > 0) ? "some traps!" : "nothing."); + (detect_traps(powc) > 0) ? "traps!" : "nothing."); break; case SPELL_BLINK: @@ -1347,7 +1347,8 @@ spret_type your_spells( spell_type spell, int powc, bool allow_fail ) break; case SPELL_DETECT_ITEMS: - detect_items(powc); + mprf("You detect %s", + (detect_items(powc) > 0) ? "items!" : "nothing."); break; case SPELL_BORGNJORS_REVIVIFICATION: @@ -1569,7 +1570,8 @@ spret_type your_spells( spell_type spell, int powc, bool allow_fail ) break; case SPELL_DETECT_CREATURES: - detect_creatures(powc); + mprf("You detect %s", + (detect_creatures(powc) > 0) ? "creatures!" : "nothing."); break; case SPELL_CURE_POISON_II: // poison magic version of cure poison -- cgit v1.2.3-54-g00ecf