summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/fight.cc20
-rw-r--r--crawl-ref/source/fight.h6
2 files changed, 17 insertions, 9 deletions
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 64bcaa10e9..41ffd6ba92 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -288,6 +288,7 @@ melee_attack::melee_attack(actor *attk, actor *defn,
cancel_attack(false),
did_hit(false), perceived_attack(false),
needs_message(false), attacker_visible(false), defender_visible(false),
+ attacker_invisible(false), defender_invisible(false),
unarmed_ok(allow_unarmed),
attack_number(which_attack),
to_hit(0), base_damage(0), potential_damage(0), damage_done(0),
@@ -345,7 +346,10 @@ void melee_attack::init_attack()
water_attack = is_water_attack(attacker, defender);
attacker_visible = attacker->visible();
+ attacker_invisible = !attacker_visible && see_grid(attacker->pos());
defender_visible = defender && defender->visible();
+ defender_invisible = !defender_visible && defender
+ && see_grid(defender->pos());
needs_message = attacker_visible || defender_visible;
if (defender && defender->submerged())
@@ -354,9 +358,10 @@ void melee_attack::init_attack()
std::string melee_attack::actor_name(const actor *a,
description_level_type desc,
- bool actor_visible)
+ bool actor_visible,
+ bool actor_invisible)
{
- return (actor_visible? a->name(desc) : anon_name(desc));
+ return (actor_visible? a->name(desc) : anon_name(desc, actor_invisible));
}
std::string melee_attack::pronoun(const actor *a,
@@ -379,13 +384,14 @@ std::string melee_attack::anon_pronoun(pronoun_type pron)
}
}
-std::string melee_attack::anon_name(description_level_type desc)
+std::string melee_attack::anon_name(description_level_type desc,
+ bool actor_invisible)
{
switch (desc)
{
case DESC_CAP_THE:
case DESC_CAP_A:
- return ("Something");
+ return (actor_invisible? "It" : "Something");
case DESC_CAP_YOUR:
return ("Its");
case DESC_NOCAP_YOUR:
@@ -395,18 +401,18 @@ std::string melee_attack::anon_name(description_level_type desc)
case DESC_NOCAP_A:
case DESC_PLAIN:
default:
- return ("something");
+ return (actor_invisible? "it" : "something");
}
}
std::string melee_attack::atk_name(description_level_type desc) const
{
- return actor_name(attacker, desc, attacker_visible);
+ return actor_name(attacker, desc, attacker_visible, attacker_invisible);
}
std::string melee_attack::def_name(description_level_type desc) const
{
- return actor_name(defender, desc, defender_visible);
+ return actor_name(defender, desc, defender_visible, defender_invisible);
}
bool melee_attack::is_water_attack(const actor *attk,
diff --git a/crawl-ref/source/fight.h b/crawl-ref/source/fight.h
index 8e5a92017c..900e90c156 100644
--- a/crawl-ref/source/fight.h
+++ b/crawl-ref/source/fight.h
@@ -70,6 +70,7 @@ public:
// If all or part of the action is visible to the player, we need a message.
bool needs_message;
bool attacker_visible, defender_visible;
+ bool attacker_invisible, defender_invisible;
bool unarmed_ok;
int attack_number;
@@ -124,9 +125,10 @@ public:
int calc_to_hit(bool random = true);
- static std::string anon_name(description_level_type desc);
+ static std::string anon_name(description_level_type desc,
+ bool actor_invisible);
static std::string actor_name(const actor *a, description_level_type desc,
- bool actor_visible);
+ bool actor_visible, bool actor_invisible);
static std::string pronoun(const actor *a, pronoun_type ptyp,
bool actor_visible);
static std::string anon_pronoun(pronoun_type ptyp);