From 5b7c011ebc58789ff4a689db367ecbad0f3ee165 Mon Sep 17 00:00:00 2001 From: pauldubois Date: Mon, 24 Mar 2008 05:46:17 +0000 Subject: Fix a bunch of the TODO items. - Display monster glyph, in color - Sort roughly by monster difficulty. Not exactly, because then monsters won't merge together, and because it leaks info. - Not done: rough health information git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3853 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/misc.cc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'crawl-ref/source/misc.cc') diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 64dd7bfa3a..ae050e7acb 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -1791,6 +1791,35 @@ bool mons_is_safe(const struct monsters *mon, bool want_move) return is_safe; } +// Return all monsters in LOS that the player is able to see. +void get_playervisible_monsters(std::vector& mons) +{ + const int ystart = MAX(0, you.y_pos - LOS_RADIUS); + const int yend = MIN(GYM, you.y_pos + LOS_RADIUS); + const int xstart = MAX(0, you.x_pos - LOS_RADIUS); + const int xend = MIN(GXM, you.x_pos + LOS_RADIUS); + + // monster check + for ( int y = ystart; y < yend; ++y ) + for ( int x = xstart; x < xend; ++x ) + { + const unsigned short targ_monst = env.mgrid[x][y]; + if ( targ_monst != NON_MONSTER ) + { + if ( see_grid(x,y) ) + { + monsters *mon = &env.mons[targ_monst]; + if ( player_monster_visible(mon) && + !mons_is_submerged(mon) && + !mons_is_mimic(mon->type) ) + { + mons.push_back(mon); + } + } + } + } +} + bool i_feel_safe(bool announce, bool want_move) { int ystart = you.y_pos - 9, xstart = you.x_pos - 9; @@ -1820,7 +1849,9 @@ bool i_feel_safe(bool announce, bool want_move) return (true); std::vector mons; + // monster check + // XXX: refactor this to make use of get_playervisible_monsters() for ( int y = ystart; y < yend; ++y ) { for ( int x = xstart; x < xend; ++x ) -- cgit v1.2.3-54-g00ecf