From 07ef1ffe1ce0431004b79ede171f3f6bfa16549f Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Wed, 21 Oct 2009 15:42:49 +0200 Subject: 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. --- crawl-ref/source/fight.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'crawl-ref/source/fight.cc') 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 -- cgit v1.2.3-54-g00ecf