summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/fight.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-04-07 20:27:45 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-04-07 20:27:45 +0000
commit5fa864a78e4ebd44189a31827edeead3f0c12597 (patch)
tree103a4942b363bcf3a5b021d831f572f439ceca09 /crawl-ref/source/fight.cc
parent4a27714410c3f8f0f5113421a77e21a43242a0c2 (diff)
downloadcrawl-ref-5fa864a78e4ebd44189a31827edeead3f0c12597.tar.gz
crawl-ref-5fa864a78e4ebd44189a31827edeead3f0c12597.zip
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
Diffstat (limited to 'crawl-ref/source/fight.cc')
-rw-r--r--crawl-ref/source/fight.cc20
1 files changed, 15 insertions, 5 deletions
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);
}