From d2adf58f0e800c6f1b51f94e9ea96db61b026bf5 Mon Sep 17 00:00:00 2001 From: haranp Date: Fri, 22 Dec 2006 16:13:06 +0000 Subject: 's'earching will now check in a radius up to 5 around you, with decreasing skill (effective skill = skill/(2*dist-1).) Walking around will also search, with probability (skill in 30) (but only adjacent squares.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@695 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/misc.cc | 60 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 20 deletions(-) (limited to 'crawl-ref/source/misc.cc') diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index a01640aede..eda5a0f8b2 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -248,34 +248,54 @@ const char *grid_item_destruction_message( unsigned char grid ) : "You hear an empty echo."; } -void search_around(void) +void search_around( bool only_adjacent ) { char srx = 0; char sry = 0; int i; - for (srx = you.x_pos - 1; srx < you.x_pos + 2; srx++) + // Traps and doors stepdown skill: + // skill/(2x-1) for squares at distance x + int max_dist = (you.skills[SK_TRAPS_DOORS] + 1) / 2; + if ( max_dist > 5 ) + max_dist = 5; + if ( max_dist > 1 && only_adjacent ) + max_dist = 1; + + for ( int srx = you.x_pos - max_dist; srx <= you.x_pos + max_dist; ++srx ) { - for (sry = you.y_pos - 1; sry < you.y_pos + 2; sry++) + for ( int sry=you.y_pos - max_dist; sry<=you.y_pos + max_dist; ++sry ) { - // don't exclude own square; may be levitating - if (grd[srx][sry] == DNGN_SECRET_DOOR - && random2(17) <= 1 + you.skills[SK_TRAPS_DOORS]) - { - grd[srx][sry] = DNGN_CLOSED_DOOR; - mpr("You found a secret door!"); - exercise(SK_TRAPS_DOORS, ((coinflip())? 2 : 1)); - } - - if (grd[srx][sry] == DNGN_UNDISCOVERED_TRAP - && random2(17) <= 1 + you.skills[SK_TRAPS_DOORS]) + if ( see_grid(srx,sry) ) // must have LOS { - i = trap_at_xy(srx, sry); - - if (i != -1) - grd[srx][sry] = trap_category(env.trap[i].type); - - mpr("You found a trap!"); + // maybe we want distance() instead of grid_distance()? + int dist = grid_distance(srx, sry, you.x_pos, you.y_pos); + + // don't exclude own square; may be levitating + if (dist == 0) + ++dist; + + // making this harsher by removing the old +1 + int effective = you.skills[SK_TRAPS_DOORS] / (2*dist - 1); + + if (grd[srx][sry] == DNGN_SECRET_DOOR && + random2(17) <= effective) + { + grd[srx][sry] = DNGN_CLOSED_DOOR; + mpr("You found a secret door!"); + exercise(SK_TRAPS_DOORS, ((coinflip()) ? 2 : 1)); + } + + if (grd[srx][sry] == DNGN_UNDISCOVERED_TRAP && + random2(17) <= effective) + { + i = trap_at_xy(srx, sry); + + if (i != -1) + grd[srx][sry] = trap_category(env.trap[i].type); + + mpr("You found a trap!"); + } } } } -- cgit v1.2.3-54-g00ecf