From b153e8bfc653f4ac0e28cfe7901d3f32006b06e9 Mon Sep 17 00:00:00 2001 From: zelgadis Date: Tue, 2 Oct 2007 06:52:08 +0000 Subject: Added floor_special and floor_reserved to dngn_feature_names[], to make the array match up with the enums. Don't describe the weapon with which an unseen monster is attacking. Added methods can_see() and visible_to() to the actor, player and monster classes, which take care of calling mons_player_visible(), player_monster_visible(), mons_monster_visible() and mons_near(). Re-arranged the first 12 dungeon_feature_type enumerations so that similar features are contiguous (i.e., closed door and secret door are next to each other), and added DNGN_MAXOPAQUE (one less than DNGN_MINSEE), DNGN_MINWALL and DNGN_MAXWALL. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2293 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/player.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'crawl-ref/source/player.cc') diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 237f8da703..57562b1d85 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -5904,6 +5904,26 @@ bool player::invisible() const return (duration[DUR_INVIS] && !backlit()); } +bool player::visible_to(actor *looker) +{ + if (this == looker) + return (!invisible() || can_see_invisible()); + + monsters* mon = dynamic_cast(looker); + + return mons_player_visible(mon); +} + +bool player::can_see(actor *target) +{ + if (this == target) + return visible_to(target); + + monsters* mon = dynamic_cast(target); + + return (mons_near(mon) && target->visible_to(this)); +} + bool player::backlit() const { return (magic_contamination >= 5 || duration[DUR_BACKLIGHT]); -- cgit v1.2.3-54-g00ecf