diff options
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/actor.cc | 11 | ||||
-rw-r--r-- | crawl-ref/source/actor.h | 11 | ||||
-rw-r--r-- | crawl-ref/source/delay.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/fight.cc | 5 | ||||
-rw-r--r-- | crawl-ref/source/makefile.obj | 1 | ||||
-rw-r--r-- | crawl-ref/source/mstuff2.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/player.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/state.cc | 2 |
8 files changed, 29 insertions, 7 deletions
diff --git a/crawl-ref/source/actor.cc b/crawl-ref/source/actor.cc new file mode 100644 index 0000000000..880fb7a93f --- /dev/null +++ b/crawl-ref/source/actor.cc @@ -0,0 +1,11 @@ +#include "AppHdr.h" + +#include "actor.h" +#include "player.h" +#include "state.h" + +bool actor::observable() +{ + return (crawl_state.arena || this == &you || you.can_see(this)); +} + diff --git a/crawl-ref/source/actor.h b/crawl-ref/source/actor.h index f8ff1ad599..e5cf5e6277 100644 --- a/crawl-ref/source/actor.h +++ b/crawl-ref/source/actor.h @@ -101,9 +101,20 @@ public: virtual bool can_go_berserk() const = 0; virtual bool can_see_invisible() const = 0; virtual bool invisible() const = 0; + + // Would looker be able to see the actor when in LOS? virtual bool visible_to(const actor *looker) const = 0; + + // Is the given cell within LOS of the actor? virtual bool see_cell(const coord_def &c) const = 0; + + // Can the actor actually see the target? virtual bool can_see(const actor *target) const = 0; + + // Visibility as required by messaging. In usual play: + // Does the player know what's happening to the actor? + virtual bool observable(); + virtual bool is_icy() const = 0; virtual bool is_fiery() const = 0; virtual void go_berserk(bool intentional) = 0; diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index b307c6a837..2fe59e8f2c 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -1816,7 +1816,7 @@ inline static bool _monster_warning(activity_interrupt_type ai, || _is_butcher_delay(atype))) { const monsters* mon = static_cast<const monsters*>(at.data); - if (!mon->visible()) + if (!you.can_see(mon)) return (false); if (at.context == "already seen" || at.context == "uncharm") { diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 3b9ffbfdfe..a1d8bbc914 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -389,10 +389,9 @@ void melee_attack::init_attack() defender_shield = defender->shield(); water_attack = is_water_attack(attacker, defender); - attacker_visible = attacker->visible() || crawl_state.arena; + attacker_visible = attacker->observable(); attacker_invisible = (!attacker_visible && see_cell(attacker->pos())); - defender_visible = (defender && (defender->visible() - || crawl_state.arena)); + defender_visible = defender && defender->observable(); defender_invisible = (!defender_visible && defender && see_cell(defender->pos())); needs_message = (attacker_visible || defender_visible); diff --git a/crawl-ref/source/makefile.obj b/crawl-ref/source/makefile.obj index 070cecb0e4..c6c84b1660 100644 --- a/crawl-ref/source/makefile.obj +++ b/crawl-ref/source/makefile.obj @@ -2,6 +2,7 @@ OBJECTS = \ abl-show.o \ abyss.o \ acr.o \ +actor.o \ arena.o \ artefact.o \ beam.o \ diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc index a7b8e20fe9..1d1ef98a34 100644 --- a/crawl-ref/source/mstuff2.cc +++ b/crawl-ref/source/mstuff2.cc @@ -1636,7 +1636,7 @@ bool mons_throw(struct monsters *monster, struct bolt &pbolt, int hand_used) } msg += "."; - if (monster->visible()) + if (monster->observable()) { mpr(msg.c_str()); diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 35ee075333..a63077e149 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -6926,7 +6926,7 @@ int player::armour_class() const int player::melee_evasion(const actor *act) const { return (player_evasion() - - ((!act || act->visible()) ? 0 : 10) + - ((!act || act->visible_to(&you)) ? 0 : 10) - (you_are_delayed() && !is_run_delay(current_delay_action())? 5 : 0)); } diff --git a/crawl-ref/source/state.cc b/crawl-ref/source/state.cc index f7b5d5f83e..e32bfa7534 100644 --- a/crawl-ref/source/state.cc +++ b/crawl-ref/source/state.cc @@ -179,7 +179,7 @@ bool interrupt_cmd_repeat( activity_interrupt_type ai, if (ai == AI_SEE_MONSTER) { const monsters* mon = static_cast<const monsters*>(at.data); - if (!mon->visible()) + if (!you.can_see(mon)) return (false); if (crawl_state.cmd_repeat_started_unsafe |