summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/beam.cc2
-rw-r--r--crawl-ref/source/enum.h33
-rw-r--r--crawl-ref/source/externs.h8
-rw-r--r--crawl-ref/source/fight.cc3
-rw-r--r--crawl-ref/source/luadgn.cc12
-rw-r--r--crawl-ref/source/mon-util.cc41
-rw-r--r--crawl-ref/source/player.cc20
-rw-r--r--crawl-ref/source/terrain.cc12
8 files changed, 97 insertions, 34 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index 7098bd3260..486b27f959 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -4645,7 +4645,7 @@ static void explosion_map( bolt &beam, int x, int y,
// special case: explosion originates from rock/statue
// (e.g. Lee's rapid deconstruction) - in this case, ignore
// solid cells at the center of the explosion.
- if (dngn_feat < DNGN_GREEN_CRYSTAL_WALL || dngn_feat == DNGN_WAX_WALL)
+ if (dngn_feat <= DNGN_MAXWALL)
{
if (!(x==0 && y==0) && !affects_wall(beam, dngn_feat))
return;
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index 61ddc607ce..ddc29fe4e9 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -840,21 +840,28 @@ enum dungeon_char_type
enum dungeon_feature_type
{
DNGN_UNSEEN, // 0
+ DNGN_CLOSED_DOOR,
+ DNGN_SECRET_DOOR,
DNGN_ROCK_WALL,
DNGN_STONE_WALL,
- DNGN_CLOSED_DOOR,
- DNGN_METAL_WALL,
- DNGN_SECRET_DOOR, // 5
+ DNGN_METAL_WALL, // 5
DNGN_GREEN_CRYSTAL_WALL,
- DNGN_ORCISH_IDOL,
- DNGN_WAX_WALL, // 8
- DNGN_PERMAROCK_WALL, // 9 - for undiggable walls
- DNGN_CLEAR_ROCK_WALL, // 10 - Transparent
- DNGN_CLEAR_STONE_WALL, // 11 - Transparent
- DNGN_CLEAR_PERMAROCK_WALL, // 12 - Transparent
+ DNGN_WAX_WALL,
+ DNGN_PERMAROCK_WALL, // 8 - for undiggable walls
+ DNGN_CLEAR_ROCK_WALL, // 9 - Transparent
+ DNGN_CLEAR_STONE_WALL, // 10 - Transparent
+ DNGN_CLEAR_PERMAROCK_WALL, // 11 - Transparent
+ DNGN_ORCISH_IDOL, // 12 - Can see past
+
+ // XXX: lowest/highest grid value which is a wall
+ DNGN_MINWALL = DNGN_ROCK_WALL,
+ DNGN_MAXWALL = DNGN_CLEAR_PERMAROCK_WALL,
+
+ // XXX: highest grid value which is opaque
+ DNGN_MAXOPAQUE = DNGN_PERMAROCK_WALL,
// XXX: lowest grid value which can be seen through
- DNGN_MINSEE = 10,
+ DNGN_MINSEE = DNGN_CLEAR_ROCK_WALL,
DNGN_GRANITE_STATUE = 21, // 21
DNGN_STATUE_RESERVED_1,
@@ -871,9 +878,9 @@ enum dungeon_feature_type
DNGN_FLOOR, // 67
DNGN_FLOOR_SPECIAL, // currently only used for colouring bazaars
DNGN_FLOOR_RESERVED,
- DNGN_EXIT_HELL, // 68
- DNGN_ENTER_HELL, // 69
- DNGN_OPEN_DOOR, // 70
+ DNGN_EXIT_HELL, // 70
+ DNGN_ENTER_HELL, // 71
+ DNGN_OPEN_DOOR, // 72
DNGN_TRAP_MECHANICAL = 75, // 75
DNGN_TRAP_MAGICAL,
DNGN_TRAP_III,
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index 578af53e2f..4aa1b1935f 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -108,8 +108,10 @@ public:
virtual void attacking(actor *other) = 0;
virtual bool can_go_berserk() const = 0;
virtual bool can_see_invisible() const = 0;
- virtual bool is_icy() const = 0;
virtual bool invisible() const = 0;
+ virtual bool visible_to(actor *looker) = 0;
+ virtual bool can_see(actor *target) = 0;
+ virtual bool is_icy() const = 0;
virtual void go_berserk(bool intentional) = 0;
virtual void mutate() = 0;
virtual void hurt(const actor *attacker, int amount) = 0;
@@ -698,6 +700,8 @@ public:
bool cannot_speak() const;
bool invisible() const;
bool can_see_invisible() const;
+ bool visible_to(actor *looker);
+ bool can_see(actor *target);
bool is_icy() const;
bool light_flight() const;
@@ -1039,6 +1043,8 @@ public:
flight_type flies() const;
bool invisible() const;
bool can_see_invisible() const;
+ bool visible_to(actor *looker);
+ bool can_see(actor *target);
bool is_icy() const;
bool paralysed() const;
bool confused() const;
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 4b033bb609..39b1dfc6e1 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -2924,6 +2924,9 @@ std::string melee_attack::mons_attack_verb(const mon_attack_def &attk)
std::string melee_attack::mons_weapon_desc()
{
+ if (!you.can_see(attacker))
+ return ("");
+
if (weapon && attacker->id() != MONS_DANCING_WEAPON)
{
std::string result = "";
diff --git a/crawl-ref/source/luadgn.cc b/crawl-ref/source/luadgn.cc
index 4a73aa9e36..f3252ff4fd 100644
--- a/crawl-ref/source/luadgn.cc
+++ b/crawl-ref/source/luadgn.cc
@@ -926,17 +926,17 @@ static int dgn_load_des_file(lua_State *ls)
const char *dngn_feature_names[] =
{
- "unseen", "rock_wall", "stone_wall", "closed_door", "metal_wall",
- "secret_door", "green_crystal_wall", "orcish_idol", "wax_wall",
- "permarock_wall", "clear_rock_wall", "clear_stone_wall",
- "clear_permarock_wall", "", "", "", "", "", "", "", "",
+ "unseen", "closed_door", "secret_door", "rock_wall", "stone_wall",
+ "metal_wall", "green_crystal_wall", "wax_wall", "permarock_wall",
+ "clear_rock_wall", "clear_stone_wall", "clear_permarock_wall",
+ "orcish_idol", "", "", "", "", "", "", "", "",
"silver_statue", "granite_statue", "orange_crystal_statue",
"statue_reserved_1", "statue_reserved_2", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "lava",
"deep_water", "", "", "shallow_water", "water_stuck", "floor",
- "exit_hell", "enter_hell", "open_door", "", "", "", "",
- "trap_mechanical", "trap_magical", "trap_iii",
+ "floor_special", "floor_reserved", "exit_hell", "enter_hell",
+ "open_door", "", "", "trap_mechanical", "trap_magical", "trap_iii",
"undiscovered_trap", "", "enter_shop", "enter_labyrinth",
"stone_stairs_down_i", "stone_stairs_down_ii",
"stone_stairs_down_iii", "rock_stairs_down", "stone_stairs_up_i",
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 007b7d8c03..e9731e36d2 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -3133,9 +3133,7 @@ bool monsters::fumbles_attack(bool verbose)
{
if (verbose)
{
- const bool can_see =
- mons_near(this) && player_monster_visible(this);
- if (can_see)
+ if (you.can_see(this))
mprf("%s splashes around in the water.",
this->name(DESC_CAP_THE).c_str());
else if (!silenced(you.x_pos, you.y_pos) && !silenced(x, y))
@@ -4581,6 +4579,43 @@ bool monsters::invisible() const
return (has_ench(ENCH_INVIS) && !backlit());
}
+bool monsters::visible_to(actor *looker)
+{
+ if (this == looker)
+ return (!invisible() || can_see_invisible());
+
+ if (looker->atype() == ACT_PLAYER)
+ return player_monster_visible(this);
+ else
+ {
+ monsters* mon = dynamic_cast<monsters*>(looker);
+
+ return mons_monster_visible(mon, this);
+ }
+}
+
+bool monsters::can_see(actor *target)
+{
+ if (this == target)
+ return visible_to(target);
+
+ if (!target->visible_to(this))
+ return false;
+
+ if (target->atype() == ACT_PLAYER)
+ return mons_near(this);
+
+ monsters* mon = dynamic_cast<monsters*>(target);
+ int tx = mon->x;
+ int ty = mon->y;
+
+ if (distance(x, y, tx, ty) > LOS_RADIUS)
+ return false;
+
+ // Ignoring clouds for now.
+ return (num_feats_between(x, y, tx, ty, DNGN_UNSEEN, DNGN_MAXOPAQUE) == 0);
+}
+
void monsters::mutate()
{
if (holiness() != MH_NATURAL)
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<monsters*>(looker);
+
+ return mons_player_visible(mon);
+}
+
+bool player::can_see(actor *target)
+{
+ if (this == target)
+ return visible_to(target);
+
+ monsters* mon = dynamic_cast<monsters*>(target);
+
+ return (mons_near(mon) && target->visible_to(this));
+}
+
bool player::backlit() const
{
return (magic_contamination >= 5 || duration[DUR_BACKLIGHT]);
diff --git a/crawl-ref/source/terrain.cc b/crawl-ref/source/terrain.cc
index 8355657edc..ecb1a70092 100644
--- a/crawl-ref/source/terrain.cc
+++ b/crawl-ref/source/terrain.cc
@@ -33,15 +33,7 @@
bool grid_is_wall( dungeon_feature_type grid )
{
- return (grid == DNGN_ROCK_WALL
- || grid == DNGN_STONE_WALL
- || grid == DNGN_METAL_WALL
- || grid == DNGN_GREEN_CRYSTAL_WALL
- || grid == DNGN_WAX_WALL
- || grid == DNGN_PERMAROCK_WALL
- || grid == DNGN_CLEAR_ROCK_WALL
- || grid == DNGN_CLEAR_STONE_WALL
- || grid == DNGN_CLEAR_PERMAROCK_WALL);
+ return (grid >= DNGN_MINWALL && grid <= DNGN_MAXWALL);
}
bool grid_is_stone_stair(dungeon_feature_type grid)
@@ -164,7 +156,7 @@ command_type grid_stair_direction(dungeon_feature_type grid)
bool grid_is_opaque( dungeon_feature_type grid )
{
- return (grid < DNGN_MINSEE && grid != DNGN_ORCISH_IDOL);
+ return (grid < DNGN_MINSEE);
}
bool grid_is_solid( dungeon_feature_type grid )