From 5fa864a78e4ebd44189a31827edeead3f0c12597 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Sat, 7 Apr 2007 20:27:45 +0000 Subject: Implemented Erik's invisibility proposal: - M_SENSE_INVIS for perceptive monsters; split existing monsters with see invisible into M_SEE_INVIS and M_SENSE_INVIS. - Monsters that can't see invisible get to-hit penalties vs invisible players and monsters in both melee and at range. - Monsters that sense where you are know where to shoot and attack, but still get to-hit penalties because they don't know exactly where you are. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1260 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/fight.cc | 20 +++++++++++++++----- 1 file changed, 15 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 3fbc2081d7..ce615b13ce 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -2014,8 +2014,9 @@ 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 acurate. - if (you.invis && !player_see_invis()) + if (you.invis && !see_invis) your_to_hit -= 5; // fighting contribution @@ -2128,11 +2129,13 @@ int melee_attack::player_to_hit(bool random_factor) } // Check for backlight (Corona). - if (defender - && defender->atype() == ACT_MONSTER - && def->has_ench(ENCH_BACKLIGHT)) + if (defender && defender->atype() == ACT_MONSTER) { - your_to_hit += 2 + random2(8); + if (def->has_ench(ENCH_BACKLIGHT)) + your_to_hit += 2 + random2(8); + // Invisible monsters are hard to hit. + else if (def->invisible() && !see_invis) + your_to_hit -= 6; } return (your_to_hit); @@ -3068,6 +3071,13 @@ int melee_attack::mons_to_hit() if (attacker->confused()) mhit -= 5; + // Invisible defender is hard to hit if you can't see invis. Note + // 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()) + mhit = mhit * 65 / 100; + return (mhit); } -- cgit v1.2.3-54-g00ecf