diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2009-10-21 16:07:05 +0200 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2009-10-22 22:37:07 +0200 |
commit | ed4a22bce4db2328e945840901176b49d4b573e7 (patch) | |
tree | 3ad9ac52b5b24dca8dd5317e7b7468d11c09db58 | |
parent | 07ef1ffe1ce0431004b79ede171f3f6bfa16549f (diff) | |
download | crawl-ref-ed4a22bce4db2328e945840901176b49d4b573e7.tar.gz crawl-ref-ed4a22bce4db2328e945840901176b49d4b573e7.zip |
Introduce actor::see_cell.
Implemented using the existing LOS functions for now. In particular,
monster-monster visibility still uses num_feats_between.
-rw-r--r-- | crawl-ref/source/actor.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.cc | 19 | ||||
-rw-r--r-- | crawl-ref/source/monster.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/player.cc | 11 | ||||
-rw-r--r-- | crawl-ref/source/player.h | 1 |
5 files changed, 19 insertions, 14 deletions
diff --git a/crawl-ref/source/actor.h b/crawl-ref/source/actor.h index a760742786..f8ff1ad599 100644 --- a/crawl-ref/source/actor.h +++ b/crawl-ref/source/actor.h @@ -102,6 +102,7 @@ public: virtual bool can_see_invisible() const = 0; virtual bool invisible() const = 0; virtual bool visible_to(const actor *looker) const = 0; + virtual bool see_cell(const coord_def &c) const = 0; virtual bool can_see(const actor *target) const = 0; virtual bool is_icy() const = 0; virtual bool is_fiery() const = 0; diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 9ad32ef80d..4ed5d9b690 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -8043,18 +8043,19 @@ bool monsters::mon_see_cell(const coord_def& p, bool reach) const true, true)); } -bool monsters::can_see(const actor *targ) const +bool monsters::see_cell(const coord_def &c) const { - if (this == targ) - return (visible_to(targ)); - - if (!targ->visible_to(this)) - return (false); + // XXX: using env.show since that's been filled anywa. + if (c == you.pos()) + return (you.see_cell(pos())); - if (targ->atype() == ACT_PLAYER) - return (mons_near(this)); + // TODO: Proper monster LOS. + return (mon_see_cell(c)); +} - return (mon_see_cell(targ->pos())); +bool monsters::can_see(const actor *targ) const +{ + return (targ->visible_to(this) && see_cell(targ->pos())); } bool monsters::can_mutate() const diff --git a/crawl-ref/source/monster.h b/crawl-ref/source/monster.h index b942b2d91e..860cf1ae0c 100644 --- a/crawl-ref/source/monster.h +++ b/crawl-ref/source/monster.h @@ -301,6 +301,7 @@ public: bool can_see_invisible() const; bool visible_to(const actor *looker) const; bool mon_see_cell(const coord_def& pos, bool reach = false) const; + bool see_cell(const coord_def& c) const; bool can_see(const actor *target) const; bool is_icy() const; bool is_fiery() const; diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 3892682d80..452c16a57c 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -7362,16 +7362,17 @@ bool player::visible_to(const actor *looker) const return mons_player_visible(mon); } +bool player::see_cell(const coord_def &c) const +{ + return (::see_cell(c)); +} + bool player::can_see(const actor *target) const { if (crawl_state.arena) return target->visible_to(this); - if (this == target) - return visible_to(target); - - const monsters* mon = dynamic_cast<const monsters*>(target); - return (mons_near(mon) && target->visible_to(this)); + return (target->visible_to(this) && see_cell(target->pos())); } bool player::backlit(bool check_haloed) const diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index 0c77c6894d..d37495b532 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -301,6 +301,7 @@ public: bool invisible() const; bool can_see_invisible() const; bool visible_to(const actor *looker) const; + bool see_cell(const coord_def &c) const; bool can_see(const actor *target) const; bool is_icy() const; bool is_fiery() const; |