From 5fa864a78e4ebd44189a31827edeead3f0c12597 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Sat, 7 Apr 2007 20:27:45 +0000 Subject: Implemented Erik's invisibility proposal: - M_SENSE_INVIS for perceptive monsters; split existing monsters with see invisible into M_SEE_INVIS and M_SENSE_INVIS. - Monsters that can't see invisible get to-hit penalties vs invisible players and monsters in both melee and at range. - Monsters that sense where you are know where to shoot and attack, but still get to-hit penalties because they don't know exactly where you are. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1260 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/mon-util.cc | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'crawl-ref/source/mon-util.cc') diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 086a63bd15..7c0da9cf5d 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -519,16 +519,21 @@ bool mons_is_unique( int mc ) return (mons_class_flag(mc, M_UNIQUE)); } -char mons_see_invis( struct monsters *mon ) +bool mons_sense_invis(const monsters *mon) +{ + return (mons_class_flag(mon->type, M_SENSE_INVIS)); +} + +bool mons_see_invis(const monsters *mon) { if (mon->type == MONS_PLAYER_GHOST || mon->type == MONS_PANDEMONIUM_DEMON) return (mon->ghost->values[ GVAL_SEE_INVIS ]); else if (((seekmonster(mon->type))->bitfields & M_SEE_INVIS) != 0) - return (1); + return (true); else if (scan_mon_inv_randarts( mon, RAP_EYESIGHT ) > 0) - return (1); + return (true); - return (0); + return (false); } // end mons_see_invis() @@ -554,7 +559,7 @@ bool mons_player_visible( struct monsters *mon ) if (player_in_water()) return (true); - if (mons_see_invis( mon )) + if (mons_see_invis( mon ) || mons_sense_invis(mon)) return (true); return (false); @@ -568,7 +573,6 @@ unsigned char mons_char(int mc) return (unsigned char) smc->showchar; } // end mons_char() - char mons_itemuse(int mc) { return (smc->gmon_use); @@ -3859,6 +3863,16 @@ bool monsters::needs_berserk(bool check_spells) const return (true); } +bool monsters::can_see_invisible() const +{ + return (mons_see_invis(this)); +} + +bool monsters::invisible() const +{ + return (has_ench(ENCH_INVIS)); +} + ///////////////////////////////////////////////////////////////////////// // mon_enchant -- cgit v1.2.3-54-g00ecf