summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/misc.cc
diff options
context:
space:
mode:
authorpauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-24 05:46:17 +0000
committerpauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-24 05:46:17 +0000
commit5b7c011ebc58789ff4a689db367ecbad0f3ee165 (patch)
tree883262771e41c222e7b48fda0772a0c0ff3cacf8 /crawl-ref/source/misc.cc
parentc250985042918f43da52ec118e9a241b9c9b0668 (diff)
downloadcrawl-ref-5b7c011ebc58789ff4a689db367ecbad0f3ee165.tar.gz
crawl-ref-5b7c011ebc58789ff4a689db367ecbad0f3ee165.zip
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
Diffstat (limited to 'crawl-ref/source/misc.cc')
-rw-r--r--crawl-ref/source/misc.cc31
1 files changed, 31 insertions, 0 deletions
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<monsters*>& 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<const monsters *> 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 )