summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/fight.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-10-21 15:42:49 +0200
committerRobert Vollmert <rvollmert@gmx.net>2009-10-22 22:37:06 +0200
commit07ef1ffe1ce0431004b79ede171f3f6bfa16549f (patch)
treebc15c42f04c5bafbb4d674addbaf8bc944c38669 /crawl-ref/source/fight.cc
parent7afa089db8b01b1810c5903309f7302545638550 (diff)
downloadcrawl-ref-07ef1ffe1ce0431004b79ede171f3f6bfa16549f.tar.gz
crawl-ref-07ef1ffe1ce0431004b79ede171f3f6bfa16549f.zip
Simply visibility checks in fight.cc.
Make use of actor::visible_to. Also fix player::visible_to to make the player invisible to himself when not seeing invisible.
Diffstat (limited to 'crawl-ref/source/fight.cc')
-rw-r--r--crawl-ref/source/fight.cc9
1 files changed, 4 insertions, 5 deletions
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 34cf5c1177..3b9ffbfdfe 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -3652,9 +3652,8 @@ int melee_attack::player_to_hit(bool random_factor)
if (wearing_amulet(AMU_INACCURACY))
your_to_hit -= 5;
- const bool see_invis = player_see_invis();
// If you can't see yourself, you're a little less accurate.
- if (you.invisible() && !see_invis)
+ if (!you.visible_to(&you))
your_to_hit -= 5;
// fighting contribution
@@ -3785,7 +3784,7 @@ int melee_attack::player_to_hit(bool random_factor)
if (defender->backlit())
your_to_hit += 2 + random2(8);
// Invisible monsters are hard to hit.
- else if (defender->invisible() && !see_invis)
+ else if (!defender->visible_to(&you))
your_to_hit -= 6;
}
@@ -4148,7 +4147,7 @@ bool melee_attack::attack_shield_blocked(bool verbose)
+ defender->shield_block_penalty());
int pro_block = defender->shield_bonus();
- if (attacker->invisible() && !defender->can_see_invisible())
+ if (!attacker->visible_to(defender))
pro_block /= 3;
#ifdef DEBUG_DIAGNOSTICS
@@ -5322,7 +5321,7 @@ int melee_attack::mons_to_hit()
// that this applies only to monsters vs monster and monster vs
// player. Does not apply to a player fighting an invisible
// monster.
- if (defender->invisible() && !attacker->can_see_invisible())
+ if (!defender->visible_to(attacker))
mhit = mhit * 65 / 100;
#ifdef DEBUG_DIAGNOSTICS