summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-01-02 06:03:46 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-01-02 06:03:46 +0000
commitdfc37e9a8428fb59f4752b24928f0019a5b76d61 (patch)
tree08f526aef8cc0c272cd1627821bd1f28af42b8a4 /crawl-ref/source
parent0f7006bc57cf51d5438cbe9ca2a1fb63d93a56c6 (diff)
downloadcrawl-ref-dfc37e9a8428fb59f4752b24928f0019a5b76d61.tar.gz
crawl-ref-dfc37e9a8428fb59f4752b24928f0019a5b76d61.zip
Fix monster-comes-into-view messages when the monster was already in view to
start with. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@762 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/acr.cc28
-rw-r--r--crawl-ref/source/misc.cc85
-rw-r--r--crawl-ref/source/misc.h2
3 files changed, 83 insertions, 32 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index faa0737241..64f4f00345 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -755,7 +755,8 @@ static void handle_wizard_command( void )
// Set up the running variables for the current run.
static void start_running( int dir, int mode )
{
- you.running.initialise(dir, mode);
+ if (i_feel_safe(true))
+ you.running.initialise(dir, mode);
}
static bool recharge_rod( item_def &rod, bool wielded )
@@ -1002,12 +1003,15 @@ void process_command( command_type cmd ) {
case CMD_MOVE_RIGHT: move_player( 1, 0); break;
case CMD_REST:
- if ( you.hp == you.hp_max &&
- you.magic_points == you.max_magic_points )
- mpr("You start searching.");
- else
- mpr("You start resting.");
start_running( RDIR_REST, RMODE_REST_DURATION );
+ if (you.running)
+ {
+ if ( you.hp == you.hp_max &&
+ you.magic_points == you.max_magic_points )
+ mpr("You start searching.");
+ else
+ mpr("You start resting.");
+ }
break;
case CMD_RUN_DOWN_LEFT:
@@ -1240,8 +1244,11 @@ void process_command( command_type cmd ) {
mpr("Sorry, you can't auto-travel out of here.");
break;
}
- start_translevel_travel();
- mesclr();
+ if (i_feel_safe(true))
+ {
+ start_translevel_travel();
+ mesclr();
+ }
break;
case CMD_EXPLORE:
@@ -1251,7 +1258,8 @@ void process_command( command_type cmd ) {
break;
}
// Start exploring
- start_explore(Options.explore_greedy);
+ if (i_feel_safe(true))
+ start_explore(Options.explore_greedy);
break;
case CMD_DISPLAY_MAP:
@@ -1265,7 +1273,7 @@ void process_command( command_type cmd ) {
plox[0] = 0;
show_map(plox, true);
redraw_screen();
- if (plox[0] > 0)
+ if (plox[0] > 0 && i_feel_safe(true))
start_travel(plox[0], plox[1]);
break;
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index f0b034a3a1..37d97015f8 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -1770,7 +1770,7 @@ int trap_at_xy(int which_x, int which_y)
return (-1);
} // end trap_at_xy()
-bool i_feel_safe()
+bool i_feel_safe(bool announce)
{
/* This is probably unnecessary, but I'm not sure that
you're always at least 9 away from a wall */
@@ -1783,29 +1783,72 @@ bool i_feel_safe()
/* statue check */
if (you.visible_statue[STATUE_SILVER] ||
- you.visible_statue[STATUE_ORANGE_CRYSTAL] )
- return false;
+ you.visible_statue[STATUE_ORANGE_CRYSTAL] )
+ {
+ if (announce)
+ mprf(MSGCH_WARN, "There are scary statues in view.");
+
+ return false;
+ }
+ std::vector<const monsters *> mons;
/* monster check */
- for ( int y = ystart; y < yend; ++y ) {
- for ( int x = xstart; x < xend; ++x ) {
- /* if you can see a nonfriendly monster then you feel
- unsafe */
- if ( see_grid(x,y) ) {
- const unsigned char targ_monst = mgrd[x][y];
- if ( targ_monst != NON_MONSTER ) {
- struct monsters *mon = &menv[targ_monst];
- if ( !mons_friendly(mon) &&
- player_monster_visible(mon) &&
- !mons_is_mimic(mon->type) &&
- (!Options.safe_zero_exp ||
- !mons_class_flag( mon->type, M_NO_EXP_GAIN ))) {
- return false;
- }
- }
- }
- }
+ for ( int y = ystart; y < yend; ++y )
+ {
+ for ( int x = xstart; x < xend; ++x )
+ {
+ /* if you can see a nonfriendly monster then you feel
+ unsafe */
+ if ( see_grid(x,y) )
+ {
+ const unsigned char targ_monst = mgrd[x][y];
+ if ( targ_monst != NON_MONSTER )
+ {
+ struct monsters *mon = &menv[targ_monst];
+ if ( !mons_friendly(mon) &&
+ player_monster_visible(mon) &&
+ !mons_is_mimic(mon->type) &&
+ (!Options.safe_zero_exp ||
+ !mons_class_flag( mon->type, M_NO_EXP_GAIN )))
+ {
+ if (announce)
+ mons.push_back(mon);
+ else
+ return false;
+ }
+ }
+ }
+ }
+ }
+
+ if (announce)
+ {
+ if (mons.size() == 1)
+ {
+ const monsters *m = mons[0];
+ switch (random2(3))
+ {
+ case 0:
+ mprf(MSGCH_WARN, "Not with %s in view!",
+ ptr_monam(m, DESC_NOCAP_A));
+ break;
+ case 1:
+ mprf(MSGCH_WARN, "There's %s right there!",
+ ptr_monam(m, DESC_NOCAP_A));
+ break;
+ case 2:
+ mprf(MSGCH_WARN, "Wait, there's %s in sight!",
+ ptr_monam(m, DESC_NOCAP_A));
+ break;
+ }
+ }
+ else if (mons.size() > 1)
+ {
+ mprf(MSGCH_WARN, "Not with these monsters around!");
+ }
+ return (mons.empty());
}
+
return true;
}
diff --git a/crawl-ref/source/misc.h b/crawl-ref/source/misc.h
index 74065c561a..997219a216 100644
--- a/crawl-ref/source/misc.h
+++ b/crawl-ref/source/misc.h
@@ -147,7 +147,7 @@ const char *grid_item_destruction_message( unsigned char grid );
void curare_hits_player(int agent, int degree);
-bool i_feel_safe();
+bool i_feel_safe(bool announce = false);
void setup_environment_effects();