From 4189018dba56b0f4b56ccd402174d56f8f9f6979 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Tue, 1 Apr 2008 11:31:25 +0000 Subject: Allow autotargeting of monsters hiding in shallow water ("You see a strange disturbance here"), assuming them to be enemy monsters. Fix Daevas being so incredibly chatty. Friendly holy beings will now give the holy_being speech with a chance of 1/20, and else stay silent. This is rare! Neutrals have the same behaviour but speak with a chance of 1/11 since you won't be around them as often as around friendlies. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4005 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/direct.cc | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'crawl-ref/source/direct.cc') diff --git a/crawl-ref/source/direct.cc b/crawl-ref/source/direct.cc index 55c807cfc6..3b89368585 100644 --- a/crawl-ref/source/direct.cc +++ b/crawl-ref/source/direct.cc @@ -1127,11 +1127,22 @@ static bool find_monster( int x, int y, int mode, int range = -1) const int targ_mon = mgrd[ x ][ y ]; - // Is target a (known) monster? - if (targ_mon == NON_MONSTER || !in_los(x,y) - || !player_monster_visible( &(menv[targ_mon]) ) - || mons_is_mimic(menv[targ_mon].type) - && !(menv[targ_mon].flags & MF_KNOWN_MIMIC)) + // No monster or outside LOS. + if (targ_mon == NON_MONSTER || !in_los(x,y)) + return (false); + + // Unseen monsters in shallow water show a "strange disturbance" + // (unless flying!) + if (!player_monster_visible(&menv[targ_mon])) + { + // since you can't see the monster, assume it's not a friend + return (mode != TARG_FRIEND && grd[x][y] == DNGN_SHALLOW_WATER + && !mons_flies(&menv[targ_mon])); + } + + // Unknown mimics don't count as monsters, either. + if (mons_is_mimic(menv[targ_mon].type) + && !(menv[targ_mon].flags & MF_KNOWN_MIMIC)) { return (false); } @@ -1143,12 +1154,13 @@ static bool find_monster( int x, int y, int mode, int range = -1) if (mode == TARG_FRIEND) return (mons_friendly(&menv[targ_mon] )); - if (mode != TARG_ENEMY) + ASSERT(mode == TARG_ENEMY); + if (mons_friendly(&menv[targ_mon])) return false; - - return ( !mons_friendly( &menv[targ_mon] ) - && (Options.target_zero_exp - || !mons_class_flag( menv[targ_mon].type, M_NO_EXP_GAIN )) ); + + // Don't target zero xp monsters, unless target_zero_exp is set. + return (Options.target_zero_exp + || !mons_class_flag( menv[targ_mon].type, M_NO_EXP_GAIN )); } static bool find_feature( int x, int y, int mode, int /* range */) -- cgit v1.2.3-54-g00ecf